* [PATCH 1/7] sim: ppc: switch to libiberty environ.h
@ 2021-11-07 1:12 Mike Frysinger
2021-11-07 1:12 ` [PATCH 2/7] sim: arm/bfin/rx: undefine page size from system headers Mike Frysinger
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Mike Frysinger @ 2021-11-07 1:12 UTC (permalink / raw)
To: gdb-patches
Drop our compat code and assume environ exists to simplify.
We did this for all other targets already, but ppc was missed.
---
sim/ppc/main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sim/ppc/main.c b/sim/ppc/main.c
index d9a40700973d..83b629ec14aa 100644
--- a/sim/ppc/main.c
+++ b/sim/ppc/main.c
@@ -42,14 +42,14 @@
#include <string.h>
#include <errno.h>
+#include "environ.h"
+
#if !defined(O_NONBLOCK) || !defined(F_GETFL) || !defined(F_SETFL)
#undef WITH_STDIO
#define WITH_STDIO DO_USE_STDIO
#endif
-extern char **environ;
-
static psim *simulation = NULL;
--
2.33.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/7] sim: arm/bfin/rx: undefine page size from system headers
2021-11-07 1:12 [PATCH 1/7] sim: ppc: switch to libiberty environ.h Mike Frysinger
@ 2021-11-07 1:12 ` Mike Frysinger
2021-11-07 1:12 ` [PATCH 3/7] sim: sh: fix isnan redefinition with mingw targets Mike Frysinger
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2021-11-07 1:12 UTC (permalink / raw)
To: gdb-patches
Some targets (like cygwin) will export page size defines that clash
with our local usage here. Undefine the system one to fix building
for these targets.
---
sim/arm/armvirt.c | 1 +
sim/bfin/dv-bfin_mmu.h | 2 ++
sim/rx/mem.h | 2 ++
3 files changed, 5 insertions(+)
diff --git a/sim/arm/armvirt.c b/sim/arm/armvirt.c
index ba01a652ebcc..c162ba79e9b7 100644
--- a/sim/arm/armvirt.c
+++ b/sim/arm/armvirt.c
@@ -46,6 +46,7 @@
#endif
+#undef PAGESIZE /* Cleanup system headers. */
#define NUMPAGES 64 * 1024
#define PAGESIZE 64 * 1024
#define PAGEBITS 16
diff --git a/sim/bfin/dv-bfin_mmu.h b/sim/bfin/dv-bfin_mmu.h
index 2405f2818ba0..408b392b6860 100644
--- a/sim/bfin/dv-bfin_mmu.h
+++ b/sim/bfin/dv-bfin_mmu.h
@@ -21,6 +21,8 @@
#ifndef DV_BFIN_MMU_H
#define DV_BFIN_MMU_H
+#undef PAGE_SIZE /* Cleanup system headers. */
+
void mmu_check_addr (SIM_CPU *, bu32 addr, bool write, bool inst, int size);
void mmu_check_cache_addr (SIM_CPU *, bu32 addr, bool write, bool inst);
void mmu_process_fault (SIM_CPU *, bu32 addr, bool write, bool inst, bool unaligned, bool miss);
diff --git a/sim/rx/mem.h b/sim/rx/mem.h
index a4c7455a20d9..15bb5573fae1 100644
--- a/sim/rx/mem.h
+++ b/sim/rx/mem.h
@@ -37,6 +37,8 @@ void init_mem (void);
void mem_usage_stats (void);
unsigned long mem_usage_cycles (void);
+#undef PAGE_SIZE /* Cleanup system headers. */
+
/* rx_mem_ptr returns a pointer which is valid as long as the address
requested remains within the same page. */
#define PAGE_BITS 12
--
2.33.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/7] sim: sh: fix isnan redefinition with mingw targets
2021-11-07 1:12 [PATCH 1/7] sim: ppc: switch to libiberty environ.h Mike Frysinger
2021-11-07 1:12 ` [PATCH 2/7] sim: arm/bfin/rx: undefine page size from system headers Mike Frysinger
@ 2021-11-07 1:12 ` Mike Frysinger
2021-11-07 1:12 ` [PATCH 4/7] sim: sh: drop errno extern Mike Frysinger
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2021-11-07 1:12 UTC (permalink / raw)
To: gdb-patches
The code assumes that all _WIN32 targets are the same and can
define isnan to _isnan. For mingw targets, they provide an isnan
define already, so no need for the fallback here.
---
sim/sh/interp.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index 2bae4484e349..c4ac5b3e66b1 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -65,8 +65,10 @@
#ifdef _WIN32
#include <float.h> /* Needed for _isnan() */
+#ifndef isnan
#define isnan _isnan
#endif
+#endif
#ifndef SIGBUS
#define SIGBUS SIGSEGV
--
2.33.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 4/7] sim: sh: drop errno extern
2021-11-07 1:12 [PATCH 1/7] sim: ppc: switch to libiberty environ.h Mike Frysinger
2021-11-07 1:12 ` [PATCH 2/7] sim: arm/bfin/rx: undefine page size from system headers Mike Frysinger
2021-11-07 1:12 ` [PATCH 3/7] sim: sh: fix isnan redefinition with mingw targets Mike Frysinger
@ 2021-11-07 1:12 ` Mike Frysinger
2021-11-07 1:12 ` [PATCH 5/7] sim: sh: break utime logic out of _WIN32 check Mike Frysinger
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2021-11-07 1:12 UTC (permalink / raw)
To: gdb-patches
This isn't needed on any reasonable target nowadays, and no other
source does this, and breaks with some mingw targets, so punt the
extern entirely.
---
sim/sh/interp.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index c4ac5b3e66b1..ce4d6cd76032 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -879,7 +879,6 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
}
case 34:
{
- extern int errno;
int perrno = errno;
errno = 0;
--
2.33.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 5/7] sim: sh: break utime logic out of _WIN32 check
2021-11-07 1:12 [PATCH 1/7] sim: ppc: switch to libiberty environ.h Mike Frysinger
` (2 preceding siblings ...)
2021-11-07 1:12 ` [PATCH 4/7] sim: sh: drop errno extern Mike Frysinger
@ 2021-11-07 1:12 ` Mike Frysinger
2021-11-07 1:12 ` [PATCH 6/7] sim: sh: clean up time(NULL) call Mike Frysinger
2021-11-07 1:12 ` [PATCH 7/7] sim: sh: fix conversion of PC to an integer Mike Frysinger
5 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2021-11-07 1:12 UTC (permalink / raw)
To: gdb-patches
Some _WIN32 targets provide utime (like mingw), so move the header
include out from _WIN32 and under the specific HAVE_UTIME_H check.
---
sim/sh/interp.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index ce4d6cd76032..c1b05ddf620c 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -45,8 +45,10 @@
#endif
#include <time.h>
#include <sys/time.h>
-#ifndef _WIN32
+#ifdef HAVE_UTIME_H
#include <utime.h>
+#endif
+#ifndef _WIN32
#include <sys/wait.h>
#endif
@@ -1024,7 +1026,12 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
int len = strswaplen (regs[5]);
strnswap (regs[5], len);
+#ifdef HAVE_UTIME_H
regs[0] = utime (ptr (regs[5]), (void *) ptr (regs[6]));
+#else
+ errno = ENOSYS;
+ regs[0] = -1;
+#endif
strnswap (regs[5], len);
break;
}
--
2.33.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 6/7] sim: sh: clean up time(NULL) call
2021-11-07 1:12 [PATCH 1/7] sim: ppc: switch to libiberty environ.h Mike Frysinger
` (3 preceding siblings ...)
2021-11-07 1:12 ` [PATCH 5/7] sim: sh: break utime logic out of _WIN32 check Mike Frysinger
@ 2021-11-07 1:12 ` Mike Frysinger
2021-11-07 1:12 ` [PATCH 7/7] sim: sh: fix conversion of PC to an integer Mike Frysinger
5 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2021-11-07 1:12 UTC (permalink / raw)
To: gdb-patches
Casting 0 to a pointer via (long *) doesn't work on LLP64 targets:
error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
It's also unnecessary here. We can simply pass NULL like every other
bit of code does.
---
sim/sh/interp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index c1b05ddf620c..c502b21b49f2 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -761,7 +761,7 @@ IOMEM (int addr, int write, int value)
static int
get_now (void)
{
- return time ((long *) 0);
+ return time (NULL);
}
static int
--
2.33.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 7/7] sim: sh: fix conversion of PC to an integer
2021-11-07 1:12 [PATCH 1/7] sim: ppc: switch to libiberty environ.h Mike Frysinger
` (4 preceding siblings ...)
2021-11-07 1:12 ` [PATCH 6/7] sim: sh: clean up time(NULL) call Mike Frysinger
@ 2021-11-07 1:12 ` Mike Frysinger
5 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2021-11-07 1:12 UTC (permalink / raw)
To: gdb-patches
On LLP64 targets where sizeof(long) != sizeof(void*), this code fails:
sim/sh/interp.c:704:24: error: cast from pointer to integer of different size -Werror=pointer-to-int-cast]
704 | do { memstalls += ((((long) PC & 3) != 0) ? (n) : ((n) - 1)); } while (0)
| ^
Since this code simply needs to check alignment, cast it using uintptr_t
which is the right type for this.
---
sim/sh/interp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index c502b21b49f2..93923fa2c56c 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -701,7 +701,7 @@ do { \
#else
#define MA(n) \
- do { memstalls += ((((long) PC & 3) != 0) ? (n) : ((n) - 1)); } while (0)
+ do { memstalls += ((((uintptr_t) PC & 3) != 0) ? (n) : ((n) - 1)); } while (0)
#define L(x) thislock = x;
#define TL(x) if ((x) == prevlock) stalls++;
--
2.33.0
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-11-07 1:12 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-07 1:12 [PATCH 1/7] sim: ppc: switch to libiberty environ.h Mike Frysinger
2021-11-07 1:12 ` [PATCH 2/7] sim: arm/bfin/rx: undefine page size from system headers Mike Frysinger
2021-11-07 1:12 ` [PATCH 3/7] sim: sh: fix isnan redefinition with mingw targets Mike Frysinger
2021-11-07 1:12 ` [PATCH 4/7] sim: sh: drop errno extern Mike Frysinger
2021-11-07 1:12 ` [PATCH 5/7] sim: sh: break utime logic out of _WIN32 check Mike Frysinger
2021-11-07 1:12 ` [PATCH 6/7] sim: sh: clean up time(NULL) call Mike Frysinger
2021-11-07 1:12 ` [PATCH 7/7] sim: sh: fix conversion of PC to an integer Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).