From patchwork Sun Dec 19 01:29:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Pero X-Patchwork-Id: 76109 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id E0635B6F2B for ; Sun, 19 Dec 2010 12:29:47 +1100 (EST) Received: (qmail 22433 invoked by alias); 19 Dec 2010 01:29:45 -0000 Received: (qmail 22423 invoked by uid 22791); 19 Dec 2010 01:29:43 -0000 X-SWARE-Spam-Status: No, hits=0.0 required=5.0 tests=AWL, BAYES_50, SARE_SUB_ENC_UTF8, TW_BJ, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (140.186.70.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 19 Dec 2010 01:29:37 +0000 Received: from eggs.gnu.org ([140.186.70.92]:50074) by fencepost.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1PU85c-0001qF-Mo for gcc-patches@gnu.org; Sat, 18 Dec 2010 20:29:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PU85d-0008Vd-DZ for gcc-patches@gnu.org; Sat, 18 Dec 2010 20:29:35 -0500 Received: from smtp181.iad.emailsrvr.com ([207.97.245.181]:46434) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PU85d-0008VV-6e for gcc-patches@gnu.org; Sat, 18 Dec 2010 20:29:33 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp48.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 8BEBC1684F3 for ; Sat, 18 Dec 2010 20:29:32 -0500 (EST) Received: from dynamic5.wm-web.iad.mlsrvr.com (dynamic5.wm-web.iad1a.rsapps.net [192.168.2.146]) by smtp48.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 7820C1684DB for ; Sat, 18 Dec 2010 20:29:32 -0500 (EST) Received: from meta-innovation.com (localhost [127.0.0.1]) by dynamic5.wm-web.iad.mlsrvr.com (Postfix) with ESMTP id 56D3C8D0505 for ; Sat, 18 Dec 2010 20:29:32 -0500 (EST) Received: by www2.webmail.us (Authenticated sender: nicola.pero@meta-innovation.com, from: nicola.pero@meta-innovation.com) with HTTP; Sun, 19 Dec 2010 02:29:32 +0100 (CET) Date: Sun, 19 Dec 2010 02:29:32 +0100 (CET) Subject: =?UTF-8?Q?libobjc:=20header=20cleanup=20for=20new=20API=20(4)?= From: "Nicola Pero" To: "gcc-patches@gnu.org" MIME-Version: 1.0 X-Type: plain Message-ID: <1292722172.353524519@192.168.2.229> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch puts objc_msg_sendv() and related types into objc/deprecated/objc_msg_sendv.h. It also avoids having objc/objc.h include objc/message.h directly. This had been done to provide the deprecated objc_msg_sendv() declarations (which was in objc/message.h before this patch) for the old API, but had the side effect of always defining struct objc_super in the old API way even if the new API is in use. :-( One of the other bad side effects was that objc/objc.h would automatically include objc/message.h, while it shouldn't (as it won't do that when we get rid of the old API), causing people to forget to include it ... and I did myself forget to include it in two testcases for the new API ;-). This patch fixes them to include as required to set __objc_msg_forward2. Committed to trunk. Thanks Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (revision 168034) +++ gcc/testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2010-12-19 Nicola Pero + + * objc.dg/gnu-api-2-resolve-method.m: Include objc/message.h. + * obj-c++.dg/gnu-api-2-resolve-method.m: Include objc/message.h. + 2010-12-18 Jakub Jelinek PR tree-optimization/46969 Index: gcc/testsuite/objc.dg/gnu-api-2-resolve-method.m =================================================================== --- gcc/testsuite/objc.dg/gnu-api-2-resolve-method.m (revision 168034) +++ gcc/testsuite/objc.dg/gnu-api-2-resolve-method.m (working copy) @@ -9,6 +9,10 @@ /* To get the modern GNU Objective-C Runtime API, you include objc/runtime.h. */ #include + +/* For __objc_msg_forward2. */ +#include + #include #include #include Index: gcc/testsuite/obj-c++.dg/gnu-api-2-resolve-method.mm =================================================================== --- gcc/testsuite/obj-c++.dg/gnu-api-2-resolve-method.mm (revision 168034) +++ gcc/testsuite/obj-c++.dg/gnu-api-2-resolve-method.mm (working copy) @@ -9,6 +9,10 @@ /* To get the modern GNU Objective-C Runtime API, you include objc/runtime.h. */ #include + +/* For __objc_msg_forward2. */ +#include + #include #include #include Index: libobjc/sendmsg.c =================================================================== --- libobjc/sendmsg.c (revision 168039) +++ libobjc/sendmsg.c (working copy) @@ -34,6 +34,7 @@ see the files COPYING3 and COPYING.RUNTIME respect #include "coretypes.h" #include "tm.h" #include "objc/runtime.h" +#include "objc/message.h" /* For objc_msg_lookup(), objc_msg_lookup_super(). */ #include "objc/thr.h" #include "objc-private/module-abi-8.h" #include "objc-private/runtime.h" Index: libobjc/Makefile.in =================================================================== --- libobjc/Makefile.in (revision 168040) +++ libobjc/Makefile.in (working copy) @@ -142,6 +142,7 @@ OBJC_DEPRECATED_H = \ objc_error.h \ objc_get_uninstalled_dtable.h \ objc_malloc.h \ + objc_msg_sendv.h \ objc_object_alloc.h \ objc_unexpected_exception.h \ objc_valloc.h \ Index: libobjc/thr.c =================================================================== --- libobjc/thr.c (revision 168039) +++ libobjc/thr.c (working copy) @@ -38,6 +38,7 @@ see the files COPYING3 and COPYING.RUNTIME respect #include "tm.h" #include "defaults.h" #include "objc/thr.h" +#include "objc/message.h" /* For objc_msg_lookup(). */ #include "objc/runtime.h" #include "objc-private/runtime.h" #include Index: libobjc/ChangeLog =================================================================== --- libobjc/ChangeLog (revision 168041) +++ libobjc/ChangeLog (working copy) @@ -1,5 +1,17 @@ 2010-12-19 Nicola Pero + * Makefile.in (OBJC_DEPRECATED_H): Added objc_msg_sendv.h. + * objc/deprecated/objc_msg_sendv.h: New. + * objc/message.h: Do not define retval_t, apply_t, arglist, + arglist_t, objc_msg_sendv, now in + objc/deprecated/objc_msg_sendv.h. + * objc/objc.h: Do not include message.h; include + objc/deprecated/objc_msg_sendv.h instead. Tidied up comments. + * sendmsg.c: Include objc/message.h. + * thr.c: Include objc/message.h. + +2010-12-19 Nicola Pero + * objc/objc-exception.h: Include objc-decls.h. Mark all functions with objc_EXPORT. * objc/objc-sync.h: Same change. Index: libobjc/objc/deprecated/objc_msg_sendv.h =================================================================== --- libobjc/objc/deprecated/objc_msg_sendv.h (revision 0) +++ libobjc/objc/deprecated/objc_msg_sendv.h (revision 0) @@ -0,0 +1,12 @@ +/* The following types and functions are provided only for + backwards-compatibility and should not be used in new code. They + were deprecated in GCC 4.6 and will be removed in the next + release. */ +typedef void* retval_t; /* return value */ +typedef void(*apply_t)(void); /* function pointer */ +typedef union arglist { + char *arg_ptr; + char arg_regs[sizeof (char*)]; +} *arglist_t; /* argument frame */ + +objc_EXPORT retval_t objc_msg_sendv(id, SEL, arglist_t); Index: libobjc/objc/objc.h =================================================================== --- libobjc/objc/objc.h (revision 168039) +++ libobjc/objc/objc.h (working copy) @@ -28,8 +28,7 @@ see the files COPYING3 and COPYING.RUNTIME respect /* This file contains the definition of the basic types used by the Objective-C language. It needs to be included to do almost - anything with Objective-C. -*/ + anything with Objective-C. */ #ifdef __cplusplus extern "C" { @@ -37,25 +36,27 @@ extern "C" { #include +/* objc-decls.h is included because deprecated/objc_msg_sendv.h needs + it. When that goes away, the include of objc-decls.h should be + removed. */ +#include "objc-decls.h" + /* The current version of the GNU Objective-C Runtime library in compressed ISO date format. This should be updated any time a new version is released with changes to the public API (there is no need to update it if there were no API changes since the previous release). This macro is only defined starting with the GNU Objective-C Runtime shipped with GCC 4.6.0. If it is not defined, - it is either an older version of the runtime, or another runtime. -*/ + it is either an older version of the runtime, or another runtime. */ #define __GNU_LIBOBJC__ 20100911 -/* - Definition of the boolean type. +/* Definition of the boolean type. - Compatibility note: the Apple/NeXT runtime defines a BOOL as a - 'signed char'. The GNU runtime uses an 'unsigned char'. + Compatibility note: the Apple/NeXT runtime defines a BOOL as a + 'signed char'. The GNU runtime uses an 'unsigned char'. - Important: this could change and we could switch to 'typedef bool - BOOL' in the future. Do not depend on the type of BOOL. -*/ + Important: this could change and we could switch to 'typedef bool + BOOL' in the future. Do not depend on the type of BOOL. */ #undef BOOL typedef unsigned char BOOL; @@ -65,8 +66,7 @@ typedef unsigned char BOOL; /* The basic Objective-C types (SEL, Class, id) are defined as pointer to opaque structures. The details of the structures are private to the runtime and may potentially change from one version to the - other. -*/ + other. */ /* A SEL (selector) represents an abstract method (in the object-oriented sense) and includes all the details of how to @@ -74,16 +74,14 @@ typedef unsigned char BOOL; types) but provides no implementation of its own. You can check whether a class implements a selector or not, and if you have a selector and know that the class implements it, you can use it to - call the method for an object in the class. - */ + call the method for an object in the class. */ typedef const struct objc_selector *SEL; #include "deprecated/struct_objc_selector.h" /* A Class is a class (in the object-oriented sense). In Objective-C there is the complication that each Class is an object itself, and so belongs to a class too. This class that a class belongs to is - called its 'meta class'. -*/ + called its 'meta class'. */ typedef struct objc_class *Class; #include "deprecated/MetaClass.h" #include "deprecated/struct_objc_class.h" @@ -91,32 +89,29 @@ typedef struct objc_class *Class; /* An 'id' is an object of an unknown class. The way the object data is stored inside the object is private and what you see here is only the beginning of the actual struct. The first field is always - a pointer to the Class that the object belongs to. -*/ + a pointer to the Class that the object belongs to. */ typedef struct objc_object { /* 'class_pointer' is the Class that the object belongs to. In case of a Class object, this pointer points to the meta class. Compatibility Note: The Apple/NeXT runtime calls this field - 'isa'. To access this field in a portable way, use - object_getClass() from runtime.h, which is an inline function so - does not add any overhead. */ + 'isa'. To access this field, use object_getClass() from + runtime.h, which is an inline function so does not add any + overhead and is also portable to other runtimes. */ Class class_pointer; } *id; -/* - 'IMP' is a C function that implements a method. When retrieving the - implementation of a method from the runtime, this is the type of the - pointer returned. The idea of the definition of IMP is to represent - a 'pointer to a general function taking an id, a SEL, followed by - other unspecified arguments'. You must always cast an IMP to a - pointer to a function taking the appropriate, specific types for - that function, before calling it - to make sure the appropriate - arguments are passed to it. The code generated by the compiler to - perform method calls automatically does this cast inside method - calls. -*/ +/* 'IMP' is a C function that implements a method. When retrieving + the implementation of a method from the runtime, this is the type + of the pointer returned. The idea of the definition of IMP is to + represent a 'pointer to a general function taking an id, a SEL, + followed by other unspecified arguments'. You must always cast an + IMP to a pointer to a function taking the appropriate, specific + types for that function, before calling it - to make sure the + appropriate arguments are passed to it. The code generated by the + compiler to perform method calls automatically does this cast + inside method calls. */ typedef id (*IMP)(id, SEL, ...); /* 'nil' is the null object. Messages to nil do nothing and always @@ -135,21 +130,18 @@ typedef id (*IMP)(id, SEL, ...); /* TODO: Move the 'Protocol' declaration into objc/runtime.h. A Protocol is simply an object, not a basic Objective-C type. The Apple runtime defines Protocol in objc/runtime.h too, so it's good - to move it there for API compatibility. -*/ + to move it there for API compatibility. */ /* A 'Protocol' is a formally defined list of selectors (normally created using the @protocol Objective-C syntax). It is mostly used at compile-time to check that classes implement all the methods that they are supposed to. Protocols are also available in the - runtime system as Protocol objects. - */ + runtime system as Protocol objects. */ #ifndef __OBJC__ /* Once we stop including the deprecated struct_objc_protocol.h there is no reason to even define a 'struct objc_protocol'. As all the structure details will be hidden, a Protocol basically is - simply an object (as it should be). - */ + simply an object (as it should be). */ /* typedef struct objc_object Protocol; */ #include "deprecated/struct_objc_protocol.h" #else /* __OBJC__ */ @@ -158,8 +150,9 @@ typedef id (*IMP)(id, SEL, ...); /* Deprecated include - here temporarily, for backwards-compatibility as reval_t, apply_t, arglist_t and objc_msg_lookup() used to be - defined here. */ -#include "message.h" + defined here. objc_msg_lookup() is now defined in message.h, + included by objc-api.h or runtime.h. */ +#include "deprecated/objc_msg_sendv.h" /* Compatibility note: the Apple/NeXT runtime defines sel_getName(), sel_registerName(), object_getClassName(), object_getIndexedIvars() @@ -167,8 +160,7 @@ typedef id (*IMP)(id, SEL, ...); The reason the GNU runtime does not define them here is that they are not basic Objective-C types (defined in this file), but are - part of the runtime API (defined in runtime.h). -*/ + part of the runtime API (defined in runtime.h). */ #ifdef __cplusplus } Index: libobjc/objc/message.h =================================================================== --- libobjc/objc/message.h (revision 168039) +++ libobjc/objc/message.h (working copy) @@ -137,20 +137,6 @@ objc_EXPORT IMP objc_msg_lookup_super (struct objc objc_EXPORT IMP (*__objc_msg_forward)(SEL); objc_EXPORT IMP (*__objc_msg_forward2)(id, SEL); - -/* The following types and functions are provided only for - backwards-compatibility and should not be used in new code. They - were deprecated in GCC 4.6 and will be removed in the next - release. */ -typedef void* retval_t; /* return value */ -typedef void(*apply_t)(void); /* function pointer */ -typedef union arglist { - char *arg_ptr; - char arg_regs[sizeof (char*)]; -} *arglist_t; /* argument frame */ - -objc_EXPORT retval_t objc_msg_sendv(id, SEL, arglist_t); - #ifdef __cplusplus } #endif