[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Memory alignment of pointers for sparc64



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 *).  (Actually the original
programmer used sizeof(long) ).  So on 4 byte machines you would get
pointers that end in 0, 4, 8, and C hex.  On DEC alpha sizeof(void *) == 8
so the pointers low byte is 0 and 8.

Now the problem is that on sparc64 sizeof(void *) == 4 but we need to align
our pointers on 8-byte boundaries otherwise we get SIGBUS errors.

So, can anyone suggest a way in C to test for this?  Something like

#if defined(__sparc64__)
#  define PointerAlign 8
#else
#  define PointerAlign sizeof( void * )
#endif

My C skills are not great, and I know much less about porting.  So it would
be great to find a reasonably potable way to set the align size -- any
suggestions are more than welcome.  Thanks.


-- 
Bill Moseley
mailto:moseley@hank.org



Reply to: