[Bug sanitizer/59369] c-c++-common/asan/pr59063-[1,2].c fails on darwin
howarth at nitro dot med.uc.edu
gcc-bugzilla@gcc.gnu.org
Mon Dec 2 20:58:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59369
--- Comment #1 from Jack Howarth <howarth at nitro dot med.uc.edu> ---
From
http://stackoverflow.com/questions/5167269/clock-gettime-alternative-in-mac-os-x,
the following code would work on darwin, but I'm not sure if the test is still
valid...
/* { dg-do run } */
#ifdef __MACH__
#define CLOCK_MONOTONIC 0
#include <sys/time.h>
static int weak_gettime (int clk_id, struct timespec *tp)
__attribute__((__weakref__("clock_gettime")));
int clock_gettime(int clk_id, struct timespec* tp) {
struct timeval now;
int rv = gettimeofday(&now, NULL);
if (rv) return rv;
tp->tv_sec = now.tv_sec;
tp->tv_nsec = now.tv_usec * 1000;
return 0;
}
#else
#include <time.h>
static int weak_gettime (clockid_t clk_id, struct timespec *tp)
__attribute__((__weakref__("clock_gettime")));
#endif
int main() {
if (!clock_gettime)
return 0;
struct timespec ts;
return weak_gettime(CLOCK_MONOTONIC, &ts);
}
More information about the Gcc-bugs
mailing list