summaryrefslogtreecommitdiffstats
path: root/pcilib
diff options
context:
space:
mode:
Diffstat (limited to 'pcilib')
-rw-r--r--pcilib/event.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/pcilib/event.c b/pcilib/event.c
index 6b37dac..7e1adcc 100644
--- a/pcilib/event.c
+++ b/pcilib/event.c
@@ -19,12 +19,22 @@
#include "tools.h"
#include "error.h"
-#ifndef __timespec_defined
+/* Newer versions of glibc guard timespec with a different definition guard, compliant to linux/time.h
+ * We need to check for both definition guards to prevent accidental redifinitions of struct timespec
+ */
+#if (defined(__timespec_defined) && __timespec_defined) || \
+ (defined(_STRUCT_TIMESPEC) && _STRUCT_TIMESPEC)
+#define PCILIB_DEFINE_TIMESPEC 0
+#else
+#define PCILIB_DEFINE_TIMESPEC 1
+#endif
+
+#if (defined(PCILIB_DEFINE_TIMESPEC) && PCILIB_DEFINE_TIMESPEC)
struct timespec {
time_t tv_sec;
long tv_nsec;
};
-#endif /* __timespec_defined */
+#endif /* PCILIB_DEFINE_TIMESPEC */
pcilib_event_t pcilib_find_event(pcilib_t *ctx, const char *event) {