Skip to content

Commit

Permalink
Fix clock_gettime() compatibility (#3896) (#4574)
Browse files Browse the repository at this point in the history
  • Loading branch information
twose authored Jan 17, 2022
1 parent d20e816 commit 3b51a8f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions include/swoole.h
Original file line number Diff line number Diff line change
Expand Up @@ -552,14 +552,14 @@ int swoole_set_cpu_affinity(cpu_set_t *set);
#ifndef HAVE_CLOCK_GETTIME
#define HAVE_CLOCK_GETTIME
#endif
#define swoole_clock_gettime clock_gettime
#define swoole_clock_realtime(t) clock_gettime(CLOCK_REALTIME, t)
#elif defined(__APPLE__)
int swoole_clock_gettime(int which_clock, struct timespec *t);
int swoole_clock_realtime(struct timespec *t);
#endif

static inline struct timespec swoole_time_until(int milliseconds) {
struct timespec t;
swoole_clock_gettime(CLOCK_REALTIME, &t);
swoole_clock_realtime(&t);

int sec = milliseconds / 1000;
int msec = milliseconds - (sec * 1000);
Expand Down
2 changes: 1 addition & 1 deletion src/core/timer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
static double orwl_timebase = 0.0;
static uint64_t orwl_timestart = 0;

int swoole_clock_gettime(int which_clock, struct timespec *t) {
int swoole_clock_realtime(struct timespec *t) {
// be more careful in a multithreaded environement
if (!orwl_timestart) {
mach_timebase_info_data_t tb = {0};
Expand Down

0 comments on commit 3b51a8f

Please sign in to comment.