Re: Memory alignment of pointers for sparc64

2002-09-05 Thread Dave Love
If I understand correctly, how about `__alignof__', utilizing GCC's knowledge of the architecture? $ cat a.c #include #ifdef __GNUC__ size_t alignment = __alignof__ (double); #else size_t alignment = 8; #endif main () { printf ("%d\n", alignment); exit (0); } $ arch && cc a.c && ./a.out i586 4

Re: Memory alignment of pointers for sparc64

2002-09-05 Thread Bill Moseley
At 02:16 PM 09/05/02 -0600, Jason Gunthorpe wrote: > >On Thu, 5 Sep 2002, Bill Moseley wrote: > >> >> Here's where it's blowing up: >> >> struct dev_ino *p; >> struct stat buf; >> ... >> // allocate a bit of memory from the pool. >> p = (struct dev_ino *) Mem_ZoneAlloc( >>

Re: Memory alignment of pointers for sparc64

2002-09-05 Thread Jason Gunthorpe
On Thu, 5 Sep 2002, Bill Moseley wrote: > > Here's where it's blowing up: > > struct dev_ino *p; > struct stat buf; > ... > // allocate a bit of memory from the pool. > p = (struct dev_ino *) Mem_ZoneAlloc( > sw->Index->entryZone,sizeof(struct dev_ino)); > >

Re: Memory alignment of pointers for sparc64

2002-09-05 Thread Bill Moseley
At 10:57 AM 09/05/02 -0600, Jason Gunthorpe wrote: >AFAIK on 32 bit SPARC, like you are using (and on other platforms, like >MIPS, etc) you often need to align structures on 8 bytes for floating >point members. doubles have to be aligned on their size generally. Ok, so it's based on the data you a

Re: Memory alignment of pointers for sparc64

2002-09-05 Thread Jason Gunthorpe
On Thu, 5 Sep 2002, Bill Moseley wrote: > About all I understand of this problem is that our code allocates memory > on 4-byte boundaries, and that cased SIGBUS on this one machine. I > printed out the results of malloc() calls and noticed it was always on > 8-byte boundaries. Hard-coding to 8-

Re: Memory alignment of pointers for sparc64

2002-09-05 Thread Bill Moseley
At 09:17 AM 09/05/02 -0400, Michael J. Saletnik wrote: >On September 4, 2002 at 23:06, Bill Moseley wrote: > > the allocated pointers based on the sizeof(void *). > >On September 5, 2002 at 08:13, Ben Collins wrote: > > What was wrong with the original usage of sizeof(long)? > >Wouldn't it be most

Re: Memory alignment of pointers for sparc64

2002-09-05 Thread Bill Moseley
On Thu, 5 Sep 2002, Ben Collins wrote: > On Wed, Sep 04, 2002 at 11:06:04PM -0700, Bill Moseley wrote: > > I'm pretty sure you mean sparc and not sparc64 (even if you are running > an ultra, it is still 32bit userspace). On sparc64, sizeof(void *) does > in fact equal 8bytes (64bit bins). Well,

Re: Memory alignment of pointers for sparc64

2002-09-05 Thread Michael J. Saletnik
On September 4, 2002 at 23:06, Bill Moseley wrote: > the allocated pointers based on the sizeof(void *). On September 5, 2002 at 08:13, Ben Collins wrote: > What was wrong with the original usage of sizeof(long)? Wouldn't it be most "correct" to use sizeof(caddr_t) ? -- {michael}

Re: Memory alignment of pointers for sparc64

2002-09-05 Thread Ben Collins
> Swish-e allocates memory from a memory pool. The application byte-aligns > the allocated pointers based on the sizeof(void *). (Actually the original Oh, one other thing you may want to look at is obstack. Glibc contains the functions internally, but you can also grab obstack.[ch] from the gli

Re: Memory alignment of pointers for sparc64

2002-09-05 Thread Ben Collins
On Wed, Sep 04, 2002 at 11:06:04PM -0700, Bill Moseley wrote: > Hi, > > I was trying to build the C application swish-e on the Sourceforge Sun > Ultra60 - Debian 3.0. > > Swish-e allocates memory from a memory pool. The application byte-aligns > the allocated pointers based on the sizeof(void *)