From e513b5f9b7d334925d09b7f05477b54719defdd2 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 18 Sep 2001 09:59:28 +0000 Subject: * objalloc.h (OBJALLOC_ALIGN): Define using offsetof. --- include/objalloc.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'include/objalloc.h') diff --git a/include/objalloc.h b/include/objalloc.h index 0b451cdc2..c7106478d 100644 --- a/include/objalloc.h +++ b/include/objalloc.h @@ -1,5 +1,5 @@ /* objalloc.h -- routines to allocate memory for objects - Copyright 1997 Free Software Foundation, Inc. + Copyright 1997, 2001 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Solutions. This program is free software; you can redistribute it and/or modify it @@ -56,12 +56,11 @@ struct objalloc_align { char x; double d; }; #ifndef offsetof #include #endif -#define OBJALLOC_ALIGN \ - ((ptrdiff_t) ((char *) &((struct objalloc_align *) 0)->d - (char *) 0)) -#else -#define OBJALLOC_ALIGN \ - ((long) ((char *) &((struct objalloc_align *) 0)->d - (char *) 0)) #endif +#ifndef offsetof +#define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER) +#endif +#define OBJALLOC_ALIGN offsetof (struct objalloc_align, d) /* Create an objalloc structure. Returns NULL if malloc fails. */ -- cgit v1.2.3