From 40ecf001fe8ec59defccdbeeaf54e8cf8c159e84 Mon Sep 17 00:00:00 2001 From: Timo Dritschler Date: Thu, 28 Nov 2019 12:50:28 +0100 Subject: 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 --- pcilib/event.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'pcilib') 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) { -- cgit v1.2.3