diff --git a/ChangeLog b/ChangeLog index 7997ae47b..f94899f2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,16 @@ the loop must be run inside an exception handler which makes sure to remove the handle from the loop before re-raising the exception. +2017-12-21 Riccardo Mottola + + * Source/NSObject.m: + Cleanup previous commit. + +2017-12-21 Riccardo Mottola + + * Source/NSObject.m: + Compatibility for OS/compiler not supporting weak symbols. + 2017-12-20 Richard Frith-Macdonald * configure.ac: Remove obsolete --enable-objc-nonfragile-abi flag diff --git a/Source/NSObject.m b/Source/NSObject.m index c68b06232..8ee2b0954 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -1,5 +1,5 @@ /** Implementation of NSObject for GNUStep - Copyright (C) 1994-2010 Free Software Foundation, Inc. + Copyright (C) 1994-2017 Free Software Foundation, Inc. Written by: Andrew Kachites McCallum Date: August 1994 @@ -77,6 +77,17 @@ #endif #endif + +/* platforms which do not support weak */ +#if (__GNUC__ == 3) && defined (__WIN32) +#define WEAK_ATTRIBUTE +#undef SUPPORT_WEAK +#else +/* all platforms which support weak */ +#define WEAK_ATTRIBUTE __attribute__((weak)) +#define SUPPORT_WEAK 1 +#endif + /* When this is `YES', every call to release/autorelease, checks to make sure isn't being set up to release itself too many times. This does not need mutex protection. */ @@ -451,18 +462,19 @@ typedef struct obj_layout *obj; * runtime. When linked against an older version, we will use our internal * versions. */ -__attribute__((weak)) +WEAK_ATTRIBUTE BOOL objc_release_fast_no_destroy_np(id anObject); -__attribute__((weak)) +WEAK_ATTRIBUTE void objc_release_fast_np(id anObject); -__attribute__((weak)) +WEAK_ATTRIBUTE size_t object_getRetainCount_np(id anObject); -__attribute__((weak)) +WEAK_ATTRIBUTE id objc_retain_fast_np(id anObject); + static BOOL objc_release_fast_no_destroy_internal(id anObject) { if (double_release_check_enabled) @@ -524,11 +536,13 @@ static BOOL objc_release_fast_no_destroy_internal(id anObject) static BOOL release_fast_no_destroy(id anObject) { +#ifdef SUPPORT_WEAK if (objc_release_fast_no_destroy_np) { return objc_release_fast_no_destroy_np(anObject); } else +#endif { return objc_release_fast_no_destroy_internal(anObject); } @@ -544,11 +558,13 @@ static void objc_release_fast_np_internal(id anObject) static void release_fast(id anObject) { +#ifdef SUPPORT_WEAK if (objc_release_fast_np) { objc_release_fast_np(anObject); } else +#endif { objc_release_fast_np_internal(anObject); } @@ -573,11 +589,13 @@ size_t object_getRetainCount_np_internal(id anObject) size_t getRetainCount(id anObject) { +#ifdef SUPPORT_WEAK if (object_getRetainCount_np) { return object_getRetainCount_np(anObject); } else +#endif { return object_getRetainCount_np_internal(anObject); } @@ -668,11 +686,13 @@ static id objc_retain_fast_np_internal(id anObject) static id retain_fast(id anObject) { +#ifdef SUPPORT_WEAK if (objc_retain_fast_np) { return objc_retain_fast_np(anObject); } else +#endif { return objc_retain_fast_np_internal(anObject); }