--- a/SConstruct
+++ b/SConstruct
@@ -746,11 +746,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
@@ -15,7 +15,10 @@
 #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 *ts)
 {
 #ifdef __MACH__ // OS X and hurd do not have clock_gettime, use clock_get_time
@@ -43,6 +46,6 @@ int clock_gettime(clockid_t clk_id UNUSE
 #endif /* __MACH__ */
     return 0;
 }
-#endif /* HAVE_CLOCK_GETTIME */
+#endif /* _POSIX_TIMERS */
 
 /* end */
