Skip to content

Commit 24b5341

Browse files
committed
Removed support for clock_gettime_nsec_np()
SDL_GetTicks() was broken and it's not adding any real value here.
1 parent c9d581c commit 24b5341

8 files changed

+5
-113
lines changed

CMakeLists.txt

-12
Original file line numberDiff line numberDiff line change
@@ -875,18 +875,6 @@ if(LIBC)
875875
else()
876876
set(HAVE_ALLOCA_H 1)
877877
set(HAVE_ALLOCA 1)
878-
if(IOS OR TVOS) # assuming iOS / TVOS >= 10.0
879-
set(HAVE_CLOCK_GETTIME_NSEC_NP 1)
880-
else()
881-
CHECK_C_SOURCE_COMPILES("
882-
#include <AvailabilityMacros.h>
883-
#include <time.h>
884-
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
885-
#error Need 10.12 or newer target
886-
#endif
887-
int main(int argc, char **argv) { return !clock_gettime_nsec_np(CLOCK_MONOTONIC); }
888-
" HAVE_CLOCK_GETTIME_NSEC_NP)
889-
endif()
890878
endif()
891879

892880
check_struct_has_member("struct sigaction" "sa_sigaction" "signal.h" HAVE_SA_SIGACTION)

configure

-46
Original file line numberDiff line numberDiff line change
@@ -24769,47 +24769,6 @@ $as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
2476924769
fi
2477024770
}
2477124771

24772-
CheckClockGettimeAPPLE()
24773-
{
24774-
have_clock_gettime_apple=no
24775-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime_nsec_np" >&5
24776-
$as_echo_n "checking for clock_gettime_nsec_np... " >&6; }
24777-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
24778-
/* end confdefs.h. */
24779-
24780-
#include <AvailabilityMacros.h>
24781-
#include <time.h>
24782-
24783-
int
24784-
main ()
24785-
{
24786-
24787-
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
24788-
#error Need 10.12 or newer target
24789-
#endif
24790-
return !clock_gettime_nsec_np(CLOCK_MONOTONIC);
24791-
24792-
;
24793-
return 0;
24794-
}
24795-
_ACEOF
24796-
if ac_fn_c_try_link "$LINENO"; then :
24797-
24798-
have_clock_gettime_apple=yes
24799-
24800-
fi
24801-
rm -f core conftest.err conftest.$ac_objext \
24802-
conftest$ac_exeext conftest.$ac_ext
24803-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_clock_gettime_apple" >&5
24804-
$as_echo "$have_clock_gettime_apple" >&6; }
24805-
24806-
if test x$have_clock_gettime_apple = xyes; then
24807-
24808-
$as_echo "#define HAVE_CLOCK_GETTIME_NSEC_NP 1" >>confdefs.h
24809-
24810-
fi
24811-
}
24812-
2481324772
CheckLinuxVersion()
2481424773
{
2481524774
ac_fn_c_check_header_mongrel "$LINENO" "linux/version.h" "ac_cv_header_linux_version_h" "$ac_includes_default"
@@ -25504,10 +25463,6 @@ fi
2550425463
CheckVulkan
2550525464
CheckPTHREAD
2550625465

25507-
25508-
$as_echo "#define HAVE_CLOCK_GETTIME_NSEC_NP 1" >>confdefs.h
25509-
25510-
2551125466
SOURCES="$SOURCES $srcdir/src/misc/ios/*.m"
2551225467
have_misc=yes
2551325468

@@ -25625,7 +25580,6 @@ $as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
2562525580

2562625581
CheckVisibilityHidden
2562725582
CheckDeclarationAfterStatement
25628-
CheckClockGettimeAPPLE
2562925583
CheckDummyVideo
2563025584
CheckDiskAudio
2563125585
CheckDummyAudio

configure.ac

-27
Original file line numberDiff line numberDiff line change
@@ -3496,29 +3496,6 @@ AS_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettime
34963496
fi
34973497
}
34983498

