X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fconfigurator%2Fconfigurator.c;h=5d959cf33c6b04bdad29c8df6fb3d5f7e77874bc;hb=98d16c40f7cb21268751da58c0cb0d14efd38c5a;hp=fe1611e4b525312e8f5dbbccadaaa4eac56eb28d;hpb=b2be425ed39cce4d0af29952607362fa05e48079;p=ccan diff --git a/tools/configurator/configurator.c b/tools/configurator/configurator.c index fe1611e4..5d959cf3 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 *flags; const char *overrides; /* On success, force this to '1' */ bool done; bool answer; @@ -310,6 +311,60 @@ static struct test tests[] = { "static __attribute__((warn_unused_result)) int func(int i) {\n" " return i + 1;\n" "}" }, + { "HAVE_OPENMP", INSIDE_MAIN, NULL, NULL, + "int i;\n" + "#pragma omp parallel for\n" + "for(i = 0; i < 0; i++) {};\n" + "return 0;\n", + "-Werror -fopenmp" }, + { "HAVE_VALGRIND_MEMCHECK_H", OUTSIDE_MAIN, NULL, NULL, + "#include \n" }, + { "HAVE_UCONTEXT", DEFINES_EVERYTHING|EXECUTE, + NULL, NULL, + "#include \n" + "static int x = 0;\n" + "static char stack[2048];\n" + "static ucontext_t a, b;\n" + "static void fn(void) {\n" + " x |= 2;\n" + " setcontext(&b);\n" + " x |= 4;\n" + "}\n" + "int main(int argc, char *argv[]) {\n" + " x |= 1;\n" + " getcontext(&a);\n" + " a.uc_stack.ss_sp = stack;\n" + " a.uc_stack.ss_size = sizeof(stack);\n" + " makecontext(&a, fn, 0);\n" + " swapcontext(&b, &a);\n" + " return (x == 3) ? 0 : 1;\n" + "}\n" + }, + { "HAVE_POINTER_SAFE_MAKECONTEXT", DEFINES_EVERYTHING|EXECUTE, + "HAVE_UCONTEXT", NULL, + "#include \n" + "#include \n" + "static int worked = 0;\n" + "static char stack[1024];\n" + "static ucontext_t a, b;\n" + "static void fn(void *p, void *q) {\n" + " void *cp = &worked;\n" + " void *cq = (void *)(~((ptrdiff_t)cp));\n" + " if ((p == cp) && (q == cq))\n" + " worked = 1;\n" + " setcontext(&b);\n" + "}\n" + "int main(int argc, char *argv[]) {\n" + " void *ap = &worked;\n" + " void *aq = (void *)(~((ptrdiff_t)ap));\n" + " getcontext(&a);\n" + " a.uc_stack.ss_sp = stack;\n" + " a.uc_stack.ss_size = sizeof(stack);\n" + " makecontext(&a, (void (*)(void))fn, 2, ap, aq);\n" + " swapcontext(&b, &a);\n" + " return worked ? 0 : 1;\n" + "}\n" + }, }; static char *grab_fd(int fd) @@ -415,7 +470,7 @@ static struct test *find_test(const char *name) static bool run_test(const char *cmd, struct test *test) { - char *output; + char *output, *newcmd; FILE *outf; int status; @@ -488,19 +543,33 @@ static bool run_test(const char *cmd, struct test *test) fclose(outf); if (verbose > 1) - if (system("cat " INPUT_FILE) == -1); + if (system("cat " INPUT_FILE) == -1) + ; + + newcmd = strdup(cmd); + + if (test->flags) { + newcmd = realloc(newcmd, strlen(newcmd) + strlen(" ") + + strlen(test->flags) + 1); + strcat(newcmd, " "); + strcat(newcmd, test->flags); + if (verbose > 1) + printf("Extra flags line: %s", newcmd); + } if (test->link) { - char *newcmd; - newcmd = malloc(strlen(cmd) + strlen(" ") + newcmd = realloc(newcmd, strlen(newcmd) + strlen(" ") + strlen(test->link) + 1); - sprintf(newcmd, "%s %s", cmd, test->link); + strcat(newcmd, " "); + strcat(newcmd, test->link); if (verbose > 1) printf("Extra link line: %s", newcmd); - cmd = newcmd; } - output = run(cmd, &status); + output = run(newcmd, &status); + + free(newcmd); + if (status != 0 || strstr(output, "warning")) { if (verbose) printf("Compile %s for %s, status %i: %s\n",