Ignore:
Timestamp:
Apr 27, 2004, 8:39:34 PM (21 years ago)
Author:
bird
Message:

GCC v3.3.3 sources.

Location:
branches/GNU/src/gcc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/gcc

    • Property svn:ignore
      •  

        old new  
        2626configure.vr
        2727configure.vrs
         28dir.info
        2829Makefile
        29 dir.info
        3030lost+found
        3131update.out
  • branches/GNU/src/gcc/libobjc/init.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* GNU Objective C Runtime initialization
    2    Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
     2   Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
    33   Contributed by Kresten Krab Thorup
    44   +load support contributed by Ovidiu Predescu <ovidiu@net-community.com>
     
    2828
    2929/* The version number of this runtime.  This must match the number
    30    defined in gcc (objc-act.c) */
     30   defined in gcc (objc-act.c). */
    3131#define OBJC_VERSION 8
    3232#define PROTOCOL_VERSION 2
    3333
    34 /* This list contains all modules currently loaded into the runtime */
    35 static struct objc_list* __objc_module_list = 0;        /* !T:MUTEX */
    36 
    37 /* This list contains all proto_list's not yet assigned class links */
    38 static struct objc_list* unclaimed_proto_list = 0;      /* !T:MUTEX */
     34/* This list contains all modules currently loaded into the runtime. */
     35static struct objc_list *__objc_module_list = 0;        /* !T:MUTEX */
     36
     37/* This list contains all proto_list's not yet assigned class links. */
     38static struct objc_list *unclaimed_proto_list = 0;      /* !T:MUTEX */
    3939
    4040/* List of unresolved static instances.  */
    4141static struct objc_list *uninitialized_statics = 0;     /* !T:MUTEX */
    4242
    43 /* Global runtime "write" mutex. */
     43/* Global runtime "write" mutex.  */
    4444objc_mutex_t __objc_runtime_mutex = 0;
    4545
    46 /* Number of threads that are alive. */
     46/* Number of threads that are alive.  */
    4747int __objc_runtime_threads_alive = 1;                   /* !T:MUTEX */
    4848
    49 /* Check compiler vs runtime version */
     49/* Check compiler vs runtime version. */
    5050static void init_check_module_version (Module_t);
    5151
    52 /* Assign isa links to protos */
    53 static void __objc_init_protocols (struct objc_protocol_list* protos);
    54 
    55 /* Add protocol to class */
    56 static void __objc_class_add_protocols (Class, struct objc_protocol_list*);
    57 
    58 /* This is a hook which is called by __objc_exec_class every time a class
    59    or a category is loaded into the runtime.  This may e.g. help a
    60    dynamic loader determine the classes that have been loaded when
    61    an object file is dynamically linked in */
    62 void (*_objc_load_callback)(Class class, Category* category); /* !T:SAFE */
    63 
    64 /* Is all categories/classes resolved? */
     52/* Assign isa links to protos. */
     53static void __objc_init_protocols (struct objc_protocol_list *protos);
     54
     55/* Add protocol to class. */
     56static void __objc_class_add_protocols (Class, struct objc_protocol_list *);
     57
     58/* This is a hook which is called by __objc_exec_class every time a
     59   class or a category is loaded into the runtime.  This may e.g. help
     60   a dynamic loader determine the classes that have been loaded when
     61   an object file is dynamically linked in. */
     62void (*_objc_load_callback) (Class class, Category *category); /* !T:SAFE */
     63
     64/* Is all categories/classes resolved?  */
    6565BOOL __objc_dangling_categories = NO;           /* !T:UNUSED */
    6666
     
    6969                           struct objc_selector *orig, BOOL is_const);
    7070
    71 /* Sends +load to all classes and categories in certain situations. */
     71/* Sends +load to all classes and categories in certain situations.  */
    7272static void objc_send_load (void);
    7373
    7474/* Inserts all the classes defined in module in a tree of classes that
    75    resembles the class hierarchy. This tree is traversed in preorder and the
    76    classes in its nodes receive the +load message if these methods were not
    77    executed before. The algorithm ensures that when the +load method of a class
    78    is executed all the superclasses have been already received the +load
    79    message. */
     75   resembles the class hierarchy. This tree is traversed in preorder
     76   and the classes in its nodes receive the +load message if these
     77   methods were not executed before. The algorithm ensures that when
     78   the +load method of a class is executed all the superclasses have
     79   been already received the +load message. */
    8080static void __objc_create_classes_tree (Module_t module);
    8181
     
    8383
    8484/* A special version that works only before the classes are completely
    85    installed in the runtime. */
     85   installed in the runtime.  */
    8686static BOOL class_is_subclass_of_class (Class class, Class superclass);
    8787
     
    9191} objc_class_tree;
    9292
    93 /* This is a linked list of objc_class_tree trees. The head of these trees
    94    are root classes (their super class is Nil). These different trees
    95    represent different class hierarchies. */
     93/* This is a linked list of objc_class_tree trees. The head of these
     94   trees are root classes (their super class is Nil). These different
     95   trees represent different class hierarchies. */
    9696static struct objc_list *__objc_class_tree_list = NULL;
    9797
    98 /* Keeps the +load methods who have been already executed. This hash should
    99    not be destroyed during the execution of the program. */
     98/* Keeps the +load methods who have been already executed. This hash
     99   should not be destroyed during the execution of the program. */
    100100static cache_ptr __objc_load_methods = NULL;
    101101
    102 /* Creates a tree of classes whose topmost class is directly inherited from
    103    `upper' and the bottom class in this tree is `bottom_class'. The classes
    104    in this tree are super classes of `bottom_class'. `subclasses' member
    105    of each tree node point to the next subclass tree node. */
     102/* Creates a tree of classes whose topmost class is directly inherited
     103   from `upper' and the bottom class in this tree is
     104   `bottom_class'. The classes in this tree are super classes of
     105   `bottom_class'. `subclasses' member of each tree node point to the
     106   next subclass tree node.  */
     107
    106108static objc_class_tree *
    107109create_tree_of_subclasses_inherited_from (Class bottom_class, Class upper)
    108110{
    109111  Class superclass = bottom_class->super_class ?
    110                         objc_lookup_class ((char*)bottom_class->super_class)
     112                        objc_lookup_class ((char *) bottom_class->super_class)
    111113                      : Nil;
    112114                                       
     
    127129      tree->subclasses = list_cons (prev, tree->subclasses);
    128130      superclass = (superclass->super_class ?
    129                         objc_lookup_class ((char*)superclass->super_class)
     131                        objc_lookup_class ((char *) superclass->super_class)
    130132                      : Nil);
    131133      prev = tree;
     
    135137}
    136138
    137 /* Insert the `class' into the proper place in the `tree' class hierarchy. This
    138    function returns a new tree if the class has been successfully inserted into
    139    the tree or NULL if the class is not part of the classes hierarchy described
    140    by `tree'. This function is private to objc_tree_insert_class(), you should
    141    not call it directly. */
     139/* Insert the `class' into the proper place in the `tree' class
     140   hierarchy. This function returns a new tree if the class has been
     141   successfully inserted into the tree or NULL if the class is not
     142   part of the classes hierarchy described by `tree'. This function is
     143   private to objc_tree_insert_class (), you should not call it
     144   directly.  */
     145
    142146static objc_class_tree *
    143147__objc_tree_insert_class (objc_class_tree *tree, Class class)
     
    155159    }
    156160  else if ((class->super_class ?
    157                     objc_lookup_class ((char*)class->super_class)
     161                    objc_lookup_class ((char *) class->super_class)
    158162                  : Nil)
    159163            == tree->class)
     
    161165      /* If class is a direct subclass of tree->class then add class to the
    162166         list of subclasses. First check to see if it wasn't already
    163          inserted. */
     167         inserted.  */
    164168      struct objc_list *list = tree->subclasses;
    165169      objc_class_tree *node;
     
    168172        {
    169173          /* Class has been already inserted; do nothing just return
    170              the tree. */
    171           if (((objc_class_tree*)list->head)->class == class)
     174             the tree.  */
     175          if (((objc_class_tree *) list->head)->class == class)
    172176            {
    173177              DEBUG_PRINTF ("2. class %s was previously inserted\n",
     
    187191  else
    188192    {
    189       /* The class is not a direct subclass of tree->class. Search for class's
    190          superclasses in the list of subclasses. */
     193      /* The class is not a direct subclass of tree->class. Search for
     194         class's superclasses in the list of subclasses. */
    191195      struct objc_list *subclasses = tree->subclasses;
    192196
    193       /* Precondition: the class must be a subclass of tree->class; otherwise
    194          return NULL to indicate our caller that it must take the next tree. */
    195       if (!class_is_subclass_of_class (class, tree->class))
     197      /* Precondition: the class must be a subclass of tree->class;
     198         otherwise return NULL to indicate our caller that it must
     199         take the next tree.  */
     200      if (! class_is_subclass_of_class (class, tree->class))
    196201        return NULL;
    197202
    198203      for (; subclasses != NULL; subclasses = subclasses->tail)
    199204        {
    200           Class aClass = ((objc_class_tree*)(subclasses->head))->class;
     205          Class aClass = ((objc_class_tree *) (subclasses->head))->class;
    201206
    202207          if (class_is_subclass_of_class (class, aClass))
    203208            {
    204               /* If we found one of class's superclasses we insert the class
    205                  into its subtree and return the original tree since nothing
    206                  has been changed. */
     209              /* If we found one of class's superclasses we insert the
     210                 class into its subtree and return the original tree
     211                 since nothing has been changed. */
    207212              subclasses->head
    208213                  = __objc_tree_insert_class (subclasses->head, class);
     
    212217        }
    213218
    214       /* We haven't found a subclass of `class' in the `subclasses' list.
    215          Create a new tree of classes whose topmost class is a direct subclass
    216          of tree->class. */
     219      /* We haven't found a subclass of `class' in the `subclasses'
     220         list.  Create a new tree of classes whose topmost class is a
     221         direct subclass of tree->class. */
    217222      {
    218223        objc_class_tree *new_tree
    219             = create_tree_of_subclasses_inherited_from (class, tree->class);
     224          = create_tree_of_subclasses_inherited_from (class, tree->class);
    220225        tree->subclasses = list_cons (new_tree, tree->subclasses);
    221226        DEBUG_PRINTF ("5. class %s inserted\n", class->name);
     
    225230}
    226231
    227 /* This function inserts `class' in the right tree hierarchy classes. */
     232/* This function inserts `class' in the right tree hierarchy classes.  */
     233
    228234static void
    229235objc_tree_insert_class (Class class)
     
    245251    }
    246252
    247   /* If the list was finished but the class hasn't been inserted, insert it
    248      here. */
    249   if (!list_node)
     253  /* If the list was finished but the class hasn't been inserted,
     254     insert it here. */
     255  if (! list_node)
    250256    {
    251257      __objc_class_tree_list = list_cons (NULL, __objc_class_tree_list);
     
    254260}
    255261
    256 /* Traverse tree in preorder. Used to send +load. */
     262/* Traverse tree in preorder. Used to send +load.  */
     263
    257264static void
    258265objc_preorder_traverse (objc_class_tree *tree,
    259266                        int level,
    260                         void (*function)(objc_class_tree*, int))
     267                        void (*function) (objc_class_tree *, int))
    261268{
    262269  struct objc_list *node;
     
    267274}
    268275
    269 /* Traverse tree in postorder. Used to destroy a tree. */
     276/* Traverse tree in postorder. Used to destroy a tree.  */
     277
    270278static void
    271279objc_postorder_traverse (objc_class_tree *tree,
    272                         int level,
    273                         void (*function)(objc_class_tree*, int))
     280                         int level,
     281                         void (*function) (objc_class_tree *, int))
    274282{
    275283  struct objc_list *node;
     
    280288}
    281289
    282 /* Used to print a tree class hierarchy. */
     290/* Used to print a tree class hierarchy.  */
     291
    283292#ifdef DEBUG
    284293static void
     
    293302#endif
    294303
    295 /* Walks on a linked list of methods in the reverse order and executes all
    296    the methods corresponding to `op' selector. Walking in the reverse order
    297    assures the +load of class is executed first and then +load of categories
    298    because of the way in which categories are added to the class methods. */
     304/* Walks on a linked list of methods in the reverse order and executes
     305   all the methods corresponding to `op' selector. Walking in the
     306   reverse order assures the +load of class is executed first and then
     307   +load of categories because of the way in which categories are
     308   added to the class methods.  */
     309
    299310static void
    300311__objc_send_message_in_list (MethodList_t method_list, Class class, SEL op)
     
    302313  int i;
    303314
    304   if (!method_list)
     315  if (! method_list)
    305316    return;
    306317
     
    308319  __objc_send_message_in_list (method_list->method_next, class, op);
    309320
    310   /* Search the method list. */
     321  /* Search the method list.  */
    311322  for (i = 0; i < method_list->method_count; i++)
    312323    {
     
    314325
    315326      if (mth->method_name && sel_eq (mth->method_name, op)
    316           && !hash_is_key_in_hash (__objc_load_methods, mth->method_imp))
     327          && ! hash_is_key_in_hash (__objc_load_methods, mth->method_imp))
    317328        {
    318329          /* Add this method into the +load hash table */
     
    321332          DEBUG_PRINTF ("sending +load in class: %s\n", class->name);
    322333
    323           /* The method was found and wasn't previously executed. */
     334          /* The method was found and wasn't previously executed.  */
    324335          (*mth->method_imp) ((id)class, mth->method_name);
    325336
     
    330341
    331342static void
    332 __objc_send_load (objc_class_tree *tree, int level)
     343__objc_send_load (objc_class_tree *tree,
     344                  int level __attribute__ ((__unused__)))
    333345{
    334346  static SEL load_sel = 0;
     
    336348  MethodList_t method_list = class->class_pointer->methods;
    337349
    338   if (!load_sel)
     350  if (! load_sel)
    339351    load_sel = sel_register_name ("load");
    340352
     
    343355
    344356static void
    345 __objc_destroy_class_tree_node (objc_class_tree *tree, int level)
     357__objc_destroy_class_tree_node (objc_class_tree *tree,
     358                                int level __attribute__ ((__unused__)))
    346359{
    347360  objc_free (tree);
    348361}
    349362
    350 /* This is used to check if the relationship between two classes before the
    351    runtime completely installs the classes. */
     363/* This is used to check if the relationship between two classes
     364   before the runtime completely installs the classes.  */
     365
    352366static BOOL
    353367class_is_subclass_of_class (Class class, Class superclass)
     
    358372        return YES;
    359373      class = (class->super_class ?
    360                   objc_lookup_class ((char*)class->super_class)
     374                  objc_lookup_class ((char *) class->super_class)
    361375                : Nil);
    362376    }
     
    365379}
    366380
    367 /* This list contains all the classes in the runtime system for whom their
    368    superclasses are not yet know to the runtime. */
    369 static struct objc_list* unresolved_classes = 0;
    370 
    371 /* Extern function used to reference the Object and NXConstantString classes.
    372  */
     381/* This list contains all the classes in the runtime system for whom
     382   their superclasses are not yet known to the runtime. */
     383static struct objc_list *unresolved_classes = 0;
     384
     385/* Extern function used to reference the Object and NXConstantString
     386   classes.  */
    373387
    374388extern void __objc_force_linking (void);
     
    381395}
    382396
    383 /* Run through the statics list, removing modules as soon as all its statics
    384    have been initialized.  */
     397/* Run through the statics list, removing modules as soon as all its
     398   statics have been initialized.  */
     399
    385400static void
    386401objc_init_statics (void)
     
    389404  struct objc_static_instances **statics_in_module;
    390405
    391   objc_mutex_lock(__objc_runtime_mutex);
     406  objc_mutex_lock (__objc_runtime_mutex);
    392407
    393408  while (*cell)
     
    401416          Class class = objc_lookup_class (statics->class_name);
    402417
    403           if (!class)
     418          if (! class)
    404419            module_initialized = 0;
    405420          /* Actually, the static's class_pointer will be NULL when we
     
    431446          struct objc_list *this = *cell;
    432447          *cell = this->tail;
    433           objc_free(this);
     448          objc_free (this);
    434449        }
    435450      else
     
    437452    }
    438453
    439   objc_mutex_unlock(__objc_runtime_mutex);
     454  objc_mutex_unlock (__objc_runtime_mutex);
    440455} /* objc_init_statics */
    441456
    442457/* This function is called by constructor functions generated for each
    443    module compiled.  (_GLOBAL_$I$...) The purpose of this function is to
    444    gather the module pointers so that they may be processed by the
    445    initialization routines as soon as possible */
     458   module compiled.  (_GLOBAL_$I$...) The purpose of this function is
     459   to gather the module pointers so that they may be processed by the
     460   initialization routines as soon as possible. */
    446461
    447462void
     
    452467  static BOOL previous_constructors = 0;
    453468
    454   static struct objc_list* unclaimed_categories = 0;
     469  static struct objc_list *unclaimed_categories = 0;
    455470
    456471  /* The symbol table (defined in objc-api.h) generated by gcc */
     
    462477
    463478  /* Entry used to traverse hash lists */
    464   struct objc_list** cell;
     479  struct objc_list **cell;
    465480
    466481  /* The table of selector references for this module */
     
    473488
    474489  /* check gcc version */
    475   init_check_module_version(module);
     490  init_check_module_version (module);
    476491
    477492  /* On the first call of this routine, initialize some data structures.  */
    478   if (!previous_constructors)
     493  if (! previous_constructors)
    479494    {
    480495        /* Initialize thread-safe system */
    481       __objc_init_thread_system();
     496      __objc_init_thread_system ();
    482497      __objc_runtime_threads_alive = 1;
    483       __objc_runtime_mutex = objc_mutex_allocate();
    484 
    485       __objc_init_selector_tables();
    486       __objc_init_class_tables();
    487       __objc_init_dispatch_tables();
     498      __objc_runtime_mutex = objc_mutex_allocate ();
     499
     500      __objc_init_selector_tables ();
     501      __objc_init_class_tables ();
     502      __objc_init_dispatch_tables ();
    488503      __objc_class_tree_list = list_cons (NULL, __objc_class_tree_list);
    489504      __objc_load_methods
     
    493508
    494509  /* Save the module pointer for later processing. (not currently used) */
    495   objc_mutex_lock(__objc_runtime_mutex);
    496   __objc_module_list = list_cons(module, __objc_module_list);
     510  objc_mutex_lock (__objc_runtime_mutex);
     511  __objc_module_list = list_cons (module, __objc_module_list);
    497512
    498513  /* Replace referenced selectors from names to SEL's.  */
     
    502517        {
    503518          const char *name, *type;
    504           name = (char*)selectors[i].sel_id;
    505           type = (char*)selectors[i].sel_types;
     519          name = (char *) selectors[i].sel_id;
     520          type = (char *) selectors[i].sel_types;
    506521          /* Constructors are constant static data so we can safely store
    507522             pointers to them in the runtime structures. is_const == YES */
    508523          __sel_register_typed_name (name, type,
    509                                      (struct objc_selector*)&(selectors[i]),
     524                                     (struct objc_selector *) &(selectors[i]),
    510525                                     YES);
    511526        }
     
    517532    {
    518533      Class class = (Class) symtab->defs[i];
    519       const char* superclass = (char*)class->super_class;
     534      const char *superclass = (char *) class->super_class;
    520535
    521536      /* Make sure we have what we think.  */
    522       assert (CLS_ISCLASS(class));
    523       assert (CLS_ISMETA(class->class_pointer));
     537      assert (CLS_ISCLASS (class));
     538      assert (CLS_ISMETA (class->class_pointer));
    524539      DEBUG_PRINTF ("phase 1, processing class: %s\n", class->name);
    525540
    526541      /* Initialize the subclass list to be NULL.
    527          In some cases it isn't and this crashes the program. */
     542         In some cases it isn't and this crashes the program.  */
    528543      class->subclass_list = NULL;
    529544
     
    536551
    537552      /* Install the fake dispatch tables */
    538       __objc_install_premature_dtable(class);
    539       __objc_install_premature_dtable(class->class_pointer);
     553      __objc_install_premature_dtable (class);
     554      __objc_install_premature_dtable (class->class_pointer);
    540555
    541556      /* Register the instance methods as class methods, this is
    542          only done for root classes. */
    543       __objc_register_instance_methods_to_class(class);
     557         only done for root classes.  */
     558      __objc_register_instance_methods_to_class (class);
    544559
    545560      if (class->protocols)
     
    547562
    548563      /* Check to see if the superclass is known in this point. If it's not
    549          add the class to the unresolved_classes list. */
    550       if (superclass && !objc_lookup_class (superclass))
     564         add the class to the unresolved_classes list.  */
     565      if (superclass && ! objc_lookup_class (superclass))
    551566        unresolved_classes = list_cons (class, unresolved_classes);
    552567   }
     
    582597
    583598          /* Register the instance methods as class methods, this is
    584              only done for root classes. */
    585           __objc_register_instance_methods_to_class(class);
     599             only done for root classes.  */
     600          __objc_register_instance_methods_to_class (class);
    586601        }
    587602      else
     
    589604          /* The object to which the category methods belong can't be found.
    590605             Save the information.  */
    591           unclaimed_categories = list_cons(category, unclaimed_categories);
     606          unclaimed_categories = list_cons (category, unclaimed_categories);
    592607        }
    593608    }
     
    626641
    627642          /* Register the instance methods as class methods, this is
    628              only done for root classes. */
    629           __objc_register_instance_methods_to_class(class);
     643             only done for root classes.  */
     644          __objc_register_instance_methods_to_class (class);
    630645        }
    631646      else
     
    635650  if (unclaimed_proto_list && objc_lookup_class ("Protocol"))
    636651    {
    637       list_mapcar (unclaimed_proto_list,(void(*)(void*))__objc_init_protocols);
     652      list_mapcar (unclaimed_proto_list,
     653                   (void (*) (void *))__objc_init_protocols);
    638654      list_free (unclaimed_proto_list);
    639655      unclaimed_proto_list = 0;
     
    642658  objc_send_load ();
    643659
    644   objc_mutex_unlock(__objc_runtime_mutex);
    645 }
    646 
    647 static void objc_send_load (void)
    648 {
    649   if (!__objc_module_list)
     660  objc_mutex_unlock (__objc_runtime_mutex);
     661}
     662
     663static void
     664objc_send_load (void)
     665{
     666  if (! __objc_module_list)
    650667    return;
    651668 
    652669  /* Try to find out if all the classes loaded so far also have their
    653      superclasses known to the runtime. We suppose that the objects that are
    654      allocated in the +load method are in general of a class declared in the
    655      same module. */
     670     superclasses known to the runtime. We suppose that the objects
     671     that are allocated in the +load method are in general of a class
     672     declared in the same module. */
    656673  if (unresolved_classes)
    657674    {
    658675      Class class = unresolved_classes->head;
    659676
    660       while (objc_lookup_class ((char*)class->super_class))
     677      while (objc_lookup_class ((char *) class->super_class))
    661678        {
    662679          list_remove_head (&unresolved_classes);
     
    667684        }
    668685
    669       /*
    670        * If we still have classes for whom we don't have yet their super
    671        * classes known to the runtime we don't send the +load messages.
    672        */
     686      /* If we still have classes for whom we don't have yet their
     687         super classes known to the runtime we don't send the +load
     688         messages.  */
    673689      if (unresolved_classes)
    674690        return;
    675691    }
    676692
    677   /* Special check to allow creating and sending messages to constant strings
    678      in +load methods. If these classes are not yet known, even if all the
    679      other classes are known, delay sending of +load. */
    680   if (!objc_lookup_class ("NXConstantString") ||
    681       !objc_lookup_class ("Object"))
     693  /* Special check to allow creating and sending messages to constant
     694     strings in +load methods. If these classes are not yet known,
     695     even if all the other classes are known, delay sending of +load. */
     696  if (! objc_lookup_class ("NXConstantString") ||
     697      ! objc_lookup_class ("Object"))
    682698    return;
    683699
    684   /* Iterate over all modules in the __objc_module_list and call on them the
    685      __objc_create_classes_tree function. This function creates a tree of
    686      classes that resembles the class hierarchy. */
    687   list_mapcar (__objc_module_list, (void(*)(void*))__objc_create_classes_tree);
     700  /* Iterate over all modules in the __objc_module_list and call on
     701     them the __objc_create_classes_tree function. This function
     702     creates a tree of classes that resembles the class hierarchy.  */
     703  list_mapcar (__objc_module_list,
     704               (void (*) (void *)) __objc_create_classes_tree);
    688705
    689706  while (__objc_class_tree_list)
     
    700717    }
    701718
    702   list_mapcar (__objc_module_list, (void(*)(void*))__objc_call_callback);
     719  list_mapcar (__objc_module_list, (void (*) (void *)) __objc_call_callback);
    703720  list_free (__objc_module_list);
    704721  __objc_module_list = NULL;
     
    713730  int i;
    714731
    715   /* Iterate thru classes defined in this module and insert them in the classes
    716      tree hierarchy. */
     732  /* Iterate thru classes defined in this module and insert them in
     733     the classes tree hierarchy. */
    717734  for (i = 0; i < symtab->cls_def_cnt; i++)
    718735    {
     
    726743__objc_call_callback (Module_t module)
    727744{
    728   /* The runtime mutex is locked in this point */
     745  /* The runtime mutex is locked in this point. */
    729746
    730747  Symtab_t symtab = module->symtab;
    731748  int i;
    732749
    733   /* Iterate thru classes defined in this module and call the callback for
    734      each one. */
     750  /* Iterate thru classes defined in this module and call the callback
     751     for each one. */
    735752  for (i = 0; i < symtab->cls_def_cnt; i++)
    736753    {
    737754      Class class = (Class) symtab->defs[i];
    738755
    739       /* Call the _objc_load_callback for this class. */
     756      /* Call the _objc_load_callback for this class.  */
    740757      if (_objc_load_callback)
    741         _objc_load_callback(class, 0);
    742     }
    743 
    744   /* Call the _objc_load_callback for categories. Don't register the instance
    745      methods as class methods for categories to root classes since they were
    746      already added in the class. */
     758        _objc_load_callback (class, 0);
     759    }
     760
     761  /* Call the _objc_load_callback for categories. Don't register the
     762     instance methods as class methods for categories to root classes
     763     since they were already added in the class. */
    747764  for (i = 0; i < symtab->cat_def_cnt; i++)
    748765    {
     
    751768     
    752769      if (_objc_load_callback)
    753         _objc_load_callback(class, category);
    754     }
    755 }
    756 
    757 /* Sanity check the version of gcc used to compile `module'*/
    758 static void init_check_module_version(Module_t module)
     770        _objc_load_callback (class, category);
     771    }
     772}
     773
     774/* Sanity check the version of gcc used to compile `module'.  */
     775
     776static void
     777init_check_module_version (Module_t module)
    759778{
    760779  if ((module->version != OBJC_VERSION) || (module->size != sizeof (Module)))
     
    762781      int code;
    763782
    764       if(module->version > OBJC_VERSION)
     783      if (module->version > OBJC_VERSION)
    765784        code = OBJC_ERR_OBJC_VERSION;
    766785      else if (module->version < OBJC_VERSION)
     
    769788        code = OBJC_ERR_MODULE_SIZE;
    770789
    771       objc_error(nil, code, "Module %s version %d doesn't match runtime %d\n",
    772                module->name, (int)module->version, OBJC_VERSION);
    773     }
    774 }
    775 
    776 static void
    777 __objc_init_protocols (struct objc_protocol_list* protos)
    778 {
    779   int i;
     790      objc_error (nil, code, "Module %s version %d doesn't match runtime %d\n",
     791                  module->name, (int)module->version, OBJC_VERSION);
     792    }
     793}
     794
     795static void
     796__objc_init_protocols (struct objc_protocol_list *protos)
     797{
     798  size_t i;
    780799  static Class proto_class = 0;
    781800
     
    783802    return;
    784803
    785   objc_mutex_lock(__objc_runtime_mutex);
    786 
    787   if (!proto_class)
    788     proto_class = objc_lookup_class("Protocol");
    789 
    790   if (!proto_class)
     804  objc_mutex_lock (__objc_runtime_mutex);
     805
     806  if (! proto_class)
     807    proto_class = objc_lookup_class ("Protocol");
     808
     809  if (! proto_class)
    791810    {
    792811      unclaimed_proto_list = list_cons (protos, unclaimed_proto_list);
    793       objc_mutex_unlock(__objc_runtime_mutex);
     812      objc_mutex_unlock (__objc_runtime_mutex);
    794813      return;
    795814    }
     
    799818#endif
    800819
    801   for(i = 0; i < protos->count; i++)
    802     {
    803       struct objc_protocol* aProto = protos->list[i];
     820  for (i = 0; i < protos->count; i++)
     821    {
     822      struct objc_protocol *aProto = protos->list[i];
    804823      if (((size_t)aProto->class_pointer) == PROTOCOL_VERSION)
    805824        {
     
    812831      else if (protos->list[i]->class_pointer != proto_class)
    813832        {
    814           objc_error(nil, OBJC_ERR_PROTOCOL_VERSION,
     833          objc_error (nil, OBJC_ERR_PROTOCOL_VERSION,
    815834                     "Version %d doesn't match runtime protocol version %d\n",
    816                      (int)((char*)protos->list[i]->class_pointer-(char*)0),
     835                     (int) ((char *) protos->list[i]->class_pointer
     836                            - (char *) 0),
    817837                     PROTOCOL_VERSION);
    818838        }
    819839    }
    820840
    821   objc_mutex_unlock(__objc_runtime_mutex);
    822 }
    823 
    824 static void __objc_class_add_protocols (Class class,
    825                                         struct objc_protocol_list* protos)
    826 {
    827   /* Well... */
     841  objc_mutex_unlock (__objc_runtime_mutex);
     842}
     843
     844static void
     845__objc_class_add_protocols (Class class, struct objc_protocol_list *protos)
     846{
     847  /* Well...  */
    828848  if (! protos)
    829849    return;
    830850
    831   /* Add it... */
     851  /* Add it...  */
    832852  protos->next = class->protocols;
    833853  class->protocols = protos;
Note: See TracChangeset for help on using the changeset viewer.