Skip to content

Commit

Permalink
Consolidated on gettimeofday for posix tick implementation
Browse files Browse the repository at this point in the history
Despite being marked as obselete, gettimeofday remains the better
supported posix api. A more portable library would conditionally switch
between the two, but for now supported both implementations has little
benefit.
  • Loading branch information
geky committed Jul 28, 2016
1 parent d823d44 commit 2cd841c
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions events_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,16 @@
#include "events_mutex.h"

#include <time.h>
#include <sys/time.h>


// Tick operations
#ifdef _POSIX_TIMERS

unsigned events_tick(void) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (unsigned)(ts.tv_sec*1000 + ts.tv_nsec/1000000);
}

#else
#include <sys/time.h>

unsigned events_tick(void) {
struct timeval tv;
gettimeofday(&tv, 0);
return (unsigned)(tv.tv_sec*1000 + tv.tv_usec/1000);
}

#endif


// Mutex operations
int events_mutex_create(events_mutex_t *m) {
Expand Down

0 comments on commit 2cd841c

Please sign in to comment.