[ccan] [PATCH] rework HAVE_CLOCK_GETTIME to avoid conflicts with autoconf and other config.h sources
Cody P Schafer
dev at codyps.com
Tue Jun 3 11:25:17 EST 2014
Signed-off-by: Cody P Schafer <dev at codyps.com>
---
ccan/time/time.c | 2 +-
tools/configurator/configurator.c | 9 +++++++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/ccan/time/time.c b/ccan/time/time.c
index 166832d..18867d5 100644
--- a/ccan/time/time.c
+++ b/ccan/time/time.c
@@ -3,7 +3,7 @@
#include <stdlib.h>
#include <stdio.h>
-#if !HAVE_CLOCK_GETTIME && !HAVE_CLOCK_GETTIME_IN_LIBRT
+#if !HAVE_CLOCK_GETTIME
#include <sys/time.h>
struct timespec time_now(void)
diff --git a/tools/configurator/configurator.c b/tools/configurator/configurator.c
index 5ba8cb0..ed6acbf 100644
--- a/tools/configurator/configurator.c
+++ b/tools/configurator/configurator.c
@@ -125,7 +125,7 @@ static struct test tests[] = {
"return __builtin_types_compatible_p(char *, int) ? 1 : 0;" },
{ "HAVE_BYTESWAP_H", OUTSIDE_MAIN, NULL, NULL,
"#include <byteswap.h>\n" },
- { "HAVE_CLOCK_GETTIME",
+ { "HAVE_CLOCK_GETTIME_WITHOUT_LIBS",
DEFINES_FUNC, "HAVE_STRUCT_TIMESPEC", NULL,
"#include <time.h>\n"
"static struct timespec func(void) {\n"
@@ -135,7 +135,7 @@ static struct test tests[] = {
"}\n" },
{ "HAVE_CLOCK_GETTIME_IN_LIBRT",
DEFINES_FUNC,
- "HAVE_STRUCT_TIMESPEC !HAVE_CLOCK_GETTIME",
+ "HAVE_STRUCT_TIMESPEC !HAVE_CLOCK_GETTIME_WITHOUT_LIBS",
"-lrt",
"#include <time.h>\n"
"static struct timespec func(void) {\n"
@@ -528,6 +528,11 @@ int main(int argc, const char *argv[])
printf("#define HAVE_CCAN 1\n");
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
printf("#define %s %u\n", tests[i].name, tests[i].answer);
+ printf("#if defined(HAVE_CLOCK_GETTIME_IN_LIBRT) || defined(HAVE_CLOCK_GETTIME_WITHOUT_LIBS)\n");
+ printf("#define HAVE_CLOCK_GETTIME 1\n");
+ printf("#else\n");
+ printf("#define HAVE_CLOCK_GETTIME 0\n");
+ printf("#endif\n");
printf("#endif /* CCAN_CONFIG_H */\n");
return 0;
}
--
1.9.3
More information about the ccan
mailing list