X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fconfigurator%2Fconfigurator.c;h=3bf5e498d262acb5e50efe5c0fb188ec2cf51185;hb=7c077923bccea4f855715c06f06a5df734bc75a0;hp=f4edb8ee1b214dbf97106bffe91335b12d5737ac;hpb=7011546929cfc537028eb4fd091104b383b5c86f;p=ccan diff --git a/tools/configurator/configurator.c b/tools/configurator/configurator.c index f4edb8ee..3bf5e498 100644 --- a/tools/configurator/configurator.c +++ b/tools/configurator/configurator.c @@ -69,7 +69,9 @@ static struct test tests[] = { { "HAVE_ALIGNOF", INSIDE_MAIN, NULL, NULL, "return __alignof__(double) > 0 ? 0 : 1;" }, { "HAVE_ASPRINTF", DEFINES_FUNC, NULL, NULL, + "#ifndef _GNU_SOURCE\n" "#define _GNU_SOURCE\n" + "#endif\n" "#include \n" "static char *func(int x) {" " char *p;\n" @@ -201,7 +203,9 @@ static struct test tests[] = { "#include \n" "static int func(void) { return getpagesize(); }" }, { "HAVE_ISBLANK", DEFINES_FUNC, NULL, NULL, + "#ifndef _GNU_SOURCE\n" "#define _GNU_SOURCE\n" + "#endif\n" "#include \n" "static int func(void) { return isblank(' '); }" }, { "HAVE_LITTLE_ENDIAN", INSIDE_MAIN|EXECUTE, NULL, NULL, @@ -209,13 +213,17 @@ static struct test tests[] = { "u.i = 0x01020304;\n" "return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;" }, { "HAVE_MEMMEM", DEFINES_FUNC, NULL, NULL, + "#ifndef _GNU_SOURCE\n" "#define _GNU_SOURCE\n" + "#endif\n" "#include \n" "static void *func(void *h, size_t hl, void *n, size_t nl) {\n" "return memmem(h, hl, n, nl);" "}\n", }, { "HAVE_MEMRCHR", DEFINES_FUNC, NULL, NULL, + "#ifndef _GNU_SOURCE\n" "#define _GNU_SOURCE\n" + "#endif\n" "#include \n" "static void *func(void *s, int c, size_t n) {\n" "return memrchr(s, c, n);" @@ -234,7 +242,9 @@ static struct test tests[] = { "}\n" }, { "HAVE_QSORT_R_PRIVATE_LAST", DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE, NULL, NULL, - "#define _GNU_SOURCE 1\n" + "#ifndef _GNU_SOURCE\n" + "#define _GNU_SOURCE\n" + "#endif\n" "#include \n" "static int cmp(const void *lp, const void *rp, void *priv) {\n" " *(unsigned int *)priv = 1;\n" @@ -282,7 +292,8 @@ static struct test tests[] = { "int main(int argc, char *argv[]) {\n" " char pad[sizeof(int *) * 1];\n" " strncpy(pad, argv[0], sizeof(pad));\n" - " return *(int *)(pad) == *(int *)(pad + 1);\n" + " int *x = (int *)pad, *y = (int *)(pad + 1);\n" + " return *x == *y;\n" "}\n" }, { "HAVE_UTIME", DEFINES_FUNC, NULL, NULL, "#include \n" @@ -430,6 +441,9 @@ static bool run_test(const char *cmd, struct test *test) test->done = true; return test->answer; } + if (deps[len]) + free(dep); + deps += len; deps += strspn(deps, " "); } @@ -549,6 +563,7 @@ int main(int argc, const char *argv[]) cmd = connect_args(argv, " -o " OUTPUT_FILE " " INPUT_FILE); for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) run_test(cmd, &tests[i]); + free(cmd); unlink(OUTPUT_FILE); unlink(INPUT_FILE); @@ -560,7 +575,9 @@ int main(int argc, const char *argv[]) printf("#define _GNU_SOURCE /* Always use GNU extensions. */\n"); printf("#endif\n"); printf("#define CCAN_COMPILER \"%s\"\n", argv[1]); - printf("#define CCAN_CFLAGS \"%s\"\n\n", connect_args(argv+1, "")); + cmd = connect_args(argv+1, ""); + printf("#define CCAN_CFLAGS \"%s\"\n\n", cmd); + free(cmd); /* This one implies "#include