--- a/SConstruct
+++ b/SConstruct
@@ -744,11 +744,13 @@ typedef int clockid_t;
 # endif
 /* OS X uses _STRUCT_TIMESPEC, but no clock_gettime */
 #ifndef _STRUCT_TIMESPEC
+#ifndef __timespec_defined
 struct timespec {
     time_t  tv_sec;
     long    tv_nsec;
 };
 #endif
+#endif
 #define CLOCK_REALTIME	0
 int clock_gettime(clockid_t, struct timespec *);
 # ifdef __cplusplus
--- a/clock_gettime.c
+++ b/clock_gettime.c
@@ -14,7 +14,9 @@
 #include <mach/mach.h>
 #endif
 
-#ifndef HAVE_CLOCK_GETTIME
+#include <unistd.h>
+
+#ifndef _POSIX_TIMERS
 int clock_gettime(clockid_t clk_id UNUSED, struct timespec *tp)
 {
 #ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
@@ -42,6 +44,6 @@ int clock_gettime(clockid_t clk_id UNUSE
 #endif /* __MACH__ */
     return 0;
 }
-#endif /* HAVE_CLOCK_GETTIME */
+#endif /* _POSIX_TIMERS */
 
 /* end */
