Commit f79190f40741613ed06855dd1e8708a8cf20daaf

Sam Lantinga 2019-04-23T07:59:31

Use _Exit() when available

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 524f83f..719d5f5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -699,7 +699,7 @@ if(LIBC)
             _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull
             atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp
             vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp
-            nanosleep sysconf sysctlbyname getauxval poll
+            nanosleep sysconf sysctlbyname getauxval poll _Exit
             )
       string(TOUPPER ${_FN} _UPPER)
       set(_HAVEVAR "HAVE_${_UPPER}")
diff --git a/configure b/configure
index b484f58..4a078eb 100755
--- a/configure
+++ b/configure
@@ -651,6 +651,7 @@ SDL_RLD_FLAGS
 SDL_STATIC_LIBS
 SDL_LIBS
 SDL_CFLAGS
+INSTALL_SDL2_CONFIG
 LIBUSB_LIBS
 LIBUSB_CFLAGS
 FCITX_LIBS
@@ -896,6 +897,7 @@ enable_rpath
 enable_backgrounding_signal
 enable_foregrounding_signal
 enable_render_d3d
+enable_sdl2_config
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1684,6 +1686,7 @@ Optional Features:
                           number to use for magic foregrounding signal or 'no'
                           [[default=no]]
   --enable-render-d3d     enable the Direct3D render driver [[default=yes]]
+  --enable-sdl2-config    Install sdl2-config [default=yes]
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -16969,7 +16972,7 @@ fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 
-    for ac_func in malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcscmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll
+    for ac_func in malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcscmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll _Exit
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -25165,6 +25168,30 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
         ;;
 esac
 
+# Check whether to install sdl2-config
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install sdl2-config" >&5
+$as_echo_n "checking whether to install sdl2-config... " >&6; }
+# Check whether --enable-sdl2-config was given.
+if test "${enable_sdl2_config+set}" = set; then :
+  enableval=$enable_sdl2_config; case "${enableval}" in
+        yes) enable_sdl2_config="TRUE" ;;
+        no) enable_sdl2_config="FALSE" ;;
+        *) as_fn_error $? "bad value '${enableval}' for --enable-sdl2-config" "$LINENO" 5 ;;
+    esac
+else
+  enable_sdl2_config="TRUE"
+fi
+
+if test "$enable_sdl2_config" = "TRUE"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+INSTALL_SDL2_CONFIG=$enable_sdl2_config
+
+
 # Verify that we have all the platform specific files we need
 
 if test x$have_joystick != xyes; then
diff --git a/configure.ac b/configure.ac
index 81d41d9..f81e0c7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -335,7 +335,7 @@ if test x$enable_libc = xyes; then
         AC_DEFINE(HAVE_MPROTECT, 1, [ ])
         ]),
     )
-    AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcscmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll)
+    AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcscmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll _Exit)
 
     AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
     AC_CHECK_FUNCS(acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf fmod fmodf log logf log10 log10f pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake
index 45acc9a..e6553e0 100644
--- a/include/SDL_config.h.cmake
+++ b/include/SDL_config.h.cmake
@@ -184,6 +184,7 @@
 #cmakedefine HAVE_SEM_TIMEDWAIT 1
 #cmakedefine HAVE_GETAUXVAL 1
 #cmakedefine HAVE_POLL 1
+#cmakedefine HAVE__EXIT 1
 
 #elif __WIN32__
 #cmakedefine HAVE_STDARG_H 1
diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in
index ef70652..a5e9d13 100644
--- a/include/SDL_config.h.in
+++ b/include/SDL_config.h.in
@@ -189,6 +189,7 @@
 #undef HAVE_SEM_TIMEDWAIT
 #undef HAVE_GETAUXVAL
 #undef HAVE_POLL
+#undef HAVE__EXIT
 
 #else
 #define HAVE_STDARG_H   1
diff --git a/src/SDL_assert.c b/src/SDL_assert.c
index 35a45c1..6282015 100644
--- a/src/SDL_assert.c
+++ b/src/SDL_assert.c
@@ -136,8 +136,12 @@ static void SDL_ExitProcess(int exitcode)
     emscripten_force_exit(exitcode);  /* this should "kill" the app. */
     exit(exitcode);
 #else
+#ifdef HAVE__EXIT /* Upper case _Exit() */
+    _Exit(exitcode);
+#else
     _exit(exitcode);
 #endif
+#endif
 }