]> git.ozlabs.org Git - ccan/blobdiff - tools/configurator/configurator.c
base64: fix for unsigned chars (e.g. ARM).
[ccan] / tools / configurator / configurator.c
index c0598509b8c0fa677ea426ab11e8b2a674f12838..7d8f6b095de4b6e615591b6fb37319a20fe603a3 100644 (file)
@@ -197,7 +197,7 @@ static const struct test base_tests[] = {
          "return __builtin_clzll(1) == (sizeof(long long)*8 - 1) ? 0 : 1;" },
        { "HAVE_BUILTIN_CTZ", "__builtin_ctz support",
          "INSIDE_MAIN", NULL, NULL,
-         "return __builtin_ctz(1 << (sizeof(int)*8 - 1)) == (sizeof(int)*8 - 1) ? 0 : 1;" },
+         "return __builtin_ctz(1U << (sizeof(int)*8 - 1)) == (sizeof(int)*8 - 1) ? 0 : 1;" },
        { "HAVE_BUILTIN_CTZL", "__builtin_ctzl support",
          "INSIDE_MAIN", NULL, NULL,
          "return __builtin_ctzl(1UL << (sizeof(long)*8 - 1)) == (sizeof(long)*8 - 1) ? 0 : 1;" },
@@ -471,7 +471,7 @@ static const struct test base_tests[] = {
          "#include <stddef.h>\n"
          "#include <ucontext.h>\n"
          "static int worked = 0;\n"
-         "static char stack[1024];\n"
+         "static char stack[8192];\n"
          "static ucontext_t a, b;\n"
          "static void fn(void *p, void *q) {\n"
          "     void *cp = &worked;\n"
@@ -498,6 +498,43 @@ static const struct test base_tests[] = {
          "     return __builtin_cpu_supports(\"mmx\");\n"
          "}"
        },
+       { "HAVE_CLOSEFROM", "closefrom() offered by system",
+         "DEFINES_EVERYTHING", NULL, NULL,
+         "#include <stdlib.h>\n"
+         "#include <unistd.h>\n"
+         "int main(void) {\n"
+         "    closefrom(STDERR_FILENO + 1);\n"
+         "    return 0;\n"
+         "}\n"
+       },
+       { "HAVE_F_CLOSEM", "F_CLOSEM defined for fctnl.",
+         "DEFINES_EVERYTHING", NULL, NULL,
+         "#include <fcntl.h>\n"
+         "#include <unistd.h>\n"
+         "int main(void) {\n"
+         "    int res = fcntl(STDERR_FILENO + 1, F_CLOSEM, 0);\n"
+         "    return res < 0;\n"
+         "}\n"
+       },
+       { "HAVE_NR_CLOSE_RANGE", "close_range syscall available as __NR_close_range.",
+         "DEFINES_EVERYTHING", NULL, NULL,
+         "#include <limits.h>\n"
+         "#include <sys/syscall.h>\n"
+         "#include <unistd.h>\n"
+         "int main(void) {\n"
+         "    int res = syscall(__NR_close_range, STDERR_FILENO + 1, INT_MAX, 0);\n"
+         "    return res < 0;\n"
+         "}\n"
+       },
+       { "HAVE_F_MAXFD", "F_MAXFD defined for fcntl.",
+         "DEFINES_EVERYTHING", NULL, NULL,
+         "#include <fcntl.h>\n"
+         "#include <unistd.h>\n"
+         "int main(void) {\n"
+         "    int res = fcntl(0, F_MAXFD);\n"
+         "    return res < 0;\n"
+         "}\n"
+       },
 };
 
 static void c12r_err(int eval, const char *fmt, ...)
@@ -760,12 +797,12 @@ static bool run_test(const char *cmd, const char *wrapper, struct test *test)
                /* We run INSIDE_MAIN tests for sanity checking. */
                if (strstr(test->style, "EXECUTE")
                    || strstr(test->style, "INSIDE_MAIN")) {
-                       char *cmd = malloc(strlen(wrapper) + strlen(" ." DIR_SEP OUTPUT_FILE) + 1);
+                       char *runcmd = malloc(strlen(wrapper) + strlen(" ." DIR_SEP OUTPUT_FILE) + 1);
 
-                       strcpy(cmd, wrapper);
-                       strcat(cmd, " ." DIR_SEP OUTPUT_FILE);
-                       output = run(cmd, &status);
-                       free(cmd);
+                       strcpy(runcmd, wrapper);
+                       strcat(runcmd, " ." DIR_SEP OUTPUT_FILE);
+                       output = run(runcmd, &status);
+                       free(runcmd);
                        if (!strstr(test->style, "EXECUTE") && status != 0)
                                c12r_errx(EXIT_BAD_TEST,
                                          "Test for %s failed with %i:\n%s",