ObjFW  Check-in [af603291de]

Overview
Comment:configure: Check return type of strerror_r

Just checking for _GNU_SOURCE is not enough, because musl still returns
int even with _GNU_SOURCE, despite the musl header explicitly checking
for _GNU_SOURCE.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: af603291ded3a04c7424f745089d7a219499de5926277f2a1f59838facb82cfa
User & Date: js on 2020-04-05 13:23:24
Other Links: manifest | tags
Context
2020-04-05
14:22
Work around musl having broken dlclose() check-in: 29c8a7106b user: js tags: trunk
13:23
configure: Check return type of strerror_r check-in: af603291de user: js tags: trunk
11:46
configure: Check whether *_l need _GNU_SOURCE check-in: fdbe09e8ea user: js tags: trunk
Changes

Modified configure.ac from [d98714da44] to [8e938279fe].

821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
			AC_MSG_RESULT(yes)
		], [
			AC_MSG_RESULT(no)
		])
		;;
esac

AC_CHECK_FUNCS(strerror_r)

AC_CHECK_LIB(m, fmod, LIBS="$LIBS -lm")
AC_CHECK_LIB(complex, creal, TESTS_LIBS="$TESTS_LIBS -lcomplex")

AC_CHECK_FUNC(asprintf, [
	case "$host" in
		*-psp-*)
			dnl asprintf is broken on the PSP, but snprintf works.







<
<







821
822
823
824
825
826
827


828
829
830
831
832
833
834
			AC_MSG_RESULT(yes)
		], [
			AC_MSG_RESULT(no)
		])
		;;
esac



AC_CHECK_LIB(m, fmod, LIBS="$LIBS -lm")
AC_CHECK_LIB(complex, creal, TESTS_LIBS="$TESTS_LIBS -lcomplex")

AC_CHECK_FUNC(asprintf, [
	case "$host" in
		*-psp-*)
			dnl asprintf is broken on the PSP, but snprintf works.
1261
1262
1263
1264
1265
1266
1267




















1268
1269
1270
1271
1272
1273
1274
	], [
		AC_MSG_RESULT(no)
	], [
		AC_MSG_RESULT(yes)
		CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
	])
])





















AC_CHECK_HEADERS(sys/utsname.h)
AC_CHECK_FUNCS(uname)

case "$host_os" in
	amigaos*)
		;;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
	], [
		AC_MSG_RESULT(no)
	], [
		AC_MSG_RESULT(yes)
		CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
	])
])

dnl This check needs to happen after the above, as _GNU_SOURCE can change the
dnl return type.
AC_CHECK_FUNCS(strerror_r, [
	AC_MSG_CHECKING(for return type of strerror_r)
	AC_TRY_COMPILE([
		#include <stdio.h>
		#include <string.h>
	], [
		switch (strerror_r(0, NULL, 0)) {
		case 0:;
		}
	], [
		AC_MSG_RESULT(int)
	], [
		AC_MSG_RESULT(char *)
		AC_DEFINE(STRERROR_R_RETURNS_CHARP, 1,
			[Whether strerror_r returns char *])
	])
])

AC_CHECK_HEADERS(sys/utsname.h)
AC_CHECK_FUNCS(uname)

case "$host_os" in
	amigaos*)
		;;

Modified src/exceptions/OFException.m from [0f0c49d47c] to [3cf46d2139].

167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
	case EUSERS:
		return @"EUSERS";
	case EWOULDBLOCK:
		return @"EWOULDBLOCK";
	}
#endif

#if defined(HAVE_STRERROR_R) && defined(_GNU_SOURCE)
	/* glibc uses a different strerror_r when _GNU_SOURCE is defined */
	char *string;

	if ((string = strerror_r(errNo, buffer, 256)) == NULL)
		return @"Unknown error (strerror_r failed)";

	ret = [OFString stringWithCString: string







|







167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
	case EUSERS:
		return @"EUSERS";
	case EWOULDBLOCK:
		return @"EWOULDBLOCK";
	}
#endif

#if defined(STRERROR_R_RETURNS_CHARP)
	/* glibc uses a different strerror_r when _GNU_SOURCE is defined */
	char *string;

	if ((string = strerror_r(errNo, buffer, 256)) == NULL)
		return @"Unknown error (strerror_r failed)";

	ret = [OFString stringWithCString: string