Commit 7c077923 authored by Cody P Schafer's avatar Cody P Schafer Committed by Rusty Russell

configurator: sometimes _GNU_SOURCE is already defined, in those cases avoid redefinition

Config defines are disabled if a warning is emitted (we may want to
reconsider that), and warnings are emitted for define redefinition.
Signed-off-by: default avatarCody P Schafer <dev@codyps.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent eda7c5a2
...@@ -69,7 +69,9 @@ static struct test tests[] = { ...@@ -69,7 +69,9 @@ static struct test tests[] = {
{ "HAVE_ALIGNOF", INSIDE_MAIN, NULL, NULL, { "HAVE_ALIGNOF", INSIDE_MAIN, NULL, NULL,
"return __alignof__(double) > 0 ? 0 : 1;" }, "return __alignof__(double) > 0 ? 0 : 1;" },
{ "HAVE_ASPRINTF", DEFINES_FUNC, NULL, NULL, { "HAVE_ASPRINTF", DEFINES_FUNC, NULL, NULL,
"#ifndef _GNU_SOURCE\n"
"#define _GNU_SOURCE\n" "#define _GNU_SOURCE\n"
"#endif\n"
"#include <stdio.h>\n" "#include <stdio.h>\n"
"static char *func(int x) {" "static char *func(int x) {"
" char *p;\n" " char *p;\n"
...@@ -201,7 +203,9 @@ static struct test tests[] = { ...@@ -201,7 +203,9 @@ static struct test tests[] = {
"#include <unistd.h>\n" "#include <unistd.h>\n"
"static int func(void) { return getpagesize(); }" }, "static int func(void) { return getpagesize(); }" },
{ "HAVE_ISBLANK", DEFINES_FUNC, NULL, NULL, { "HAVE_ISBLANK", DEFINES_FUNC, NULL, NULL,
"#ifndef _GNU_SOURCE\n"
"#define _GNU_SOURCE\n" "#define _GNU_SOURCE\n"
"#endif\n"
"#include <ctype.h>\n" "#include <ctype.h>\n"
"static int func(void) { return isblank(' '); }" }, "static int func(void) { return isblank(' '); }" },
{ "HAVE_LITTLE_ENDIAN", INSIDE_MAIN|EXECUTE, NULL, NULL, { "HAVE_LITTLE_ENDIAN", INSIDE_MAIN|EXECUTE, NULL, NULL,
...@@ -209,13 +213,17 @@ static struct test tests[] = { ...@@ -209,13 +213,17 @@ static struct test tests[] = {
"u.i = 0x01020304;\n" "u.i = 0x01020304;\n"
"return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;" }, "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, { "HAVE_MEMMEM", DEFINES_FUNC, NULL, NULL,
"#ifndef _GNU_SOURCE\n"
"#define _GNU_SOURCE\n" "#define _GNU_SOURCE\n"
"#endif\n"
"#include <string.h>\n" "#include <string.h>\n"
"static void *func(void *h, size_t hl, void *n, size_t nl) {\n" "static void *func(void *h, size_t hl, void *n, size_t nl) {\n"
"return memmem(h, hl, n, nl);" "return memmem(h, hl, n, nl);"
"}\n", }, "}\n", },
{ "HAVE_MEMRCHR", DEFINES_FUNC, NULL, NULL, { "HAVE_MEMRCHR", DEFINES_FUNC, NULL, NULL,
"#ifndef _GNU_SOURCE\n"
"#define _GNU_SOURCE\n" "#define _GNU_SOURCE\n"
"#endif\n"
"#include <string.h>\n" "#include <string.h>\n"
"static void *func(void *s, int c, size_t n) {\n" "static void *func(void *s, int c, size_t n) {\n"
"return memrchr(s, c, n);" "return memrchr(s, c, n);"
...@@ -234,7 +242,9 @@ static struct test tests[] = { ...@@ -234,7 +242,9 @@ static struct test tests[] = {
"}\n" }, "}\n" },
{ "HAVE_QSORT_R_PRIVATE_LAST", { "HAVE_QSORT_R_PRIVATE_LAST",
DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE, NULL, NULL, DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE, NULL, NULL,
"#define _GNU_SOURCE 1\n" "#ifndef _GNU_SOURCE\n"
"#define _GNU_SOURCE\n"
"#endif\n"
"#include <stdlib.h>\n" "#include <stdlib.h>\n"
"static int cmp(const void *lp, const void *rp, void *priv) {\n" "static int cmp(const void *lp, const void *rp, void *priv) {\n"
" *(unsigned int *)priv = 1;\n" " *(unsigned int *)priv = 1;\n"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment