Remove support for on_exit()
authorPeter Eisentraut
Tue, 27 Dec 2011 18:57:59 +0000 (20:57 +0200)
committerPeter Eisentraut
Tue, 27 Dec 2011 18:57:59 +0000 (20:57 +0200)
All supported platforms support the C89 standard function atexit()
(SunOS 4 probably being the last one not to), and supporting both
makes the code clumsy.

configure
configure.in
contrib/pg_upgrade/server.c
src/backend/storage/ipc/ipc.c
src/bin/psql/input.c
src/include/pg_config.h.in
src/include/pg_config.h.win32

index c0345b94757973674d26be51fea9075e455e1d88..bfc7a1f86fac33c1af8fcd884f5eaf0f134c6e0a 100755 (executable)
--- a/configure
+++ b/configure
 done
 
 
-# Check for one of atexit() or on_exit()
-
-for ac_func in atexit
-do
-as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
-$as_echo_n "checking for $ac_func... " >&6; }
-if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
-  $as_echo_n "(cached) " >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-/* Define $ac_func to an innocuous variant, in case  declares $ac_func.
-   For example, HP-UX 11i  declares gettimeofday.  */
-#define $ac_func innocuous_$ac_func
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.
-    Prefer  to  if __STDC__ is defined, since
-     exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include 
-#else
-# include 
-#endif
-
-#undef $ac_func
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char $ac_func ();
-/* 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_$ac_func || defined __stub___$ac_func
-choke me
-#endif
-
-int
-main ()
-{
-return $ac_func ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-    test -z "$ac_c_werror_flag" ||
-    test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-    test "$cross_compiling" = yes ||
-    $as_test_x conftest$ac_exeext
-       }; then
-  eval "$as_ac_var=yes"
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-   eval "$as_ac_var=no"
-fi
-
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-ac_res=`eval 'as_val=${'$as_ac_var'}
-        $as_echo "$as_val"'`
-          { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-as_val=`eval 'as_val=${'$as_ac_var'}
-        $as_echo "$as_val"'`
-   if test "x$as_val" = x""yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-else
-
-for ac_func in on_exit
-do
-as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
-$as_echo_n "checking for $ac_func... " >&6; }
-if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
-  $as_echo_n "(cached) " >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-/* Define $ac_func to an innocuous variant, in case  declares $ac_func.
-   For example, HP-UX 11i  declares gettimeofday.  */
-#define $ac_func innocuous_$ac_func
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.
-    Prefer  to  if __STDC__ is defined, since
-     exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include 
-#else
-# include 
-#endif
-
-#undef $ac_func
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char $ac_func ();
-/* 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_$ac_func || defined __stub___$ac_func
-choke me
-#endif
-
-int
-main ()
-{
-return $ac_func ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
-$as_echo "$ac_try_echo") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-    test -z "$ac_c_werror_flag" ||
-    test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-    test "$cross_compiling" = yes ||
-    $as_test_x conftest$ac_exeext
-       }; then
-  eval "$as_ac_var=yes"
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-   eval "$as_ac_var=no"
-fi
-
-rm -rf conftest.dSYM
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-ac_res=`eval 'as_val=${'$as_ac_var'}
-        $as_echo "$as_val"'`
-          { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-as_val=`eval 'as_val=${'$as_ac_var'}
-        $as_echo "$as_val"'`
-   if test "x$as_val" = x""yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-else
-  { { $as_echo "$as_me:$LINENO: error: neither atexit() nor on_exit() found" >&5
-$as_echo "$as_me: error: neither atexit() nor on_exit() found" >&2;}
-   { (exit 1); exit 1; }; }
-fi
-done
-
-fi
-done
-
-
 
 #
 # Pthreads
index 9def3d54d5fea77e4fbe89fc6095dbd18f42b017..54ca820b11cfdbddb609a293d573e02afdd23b3f 100644 (file)
@@ -1438,11 +1438,6 @@ fi
 AC_CHECK_FUNCS([strtoll strtoq], [break])
 AC_CHECK_FUNCS([strtoull strtouq], [break])
 
-# Check for one of atexit() or on_exit()
-AC_CHECK_FUNCS(atexit, [],
-               [AC_CHECK_FUNCS(on_exit, [],
-               [AC_MSG_ERROR([neither atexit() nor on_exit() found])])])
-
 
 #
 # Pthreads
index 9c4f2d6fc3fd6858bca5fcd805c676cafde94e68..e45f72b0ae2bf34575d6ab177ac2f24728e7fc05 100644 (file)
@@ -130,11 +130,7 @@ get_major_server_version(ClusterInfo *cluster)
 
 
 static void
-#ifdef HAVE_ATEXIT
 stop_postmaster_atexit(void)
-#else
-stop_postmaster_on_exit(int exitstatus, void *arg)
-#endif
 {
    stop_postmaster(true);
 
@@ -151,11 +147,7 @@ start_postmaster(ClusterInfo *cluster)
 
    if (!exit_hook_registered)
    {
-#ifdef HAVE_ATEXIT
        atexit(stop_postmaster_atexit);
-#else
-       on_exit(stop_postmaster_on_exit);
-#endif
        exit_hook_registered = true;
    }
 
index 540209ce79501b753d5277f348770918ecbce4b8..1ca813a72da1b99f08092918de7e578e02a07ef7 100644 (file)
@@ -39,7 +39,7 @@
 bool       proc_exit_inprogress = false;
 
 /*
- * This flag tracks whether we've called atexit(2) in the current process
+ * This flag tracks whether we've called atexit() in the current process
  * (or in the parent postmaster).
  */
 static bool atexit_callback_setup = false;
