mirror of https://github.com/encounter/SDL.git
Removed support for clock_gettime_nsec_np()
SDL_GetTicks() was broken and it's not adding any real value here.
This commit is contained in:
parent
42798cec8b
commit
2426949a18
|
@ -875,18 +875,6 @@ if(LIBC)
|
||||||
else()
|
else()
|
||||||
set(HAVE_ALLOCA_H 1)
|
set(HAVE_ALLOCA_H 1)
|
||||||
set(HAVE_ALLOCA 1)
|
set(HAVE_ALLOCA 1)
|
||||||
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()
|
endif()
|
||||||
|
|
||||||
check_struct_has_member("struct sigaction" "sa_sigaction" "signal.h" HAVE_SA_SIGACTION)
|
check_struct_has_member("struct sigaction" "sa_sigaction" "signal.h" HAVE_SA_SIGACTION)
|
||||||
|
|
|
@ -24769,47 +24769,6 @@ $as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
|
||||||
fi
|
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()
|
CheckLinuxVersion()
|
||||||
{
|
{
|
||||||
ac_fn_c_check_header_mongrel "$LINENO" "linux/version.h" "ac_cv_header_linux_version_h" "$ac_includes_default"
|
ac_fn_c_check_header_mongrel "$LINENO" "linux/version.h" "ac_cv_header_linux_version_h" "$ac_includes_default"
|
||||||
|
@ -25504,10 +25463,6 @@ fi
|
||||||
CheckVulkan
|
CheckVulkan
|
||||||
CheckPTHREAD
|
CheckPTHREAD
|
||||||
|
|
||||||
|
|
||||||
$as_echo "#define HAVE_CLOCK_GETTIME_NSEC_NP 1" >>confdefs.h
|
|
||||||
|
|
||||||
|
|
||||||
SOURCES="$SOURCES $srcdir/src/misc/ios/*.m"
|
SOURCES="$SOURCES $srcdir/src/misc/ios/*.m"
|
||||||
have_misc=yes
|
have_misc=yes
|
||||||
|
|
||||||
|
@ -25625,7 +25580,6 @@ $as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
|
||||||
|
|
||||||
CheckVisibilityHidden
|
CheckVisibilityHidden
|
||||||
CheckDeclarationAfterStatement
|
CheckDeclarationAfterStatement
|
||||||
CheckClockGettimeAPPLE
|
|
||||||
CheckDummyVideo
|
CheckDummyVideo
|
||||||
CheckDiskAudio
|
CheckDiskAudio
|
||||||
CheckDummyAudio
|
CheckDummyAudio
|
||||||
|
|
27
configure.ac
27
configure.ac
|
@ -3496,29 +3496,6 @@ AS_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettime
|
||||||
fi
|
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
|
dnl Check for a valid linux/version.h
|
||||||
CheckLinuxVersion()
|
CheckLinuxVersion()
|
||||||
{
|
{
|
||||||
|
@ -4054,9 +4031,6 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
|
||||||
CheckVulkan
|
CheckVulkan
|
||||||
CheckPTHREAD
|
CheckPTHREAD
|
||||||
|
|
||||||
dnl assuming iOS >= 10.0
|
|
||||||
AC_DEFINE(HAVE_CLOCK_GETTIME_NSEC_NP, 1, [ ])
|
|
||||||
|
|
||||||
SOURCES="$SOURCES $srcdir/src/misc/ios/*.m"
|
SOURCES="$SOURCES $srcdir/src/misc/ios/*.m"
|
||||||
have_misc=yes
|
have_misc=yes
|
||||||
|
|
||||||
|
@ -4152,7 +4126,6 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
|
||||||
|
|
||||||
CheckVisibilityHidden
|
CheckVisibilityHidden
|
||||||
CheckDeclarationAfterStatement
|
CheckDeclarationAfterStatement
|
||||||
CheckClockGettimeAPPLE
|
|
||||||
CheckDummyVideo
|
CheckDummyVideo
|
||||||
CheckDiskAudio
|
CheckDiskAudio
|
||||||
CheckDummyAudio
|
CheckDummyAudio
|
||||||
|
|
|
@ -191,7 +191,6 @@
|
||||||
#cmakedefine HAVE_SYSCONF 1
|
#cmakedefine HAVE_SYSCONF 1
|
||||||
#cmakedefine HAVE_SYSCTLBYNAME 1
|
#cmakedefine HAVE_SYSCTLBYNAME 1
|
||||||
#cmakedefine HAVE_CLOCK_GETTIME 1
|
#cmakedefine HAVE_CLOCK_GETTIME 1
|
||||||
#cmakedefine HAVE_CLOCK_GETTIME_NSEC_NP 1
|
|
||||||
#cmakedefine HAVE_GETPAGESIZE 1
|
#cmakedefine HAVE_GETPAGESIZE 1
|
||||||
#cmakedefine HAVE_MPROTECT 1
|
#cmakedefine HAVE_MPROTECT 1
|
||||||
#cmakedefine HAVE_ICONV 1
|
#cmakedefine HAVE_ICONV 1
|
||||||
|
|
|
@ -196,7 +196,6 @@
|
||||||
#undef HAVE_SYSCONF
|
#undef HAVE_SYSCONF
|
||||||
#undef HAVE_SYSCTLBYNAME
|
#undef HAVE_SYSCTLBYNAME
|
||||||
#undef HAVE_CLOCK_GETTIME
|
#undef HAVE_CLOCK_GETTIME
|
||||||
#undef HAVE_CLOCK_GETTIME_NSEC_NP
|
|
||||||
#undef HAVE_GETPAGESIZE
|
#undef HAVE_GETPAGESIZE
|
||||||
#undef HAVE_MPROTECT
|
#undef HAVE_MPROTECT
|
||||||
#undef HAVE_ICONV
|
#undef HAVE_ICONV
|
||||||
|
|
|
@ -53,7 +53,6 @@
|
||||||
#define HAVE_REALLOC 1
|
#define HAVE_REALLOC 1
|
||||||
#define HAVE_FREE 1
|
#define HAVE_FREE 1
|
||||||
#define HAVE_ALLOCA 1
|
#define HAVE_ALLOCA 1
|
||||||
#define HAVE_CLOCK_GETTIME_NSEC_NP 1
|
|
||||||
#define HAVE_GETENV 1
|
#define HAVE_GETENV 1
|
||||||
#define HAVE_SETENV 1
|
#define HAVE_SETENV 1
|
||||||
#define HAVE_PUTENV 1
|
#define HAVE_PUTENV 1
|
||||||
|
|
|
@ -56,9 +56,6 @@
|
||||||
#define HAVE_CALLOC 1
|
#define HAVE_CALLOC 1
|
||||||
#define HAVE_REALLOC 1
|
#define HAVE_REALLOC 1
|
||||||
#define HAVE_FREE 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_ALLOCA 1
|
||||||
#define HAVE_GETENV 1
|
#define HAVE_GETENV 1
|
||||||
#define HAVE_SETENV 1
|
#define HAVE_SETENV 1
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
Also added OS X Monotonic clock support
|
Also added OS X Monotonic clock support
|
||||||
Based on work in https://github.com/ThomasHabets/monotonic_clock
|
Based on work in https://github.com/ThomasHabets/monotonic_clock
|
||||||
*/
|
*/
|
||||||
#if HAVE_NANOSLEEP || HAVE_CLOCK_GETTIME || HAVE_CLOCK_GETTIME_NSEC_NP
|
#if HAVE_NANOSLEEP || HAVE_CLOCK_GETTIME
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Use CLOCK_MONOTONIC_RAW, if available, which is not subject to adjustment by NTP */
|
/* Use CLOCK_MONOTONIC_RAW, if available, which is not subject to adjustment by NTP */
|
||||||
#if HAVE_CLOCK_GETTIME || HAVE_CLOCK_GETTIME_NSEC_NP
|
#if HAVE_CLOCK_GETTIME
|
||||||
#ifdef CLOCK_MONOTONIC_RAW
|
#ifdef CLOCK_MONOTONIC_RAW
|
||||||
#define SDL_MONOTONIC_CLOCK CLOCK_MONOTONIC_RAW
|
#define SDL_MONOTONIC_CLOCK CLOCK_MONOTONIC_RAW
|
||||||
#else
|
#else
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
/* The first ticks value of the application */
|
/* The first ticks value of the application */
|
||||||
#if HAVE_CLOCK_GETTIME
|
#if HAVE_CLOCK_GETTIME
|
||||||
static struct timespec start_ts;
|
static struct timespec start_ts;
|
||||||
#elif defined(__APPLE__) && !HAVE_CLOCK_GETTIME_NSEC_NP
|
#elif defined(__APPLE__)
|
||||||
static uint64_t start_mach;
|
static uint64_t start_mach;
|
||||||
mach_timebase_info_data_t mach_base_info;
|
mach_timebase_info_data_t mach_base_info;
|
||||||
#endif
|
#endif
|
||||||
|
@ -87,17 +87,11 @@ SDL_TicksInit(void)
|
||||||
has_monotonic_time = SDL_TRUE;
|
has_monotonic_time = SDL_TRUE;
|
||||||
} else
|
} else
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#if !HAVE_CLOCK_GETTIME_NSEC_NP
|
|
||||||
kern_return_t ret = mach_timebase_info(&mach_base_info);
|
kern_return_t ret = mach_timebase_info(&mach_base_info);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
has_monotonic_time = SDL_TRUE;
|
has_monotonic_time = SDL_TRUE;
|
||||||
start_mach = mach_absolute_time();
|
start_mach = mach_absolute_time();
|
||||||
} else
|
} else
|
||||||
#else
|
|
||||||
if (clock_gettime_nsec_np(SDL_MONOTONIC_CLOCK) > 0) {
|
|
||||||
has_monotonic_time = SDL_TRUE;
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
gettimeofday(&start_tv, NULL);
|
gettimeofday(&start_tv, NULL);
|
||||||
|
@ -124,12 +118,8 @@ SDL_GetTicks(void)
|
||||||
clock_gettime(SDL_MONOTONIC_CLOCK, &now);
|
clock_gettime(SDL_MONOTONIC_CLOCK, &now);
|
||||||
ticks = (Uint32)((now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec - start_ts.tv_nsec) / 1000000);
|
ticks = (Uint32)((now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec - start_ts.tv_nsec) / 1000000);
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#if !HAVE_CLOCK_GETTIME_NSEC_NP
|
|
||||||
uint64_t now = mach_absolute_time();
|
uint64_t now = mach_absolute_time();
|
||||||
ticks = (Uint32)((((now - start_mach) * mach_base_info.numer) / mach_base_info.denom) / 1000000);
|
ticks = (Uint32)((((now - start_mach) * mach_base_info.numer) / mach_base_info.denom) / 1000000);
|
||||||
#else
|
|
||||||
ticks = (Uint32)clock_gettime_nsec_np(SDL_MONOTONIC_CLOCK);
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
SDL_assert(SDL_FALSE);
|
SDL_assert(SDL_FALSE);
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
|
@ -160,11 +150,7 @@ SDL_GetPerformanceCounter(void)
|
||||||
ticks *= 1000000000;
|
ticks *= 1000000000;
|
||||||
ticks += now.tv_nsec;
|
ticks += now.tv_nsec;
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#if !HAVE_CLOCK_GETTIME_NSEC_NP
|
|
||||||
ticks = mach_absolute_time();
|
ticks = mach_absolute_time();
|
||||||
#else
|
|
||||||
ticks = (Uint32)clock_gettime_nsec_np(SDL_MONOTONIC_CLOCK);
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
SDL_assert(SDL_FALSE);
|
SDL_assert(SDL_FALSE);
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
|
@ -191,16 +177,13 @@ SDL_GetPerformanceFrequency(void)
|
||||||
#if HAVE_CLOCK_GETTIME
|
#if HAVE_CLOCK_GETTIME
|
||||||
return 1000000000;
|
return 1000000000;
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#if !HAVE_CLOCK_GETTIME_NSEC_NP
|
|
||||||
Uint64 freq = mach_base_info.denom;
|
Uint64 freq = mach_base_info.denom;
|
||||||
freq *= 1000000000;
|
freq *= 1000000000;
|
||||||
freq /= mach_base_info.numer;
|
freq /= mach_base_info.numer;
|
||||||
return freq;
|
return freq;
|
||||||
#else
|
|
||||||
return 1000000000;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
}
|
||||||
}
|
|
||||||
return 1000000;
|
return 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue