[ccan] [PATCH 1/9] time: rework HAVE_CLOCK_GETTIME to avoid conflicts with autoconf and other config.h sources

Rusty Russell rusty at rustcorp.com.au
Sat Jun 21 14:44:56 EST 2014


Cody P Schafer <dev at codyps.com> writes:
> CC: Rusty Russell <rusty at rustcorp.com.au>
> Signed-off-by: Cody P Schafer <dev at codyps.com>

Yes, the HAVE_CLOCK_GETTIME_IN_LIBRT || HAVE_CLOCK_GETTIME is a hack.

But I think that we should make configurator a bit smarter, rather
than opencoding in config.h.

I don't have a system which needs -lrt any more, but this should work.

Thoughts?
Rusty.

diff --git a/tools/configurator/configurator.c b/tools/configurator/configurator.c
index 5ba8cb0..e2d8806 100644
--- a/tools/configurator/configurator.c
+++ b/tools/configurator/configurator.c
@@ -55,6 +55,7 @@ struct test {
 	const char *depends;
 	const char *link;
 	const char *fragment;
+	const char *overrides; /* On success, force this to '1' */
 	bool done;
 	bool answer;
 };
@@ -142,7 +143,9 @@ static struct test tests[] = {
 	  "	struct timespec ts;\n"
 	  "	clock_gettime(CLOCK_REALTIME, &ts);\n"
 	  "	return ts;\n"
-	  "}\n" },
+	  "}\n",
+	  /* This means HAVE_CLOCK_GETTIME, too */
+	  "HAVE_CLOCK_GETTIME" },
 	{ "HAVE_COMPOUND_LITERALS", INSIDE_MAIN, NULL, NULL,
 	  "int *foo = (int[]) { 1, 2, 3, 4 };\n"
 	  "return foo[0] ? 0 : 1;" },
@@ -477,6 +480,12 @@ static bool run_test(const char *cmd, struct test *test)
 		test->answer = (status == 0);
 	}
 	test->done = true;
+
+	if (test->answer && test->overrides) {
+		struct test *override = find_test(test->overrides);
+		override->done = true;
+		override->answer = true;
+	}
 	return test->answer;
 }
 


More information about the ccan mailing list