|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: Jay Estabrook (Jay.Estabrook
hp.com)
Date: Sun Apr 27 2008 - 10:05:27 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Sigh...
I knew it was too early on a Sunday morning for this... ;-}
Estabrook, Jay wrote:
>
> The poor programming practice (hal) arises from assuming that all
> architectures have a natural boundary of 32-bits. Something like
> the following are indicative:
>
> pointer = (void *)((((char *)address) + 3) & ~3);
Should be:
pointer = (void *)((((char *)address) + 4) & ~3);
which rounds UP to the next 32-bit natural boundary.
>
> Better is:
>
> #define SZM (sizeof(void*)-1)
> pointer = (void *)((((char *)address) + SZM) & ~SZM);
And this should be:
#define SZ (sizeof(void*))
#define SZM (SZ-1)
pointer = (void *)((((char *)address) + SZ) & ~SZM);
which also rounds UP.
Now back to the funny pages... ;-}
--Jay++
_______________________________________________
axp-list mailing list
axp-list
redhat.com
https://www.redhat.com/mailman/listinfo/axp-list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]