Commit 9343ebfc authored by Petr Pisar's avatar Petr Pisar

Check for _XOPEN_SOURCE level needed for strdup()

500 is needed on glibc, 600 on Mac OS X.
Thanks to Boris Dušek for reporting this issue.

<rdar://problem/19363342>
parent 4d488279
#define _XOPEN_SOURCE 500
#include "../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
......
#define _XOPEN_SOURCE 500
#include "../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
......
#define _XOPEN_SOURCE 500
#include "../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
......
#define _XOPEN_SOURCE 500
#include "../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
......
#define _XOPEN_SOURCE 500
#include "../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
......
#define _XOPEN_SOURCE 500
#include "../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
......
#define _XOPEN_SOURCE 500
#include "../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
......
#define _XOPEN_SOURCE 500
#include "../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
......
#define _XOPEN_SOURCE 500
#include "../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
......
#define _XOPEN_SOURCE 500
#include "../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
......
#define _XOPEN_SOURCE 500
#include "../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
......
#define _XOPEN_SOURCE 500
#include "../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
......
#define _XOPEN_SOURCE 500
#include "../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
......
#define _XOPEN_SOURCE 500
#include "../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
......
#define _XOPEN_SOURCE 500
#include "../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
......
......@@ -186,6 +186,27 @@ AC_CHECK_FUNCS([localtime_r memset munmap setlocale strdup strerror])
# Default CFLAGS
CFLAGS="${CFLAGS} -std=c99 -Wall"
dnl Check for strdup() feature test macros
dnl strdup() is provided since SUSv2, thus _XOPEN_SOURCE >= 500 has to be
dnl defined with -std=c99. However Mac OS X requires 600. Reported as
dnl <rdar://problem/19363342>.
AC_MSG_CHECKING([Checking for _XOPEN_SOURCE level needed for strdup()])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#define _XOPEN_SOURCE 500
#include <string.h>]], [[(void)strdup("");]])],
[xopen_source_level_for_strdup=500],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#define _XOPEN_SOURCE 600
#include <string.h>]], [[(void)strdup("");]])],
[xopen_source_level_for_strdup=600],
[AC_MSG_FAILURE([Cannot determine _XOPEN_SOURCE level for strdup()])]
)])
AC_MSG_RESULT([$xopen_source_level_for_strdup])
AC_DEFINE_UNQUOTED([XOPEN_SOURCE_LEVEL_FOR_STRDUP],
[$xopen_source_level_for_strdup],
[_XOPEN_SOURCE level needed for strdup()])
AC_CONFIG_FILES([Makefile src/Makefile po/Makefile.in client/Makefile
test/Makefile test/offline/Makefile test/simline/Makefile
test/online/Makefile libisds.pc])
......
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 500 /* For strdup() */
#include "../../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#endif
#include "http.h"
......
......@@ -10,7 +10,7 @@
#endif
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600 /* For unsetenv(3) */
#define _XOPEN_SOURCE 600 /* For unsetenv(3) and strdup(3) */
#endif
#include "../test.h"
......
#define _XOPEN_SOURCE 500 /* For strdup(3) */
#include "../../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include "../test-tools.h"
#include "http.h"
#include "services.h"
......
#include "../../config.h"
#define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
#include "../test-tools.h"
#include <stdio.h>
#include <string.h>
......
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