This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

long long considered harmful?

Below is a clipping from our debug.h header which defines the register
structures for QNX Neutrino.  I've been in conversation with Mark Kettenis
about our gdb submission and it looks like portability issues in this header
are one of the few remaining stumbling blocks, at least from his
perspective.  I guess that conceivably some older systems might not be able
to deal with a 64 bit int type.  The question I want to ask is, "how do I
deal with this in a portable way?"

I don't believe that any of these structures are ever manipulated in any way
other than to read/write bytes of data into and out of them.  Would it be
best just to define any long long members as arrays of char?  It doesn't
seem very pretty but it would certainly do the trick.

ie. "char u64[8]" instead of "long long u64" is fine but "char gpr_hi[32 *
8]" instead of "long long gpr_hi[32]" seems a bit nasty.



>>>>>>>>>>>>>debug.h clip<<<<<<<<<<<<<<<<<<<<<
typedef union
  unsigned long long u64;
  double f;
} mipsfloat;

typedef struct mips_cpu_registers
  unsigned regs[74];
  unsigned long long regs_alignment;

typedef struct mips_fpu_registers
  mipsfloat fpr[32];
  unsigned fpcr31;

typedef struct mips_alt_registers
    struct mips_tx79
      unsigned long long gpr_hi[32];
      unsigned long long lo1;
      unsigned long long hi1;
      unsigned sa;
    } tx79;
  } un;

#ifdef __BIGREGS__
typedef unsigned long long ppcint;
typedef unsigned ppcint;

typedef union
  unsigned long long u64;
  double f;
} ppcfloat;

typedef union
  unsigned long long u64[2];
  unsigned u32[4];
  unsigned char u8[16];
  float f32[4];
} ppcvmx;

typedef struct ppc_cpu_registers
  ppcint gpr[32];
  ppcint ctr;
  ppcint lr;
  ppcint msr;
  ppcint iar;
  unsigned cr;
  unsigned xer;
  unsigned ear;   /* Not present on all chips.  */
  unsigned mq;   /* Only on the 601.  */
  unsigned vrsave;  /* On Altivec CPU's, SPR256.  */

typedef struct ppc_fpu_registers
  ppcfloat fpr[32];
  unsigned fpscr;
  unsigned fpscr_val;
  /* Load/store of fpscr is done through fprs, the real value is in [32,63]
of a fpr.
     Fpscr is the address for lfd, stfd. fpscr_val is the real value of
fpscr.  */

typedef struct ppc_vmx_registers
  ppcvmx vmxr[32];
  ppcvmx vscr;

typedef struct ppc_alt_registers

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]