gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcl-devel] Patch: don't #include inside a function


From: Jerry James
Subject: [Gcl-devel] Patch: don't #include inside a function
Date: Tue, 4 Nov 2008 09:04:46 -0700

I'm taking over maintainership of the Fedora GCL package, effective
today.  I've grabbed the current Debian patch.  Even with that patch,
I'm getting a build failure, due to h/unrandomize.h.  Essentially, it
is not possible to #include <unistd.h> inside a function when
compiling with both optimization and -D_FORTIFY_SOURCE.  When I
complained about this to the glibc maintainers, they replied:

  Then GCL is buggy.  Standard headers are never meant to be included
  inside of a function.  E.g. ISO C99 says in 7.1.2/4:
  ... "If used, a header shall be included outside of any external
declaration or
  definition, and it shall first be included before the first
reference to any of
  the functions or objects it declares, or to any of the types or macros it
  defines."...

So here is a patch to move the #include statements out of functions.
After applying this patch, configure will need to be regenerated.

diff -dur gcl-2.6.7.ORIG/configure.in gcl-2.6.7/configure.in
--- gcl-2.6.7.ORIG/configure.in 2008-11-03 16:58:14.000000000 -0700
+++ gcl-2.6.7/configure.in      2008-11-04 08:58:03.000000000 -0700
@@ -1032,7 +1032,11 @@
        fi

        AC_MSG_CHECKING([for personality(ADDR_NO_RANDOMIZE) support])
-       AC_TRY_RUN([void gprof_cleanup() {};
+       AC_TRY_RUN([#include <sys/personality.h>
+                   #include <syscall.h>
+                   #include <unistd.h>
+                   #include <alloca.h>
+                   void gprof_cleanup() {};
                    int main(int argc,char *argv[],char *envp[]) {
                    #include "h/unrandomize.h"
                    return 
0;}],CAN_UNRANDOMIZE_SBRK=1,CAN_UNRANDOMIZE_SBRK=0,CAN_UNRANDOMIZE_SBRK=0)
diff -dur gcl-2.6.7.ORIG/h/unrandomize.h gcl-2.6.7/h/unrandomize.h
--- gcl-2.6.7.ORIG/h/unrandomize.h      2008-11-03 16:58:16.000000000 -0700
+++ gcl-2.6.7/h/unrandomize.h   2008-11-04 08:58:24.000000000 -0700
@@ -1,8 +1,3 @@
-#include <sys/personality.h>
-#include <syscall.h>
-#include <unistd.h>
-#include <alloca.h>
-
 {

   long pers = personality(0xffffffffUL);
diff -dur gcl-2.6.7.ORIG/o/main.c gcl-2.6.7/o/main.c
--- gcl-2.6.7.ORIG/o/main.c     2008-11-03 16:58:56.000000000 -0700
+++ gcl-2.6.7/o/main.c  2008-11-04 09:00:38.000000000 -0700
@@ -27,6 +27,11 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
+#ifdef CAN_UNRANDOMIZE_SBRK
+#include <sys/personality.h>
+#include <syscall.h>
+#include <alloca.h>
+#endif

 static void
 init_main(void);

Regards,
-- 
Jerry James
http://loganjerry.googlepages.com/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]