From patchwork Tue Oct 12 16:54:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Pero X-Patchwork-Id: 67601 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 1F71AB6EED for ; Wed, 13 Oct 2010 03:55:34 +1100 (EST) Received: (qmail 15052 invoked by alias); 12 Oct 2010 16:55:31 -0000 Received: (qmail 15036 invoked by uid 22791); 12 Oct 2010 16:55:28 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL, BAYES_00, 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; Tue, 12 Oct 2010 16:55:16 +0000 Received: from eggs.gnu.org ([140.186.70.92]:50322) by fencepost.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1P5i8A-0007Fv-Tj for gcc-patches@gnu.org; Tue, 12 Oct 2010 12:55:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P5i7p-0004UG-MR for gcc-patches@gnu.org; Tue, 12 Oct 2010 12:55:14 -0400 Received: from smtp151.iad.emailsrvr.com ([207.97.245.151]:44540) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P5i7p-0004TY-IB for gcc-patches@gnu.org; Tue, 12 Oct 2010 12:54:53 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp35.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id D052E2C83C6 for ; Tue, 12 Oct 2010 12:54:50 -0400 (EDT) X-Orig-To: gcc-patches@gnu.org Received: from dynamic11.wm-web.iad.mlsrvr.com (dynamic11.wm-web.iad1a.rsapps.net [192.168.2.218]) by smtp35.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id BB2E72C8355 for ; Tue, 12 Oct 2010 12:54:50 -0400 (EDT) Received: from meta-innovation.com (localhost [127.0.0.1]) by dynamic11.wm-web.iad.mlsrvr.com (Postfix) with ESMTP id 8C91BE0086 for ; Tue, 12 Oct 2010 12:54:50 -0400 (EDT) Received: by www2.webmail.us (Authenticated sender: nicola.pero@meta-innovation.com, from: nicola.pero@meta-innovation.com) with HTTP; Tue, 12 Oct 2010 18:54:50 +0200 (CEST) Date: Tue, 12 Oct 2010 18:54:50 +0200 (CEST) Subject: =?UTF-8?Q?libobjc=20-=20more=20modern=20Objective-C=20runtime=20API=20(3?= =?UTF-8?Q?)?= From: "Nicola Pero" To: "gcc-patches@gnu.org" MIME-Version: 1.0 X-Type: plain Message-ID: <1286902490.574426143@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 tranche of the API reorganization adds objc_malloc() and similar to objc/runtime.h, and switches many files inside libobjc itself to including the new headers. Committed to trunk. Thanks 2010-10-12 Nicola Pero * archive.c: Do not include objc/objc.h. * class.c: Do not include objc/objc.h. * encoding.c: Include objc/runtime.h, ctype.h and objc-private/module-abi-8.h instead of objc/objc-api.h and objc/encoding.h. * error.c: Do not include objc/objc.h. * gc.c: Include tconfig.h and objc/encoding.h only if OBJC_WITH_GC. * hash.c: Include objc/runtime.h and objc/thr.h instead of objc/objc-api.h. Do not include objc/objc.h. * init.c: Do not include objc/objc.h. * ivars.c: Include objc/runtime.h, objc-private/module-abi-8.h and objc/thr.h instead of objc/objc-api.h. Do not include objc/objc.h. * linking.m: Tidied comment. * memory.c: Include objc/runtime.h instead of objc/objc-api.h. Do not include objc/objc.h. * objects.c: Do not include objc/objc.h. * objc-sync.c: Include objc/runtime.h instead of objc/objc-api.h. * protocols.c: Do not include objc/objc.h. * sarray.c: Include objc/runtime.h instead of objc/objc-api.h. Do not include objc/objc.h. * selector.c: Do not include objc/objc.h. * sendmsg.c: Do not include objc/objc.h. * thr.c: Include objc/runtime.h instead of objc/objc-api.h. Do not include objc/objc.h. * objc/objc-decls.h: Reindented code. * objc/runtime.h Include objc-decls.h. Updated comments. (objc_malloc): New. (objc_atomic_malloc): New. (objc_calloc): New. (objc_realloc): New. (objc_free): New. * objc-private/runtime.h: Updated comments. Index: sendmsg.c =================================================================== --- sendmsg.c (revision 165348) +++ sendmsg.c (working copy) @@ -33,7 +33,6 @@ see the files COPYING3 and COPYING.RUNTIME respect #include "tconfig.h" #include "coretypes.h" #include "tm.h" -#include "objc/objc.h" #include "objc/objc-api.h" #include "objc/thr.h" #include "objc-private/runtime.h" Index: init.c =================================================================== --- init.c (revision 165349) +++ init.c (working copy) @@ -26,7 +26,6 @@ see the files COPYING3 and COPYING.RUNTIME respect #include "objc-private/common.h" #include "objc-private/error.h" -#include "objc/objc.h" #include "objc/objc-api.h" #include "objc/thr.h" #include "objc-private/hash.h" Index: objc-private/runtime.h =================================================================== --- objc-private/runtime.h (revision 165349) +++ objc-private/runtime.h (working copy) @@ -34,7 +34,8 @@ The original list was: but can almost certainly be shrinked down. -*/ +Note that you can use this file both with objc/objc-api.h and with +objc/runtime.h. */ #ifndef __objc_private_runtime_INCLUDE_GNU #define __objc_private_runtime_INCLUDE_GNU Index: linking.m =================================================================== --- linking.m (revision 165348) +++ linking.m (working copy) @@ -28,9 +28,8 @@ see the files COPYING3 and COPYING.RUNTIME respect #include /* Generate references to Object and NXConstanstString classes since they are - needed by the runtime system to run correctly. */ + needed by the runtime system to run correctly. */ - void __objc_linking (void) { [Object name]; Index: class.c =================================================================== --- class.c (revision 165349) +++ class.c (working copy) @@ -89,7 +89,6 @@ see the files COPYING3 and COPYING.RUNTIME respect #include "objc-private/common.h" #include "objc-private/error.h" -#include "objc/objc.h" #include "objc/objc-api.h" #include "objc/thr.h" #include "objc-private/runtime.h" /* the kitchen sink */ Index: selector.c =================================================================== --- selector.c (revision 165349) +++ selector.c (working copy) @@ -23,7 +23,6 @@ see the files COPYING3 and COPYING.RUNTIME respect . */ #include "objc-private/common.h" -#include "objc/objc.h" #include "objc/objc-api.h" #include "objc/thr.h" #include "objc-private/hash.h" Index: hash.c =================================================================== --- hash.c (revision 165348) +++ hash.c (working copy) @@ -25,8 +25,8 @@ see the files COPYING3 and COPYING.RUNTIME respect #include "objc-private/common.h" #include /* For assert */ -#include "objc/objc.h" -#include "objc/objc-api.h" +#include "objc/runtime.h" /* For objc_calloc */ +#include "objc/thr.h" /* Required by objc-private/runtime.h. */ #include "objc-private/hash.h" #include "objc-private/runtime.h" /* for DEBUG_PRINTF */ Index: protocols.c =================================================================== --- protocols.c (revision 165349) +++ protocols.c (working copy) @@ -23,7 +23,6 @@ see the files COPYING3 and COPYING.RUNTIME respect . */ #include "objc-private/common.h" -#include "objc/objc.h" #include "objc/runtime.h" #include "objc-private/module-abi-8.h" /* For runtime structures */ #include "objc/thr.h" Index: encoding.c =================================================================== --- encoding.c (revision 165348) +++ encoding.c (working copy) @@ -36,9 +36,10 @@ see the files COPYING3 and COPYING.RUNTIME respect #include "tconfig.h" #include "coretypes.h" #include "tm.h" -#include "objc/objc-api.h" -#include "objc/encoding.h" +#include "objc/runtime.h" +#include "objc-private/module-abi-8.h" /* For struct objc_method */ #include +#include #undef MAX #define MAX(X, Y) \ Index: objc-sync.c =================================================================== --- objc-sync.c (revision 165348) +++ objc-sync.c (working copy) @@ -79,7 +79,7 @@ see the files COPYING3 and COPYING.RUNTIME respect #include "objc-private/common.h" #include "objc/objc-sync.h" /* For objc_sync_enter(), objc_sync_exit() */ -#include "objc/objc-api.h" /* For objc_malloc() */ +#include "objc/runtime.h" /* For objc_malloc() */ #include "objc/thr.h" /* For objc_mutex_loc() and similar */ #include "objc-private/objc-sync.h" /* For __objc_sync_init() */ Index: error.c =================================================================== --- error.c (revision 165348) +++ error.c (working copy) @@ -48,8 +48,7 @@ _objc_abort (const char *fmt, ...) } /* The rest of the file is deprecated. */ -#include "objc/objc.h" -#include "objc/objc-api.h" +#include "objc/objc-api.h" /* For objc_error_handler. */ /* ** Error handler function Index: objects.c =================================================================== --- objects.c (revision 165348) +++ objects.c (working copy) @@ -23,7 +23,6 @@ see the files COPYING3 and COPYING.RUNTIME respect . */ #include "objc-private/common.h" -#include "objc/objc.h" #include "objc/objc-api.h" #include "objc-private/runtime.h" /* the kitchen sink */ Index: thr.c =================================================================== --- thr.c (revision 165348) +++ thr.c (working copy) @@ -38,8 +38,7 @@ see the files COPYING3 and COPYING.RUNTIME respect #include "tm.h" #include "defaults.h" #include "objc/thr.h" -#include "objc/objc.h" -#include "objc/objc-api.h" +#include "objc/runtime.h" #include "objc-private/runtime.h" #include Index: sarray.c =================================================================== --- sarray.c (revision 165348) +++ sarray.c (working copy) @@ -24,9 +24,8 @@ see the files COPYING3 and COPYING.RUNTIME respect #include "objc-private/common.h" #include "objc-private/sarray.h" -#include "objc/objc.h" -#include "objc/objc-api.h" -#include "objc/thr.h" +#include "objc/runtime.h" /* For objc_malloc */ +#include "objc/thr.h" /* For objc_mutex_lock */ #include "objc-private/runtime.h" #include #include /* For memset */ Index: ChangeLog =================================================================== --- ChangeLog (revision 165349) +++ ChangeLog (working copy) @@ -1,5 +1,42 @@ 2010-10-12 Nicola Pero + * archive.c: Do not include objc/objc.h. + * class.c: Do not include objc/objc.h. + * encoding.c: Include objc/runtime.h, ctype.h and + objc-private/module-abi-8.h instead of objc/objc-api.h and + objc/encoding.h. + * error.c: Do not include objc/objc.h. + * gc.c: Include tconfig.h and objc/encoding.h only if + OBJC_WITH_GC. + * hash.c: Include objc/runtime.h and objc/thr.h instead of + objc/objc-api.h. Do not include objc/objc.h. + * init.c: Do not include objc/objc.h. + * ivars.c: Include objc/runtime.h, objc-private/module-abi-8.h and + objc/thr.h instead of objc/objc-api.h. Do not include + objc/objc.h. + * linking.m: Tidied comment. + * memory.c: Include objc/runtime.h instead of objc/objc-api.h. + Do not include objc/objc.h. + * objects.c: Do not include objc/objc.h. + * objc-sync.c: Include objc/runtime.h instead of objc/objc-api.h. + * protocols.c: Do not include objc/objc.h. + * sarray.c: Include objc/runtime.h instead of objc/objc-api.h. Do + not include objc/objc.h. + * selector.c: Do not include objc/objc.h. + * sendmsg.c: Do not include objc/objc.h. + * thr.c: Include objc/runtime.h instead of objc/objc-api.h. + Do not include objc/objc.h. + * objc/objc-decls.h: Reindented code. + * objc/runtime.h Include objc-decls.h. Updated comments. + (objc_malloc): New. + (objc_atomic_malloc): New. + (objc_calloc): New. + (objc_realloc): New. + (objc_free): New. + * objc-private/runtime.h: Updated comments. + +2010-10-12 Nicola Pero + * Makefile.in (C_SOURCE_FILES): Added protocols.c. * objc-private/protocols.h: New. * protocols.c: New. Index: memory.c =================================================================== --- memory.c (revision 165348) +++ memory.c (working copy) @@ -42,8 +42,7 @@ see the files COPYING3 and COPYING.RUNTIME respect #define __USE_FIXED_PROTOTYPES__ #include -#include "objc/objc.h" -#include "objc/objc-api.h" +#include "objc/runtime.h" #if OBJC_WITH_GC #include Index: archive.c =================================================================== --- archive.c (revision 165348) +++ archive.c (working copy) @@ -27,7 +27,6 @@ see the files COPYING3 and COPYING.RUNTIME respect #include "objc-private/common.h" #include "objc-private/error.h" #include "tconfig.h" -#include "objc/objc.h" #include "objc/objc-api.h" #include "objc/hash.h" #include "objc/objc-list.h" Index: ivars.c =================================================================== --- ivars.c (revision 165348) +++ ivars.c (working copy) @@ -23,8 +23,9 @@ see the files COPYING3 and COPYING.RUNTIME respect . */ #include "objc-private/common.h" -#include "objc/objc.h" -#include "objc/objc-api.h" +#include "objc/runtime.h" +#include "objc-private/module-abi-8.h" /* For runtime structures */ +#include "objc/thr.h" #include "objc-private/runtime.h" /* the kitchen sink */ #include /* For strcmp */ Index: gc.c =================================================================== --- gc.c (revision 165348) +++ gc.c (working copy) @@ -24,16 +24,16 @@ see the files COPYING3 and COPYING.RUNTIME respect . */ #include "objc-private/common.h" -#include "tconfig.h" #include "objc/objc.h" -#include "objc/encoding.h" +#if OBJC_WITH_GC + +#include "tconfig.h" #include #include #include +#include "objc/encoding.h" -#if OBJC_WITH_GC - #include #include Index: objc/objc-decls.h =================================================================== --- objc/objc-decls.h (revision 165348) +++ objc/objc-decls.h (working copy) @@ -28,13 +28,13 @@ see the files COPYING3 and COPYING.RUNTIME respect #if defined (_WIN32) || defined (__WIN32__) || defined (WIN32) -# ifdef DLL_EXPORT /* defined by libtool (if required) */ -# define objc_EXPORT -# define objc_DECLARE -#else -# define objc_EXPORT extern __declspec(dllimport) -# define objc_DECLARE extern __declspec(dllimport) -#endif +# ifdef DLL_EXPORT /* defined by libtool (if required) */ +# define objc_EXPORT +# define objc_DECLARE +# else +# define objc_EXPORT extern __declspec(dllimport) +# define objc_DECLARE extern __declspec(dllimport) +# endif #else Index: objc/runtime.h =================================================================== --- objc/runtime.h (revision 165349) +++ objc/runtime.h (working copy) @@ -48,6 +48,7 @@ see the files COPYING3 and COPYING.RUNTIME respect /* TODO: This file is incomplete. */ #include "objc.h" +#include "objc-decls.h" /* An 'Ivar' represents an instance variable. It holds information about the name, type and offset of the instance variable. */ @@ -543,12 +544,39 @@ struct __objcFastEnumerationState */ +/** Implementation: the following functions are in memory.c. */ + +/* Traditional GNU Objective-C Runtime functions that are used for + memory allocation and disposal. These functions are used in the + same way as you use malloc, realloc, calloc and free and make sure + that memory allocation works properly with the garbage + collector. + + Compatibility Note: these functions are not available with the + Apple/NeXT runtime. */ + +objc_EXPORT void *objc_malloc(size_t size); + +/* FIXME: Shouldn't the following be called objc_malloc_atomic ? The + GC function is GC_malloc_atomic() which makes sense. + */ +objc_EXPORT void *objc_atomic_malloc(size_t size); + +objc_EXPORT void *objc_realloc(void *mem, size_t size); + +objc_EXPORT void *objc_calloc(size_t nelem, size_t size); + +objc_EXPORT void objc_free(void *mem); + + /** Implementation: the following functions are in encoding.c. */ /* Traditional GNU Objective-C Runtime functions that are currently used to implement method forwarding. -*/ + Compatibility Note: these functions are not available with the + Apple/NeXT runtime. */ + /* Return the size of a variable which has the specified 'type' encoding. */ int objc_sizeof_type (const char *type);