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

Re: Memory alignment of pointers for sparc64



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 *).  (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.

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).

Why not force minimum 8byte allocations? Will it really cause that much
of a usage problem? Would probably cause less fragmentation, I bet.
Guess you could do:

#ifdef __sparc__
# define PointerAlign 8
#else
# define PointerAlign sizeof(void *)
#endif


What was wrong with the original usage of sizeof(long)?


-- 
Debian     - http://www.debian.org/
Linux 1394 - http://linux1394.sourceforge.net/
Subversion - http://subversion.tigris.org/
Deqo       - http://www.deqo.com/



Reply to: