diff options
author | Alan Modra <amodra@bigpond.net.au> | 2001-09-18 13:39:40 +0000 |
---|---|---|
committer | Alan Modra <amodra@gcc.gnu.org> | 2001-09-18 23:09:40 +0930 |
commit | b9bc4bf6de6b9ee79b92d2702fa5137c387c249c (patch) | |
tree | 76b22daab5767c28829e58824fe43224587f6130 /include/objalloc.h | |
parent | d71ebc326b4ae6bdec7bce1402cf69e64202b1b2 (diff) | |
download | gcc-b9bc4bf6de6b9ee79b92d2702fa5137c387c249c.zip gcc-b9bc4bf6de6b9ee79b92d2702fa5137c387c249c.tar.gz gcc-b9bc4bf6de6b9ee79b92d2702fa5137c387c249c.tar.bz2 |
* objalloc.h (OBJALLOC_ALIGN): Define using offsetof.
From-SVN: r45677
Diffstat (limited to 'include/objalloc.h')
-rw-r--r-- | include/objalloc.h | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/include/objalloc.h b/include/objalloc.h index 0b451cd..c710647 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 <stddef.h> #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. */ |