From f6e85c64d269947119b93a6c8cee5a7c13a8ae9d Mon Sep 17 00:00:00 2001 From: nicola Date: Mon, 7 May 2007 00:27:06 +0000 Subject: [PATCH] Updated/synced with latest GCC's libobjc git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/libobjc/trunk@25127 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 70 ++++++++++++++++++++++---------------------- ChangeLog.GNUstep | 38 ++++++++++++++++++++++++ encoding.c | 4 +++ gc.c | 24 ++++++++------- objc/objc-api.h | 74 ++++++++++++++++++++--------------------------- objc/objc-list.h | 2 +- sendmsg.c | 11 ++++--- thr-objc.c | 8 +++-- 8 files changed, 136 insertions(+), 95 deletions(-) diff --git a/ChangeLog b/ChangeLog index fab9e00..d8775e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,42 +1,44 @@ -2007-04-30 Richard Frith-Macdonald - - * sendmsg.c: Add forward2 - * objc/objc-api.h: Add forward2 - * thr-pthreads.c: Fix memory leak - -2006-02-24 Jeremy Bettis - - * misc.c: Added some missing objc_DECLARE keywords on function pointer definitions. - * init.c: (objc_send_load): Removed the check for NXConstantString class to fix +load. - (again see:ChangeLog.GNUstep Tue Feb 11 17:11:00 2003) - -2006-02-21 Jeremy Bettis - - * thr-win32.c: (__objc_thread_detach): Removed duplicate - definitions of thread_id and win32_handle. - * objc/objc-decls.h: Don't use __dllspec on mingw platform. - -2006-02-10 Jeremy Bettis - - * init.c (objc_init_statics, __objc_init_protocols): Fix to GCC - bug 23214 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23214) In - some odd circumstances protocols are not properly initalized. See - the Bugzilla page for testcase. +2007-04-21 Andrew Ruder + + * sendmsg.c (__objc_get_forward_imp): Call + __objc_msg_forward2 for real. + +2007-04-09 Andrew Ruder + + * sendmsg.c: Added __objc_msg_forward2, a hook that allows + external libraries to provide a function that returns the real + forwarding function based on both the selector and the receiver. + * objc/objc-api.h: Define __objc_msg_forward2. + +2007-02-18 Manuel Lopez-Ibanez + + * objc/objc-list.h (list_free): Add keyword 'inline' to avoid + unused warning. -2006-02-10 Jeremy Bettis +2006-10-31 Geoffrey Keating - * thr-win32.c: There is no such define __MINGW__, changed to __MINGW32__ + * encoding.c (darwin_rs6000_special_round_type_align): New. -2006-01-20 Adam Fedor +2006-02-21 Rainer Orth - * Import from recent gcc repository 2006-01-03 with fixups (see - ChangeLog for more info). - * ChangeLog, GNUmakefile, Protocol.m, encoding.c, hash.c, init.c, - libobjc.def, linking.c, sarray.c, selector.c, sendmsg.c, thr-mach.c, - thr-objc.c, thr-posix.c, thr-win32.c, objc/hash.h, objc/objc-api.h, - objc/objc-decls.h, objc/runtime.h: Import and fixup. + PR libobjc/26309 + * thr-objc.c (_XOPEN_SOURCE): Don't define on Tru64 UNIX. + +2006-01-24 David Ayers + + PR libobjc/9751 + * gc.c (class_ivar_set_gcinvisible): Replace strncpy with memcpy + and insure the new strings are '\0' termintated. + +2006-01-24 David Ayers + + PR libobjc/13946 + * configure.ac: Add include directives for --enable-objc-gc. + * Makefile.in: Ditto. + * configure: Regenerate. - * README.GNUstep: Update. + * gc.c (__objc_class_structure_encoding): Increment the used bytes + instead of the local pointer to them. 2005-12-14 Andrew Pinski diff --git a/ChangeLog.GNUstep b/ChangeLog.GNUstep index 1e4f1e2..d28ee4f 100644 --- a/ChangeLog.GNUstep +++ b/ChangeLog.GNUstep @@ -1,9 +1,24 @@ +2007-05-06 Nicola Pero + + * ChangeLog: Removed GNUstep-specific entries. This is supposed + to be a copy of GCC's ChangeLog. + * ChangeLog.GNUstep: Added GNUstep-specific entries that were + removed from ChangeLog. + + * gc.c, sendmsg.c, objc/objc-api.h, objc/objc-list.h, encoding.c, + thr-objc.c: Imported latest changes from GCC's libobjc. See + ChangeLog for details. + 2007-05-06 Nicola Pero * configure: Added code at the very beginning to print an help message and abort. Users who don't read the README.GNUstep might otherwise try to run configure, messing everything up. +2007-04-30 Richard Frith-Macdonald + + * thr-pthreads.c: Fix memory leak + 2007-02-28 Nicola Pero * GNUmakefile (GNUSTEP_MAKEFILES): Use gnustep-config to @@ -25,6 +40,29 @@ versions of gnustep-make older than October 2001. If your gnustep-make is that old, please upgrade. + 2006-02-24 Jeremy Bettis + + * misc.c: Added some missing objc_DECLARE keywords on function pointer definitions. + * init.c: (objc_send_load): Removed the check for NXConstantString class to fix +load. + (again see:ChangeLog.GNUstep Tue Feb 11 17:11:00 2003) + +2006-02-21 Jeremy Bettis + + * thr-win32.c: (__objc_thread_detach): Removed duplicate + definitions of thread_id and win32_handle. + * objc/objc-decls.h: Don't use __dllspec on mingw platform. + +2006-02-10 Jeremy Bettis + + * init.c (objc_init_statics, __objc_init_protocols): Fix to GCC + bug 23214 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23214) In + some odd circumstances protocols are not properly initalized. See + the Bugzilla page for testcase. + +2006-02-10 Jeremy Bettis + + * thr-win32.c: There is no such define __MINGW__, changed to __MINGW32__ + 2006-01-20 Adam Fedor * GNUmakefile: Update module name. diff --git a/encoding.c b/encoding.c index 94c2507..cde5125 100644 --- a/encoding.c +++ b/encoding.c @@ -120,6 +120,10 @@ static int __attribute__ ((__unused__)) not_target_flags = 0; : TREE_TYPE (_fields)) == DFmode) \ ? MAX (MAX (COMPUTED, SPECIFIED), 64) \ : MAX (COMPUTED, SPECIFIED));}) +/* FIXME: The word 'fixme' is insufficient to explain the wrong-ness + of this next macro definition. */ +#define darwin_rs6000_special_round_type_align(S,C,S2) \ + rs6000_special_round_type_align(S,C,S2) /* return the size of an object specified by type diff --git a/gc.c b/gc.c index 9bb11fc..5101999 100644 --- a/gc.c +++ b/gc.c @@ -1,5 +1,5 @@ /* Basic data types for Objective C. - Copyright (C) 1998, 2002 Free Software Foundation, Inc. + Copyright (C) 1998, 2002, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by Ovidiu Predescu. This file is part of GCC. @@ -250,7 +250,7 @@ __objc_class_structure_encoding (Class class, char **type, int *size, if (! class) { strcat (*type, "{"); - *current++; + (*current)++; return; } @@ -397,30 +397,34 @@ class_ivar_set_gcinvisible (Class class, const char *ivarname, if (*type == _C_GCINVISIBLE) { char *new_type; + size_t len; if (gc_invisible || ! __objc_ivar_pointer (type)) return; /* The type of the variable already matches the requested gc_invisible type */ - /* The variable is gc_invisible and we have to reverse it */ - new_type = objc_atomic_malloc (strlen (ivar->ivar_type)); - strncpy (new_type, ivar->ivar_type, - (size_t)(type - ivar->ivar_type)); + /* The variable is gc_invisible so we make it gc visible. */ + new_type = objc_atomic_malloc (strlen(ivar->ivar_type)); + len = (type - ivar->ivar_type); + memcpy (new_type, ivar->ivar_type, len); + new_type[len] = 0; strcat (new_type, type + 1); ivar->ivar_type = new_type; } else { char *new_type; + size_t len; if (! gc_invisible || ! __objc_ivar_pointer (type)) return; /* The type of the variable already matches the requested gc_invisible type */ - /* The variable is gc visible and we have to make it gc_invisible */ - new_type = objc_malloc (strlen (ivar->ivar_type) + 2); - strncpy (new_type, ivar->ivar_type, - (size_t)(type - ivar->ivar_type)); + /* The variable is gc visible so we make it gc_invisible. */ + new_type = objc_malloc (strlen(ivar->ivar_type) + 2); + len = (type - ivar->ivar_type); + memcpy (new_type, ivar->ivar_type, len); + new_type[len] = 0; strcat (new_type, "!"); strcat (new_type, type); ivar->ivar_type = new_type; diff --git a/objc/objc-api.h b/objc/objc-api.h index 36d5834..8100c6c 100644 --- a/objc/objc-api.h +++ b/objc/objc-api.h @@ -41,11 +41,9 @@ extern "C" { /* For functions which return Method_t */ #define METHOD_NULL (Method_t)0 /* Boolean typedefs */ -/* -** Method descriptor returned by introspective Object methods. -** This is really just the first part of the more complete objc_method -** structure defined below and used internally by the runtime. -*/ +/* Method descriptor returned by introspective Object methods. + This is really just the first part of the more complete objc_method + structure defined below and used internally by the runtime. */ struct objc_method_description { SEL name; /* this is a selector, not a string */ @@ -85,36 +83,32 @@ struct objc_method_description #define _C_COMPLEX 'j' -/* -** Error handling -** -** Call objc_error() or objc_verror() to record an error; this error -** routine will generally exit the program but not necessarily if the -** user has installed his own error handler. -** -** Call objc_set_error_handler to assign your own function for -** handling errors. The function should return YES if it is ok -** to continue execution, or return NO or just abort if the -** program should be stopped. The default error handler is just to -** print a message on stderr. -** -** The error handler function should be of type objc_error_handler -** The first parameter is an object instance of relevance. -** The second parameter is an error code. -** The third parameter is a format string in the printf style. -** The fourth parameter is a variable list of arguments. -*/ +/* Error handling + + Call objc_error() or objc_verror() to record an error; this error + routine will generally exit the program but not necessarily if the + user has installed his own error handler. + + Call objc_set_error_handler to assign your own function for + handling errors. The function should return YES if it is ok + to continue execution, or return NO or just abort if the + program should be stopped. The default error handler is just to + print a message on stderr. + + The error handler function should be of type objc_error_handler + The first parameter is an object instance of relevance. + The second parameter is an error code. + The third parameter is a format string in the printf style. + The fourth parameter is a variable list of arguments. */ extern void objc_error(id object, int code, const char* fmt, ...); extern void objc_verror(id object, int code, const char* fmt, va_list ap); typedef BOOL (*objc_error_handler)(id, int code, const char *fmt, va_list ap); extern objc_error_handler objc_set_error_handler(objc_error_handler func); -/* -** Error codes -** These are used by the runtime library, and your -** error handling may use them to determine if the error is -** hard or soft thus whether execution can continue or abort. -*/ +/* Error codes + These are used by the runtime library, and your + error handling may use them to determine if the error is + hard or soft thus whether execution can continue or abort. */ #define OBJC_ERR_UNKNOWN 0 /* Generic error */ #define OBJC_ERR_OBJC_VERSION 1 /* Incorrect runtime version */ @@ -139,10 +133,8 @@ extern objc_error_handler objc_set_error_handler(objc_error_handler func); #define OBJC_ERR_BAD_STATE 40 /* Bad thread state */ -/* -** Set this variable nonzero to print a line describing each -** message that is sent. (this is currently disabled) -*/ +/* Set this variable nonzero to print a line describing each + message that is sent. (this is currently disabled) */ extern BOOL objc_trace; @@ -160,14 +152,12 @@ struct objc_static_instances #endif }; -/* -** Whereas a Module (defined further down) is the root (typically) of a file, -** a Symtab is the root of the class and category definitions within the -** module. -** -** A Symtab contains a variable length array of pointers to classes and -** categories defined in the module. -*/ +/* Whereas a Module (defined further down) is the root (typically) of a file, + a Symtab is the root of the class and category definitions within the + module. + + A Symtab contains a variable length array of pointers to classes and + categories defined in the module. */ typedef struct objc_symtab { unsigned long sel_ref_cnt; /* Unknown. */ SEL refs; /* Unknown. */ diff --git a/objc/objc-list.h b/objc/objc-list.h index 051e1c2..8708461 100644 --- a/objc/objc-list.h +++ b/objc/objc-list.h @@ -139,7 +139,7 @@ list_find(struct objc_list** list, void* elem) /* Free list (backwards recursive) */ -static void +static inline void list_free(struct objc_list* list) { if(list) diff --git a/sendmsg.c b/sendmsg.c index 428ac00..a037cba 100644 --- a/sendmsg.c +++ b/sendmsg.c @@ -74,8 +74,7 @@ static void __objc_init_install_dtable (id, SEL); return type for the selector. __objc_block_forward for structures. __objc_double_forward for floats/doubles. - __objc_word_forward for pointers or types that fit in registers. - */ + __objc_word_forward for pointers or types that fit in registers. */ static double __objc_double_forward (id, SEL, ...); static id __objc_word_forward (id, SEL, ...); typedef struct { id many[8]; } __big; @@ -92,7 +91,7 @@ id nil_method (id, SEL); /* Given a selector, return the proper forwarding implementation. */ inline IMP -__objc_get_forward_imp (SEL sel) +__objc_get_forward_imp (id rcv, SEL sel) { /* If a custom forwarding hook was registered, try getting a forwarding function from it. There are two forward routine hooks, one that @@ -111,7 +110,7 @@ __objc_get_forward_imp (SEL sel) } /* In all other cases, use the default forwarding functions built using - * __builtin_apply and friends. */ + __builtin_apply and friends. */ { const char *t = sel->sel_types; @@ -180,7 +179,7 @@ get_imp (Class class, SEL sel) is not in the dispatch table. So the method just doesn't exist for the class. Return the forwarding implementation. */ - res = __objc_get_forward_imp (sel); + res = __objc_get_forward_imp ((id)class, sel); } } } @@ -249,7 +248,7 @@ objc_msg_lookup (id receiver, SEL op) { /* If the method still just doesn't exist for the class, attempt to forward the method. */ - result = __objc_get_forward_imp (op); + result = __objc_get_forward_imp (receiver, op); } } } diff --git a/thr-objc.c b/thr-objc.c index 0289fd6..454b8d8 100644 --- a/thr-objc.c +++ b/thr-objc.c @@ -1,5 +1,6 @@ /* GNU Objective C Runtime Thread Interface. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006 + Free Software Foundation, Inc. This file is part of GCC. @@ -26,8 +27,11 @@ Boston, MA 02110-1301, USA. */ #define _LIBOBJC /* The line below is needed for declarations of functions such as pthread_mutexattr_settype, without which gthr-posix.h may fail to - compile within libobjc. */ + compile within libobjc. Unfortunately, this breaks compilation on + Tru64 UNIX V4.0F, so disable it there. */ +#ifndef __osf__ #define _XOPEN_SOURCE 500 +#endif #include "config.h" #include "tconfig.h" #include "coretypes.h"