ObjFW  Check-in [ccd504e68d]

Overview
Comment:Use NSFoundationVersionNumber to detect Foundation

This is more reliable than checking for CFRetain to see if
CoreFoundation is linked, as CFRetain is always available, even when not
linked against CoreFoundation explicitly.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ccd504e68daa4f4234cbbc2201c0bfcefedabe28c350201835972c3121d5af5c
User & Date: js on 2016-10-15 20:47:45
Other Links: manifest | tags
Context
2016-10-16
20:01
OFBlocks: Forward stack block to copy when copied check-in: 9dc0755178 user: js tags: trunk
2016-10-15
20:47
Use NSFoundationVersionNumber to detect Foundation check-in: ccd504e68d user: js tags: trunk
13:49
OFBlock: Set (*dst)->forwarding after memcpy() check-in: dbb706d21e user: js tags: trunk
Changes

Modified configure.ac from [840e6b941e] to [8a76db0974].

402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
])

case "$host_os" in
	darwin*)
		AC_SUBST(LDFLAGS_REEXPORT, ["-Wl,-reexport-lobjfw"])
		AS_IF([test x"$objc_runtime" = x"Apple runtime"], [
			AC_SUBST(REEXPORT_LIBOBJC, ["-Wl,-reexport-lobjc"])
			LDFLAGS="$LDFLAGS -Wl,-U,_CFRetain"
		])

		AS_IF([test x"$objc_runtime" = x"ObjFW runtime"], [
			AS_IF([test x"$exception_type" = x"DWARF"], [
				LDFLAGS="$LDFLAGS -Wl,-U,___gxx_personality_v0"
			])
			AS_IF([test x"$exception_type" = x"SjLj"], [







|







402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
])

case "$host_os" in
	darwin*)
		AC_SUBST(LDFLAGS_REEXPORT, ["-Wl,-reexport-lobjfw"])
		AS_IF([test x"$objc_runtime" = x"Apple runtime"], [
			AC_SUBST(REEXPORT_LIBOBJC, ["-Wl,-reexport-lobjc"])
			LDFLAGS="$LDFLAGS -Wl,-U,_NSFoundationVersionNumber"
		])

		AS_IF([test x"$objc_runtime" = x"ObjFW runtime"], [
			AS_IF([test x"$exception_type" = x"DWARF"], [
				LDFLAGS="$LDFLAGS -Wl,-U,___gxx_personality_v0"
			])
			AS_IF([test x"$exception_type" = x"SjLj"], [

Modified src/OFObject.m from [efb4532301] to [f0a708441f].

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#if defined(OF_HAVE_ATOMIC_OPS)
# import "atomic.h"
#elif defined(OF_HAVE_THREADS)
# import "threading.h"
#endif

#ifdef OF_APPLE_RUNTIME
extern void* CFRetain(void*) __attribute__((__weak__));
#endif

#if defined(OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR)
extern id of_forward(id, SEL, ...);
extern struct stret of_forward_stret(id, SEL, ...);
#else
# define of_forward of_method_not_found







|







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#if defined(OF_HAVE_ATOMIC_OPS)
# import "atomic.h"
#elif defined(OF_HAVE_THREADS)
# import "threading.h"
#endif

#ifdef OF_APPLE_RUNTIME
extern double *NSFoundationVersionNumber __attribute__((__weak__));
#endif

#if defined(OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR)
extern id of_forward(id, SEL, ...);
extern struct stret of_forward_stret(id, SEL, ...);
#else
# define of_forward of_method_not_found
216
217
218
219
220
221
222
223
224
225

226
227
228
229
230
231
232
233
234
235
236
237
{
#if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__)
	objc_setUncaughtExceptionHandler(uncaughtExceptionHandler);
#endif

#if defined(OF_APPLE_RUNTIME)
	/*
	 * If the CFRetain symbol is defined, we are linked against
	 * CoreFoundation. Since CoreFoundation sets its own forward handler
	 * on load, we should not set ours, as this will break CoreFoundation.

	 *
	 * Unfortunately, there is no way to check if a forward handler has
	 * already been set, so this is the best we can do.
	 */
	if (&CFRetain == NULL)
		objc_setForwardHandler((void*)&of_forward,
		    (void*)&of_forward_stret);
#else
	objc_setForwardHandler((IMP)&of_forward, (IMP)&of_forward_stret);
#endif

	objc_setEnumerationMutationHandler(enumerationMutationHandler);







|
|
|
>




|







216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
{
#if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__)
	objc_setUncaughtExceptionHandler(uncaughtExceptionHandler);
#endif

#if defined(OF_APPLE_RUNTIME)
	/*
	 * If the NSFoundationVersionNumber symbol is defined, we are linked
	 * against Foundation. Since CoreFoundation sets its own forward
	 * handler on load, we should not set ours, as this will break
	 * Foundation.
	 *
	 * Unfortunately, there is no way to check if a forward handler has
	 * already been set, so this is the best we can do.
	 */
	if (&NSFoundationVersionNumber == NULL)
		objc_setForwardHandler((void*)&of_forward,
		    (void*)&of_forward_stret);
#else
	objc_setForwardHandler((IMP)&of_forward, (IMP)&of_forward_stret);
#endif

	objc_setEnumerationMutationHandler(enumerationMutationHandler);