better check for clock_gettime_nsec_np() -- cf. bug #5467.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6835785..39adf31 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -873,7 +873,18 @@ if(LIBC)
else()
set(HAVE_ALLOCA_H 1)
set(HAVE_ALLOCA 1)
- check_symbol_exists(clock_gettime_nsec_np "time.h" HAVE_CLOCK_GETTIME_NSEC_NP)
+ if(IOS OR TVOS) # assuming iOS / TVOS >= 10.0
+ set(HAVE_CLOCK_GETTIME_NSEC_NP 1)
+ else()
+ CHECK_C_SOURCE_COMPILES("
+ #include <AvailabilityMacros.h>
+ #include <time.h>
+ #if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
+ #error Need 10.12 or newer target
+ #endif
+ int main(int argc, char **argv) { return !clock_gettime_nsec_np(CLOCK_MONOTONIC); }
+ " HAVE_CLOCK_GETTIME_NSEC_NP)
+ endif()
endif()
check_struct_has_member("struct sigaction" "sa_sigaction" "signal.h" HAVE_SA_SIGACTION)
diff --git a/configure b/configure
index 4c3cdea..5b477e0 100755
--- a/configure
+++ b/configure
@@ -17068,7 +17068,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 wcslcpy wcslcat wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr strtok_r 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 elf_aux_info clock_gettime_nsec_np poll _Exit
+ for ac_func in malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcslcpy wcslcat wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr strtok_r 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 elf_aux_info 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"
@@ -24748,6 +24748,47 @@ $as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
fi
}
+CheckClockGettimeAPPLE()
+{
+ have_clock_gettime_apple=no
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime_nsec_np" >&5
+$as_echo_n "checking for clock_gettime_nsec_np... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <AvailabilityMacros.h>
+#include <time.h>
+
+int
+main ()
+{
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
+#error Need 10.12 or newer target
+#endif
+ return !clock_gettime_nsec_np(CLOCK_MONOTONIC);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+ have_clock_gettime_apple=yes
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_clock_gettime_apple" >&5
+$as_echo "$have_clock_gettime_apple" >&6; }
+
+ if test x$have_clock_gettime_apple = xyes; then
+
+$as_echo "#define HAVE_CLOCK_GETTIME_NSEC_NP 1" >>confdefs.h
+
+ fi
+}
+
CheckLinuxVersion()
{
ac_fn_c_check_header_mongrel "$LINENO" "linux/version.h" "ac_cv_header_linux_version_h" "$ac_includes_default"
@@ -25442,6 +25483,10 @@ fi
CheckVulkan
CheckPTHREAD
+
+$as_echo "#define HAVE_CLOCK_GETTIME_NSEC_NP 1" >>confdefs.h
+
+
SOURCES="$SOURCES $srcdir/src/misc/ios/*.m"
have_misc=yes
@@ -25559,6 +25604,7 @@ $as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
CheckVisibilityHidden
CheckDeclarationAfterStatement
+ CheckClockGettimeAPPLE
CheckDummyVideo
CheckDiskAudio
CheckDummyAudio
@@ -26010,7 +26056,6 @@ fi
-
cat >Makefile.rules <<__EOF__
# Build rules for objects
diff --git a/configure.ac b/configure.ac
index 3418f0a..976314a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -345,7 +345,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 wcslcpy wcslcat wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr strtok_r 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 elf_aux_info clock_gettime_nsec_np poll _Exit)
+ AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcslcpy wcslcat wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr strtok_r 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 elf_aux_info 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 trunc truncf fmod fmodf log logf log10 log10f lround lroundf pow powf round roundf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
@@ -3486,6 +3486,29 @@ AS_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettime
fi
}
+dnl Check for clock_gettime_nsec_np()
+CheckClockGettimeAPPLE()
+{
+ have_clock_gettime_apple=no
+ AC_MSG_CHECKING(for clock_gettime_nsec_np)
+ AC_TRY_LINK([
+#include <AvailabilityMacros.h>
+#include <time.h>
+ ],[
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
+#error Need 10.12 or newer target
+#endif
+ return !clock_gettime_nsec_np(CLOCK_MONOTONIC);
+ ],[
+ have_clock_gettime_apple=yes
+ ])
+ AC_MSG_RESULT($have_clock_gettime_apple)
+
+ if test x$have_clock_gettime_apple = xyes; then
+ AC_DEFINE(HAVE_CLOCK_GETTIME_NSEC_NP, 1, [ ])
+ fi
+}
+
dnl Check for a valid linux/version.h
CheckLinuxVersion()
{
@@ -4021,6 +4044,9 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
CheckVulkan
CheckPTHREAD
+ dnl assuming iOS >= 10.0
+ AC_DEFINE(HAVE_CLOCK_GETTIME_NSEC_NP, 1, [ ])
+
SOURCES="$SOURCES $srcdir/src/misc/ios/*.m"
have_misc=yes
@@ -4116,6 +4142,7 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
CheckVisibilityHidden
CheckDeclarationAfterStatement
+ CheckClockGettimeAPPLE
CheckDummyVideo
CheckDiskAudio
CheckDummyAudio
diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h
index 9a748be..08524b4 100644
--- a/include/SDL_config_iphoneos.h
+++ b/include/SDL_config_iphoneos.h
@@ -53,6 +53,7 @@
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
+#define HAVE_CLOCK_GETTIME_NSEC_NP 1
#define HAVE_GETENV 1
#define HAVE_SETENV 1
#define HAVE_PUTENV 1
diff --git a/include/SDL_config_macosx.h b/include/SDL_config_macosx.h
index 9a8f720..464b197 100644
--- a/include/SDL_config_macosx.h
+++ b/include/SDL_config_macosx.h
@@ -56,6 +56,9 @@
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+#define HAVE_CLOCK_GETTIME_NSEC_NP 1
+#endif
#define HAVE_ALLOCA 1
#define HAVE_GETENV 1
#define HAVE_SETENV 1