"static int __attribute__((cold)) func(int x) { return x; }" },
{ "HAVE_ATTRIBUTE_CONST", DEFINES_FUNC, NULL, NULL,
"static int __attribute__((const)) func(int x) { return x; }" },
+ { "HAVE_ATTRIBUTE_PURE", DEFINES_FUNC, NULL, NULL,
+ "static int __attribute__((pure)) func(int x) { return x; }" },
{ "HAVE_ATTRIBUTE_MAY_ALIAS", OUTSIDE_MAIN, NULL, NULL,
"typedef short __attribute__((__may_alias__)) short_a;" },
{ "HAVE_ATTRIBUTE_NORETURN", DEFINES_FUNC, NULL, NULL,
{ "HAVE_COMPOUND_LITERALS", INSIDE_MAIN, NULL, NULL,
"int *foo = (int[]) { 1, 2, 3, 4 };\n"
"return foo[0] ? 0 : 1;" },
+ { "HAVE_FCHDIR", DEFINES_EVERYTHING|EXECUTE, NULL, NULL,
+ "#include <sys/types.h>\n"
+ "#include <sys/stat.h>\n"
+ "#include <fcntl.h>\n"
+ "#include <unistd.h>\n"
+ "int main(void) {\n"
+ " int fd = open(\"..\", O_RDONLY);\n"
+ " return fchdir(fd) == 0 ? 0 : 1;\n"
+ "}\n" },
{ "HAVE_ERR_H", DEFINES_FUNC, NULL, NULL,
"#include <err.h>\n"
"static void func(int arg) {\n"
"return ({ int x = argc; x == argc ? 0 : 1; });" },
{ "HAVE_SYS_FILIO_H", OUTSIDE_MAIN, NULL, NULL, /* Solaris needs this for FIONREAD */
"#include <sys/filio.h>\n" },
+ { "HAVE_SYS_TERMIOS_H", OUTSIDE_MAIN, NULL, NULL,
+ "#include <sys/termios.h>\n" },
{ "HAVE_TYPEOF", INSIDE_MAIN, NULL, NULL,
"__typeof__(argc) i; i = argc; return i == argc ? 0 : 1;" },
{ "HAVE_UTIME", DEFINES_FUNC, NULL, NULL,
for (i = 1; argv[i]; i++) {
strcpy(ret + len, argv[i]);
len += strlen(argv[i]);
- ret[len++] = ' ';
+ if (argv[i+1])
+ ret[len++] = ' ';
}
strcpy(ret + len, extra);
return ret;
if (argc == 1)
argv = default_args;
- cmd = connect_args(argv, "-o " OUTPUT_FILE " " INPUT_FILE);
+ cmd = connect_args(argv, " -o " OUTPUT_FILE " " INPUT_FILE);
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
run_test(cmd, &tests[i]);
unlink(OUTPUT_FILE);
unlink(INPUT_FILE);
- cmd[strlen(cmd) - strlen(" -o " OUTPUT_FILE " " INPUT_FILE)] = '\0';
printf("/* Generated by CCAN configurator */\n"
"#ifndef CCAN_CONFIG_H\n"
"#define CCAN_CONFIG_H\n");
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", cmd + strlen(argv[1]) + 1);
+ printf("#define CCAN_CFLAGS \"%s\"\n\n", connect_args(argv+1, ""));
/* This one implies "#include <ccan/..." works, eg. for tdb2.h */
printf("#define HAVE_CCAN 1\n");
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)