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;
static struct test tests[] = {
{ "HAVE_32BIT_OFF_T", DEFINES_EVERYTHING|EXECUTE, NULL, NULL,
"#include <sys/types.h>\n"
- "int main(int argc, char *argv[]) {\n"
+ "int main(void) {\n"
" return sizeof(off_t) == 4 ? 0 : 1;\n"
"}\n" },
{ "HAVE_ALIGNOF", INSIDE_MAIN, NULL, NULL,
"#include <stdlib.h>\n"
"static void __attribute__((noreturn)) func(int x) { exit(x); }" },
{ "HAVE_ATTRIBUTE_PRINTF", DEFINES_FUNC, NULL, NULL,
- "static void __attribute__((format(__printf__, 1, 2))) func(const char *fmt, ...) { }" },
+ "static void __attribute__((format(__printf__, 1, 2))) func(const char *fmt, ...) { (void)fmt; }" },
{ "HAVE_ATTRIBUTE_UNUSED", OUTSIDE_MAIN, NULL, NULL,
"static int __attribute__((unused)) func(int x) { return x; }" },
{ "HAVE_ATTRIBUTE_USED", OUTSIDE_MAIN, NULL, NULL,
"HAVE_32BIT_OFF_T", NULL,
"#define _FILE_OFFSET_BITS 64\n"
"#include <sys/types.h>\n"
- "int main(int argc, char *argv[]) {\n"
+ "int main(void) {\n"
" return sizeof(off_t) == 8 ? 0 : 1;\n"
"}\n" },
{ "HAVE_FOR_LOOP_DECLARATION", INSIDE_MAIN, NULL, NULL,
" return nest(base, i-1);\n"
"}\n"
"int main(int argc, char *argv[]) {\n"
- " return (nest(&argc, argc) > 0) ? 0 : 1\n;"
+ " (void)argv;\n"
+ " return (nest(&argc, argc) > 0) ? 0 : 1;\n"
"}\n" },
{ "HAVE_STATEMENT_EXPR", INSIDE_MAIN, NULL, NULL,
"return ({ int x = argc; x == argc ? 0 : 1; });" },
{ "HAVE_UNALIGNED_ACCESS", DEFINES_EVERYTHING|EXECUTE, NULL, NULL,
"#include <string.h>\n"
"int main(int argc, char *argv[]) {\n"
+ " (void)argc;\n"
" char pad[sizeof(int *) * 1];\n"
" strncpy(pad, argv[0], sizeof(pad));\n"
" int *x = (int *)pad, *y = (int *)(pad + 1);\n"
"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 <valgrind/memcheck.h>\n" },
};
static char *grab_fd(int fd)
}
#define PRE_BOILERPLATE "/* Test program generated by configurator. */\n"
-#define MAIN_START_BOILERPLATE "int main(int argc, char *argv[]) {\n"
+#define MAIN_START_BOILERPLATE \
+ "int main(int argc, char *argv[]) {\n" \
+ " (void)argc;\n" \
+ " (void)argv;\n"
#define USE_FUNC_BOILERPLATE "(void)func;\n"
#define MAIN_BODY_BOILERPLATE "return 0;\n"
#define MAIN_END_BOILERPLATE "}\n"
static bool run_test(const char *cmd, struct test *test)
{
- char *output;
+ char *output, *newcmd;
FILE *outf;
int status;
if (verbose > 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",