Import from recent gcc CVS. Bump version to 1.2.3

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/libobjc/trunk@16052 72102866-910b-0410-8b05-ffd578937521
main
fedor 23 years ago
parent 5c8c6241e1
commit f6d5ab7a58

@ -1,9 +1,253 @@
Tue Feb 11 17:11:00 2003 Richard Frith-Macdonald <richard@brainstorm.co.uk> 2003-02-20 Alexandre Oliva <aoliva@redhat.com>
* init.c: Don't do the check to see if Object and NXConstantString * configure.in: Propagate ORIGINAL_LD_FOR_MULTILIBS to
are set up before calling +load ... NXConstantString is never set config.status.
when we use gcc-3.0 and later in GNUstep ... which means that * configure: Rebuilt.
+load would never be sent.
2003-01-27 Alexandre Oliva <aoliva@redhat.com>
* aclocal.m4 (glibcpp_toolexeclibdir): Instead of
$(MULTISUBDIR), use `$CC -print-multi-os-directory`, unless
version_specific_libs is enabled.
* configure: Rebuilt.
2003-01-09 Christian Cornelssen <ccorn@cs.tu-berlin.de>
* Makefile.in (FLAGS_TO_PASS): Also pass DESTDIR.
(install-libs, install-headers): Prepend $(DESTDIR) to
destination paths in all (un)installation commands.
2002-12-02 Zack Weinberg <zack@codesourcery.com>
* thr-objc.c: Include coretypes.h and tm.h.
2002-12-01 Zack Weinberg <zack@codesourcery.com>
* encoding.c, sendmsg.c: Include coretypes.h and tm.h.
2002-11-26 Nathanael Nerode <neroden@gcc.gnu.org>
* configure.in: Remove skip-this-dir support.
* configure: Regenerate.
2002-09-22 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* Makefile.in (all): Fix multilib parallel build.
Thu Sep 12 12:44:37 2002 Nicola Pero <n.pero@mi.flashnet.it>
* sendmsg.c (nil_method): Declare not to take a variable number of
args.
(objc_msg_lookup): Cast nil_method to IMP before returning it.
(objc_msg_lookup_super): The same.
2002-09-10 Jan Hubicka <jh@suse.cz>
* nil_method.c (nil_method): No longer defined with variable
arguments.
2002-07-02 Rodney Brown <rbrown64@csc.com.au>
* objc/encoding.h: Fix formatting.
* objc/hash.h: Likewise.
* objc/objc-api.h: Likewise.
* objc/runtime.h: Likewise.
* objc/thr.h: Likewise.
* archive.c: Likewise.
* class.c: Likewise.
* encoding.c: Likewise.
* gc.c: Likewise.
* hash.c: Likewise.
* init.c: Likewise.
* misc.c: Likewise.
* nil_method.c: Likewise.
* objects.c: Likewise.
* sarray.c: Likewise.
* selector.c: Likewise.
* sendmsg.c: Likewise.
* thr-mach.c: Likewise.
* thr.c: Likewise.
2002-06-25 DJ Delorie <dj@redhat.com>
* aclocal.m4 (GLIBCPP_CONFIGURE): Split out
GLIBCPP_TOPREL_CONFIGURE.
* configure.in: Call it before AC_CANONICAL_SYSTEM.
* configure: Regenerate.
2002-06-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* Object.m (forward, read, write): Fix unused parameter warnings.
* encoding.c: Include <stdlib.h>.
(target_flags): Mark with attribute unused.
(atoi): Delete.
* runtime.h (__objc_selector_max_index): Change to unsigned int.
(__objc_generate_gc_type_description): Prototype.
* selector.c (__objc_selector_max_index): Change to unsigned int.
Mon Jun 17 18:37:42 2002 Nicola Pero <n.pero@mi.flashnet.it>
* sendmsg.c (__objc_get_forward_imp): Fix warning by making sure
we always have a return value: if __objc_msg_forward does not
supply a forwarding implementation, return the default
__builtin_apply based one.
2002-06-15 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* Object.m: Fix signed/unsigned warning.
* Protocol.m: Likewise.
* archive.c: Always include stdlib.h.
(objc_read_short, objc_read_unsigned_short, objc_read_int,
objc_read_long, __objc_read_nbyte_uint, __objc_read_nbyte_ulong):
Fix signed/unsigned warning.
(objc_write_type, objc_read_type, objc_write_types,
objc_read_types): Ensure ctype 8-bit safety.
(__objc_no_write, __objc_no_read): Mark unused parameters.
* class.c (class_table_setup): Specify void arg.
* encoding.c (atoi, objc_sizeof_type, objc_alignof_type,
objc_skip_typespec, objc_skip_offset,
objc_layout_structure_next_member): Ensure ctype 8-bit safety.
(objc_layout_structure_next_member): Ensure variables are
initialized.
* gc.c (__objc_generate_gc_type_description,
class_ivar_set_gcinvisible): Mark unused parameters.
* init.c (__objc_send_load, __objc_destroy_class_tree_node): Mark
unused parameters.
(__objc_init_protocols) Fix signed/unsigned warning.
* nil_method.c (nil_method): Mark unused parameters.
* thr.h (objc_thread_callback): Specify void arg.
* sarray.c (sarray_new, sarray_realloc, sarray_free): Fix
signed/unsigned warning.
(sarray_free): Fix formatting.
* selector.c (sel_types_match): Ensure ctype 8-bit safety.
* sendmsg.c (__objc_init_install_dtable) Mark unused parameters.
2002-06-09 Andreas Jaeger <aj@suse.de>
* encoding.c (objc_layout_structure_next_member): Remove unused
variable.
2002-05-20 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* Makefile.in (SHELL): Set to @SHELL@.
(WARN_CFLAGS): New.
(ALL_CFLAGS): Add $(WARN_CFLAGS).
2002-05-16 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* aclocal.m4: Allow for PWDCMD to override hardcoded pwd.
* configure: Regenerate.
2002-05-08 Alexandre Oliva <aoliva@redhat.com>
* configure.in (ORIGINAL_LD_FOR_MULTILIBS): Preserve LD at
script entry, and set LD to it when configuring multilibs.
* configure: Rebuilt.
2002-04-19 David O'Brien <obrien@FreeBSD.org>
* encoding.c (MAX, MIN, ROUNDING): #undef before defining.
2002-04-09 Hans-Peter Nilsson <hp@bitrange.com>
PR objc/6107
* objc/objc-api.h (struct objc_protocol_list): Change type of
member count from int to size_t.
2002-02-11 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
PR libobjc/4039
* aclocal.m4: Replace with version copied from libstdc++-v3.
* configure.in: Update for changes to aclocal and Makefile.
* configure: Regenerate.
* Makefile.in: Correct install of multilibs and shared libs, use
INSTALL_DATA for include files.
Mon Dec 17 17:02:12 2001 Nicola Pero <nicola@brainstorm.co.uk>
* init.c (__objc_exec_class): Fixed bug in the loop on unclaimed
categories - when an unclaimed category was found, the loop was
doing two steps forward instead of one, so that in certain cases
it was failing to properly load all the categories. (Reported
with fix by Alexander Malmberg <alexander@malmberg.org>).
2001-11-14 Aldy Hernandez <aldyh@redhat.com>
* encoding.c: Add target_flags.
2001-11-07 Aldy Hernandez <aldyh@redhat.com>
* objc/objc-api.h (_C_VECTOR): New.
* encoding.c (VECTOR_TYPE): New.
Mon Oct 29 21:29:21 2001 Nicola Pero <n.pero@mi.flashnet.it>
* class.c: Rewritten the class table to use optimized, lock-free
lookup. This more than doubles the speed of class method
invocations. (class_table_setup), (class_table_insert),
(class_table_replace), (class_table_get_safe),
(class_table_next), (class_table_print),
(class_table_print_histogram): New functions.
(__objc_init_class_tables): Use class_table_setup.
(__objc_add_class_to_hash): Use class_table_get_safe and
class_table_insert. (objc_lookup_class), (objc_get_class): Do not
assert the existence of the table; do not lock the runtime; use
class_table_get_safe. (objc_next_class): Use class_table_next.
(__objc_resolve_class_links): Use class_table_next.
(class_pose_as): Use class_table_replace.
2001-09-10 Ovidiu Predescu <ovidiu@cup.hp.com>
* gc.c: Removed the DEBUG declaration.
Wed Jul 18 12:48:56 2001 Nicola Pero <n.pero@mi.flashnet.it>
* thr.c (objc_mutex_lock): Invoke __objc_thread_id directly,
rather than through objc_thread_id, to save a function call.
(objc_mutex_trylock, objc_mutex_unlock, objc_condition_wait):
Ditto.
Mon Jul 16 12:15:00 2001 Nicola Pero <n.pero@mi.flashnet.it>
* objc/objc-api.h (object_is_class): Fixed - buggy code was trying
to cast an id to a Class, which can not be done. Make the check
by using CLS_ISMETA on the class pointer instead.
(object_is_meta_class): Similar fix.
2001-06-09 Alexandre Oliva <aoliva@redhat.com>, Stephen L Moshier <moshier@mediaone.net>
* configure.in (AC_EXEEXT): Work around in case it expands to
nothing, as in autoconf 2.50.
* acinclude.m4: Likewise.
* configure: Rebuilt.
2001-06-08 Nicola Pero <n.pero@mi.flashnet.it>
* THREADS: Explain that when we compile libobjc inside GCC, we
always use thr-objc.c as a backend, which uses GCC's thread code.
2001-06-06 Richard Frith-Macdonald <rrfm@gnu.org>
* init.c (__objc_send_message_in_list): When setting a new entry
in __objc_load_methods use the method IMP as key, but check to see
if the method is in the hashtable by looking at the IMP also.
Also ... call the method after adding it to the hashtable rather
than before ... thus preventing an obscure possibility of infinite
recursion if a +load method itself loads a subclass.
2001-05-25 Ovidiu Predescu <ovidiu@cup.hp.com>
* init.c (__objc_send_message_in_list): When setting a new entry
in __objc_load_methods use the method name as key, not the method
IMP (reported by Richard Frith-Macdonald <richard@brainstorm.co.uk>).
2001-05-09 Joseph S. Myers <jsm28@cam.ac.uk>
* objc-features.texi: Move to ../gcc/objc.texi.
* fdl.texi: Remove.
* Makefile.in: Don't generate documentation from
objc-features.texi.
2001-05-01 Mark Mitchell <mark@codesourcery.com> 2001-05-01 Mark Mitchell <mark@codesourcery.com>
@ -15,6 +259,10 @@ Tue Feb 11 17:11:00 2003 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* objc-features.texi: Use the GFDL. * objc-features.texi: Use the GFDL.
Wed Mar 21 04:44:58 EST 2001 John Wehle (john@feith.com)
* encoding.c (REAL_TYPE): Define.
2001-03-19 David Edelsohn <edelsohn@gnu.org> 2001-03-19 David Edelsohn <edelsohn@gnu.org>
* encoding.c (TYPE_MODE): Define. * encoding.c (TYPE_MODE): Define.
@ -26,6 +274,15 @@ Tue Feb 11 17:11:00 2003 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* objc/thr.h: Declare them. * objc/thr.h: Declare them.
* libobjc.def: Mention them. * libobjc.def: Mention them.
2001-02-28 Ovidiu Predescu <ovidiu@cup.hp.com>
* objc-features.texi: Document the @compatibility_alias compiler
directive (description from Nicola Pero <n.pero@mi.flashnet.it>).
Fri Feb 23 18:12:00 2001 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* sendmsg.c (__objc_forward): Delete strlen() declaration.
2001-02-08 Geoffrey Keating <geoffk@redhat.com> 2001-02-08 Geoffrey Keating <geoffk@redhat.com>
* configure.in: Don't run AC_PROG_CC_WORKS or AC_EXEEXT, because * configure.in: Don't run AC_PROG_CC_WORKS or AC_EXEEXT, because
@ -307,4 +564,3 @@ Mon Sep 21 23:27:10 1998 Ovidiu Predescu <ovidiu@slip.net>
1998-09-21 Ben Elliston <bje@cygnus.com> 1998-09-21 Ben Elliston <bje@cygnus.com>
* New directory. Moved files from ../gcc/objc. * New directory. Moved files from ../gcc/objc.

