From c375c43b73df248b6c1b7c87608ba491600c3e0a Mon Sep 17 00:00:00 2001 From: "Kaveh R. Ghazi" Date: Mon, 2 Nov 1998 07:20:48 +0000 Subject: [PATCH] configure.in: Call AC_FUNC_VFORK. * 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. From-SVN: r23498 --- gcc/ChangeLog | 18 ++++ gcc/collect2.c | 41 +++----- gcc/config.in | 9 ++ gcc/configure | 267 ++++++++++++++++++++++++++++++++++++++++++++--- gcc/configure.in | 1 + gcc/gcc.c | 4 - gcc/protoize.c | 6 -- 7 files changed, 299 insertions(+), 47 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6065375970c..2c284181cda 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,21 @@ +Mon Nov 2 10:10:35 1998 Kaveh R. Ghazi + + * 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. + Mon Nov 2 07:52:28 1998 Alexandre Oliva * configure.in (DEFAULT_LINKER): renamed from LD diff --git a/gcc/collect2.c b/gcc/collect2.c index 166cbe1c483..5fdd08bedf5 100644 --- a/gcc/collect2.c +++ b/gcc/collect2.c @@ -30,6 +30,19 @@ Boston, MA 02111-1307, USA. */ #include #include +#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 +#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 --git a/gcc/config.in b/gcc/config.in index 05b300231b1..fd08dcfda7d 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -98,9 +98,15 @@ /* Define if you don't have vprintf but do have _doprnt. */ #undef HAVE_DOPRNT +/* Define if you have . */ +#undef HAVE_VFORK_H + /* Define if you have the vprintf function. */ #undef HAVE_VPRINTF +/* Define to `int' if doesn't define. */ +#undef pid_t + /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS @@ -110,6 +116,9 @@ /* Define if you can safely include both and . */ #undef TIME_WITH_SYS_TIME +/* Define vfork as fork if vfork does not work. */ +#undef vfork + /* Define if you have the atoll function. */ #undef HAVE_ATOLL diff --git a/gcc/configure b/gcc/configure index 30f14d210b8..ee384fc57a1 100755 --- a/gcc/configure +++ b/gcc/configure @@ -2209,18 +2209,261 @@ EOF fi +echo $ac_n "checking for pid_t""... $ac_c" 1>&6 +echo "configure:2214: checking for pid_t" >&5 +if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#if STDC_HEADERS +#include +#include +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "pid_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_pid_t=yes +else + rm -rf conftest* + ac_cv_type_pid_t=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_type_pid_t" 1>&6 +if test $ac_cv_type_pid_t = no; then + cat >> confdefs.h <<\EOF +#define pid_t int +EOF + +fi + +ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for vfork.h""... $ac_c" 1>&6 +echo "configure:2248: checking for vfork.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2258: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_VFORK_H 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi + +echo $ac_n "checking for working vfork""... $ac_c" 1>&6 +echo "configure:2283: checking for working vfork" >&5 +if eval "test \"`echo '$''{'ac_cv_func_vfork_works'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + echo $ac_n "checking for vfork""... $ac_c" 1>&6 +echo "configure:2289: checking for vfork" >&5 +if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char vfork(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_vfork) || defined (__stub___vfork) +choke me +#else +vfork(); +#endif + +; return 0; } +EOF +if { (eval echo configure:2317: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_func_vfork=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_vfork=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'vfork`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +fi + +ac_cv_func_vfork_works=$ac_cv_func_vfork +else + cat > conftest.$ac_ext < +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_VFORK_H +#include +#endif +/* On some sparc systems, changes by the child to local and incoming + argument registers are propagated back to the parent. + The compiler is told about this with #include , + but some compilers (e.g. gcc -O) don't grok . + Test for this by using a static variable whose address + is put into a register that is clobbered by the vfork. */ +static +#ifdef __cplusplus +sparc_address_test (int arg) +#else +sparc_address_test (arg) int arg; +#endif +{ + static pid_t child; + if (!child) { + child = vfork (); + if (child < 0) { + perror ("vfork"); + _exit(2); + } + if (!child) { + arg = getpid(); + write(-1, "", 0); + _exit (arg); + } + } +} +main() { + pid_t parent = getpid (); + pid_t child; + + sparc_address_test (); + + child = vfork (); + + if (child == 0) { + /* Here is another test for sparc vfork register problems. + This test uses lots of local variables, at least + as many local variables as main has allocated so far + including compiler temporaries. 4 locals are enough for + gcc 1.40.3 on a Solaris 4.1.3 sparc, but we use 8 to be safe. + A buggy compiler should reuse the register of parent + for one of the local variables, since it will think that + parent can't possibly be used any more in this routine. + Assigning to the local variable will thus munge parent + in the parent process. */ + pid_t + p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(), + p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid(); + /* Convince the compiler that p..p7 are live; otherwise, it might + use the same hardware register for all 8 local variables. */ + if (p != p1 || p != p2 || p != p3 || p != p4 + || p != p5 || p != p6 || p != p7) + _exit(1); + + /* On some systems (e.g. IRIX 3.3), + vfork doesn't separate parent from child file descriptors. + If the child closes a descriptor before it execs or exits, + this munges the parent's descriptor as well. + Test for this by closing stdout in the child. */ + _exit(close(fileno(stdout)) != 0); + } else { + int status; + struct stat st; + + while (wait(&status) != child) + ; + exit( + /* Was there some problem with vforking? */ + child < 0 + + /* Did the child fail? (This shouldn't happen.) */ + || status + + /* Did the vfork/compiler bug occur? */ + || parent != getpid() + + /* Did the file descriptor bug occur? */ + || fstat(fileno(stdout), &st) != 0 + ); + } +} +EOF +if { (eval echo configure:2434: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + ac_cv_func_vfork_works=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_func_vfork_works=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$ac_cv_func_vfork_works" 1>&6 +if test $ac_cv_func_vfork_works = no; then + cat >> confdefs.h <<\EOF +#define vfork fork +EOF + +fi + for ac_func in malloc realloc calloc free bcopy bzero bcmp \ index rindex getenv atol sbrk abort atof strerror getcwd getwd \ strsignal do echo $ac_n "checking whether $ac_func must be declared""... $ac_c" 1>&6 -echo "configure:2219: checking whether $ac_func must be declared" >&5 +echo "configure:2462: checking whether $ac_func must be declared" >&5 if eval "test \"`echo '$''{'gcc_cv_decl_needed_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -2253,7 +2496,7 @@ int main() { char *(*pfn) = (char *(*)) $ac_func ; return 0; } EOF -if { (eval echo configure:2257: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2500: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "gcc_cv_decl_needed_$ac_func=no" else @@ -2282,12 +2525,12 @@ done for ac_func in getrlimit setrlimit do echo $ac_n "checking whether $ac_func must be declared""... $ac_c" 1>&6 -echo "configure:2286: checking whether $ac_func must be declared" >&5 +echo "configure:2529: checking whether $ac_func must be declared" >&5 if eval "test \"`echo '$''{'gcc_cv_decl_needed_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -2324,7 +2567,7 @@ int main() { char *(*pfn) = (char *(*)) $ac_func ; return 0; } EOF -if { (eval echo configure:2328: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2571: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "gcc_cv_decl_needed_$ac_func=no" else @@ -2351,12 +2594,12 @@ done echo $ac_n "checking for sys_siglist declaration in signal.h or unistd.h""... $ac_c" 1>&6 -echo "configure:2355: checking for sys_siglist declaration in signal.h or unistd.h" >&5 +echo "configure:2598: checking for sys_siglist declaration in signal.h or unistd.h" >&5 if eval "test \"`echo '$''{'ac_cv_decl_sys_siglist'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2368,7 +2611,7 @@ int main() { char *msg = *(sys_siglist + 1); ; return 0; } EOF -if { (eval echo configure:2372: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2615: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_decl_sys_siglist=yes else @@ -5587,7 +5830,7 @@ fi # Figure out what assembler alignment features are present. echo $ac_n "checking assembler alignment features""... $ac_c" 1>&6 -echo "configure:5591: checking assembler alignment features" >&5 +echo "configure:5834: checking assembler alignment features" >&5 gcc_cv_as= gcc_cv_as_alignment_features= gcc_cv_as_gas_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gas @@ -5660,7 +5903,7 @@ fi echo "$ac_t""$gcc_cv_as_alignment_features" 1>&6 echo $ac_n "checking assembler subsection support""... $ac_c" 1>&6 -echo "configure:5664: checking assembler subsection support" >&5 +echo "configure:5907: checking assembler subsection support" >&5 gcc_cv_as_subsections= if test x$gcc_cv_as != x; then # Check if we have .subsection @@ -5896,7 +6139,7 @@ fi # Warn if using init_priority. echo $ac_n "checking whether to enable init_priority by default""... $ac_c" 1>&6 -echo "configure:5900: checking whether to enable init_priority by default" >&5 +echo "configure:6143: checking whether to enable init_priority by default" >&5 if test x$enable_init_priority != xyes; then enable_init_priority=no fi diff --git a/gcc/configure.in b/gcc/configure.in index ae503a05d83..3af08910feb 100644 --- a/gcc/configure.in +++ b/gcc/configure.in @@ -367,6 +367,7 @@ AC_CHECK_FUNCS(strtoul bsearch strerror putenv popen bcopy bzero bcmp \ 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 --git a/gcc/gcc.c b/gcc/gcc.c index a7eb71e45e2..3182f6876cc 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -69,10 +69,6 @@ extern void set_std_prefix PROTO((char *, int)); #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 --git a/gcc/protoize.c b/gcc/protoize.c index 18187a6c9cd..1e2944e48c3 100644 --- a/gcc/protoize.c +++ b/gcc/protoize.c @@ -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. */ -- 2.30.2