summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Dritschler <timo.dritschler@kit.edu>2019-11-28 12:50:28 +0100
committerTimo Dritschler <timo.dritschler@kit.edu>2019-11-28 12:50:28 +0100
commit40ecf001fe8ec59defccdbeeaf54e8cf8c159e84 (patch)
tree05f7cef9ae1d7d927cb8ea9200853450ec79cac0
parentfb482cd0459e3d52694b14f2b13ca06dbc36c512 (diff)
downloadpcitool-40ecf001fe8ec59defccdbeeaf54e8cf8c159e84.tar.gz
pcitool-40ecf001fe8ec59defccdbeeaf54e8cf8c159e84.tar.bz2
pcitool-40ecf001fe8ec59defccdbeeaf54e8cf8c159e84.tar.xz
pcitool-40ecf001fe8ec59defccdbeeaf54e8cf8c159e84.zip
Check for new definition guard in glibc
Updated versions of glibc use a linux/time.h compliant definition guard https://sourceware.org/git/?p=glibc.git;a=commit;h=c1c2848b572ea7f92b7fa81dd5b1b9ef7c69b83b
-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) {