@ -1,3 +1,14 @@
2003-02-22 Adam Fedor <fedor@gnu.org>
* Import from recent gcc CVS. Bump version to 1.2.3
Tue Feb 11 17:11:00 2003 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* init.c: Don't do the check to see if Object and NXConstantString
are set up before calling +load ... NXConstantString is never set
when we use gcc-3.0 and later in GNUstep ... which means that
+load would never be sent.
Thu Sep 12 13:15:00 2002 Nicola Pero <n.pero@mi.flashnet.it> Thu Sep 12 13:15:00 2002 Nicola Pero <n.pero@mi.flashnet.it>
* libobjc.def (objc_set_error_handler): Added. * libobjc.def (objc_set_error_handler): Added.

@ -26,7 +26,7 @@
include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/common.make include $(GNUSTEP_SYSTEM_ROOT)/Makefiles/common.make
PACKAGE_NAME = gnustep-objc PACKAGE_NAME = gnustep-objc
VERSION=1.2.2 VERSION=1.2.3
CVS_MODULE_NAME = objc CVS_MODULE_NAME = objc

@ -30,8 +30,6 @@ Boston, MA 02111-1307, USA. */
/* FIXME: This file has no business including tm.h. */ /* FIXME: This file has no business including tm.h. */
#include "tconfig.h" #include "tconfig.h"
#include "coretypes.h"
#include "tm.h"
#include "objc-api.h" #include "objc-api.h"
#include "encoding.h" #include "encoding.h"
#include <stdlib.h> #include <stdlib.h>

