patch to autoconfiscate vfork handling

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Fri Oct 30 07:31:00 GMT 1998


	This patch adds autoconf support for vfork instead of checking
macro USG.  I included changes to the gcc dir (for collect2.c) as well
as a libiberty dir change (for pexecute.c) in this one file since they
go together and were relatively small.


	The libiberty/pexecute.c changes didn't require using
AC_FUNC_VFORK since libiberty/configure.in already calls it. 

	Okay to install?

		--Kaveh




Fri Oct 30 10:05:40 1998  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* configure.in: Call AC_FUNC_VFORK.

	* collect2.c: Define VFORK_STRING as a printable string for
 	error messages (either "vfork" or "fork".)  If HAVE_VFORK_H is
 	defined, include vfork.h.  If VMS is defined, define vfork()
	appropriately.  Remove vfork check on USG, we're using autoconf.
	(collect_execute): Pass VFORK_STRING to fatal_perror instead of
	checking locally what string to pass.
	(scan_prog_file): Likewise.
	(scan_libraries): Likewise.

	* gcc.c: Remove vfork check on USG, we're using autoconf.
	Besides, no calls to vfork/fork occur in this file.

	* protoize.c: Likewise.


diff -rup orig/egcs-CVS19981029/gcc/configure.in egcs-CVS19981029/gcc/configure.in
--- orig/egcs-CVS19981029/gcc/configure.in	Thu Oct 29 17:26:07 1998
+++ egcs-CVS19981029/gcc/configure.in	Thu Oct 29 17:46:45 1998
@@ -365,6 +365,7 @@ AC_CHECK_FUNCS(strtoul bsearch strerror 
 
 GCC_FUNC_VFPRINTF_DOPRNT
 GCC_FUNC_PRINTF_PTR
+AC_FUNC_VFORK
 
 GCC_NEED_DECLARATIONS(malloc realloc calloc free bcopy bzero bcmp \
 	index rindex getenv atol sbrk abort atof strerror getcwd getwd \
diff -rup orig/egcs-CVS19981029/gcc/collect2.c egcs-CVS19981029/gcc/collect2.c
--- orig/egcs-CVS19981029/gcc/collect2.c	Thu Oct 29 17:26:05 1998
+++ egcs-CVS19981029/gcc/collect2.c	Thu Oct 29 17:46:35 1998
@@ -30,6 +30,19 @@ Boston, MA 02111-1307, USA.  */
 #include <signal.h>
 #include <sys/stat.h>
 
+#ifdef vfork /* Autoconf may define this to fork for us. */
+# define VFORK_STRING "fork"
+#else
+# define VFORK_STRING "vfork"
+#endif
+#ifdef HAVE_VFORK_H
+#include <vfork.h>
+#endif
+#ifdef VMS
+#define vfork() (decc$$alloc_vfork_blocks() >= 0 ? \
+               lib$get_current_invo_context(decc$$get_vfork_jmpbuf()) : -1)
+#endif /* VMS */
+
 #define COLLECT
 
 #include "demangle.h"
@@ -43,10 +56,6 @@ Boston, MA 02111-1307, USA.  */
 #define obstack_chunk_alloc xmalloc
 #define obstack_chunk_free free
 
-#ifdef USG
-#define vfork fork
-#endif
-
 #ifndef WIFSIGNALED
 #define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f)
 #endif
@@ -1716,13 +1725,7 @@ collect_execute (prog, argv, redir)
 #ifndef __CYGWIN32__
   pid = vfork ();
   if (pid == -1)
-    {
-#ifdef vfork
-      fatal_perror ("fork");
-#else
-      fatal_perror ("vfork");
-#endif
-    }
+    fatal_perror (VFORK_STRING);
 
   if (pid == 0)			/* child context */
     {
@@ -2243,13 +2246,7 @@ scan_prog_file (prog_name, which_pass)
   /* Spawn child nm on pipe */
   pid = vfork ();
   if (pid == -1)
-    {
-#ifdef vfork
-      fatal_perror ("fork");
-#else
-      fatal_perror ("vfork");
-#endif
-    }
+    fatal_perror (VFORK_STRING);
 
   if (pid == 0)			/* child context */
     {
@@ -2685,13 +2682,7 @@ scan_libraries (prog_name)
   /* Spawn child ldd on pipe */
   pid = vfork ();
   if (pid == -1)
-    {
-#ifdef vfork
-      fatal_perror ("fork");
-#else
-      fatal_perror ("vfork");
-#endif
-    }
+    fatal_perror (VFORK_STRING);
 
   if (pid == 0)			/* child context */
     {
diff -rup orig/egcs-CVS19981029/gcc/gcc.c egcs-CVS19981029/gcc/gcc.c
--- orig/egcs-CVS19981029/gcc/gcc.c	Thu Oct 29 17:26:23 1998
+++ egcs-CVS19981029/gcc/gcc.c	Thu Oct 29 17:47:24 1998
@@ -69,10 +69,6 @@ extern void set_std_prefix PROTO((char *
 #define exit __posix_exit
 #endif
 
-#ifdef USG
-#define vfork fork
-#endif /* USG */
-
 /* Test if something is a normal file.  */
 #ifndef S_ISREG
 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
diff -rup orig/egcs-CVS19981029/gcc/protoize.c egcs-CVS19981029/gcc/protoize.c
--- orig/egcs-CVS19981029/gcc/protoize.c	Thu Oct 29 17:27:07 1998
+++ egcs-CVS19981029/gcc/protoize.c	Thu Oct 29 17:47:24 1998
@@ -182,12 +182,6 @@ extern int access ();
 extern size_t   strlen ()
 #endif
 
-/* Fork is not declared because the declaration caused a conflict
-   on the HPPA.  */
-#if !(defined (USG) || defined (VMS))
-#define fork vfork
-#endif /* (defined (USG) || defined (VMS)) */
-
 #endif /* !defined (POSIX) */
 
 /* Look for these where the `const' qualifier is intentionally cast aside.  */






Fri Oct 30 10:05:40 1998  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* pexecute.c: Check HAVE_CONFIG_H, not IN_GCC, when determining
 	whether to include config.h.  Possibly include unistd.h in the
 	!IN_GCC case.  Define VFORK_STRING as a printable function call
 	for error messages (either "vfork" or "fork".)  If HAVE_VFORK_H is
 	defined, include vfork.h.  If VMS is defined, define vfork()
 	appropriately.  Remove vfork check on USG, we're using autoconf.
  	(pexecute): Set `errmsg_fmt' to VFORK_STRING instead of checking
 	locally what string to use.


diff -rup orig/egcs-CVS19981029/libiberty/pexecute.c egcs-CVS19981029/libiberty/pexecute.c
--- orig/egcs-CVS19981029/libiberty/pexecute.c	Thu Oct 29 17:30:16 1998
+++ egcs-CVS19981029/libiberty/pexecute.c	Thu Oct 29 17:47:24 1998
@@ -23,15 +23,33 @@ Boston, MA 02111-1307, USA.  */
 /* This file lives in at least two places: libiberty and gcc.
    Don't change one without the other.  */
 
-#ifdef IN_GCC
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
+#ifdef IN_GCC
 #include "system.h"
 #else
 #include <stdio.h>
 #include <errno.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #define ISSPACE (x) isspace(x)
 #endif
 
+#ifdef vfork /* Autoconf may define this to fork for us. */
+# define VFORK_STRING "fork"
+#else
+# define VFORK_STRING "vfork"
+#endif
+#ifdef HAVE_VFORK_H
+#include <vfork.h>
+#endif
+#ifdef VMS
+#define vfork() (decc$$alloc_vfork_blocks() >= 0 ? \
+               lib$get_current_invo_context(decc$$get_vfork_jmpbuf()) : -1)
+#endif /* VMS */
+
 #ifdef IN_GCC
 #include "gansidecl.h"
 /* ??? Need to find a suitable header file.  */
@@ -628,15 +646,6 @@ pfinish ()
 #if ! defined (__MSDOS__) && ! defined (OS2) && ! defined (MPW) \
     && ! defined (_WIN32)
 
-#ifdef VMS
-#define vfork() (decc$$alloc_vfork_blocks() >= 0 ? \
-               lib$get_current_invo_context(decc$$get_vfork_jmpbuf()) : -1)
-#else
-#ifdef USG
-#define vfork fork
-#endif
-#endif
-
 extern int execv ();
 extern int execvp ();
 #ifdef IN_GCC
@@ -703,11 +712,7 @@ pexecute (program, argv, this_pname, tem
     {
     case -1:
       {
-#ifdef vfork
-	*errmsg_fmt = "fork";
-#else
-	*errmsg_fmt = "vfork";
-#endif
+	*errmsg_fmt = VFORK_STRING;
 	*errmsg_arg = NULL;
 	return -1;
       }



More information about the Gcc-patches mailing list