Skip to content

Commit

Permalink
iDon't define sqInt as int on 32-bits. Leave it for the 32-bit image
Browse files Browse the repository at this point in the history
format on 64 bit platforms. Using int instead of long plays havok
with printf formats.  Eliminate warnings from sqUnixMain.c's linux
ARM exception reporting code that result from the change
  • Loading branch information
eliotmiranda committed Sep 15, 2024
1 parent 3e01328 commit cf86967
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 49 deletions.
90 changes: 46 additions & 44 deletions platforms/Cross/vm/sqMemoryAccess.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* sqMemoryAccess.h -- memory accessors (and associated type definitions)
*
* Author: Ian.Piumarta@squeakland.org
*
* Last edited: 2013-10-14 12:23:39 by eliot on McStalker
* Authors: Ian Piumarta, Nicolas Cellier, David Lewis, & Eliot Miranda.
* If you feel you should be included here, let us know.
*/

/* This file defines the core types for the VM, sqInt, usqInt et al, and
Expand Down Expand Up @@ -59,42 +58,44 @@
# error host is neither 32- nor 64-bit?
#endif

/* sqInt is a signed integer with size adequate for holding an Object Oriented Pointer (or immediate value)
- that is 32bits long on a 32bits image or 64bits long on a 64bits image
we could use C99 int32_t and int64_t once retiring legacy compiler support this time has not yet come
usqInt is the unsigned flavour
SQABS is a macro for taking absolute value of an sqInt */
#if SQ_IMAGE32
typedef int sqInt;
typedef unsigned int usqInt;
#define PRIdSQINT "d"
#define PRIuSQINT "u"
#define PRIxSQINT "x"
#define PRIXSQINT "X"
# define SQABS abs
#elif SQ_HOST64 && (SIZEOF_LONG == 8)
typedef long sqInt;
typedef unsigned long usqInt;
#define PRIdSQINT "ld"
#define PRIuSQINT "lu"
#define PRIxSQINT "lx"
#define PRIXSQINT "lX"
/* sqInt is a signed integer with size adequate for holding an Object Oriented Pointer
* (or immediate value). That is 32bits in a 32bit image or 64bits in a 64bit image.
* usqInt is the unsigned flavour. SQABS is a macro for the absolute value of a sqInt.
*
* We could use C99 int32_t and int64_t once retiring legacy compiler support this
* time has not yet come.
*/
#if (SQ_IMAGE32 && (SIZEOF_LONG == 4)) || (SQ_HOST64 && (SIZEOF_LONG == 8))
typedef long sqInt;
typedef unsigned long usqInt;
# define PRIdSQINT "ld"
# define PRIuSQINT "lu"
# define PRIxSQINT "lx"
# define PRIXSQINT "lX"
# define SQABS labs
#elif SQ_IMAGE32
typedef int sqInt;
typedef unsigned int usqInt;
# define PRIdSQINT "d"
# define PRIuSQINT "u"
# define PRIxSQINT "x"
# define PRIXSQINT "X"
# define SQABS abs
#elif (SIZEOF_LONG_LONG != 8)
# error long long integers are not 64-bits wide?
#else
typedef long long sqInt;
typedef unsigned long long usqInt;
#define PRIdSQINT "lld"
#define PRIuSQINT "llu"
#define PRIxSQINT "llx"
#define PRIXSQINT "llX"
typedef long long sqInt;
typedef unsigned long long usqInt;
# define PRIdSQINT "lld"
# define PRIuSQINT "llu"
# define PRIxSQINT "llx"
# define PRIXSQINT "llX"
# define SQABS llabs
#endif

/* sqLong is a signed integer with at least 64bits on both 32 and 64 bits images
usqLong is the unsigned flavour
SQLABS is a macro for taking absolute value of a sqLong */
/* sqLong is a signed integer with at least 64bits on both 32 and 64 bit platforms.
* usqLong is the unsigned flavour. SQLABS is a macro for the absolute value of a sqLong
*/
#if !defined(sqLong)
# if SIZEOF_LONG == 8
# define sqLong long
Expand All @@ -111,24 +112,25 @@
# endif
#endif /* !defined(sqLong) */

/* sqIntptr_t is a signed integer with enough bits to hold a pointer
usqIntptr_t is the unsigned flavour
this is essentially C99 intptr_t and uintptr_t but we support legacy compilers
the C99 printf formats macros are also defined with SQ prefix */
/* sqIntptr_t is a signed integer with enough bits to hold a pointer (a void *).
* usqIntptr_t is the unsigned flavour.
* this is essentially C99 intptr_t and uintptr_t but we support legacy compilers
* the C99 printf formats macros are also defined with SQ prefix
*/
#if SIZEOF_LONG == SIZEOF_VOID_P
typedef long sqIntptr_t;
typedef unsigned long usqIntptr_t;
#define PRIdSQPTR "ld"
#define PRIuSQPTR "lu"
#define PRIxSQPTR "lx"
#define PRIXSQPTR "lX"
# define PRIdSQPTR "ld"
# define PRIuSQPTR "lu"
# define PRIxSQPTR "lx"
# define PRIXSQPTR "lX"
#else
typedef long long sqIntptr_t;
typedef unsigned long long usqIntptr_t;
#define PRIdSQPTR "lld"
#define PRIuSQPTR "llu"
#define PRIxSQPTR "llx"
#define PRIXSQPTR "llX"
# define PRIdSQPTR "lld"
# define PRIuSQPTR "llu"
# define PRIxSQPTR "llx"
# define PRIXSQPTR "llX"
#endif

#if SQ_HOST64 && SQ_IMAGE32
Expand Down
10 changes: 5 additions & 5 deletions platforms/unix/vm/sqUnixMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1092,12 +1092,12 @@ printRegisterState(FILE *file,ucontext_t *uap)
v(uap->uc_mcontext.fault_address));
return v(uap->uc_mcontext.pc);
# elif __linux__ && (defined(__arm__) || defined(__arm32__) || defined(ARM32))
struct sigcontext *regs = &uap->uc_mcontext;
struct sigcontext *regs = (struct sigcontext *)&uap->uc_mcontext;
fprintf(file,
"\t r0 0x%08x r1 0x%08x r2 0x%08x r3 0x%08x\n"
"\t r4 0x%08x r5 0x%08x r6 0x%08x r7 0x%08x\n"
"\t r8 0x%08x r9 0x%08x r10 0x%08x fp 0x%08x\n"
"\t ip 0x%08x sp 0x%08x lr 0x%08x pc 0x%08x\n",
"\t r0 0lx%08lx r1 0lx%08lx r2 0lx%08lx r3 0lx%08lx\n"
"\t r4 0lx%08lx r5 0lx%08lx r6 0lx%08lx r7 0lx%08lx\n"
"\t r8 0lx%08lx r9 0lx%08lx r10 0lx%08lx fp 0lx%08lx\n"
"\t ip 0lx%08lx sp 0lx%08lx lr 0lx%08lx pc 0lx%08lx\n",
regs->arm_r0,regs->arm_r1,regs->arm_r2,regs->arm_r3,
regs->arm_r4,regs->arm_r5,regs->arm_r6,regs->arm_r7,
regs->arm_r8,regs->arm_r9,regs->arm_r10,regs->arm_fp,
Expand Down

0 comments on commit cf86967

Please sign in to comment.