204
init.c

@ -1,5 +1,5 @@
/* GNU Objective C Runtime initialization /* GNU Objective C Runtime initialization
Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
Contributed by Kresten Krab Thorup Contributed by Kresten Krab Thorup
+load support contributed by Ovidiu Predescu <ovidiu@net-community.com> +load support contributed by Ovidiu Predescu <ovidiu@net-community.com>
@ -27,14 +27,14 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "runtime.h" #include "runtime.h"
/* The version number of this runtime. This must match the number /* The version number of this runtime. This must match the number
defined in gcc (objc-act.c) */ defined in gcc (objc-act.c). */
#define OBJC_VERSION 8 #define OBJC_VERSION 8
#define PROTOCOL_VERSION 2 #define PROTOCOL_VERSION 2
/* This list contains all modules currently loaded into the runtime */ /* This list contains all modules currently loaded into the runtime. */
static struct objc_list *__objc_module_list = 0; /* !T:MUTEX */ static struct objc_list *__objc_module_list = 0; /* !T:MUTEX */
/* This list contains all proto_list's not yet assigned class links */ /* This list contains all proto_list's not yet assigned class links. */
static struct objc_list *unclaimed_proto_list = 0; /* !T:MUTEX */ static struct objc_list *unclaimed_proto_list = 0; /* !T:MUTEX */
/* List of unresolved static instances. */ /* List of unresolved static instances. */
@ -46,19 +46,19 @@ objc_mutex_t __objc_runtime_mutex = 0;
/* Number of threads that are alive. */ /* Number of threads that are alive. */
int __objc_runtime_threads_alive = 1; /* !T:MUTEX */ int __objc_runtime_threads_alive = 1; /* !T:MUTEX */
/* Check compiler vs runtime version */ /* Check compiler vs runtime version. */
static void init_check_module_version (Module_t); static void init_check_module_version (Module_t);
/* Assign isa links to protos */ /* Assign isa links to protos. */
static void __objc_init_protocols (struct objc_protocol_list *protos); static void __objc_init_protocols (struct objc_protocol_list *protos);
/* Add protocol to class */ /* Add protocol to class. */
static void __objc_class_add_protocols (Class, struct objc_protocol_list *); static void __objc_class_add_protocols (Class, struct objc_protocol_list *);
/* This is a hook which is called by __objc_exec_class every time a class /* This is a hook which is called by __objc_exec_class every time a
or a category is loaded into the runtime. This may e.g. help a class or a category is loaded into the runtime. This may e.g. help
dynamic loader determine the classes that have been loaded when a dynamic loader determine the classes that have been loaded when
an object file is dynamically linked in */ an object file is dynamically linked in. */
void (*_objc_load_callback) (Class class, Category *category); /* !T:SAFE */ void (*_objc_load_callback) (Class class, Category *category); /* !T:SAFE */
/* Is all categories/classes resolved? */ /* Is all categories/classes resolved? */
@ -72,11 +72,11 @@ __sel_register_typed_name (const char *name, const char *types,
static void objc_send_load (void); static void objc_send_load (void);
/* Inserts all the classes defined in module in a tree of classes that /* Inserts all the classes defined in module in a tree of classes that
resembles the class hierarchy. This tree is traversed in preorder and the resembles the class hierarchy. This tree is traversed in preorder
classes in its nodes receive the +load message if these methods were not and the classes in its nodes receive the +load message if these
executed before. The algorithm ensures that when the +load method of a class methods were not executed before. The algorithm ensures that when
is executed all the superclasses have been already received the +load the +load method of a class is executed all the superclasses have
message. */ been already received the +load message. */
static void __objc_create_classes_tree (Module_t module); static void __objc_create_classes_tree (Module_t module);
static void __objc_call_callback (Module_t module); static void __objc_call_callback (Module_t module);
@ -90,19 +90,21 @@ typedef struct objc_class_tree {
struct objc_list *subclasses; /* `head' is pointer to an objc_class_tree */ struct objc_list *subclasses; /* `head' is pointer to an objc_class_tree */
} objc_class_tree; } objc_class_tree;
/* This is a linked list of objc_class_tree trees. The head of these trees /* This is a linked list of objc_class_tree trees. The head of these
are root classes (their super class is Nil). These different trees trees are root classes (their super class is Nil). These different
represent different class hierarchies. */ trees represent different class hierarchies. */
static struct objc_list *__objc_class_tree_list = NULL; static struct objc_list *__objc_class_tree_list = NULL;
/* Keeps the +load methods who have been already executed. This hash should /* Keeps the +load methods who have been already executed. This hash
not be destroyed during the execution of the program. */ should not be destroyed during the execution of the program. */
static cache_ptr __objc_load_methods = NULL; static cache_ptr __objc_load_methods = NULL;
/* Creates a tree of classes whose topmost class is directly inherited from /* Creates a tree of classes whose topmost class is directly inherited
`upper' and the bottom class in this tree is `bottom_class'. The classes from `upper' and the bottom class in this tree is
in this tree are super classes of `bottom_class'. `subclasses' member `bottom_class'. The classes in this tree are super classes of
of each tree node point to the next subclass tree node. */ `bottom_class'. `subclasses' member of each tree node point to the
next subclass tree node. */
static objc_class_tree * static objc_class_tree *
create_tree_of_subclasses_inherited_from (Class bottom_class, Class upper) create_tree_of_subclasses_inherited_from (Class bottom_class, Class upper)
{ {
@ -134,11 +136,13 @@ create_tree_of_subclasses_inherited_from (Class bottom_class, Class upper)
return tree; return tree;
} }
/* Insert the `class' into the proper place in the `tree' class hierarchy. This /* Insert the `class' into the proper place in the `tree' class
function returns a new tree if the class has been successfully inserted into hierarchy. This function returns a new tree if the class has been
the tree or NULL if the class is not part of the classes hierarchy described successfully inserted into the tree or NULL if the class is not
by `tree'. This function is private to objc_tree_insert_class(), you should part of the classes hierarchy described by `tree'. This function is
not call it directly. */ private to objc_tree_insert_class (), you should not call it
directly. */
static objc_class_tree * static objc_class_tree *
__objc_tree_insert_class (objc_class_tree *tree, Class class) __objc_tree_insert_class (objc_class_tree *tree, Class class)
{ {
@ -186,12 +190,13 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class)
} }
else else
{ {
/* The class is not a direct subclass of tree->class. Search for class's /* The class is not a direct subclass of tree->class. Search for
superclasses in the list of subclasses. */ class's superclasses in the list of subclasses. */
struct objc_list *subclasses = tree->subclasses; struct objc_list *subclasses = tree->subclasses;
/* Precondition: the class must be a subclass of tree->class; otherwise /* Precondition: the class must be a subclass of tree->class;
return NULL to indicate our caller that it must take the next tree. */ otherwise return NULL to indicate our caller that it must
take the next tree. */
if (! class_is_subclass_of_class (class, tree->class)) if (! class_is_subclass_of_class (class, tree->class))
return NULL; return NULL;
@ -201,9 +206,9 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class)
if (class_is_subclass_of_class (class, aClass)) if (class_is_subclass_of_class (class, aClass))
{ {
/* If we found one of class's superclasses we insert the class /* If we found one of class's superclasses we insert the
into its subtree and return the original tree since nothing class into its subtree and return the original tree
has been changed. */ since nothing has been changed. */
subclasses->head subclasses->head
= __objc_tree_insert_class (subclasses->head, class); = __objc_tree_insert_class (subclasses->head, class);
DEBUG_PRINTF ("4. class %s inserted\n", class->name); DEBUG_PRINTF ("4. class %s inserted\n", class->name);
@ -211,9 +216,9 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class)
} }
} }
/* We haven't found a subclass of `class' in the `subclasses' list. /* We haven't found a subclass of `class' in the `subclasses'
Create a new tree of classes whose topmost class is a direct subclass list. Create a new tree of classes whose topmost class is a
of tree->class. */ direct subclass of tree->class. */
{ {
objc_class_tree *new_tree objc_class_tree *new_tree
= create_tree_of_subclasses_inherited_from (class, tree->class); = create_tree_of_subclasses_inherited_from (class, tree->class);
@ -225,6 +230,7 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class)
} }
/* This function inserts `class' in the right tree hierarchy classes. */ /* This function inserts `class' in the right tree hierarchy classes. */
static void static void
objc_tree_insert_class (Class class) objc_tree_insert_class (Class class)
{ {
@ -244,8 +250,8 @@ objc_tree_insert_class (Class class)
list_node = list_node->tail; list_node = list_node->tail;
} }
/* If the list was finished but the class hasn't been inserted, insert it /* If the list was finished but the class hasn't been inserted,
here. */ insert it here. */
if (! list_node) if (! list_node)
{ {
__objc_class_tree_list = list_cons (NULL, __objc_class_tree_list); __objc_class_tree_list = list_cons (NULL, __objc_class_tree_list);
@ -254,6 +260,7 @@ objc_tree_insert_class (Class class)
} }
/* Traverse tree in preorder. Used to send +load. */ /* Traverse tree in preorder. Used to send +load. */
static void static void
objc_preorder_traverse (objc_class_tree *tree, objc_preorder_traverse (objc_class_tree *tree,
int level, int level,
@ -267,6 +274,7 @@ objc_preorder_traverse (objc_class_tree *tree,
} }
/* Traverse tree in postorder. Used to destroy a tree. */ /* Traverse tree in postorder. Used to destroy a tree. */
static void static void
objc_postorder_traverse (objc_class_tree *tree, objc_postorder_traverse (objc_class_tree *tree,
int level, int level,
@ -280,6 +288,7 @@ objc_postorder_traverse (objc_class_tree *tree,
} }
/* Used to print a tree class hierarchy. */ /* Used to print a tree class hierarchy. */
#ifdef DEBUG_RUNTIME #ifdef DEBUG_RUNTIME
static void static void
__objc_tree_print (objc_class_tree *tree, int level) __objc_tree_print (objc_class_tree *tree, int level)
@ -292,10 +301,12 @@ __objc_tree_print (objc_class_tree *tree, int level)
} }
#endif #endif
/* Walks on a linked list of methods in the reverse order and executes all /* Walks on a linked list of methods in the reverse order and executes
the methods corresponding to `op' selector. Walking in the reverse order all the methods corresponding to `op' selector. Walking in the
assures the +load of class is executed first and then +load of categories reverse order assures the +load of class is executed first and then
because of the way in which categories are added to the class methods. */ +load of categories because of the way in which categories are
added to the class methods. */
static void static void
__objc_send_message_in_list (MethodList_t method_list, Class class, SEL op) __objc_send_message_in_list (MethodList_t method_list, Class class, SEL op)
{ {
@ -315,21 +326,22 @@ __objc_send_message_in_list (MethodList_t method_list, Class class, SEL op)
if (mth->method_name && sel_eq (mth->method_name, op) if (mth->method_name && sel_eq (mth->method_name, op)
&& ! hash_is_key_in_hash (__objc_load_methods, mth->method_imp)) && ! hash_is_key_in_hash (__objc_load_methods, mth->method_imp))
{ {
/* The method was found and wasn't previously executed. */
(*mth->method_imp) ((id)class, mth->method_name);
/* Add this method into the +load hash table */ /* Add this method into the +load hash table */
hash_add (&__objc_load_methods, mth->method_imp, mth->method_imp); hash_add (&__objc_load_methods, mth->method_imp, mth->method_imp);
DEBUG_PRINTF ("sending +load in class: %s\n", class->name); DEBUG_PRINTF ("sending +load in class: %s\n", class->name);
/* The method was found and wasn't previously executed. */
(*mth->method_imp) ((id)class, mth->method_name);
break; break;
} }
} }
} }
static void static void
__objc_send_load (objc_class_tree *tree, int level) __objc_send_load (objc_class_tree *tree,
int level __attribute__ ((__unused__)))
{ {
static SEL load_sel = 0; static SEL load_sel = 0;
Class class = tree->class; Class class = tree->class;
@ -342,13 +354,15 @@ __objc_send_load (objc_class_tree *tree, int level)
} }
static void static void
__objc_destroy_class_tree_node (objc_class_tree *tree, int level) __objc_destroy_class_tree_node (objc_class_tree *tree,
int level __attribute__ ((__unused__)))
{ {
objc_free (tree); objc_free (tree);
} }
/* This is used to check if the relationship between two classes before the /* This is used to check if the relationship between two classes
runtime completely installs the classes. */ before the runtime completely installs the classes. */
static BOOL static BOOL
class_is_subclass_of_class (Class class, Class superclass) class_is_subclass_of_class (Class class, Class superclass)
{ {
@ -364,12 +378,12 @@ class_is_subclass_of_class (Class class, Class superclass)
return NO; return NO;
} }
/* This list contains all the classes in the runtime system for whom their /* This list contains all the classes in the runtime system for whom
superclasses are not yet know to the runtime. */ their superclasses are not yet known to the runtime. */
static struct objc_list *unresolved_classes = 0; static struct objc_list *unresolved_classes = 0;
/* Extern function used to reference the Object and NXConstantString classes. /* Extern function used to reference the Object and NXConstantString
*/ classes. */
extern void __objc_force_linking (void); extern void __objc_force_linking (void);
@ -380,8 +394,9 @@ __objc_force_linking (void)
__objc_linking (); __objc_linking ();
} }
/* Run through the statics list, removing modules as soon as all its statics /* Run through the statics list, removing modules as soon as all its
have been initialized. */ statics have been initialized. */
static void static void
objc_init_statics (void) objc_init_statics (void)
{ {
@ -440,9 +455,9 @@ objc_init_statics (void)
} /* objc_init_statics */ } /* objc_init_statics */
/* This function is called by constructor functions generated for each /* This function is called by constructor functions generated for each
module compiled. (_GLOBAL_$I$...) The purpose of this function is to module compiled. (_GLOBAL_$I$...) The purpose of this function is
gather the module pointers so that they may be processed by the to gather the module pointers so that they may be processed by the
initialization routines as soon as possible */ initialization routines as soon as possible. */
objc_DECLARE void objc_DECLARE void
__objc_exec_class (Module_t module) __objc_exec_class (Module_t module)
@ -599,9 +614,7 @@ __objc_exec_class (Module_t module)
/* Scan the unclaimed category hash. Attempt to attach any unclaimed /* Scan the unclaimed category hash. Attempt to attach any unclaimed
categories to objects. */ categories to objects. */
for (cell = &unclaimed_categories; for (cell = &unclaimed_categories; *cell; )
*cell;
({ if (*cell) cell = &(*cell)->tail; }))
{ {
Category_t category = (*cell)->head; Category_t category = (*cell)->head;
Class class = objc_lookup_class (category->class_name); Class class = objc_lookup_class (category->class_name);
@ -630,11 +643,14 @@ __objc_exec_class (Module_t module)
only done for root classes. */ only done for root classes. */
__objc_register_instance_methods_to_class (class); __objc_register_instance_methods_to_class (class);
} }
else
cell = &(*cell)->tail;
} }
if (unclaimed_proto_list && objc_lookup_class ("Protocol")) if (unclaimed_proto_list && objc_lookup_class ("Protocol"))
{ {
list_mapcar (unclaimed_proto_list,(void(*)(void*))__objc_init_protocols); list_mapcar (unclaimed_proto_list,
(void (*) (void *))__objc_init_protocols);
list_free (unclaimed_proto_list); list_free (unclaimed_proto_list);
unclaimed_proto_list = 0; unclaimed_proto_list = 0;
} }
@ -644,15 +660,16 @@ __objc_exec_class (Module_t module)
objc_mutex_unlock (__objc_runtime_mutex); objc_mutex_unlock (__objc_runtime_mutex);
} }
static void objc_send_load (void) static void
objc_send_load (void)
{ {
if (! __objc_module_list) if (! __objc_module_list)
return; return;
/* Try to find out if all the classes loaded so far also have their /* Try to find out if all the classes loaded so far also have their
superclasses known to the runtime. We suppose that the objects that are superclasses known to the runtime. We suppose that the objects
allocated in the +load method are in general of a class declared in the that are allocated in the +load method are in general of a class
same module. */ declared in the same module. */
if (unresolved_classes) if (unresolved_classes)
{ {
Class class = unresolved_classes->head; Class class = unresolved_classes->head;
@ -666,10 +683,9 @@ static void objc_send_load (void)
break; break;
} }
/* /* If we still have classes for whom we don't have yet their
* If we still have classes for whom we don't have yet their super super classes known to the runtime we don't send the +load
* classes known to the runtime we don't send the +load messages. messages. */
*/
if (unresolved_classes) if (unresolved_classes)
return; return;
} }
@ -693,10 +709,11 @@ static void objc_send_load (void)
return; return;
#endif #endif
/* Iterate over all modules in the __objc_module_list and call on them the /* Iterate over all modules in the __objc_module_list and call on
__objc_create_classes_tree function. This function creates a tree of them the __objc_create_classes_tree function. This function
classes that resembles the class hierarchy. */ creates a tree of classes that resembles the class hierarchy. */
list_mapcar (__objc_module_list, (void(*)(void*))__objc_create_classes_tree); list_mapcar (__objc_module_list,
(void (*) (void *)) __objc_create_classes_tree);
while (__objc_class_tree_list) while (__objc_class_tree_list)
{ {
@ -724,8 +741,8 @@ __objc_create_classes_tree (Module_t module)
Symtab_t symtab = module->symtab; Symtab_t symtab = module->symtab;
int i; int i;
/* Iterate thru classes defined in this module and insert them in the classes /* Iterate thru classes defined in this module and insert them in
tree hierarchy. */ the classes tree hierarchy. */
for (i = 0; i < symtab->cls_def_cnt; i++) for (i = 0; i < symtab->cls_def_cnt; i++)
{ {
Class class = (Class) symtab->defs[i]; Class class = (Class) symtab->defs[i];
@ -737,13 +754,13 @@ __objc_create_classes_tree (Module_t module)
static void static void
__objc_call_callback (Module_t module) __objc_call_callback (Module_t module)
{ {
/* The runtime mutex is locked in this point */ /* The runtime mutex is locked in this point. */
Symtab_t symtab = module->symtab; Symtab_t symtab = module->symtab;
int i; int i;
/* Iterate thru classes defined in this module and call the callback for /* Iterate thru classes defined in this module and call the callback
each one. */ for each one. */
for (i = 0; i < symtab->cls_def_cnt; i++) for (i = 0; i < symtab->cls_def_cnt; i++)
{ {
Class class = (Class) symtab->defs[i]; Class class = (Class) symtab->defs[i];
@ -753,9 +770,9 @@ __objc_call_callback (Module_t module)
_objc_load_callback (class, 0); _objc_load_callback (class, 0);
} }
/* Call the _objc_load_callback for categories. Don't register the instance /* Call the _objc_load_callback for categories. Don't register the
methods as class methods for categories to root classes since they were instance methods as class methods for categories to root classes
already added in the class. */ since they were already added in the class. */
for (i = 0; i < symtab->cat_def_cnt; i++) for (i = 0; i < symtab->cat_def_cnt; i++)
{ {
Category_t category = symtab->defs[i + symtab->cls_def_cnt]; Category_t category = symtab->defs[i + symtab->cls_def_cnt];
@ -766,8 +783,10 @@ __objc_call_callback (Module_t module)
} }
} }
/* Sanity check the version of gcc used to compile `module'*/ /* Sanity check the version of gcc used to compile `module'. */
static void init_check_module_version(Module_t module)
static void
init_check_module_version (Module_t module)
{ {
if ((module->version != OBJC_VERSION) || (module->size != sizeof (Module))) if ((module->version != OBJC_VERSION) || (module->size != sizeof (Module)))
{ {
@ -788,7 +807,7 @@ static void init_check_module_version(Module_t module)
static void static void
__objc_init_protocols (struct objc_protocol_list *protos) __objc_init_protocols (struct objc_protocol_list *protos)
{ {
int i; size_t i;
static Class proto_class = 0; static Class proto_class = 0;
if (! protos) if (! protos)
@ -825,7 +844,8 @@ __objc_init_protocols (struct objc_protocol_list* protos)
{ {
objc_error (nil, OBJC_ERR_PROTOCOL_VERSION, objc_error (nil, OBJC_ERR_PROTOCOL_VERSION,
"Version %d doesn't match runtime protocol version %d\n", "Version %d doesn't match runtime protocol version %d\n",
(int)((char*)protos->list[i]->class_pointer-(char*)0), (int) ((char *) protos->list[i]->class_pointer
- (char *) 0),
PROTOCOL_VERSION); PROTOCOL_VERSION);
} }
} }
@ -833,8 +853,8 @@ __objc_init_protocols (struct objc_protocol_list* protos)
objc_mutex_unlock (__objc_runtime_mutex); objc_mutex_unlock (__objc_runtime_mutex);
} }
static void __objc_class_add_protocols (Class class, static void
struct objc_protocol_list* protos) __objc_class_add_protocols (Class class, struct objc_protocol_list *protos)
{ {
/* Well... */ /* Well... */
if (! protos) if (! protos)

@ -1,5 +1,5 @@
/* GNU Objective-C Runtime API. /* GNU Objective-C Runtime API.
Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
This file is part of GNU CC. This file is part of GNU CC.
@ -76,6 +76,7 @@ struct objc_method_description
#define _C_UNION_E ')' #define _C_UNION_E ')'
#define _C_STRUCT_B '{' #define _C_STRUCT_B '{'
#define _C_STRUCT_E '}' #define _C_STRUCT_E '}'
#define _C_VECTOR '!'
/* /*
@ -261,7 +262,7 @@ typedef struct objc_method_list {
struct objc_protocol_list { struct objc_protocol_list {
struct objc_protocol_list *next; struct objc_protocol_list *next;
int count; size_t count;
Protocol *list[1]; Protocol *list[1];
}; };
@ -581,19 +582,21 @@ object_get_super_class
static inline BOOL static inline BOOL
object_is_class (id object) object_is_class (id object)
{ {
return CLS_ISCLASS((Class)object); return ((object != nil) && CLS_ISMETA (object->class_pointer));
} }
static inline BOOL static inline BOOL
object_is_instance (id object) object_is_instance (id object)
{ {
return (object!=nil)&&CLS_ISCLASS(object->class_pointer); return ((object != nil) && CLS_ISCLASS (object->class_pointer));
} }
static inline BOOL static inline BOOL
object_is_meta_class (id object) object_is_meta_class (id object)
{ {
return CLS_ISMETA((Class)object); return ((object != nil)
&& !object_is_instance (object)
&& !object_is_class (object));
} }
struct sarray* struct sarray*

@ -1,5 +1,5 @@
/* GNU Objective C Runtime internal declarations /* GNU Objective C Runtime internal declarations
Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
Contributed by Kresten Krab Thorup Contributed by Kresten Krab Thorup
This file is part of GNU CC. This file is part of GNU CC.
@ -65,7 +65,8 @@ objc_EXPORT Method_t search_for_method_in_list(MethodList_t list, SEL op);
objc_EXPORT BOOL __objc_class_links_resolved; objc_EXPORT BOOL __objc_class_links_resolved;
/* Number of selectors stored in each of the selector tables */ /* Number of selectors stored in each of the selector tables */
objc_EXPORT int __objc_selector_max_index; objc_EXPORT unsigned int __objc_selector_max_index;
extern unsigned int __objc_selector_max_index;
/* Mutex locking __objc_selector_max_index and its arrays. */ /* Mutex locking __objc_selector_max_index and its arrays. */
objc_EXPORT objc_mutex_t __objc_runtime_mutex; objc_EXPORT objc_mutex_t __objc_runtime_mutex;
@ -82,6 +83,7 @@ objc_EXPORT int __objc_runtime_threads_alive;
BOOL __objc_responds_to (id object, SEL sel); /* for internal use only! */ BOOL __objc_responds_to (id object, SEL sel); /* for internal use only! */
SEL __sel_register_typed_name (const char*, const char*, SEL __sel_register_typed_name (const char*, const char*,
struct objc_selector*, BOOL is_const); struct objc_selector*, BOOL is_const);
extern void __objc_generate_gc_type_description (Class);
#endif /* not __objc_runtime_INCLUDE_GNU */ #endif /* not __objc_runtime_INCLUDE_GNU */

@ -1,5 +1,5 @@
/* GNU Objective C Runtime selector related functions /* GNU Objective C Runtime selector related functions
Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
Contributed by Kresten Krab Thorup Contributed by Kresten Krab Thorup
This file is part of GNU CC. This file is part of GNU CC.
@ -38,7 +38,7 @@ static cache_ptr __objc_selector_hash = 0; /* name -> uid !T:MUTEX */
static void register_selectors_from_list (MethodList_t); static void register_selectors_from_list (MethodList_t);
/* Number of selectors stored in each of the above tables */ /* Number of selectors stored in each of the above tables */
int __objc_selector_max_index = 0; /* !T:MUTEX */ unsigned int __objc_selector_max_index = 0; /* !T:MUTEX */
void __objc_init_selector_tables () void __objc_init_selector_tables ()
{ {
@ -164,8 +164,8 @@ sel_types_match (const char* t1, const char* t2)
{ {
if (*t1 == '+') t1++; if (*t1 == '+') t1++;
if (*t2 == '+') t2++; if (*t2 == '+') t2++;
while (isdigit(*t1)) t1++; while (isdigit ((unsigned char) *t1)) t1++;
while (isdigit(*t2)) t2++; while (isdigit ((unsigned char) *t2)) t2++;
/* xxx Remove these next two lines when qualifiers are put in /* xxx Remove these next two lines when qualifiers are put in
all selectors, not just Protocol selectors. */ all selectors, not just Protocol selectors. */
t1 = objc_skip_type_qualifiers (t1); t1 = objc_skip_type_qualifiers (t1);
@ -285,8 +285,7 @@ sel_get_uid (const char *name)
/* Get name of selector. If selector is unknown, the empty string "" /* Get name of selector. If selector is unknown, the empty string ""
is returned */ is returned */
const char* const char *sel_get_name (SEL selector)
sel_get_name (SEL selector)
{ {
const char *ret; const char *ret;
@ -308,8 +307,7 @@ sel_is_mapped (SEL selector)
} }
const char* const char *sel_get_type (SEL selector)
sel_get_type (SEL selector)
{ {
if (selector) if (selector)
return selector->sel_types; return selector->sel_types;
@ -455,4 +453,3 @@ sel_register_typed_name (const char *name, const char *type)
return ret; return ret;
} }

@ -1,6 +1,6 @@
/* GNU Objective C Runtime message lookup /* GNU Objective C Runtime message lookup
Copyright (C) 1993, 1995, 1996, 1997, 1998, Copyright (C) 1993, 1995, 1996, 1997, 1998,
2001 Free Software Foundation, Inc. 2001, 2002 Free Software Foundation, Inc.
Contributed by Kresten Krab Thorup Contributed by Kresten Krab Thorup
This file is part of GNU CC. This file is part of GNU CC.
@ -25,6 +25,8 @@ Boston, MA 02111-1307, USA. */
however invalidate any other reasons why the executable file might be however invalidate any other reasons why the executable file might be
covered by the GNU General Public License. */ covered by the GNU General Public License. */
/* FIXME: This file has no business including tm.h. */
#include "tconfig.h" #include "tconfig.h"
#include "runtime.h" #include "runtime.h"
#include "sarray.h" #include "sarray.h"
@ -78,20 +80,24 @@ static id
__objc_block_forward (id, SEL, ...); __objc_block_forward (id, SEL, ...);
static Method_t search_for_method_in_hierarchy (Class class, SEL sel); static Method_t search_for_method_in_hierarchy (Class class, SEL sel);
Method_t search_for_method_in_list (MethodList_t list, SEL op); Method_t search_for_method_in_list (MethodList_t list, SEL op);
id nil_method(id, SEL, ...); id nil_method (id, SEL);
/* Given a selector, return the proper forwarding implementation. */ /* Given a selector, return the proper forwarding implementation. */
__inline__ __inline__
IMP IMP
__objc_get_forward_imp (SEL sel) __objc_get_forward_imp (SEL sel)
{ {
/* If a custom forwarding hook was registered, try getting a forwarding
* function from it. */
if (__objc_msg_forward) if (__objc_msg_forward)
{ {
IMP result; IMP result;
if ((result = __objc_msg_forward (sel))) if ((result = __objc_msg_forward (sel)) != NULL)
return result; return result;
} }
else
/* In all other cases, use the default forwarding functions built using
* __builtin_apply and friends. */
{ {
const char *t = sel->sel_types; const char *t = sel->sel_types;
@ -195,7 +201,7 @@ objc_msg_lookup(id receiver, SEL op)
return result; return result;
} }
else else
return nil_method; return (IMP)nil_method;
} }
IMP IMP
@ -204,7 +210,7 @@ objc_msg_lookup_super (Super_t super, SEL sel)
if (super->self) if (super->self)
return get_imp (super->class, sel); return get_imp (super->class, sel);
else else
return nil_method; return (IMP)nil_method;
} }
int method_get_sizeof_arguments (Method *); int method_get_sizeof_arguments (Method *);
@ -224,15 +230,14 @@ objc_msg_sendv(id object, SEL op, arglist_t arg_frame)
void void
__objc_init_dispatch_tables () __objc_init_dispatch_tables ()
{ {
__objc_uninstalled_dtable __objc_uninstalled_dtable = sarray_new (200, 0);
= sarray_new(200, 0);
} }
/* This function is called by objc_msg_lookup when the /* This function is called by objc_msg_lookup when the
dispatch table needs to be installed; thus it is called once dispatch table needs to be installed; thus it is called once
for each class, namely when the very first message is sent to it. */ for each class, namely when the very first message is sent to it. */
static void static void
__objc_init_install_dtable(id receiver, SEL op) __objc_init_install_dtable (id receiver, SEL op __attribute__ ((__unused__)))
{ {
/* This may happen, if the programmer has taken the address of a /* This may happen, if the programmer has taken the address of a
method before the dtable was initialized... too bad for him! */ method before the dtable was initialized... too bad for him! */
@ -599,7 +604,6 @@ __objc_forward (id object, SEL sel, arglist_t args)
/* The object doesn't recognize the method. Check for responding to /* The object doesn't recognize the method. Check for responding to
error:. If it does then sent it. */ error:. If it does then sent it. */
{ {
size_t strlen (const char*);
char msg[256 + strlen ((const char *) sel_get_name (sel)) char msg[256 + strlen ((const char *) sel_get_name (sel))
+ strlen ((const char *) object->class_pointer->name)]; + strlen ((const char *) object->class_pointer->name)];
@ -644,7 +648,8 @@ __objc_print_dtable_stats()
(long) nbuckets * sizeof (struct sbucket)); (long) nbuckets * sizeof (struct sbucket));
total += nbuckets * sizeof (struct sbucket); total += nbuckets * sizeof (struct sbucket);
printf("idxtables: %d = %ld bytes\n", idxsize, (long)idxsize*sizeof(void*)); printf ("idxtables: %d = %ld bytes\n",
idxsize, (long) idxsize * sizeof (void *));
total += idxsize * sizeof (void *); total += idxsize * sizeof (void *);
printf ("-----------------------------------\n"); printf ("-----------------------------------\n");
printf ("total: %d bytes\n", total); printf ("total: %d bytes\n", total);

Loading…
Cancel
Save