ObjFW  Check-in [ec36a82d68]

Overview
Comment:Make things work with glibc 2.17 and Clang 3.4.2
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ec36a82d68b85d77fa255b1000801ccba3dbf9247e0601e54c5c75869e50eb7d
User & Date: js on 2017-05-27 10:08:11
Other Links: manifest | tags
Context
2017-05-27
10:33
Add unistd.h wrapper to make things less horrible check-in: d31ec806ef user: js tags: trunk
10:08
Make things work with glibc 2.17 and Clang 3.4.2 check-in: ec36a82d68 user: js tags: trunk
08:56
+[OFHTTPCookie requestHeaderFieldsWithCookies:] check-in: 8896ef883e user: js tags: trunk
Changes

Modified configure.ac from [2d6f795b86] to [d691fbf5a5].

192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
], [
	AC_MSG_RESULT(yes)
], [
	AC_MSG_RESULT(no)
	AC_MSG_ERROR(Compiler does not support properties!)
])

AC_MSG_CHECKING(whether Objective C compiler supports blocks)
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -fblocks"
AC_TRY_COMPILE([], [
	int (^foo)(int bar);
	foo = ^ (int bar) { return 0; }
], [
	AC_SUBST(BLOCKS_FLAGS, "-fblocks")
	AC_SUBST(OFBLOCKTESTS_M, "OFBlockTests.m")
	AC_MSG_RESULT(yes)
], [
	AC_MSG_RESULT(no)
	OBJCFLAGS="$old_OBJCFLAGS"
])

AC_CHECK_TOOL(AR, ar)
AC_PROG_RANLIB
AC_ARG_ENABLE(shared,
	AS_HELP_STRING([--disable-shared], [do not build shared library]))
AS_IF([test x"$enable_shared" != x"no"], [
	BUILDSYS_SHARED_LIB
	AC_SUBST(OBJFW_SHARED_LIB, "${LIB_PREFIX}objfw${LIB_SUFFIX}")







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







192
193
194
195
196
197
198















199
200
201
202
203
204
205
], [
	AC_MSG_RESULT(yes)
], [
	AC_MSG_RESULT(no)
	AC_MSG_ERROR(Compiler does not support properties!)
])
















AC_CHECK_TOOL(AR, ar)
AC_PROG_RANLIB
AC_ARG_ENABLE(shared,
	AS_HELP_STRING([--disable-shared], [do not build shared library]))
AS_IF([test x"$enable_shared" != x"no"], [
	BUILDSYS_SHARED_LIB
	AC_SUBST(OBJFW_SHARED_LIB, "${LIB_PREFIX}objfw${LIB_SUFFIX}")
1189
1190
1191
1192
1193
1194
1195

1196
1197
1198
1199
1200
1201
1202
	*-*-mingw*)
		have_processes="yes"
		;;
	*-*-msdosdjgpp*)
		have_processes="no"
		;;
	*)

		AC_CHECK_FUNCS(kill)

		AC_CHECK_FUNC(posix_spawnp, [
			AS_IF([test x"$ac_cv_func_kill" = x"yes"], [
				have_processes="yes"

				AC_CHECK_HEADERS(spawn.h)







>







1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
	*-*-mingw*)
		have_processes="yes"
		;;
	*-*-msdosdjgpp*)
		have_processes="no"
		;;
	*)
		AC_HEADER_SYS_WAIT
		AC_CHECK_FUNCS(kill)

		AC_CHECK_FUNC(posix_spawnp, [
			AS_IF([test x"$ac_cv_func_kill" = x"yes"], [
				have_processes="yes"

				AC_CHECK_HEADERS(spawn.h)
1239
1240
1241
1242
1243
1244
1245


















1246
1247
1248
1249
1250
1251
1252
		])
		AS_IF([test x"$enable_static" = x"yes" \
		    -o x"$enable_shared" = x"no"], [
			AC_SUBST(OBJFW_BRIDGE_STATIC_LIB, "libobjfw-bridge.a")
		])
	])
])



















