Skip to content
Permalink
Browse files

better check for clock_gettime_nsec_np() -- cf. bug #5467.

  • Loading branch information
sezero committed Feb 10, 2021
1 parent d327bbf commit aa4a6b0b88b2e0b1206a147570bb7af3aff15350
Showing with 91 additions and 4 deletions.
  1. +12 −1 CMakeLists.txt
  2. +47 −2 configure
  3. +28 −1 configure.ac
  4. +1 −0 include/SDL_config_iphoneos.h
  5. +3 −0 include/SDL_config_macosx.h
@@ -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)
@@ -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"
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"
CheckVulkan
CheckPTHREAD


$as_echo "#define HAVE_CLOCK_GETTIME_NSEC_NP 1" >>confdefs.h


SOURCES="$SOURCES $srcdir/src/misc/ios/*.m"
have_misc=yes


CheckVisibilityHidden
CheckDeclarationAfterStatement
CheckClockGettimeAPPLE
CheckDummyVideo
CheckDiskAudio
CheckDummyAudio






cat >Makefile.rules <<__EOF__
@@ -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
@@ -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
@@ -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

0 comments on commit aa4a6b0

Please sign in to comment.