Skip to content

Commit

Permalink
Merge pull request #937 from cellularmitosis/clock1012
Browse files Browse the repository at this point in the history
Mac clock shim not needed after 10.12
  • Loading branch information
bakpakin committed Mar 23, 2022
2 parents b60ef68 + e9870b2 commit 9d0da74
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
10 changes: 0 additions & 10 deletions src/core/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
#include <sys/stat.h>
#include <signal.h>

#ifdef JANET_APPLE
#include <AvailabilityMacros.h>
#endif

#ifdef JANET_WINDOWS
#include <windows.h>
#include <direct.h>
Expand All @@ -67,12 +63,6 @@ extern char **environ;
#endif
#endif

/* For macos */
#ifdef JANET_APPLE
#include <mach/clock.h>
#include <mach/mach.h>
#endif

/* Not POSIX, but all Unixes but Solaris have this function. */
#if defined(JANET_POSIX) && !defined(__sun)
time_t timegm(struct tm *tm);
Expand Down
14 changes: 8 additions & 6 deletions src/core/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
#endif
#endif

#ifdef JANET_APPLE
#include <AvailabilityMacros.h>
#endif

#include <inttypes.h>

/* Base 64 lookup table for digits */
Expand Down Expand Up @@ -789,11 +793,6 @@ int32_t janet_sorted_keys(const JanetKV *dict, int32_t cap, int32_t *index_buffe

/* Clock shims for various platforms */
#ifdef JANET_GETTIME
/* For macos */
#ifdef JANET_APPLE
#include <mach/clock.h>
#include <mach/mach.h>
#endif
#ifdef JANET_WINDOWS
int janet_gettime(struct timespec *spec) {
FILETIME ftime;
Expand All @@ -806,7 +805,10 @@ int janet_gettime(struct timespec *spec) {
spec->tv_nsec = wintime % 10000000LL * 100;
return 0;
}
#elif defined(JANET_APPLE)
/* clock_gettime() wasn't available on Mac until 10.12. */
#elif defined(JANET_APPLE) && !defined(MAC_OS_X_VERSION_10_12)
#include <mach/clock.h>
#include <mach/mach.h>
int janet_gettime(struct timespec *spec) {
clock_serv_t cclock;
mach_timespec_t mts;
Expand Down

0 comments on commit 9d0da74

Please sign in to comment.