3499-
dnl Check for clock_gettime_nsec_np()
3500-
CheckClockGettimeAPPLE()
3501-
{
3502-
have_clock_gettime_apple=no
3503-
AC_MSG_CHECKING(for clock_gettime_nsec_np)
3504-
AC_TRY_LINK([
3505-
#include <AvailabilityMacros.h>
3506-
#include <time.h>
3507-
],[
3508-
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
3509-
#error Need 10.12 or newer target
3510-
#endif
3511-
return !clock_gettime_nsec_np(CLOCK_MONOTONIC);
3512-
],[
3513-
have_clock_gettime_apple=yes
3514-
])
3515-
AC_MSG_RESULT($have_clock_gettime_apple)
3516-
3517-
if test x$have_clock_gettime_apple = xyes; then
3518-
AC_DEFINE(HAVE_CLOCK_GETTIME_NSEC_NP, 1, [ ])
3519-
fi
3520-
}
3521-
35223499
dnl Check for a valid linux/version.h
35233500
CheckLinuxVersion()
35243501
{
@@ -4054,9 +4031,6 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
40544031
CheckVulkan
40554032
CheckPTHREAD
40564033

4057-
dnl assuming iOS >= 10.0
4058-
AC_DEFINE(HAVE_CLOCK_GETTIME_NSEC_NP, 1, [ ])
4059-
40604034
SOURCES="$SOURCES $srcdir/src/misc/ios/*.m"
40614035
have_misc=yes
40624036

@@ -4152,7 +4126,6 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
41524126

41534127
CheckVisibilityHidden
41544128
CheckDeclarationAfterStatement
4155-
CheckClockGettimeAPPLE
41564129
CheckDummyVideo
41574130
CheckDiskAudio
41584131
CheckDummyAudio

include/SDL_config.h.cmake

-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@
191191
#cmakedefine HAVE_SYSCONF 1
192192
#cmakedefine HAVE_SYSCTLBYNAME 1
193193
#cmakedefine HAVE_CLOCK_GETTIME 1
194-
#cmakedefine HAVE_CLOCK_GETTIME_NSEC_NP 1
195194
#cmakedefine HAVE_GETPAGESIZE 1
196195
#cmakedefine HAVE_MPROTECT 1
197196
#cmakedefine HAVE_ICONV 1

include/SDL_config.h.in

-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@
196196
#undef HAVE_SYSCONF
197197
#undef HAVE_SYSCTLBYNAME
198198
#undef HAVE_CLOCK_GETTIME
199-
#undef HAVE_CLOCK_GETTIME_NSEC_NP
200199
#undef HAVE_GETPAGESIZE
201200
#undef HAVE_MPROTECT
202201
#undef HAVE_ICONV

include/SDL_config_iphoneos.h

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
#define HAVE_REALLOC 1
5454
#define HAVE_FREE 1
5555
#define HAVE_ALLOCA 1
56-
#define HAVE_CLOCK_GETTIME_NSEC_NP 1
5756
#define HAVE_GETENV 1
5857
#define HAVE_SETENV 1
5958
#define HAVE_PUTENV 1

include/SDL_config_macosx.h

-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@
5656
#define HAVE_CALLOC 1
5757
#define HAVE_REALLOC 1
5858
#define HAVE_FREE 1
59-
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
60-
#define HAVE_CLOCK_GETTIME_NSEC_NP 1
61-
#endif
6259
#define HAVE_ALLOCA 1
6360
#define HAVE_GETENV 1
6461
#define HAVE_SETENV 1

src/timer/unix/SDL_systimer.c

+5-22
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@
4646
Also added OS X Monotonic clock support
4747
Based on work in https://github.com/ThomasHabets/monotonic_clock
4848
*/
49-
#if HAVE_NANOSLEEP || HAVE_CLOCK_GETTIME || HAVE_CLOCK_GETTIME_NSEC_NP
49+
#if HAVE_NANOSLEEP || HAVE_CLOCK_GETTIME
5050
#include <time.h>
5151
#endif
5252
#ifdef __APPLE__
5353
#include <mach/mach_time.h>
5454
#endif
5555

5656
/* Use CLOCK_MONOTONIC_RAW, if available, which is not subject to adjustment by NTP */
57-
#if HAVE_CLOCK_GETTIME || HAVE_CLOCK_GETTIME_NSEC_NP
57+
#if HAVE_CLOCK_GETTIME
5858
#ifdef CLOCK_MONOTONIC_RAW
5959
#define SDL_MONOTONIC_CLOCK CLOCK_MONOTONIC_RAW
6060
#else
@@ -65,7 +65,7 @@
6565
/* The first ticks value of the application */
6666
#if HAVE_CLOCK_GETTIME
6767
static struct timespec start_ts;
68-
#elif defined(__APPLE__) && !HAVE_CLOCK_GETTIME_NSEC_NP
68+
#elif defined(__APPLE__)
6969
static uint64_t start_mach;
7070
mach_timebase_info_data_t mach_base_info;
7171
#endif
@@ -87,17 +87,11 @@ SDL_TicksInit(void)
8787
has_monotonic_time = SDL_TRUE;
8888
} else
8989
#elif defined(__APPLE__)
90-
#if !HAVE_CLOCK_GETTIME_NSEC_NP
9190
kern_return_t ret = mach_timebase_info(&mach_base_info);
9291
if (ret == 0) {
9392
has_monotonic_time = SDL_TRUE;
9493
start_mach = mach_absolute_time();
9594
} else
96-
#else
97-
if (clock_gettime_nsec_np(SDL_MONOTONIC_CLOCK) > 0) {
98-
has_monotonic_time = SDL_TRUE;
99-
} else
100-
#endif
10195
#endif
10296
{
10397
gettimeofday(&start_tv, NULL);
@@ -124,12 +118,8 @@ SDL_GetTicks(void)
124118
clock_gettime(SDL_MONOTONIC_CLOCK, &now);
125119
ticks = (Uint32)((now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec - start_ts.tv_nsec) / 1000000);
126120
#elif defined(__APPLE__)
127-
#if !HAVE_CLOCK_GETTIME_NSEC_NP
128121
uint64_t now = mach_absolute_time();
129122
ticks = (Uint32)((((now - start_mach) * mach_base_info.numer) / mach_base_info.denom) / 1000000);
130-
#else
131-
ticks = (Uint32)clock_gettime_nsec_np(SDL_MONOTONIC_CLOCK);
132-
#endif
133123
#else
134124
SDL_assert(SDL_FALSE);
135125
ticks = 0;
@@ -160,11 +150,7 @@ SDL_GetPerformanceCounter(void)
160150
ticks *= 1000000000;
161151
ticks += now.tv_nsec;
162152
#elif defined(__APPLE__)
163-
#if !HAVE_CLOCK_GETTIME_NSEC_NP
164153
ticks = mach_absolute_time();
165-
#else
166-
ticks = (Uint32)clock_gettime_nsec_np(SDL_MONOTONIC_CLOCK);
167-
#endif
168154
#else
169155
SDL_assert(SDL_FALSE);
170156
ticks = 0;
@@ -191,16 +177,13 @@ SDL_GetPerformanceFrequency(void)
191177
#if HAVE_CLOCK_GETTIME
192178
return 1000000000;
193179
#elif defined(__APPLE__)
194-
#if !HAVE_CLOCK_GETTIME_NSEC_NP
195180
Uint64 freq = mach_base_info.denom;
196181
freq *= 1000000000;
197182
freq /= mach_base_info.numer;
198183
return freq;
199-
#else
200-
return 1000000000;
201-
#endif
202184
#endif
203-
}
185+
}
186+
204187
return 1000000;
205188
}
206189

0 commit comments

Comments
 (0)