PATCH: libgomp/25877: Add alloca.h header file.

Steve Ellcey sje@cup.hp.com
Fri Jan 20 21:36:00 GMT 2006


> On Fri, Jan 20, 2006 at 10:21:07AM -0800, Steve Ellcey wrote:
> > FYI:  After getting some more email from Paolo I went ahead and checked
> > in the oringal patch as approved by Diego.  I did not change it to use
> > AC_FUNC_ALLOCA.
> 
> Please don't use <alloca.h>.  Please #define alloca to 
> __builtin_alloca, as we do in libgfortran.
> 
> 
> r~

OK, Here is patch that undoes the earlier one and defines gomp_alloca to
be __builtin_alloca (in libgomp.h) and then uses that in team.c.  That
seems to mimic what libgfortran does.  I haven't tested it yet.  Is this
what you are looking for?

2006-01-20  Steve Ellcey  <sje@cup.hp.com>

	PR libgomp/25877
	* configure.ac: Remove check for alloca.h
	* libgomp.h: define gomp_alloca to be __builtin_alloca.
	* team.c: Remove use of alloca.h.
	Call gomp_alloca instead of alloca.

Index: configure.ac
===================================================================
--- configure.ac	(revision 110039)
+++ configure.ac	(working copy)
@@ -136,7 +136,7 @@ AC_SUBST(libtool_VERSION)
 # Check header files.
 AC_STDC_HEADERS
 AC_HEADER_TIME
-AC_CHECK_HEADERS(alloca.h unistd.h semaphore.h sys/time.h)
+AC_CHECK_HEADERS(unistd.h semaphore.h sys/time.h)
 AC_CHECK_HEADER([pthread.h],[],
   [AC_MSG_ERROR([Pthreads are required to build libgomp])])
 
Index: libgomp.h
===================================================================
--- libgomp.h	(revision 110039)
+++ libgomp.h	(working copy)
@@ -250,6 +250,10 @@ extern void *gomp_malloc (size_t) __attr
 extern void *gomp_malloc_cleared (size_t) __attribute__((malloc));
 extern void *gomp_realloc (void *, size_t);
 
+/* Avoid conflicting prototypes of alloca() in system headers by using
+   GCC's builtin alloca().  */
+#define gomp_alloca(x)  __builtin_alloca(x)
+
 /* error.c */
 
 extern void gomp_error (const char *, ...)
Index: team.c
===================================================================
--- team.c	(revision 110039)
+++ team.c	(working copy)
@@ -32,11 +32,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef HAVE_ALLOCA_H
-# include <alloca.h>
-#endif
-
-
 /* This array manages threads spawned from the top level, which will
    return to the idle loop once the current PARALLEL construct ends.  */
 static struct gomp_thread **gomp_threads;
@@ -270,7 +265,8 @@ gomp_team_start (void (*fn) (void *), vo
 	}
     }
 
-  start_data = alloca (sizeof (struct gomp_thread_start_data) * (nthreads-i));
+  start_data = gomp_alloca (sizeof (struct gomp_thread_start_data)
+			    * (nthreads-i));
 
   /* Launch new threads.  */
   for (; i < nthreads; ++i, ++start_data)



More information about the Gcc-patches mailing list