This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
OBJALLOC_ALIGN change
- To: gcc-patches at gcc dot gnu dot org
- Subject: OBJALLOC_ALIGN change
- From: Alan Modra <amodra at bigpond dot net dot au>
- Date: Tue, 18 Sep 2001 23:15:11 +0930
Approved by DJ Delorie in private email, committing to mainline.
Fixes some signed/unsigned warnings in binutils.
include/ChangeLog
* objalloc.h (OBJALLOC_ALIGN): Define using offsetof.
--
Alan Modra
Index: include/objalloc.h
===================================================================
RCS file: /cvs/gcc/gcc/include/objalloc.h,v
retrieving revision 1.2
diff -u -p -r1.2 objalloc.h
--- objalloc.h 1999/01/11 13:51:10 1.2
+++ objalloc.h 2001/09/18 13:38:25
@@ -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. */