From patchwork Sun Dec 19 17:30:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: =?UTF-8?Q?libobjc:=20Call=20=5F=5Fobjc=5Fresolve=5Fclass=5Flinks()=20at?= =?UTF-8?Q?=20the=20end=20of=20=5F=5Fobjc=5Fexec=5Fclass()?= Date: Sun, 19 Dec 2010 07:30:33 -0000 From: Nicola Pero X-Patchwork-Id: 76146 Message-Id: <1292779833.505511720@192.168.2.227> To: "gcc-patches@gnu.org" This patch fixes the fact that libobjc wouldn't resolve class links automatically after loading new modules ("class links" mean the class-to-superclass pointers). Hopefully this patch means that gnustep-base, which currently calls __objc_resolve_class_links() manually after loading a bundle, no longer needs to do it, and __objc_resolve_class_links() can become the private function it is supposed to be. ;-) Committed to trunk. Thanks Index: init.c =================================================================== --- init.c (revision 168058) +++ init.c (working copy) @@ -31,7 +31,7 @@ #include "objc-private/hash.h" #include "objc-private/objc-list.h" #include "objc-private/module-abi-8.h" -#include "objc-private/runtime.h" +#include "objc-private/runtime.h" /* For __objc_resolve_class_links(). */ #include "objc-private/selector.h" /* For __sel_register_typed_name(). */ #include "objc-private/objc-sync.h" /* For __objc_sync_init() */ #include "objc-private/protocols.h" /* For __objc_protocols_init(), @@ -719,11 +719,15 @@ objc_send_load (); + /* Check if there are no unresolved classes (ie, classes whose + superclass has not been loaded yet) and that the 'Object' class, + used as the class of classes, exist. If so, it is worth + "resolving the class links" at this point, which will setup all + the class/superclass pointers. */ + if (!unresolved_classes && objc_getClass ("Object")) + __objc_resolve_class_links (); + objc_mutex_unlock (__objc_runtime_mutex); - - /* TODO: Do we need to add a call to __objc_resolve_class_links() - here ? gnustep-base does it manually after it loads a module. - Shouldn't we do it automatically ? */ } static void Index: ChangeLog =================================================================== --- ChangeLog (revision 168064) +++ ChangeLog (working copy) @@ -1,5 +1,10 @@ 2010-12-19 Nicola Pero + * init.c (__objc_exec_class): Call __objc_resolve_class_links (), + if appropriate, after loading the module. + +2010-12-19 Nicola Pero + * sendmsg.c (method_setImplementation): Do not declare. 2010-12-19 Nicola Pero