Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -194,25 +194,10 @@ ], [ 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"], [ @@ -1191,10 +1176,11 @@ ;; *-*-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" @@ -1241,10 +1227,28 @@ -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) @@ -1280,11 +1284,11 @@ { struct objc_class *_isa; Foo *_foo; } - @property (readonly, retain) Foo *foo; + @property (readonly, nonatomic) Foo *foo; + (Foo *)foo; @end @implementation Foo @@ -1355,10 +1359,21 @@ - (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. */ Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -22,11 +22,17 @@ #include #include #ifdef HAVE_UNISTD_H +# ifdef __GLIBC__ +# undef __USE_XOPEN /* Needed to avoid old glibc using __block */ +# endif # include +# ifdef __GLIBC__ +# define __USE_XOPEN 1 +# endif #endif #import "OFApplication.h" #import "OFString.h" #import "OFArray.h" Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -20,11 +20,17 @@ #ifdef HAVE_FCNTL_H # include #endif #ifdef HAVE_UNISTD_H +# ifdef __GLIBC__ +# undef __USE_XOPEN /* Needed to avoid old glibc using __block */ +# endif # include +# ifdef __GLIBC__ +# define __USE_XOPEN 1 +# endif #endif #include "platform.h" #ifdef OF_WII Index: src/OFFileManager.m ================================================================== --- src/OFFileManager.m +++ src/OFFileManager.m @@ -20,11 +20,17 @@ #ifdef HAVE_DIRENT_H # include #endif #ifdef HAVE_UNISTD_H +# ifdef __GLIBC__ +# undef __USE_XOPEN /* Needed to avoid old glibc using __block */ +# endif # include +# ifdef __GLIBC__ +# define __USE_XOPEN 1 +# endif #endif #ifdef HAVE_PWD_H # include #endif Index: src/OFKernelEventObserver_epoll.m ================================================================== --- src/OFKernelEventObserver_epoll.m +++ src/OFKernelEventObserver_epoll.m @@ -21,11 +21,17 @@ #ifdef HAVE_FCNTL_H # include #endif #ifdef HAVE_UNISTD_H +# ifdef __GLIBC__ +# undef __USE_XOPEN /* Needed to avoid old glibc using __block */ +# endif # include +# ifdef __GLIBC__ +# define __USE_XOPEN 1 +# endif #endif #include #import "OFKernelEventObserver.h" Index: src/OFProcess.m ================================================================== --- src/OFProcess.m +++ src/OFProcess.m @@ -17,24 +17,23 @@ #include "config.h" #include #include -/* Work around __block being used by glibc */ -#ifdef __GLIBC__ -# undef __USE_XOPEN -#endif - -#include "platform.h" - #include #ifdef HAVE_UNISTD_H +# ifdef __GLIBC__ +# undef __USE_XOPEN /* Needed to avoid old glibc using __block */ +# endif # include +# ifdef __GLIBC__ +# define __USE_XOPEN 1 +# endif #endif -#ifndef OF_WINDOWS +#ifdef HAVE_SYS_WAIT_H # include #endif #ifdef HAVE_SPAWN_H # include Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -14,20 +14,20 @@ * file. */ #include "config.h" -/* Work around __block being used by glibc */ -#include /* include any libc header to get the libc defines */ -#ifdef __GLIBC__ -# undef __USE_XOPEN -#endif - #include #ifdef HAVE_UNISTD_H +# ifdef __GLIBC__ +# undef __USE_XOPEN /* Needed to avoid old glibc using __block */ +# endif # include +# ifdef __GLIBC__ +# define __USE_XOPEN 1 +# endif #endif #ifdef HAVE_SYS_IOCTL_H # include #endif Index: src/OFSystemInfo.m ================================================================== --- src/OFSystemInfo.m +++ src/OFSystemInfo.m @@ -16,18 +16,20 @@ #define __NO_EXT_QNX #include "config.h" -/* Work around __block being used by glibc */ #include /* include any libc header to get the libc defines */ -#ifdef __GLIBC__ -# undef __USE_XOPEN -#endif #ifdef HAVE_UNISTD_H +# ifdef __GLIBC__ +# undef __USE_XOPEN /* Needed to avoid old glibc using __block */ +# endif # include +# ifdef __GLIBC__ +# define __USE_XOPEN 1 +# endif #endif #include "platform.h" #ifdef OF_MACOS Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -22,24 +22,25 @@ #include #include #include -/* Work around __block being used by glibc */ -#ifdef __GLIBC__ -# undef __USE_XOPEN -#endif - -#include "platform.h" - #ifdef HAVE_UNISTD_H +# ifdef __GLIBC__ +# undef __USE_XOPEN /* Needed to avoid old glibc using __block */ +# endif # include +# ifdef __GLIBC__ +# define __USE_XOPEN 1 +# endif #endif #ifdef OF_HAVE_SCHED_YIELD # include #endif + +#include "platform.h" #ifdef OF_WII # define BOOL OGC_BOOL # define nanosleep ogc_nanosleep # include Index: src/socket_helpers.h ================================================================== --- src/socket_helpers.h +++ src/socket_helpers.h @@ -14,17 +14,20 @@ * file. */ #include "config.h" -/* Work around __block being used by glibc */ -#ifdef __GLIBC__ -# undef __USE_XOPEN -#endif +#include /* 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 +# ifdef __GLIBC__ +# define __USE_XOPEN 1 +# endif #endif #ifdef HAVE_ARPA_INET_H # include #endif