This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [3.4] Fix PR fortran/17180


> BIGGEST_ALIGNMENT may be non-constant.  I think for the support
> library you need to do
>
> struct test_alignment
> {
>   char x __attribute__((aligned));
> };
>
> #define MALLOC_ALIGNMENT	(sizeof (struct test_alignment))

I now think the patch is not really correct because the pool is used on the 
host, not on the target if I understand correctly the F77 code.

So something modelled on ggc-page.c is probably needed.


2004-09-02  Eric Botcazou  <ebotcazou@libertysurf.fr>

        PR fortran/17180
	* malloc.c (MALLOC_ALIGNMENT): Rename into MAX_ALIGNMENT
	and use a host-based heuristics to determine it.
	(ROUNDED_AREA_SIZE): Adjust.


-- 
Eric Botcazou
Index: malloc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/Attic/malloc.c,v
retrieving revision 1.12.14.2
diff -u -r1.12.14.2 malloc.c
--- malloc.c	1 Sep 2004 07:23:11 -0000	1.12.14.2
+++ malloc.c	2 Sep 2004 06:39:50 -0000
@@ -83,8 +83,16 @@
 
 /* Internal macros. */
 
-#define MALLOC_ALIGNMENT  (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
-#define ROUNDED_AREA_SIZE (MALLOC_ALIGNMENT * ((sizeof(mallocArea_) + MALLOC_ALIGNMENT - 1) / MALLOC_ALIGNMENT))
+struct max_alignment {
+  char c;
+  union {
+    HOST_WIDEST_INT i;
+    long double d;
+  } u;
+};
+
+#define MAX_ALIGNMENT (offsetof (struct max_alignment, u))
+#define ROUNDED_AREA_SIZE (MAX_ALIGNMENT * ((sizeof(mallocArea_) + MAX_ALIGNMENT - 1) / MAX_ALIGNMENT))
 
 #if MALLOC_DEBUG
 #define malloc_kill_(ptr,s) do {memset((ptr),127,(s));free((ptr));} while(0)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]