Mail Archives: djgpp-workers/2004/11/10/16:12:14
The short test program attached at the end of this message prints
zero values on Windows 98, but a user who tried it on XP told me it
printed "4", which means that __attribute__((__aligned__)) is not
working on XP.
The assembly emitted by GCC is okay, so I suspect that the XP DPMI
host somehow screws up our alignment. Any ideas why this happens or
how to overcome it?
In case you are curious, this comes from Emacs which needs to have
certain variables aligned on 8-byte boundary to be able to use the
low-order bits of their address for Lisp data type tags. Previously,
high-order bits were used, but that limited the maximum size of a
buffer to 128MB, while with LSB tags we can go as far as 256MB. So
I'd like to have this problem solved on XP as well, if at all
possible.
-------------------------------------------------------------------
#include <stdio.h>
#define GCTYPEBITS 3
# define DECL_ALIGN(type, var) \
type __attribute__ ((__aligned__ (1 << GCTYPEBITS))) var
struct SS
{
char *ptr;
long nr;
};
DECL_ALIGN (struct SS, ss1);
DECL_ALIGN (struct SS, ss2);
DECL_ALIGN (struct SS, ss3);
DECL_ALIGN (struct SS, ss4);
int
main ()
{
int rem;
rem = (unsigned long)&ss1 % 8;
printf ("ss1: rem %d\n", rem);
rem = (unsigned long)&ss2 % 8;
printf ("ss2: rem %d\n", rem);
rem = (unsigned long)&ss3 % 8;
printf ("ss3: rem %d\n", rem);
rem = (unsigned long)&ss4 % 8;
printf ("ss4: rem %d\n", rem);
return 0;
}
- Raw text -