@@ -51,7 +51,7 @@ static void proc_exit_prepare(int code);
 /* ----------------------------------------------------------------
  *                     exit() handling stuff
  *
- * These functions are in generally the same spirit as atexit(2),
+ * These functions are in generally the same spirit as atexit(),
  * but provide some additional features we need --- in particular,
  * we want to register callbacks to invoke when we are disconnecting
  * from a broken shared-memory context but not exiting the postmaster.
@@ -234,8 +234,6 @@ shmem_exit(int code)
  * postmaster treat it as a crash --- see pmsignal.c.
  * ----------------------------------------------------------------
  */
-#ifdef HAVE_ATEXIT
-
 static void
 atexit_callback(void)
 {
@@ -243,15 +241,6 @@ atexit_callback(void)
    /* ... too bad we don't know the real exit code ... */
    proc_exit_prepare(-1);
 }
-#else                          /* assume we have on_exit instead */
-
-static void
-atexit_callback(int exitstatus, void *arg)
-{
-   /* Clean up everything that must be cleaned up */
-   proc_exit_prepare(exitstatus);
-}
-#endif   /* HAVE_ATEXIT */
 
 /* ----------------------------------------------------------------
  *     on_proc_exit
@@ -275,11 +264,7 @@ on_proc_exit(pg_on_exit_callback function, Datum arg)
 
    if (!atexit_callback_setup)
    {
-#ifdef HAVE_ATEXIT
        atexit(atexit_callback);
-#else
-       on_exit(atexit_callback, NULL);
-#endif
        atexit_callback_setup = true;
    }
 }
@@ -306,11 +291,7 @@ on_shmem_exit(pg_on_exit_callback function, Datum arg)
 
    if (!atexit_callback_setup)
    {
-#ifdef HAVE_ATEXIT
        atexit(atexit_callback);
-#else
-       on_exit(atexit_callback, NULL);
-#endif
        atexit_callback_setup = true;
    }
 }
index ec0e6e1d49bc253193b934046cc6d6dc9ff1b2fe..870251bb84b60219e4b659ecdba2e65ddf819ad4 100644 (file)
@@ -45,12 +45,7 @@ static int   history_lines_added;
 #define NL_IN_HISTORY  0x01
 #endif
 
-#ifdef HAVE_ATEXIT
 static void finishInput(void);
-#else
-/* designed for use with on_exit() */
-static void finishInput(int, void *);
-#endif
 
 
 /*
@@ -313,11 +308,7 @@ initializeInput(int flags)
    }
 #endif
 
-#ifdef HAVE_ATEXIT
    atexit(finishInput);
-#else
-   on_exit(finishInput, NULL);
-#endif
 }
 
 
@@ -416,11 +407,7 @@ saveHistory(char *fname, int max_lines, bool appendFlag, bool encodeFlag)
 
 
 static void
-#ifdef HAVE_ATEXIT
 finishInput(void)
-#else
-finishInput(int exitstatus, void *arg)
-#endif
 {
 #ifdef USE_READLINE
    if (useHistory && psql_history)
index b969d8c8e6fed1f83525573cae01d54f893d8109..ef467b7386655b79a51ef9c75bae19e22aa30c8d 100644 (file)
@@ -90,9 +90,6 @@
 /* Define to 1 if you have the `append_history' function. */
 #undef HAVE_APPEND_HISTORY
 
-/* Define to 1 if you have the `atexit' function. */
-#undef HAVE_ATEXIT
-
 /* Define to 1 if you have the `cbrt' function. */
 #undef HAVE_CBRT
 
 /* Define to 1 if you have the  header file. */
 #undef HAVE_NET_IF_H
 
-/* Define to 1 if you have the `on_exit' function. */
-#undef HAVE_ON_EXIT
-
 /* Define to 1 if you have the  header file. */
 #undef HAVE_OSSP_UUID_H
 
index e568a03519ece7534199097a94780f2d84053850..35294e9f124900acf570ca7977004474355958b0 100644 (file)
@@ -72,9 +72,6 @@
 # define gettimeofday(a,b) gettimeofday(a)
 #endif
 
-/* Define to 1 if you have the `atexit' function. */
-#define HAVE_ATEXIT 1
-
 /* Define to 1 if you have the `cbrt' function. */
 //#define HAVE_CBRT 1
 
 /* Define to 1 if you have the  header file. */
 /* #undef HAVE_NETINET_TCP_H */
 
-/* Define to 1 if you have the `on_exit' function. */
-/* #undef HAVE_ON_EXIT */
-
 /* Define to 1 if you have the  header file. */
 /* #undef HAVE_PAM_PAM_APPL_H */