AS_IF([test x"$GOBJC" = x"yes"], [
	OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wpointer-arith -Werror"

	AC_MSG_CHECKING(whether we need -Wno-strict-aliasing due to GCC bugs)
	AC_TRY_COMPILE([
		@interface Foo







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







1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
		])
		AS_IF([test x"$enable_static" = x"yes" \
		    -o x"$enable_shared" = x"no"], [
			AC_SUBST(OBJFW_BRIDGE_STATIC_LIB, "libobjfw-bridge.a")
		])
	])
])

dnl This needs to be after all other header checks, as they include unistd.h,
dnl which in old glibc versions uses __block. This is worked around in the code
dnl by undefining __USE_XOPEN.
AC_MSG_CHECKING(whether Objective C compiler supports blocks)
old_OBJCFLAGS="$OBJCFLAGS"
OBJCFLAGS="$OBJCFLAGS -fblocks"
AC_TRY_COMPILE([], [
	int (^foo)(int bar);
	foo = ^ (int bar) { return 0; }
], [
	AC_SUBST(BLOCKS_FLAGS, "-fblocks")
	AC_SUBST(OFBLOCKTESTS_M, "OFBlockTests.m")
	AC_MSG_RESULT(yes)
], [
	AC_MSG_RESULT(no)
	OBJCFLAGS="$old_OBJCFLAGS"
])

AS_IF([test x"$GOBJC" = x"yes"], [
	OBJCFLAGS="$OBJCFLAGS -Wwrite-strings -Wpointer-arith -Werror"

	AC_MSG_CHECKING(whether we need -Wno-strict-aliasing due to GCC bugs)
	AC_TRY_COMPILE([
		@interface Foo
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
		#endif
		@interface Foo
		{
			struct objc_class *_isa;
			Foo *_foo;
		}

		@property (readonly, retain) Foo *foo;

		+ (Foo *)foo;
		@end

		@implementation Foo
		@synthesize foo = _foo;








|







1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
		#endif
		@interface Foo
		{
			struct objc_class *_isa;
			Foo *_foo;
		}

		@property (readonly, nonatomic) Foo *foo;

		+ (Foo *)foo;
		@end

		@implementation Foo
		@synthesize foo = _foo;

1353
1354
1355
1356
1357
1358
1359











1360
1361
1362
1363
1364
1365
1366
		#endif
		    ;
		- (void)dealloc;
		@end

		@interface Foo: Object
		@end












		/*
		 * Unfortunately, this cannot be shorter, as it only works when
		 * it is used inside a macro.
		 */
		#ifdef __clang__
		# define OF_DEALLOC_UNSUPPORTED				\







>
>
>
>
>
>
>
>
>
>
>







1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
		#endif
		    ;
		- (void)dealloc;
		@end

		@interface Foo: Object
		@end

		void
		test(void)
		{
			if (sizeof(int) == 4)
				__asm__ ("");
			else if (sizeof(int) == 8)
				__asm__ ("");
			else
				abort();
		}

		/*
		 * Unfortunately, this cannot be shorter, as it only works when
		 * it is used inside a macro.
		 */
		#ifdef __clang__
		# define OF_DEALLOC_UNSUPPORTED				\

Modified src/OFApplication.m from [4dabbbf60b] to [e9758a10ed].

20
21
22
23
24
25
26



27



28
29
30
31
32
33
34
#include <stdlib.h>
#include <string.h>

#include <errno.h>
#include <signal.h>

#ifdef HAVE_UNISTD_H



# include <unistd.h>



#endif

#import "OFApplication.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFLocalization.h"







>
>
>

>
>
>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdlib.h>
#include <string.h>

#include <errno.h>
#include <signal.h>

#ifdef HAVE_UNISTD_H
# ifdef __GLIBC__
#  undef __USE_XOPEN	/* Needed to avoid old glibc using __block */
# endif
# include <unistd.h>
# ifdef __GLIBC__
#  define __USE_XOPEN 1
# endif
#endif

#import "OFApplication.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFLocalization.h"

Modified src/OFFile.m from [867ccc3495] to [cf06285f59].

18
19
20
21
22
23
24



25



26
27
28
29
30
31
32

#include <errno.h>

#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H



# include <unistd.h>



#endif

#include "platform.h"

#ifdef OF_WII
# define BOOL OGC_BOOL
# include <fat.h>







>
>
>

>
>
>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

#include <errno.h>

#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
# ifdef __GLIBC__
#  undef __USE_XOPEN	/* Needed to avoid old glibc using __block */
# endif
# include <unistd.h>
# ifdef __GLIBC__
#  define __USE_XOPEN 1
# endif
#endif

#include "platform.h"

#ifdef OF_WII
# define BOOL OGC_BOOL
# include <fat.h>

Modified src/OFFileManager.m from [6850bf008a] to [a094a79fd3].

18
19
20
21
22
23
24



25



26
27
28
29
30
31
32

#include <errno.h>

#ifdef HAVE_DIRENT_H
# include <dirent.h>
#endif
#ifdef HAVE_UNISTD_H



# include <unistd.h>



#endif

#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
#ifdef HAVE_GRP_H
# include <grp.h>







>
>
>

>
>
>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

#include <errno.h>

#ifdef HAVE_DIRENT_H
# include <dirent.h>
#endif
#ifdef HAVE_UNISTD_H
# ifdef __GLIBC__
#  undef __USE_XOPEN	/* Needed to avoid old glibc using __block */
# endif
# include <unistd.h>
# ifdef __GLIBC__
#  define __USE_XOPEN 1
# endif
#endif

#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
#ifdef HAVE_GRP_H
# include <grp.h>

Modified src/OFKernelEventObserver_epoll.m from [5e58174b96] to [80e980fa67].

19
20
21
22
23
24
25



26



27
28
29
30
31
32
33
#include <assert.h>
#include <errno.h>

#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H



# include <unistd.h>



#endif

#include <sys/epoll.h>

#import "OFKernelEventObserver.h"
#import "OFKernelEventObserver+Private.h"
#import "OFKernelEventObserver_epoll.h"







>
>
>

>
>
>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <assert.h>
#include <errno.h>

#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
# ifdef __GLIBC__
#  undef __USE_XOPEN	/* Needed to avoid old glibc using __block */
# endif
# include <unistd.h>
# ifdef __GLIBC__
#  define __USE_XOPEN 1
# endif
#endif

#include <sys/epoll.h>

#import "OFKernelEventObserver.h"
#import "OFKernelEventObserver+Private.h"
#import "OFKernelEventObserver_epoll.h"

Modified src/OFProcess.m from [c5ef32205f] to [4c6eb1f07f].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31



32



33
34
35
36
37
38
39
40
41
42
 */

#include "config.h"

#include <errno.h>
#include <string.h>

/* Work around __block being used by glibc */
#ifdef __GLIBC__
# undef __USE_XOPEN
#endif

#include "platform.h"

#include <signal.h>

#ifdef HAVE_UNISTD_H



# include <unistd.h>



#endif

#ifndef OF_WINDOWS
# include <sys/wait.h>
#endif

#ifdef HAVE_SPAWN_H
# include <spawn.h>
#endif








<
<
<
<
<
<
<



>
>
>

>
>
>


|







15
16
17
18
19
20
21







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 */

#include "config.h"

#include <errno.h>
#include <string.h>








#include <signal.h>

#ifdef HAVE_UNISTD_H
# ifdef __GLIBC__
#  undef __USE_XOPEN	/* Needed to avoid old glibc using __block */
# endif
# include <unistd.h>
# ifdef __GLIBC__
#  define __USE_XOPEN 1
# endif
#endif

#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif

#ifdef HAVE_SPAWN_H
# include <spawn.h>
#endif

Modified src/OFStdIOStream.m from [2c73c952bc] to [f40b730d75].

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27



28



29
30
31
32
33
34
35
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

/* Work around __block being used by glibc */
#include <stdlib.h>	/* include any libc header to get the libc defines */
#ifdef __GLIBC__
# undef __USE_XOPEN
#endif

#include <errno.h>

#ifdef HAVE_UNISTD_H



# include <unistd.h>



#endif

#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_TTYCOM_H
# include <sys/ttycom.h>







<
<
<
<
<
<



>
>
>

>
>
>







12
13
14
15
16
17
18






19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"







#include <errno.h>

#ifdef HAVE_UNISTD_H
# ifdef __GLIBC__
#  undef __USE_XOPEN	/* Needed to avoid old glibc using __block */
# endif
# include <unistd.h>
# ifdef __GLIBC__
#  define __USE_XOPEN 1
# endif
#endif

#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_TTYCOM_H
# include <sys/ttycom.h>

Modified src/OFSystemInfo.m from [bfa2f21764] to [7e09138521].

14
15
16
17
18
19
20
21
22


23
24
25
26
27
28



29
30
31
32
33
34
35
 * file.
 */

#define __NO_EXT_QNX

#include "config.h"

/* Work around __block being used by glibc */
#include <stdlib.h>	/* include any libc header to get the libc defines */


#ifdef __GLIBC__
# undef __USE_XOPEN
#endif

#ifdef HAVE_UNISTD_H
# include <unistd.h>



#endif

#include "platform.h"

#ifdef OF_MACOS
# include <sys/sysctl.h>
#endif







<

>
>
|
|
|
<
<

>
>
>







14
15
16
17
18
19
20

21
22
23
24
25
26


27
28
29
30
31
32
33
34
35
36
37
 * file.
 */

#define __NO_EXT_QNX

#include "config.h"


#include <stdlib.h>	/* include any libc header to get the libc defines */

#ifdef HAVE_UNISTD_H
# ifdef __GLIBC__
#  undef __USE_XOPEN	/* Needed to avoid old glibc using __block */
# endif


# include <unistd.h>
# ifdef __GLIBC__
#  define __USE_XOPEN 1
# endif
#endif

#include "platform.h"

#ifdef OF_MACOS
# include <sys/sysctl.h>
#endif

Modified src/OFThread.m from [0372a1b765] to [642d2b4756].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



36
37
38
39
40


41
42
43
44
45
46
47

#include "config.h"

#include <stdlib.h>
#include <math.h>
#include <time.h>

/* Work around __block being used by glibc */
#ifdef __GLIBC__
# undef __USE_XOPEN
#endif

#include "platform.h"

#ifdef HAVE_UNISTD_H
# include <unistd.h>



#endif

#ifdef OF_HAVE_SCHED_YIELD
# include <sched.h>
#endif



#ifdef OF_WII
# define BOOL OGC_BOOL
# define nanosleep ogc_nanosleep
# include <ogcsys.h>
# undef BOOL
# undef nanosleep







|
|
|
|
<
<
<
<

>
>
>





>
>







20
21
22
23
24
25
26
27
28
29
30




31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

#include "config.h"

#include <stdlib.h>
#include <math.h>
#include <time.h>

#ifdef HAVE_UNISTD_H
# ifdef __GLIBC__
#  undef __USE_XOPEN	/* Needed to avoid old glibc using __block */
# endif




# include <unistd.h>
# ifdef __GLIBC__
#  define __USE_XOPEN 1
# endif
#endif

#ifdef OF_HAVE_SCHED_YIELD
# include <sched.h>
#endif

#include "platform.h"

#ifdef OF_WII
# define BOOL OGC_BOOL
# define nanosleep ogc_nanosleep
# include <ogcsys.h>
# undef BOOL
# undef nanosleep

Modified src/socket_helpers.h from [8ff5d2ca5e] to [4619bdb896].

12
13
14
15
16
17
18

19

20
21
22
23
24
25



26
27
28
29
30
31
32
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"


/* Work around __block being used by glibc */

#ifdef __GLIBC__
# undef __USE_XOPEN
#endif

#ifdef HAVE_UNISTD_H
# include <unistd.h>



#endif

#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>







>
|
>
|
|
|
<
<

>
>
>







12
13
14
15
16
17
18
19
20
21
22
23
24


25
26
27
28
29
30
31
32
33
34
35
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <stdlib.h>	/* include any libc header to get the libc defines */

#ifdef HAVE_UNISTD_H
# ifdef __GLIBC__
#  undef __USE_XOPEN	/* Needed to avoid old glibc using __block */
# endif


# include <unistd.h>
# ifdef __GLIBC__
#  define __USE_XOPEN 1
# endif
#endif

#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>