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:
27 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/ChangeLog

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 2003-02-05  Release Manager
    2 
    3         * GCC 3.2.2 Released.
    4 
    5 2003-01-28  Christian Cornelssen  <ccorn@cs.tu-berlin.de>
     12004-02-14  Release Manager
     2
     3        * GCC 3.3.3 Released.
     4
     52003-12-01  Zack Weinberg  <zack@codesourcery.com>
     6
     7        PR 11433
     8        * Protocol.m (descriptionForInstanceMethod): Don't dereference
     9        instance_methods if it's NULL.
     10        (descriptionForClassMethod): Likewise for class_methods.
     11
     122003-10-16  Release Manager
     13
     14        * GCC 3.3.2 Released.
     15
     162003-09-09  Alan Modra  <amodra@bigpond.net.au>
     17
     18        * configure: Regenerate.
     19
     202003-08-04  Release Manager
     21
     22        * GCC 3.3.1 Released.
     23
     242003-08-04  Release Manager
     25
     26        * GCC 3.3.1 Released.
     27
     282003-05-13  Release Manager
     29
     30        * GCC 3.3 Released.
     31
     322003-05-13  Release Manager
     33
     34        * GCC 3.3 Released.
     35
     362003-05-13  Release Manager
     37
     38        * GCC 3.3 Released.
     39
     402003-02-20  Alexandre Oliva  <aoliva@redhat.com>
     41
     42        * configure.in: Propagate ORIGINAL_LD_FOR_MULTILIBS to
     43        config.status.
     44        * configure: Rebuilt.
     45
     462003-01-27  Alexandre Oliva  <aoliva@redhat.com>
     47
     48        * aclocal.m4 (glibcpp_toolexeclibdir): Instead of
     49        $(MULTISUBDIR), use `$CC -print-multi-os-directory`, unless
     50        version_specific_libs is enabled.
     51        * configure: Rebuilt.
     52
     532003-01-26  Christian Cornelssen  <ccorn@cs.tu-berlin.de>
    654
    755        * Makefile.in (FLAGS_TO_PASS): Also pass DESTDIR.
     
    957        destination paths in all (un)installation commands.
    1058
    11 2003-01-27  Alexandre Oliva  <aoliva@redhat.com>
    12 
    13         * aclocal.m4 (glibcpp_toolexeclibdir): Instead of
    14         $(MULTISUBDIR), use `$CC -print-multi-os-directory`, unless
    15         version_specific_libs is enabled.
    16         * configure: Rebuilt.
    17 
    18 2002-11-19  Release Manager
    19 
    20         * GCC 3.2.1 Released.
    21 
    22 2002-11-19  Release Manager
    23 
    24         * GCC 3.2.1 Released.
    25 
    26 2002-11-18  Release Manager
    27 
    28         * GCC 3.2.1 Released.
    29 
    30 2002-10-07  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
     592002-09-22  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
    3160
    3261        * Makefile.in (all): Fix multilib parallel build.
    3362
    34 2002-08-14  Release Manager
    35 
    36         * GCC 3.2 Released.
    37 
    38 2002-07-25  Release Manager
    39 
    40         * GCC 3.1.1 Released.
     63Thu Sep 12 12:44:37 2002  Nicola Pero  <n.pero@mi.flashnet.it>
     64
     65        * sendmsg.c (nil_method): Declare not to take a variable number of
     66        args.
     67        (objc_msg_lookup): Cast nil_method to IMP before returning it.
     68        (objc_msg_lookup_super): The same.
     69
     702002-09-10  Jan Hubicka  <jh@suse.cz>
     71
     72        * nil_method.c (nil_method): No longer defined with variable
     73        arguments.
     74
     752002-07-02  Rodney Brown  <rbrown64@csc.com.au>
     76
     77        * objc/encoding.h: Fix formatting.
     78        * objc/hash.h: Likewise.
     79        * objc/objc-api.h: Likewise.
     80        * objc/runtime.h: Likewise.
     81        * objc/thr.h: Likewise.
     82        * archive.c: Likewise.
     83        * class.c: Likewise.
     84        * encoding.c: Likewise.
     85        * gc.c: Likewise.
     86        * hash.c: Likewise.
     87        * init.c: Likewise.
     88        * misc.c: Likewise.
     89        * nil_method.c: Likewise.
     90        * objects.c: Likewise.
     91        * sarray.c: Likewise.
     92        * selector.c: Likewise.
     93        * sendmsg.c: Likewise.
     94        * thr-mach.c: Likewise.
     95        * thr.c: Likewise.
    4196
    42972002-06-25  DJ Delorie  <dj@redhat.com>
     
    47102        * configure: Regenerate.
    48103
    49 2002-05-14  Release Manager
    50 
    51         * GCC 3.1 Released.
    52 
    53 2002-05-14  Release Manager
    54 
    55         * GCC 3.1 Released.
     1042002-06-21  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
     105
     106        * Object.m (forward, read, write): Fix unused parameter warnings.
     107        * encoding.c: Include <stdlib.h>.
     108        (target_flags): Mark with attribute unused.
     109        (atoi): Delete.
     110        * runtime.h (__objc_selector_max_index): Change to unsigned int.
     111        (__objc_generate_gc_type_description): Prototype.
     112        * selector.c (__objc_selector_max_index): Change to unsigned int.
     113
     114Mon Jun 17 18:37:42 2002  Nicola Pero  <n.pero@mi.flashnet.it>
     115
     116        * sendmsg.c (__objc_get_forward_imp): Fix warning by making sure
     117        we always have a return value: if __objc_msg_forward does not
     118        supply a forwarding implementation, return the default
     119        __builtin_apply based one.
     120
     1212002-06-15  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
     122
     123        * Object.m: Fix signed/unsigned warning.
     124        * Protocol.m: Likewise.
     125        * archive.c: Always include stdlib.h.
     126        (objc_read_short, objc_read_unsigned_short, objc_read_int,
     127        objc_read_long, __objc_read_nbyte_uint, __objc_read_nbyte_ulong):
     128        Fix signed/unsigned warning.
     129        (objc_write_type, objc_read_type, objc_write_types,
     130        objc_read_types): Ensure ctype 8-bit safety.
     131        (__objc_no_write, __objc_no_read): Mark unused parameters.
     132        * class.c (class_table_setup): Specify void arg.
     133        * encoding.c (atoi, objc_sizeof_type, objc_alignof_type,
     134        objc_skip_typespec, objc_skip_offset,
     135        objc_layout_structure_next_member): Ensure ctype 8-bit safety.
     136        (objc_layout_structure_next_member): Ensure variables are
     137        initialized.
     138        * gc.c (__objc_generate_gc_type_description,
     139        class_ivar_set_gcinvisible): Mark unused parameters.
     140        * init.c (__objc_send_load, __objc_destroy_class_tree_node): Mark
     141        unused parameters.
     142        (__objc_init_protocols) Fix signed/unsigned warning.
     143        * nil_method.c (nil_method): Mark unused parameters.
     144        * thr.h (objc_thread_callback): Specify void arg.
     145        * sarray.c (sarray_new, sarray_realloc, sarray_free): Fix
     146        signed/unsigned warning.
     147        (sarray_free): Fix formatting.
     148        * selector.c (sel_types_match): Ensure ctype 8-bit safety.
     149        * sendmsg.c (__objc_init_install_dtable) Mark unused parameters.
     150
     1512002-06-09  Andreas Jaeger  <aj@suse.de>
     152
     153        * encoding.c (objc_layout_structure_next_member): Remove unused
     154        variable.
     155
     1562002-05-20  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
     157
     158        * Makefile.in (SHELL): Set to @SHELL@.
     159        (WARN_CFLAGS): New.
     160        (ALL_CFLAGS): Add $(WARN_CFLAGS).
     161
     1622002-05-16  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
     163
     164        * aclocal.m4: Allow for PWDCMD to override hardcoded pwd.
     165        * configure: Regenerate.
    56166
    571672002-05-08  Alexandre Oliva  <aoliva@redhat.com>
     
    902002001-11-14  Aldy Hernandez  <aldyh@redhat.com>
    91201
    92         * encoding.c: Add target_flags.
     202        * encoding.c: Add target_flags.
    93203
    942042001-11-07  Aldy Hernandez  <aldyh@redhat.com>
     
    101211
    102212        * class.c: Rewritten the class table to use optimized, lock-free
    103         lookup.  This more than doubles the speed of class method
    104         invocations.  (class_table_setup), (class_table_insert),
    105         (class_table_replace), (class_table_get_safe),
    106         (class_table_next), (class_table_print),
    107         (class_table_print_histogram): New functions.
    108         (__objc_init_class_tables): Use class_table_setup.
    109         (__objc_add_class_to_hash): Use class_table_get_safe and
    110         class_table_insert.  (objc_lookup_class), (objc_get_class): Do not
    111         assert the existence of the table; do not lock the runtime; use
    112         class_table_get_safe.  (objc_next_class): Use class_table_next.
    113         (__objc_resolve_class_links): Use class_table_next.
    114         (class_pose_as): Use class_table_replace.
     213        lookup.  This more than doubles the speed of class method
     214        invocations.  (class_table_setup), (class_table_insert),
     215        (class_table_replace), (class_table_get_safe),
     216        (class_table_next), (class_table_print),
     217        (class_table_print_histogram): New functions.
     218        (__objc_init_class_tables): Use class_table_setup.
     219        (__objc_add_class_to_hash): Use class_table_get_safe and
     220        class_table_insert.  (objc_lookup_class), (objc_get_class): Do not
     221        assert the existence of the table; do not lock the runtime; use
     222        class_table_get_safe.  (objc_next_class): Use class_table_next.
     223        (__objc_resolve_class_links): Use class_table_next.
     224        (class_pose_as): Use class_table_replace.
    115225
    1162262001-09-10  Ovidiu Predescu  <ovidiu@cup.hp.com>
     
    227337        friends have on various platforms. (Solution suggested by Helge
    228338        Hess.)
    229        
     339
    230340        * objc/objc-api.h: Define __objc_msg_forward.
    231341
     
    2343442000-12-06      Ralf Corsepius <corsepiu@faw.uni-ulm.de>
    235345
    236         * thr-rtems.c: New file. Stub to compile. 
     346        * thr-rtems.c: New file. Stub to compile.
    237347
    2383482000-09-06  Alexandre Oliva  <aoliva@redhat.com>
     
    276386Fri Jul 28 08:58:02 2000  Nicola Pero  <nicola@brainstorm.co.uk>
    277387
    278         * configure.in: Added libtool support; build shared libraries 
     388        * configure.in: Added libtool support; build shared libraries
    279389        if --enable-shared was passed on command line.
    280390        * Makefile.in: Modified most compilation commands to use libtool.
     
    337447        * Makefile.in (gc.o, gc_gc.o): Do not pass -fgnu-runtime to
    338448        the compiler when building C code.
    339        
     449
    340450Fri Aug  6 23:32:29 1999  Daniel Jacobowitz <drow@drow.them.org>
    341451
     
    416526
    417527        * encoding.c: Redefine get_inner_array_type to get the first entry
    418         in the structure.
     528        in the structure.
    419529
    420530Thu Oct  8 12:21:14 1998  Richard Frith-Macdonald <richard@brainstorm.co.uk>
     
    481591
    482592        * New directory.  Moved files from ../gcc/objc.
    483 
  • branches/GNU/src/gcc/libobjc/Makefile.in

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    2323#worthless.
    2424
    25 SHELL = /bin/sh
     25SHELL = @SHELL@
    2626MAKEOVERRIDES=
    2727
     
    6868CC = @CC@
    6969CFLAGS = @CFLAGS@
     70WARN_CFLAGS = -W -Wall -Wwrite-strings -Wstrict-prototypes
    7071GTHREAD_FLAGS=@GTHREAD_FLAGS@
    71 ALL_CFLAGS = -I. -I$(srcdir) $(CPPFLAGS) $(DEFS) $(CFLAGS) \
     72ALL_CFLAGS = -I. -I$(srcdir) $(CPPFLAGS) $(DEFS) $(CFLAGS) $(WARN_CFLAGS) \
    7273        $(GTHREAD_FLAGS) -DIN_GCC -DIN_TARGET_LIBS
    7374
  • branches/GNU/src/gcc/libobjc/Object.m

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* The implementation of class Object for Objective-C.
    2    Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
     2   Copyright (C) 1993, 1994, 1995, 1997, 2002 Free Software Foundation, Inc.
    33
    44This file is part of GNU CC.
     
    200200+ (BOOL) conformsTo: (Protocol*)aProtocol
    201201{
    202   int i;
     202  size_t i;
    203203  struct objc_protocol_list* proto_list;
    204204  id parent;
     
    272272- (retval_t)forward:(SEL)aSel :(arglist_t)argFrame
    273273{
     274  (void) argFrame; /* UNUSED */
    274275  return (retval_t)[self doesNotRecognize: aSel];
    275276}
     
    365366- read: (TypedStream*)aStream
    366367{
     368  (void) aStream; /* UNUSED */
    367369  // [super read: aStream]; 
    368370  return self;
     
    371373- write: (TypedStream*)aStream
    372374{
     375  (void) aStream; /* UNUSED */
    373376  // [super write: aStream];
    374377  return self;
  • branches/GNU/src/gcc/libobjc/Protocol.m

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    5454- (BOOL) conformsTo: (Protocol *)aProtocolObject
    5555{
    56   int i;
     56  size_t i;
    5757  struct objc_protocol_list* proto_list;
    5858
     
    8181  struct objc_method_description *result;
    8282
    83   for (i = 0; i < instance_methods->count; i++)
    84     {
    85       if (!strcmp ((char*)instance_methods->list[i].name, name))
    86         return &(instance_methods->list[i]);
    87     }
     83  if (instance_methods)
     84    for (i = 0; i < instance_methods->count; i++)
     85      {
     86        if (!strcmp ((char*)instance_methods->list[i].name, name))
     87          return &(instance_methods->list[i]);
     88      }
    8889
    8990  for (proto_list = protocol_list; proto_list; proto_list = proto_list->next)
    9091    {
    91       for (i=0; i < proto_list->count; i++)
     92      size_t j;
     93      for (j=0; j < proto_list->count; j++)
    9294        {
    93           if ((result = [proto_list->list[i]
     95          if ((result = [proto_list->list[j]
    9496                         descriptionForInstanceMethod: aSel]))
    9597            return result;
     
    107109  struct objc_method_description *result;
    108110
    109   for (i = 0; i < class_methods->count; i++)
    110     {
    111       if (!strcmp ((char*)class_methods->list[i].name, name))
    112         return &(class_methods->list[i]);
    113     }
     111  if (class_methods)
     112    for (i = 0; i < class_methods->count; i++)
     113      {
     114        if (!strcmp ((char*)class_methods->list[i].name, name))
     115          return &(class_methods->list[i]);
     116      }
    114117
    115118  for (proto_list = protocol_list; proto_list; proto_list = proto_list->next)
    116119    {
    117       for (i=0; i < proto_list->count; i++)
     120      size_t j;
     121      for (j=0; j < proto_list->count; j++)
    118122        {
    119           if ((result = [proto_list->list[i]
     123          if ((result = [proto_list->list[j]
    120124                         descriptionForClassMethod: aSel]))
    121125            return result;
  • branches/GNU/src/gcc/libobjc/aclocal.m4

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    5555# canonicalize only relative paths, because then amd will not unmount
    5656# drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
    57 glibcpp_builddir=`pwd`
     57glibcpp_builddir=`${PWDCMD-pwd}`
    5858case $srcdir in
    5959[\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;;
  • branches/GNU/src/gcc/libobjc/archive.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* GNU Objective C Runtime archiving
    2    Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
     1 /* GNU Objective C Runtime archiving
     2   Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
    33   Contributed by Kresten Krab Thorup
    44
     
    2929#include "typedstream.h"
    3030#include "encoding.h"
    31 
    32 #ifdef HAVE_STDLIB_H
    3331#include <stdlib.h>
    34 #endif
    35 
    36 extern int fflush(FILE*);
     32
     33extern int fflush (FILE *);
    3734
    3835#define ROUND(V, A) \
    39   ({ typeof(V) __v=(V); typeof(A) __a=(A);  \
    40      __a*((__v+__a-1)/__a); })
    41 
    42 #define PTR2LONG(P) (((char*)(P))-(char*)0)
    43 #define LONG2PTR(L) (((char*)0)+(L))
     36  ({ typeof (V) __v = (V); typeof (A) __a = (A);  \
     37     __a * ((__v + __a - 1)/__a); })
     38
     39#define PTR2LONG(P) (((char *) (P))-(char *) 0)
     40#define LONG2PTR(L) (((char *) 0) + (L))
    4441
    4542/* Declare some functions... */
    4643
    4744static int
    48 objc_read_class (struct objc_typed_stream* stream, Class* class);
    49 
    50 int objc_sizeof_type(const char* type);
     45objc_read_class (struct objc_typed_stream *stream, Class *class);
     46
     47int objc_sizeof_type (const char *type);
    5148
    5249static int
    53 objc_write_use_common (struct objc_typed_stream* stream, unsigned long key);
     50objc_write_use_common (struct objc_typed_stream *stream, unsigned long key);
    5451
    5552static int
    56 objc_write_register_common (struct objc_typed_stream* stream,
     53objc_write_register_common (struct objc_typed_stream *stream,
    5754                            unsigned long key);
    5855
    5956static int
    60 objc_write_class (struct objc_typed_stream* stream,
    61                          struct objc_class* class);
    62 
    63 const char* objc_skip_type (const char* type);
    64 
    65 static void __objc_finish_write_root_object(struct objc_typed_stream*);
    66 static void __objc_finish_read_root_object(struct objc_typed_stream*);
     57objc_write_class (struct objc_typed_stream *stream,
     58                         struct objc_class *class);
     59
     60const char *objc_skip_type (const char *type);
     61
     62static void __objc_finish_write_root_object (struct objc_typed_stream *);
     63static void __objc_finish_read_root_object (struct objc_typed_stream *);
    6764
    6865static __inline__ int
    69 __objc_code_unsigned_char (unsigned char* buf, unsigned char val)
     66__objc_code_unsigned_char (unsigned char *buf, unsigned char val)
    7067{
    7168  if ((val&_B_VALUE) == val)
     
    8380
    8481int
    85 objc_write_unsigned_char (struct objc_typed_stream* stream,
     82objc_write_unsigned_char (struct objc_typed_stream *stream,
    8683                          unsigned char value)
    8784{
    88   unsigned char buf[sizeof (unsigned char)+1];
     85  unsigned char buf[sizeof (unsigned char) + 1];
    8986  int len = __objc_code_unsigned_char (buf, value);
    90   return (*stream->write)(stream->physical, buf, len);
     87  return (*stream->write) (stream->physical, buf, len);
    9188}
    9289
    9390static __inline__ int
    94 __objc_code_char (unsigned char* buf, signed char val)
     91__objc_code_char (unsigned char *buf, signed char val)
    9592{
    9693  if (val >= 0)
     
    105102
    106103int
    107 objc_write_char (struct objc_typed_stream* stream, signed char value)
    108 {
    109   unsigned char buf[sizeof (char)+1];
     104objc_write_char (struct objc_typed_stream *stream, signed char value)
     105{
     106  unsigned char buf[sizeof (char) + 1];
    110107  int len = __objc_code_char (buf, value);
    111   return (*stream->write)(stream->physical, buf, len);
     108  return (*stream->write) (stream->physical, buf, len);
    112109}
    113110
    114111static __inline__ int
    115 __objc_code_unsigned_short (unsigned char* buf, unsigned short val)
     112__objc_code_unsigned_short (unsigned char *buf, unsigned short val)
    116113{
    117114  if ((val&_B_VALUE) == val)
     
    126123      buf[0] = _B_NINT;
    127124
    128       for (c= sizeof(short); c != 0; c -= 1)
    129         if (((val>>(8*(c-1)))%0x100) != 0)
     125      for (c = sizeof (short); c != 0; c -= 1)
     126        if (((val >> (8*(c - 1)))%0x100) != 0)
    130127          break;
    131128
     
    134131      for (b = 1; c != 0; c--, b++)
    135132        {
    136           buf[b] = (val >> (8*(c-1)))%0x100;
     133          buf[b] = (val >> (8*(c - 1)))%0x100;
    137134        }
    138135
     
    142139
    143140int
    144 objc_write_unsigned_short (struct objc_typed_stream* stream,
     141objc_write_unsigned_short (struct objc_typed_stream *stream,
    145142                           unsigned short value)
    146143{
    147   unsigned char buf[sizeof (unsigned short)+1];
     144  unsigned char buf[sizeof (unsigned short) + 1];
    148145  int len = __objc_code_unsigned_short (buf, value);
    149   return (*stream->write)(stream->physical, buf, len);
     146  return (*stream->write) (stream->physical, buf, len);
    150147}
    151148     
    152149static __inline__ int
    153 __objc_code_short (unsigned char* buf, short val)
     150__objc_code_short (unsigned char *buf, short val)
    154151{
    155152  int sign = (val < 0);
     
    161158
    162159int
    163 objc_write_short (struct objc_typed_stream* stream, short value)
    164 {
    165   unsigned char buf[sizeof (short)+1];
     160objc_write_short (struct objc_typed_stream *stream, short value)
     161{
     162  unsigned char buf[sizeof (short) + 1];
    166163  int len = __objc_code_short (buf, value);
    167   return (*stream->write)(stream->physical, buf, len);
     164  return (*stream->write) (stream->physical, buf, len);
    168165}
    169166     
    170167
    171168static __inline__ int
    172 __objc_code_unsigned_int (unsigned char* buf, unsigned int val)
     169__objc_code_unsigned_int (unsigned char *buf, unsigned int val)
    173170{
    174171  if ((val&_B_VALUE) == val)
     
    183180      buf[0] = _B_NINT;
    184181
    185       for (c= sizeof(int); c != 0; c -= 1)
    186         if (((val>>(8*(c-1)))%0x100) != 0)
     182      for (c = sizeof (int); c != 0; c -= 1)
     183        if (((val >> (8*(c - 1)))%0x100) != 0)
    187184          break;
    188185
     
    199196
    200197int
    201 objc_write_unsigned_int (struct objc_typed_stream* stream, unsigned int value)
    202 {
    203   unsigned char buf[sizeof(unsigned int)+1];
     198objc_write_unsigned_int (struct objc_typed_stream *stream, unsigned int value)
     199{
     200  unsigned char buf[sizeof (unsigned int) + 1];
    204201  int len = __objc_code_unsigned_int (buf, value);
    205   return (*stream->write)(stream->physical, buf, len);
     202  return (*stream->write) (stream->physical, buf, len);
    206203}
    207204
    208205static __inline__ int
    209 __objc_code_int (unsigned char* buf, int val)
     206__objc_code_int (unsigned char *buf, int val)
    210207{
    211208  int sign = (val < 0);
     
    217214
    218215int
    219 objc_write_int (struct objc_typed_stream* stream, int value)
    220 {
    221   unsigned char buf[sizeof(int)+1];
     216objc_write_int (struct objc_typed_stream *stream, int value)
     217{
     218  unsigned char buf[sizeof (int) + 1];
    222219  int len = __objc_code_int (buf, value);
    223   return (*stream->write)(stream->physical, buf, len);
     220  return (*stream->write) (stream->physical, buf, len);
    224221}
    225222
    226223static __inline__ int
    227 __objc_code_unsigned_long (unsigned char* buf, unsigned long val)
     224__objc_code_unsigned_long (unsigned char *buf, unsigned long val)
    228225{
    229226  if ((val&_B_VALUE) == val)
     
    238235      buf[0] = _B_NINT;
    239236
    240       for (c= sizeof(long); c != 0; c -= 1)
    241         if (((val>>(8*(c-1)))%0x100) != 0)
     237      for (c = sizeof (long); c != 0; c -= 1)
     238        if (((val >> (8*(c - 1)))%0x100) != 0)
    242239          break;
    243240
     
    246243      for (b = 1; c != 0; c--, b++)
    247244        {
    248           buf[b] = (val >> (8*(c-1)))%0x100;
     245          buf[b] = (val >> (8*(c - 1)))%0x100;
    249246        }
    250247
     
    254251
    255252int
    256 objc_write_unsigned_long (struct objc_typed_stream* stream,
     253objc_write_unsigned_long (struct objc_typed_stream *stream,
    257254                          unsigned long value)
    258255{
    259   unsigned char buf[sizeof(unsigned long)+1];
     256  unsigned char buf[sizeof (unsigned long) + 1];
    260257  int len = __objc_code_unsigned_long (buf, value);
    261   return (*stream->write)(stream->physical, buf, len);
     258  return (*stream->write) (stream->physical, buf, len);
    262259}
    263260
    264261static __inline__ int
    265 __objc_code_long (unsigned char* buf, long val)
     262__objc_code_long (unsigned char *buf, long val)
    266263{
    267264  int sign = (val < 0);
     
    273270
    274271int
    275 objc_write_long (struct objc_typed_stream* stream, long value)
    276 {
    277   unsigned char buf[sizeof(long)+1];
     272objc_write_long (struct objc_typed_stream *stream, long value)
     273{
     274  unsigned char buf[sizeof (long) + 1];
    278275  int len = __objc_code_long (buf, value);
    279   return (*stream->write)(stream->physical, buf, len);
     276  return (*stream->write) (stream->physical, buf, len);
    280277}
    281278
    282279
    283280int
    284 objc_write_string (struct objc_typed_stream* stream,
    285                    const unsigned char* string, unsigned int nbytes)
    286 {
    287   unsigned char buf[sizeof(unsigned int)+1];
     281objc_write_string (struct objc_typed_stream *stream,
     282                   const unsigned char *string, unsigned int nbytes)
     283{
     284  unsigned char buf[sizeof (unsigned int) + 1];
    288285  int len = __objc_code_unsigned_int (buf, nbytes);
    289286 
     
    294291    buf[0] = (buf[0]&_B_VALUE)|_B_NSTR;
    295292
    296   if ((*stream->write)(stream->physical, buf, len) != 0)
    297     return (*stream->write)(stream->physical, string, nbytes);
     293  if ((*stream->write) (stream->physical, buf, len) != 0)
     294    return (*stream->write) (stream->physical, string, nbytes);
    298295  else
    299296    return 0;
     
    301298
    302299int
    303 objc_write_string_atomic (struct objc_typed_stream* stream,
    304                           unsigned char* string, unsigned int nbytes)
     300objc_write_string_atomic (struct objc_typed_stream *stream,
     301                          unsigned char *string, unsigned int nbytes)
    305302{
    306303  unsigned long key;
     
    318315
    319316static int
    320 objc_write_register_common (struct objc_typed_stream* stream,
     317objc_write_register_common (struct objc_typed_stream *stream,
    321318                            unsigned long key)
    322319{
    323320  unsigned char buf[sizeof (unsigned long)+2];
    324   int len = __objc_code_unsigned_long (buf+1, key);
     321  int len = __objc_code_unsigned_long (buf + 1, key);
    325322  if (len == 1)
    326323    {
    327324      buf[0] = _B_RCOMM|0x01;
    328325      buf[1] &= _B_VALUE;
    329       return (*stream->write)(stream->physical, buf, len+1);
     326      return (*stream->write) (stream->physical, buf, len + 1);
    330327    }
    331328  else
    332329    {
    333330      buf[1] = (buf[1]&_B_VALUE)|_B_RCOMM;
    334       return (*stream->write)(stream->physical, buf+1, len);
     331      return (*stream->write) (stream->physical, buf + 1, len);
    335332    }
    336333}
    337334
    338335static int
    339 objc_write_use_common (struct objc_typed_stream* stream, unsigned long key)
     336objc_write_use_common (struct objc_typed_stream *stream, unsigned long key)
    340337{
    341338  unsigned char buf[sizeof (unsigned long)+2];
    342   int len = __objc_code_unsigned_long (buf+1, key);
     339  int len = __objc_code_unsigned_long (buf + 1, key);
    343340  if (len == 1)
    344341    {
    345342      buf[0] = _B_UCOMM|0x01;
    346343      buf[1] &= _B_VALUE;
    347       return (*stream->write)(stream->physical, buf, 2);
     344      return (*stream->write) (stream->physical, buf, 2);
    348345    }
    349346  else
    350347    {
    351348      buf[1] = (buf[1]&_B_VALUE)|_B_UCOMM;
    352       return (*stream->write)(stream->physical, buf+1, len);
     349      return (*stream->write) (stream->physical, buf + 1, len);
    353350    }
    354351}
    355352
    356353static __inline__ int
    357 __objc_write_extension (struct objc_typed_stream* stream, unsigned char code)
     354__objc_write_extension (struct objc_typed_stream *stream, unsigned char code)
    358355{
    359356  if (code <= _B_VALUE)
    360357    {
    361358      unsigned char buf = code|_B_EXT;
    362       return (*stream->write)(stream->physical, &buf, 1);
     359      return (*stream->write) (stream->physical, &buf, 1);
    363360    }
    364361  else
    365362    {
    366       objc_error(nil, OBJC_ERR_BAD_OPCODE,
    367                  "__objc_write_extension: bad opcode %c\n", code);
     363      objc_error (nil, OBJC_ERR_BAD_OPCODE,
     364                  "__objc_write_extension: bad opcode %c\n", code);
    368365      return -1;
    369366    }
     
    371368
    372369__inline__ int
    373 __objc_write_object (struct objc_typed_stream* stream, id object)
     370__objc_write_object (struct objc_typed_stream *stream, id object)
    374371{
    375372  unsigned char buf = '\0';
     
    379376      __objc_write_extension (stream, _BX_OBJECT);
    380377      objc_write_class (stream, object->class_pointer);
    381       (*objc_msg_lookup(object, write_sel))(object, write_sel, stream);
    382       return (*stream->write)(stream->physical, &buf, 1);
     378      (*objc_msg_lookup (object, write_sel)) (object, write_sel, stream);
     379      return (*stream->write) (stream->physical, &buf, 1);
    383380    }
    384381  else
    385     return objc_write_use_common(stream, 0);
     382    return objc_write_use_common (stream, 0);
    386383}
    387384
    388385int
    389 objc_write_object_reference (struct objc_typed_stream* stream, id object)
     386objc_write_object_reference (struct objc_typed_stream *stream, id object)
    390387{
    391388  unsigned long key;
     
    398395
    399396int
    400 objc_write_root_object (struct objc_typed_stream* stream, id object)
     397objc_write_root_object (struct objc_typed_stream *stream, id object)
    401398{
    402399  int len = 0;
     
    408405      stream->writing_root_p = 1;
    409406      __objc_write_extension (stream, _BX_OBJROOT);
    410       if((len = objc_write_object (stream, object)))
    411         __objc_finish_write_root_object(stream);
     407      if ((len = objc_write_object (stream, object)))
     408        __objc_finish_write_root_object (stream);
    412409      stream->writing_root_p = 0;
    413410    }
     
    416413
    417414int
    418 objc_write_object (struct objc_typed_stream* stream, id object)
     415objc_write_object (struct objc_typed_stream *stream, id object)
    419416{
    420417  unsigned long key;
     
    423420
    424421  else if (object == nil)
    425     return objc_write_use_common(stream, 0);
     422    return objc_write_use_common (stream, 0);
    426423
    427424  else
     
    436433
    437434__inline__ int
    438 __objc_write_class (struct objc_typed_stream* stream, struct objc_class* class)
     435__objc_write_class (struct objc_typed_stream *stream, struct objc_class *class)
    439436{
    440437  __objc_write_extension (stream, _BX_CLASS);
    441   objc_write_string_atomic(stream, (char*)class->name,
    442                            strlen((char*)class->name));
     438  objc_write_string_atomic (stream, (char *) class->name,
     439                           strlen ((char *) class->name));
    443440  return objc_write_unsigned_long (stream, class->version);
    444441}
     
    446443
    447444static int
    448 objc_write_class (struct objc_typed_stream* stream,
    449                          struct objc_class* class)
     445objc_write_class (struct objc_typed_stream *stream,
     446                         struct objc_class *class)
    450447{
    451448  unsigned long key;
     
    455452    {
    456453      int length;
    457       hash_add (&stream->stream_table, LONG2PTR(key=PTR2LONG(class)), class);
     454      hash_add (&stream->stream_table, LONG2PTR(key = PTR2LONG(class)), class);
    458455      if ((length = objc_write_register_common (stream, key)))
    459456        return __objc_write_class (stream, class);
     
    464461
    465462__inline__ int
    466 __objc_write_selector (struct objc_typed_stream* stream, SEL selector)
    467 {
    468   const char* sel_name;
     463__objc_write_selector (struct objc_typed_stream *stream, SEL selector)
     464{
     465  const char *sel_name;
    469466  __objc_write_extension (stream, _BX_SEL);
    470467  /* to handle NULL selectors */
     
    476473
    477474int
    478 objc_write_selector (struct objc_typed_stream* stream, SEL selector)
    479 {
    480   const char* sel_name;
     475objc_write_selector (struct objc_typed_stream *stream, SEL selector)
     476{
     477  const char *sel_name;
    481478  unsigned long key;
    482479
     
    492489      int length;
    493490      hash_add (&stream->stream_table,
    494                 LONG2PTR(key=PTR2LONG(sel_name)), (char*)sel_name);
     491                LONG2PTR(key = PTR2LONG(sel_name)), (char *) sel_name);
    495492      if ((length = objc_write_register_common (stream, key)))
    496493        return __objc_write_selector (stream, selector);
     
    506503
    507504__inline__ int
    508 objc_read_char (struct objc_typed_stream* stream, char* val)
     505objc_read_char (struct objc_typed_stream *stream, char *val)
    509506{
    510507  unsigned char buf;
    511508  int len;
    512   len = (*stream->read)(stream->physical, &buf, 1);
     509  len = (*stream->read) (stream->physical, &buf, 1);
    513510  if (len != 0)
    514511    {
     
    518515      else if ((buf & _B_NUMBER) == 1)
    519516        {
    520           len = (*stream->read)(stream->physical, val, 1);
     517          len = (*stream->read) (stream->physical, val, 1);
    521518          if (buf&_B_SIGN)
    522             (*val) = -1*(*val);
     519            (*val) = -1 * (*val);
    523520        }
    524521
    525522      else
    526         objc_error(nil, OBJC_ERR_BAD_DATA,
    527                    "expected 8bit signed int, got %dbit int",
    528                    (int)(buf&_B_NUMBER)*8);
     523        objc_error (nil, OBJC_ERR_BAD_DATA,
     524                    "expected 8bit signed int, got %dbit int",
     525                    (int) (buf&_B_NUMBER)*8);
    529526    }
    530527  return len;
     
    533530
    534531__inline__ int
    535 objc_read_unsigned_char (struct objc_typed_stream* stream, unsigned char* val)
     532objc_read_unsigned_char (struct objc_typed_stream *stream, unsigned char *val)
    536533{
    537534  unsigned char buf;
    538535  int len;
    539   if ((len = (*stream->read)(stream->physical, &buf, 1)))
     536  if ((len = (*stream->read) (stream->physical, &buf, 1)))
    540537    {
    541538      if ((buf & _B_CODE) == _B_SINT)
     
    543540
    544541      else if ((buf & _B_NUMBER) == 1)
    545         len = (*stream->read)(stream->physical, val, 1);
     542        len = (*stream->read) (stream->physical, val, 1);
    546543
    547544      else
    548         objc_error(nil, OBJC_ERR_BAD_DATA,
    549                    "expected 8bit unsigned int, got %dbit int",
    550                    (int)(buf&_B_NUMBER)*8);
     545        objc_error (nil, OBJC_ERR_BAD_DATA,
     546                    "expected 8bit unsigned int, got %dbit int",
     547                    (int) (buf&_B_NUMBER)*8);
    551548    }
    552549  return len;
     
    554551
    555552__inline__ int
    556 objc_read_short (struct objc_typed_stream* stream, short* value)
    557 {
    558   unsigned char buf[sizeof(short)+1];
     553objc_read_short (struct objc_typed_stream *stream, short *value)
     554{
     555  unsigned char buf[sizeof (short) + 1];
    559556  int len;
    560   if ((len = (*stream->read)(stream->physical, buf, 1)))
     557  if ((len = (*stream->read) (stream->physical, buf, 1)))
    561558    {
    562559      if ((buf[0] & _B_CODE) == _B_SINT)
     
    567564          int pos = 1;
    568565          int nbytes = buf[0] & _B_NUMBER;
    569           if (nbytes > sizeof (short))
    570             objc_error(nil, OBJC_ERR_BAD_DATA,
    571                        "expected short, got bigger (%dbits)", nbytes*8);
    572           len = (*stream->read)(stream->physical, buf+1, nbytes);
     566          if (nbytes > (int) sizeof (short))
     567            objc_error (nil, OBJC_ERR_BAD_DATA,
     568                        "expected short, got bigger (%dbits)", nbytes*8);
     569          len = (*stream->read) (stream->physical, buf + 1, nbytes);
    573570          (*value) = 0;
    574571          while (pos <= nbytes)
     
    582579
    583580__inline__ int
    584 objc_read_unsigned_short (struct objc_typed_stream* stream,
    585                           unsigned short* value)
    586 {
    587   unsigned char buf[sizeof(unsigned short)+1];
     581objc_read_unsigned_short (struct objc_typed_stream *stream,
     582                          unsigned short *value)
     583{
     584  unsigned char buf[sizeof (unsigned short) + 1];
    588585  int len;
    589   if ((len = (*stream->read)(stream->physical, buf, 1)))
     586  if ((len = (*stream->read) (stream->physical, buf, 1)))
    590587    {
    591588      if ((buf[0] & _B_CODE) == _B_SINT)
     
    596593          int pos = 1;
    597594          int nbytes = buf[0] & _B_NUMBER;
    598           if (nbytes > sizeof (short))
    599             objc_error(nil, OBJC_ERR_BAD_DATA,
    600                        "expected short, got int or bigger");
    601           len = (*stream->read)(stream->physical, buf+1, nbytes);
     595          if (nbytes > (int) sizeof (short))
     596            objc_error (nil, OBJC_ERR_BAD_DATA,
     597                        "expected short, got int or bigger");
     598          len = (*stream->read) (stream->physical, buf + 1, nbytes);
    602599          (*value) = 0;
    603600          while (pos <= nbytes)
     
    610607
    611608__inline__ int
    612 objc_read_int (struct objc_typed_stream* stream, int* value)
    613 {
    614   unsigned char buf[sizeof(int)+1];
     609objc_read_int (struct objc_typed_stream *stream, int *value)
     610{
     611  unsigned char buf[sizeof (int) + 1];
    615612  int len;
    616   if ((len = (*stream->read)(stream->physical, buf, 1)))
     613  if ((len = (*stream->read) (stream->physical, buf, 1)))
    617614    {
    618615      if ((buf[0] & _B_CODE) == _B_SINT)
     
    623620          int pos = 1;
    624621          int nbytes = buf[0] & _B_NUMBER;
    625           if (nbytes > sizeof (int))
    626             objc_error(nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
    627           len = (*stream->read)(stream->physical, buf+1, nbytes);
     622          if (nbytes > (int) sizeof (int))
     623            objc_error (nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
     624          len = (*stream->read) (stream->physical, buf + 1, nbytes);
    628625          (*value) = 0;
    629626          while (pos <= nbytes)
     
    637634
    638635__inline__ int
    639 objc_read_long (struct objc_typed_stream* stream, long* value)
    640 {
    641   unsigned char buf[sizeof(long)+1];
     636objc_read_long (struct objc_typed_stream *stream, long *value)
     637{
     638  unsigned char buf[sizeof (long) + 1];
    642639  int len;
    643   if ((len = (*stream->read)(stream->physical, buf, 1)))
     640  if ((len = (*stream->read) (stream->physical, buf, 1)))
    644641    {
    645642      if ((buf[0] & _B_CODE) == _B_SINT)
     
    650647          int pos = 1;
    651648          int nbytes = buf[0] & _B_NUMBER;
    652           if (nbytes > sizeof (long))
    653             objc_error(nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
    654           len = (*stream->read)(stream->physical, buf+1, nbytes);
     649          if (nbytes > (int) sizeof (long))
     650            objc_error (nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
     651          len = (*stream->read) (stream->physical, buf + 1, nbytes);
    655652          (*value) = 0;
    656653          while (pos <= nbytes)
     
    664661
    665662__inline__ int
    666 __objc_read_nbyte_uint (struct objc_typed_stream* stream,
    667                        unsigned int nbytes, unsigned int* val)
    668 {
    669   int len, pos = 0;
    670   unsigned char buf[sizeof(unsigned int)+1];
     663__objc_read_nbyte_uint (struct objc_typed_stream *stream,
     664                        unsigned int nbytes, unsigned int *val)
     665{
     666  int len;
     667  unsigned int pos = 0;
     668  unsigned char buf[sizeof (unsigned int) + 1];
    671669
    672670  if (nbytes > sizeof (int))
    673     objc_error(nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
    674 
    675   len = (*stream->read)(stream->physical, buf, nbytes);
     671    objc_error (nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
     672
     673  len = (*stream->read) (stream->physical, buf, nbytes);
    676674  (*val) = 0;
    677675  while (pos < nbytes)
     
    682680
    683681__inline__ int
    684 objc_read_unsigned_int (struct objc_typed_stream* stream,
    685                         unsigned int* value)
    686 {
    687   unsigned char buf[sizeof(unsigned int)+1];
     682objc_read_unsigned_int (struct objc_typed_stream *stream,
     683                        unsigned int *value)
     684{
     685  unsigned char buf[sizeof (unsigned int) + 1];
    688686  int len;
    689   if ((len = (*stream->read)(stream->physical, buf, 1)))
     687  if ((len = (*stream->read) (stream->physical, buf, 1)))
    690688    {
    691689      if ((buf[0] & _B_CODE) == _B_SINT)
     
    700698
    701699int
    702 __objc_read_nbyte_ulong (struct objc_typed_stream* stream,
    703                        unsigned int nbytes, unsigned long* val)
    704 {
    705   int len, pos = 0;
    706   unsigned char buf[sizeof(unsigned long)+1];
     700__objc_read_nbyte_ulong (struct objc_typed_stream *stream,
     701                       unsigned int nbytes, unsigned long *val)
     702{
     703  int len;
     704  unsigned int pos = 0;
     705  unsigned char buf[sizeof (unsigned long) + 1];
    707706
    708707  if (nbytes > sizeof (long))
    709     objc_error(nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
    710 
    711   len = (*stream->read)(stream->physical, buf, nbytes);
     708    objc_error (nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
     709
     710  len = (*stream->read) (stream->physical, buf, nbytes);
    712711  (*val) = 0;
    713712  while (pos < nbytes)
     
    718717
    719718__inline__ int
    720 objc_read_unsigned_long (struct objc_typed_stream* stream,
    721                         unsigned long* value)
    722 {
    723   unsigned char buf[sizeof(unsigned long)+1];
     719objc_read_unsigned_long (struct objc_typed_stream *stream,
     720                         unsigned long *value)
     721{
     722  unsigned char buf[sizeof (unsigned long) + 1];
    724723  int len;
    725   if ((len = (*stream->read)(stream->physical, buf, 1)))
     724  if ((len = (*stream->read) (stream->physical, buf, 1)))
    726725    {
    727726      if ((buf[0] & _B_CODE) == _B_SINT)
     
    736735
    737736__inline__ int
    738 objc_read_string (struct objc_typed_stream* stream,
    739                   char** string)
    740 {
    741   unsigned char buf[sizeof(unsigned int)+1];
     737objc_read_string (struct objc_typed_stream *stream,
     738                  char **string)
     739{
     740  unsigned char buf[sizeof (unsigned int) + 1];
    742741  int len;
    743   if ((len = (*stream->read)(stream->physical, buf, 1)))
     742  if ((len = (*stream->read) (stream->physical, buf, 1)))
    744743    {
    745744      unsigned long key = 0;
     
    747746      if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */
    748747        {
    749           len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
    750           len = (*stream->read)(stream->physical, buf, 1);
     748          len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
     749          len = (*stream->read) (stream->physical, buf, 1);
    751750        }
    752751
     
    755754        {
    756755          int length = buf[0]&_B_VALUE;
    757           (*string) = (char*)objc_malloc(length+1);
     756          (*string) = (char*)objc_malloc (length + 1);
    758757          if (key)
    759758            hash_add (&stream->stream_table, LONG2PTR(key), *string);
    760           len = (*stream->read)(stream->physical, *string, length);
     759          len = (*stream->read) (stream->physical, *string, length);
    761760          (*string)[length] = '\0';
    762761        }
     
    766765        {
    767766          char *tmp;
    768           len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
     767          len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
    769768          tmp = hash_value_for_key (stream->stream_table, LONG2PTR (key));
    770           *string = objc_malloc (strlen(tmp) + 1);
     769          *string = objc_malloc (strlen (tmp) + 1);
    771770          strcpy (*string, tmp);
    772771        }
     
    776775        {
    777776          unsigned int nbytes = buf[0]&_B_VALUE;
    778           len = __objc_read_nbyte_uint(stream, nbytes, &nbytes);
     777          len = __objc_read_nbyte_uint (stream, nbytes, &nbytes);
    779778          if (len) {
    780             (*string) = (char*)objc_malloc(nbytes+1);
     779            (*string) = (char*)objc_malloc (nbytes + 1);
    781780            if (key)
    782781              hash_add (&stream->stream_table, LONG2PTR(key), *string);
    783             len = (*stream->read)(stream->physical, *string, nbytes);
     782            len = (*stream->read) (stream->physical, *string, nbytes);
    784783            (*string)[nbytes] = '\0';
    785784          }
     
    788787       
    789788      default:
    790         objc_error(nil, OBJC_ERR_BAD_DATA,
    791                    "expected string, got opcode %c\n", (buf[0]&_B_CODE));
     789        objc_error (nil, OBJC_ERR_BAD_DATA,
     790                    "expected string, got opcode %c\n", (buf[0]&_B_CODE));
    792791      }
    793792    }
     
    798797
    799798int
    800 objc_read_object (struct objc_typed_stream* stream, id* object)
     799objc_read_object (struct objc_typed_stream *stream, id *object)
    801800{
    802801  unsigned char buf[sizeof (unsigned int)];
    803802  int len;
    804   if ((len = (*stream->read)(stream->physical, buf, 1)))
     803  if ((len = (*stream->read) (stream->physical, buf, 1)))
    805804    {
    806805      SEL read_sel = sel_get_any_uid ("read:");
     
    809808      if ((buf[0]&_B_CODE) == _B_RCOMM) /* register common */
    810809        {
    811           len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
    812           len = (*stream->read)(stream->physical, buf, 1);
     810          len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
     811          len = (*stream->read) (stream->physical, buf, 1);
    813812        }
    814813
     
    821820
    822821          /* create instance */
    823           (*object) = class_create_instance(class);
     822          (*object) = class_create_instance (class);
    824823
    825824          /* register? */
     
    829828          /* send -read: */
    830829          if (__objc_responds_to (*object, read_sel))
    831             (*get_imp(class, read_sel))(*object, read_sel, stream);
     830            (*get_imp (class, read_sel)) (*object, read_sel, stream);
    832831
    833832          /* check null-byte */
    834           len = (*stream->read)(stream->physical, buf, 1);
     833          len = (*stream->read) (stream->physical, buf, 1);
    835834          if (buf[0] != '\0')
    836             objc_error(nil, OBJC_ERR_BAD_DATA,
    837                        "expected null-byte, got opcode %c", buf[0]);
     835            objc_error (nil, OBJC_ERR_BAD_DATA,
     836                        "expected null-byte, got opcode %c", buf[0]);
    838837        }
    839838
     
    841840        {
    842841          if (key)
    843             objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
    844           len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
     842            objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
     843          len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
    845844          (*object) = hash_value_for_key (stream->object_table, LONG2PTR(key));
    846845        }
     
    848847      else if (buf[0] == (_B_EXT | _BX_OBJREF)) /* a forward reference */
    849848        {
    850           struct objc_list* other;
     849          struct objc_list *other;
    851850          len = objc_read_unsigned_long (stream, &key);
    852           other = (struct objc_list*)hash_value_for_key (stream->object_refs,
    853                                                          LONG2PTR(key));
     851          other = (struct objc_list *) hash_value_for_key (stream->object_refs,
     852                                                           LONG2PTR(key));
    854853          hash_add (&stream->object_refs, LONG2PTR(key),
    855                     (void*)list_cons(object, other));
     854                    (void *)list_cons (object, other));
    856855        }
    857856
     
    859858        {
    860859          if (key)
    861             objc_error(nil, OBJC_ERR_BAD_KEY,
    862                        "cannot register root object...");
     860            objc_error (nil, OBJC_ERR_BAD_KEY,
     861                        "cannot register root object...");
    863862          len = objc_read_object (stream, object);
    864863          __objc_finish_read_root_object (stream);
     
    866865
    867866      else
    868         objc_error(nil, OBJC_ERR_BAD_DATA,
    869                    "expected object, got opcode %c", buf[0]);
     867        objc_error (nil, OBJC_ERR_BAD_DATA,
     868                    "expected object, got opcode %c", buf[0]);
    870869    }
    871870  return len;
     
    873872
    874873static int
    875 objc_read_class (struct objc_typed_stream* stream, Class* class)
     874objc_read_class (struct objc_typed_stream *stream, Class *class)
    876875{
    877876  unsigned char buf[sizeof (unsigned int)];
    878877  int len;
    879   if ((len = (*stream->read)(stream->physical, buf, 1)))
     878  if ((len = (*stream->read) (stream->physical, buf, 1)))
    880879    {
    881880      unsigned long key = 0;
     
    883882      if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */
    884883        {
    885           len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
    886           len = (*stream->read)(stream->physical, buf, 1);
     884          len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
     885          len = (*stream->read) (stream->physical, buf, 1);
    887886        }
    888887
    889888      if (buf[0] == (_B_EXT | _BX_CLASS))
    890889        {
    891           char* class_name;
     890          char *class_name;
    892891          unsigned long version;
    893892
    894893          /* get class */
    895894          len = objc_read_string (stream, &class_name);
    896           (*class) = objc_get_class(class_name);
    897           objc_free(class_name);
     895          (*class) = objc_get_class (class_name);
     896          objc_free (class_name);
    898897
    899898          /* register */
     
    901900            hash_add (&stream->stream_table, LONG2PTR(key), *class);
    902901
    903           objc_read_unsigned_long(stream, &version);
    904           hash_add (&stream->class_table, (*class)->name, (void*)version);
     902          objc_read_unsigned_long (stream, &version);
     903          hash_add (&stream->class_table, (*class)->name, (void *)version);
    905904        }
    906905
     
    908907        {
    909908          if (key)
    910             objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
    911           len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
    912           (*class) = hash_value_for_key (stream->stream_table, LONG2PTR(key));
    913           if (!*class)
    914             objc_error(nil, OBJC_ERR_BAD_CLASS,
    915                        "cannot find class for key %lu", key);
     909            objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
     910          len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
     911          *class = hash_value_for_key (stream->stream_table, LONG2PTR(key));
     912          if (! *class)
     913            objc_error (nil, OBJC_ERR_BAD_CLASS,
     914                        "cannot find class for key %lu", key);
    916915        }
    917916
    918917      else
    919         objc_error(nil, OBJC_ERR_BAD_DATA,
    920                    "expected class, got opcode %c", buf[0]);
     918        objc_error (nil, OBJC_ERR_BAD_DATA,
     919                    "expected class, got opcode %c", buf[0]);
    921920    }
    922921  return len;
     
    924923
    925924int
    926 objc_read_selector (struct objc_typed_stream* stream, SEL* selector)
     925objc_read_selector (struct objc_typed_stream *stream, SEL* selector)
    927926{
    928927  unsigned char buf[sizeof (unsigned int)];
    929928  int len;
    930   if ((len = (*stream->read)(stream->physical, buf, 1)))
     929  if ((len = (*stream->read) (stream->physical, buf, 1)))
    931930    {
    932931      unsigned long key = 0;
     
    934933      if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */
    935934        {
    936           len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
    937           len = (*stream->read)(stream->physical, buf, 1);
     935          len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
     936          len = (*stream->read) (stream->physical, buf, 1);
    938937        }
    939938
    940939      if (buf[0] == (_B_EXT|_BX_SEL)) /* selector! */
    941940        {
    942           char* selector_name;
     941          char *selector_name;
    943942
    944943          /* get selector */
    945944          len = objc_read_string (stream, &selector_name);
    946945          /* To handle NULL selectors */
    947           if (0 == strlen(selector_name))
     946          if (0 == strlen (selector_name))
    948947            {
    949948              (*selector) = (SEL)0;
     
    951950            }
    952951          else
    953             (*selector) = sel_get_any_uid(selector_name);
    954           objc_free(selector_name);
     952            (*selector) = sel_get_any_uid (selector_name);
     953          objc_free (selector_name);
    955954
    956955          /* register */
    957956          if (key)
    958             hash_add (&stream->stream_table, LONG2PTR(key), (void*)*selector);
     957            hash_add (&stream->stream_table, LONG2PTR(key), (void *) *selector);
    959958        }
    960959
     
    962961        {
    963962          if (key)
    964             objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
    965           len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
     963            objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
     964          len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
    966965          (*selector) = hash_value_for_key (stream->stream_table,
    967966                                            LONG2PTR(key));
     
    969968
    970969      else
    971         objc_error(nil, OBJC_ERR_BAD_DATA,
    972                    "expected selector, got opcode %c", buf[0]);
     970        objc_error (nil, OBJC_ERR_BAD_DATA,
     971                    "expected selector, got opcode %c", buf[0]);
    973972    }
    974973  return len;
     
    985984
    986985int
    987 objc_write_type(TypedStream* stream, const char* type, const void* data)
    988 {
    989   switch(*type) {
     986objc_write_type (TypedStream *stream, const char *type, const void *data)
     987{
     988  switch (*type) {
    990989  case _C_ID:
    991     return objc_write_object (stream, *(id*)data);
     990    return objc_write_object (stream, *(id *) data);
    992991    break;
    993992
    994993  case _C_CLASS:
    995     return objc_write_class (stream, *(Class*)data);
     994    return objc_write_class (stream, *(Class *) data);
    996995    break;
    997996
    998997  case _C_SEL:
    999     return objc_write_selector (stream, *(SEL*)data);
     998    return objc_write_selector (stream, *(SEL *) data);
    1000999    break;
    10011000
    10021001  case _C_CHR:
    1003     return objc_write_char(stream, *(signed char*)data);
     1002    return objc_write_char (stream, *(signed char *) data);
    10041003    break;
    10051004   
    10061005  case _C_UCHR:
    1007     return objc_write_unsigned_char(stream, *(unsigned char*)data);
     1006    return objc_write_unsigned_char (stream, *(unsigned char *) data);
    10081007    break;
    10091008
    10101009  case _C_SHT:
    1011     return objc_write_short(stream, *(short*)data);
     1010    return objc_write_short (stream, *(short *) data);
    10121011    break;
    10131012
    10141013  case _C_USHT:
    1015     return objc_write_unsigned_short(stream, *(unsigned short*)data);
     1014    return objc_write_unsigned_short (stream, *(unsigned short *) data);
    10161015    break;
    10171016
    10181017  case _C_INT:
    1019     return objc_write_int(stream, *(int*)data);
     1018    return objc_write_int (stream, *(int *) data);
    10201019    break;
    10211020
    10221021  case _C_UINT:
    1023     return objc_write_unsigned_int(stream, *(unsigned int*)data);
     1022    return objc_write_unsigned_int (stream, *(unsigned int *) data);
    10241023    break;
    10251024
    10261025  case _C_LNG:
    1027     return objc_write_long(stream, *(long*)data);
     1026    return objc_write_long (stream, *(long *) data);
    10281027    break;
    10291028
    10301029  case _C_ULNG:
    1031     return objc_write_unsigned_long(stream, *(unsigned long*)data);
     1030    return objc_write_unsigned_long (stream, *(unsigned long *) data);
    10321031    break;
    10331032
    10341033  case _C_CHARPTR:
    1035     return objc_write_string (stream, *(char**)data, strlen(*(char**)data));
     1034    return objc_write_string (stream,
     1035                              *(char **) data, strlen (*(char **) data));
    10361036    break;
    10371037
    10381038  case _C_ATOM:
    1039     return objc_write_string_atomic (stream, *(char**)data,
    1040                                      strlen(*(char**)data));
     1039    return objc_write_string_atomic (stream, *(char **) data,
     1040                                     strlen (*(char **) data));
    10411041    break;
    10421042
    10431043  case _C_ARY_B:
    10441044    {
    1045       int len = atoi(type+1);
    1046       while (isdigit(*++type))
     1045      int len = atoi (type + 1);
     1046      while (isdigit ((unsigned char) *++type))
    10471047        ;
    10481048      return objc_write_array (stream, type, len, data);
     
    10601060          align = objc_alignof_type (type);       /* padd to alignment */
    10611061          acc_size += ROUND (acc_size, align);
    1062           objc_write_type (stream, type, ((char*)data)+acc_size);
     1062          objc_write_type (stream, type, ((char *) data) + acc_size);
    10631063          acc_size += objc_sizeof_type (type);   /* add component size */
    10641064          type = objc_skip_typespec (type);      /* skip component */
     
    10691069  default:
    10701070    {
    1071       objc_error(nil, OBJC_ERR_BAD_TYPE,
    1072                  "objc_write_type: cannot parse typespec: %s\n", type);
     1071      objc_error (nil, OBJC_ERR_BAD_TYPE,
     1072                  "objc_write_type: cannot parse typespec: %s\n", type);
    10731073      return 0;
    10741074    }
     
    10841084
    10851085int
    1086 objc_read_type(TypedStream* stream, const char* type, void* data)
     1086objc_read_type(TypedStream *stream, const char *type, void *data)
    10871087{
    10881088  char c;
    1089   switch(c = *type) {
     1089  switch (c = *type) {
    10901090  case _C_ID:
    10911091    return objc_read_object (stream, (id*)data);
     
    11391139  case _C_ARY_B:
    11401140    {
    1141       int len = atoi(type+1);
    1142       while (isdigit(*++type))
     1141      int len = atoi (type + 1);
     1142      while (isdigit ((unsigned char) *++type))
    11431143        ;
    11441144      return objc_read_array (stream, type, len, data);
     
    11651165  default:
    11661166    {
    1167       objc_error(nil, OBJC_ERR_BAD_TYPE,
    1168                  "objc_read_type: cannot parse typespec: %s\n", type);
     1167      objc_error (nil, OBJC_ERR_BAD_TYPE,
     1168                  "objc_read_type: cannot parse typespec: %s\n", type);
    11691169      return 0;
    11701170    }
     
    11831183
    11841184int
    1185 objc_write_types (TypedStream* stream, const char* type, ...)
     1185objc_write_types (TypedStream *stream, const char *type, ...)
    11861186{
    11871187  va_list args;
     
    11931193  for (c = type; *c; c = objc_skip_typespec (c))
    11941194    {
    1195       switch(*c) {
     1195      switch (*c) {
    11961196      case _C_ID:
    11971197        res = objc_write_object (stream, *va_arg (args, id*));
     
    11991199
    12001200      case _C_CLASS:
    1201         res = objc_write_class (stream, *va_arg(args, Class*));
     1201        res = objc_write_class (stream, *va_arg (args, Class*));
    12021202        break;
    12031203
    12041204      case _C_SEL:
    1205         res = objc_write_selector (stream, *va_arg(args, SEL*));
     1205        res = objc_write_selector (stream, *va_arg (args, SEL*));
    12061206        break;
    12071207       
     
    12161216       
    12171217      case _C_SHT:
    1218         res = objc_write_short (stream, *va_arg(args, short*));
     1218        res = objc_write_short (stream, *va_arg (args, short*));
    12191219        break;
    12201220
    12211221      case _C_USHT:
    12221222        res = objc_write_unsigned_short (stream,
    1223                                          *va_arg(args, unsigned short*));
     1223                                         *va_arg (args, unsigned short*));
    12241224        break;
    12251225
    12261226      case _C_INT:
    1227         res = objc_write_int(stream, *va_arg(args, int*));
     1227        res = objc_write_int(stream, *va_arg (args, int*));
    12281228        break;
    12291229       
    12301230      case _C_UINT:
    1231         res = objc_write_unsigned_int(stream, *va_arg(args, unsigned int*));
     1231        res = objc_write_unsigned_int(stream, *va_arg (args, unsigned int*));
    12321232        break;
    12331233
    12341234      case _C_LNG:
    1235         res = objc_write_long(stream, *va_arg(args, long*));
     1235        res = objc_write_long(stream, *va_arg (args, long*));
    12361236        break;
    12371237       
    12381238      case _C_ULNG:
    1239         res = objc_write_unsigned_long(stream, *va_arg(args, unsigned long*));
     1239        res = objc_write_unsigned_long(stream, *va_arg (args, unsigned long*));
    12401240        break;
    12411241
    12421242      case _C_CHARPTR:
    12431243        {
    1244           char** str = va_arg(args, char**);
    1245           res = objc_write_string (stream, *str, strlen(*str));
     1244          char **str = va_arg (args, char **);
     1245          res = objc_write_string (stream, *str, strlen (*str));
    12461246        }
    12471247        break;
     
    12491249      case _C_ATOM:
    12501250        {
    1251           char** str = va_arg(args, char**);
    1252           res = objc_write_string_atomic (stream, *str, strlen(*str));
     1251          char **str = va_arg (args, char **);
     1252          res = objc_write_string_atomic (stream, *str, strlen (*str));
    12531253        }
    12541254        break;
     
    12561256      case _C_ARY_B:
    12571257        {
    1258           int len = atoi(c+1);
    1259           const char* t = c;
    1260           while (isdigit(*++t))
     1258          int len = atoi (c + 1);
     1259          const char *t = c;
     1260          while (isdigit ((unsigned char) *++t))
    12611261            ;
    1262           res = objc_write_array (stream, t, len, va_arg(args, void*));
     1262          res = objc_write_array (stream, t, len, va_arg (args, void *));
    12631263          t = objc_skip_typespec (t);
    12641264          if (*t != _C_ARY_E)
    1265             objc_error(nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
     1265            objc_error (nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
    12661266        }
    12671267        break;
    12681268       
    12691269      default:
    1270         objc_error(nil, OBJC_ERR_BAD_TYPE,
    1271                    "objc_write_types: cannot parse typespec: %s\n", type);
     1270        objc_error (nil, OBJC_ERR_BAD_TYPE,
     1271                    "objc_write_types: cannot parse typespec: %s\n", type);
    12721272      }
    12731273    }
     
    12831283
    12841284int
    1285 objc_read_types(TypedStream* stream, const char* type, ...)
     1285objc_read_types(TypedStream *stream, const char *type, ...)
    12861286{
    12871287  va_list args;
     
    12891289  int res = 0;
    12901290
    1291   va_start(args, type);
     1291  va_start (args, type);
    12921292
    12931293  for (c = type; *c; c = objc_skip_typespec(c))
    12941294    {
    1295       switch(*c) {
     1295      switch (*c) {
    12961296      case _C_ID:
    1297         res = objc_read_object(stream, va_arg(args, id*));
     1297        res = objc_read_object(stream, va_arg (args, id*));
    12981298        break;
    12991299
    13001300      case _C_CLASS:
    1301         res = objc_read_class(stream, va_arg(args, Class*));
     1301        res = objc_read_class(stream, va_arg (args, Class*));
    13021302        break;
    13031303
    13041304      case _C_SEL:
    1305         res = objc_read_selector(stream, va_arg(args, SEL*));
     1305        res = objc_read_selector(stream, va_arg (args, SEL*));
    13061306        break;
    13071307       
    13081308      case _C_CHR:
    1309         res = objc_read_char(stream, va_arg(args, char*));
     1309        res = objc_read_char(stream, va_arg (args, char*));
    13101310        break;
    13111311       
    13121312      case _C_UCHR:
    1313         res = objc_read_unsigned_char(stream, va_arg(args, unsigned char*));
     1313        res = objc_read_unsigned_char(stream, va_arg (args, unsigned char*));
    13141314        break;
    13151315       
    13161316      case _C_SHT:
    1317         res = objc_read_short(stream, va_arg(args, short*));
     1317        res = objc_read_short(stream, va_arg (args, short*));
    13181318        break;
    13191319
    13201320      case _C_USHT:
    1321         res = objc_read_unsigned_short(stream, va_arg(args, unsigned short*));
     1321        res = objc_read_unsigned_short(stream, va_arg (args, unsigned short*));
    13221322        break;
    13231323
    13241324      case _C_INT:
    1325         res = objc_read_int(stream, va_arg(args, int*));
     1325        res = objc_read_int(stream, va_arg (args, int*));
    13261326        break;
    13271327       
    13281328      case _C_UINT:
    1329         res = objc_read_unsigned_int(stream, va_arg(args, unsigned int*));
     1329        res = objc_read_unsigned_int(stream, va_arg (args, unsigned int*));
    13301330        break;
    13311331
    13321332      case _C_LNG:
    1333         res = objc_read_long(stream, va_arg(args, long*));
     1333        res = objc_read_long(stream, va_arg (args, long*));
    13341334        break;
    13351335       
    13361336      case _C_ULNG:
    1337         res = objc_read_unsigned_long(stream, va_arg(args, unsigned long*));
     1337        res = objc_read_unsigned_long(stream, va_arg (args, unsigned long*));
    13381338        break;
    13391339
     
    13411341      case _C_ATOM:
    13421342        {
    1343           char** str = va_arg(args, char**);
     1343          char **str = va_arg (args, char **);
    13441344          res = objc_read_string (stream, str);
    13451345        }
     
    13481348      case _C_ARY_B:
    13491349        {
    1350           int len = atoi(c+1);
    1351           const char* t = c;
    1352           while (isdigit(*++t))
     1350          int len = atoi (c + 1);
     1351          const char *t = c;
     1352          while (isdigit ((unsigned char) *++t))
    13531353            ;
    1354           res = objc_read_array (stream, t, len, va_arg(args, void*));
     1354          res = objc_read_array (stream, t, len, va_arg (args, void *));
    13551355          t = objc_skip_typespec (t);
    13561356          if (*t != _C_ARY_E)
    1357             objc_error(nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
     1357            objc_error (nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
    13581358        }
    13591359        break;
    13601360       
    13611361      default:
    1362         objc_error(nil, OBJC_ERR_BAD_TYPE,
    1363                    "objc_read_types: cannot parse typespec: %s\n", type);
     1362        objc_error (nil, OBJC_ERR_BAD_TYPE,
     1363                    "objc_read_types: cannot parse typespec: %s\n", type);
    13641364      }
    13651365    }
    1366   va_end(args);
     1366  va_end (args);
    13671367  return res;
    13681368}
     
    13741374
    13751375int
    1376 objc_write_array (TypedStream* stream, const char* type,
    1377                   int count, const void* data)
     1376objc_write_array (TypedStream *stream, const char *type,
     1377                  int count, const void *data)
    13781378{
    13791379  int off = objc_sizeof_type(type);
    1380   const char* where = data;
     1380  const char *where = data;
    13811381
    13821382  while (count-- > 0)
     
    13961396
    13971397int
    1398 objc_read_array (TypedStream* stream, const char* type,
    1399                  int count, void* data)
     1398objc_read_array (TypedStream *stream, const char *type,
     1399                 int count, void *data)
    14001400{
    14011401  int off = objc_sizeof_type(type);
    1402   char* where = (char*)data;
     1402  char *where = (char*)data;
    14031403
    14041404  while (count-- > 0)
     
    14111411
    14121412static int
    1413 __objc_fread(FILE* file, char* data, int len)
     1413__objc_fread (FILE *file, char *data, int len)
    14141414{
    14151415  return fread(data, len, 1, file);
     
    14171417
    14181418static int
    1419 __objc_fwrite(FILE* file, char* data, int len)
     1419__objc_fwrite (FILE *file, char *data, int len)
    14201420{
    14211421  return fwrite(data, len, 1, file);
     
    14231423
    14241424static int
    1425 __objc_feof(FILE* file)
     1425__objc_feof (FILE *file)
    14261426{
    14271427  return feof(file);
     
    14291429
    14301430static int
    1431 __objc_no_write(FILE* file, char* data, int len)
     1431__objc_no_write (FILE *file __attribute__ ((__unused__)),
     1432                 const char *data __attribute__ ((__unused__)),
     1433                 int len __attribute__ ((__unused__)))
    14321434{
    14331435  objc_error (nil, OBJC_ERR_NO_WRITE, "TypedStream not open for writing");
     
    14361438
    14371439static int
    1438 __objc_no_read(FILE* file, char* data, int len)
     1440__objc_no_read (FILE *file __attribute__ ((__unused__)),
     1441                const char *data __attribute__ ((__unused__)),
     1442                int len __attribute__ ((__unused__)))
    14391443{
    14401444  objc_error (nil, OBJC_ERR_NO_READ, "TypedStream not open for reading");
     
    14431447
    14441448static int
    1445 __objc_read_typed_stream_signature (TypedStream* stream)
     1449__objc_read_typed_stream_signature (TypedStream *stream)
    14461450{
    14471451  char buffer[80];
    14481452  int pos = 0;
    14491453  do
    1450     (*stream->read)(stream->physical, buffer+pos, 1);
     1454    (*stream->read) (stream->physical, buffer+pos, 1);
    14511455  while (buffer[pos++] != '\0')
    14521456    ;
     
    14591463
    14601464static int
    1461 __objc_write_typed_stream_signature (TypedStream* stream)
     1465__objc_write_typed_stream_signature (TypedStream *stream)
    14621466{
    14631467  char buffer[80];
    14641468  sprintf(buffer, "GNU TypedStream %d", OBJC_TYPED_STREAM_VERSION);
    14651469  stream->version = OBJC_TYPED_STREAM_VERSION;
    1466   (*stream->write)(stream->physical, buffer, strlen(buffer)+1);
     1470  (*stream->write) (stream->physical, buffer, strlen (buffer) + 1);
    14671471  return 1;
    14681472}
    14691473
    1470 static void __objc_finish_write_root_object(struct objc_typed_stream* stream)
     1474static void __objc_finish_write_root_object(struct objc_typed_stream *stream)
    14711475{
    14721476  hash_delete (stream->object_table);
     
    14761480}
    14771481
    1478 static void __objc_finish_read_root_object(struct objc_typed_stream* stream)
     1482static void __objc_finish_read_root_object(struct objc_typed_stream *stream)
    14791483{
    14801484  node_ptr node;
     
    14881492       node = hash_next (stream->object_refs, node))
    14891493    {
    1490       struct objc_list* reflist = node->value;
    1491       const void* key = node->key;
     1494      struct objc_list *reflist = node->value;
     1495      const void *key = node->key;
    14921496      id object = hash_value_for_key (stream->object_table, key);
    1493       while(reflist)
    1494         {
    1495           *((id*)reflist->head) = object;
     1497      while (reflist)
     1498        {
     1499          *((id*) reflist->head) = object;
    14961500          if (hash_value_for_key (free_list,reflist) == NULL)
    14971501            hash_add (&free_list,reflist,reflist);
     
    15211525          id object = node->value;
    15221526          if (__objc_responds_to (object, awake_sel))
    1523             (*objc_msg_lookup(object, awake_sel))(object, awake_sel);
     1527            (*objc_msg_lookup (object, awake_sel)) (object, awake_sel);
    15241528        }
    15251529    }
     
    15361540*/
    15371541
    1538 TypedStream*
    1539 objc_open_typed_stream (FILE* physical, int mode)
    1540 {
    1541   TypedStream* s = (TypedStream*)objc_malloc(sizeof(TypedStream));
     1542TypedStream *
     1543objc_open_typed_stream (FILE *physical, int mode)
     1544{
     1545  TypedStream *s = (TypedStream *) objc_malloc (sizeof (TypedStream));
    15421546
    15431547  s->mode = mode;
    15441548  s->physical = physical;
    1545   s->stream_table = hash_new(64,
    1546                              (hash_func_type)hash_ptr,
    1547                              (compare_func_type)compare_ptrs);
    1548   s->object_table = hash_new(64,
    1549                              (hash_func_type)hash_ptr,
    1550                              (compare_func_type)compare_ptrs);
    1551   s->eof = (objc_typed_eof_func)__objc_feof;
    1552   s->flush = (objc_typed_flush_func)fflush;
     1549  s->stream_table = hash_new (64,
     1550                              (hash_func_type) hash_ptr,
     1551                              (compare_func_type) compare_ptrs);
     1552  s->object_table = hash_new (64,
     1553                              (hash_func_type) hash_ptr,
     1554                              (compare_func_type) compare_ptrs);
     1555  s->eof = (objc_typed_eof_func) __objc_feof;
     1556  s->flush = (objc_typed_flush_func) fflush;
    15531557  s->writing_root_p = 0;
    15541558  if (mode == OBJC_READONLY)
    15551559    {
    1556       s->class_table = hash_new(8, (hash_func_type)hash_string,
    1557                                 (compare_func_type)compare_strings);
    1558       s->object_refs = hash_new(8, (hash_func_type)hash_ptr,
    1559                                 (compare_func_type)compare_ptrs);
    1560       s->read = (objc_typed_read_func)__objc_fread;
    1561       s->write = (objc_typed_write_func)__objc_no_write;
     1560      s->class_table = hash_new (8, (hash_func_type) hash_string,
     1561                                 (compare_func_type) compare_strings);
     1562      s->object_refs = hash_new (8, (hash_func_type) hash_ptr,
     1563                                 (compare_func_type) compare_ptrs);
     1564      s->read = (objc_typed_read_func) __objc_fread;
     1565      s->write = (objc_typed_write_func) __objc_no_write;
    15621566      __objc_read_typed_stream_signature (s);
    15631567    }
     
    15661570      s->class_table = 0;
    15671571      s->object_refs = 0;
    1568       s->read = (objc_typed_read_func)__objc_no_read;
    1569       s->write = (objc_typed_write_func)__objc_fwrite;
     1572      s->read = (objc_typed_read_func) __objc_no_read;
     1573      s->write = (objc_typed_write_func) __objc_fwrite;
    15701574      __objc_write_typed_stream_signature (s);
    15711575    }     
     
    15841588
    15851589TypedStream*
    1586 objc_open_typed_stream_for_file (const char* file_name, int mode)
    1587 {
    1588   FILE* file = NULL;
    1589   TypedStream* s;
     1590objc_open_typed_stream_for_file (const char *file_name, int mode)
     1591{
     1592  FILE *file = NULL;
     1593  TypedStream *s;
    15901594
    15911595  if (mode == OBJC_READONLY)
     
    16111615
    16121616void
    1613 objc_close_typed_stream (TypedStream* stream)
     1617objc_close_typed_stream (TypedStream *stream)
    16141618{
    16151619  if (stream->mode == OBJC_READONLY)
     
    16241628
    16251629  if (stream->type == (OBJC_MANAGED_STREAM | OBJC_FILE_STREAM))
    1626     fclose ((FILE*)stream->physical);
     1630    fclose ((FILE *)stream->physical);
    16271631
    16281632  objc_free(stream);
     
    16301634
    16311635BOOL
    1632 objc_end_of_typed_stream (TypedStream* stream)
    1633 {
    1634   return (*stream->eof)(stream->physical);
     1636objc_end_of_typed_stream (TypedStream *stream)
     1637{
     1638  return (*stream->eof) (stream->physical);
    16351639}
    16361640
    16371641void
    1638 objc_flush_typed_stream (TypedStream* stream)
    1639 {
    1640   (*stream->flush)(stream->physical);
     1642objc_flush_typed_stream (TypedStream *stream)
     1643{
     1644  (*stream->flush) (stream->physical);
    16411645}
    16421646
    16431647long
    1644 objc_get_stream_class_version (TypedStream* stream, Class class)
     1648objc_get_stream_class_version (TypedStream *stream, Class class)
    16451649{
    16461650  if (stream->class_table)
  • branches/GNU/src/gcc/libobjc/class.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* GNU Objective C Runtime class related functions
    2    Copyright (C) 1993, 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
     2   Copyright (C) 1993, 1995, 1996, 1997, 2001, 2002
     3     Free Software Foundation, Inc.
    34   Contributed by Kresten Krab Thorup and Dennis Glatting.
    45
     
    164165/* Setup the table.  */
    165166static void
    166 class_table_setup ()
     167class_table_setup (void)
    167168{
    168169  /* Start - nothing in the table.  */
    169   memset (class_table_array, 0, sizeof(class_node_ptr) * CLASS_TABLE_SIZE);
     170  memset (class_table_array, 0, sizeof (class_node_ptr) * CLASS_TABLE_SIZE);
    170171
    171172  /* The table writing mutex.  */
     
    340341/* Debugging function - print the class table.  */
    341342void
    342 class_table_print ()
     343class_table_print (void)
    343344{
    344345  int i;
     
    363364   in real cases.  */
    364365void
    365 class_table_print_histogram ()
     366class_table_print_histogram (void)
    366367{
    367368  int i, j;
     
    409410   objc_lookup_class if the runtime is not able to find the class. 
    410411   This may e.g. try to load in the class using dynamic loading.  */
    411 Class (*_objc_lookup_class)(const char* name) = 0;      /* !T:SAFE */
     412Class (*_objc_lookup_class) (const char *name) = 0;      /* !T:SAFE */
    412413
    413414
     
    416417
    417418
    418 void __objc_init_class_tables()
     419void
     420__objc_init_class_tables (void)
    419421{
    420422  /* Allocate the class hash table.  */
    421423 
    422   if(__class_table_lock)
     424  if (__class_table_lock)
    423425    return;
    424426 
    425   objc_mutex_lock(__objc_runtime_mutex);
     427  objc_mutex_lock (__objc_runtime_mutex);
    426428 
    427429  class_table_setup ();
    428430
    429   objc_mutex_unlock(__objc_runtime_mutex);
     431  objc_mutex_unlock (__objc_runtime_mutex);
    430432
    431433
     
    433435   class a number, unless it's already known.  */
    434436void
    435 __objc_add_class_to_hash(Class class)
     437__objc_add_class_to_hash (Class class)
    436438{
    437439  Class h_class;
    438440
    439   objc_mutex_lock(__objc_runtime_mutex);
     441  objc_mutex_lock (__objc_runtime_mutex);
    440442
    441443  /* Make sure the table is there.  */
    442   assert(__class_table_lock);
     444  assert (__class_table_lock);
    443445
    444446  /* Make sure it's not a meta class.  */
    445   assert(CLS_ISCLASS(class));
     447  assert (CLS_ISCLASS (class));
    446448
    447449  /* Check to see if the class is already in the hash table.  */
    448450  h_class = class_table_get_safe (class->name);
    449   if (!h_class)
     451  if (! h_class)
    450452    {
    451453      /* The class isn't in the hash table.  Add the class and assign a class
     
    453455      static unsigned int class_number = 1;
    454456
    455       CLS_SETNUMBER(class, class_number);
    456       CLS_SETNUMBER(class->class_pointer, class_number);
     457      CLS_SETNUMBER (class, class_number);
     458      CLS_SETNUMBER (class->class_pointer, class_number);
    457459
    458460      ++class_number;
     
    460462    }
    461463
    462   objc_mutex_unlock(__objc_runtime_mutex);
     464  objc_mutex_unlock (__objc_runtime_mutex);
    463465}
    464466
     
    466468   identify a known class, the hook _objc_lookup_class is called.  If
    467469   this fails, nil is returned.  */
    468 Class objc_lookup_class (const char* name)
     470Class
     471objc_lookup_class (const char *name)
    469472{
    470473  Class class;
     
    476479
    477480  if (_objc_lookup_class)
    478     return (*_objc_lookup_class)(name);
     481    return (*_objc_lookup_class) (name);
    479482  else
    480483    return 0;
     
    495498
    496499  if (_objc_lookup_class)
    497     class = (*_objc_lookup_class)(name);
    498 
    499   if(class)
     500    class = (*_objc_lookup_class) (name);
     501
     502  if (class)
    500503    return class;
    501504 
    502   objc_error(nil, OBJC_ERR_BAD_CLASS,
    503              "objc runtime: cannot find class %s\n", name);
     505  objc_error (nil, OBJC_ERR_BAD_CLASS,
     506              "objc runtime: cannot find class %s\n", name);
    504507  return 0;
    505508}
    506509
    507510MetaClass
    508 objc_get_meta_class(const char *name)
    509 {
    510   return objc_get_class(name)->class_pointer;
     511objc_get_meta_class (const char *name)
     512{
     513  return objc_get_class (name)->class_pointer;
    511514}
    512515
     
    517520       id class;
    518521       void *es = NULL;
    519        while ((class = objc_next_class(&es)))
     522       while ((class = objc_next_class (&es)))
    520523         ... do something with class;
    521524*/
    522525Class
    523 objc_next_class(void **enum_state)
     526objc_next_class (void **enum_state)
    524527{
    525528  Class class;
    526529
    527   objc_mutex_lock(__objc_runtime_mutex);
     530  objc_mutex_lock (__objc_runtime_mutex);
    528531 
    529532  /* Make sure the table is there.  */
    530   assert(__class_table_lock);
    531 
    532   class = class_table_next ((struct class_table_enumerator **)enum_state);
    533 
    534   objc_mutex_unlock(__objc_runtime_mutex);
     533  assert (__class_table_lock);
     534
     535  class = class_table_next ((struct class_table_enumerator **) enum_state);
     536
     537  objc_mutex_unlock (__objc_runtime_mutex);
    535538 
    536539  return class;
     
    540543   can be sure of is that the class_pointer for class objects point to
    541544   the right meta class objects.  */
    542 void __objc_resolve_class_links()
     545void
     546__objc_resolve_class_links (void)
    543547{
    544548  struct class_table_enumerator *es = NULL;
     
    546550  Class class1;
    547551
    548   assert(object_class);
    549 
    550   objc_mutex_lock(__objc_runtime_mutex);
     552  assert (object_class);
     553
     554  objc_mutex_lock (__objc_runtime_mutex);
    551555
    552556  /* Assign subclass links.  */
     
    554558    {
    555559      /* Make sure we have what we think we have.  */
    556       assert (CLS_ISCLASS(class1));
    557       assert (CLS_ISMETA(class1->class_pointer));
     560      assert (CLS_ISCLASS (class1));
     561      assert (CLS_ISMETA (class1->class_pointer));
    558562
    559563      /* The class_pointer of all meta classes point to Object's meta
     
    561565      class1->class_pointer->class_pointer = object_class->class_pointer;
    562566
    563       if (!(CLS_ISRESOLV(class1)))
    564         {
    565           CLS_SETRESOLV(class1);
    566           CLS_SETRESOLV(class1->class_pointer);
     567      if (! CLS_ISRESOLV (class1))
     568        {
     569          CLS_SETRESOLV (class1);
     570          CLS_SETRESOLV (class1->class_pointer);
    567571             
    568           if(class1->super_class)
     572          if (class1->super_class)
    569573            {   
    570574              Class a_super_class
     
    608612        {
    609613          sub_class->super_class = class1;
    610           if(CLS_ISCLASS(sub_class))
     614          if (CLS_ISCLASS (sub_class))
    611615            sub_class->class_pointer->super_class = class1->class_pointer;
    612616        }
    613617    }
    614618
    615   objc_mutex_unlock(__objc_runtime_mutex);
     619  objc_mutex_unlock (__objc_runtime_mutex);
    616620}
    617621
     
    623627class_pose_as (Class impostor, Class super_class)
    624628{
    625   if (!CLS_ISRESOLV (impostor))
     629  if (! CLS_ISRESOLV (impostor))
    626630    __objc_resolve_class_links ();
    627631
     
    686690     into impostor.  */
    687691
    688   objc_mutex_lock(__objc_runtime_mutex);
     692  objc_mutex_lock (__objc_runtime_mutex);
    689693
    690694  class_table_replace (super_class, impostor);
    691695
    692   objc_mutex_unlock(__objc_runtime_mutex);
     696  objc_mutex_unlock (__objc_runtime_mutex);
    693697
    694698  /* Next, we update the dispatch tables...  */
  • branches/GNU/src/gcc/libobjc/configure

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    773773# canonicalize only relative paths, because then amd will not unmount
    774774# drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
    775 glibcpp_builddir=`pwd`
     775glibcpp_builddir=`${PWDCMD-pwd}`
    776776case $srcdir in
    777777\\/$* | ?:\\/*) glibcpp_srcdir=${srcdir} ;;
     
    16051605
    16061606hpux10.20*|hpux11*)
    1607   lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
    1608   lt_cv_file_magic_cmd=/usr/bin/file
    1609   lt_cv_file_magic_test_file=/usr/lib/libc.sl
     1607  case $host_cpu in
     1608  hppa*)
     1609    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
     1610    lt_cv_file_magic_cmd=/usr/bin/file
     1611    lt_cv_file_magic_test_file=/usr/lib/libc.sl
     1612    ;;
     1613  ia64*)
     1614    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
     1615    lt_cv_file_magic_cmd=/usr/bin/file
     1616    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
     1617    ;;
     1618  esac
    16101619  ;;
    16111620
     
    16971706
    16981707echo $ac_n "checking for object suffix""... $ac_c" 1>&6
    1699 echo "configure:1700: checking for object suffix" >&5
     1708echo "configure:1709: checking for object suffix" >&5
    17001709if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then
    17011710  echo $ac_n "(cached) $ac_c" 1>&6
     
    17031712  rm -f conftest*
    17041713echo 'int i = 1;' > conftest.$ac_ext
    1705 if { (eval echo configure:1706: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     1714if { (eval echo configure:1715: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
    17061715  for ac_file in conftest.*; do
    17071716    case $ac_file in
     
    17271736  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
    17281737    echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6
    1729 echo "configure:1730: checking for ${ac_tool_prefix}file" >&5
     1738echo "configure:1739: checking for ${ac_tool_prefix}file" >&5
    17301739if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
    17311740  echo $ac_n "(cached) $ac_c" 1>&6
     
    17891798  if test -n "$ac_tool_prefix"; then
    17901799    echo $ac_n "checking for file""... $ac_c" 1>&6
    1791 echo "configure:1792: checking for file" >&5
     1800echo "configure:1801: checking for file" >&5
    17921801if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
    17931802  echo $ac_n "(cached) $ac_c" 1>&6
     
    18601869set dummy ${ac_tool_prefix}ranlib; ac_word=$2
    18611870echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    1862 echo "configure:1863: checking for $ac_word" >&5
     1871echo "configure:1872: checking for $ac_word" >&5
    18631872if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
    18641873  echo $ac_n "(cached) $ac_c" 1>&6
     
    18921901set dummy ranlib; ac_word=$2
    18931902echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    1894 echo "configure:1895: checking for $ac_word" >&5
     1903echo "configure:1904: checking for $ac_word" >&5
    18951904if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
    18961905  echo $ac_n "(cached) $ac_c" 1>&6
     
    19271936set dummy ${ac_tool_prefix}strip; ac_word=$2
    19281937echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    1929 echo "configure:1930: checking for $ac_word" >&5
     1938echo "configure:1939: checking for $ac_word" >&5
    19301939if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
    19311940  echo $ac_n "(cached) $ac_c" 1>&6
     
    19591968set dummy strip; ac_word=$2
    19601969echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    1961 echo "configure:1962: checking for $ac_word" >&5
     1970echo "configure:1971: checking for $ac_word" >&5
    19621971if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
    19631972  echo $ac_n "(cached) $ac_c" 1>&6
     
    20262035*-*-irix6*)
    20272036  # Find out which ABI we are using.
    2028   echo '#line 2029 "configure"' > conftest.$ac_ext
    2029   if { (eval echo configure:2030: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     2037  echo '#line 2038 "configure"' > conftest.$ac_ext
     2038  if { (eval echo configure:2039: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     2039   if test "$lt_cv_prog_gnu_ld" = yes; then
     2040    case `/usr/bin/file conftest.$ac_objext` in
     2041    *32-bit*)
     2042      LD="${LD-ld} -melf32bsmip"
     2043      ;;
     2044    *N32*)
     2045      LD="${LD-ld} -melf32bmipn32"
     2046      ;;
     2047    *64-bit*)
     2048      LD="${LD-ld} -melf64bmip"
     2049      ;;
     2050    esac
     2051   else
    20302052    case `/usr/bin/file conftest.$ac_objext` in
    20312053    *32-bit*)
     
    20392061      ;;
    20402062    esac
     2063   fi
     2064  fi
     2065  rm -rf conftest*
     2066  ;;
     2067
     2068ia64-*-hpux*)
     2069  # Find out which ABI we are using.
     2070  echo 'int i;' > conftest.$ac_ext
     2071  if { (eval echo configure:2072: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     2072    case "`/usr/bin/file conftest.o`" in
     2073    *ELF-32*)
     2074      HPUX_IA64_MODE="32"
     2075      ;;
     2076    *ELF-64*)
     2077      HPUX_IA64_MODE="64"
     2078      ;;
     2079    esac
     2080  fi
     2081  rm -rf conftest*
     2082  ;;
     2083
     2084x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
     2085  # Find out which ABI we are using.
     2086  echo 'int i;' > conftest.$ac_ext
     2087  if { (eval echo configure:2088: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     2088    case "`/usr/bin/file conftest.o`" in
     2089    *32-bit*)
     2090      case $host in
     2091        x86_64-*linux*)
     2092          LD="${LD-ld} -m elf_i386"
     2093          ;;
     2094        ppc64-*linux*|powerpc64-*linux*)
     2095          LD="${LD-ld} -m elf32ppclinux"
     2096          ;;
     2097        s390x-*linux*)
     2098          LD="${LD-ld} -m elf_s390"
     2099          ;;
     2100        sparc64-*linux*)
     2101          LD="${LD-ld} -m elf32_sparc"
     2102          ;;
     2103      esac
     2104      ;;
     2105    *64-bit*)
     2106      case $host in
     2107        x86_64-*linux*)
     2108          LD="${LD-ld} -m elf_x86_64"
     2109          ;;
     2110        ppc*-*linux*|powerpc*-*linux*)
     2111          LD="${LD-ld} -m elf64ppc"
     2112          ;;
     2113        s390*-*linux*)
     2114          LD="${LD-ld} -m elf64_s390"
     2115          ;;
     2116        sparc*-*linux*)
     2117          LD="${LD-ld} -m elf64_sparc"
     2118          ;;
     2119      esac
     2120      ;;
     2121    esac
    20412122  fi
    20422123  rm -rf conftest*
     
    20482129  CFLAGS="$CFLAGS -belf"
    20492130  echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
    2050 echo "configure:2051: checking whether the C compiler needs -belf" >&5
     2131echo "configure:2132: checking whether the C compiler needs -belf" >&5
    20512132if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then
    20522133  echo $ac_n "(cached) $ac_c" 1>&6
     
    20612142
    20622143     cat > conftest.$ac_ext <<EOF
    2063 #line 2064 "configure"
     2144#line 2145 "configure"
    20642145#include "confdefs.h"
    20652146
     
    20682149; return 0; }
    20692150EOF
    2070 if { (eval echo configure:2071: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
     2151if { (eval echo configure:2152: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    20712152  rm -rf conftest*
    20722153  lt_cv_cc_needs_belf=yes
     
    20982179set dummy ${ac_tool_prefix}dlltool; ac_word=$2
    20992180echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    2100 echo "configure:2101: checking for $ac_word" >&5
     2181echo "configure:2182: checking for $ac_word" >&5
    21012182if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
    21022183  echo $ac_n "(cached) $ac_c" 1>&6
     
    21302211set dummy dlltool; ac_word=$2
    21312212echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    2132 echo "configure:2133: checking for $ac_word" >&5
     2213echo "configure:2214: checking for $ac_word" >&5
    21332214if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
    21342215  echo $ac_n "(cached) $ac_c" 1>&6
     
    21652246set dummy ${ac_tool_prefix}as; ac_word=$2
    21662247echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    2167 echo "configure:2168: checking for $ac_word" >&5
     2248echo "configure:2249: checking for $ac_word" >&5
    21682249if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
    21692250  echo $ac_n "(cached) $ac_c" 1>&6
     
    21972278set dummy as; ac_word=$2
    21982279echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    2199 echo "configure:2200: checking for $ac_word" >&5
     2280echo "configure:2281: checking for $ac_word" >&5
    22002281if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
    22012282  echo $ac_n "(cached) $ac_c" 1>&6
     
    22322313set dummy ${ac_tool_prefix}objdump; ac_word=$2
    22332314echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    2234 echo "configure:2235: checking for $ac_word" >&5
     2315echo "configure:2316: checking for $ac_word" >&5
    22352316if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then
    22362317  echo $ac_n "(cached) $ac_c" 1>&6
     
    22642345set dummy objdump; ac_word=$2
    22652346echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    2266 echo "configure:2267: checking for $ac_word" >&5
     2347echo "configure:2348: checking for $ac_word" >&5
    22672348if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then
    22682349  echo $ac_n "(cached) $ac_c" 1>&6
     
    23002381  # can override, but on older systems we have to supply one
    23012382  echo $ac_n "checking if libtool should supply DllMain function""... $ac_c" 1>&6
    2302 echo "configure:2303: checking if libtool should supply DllMain function" >&5
     2383echo "configure:2384: checking if libtool should supply DllMain function" >&5
    23032384if eval "test \"`echo '$''{'lt_cv_need_dllmain'+set}'`\" = set"; then
    23042385  echo $ac_n "(cached) $ac_c" 1>&6
    23052386else
    23062387  cat > conftest.$ac_ext <<EOF
    2307 #line 2308 "configure"
     2388#line 2389 "configure"
    23082389#include "confdefs.h"
    23092390
     
    23132394; return 0; }
    23142395EOF
    2315 if { (eval echo configure:2316: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
     2396if { (eval echo configure:2397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    23162397  rm -rf conftest*
    23172398  lt_cv_need_dllmain=no
     
    23342415    CFLAGS="$CFLAGS -mdll"
    23352416    echo $ac_n "checking how to link DLLs""... $ac_c" 1>&6
    2336 echo "configure:2337: checking how to link DLLs" >&5
     2417echo "configure:2418: checking how to link DLLs" >&5
    23372418if eval "test \"`echo '$''{'lt_cv_cc_dll_switch'+set}'`\" = set"; then
    23382419  echo $ac_n "(cached) $ac_c" 1>&6
    23392420else
    23402421  cat > conftest.$ac_ext <<EOF
    2341 #line 2342 "configure"
     2422#line 2423 "configure"
    23422423#include "confdefs.h"
    23432424
     
    23462427; return 0; }
    23472428EOF
    2348 if { (eval echo configure:2349: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
     2429if { (eval echo configure:2430: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
    23492430  rm -rf conftest*
    23502431  lt_cv_cc_dll_switch=-mdll
     
    24642545set dummy ranlib; ac_word=$2
    24652546echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
    2466 echo "configure:2467: checking for $ac_word" >&5
     2547echo "configure:2548: checking for $ac_word" >&5
    24672548if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
    24682549  echo $ac_n "(cached) $ac_c" 1>&6
     
    25042585# ./install, which can be erroneously created by make from ./install.sh.
    25052586echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
    2506 echo "configure:2507: checking for a BSD compatible install" >&5
     2587echo "configure:2588: checking for a BSD compatible install" >&5
    25072588if test -z "$INSTALL"; then
    25082589if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
     
    25572638
    25582639echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
    2559 echo "configure:2560: checking whether ${MAKE-make} sets \${MAKE}" >&5
     2640echo "configure:2641: checking whether ${MAKE-make} sets \${MAKE}" >&5
    25602641set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
    25612642if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
     
    25862667# Sanity check for the cross-compilation case:
    25872668echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
    2588 echo "configure:2589: checking how to run the C preprocessor" >&5
     2669echo "configure:2670: checking how to run the C preprocessor" >&5
    25892670# On Suns, sometimes $CPP names a directory.
    25902671if test -n "$CPP" && test -d "$CPP"; then
     
    26012682  # not just through cpp.
    26022683  cat > conftest.$ac_ext <<EOF
    2603 #line 2604 "configure"
     2684#line 2685 "configure"
    26042685#include "confdefs.h"
    26052686#include <assert.h>
     
    26072688EOF
    26082689ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
    2609 { (eval echo configure:2610: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
     2690{ (eval echo configure:2691: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
    26102691ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
    26112692if test -z "$ac_err"; then
     
    26182699  CPP="${CC-cc} -E -traditional-cpp"
    26192700  cat > conftest.$ac_ext <<EOF
    2620 #line 2621 "configure"
     2701#line 2702 "configure"
    26212702#include "confdefs.h"
    26222703#include <assert.h>
     
    26242705EOF
    26252706ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
    2626 { (eval echo configure:2627: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
     2707{ (eval echo configure:2708: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
    26272708ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
    26282709if test -z "$ac_err"; then
     
    26352716  CPP="${CC-cc} -nologo -E"
    26362717  cat > conftest.$ac_ext <<EOF
    2637 #line 2638 "configure"
     2718#line 2719 "configure"
    26382719#include "confdefs.h"
    26392720#include <assert.h>
     
    26412722EOF
    26422723ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
    2643 { (eval echo configure:2644: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
     2724{ (eval echo configure:2725: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
    26442725ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
    26452726if test -z "$ac_err"; then
     
    26672748ac_safe=`echo "stdio.h" | sed 'y%./+-%__p_%'`
    26682749echo $ac_n "checking for stdio.h""... $ac_c" 1>&6
    2669 echo "configure:2670: checking for stdio.h" >&5
     2750echo "configure:2751: checking for stdio.h" >&5
    26702751if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
    26712752  echo $ac_n "(cached) $ac_c" 1>&6
    26722753else
    26732754  cat > conftest.$ac_ext <<EOF
    2674 #line 2675 "configure"
     2755#line 2756 "configure"
    26752756#include "confdefs.h"
    26762757#include <stdio.h>
    26772758EOF
    26782759ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
    2679 { (eval echo configure:2680: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
     2760{ (eval echo configure:2761: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
    26802761ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
    26812762if test -z "$ac_err"; then
     
    27052786
    27062787echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
    2707 echo "configure:2708: checking for ANSI C header files" >&5
     2788echo "configure:2789: checking for ANSI C header files" >&5
    27082789if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
    27092790  echo $ac_n "(cached) $ac_c" 1>&6
    27102791else
    27112792  cat > conftest.$ac_ext <<EOF
    2712 #line 2713 "configure"
     2793#line 2794 "configure"
    27132794#include "confdefs.h"
    27142795#include <stdlib.h>
     
    27182799EOF
    27192800ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
    2720 { (eval echo configure:2721: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
     2801{ (eval echo configure:2802: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
    27212802ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
    27222803if test -z "$ac_err"; then
     
    27352816  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
    27362817cat > conftest.$ac_ext <<EOF
    2737 #line 2738 "configure"
     2818#line 2819 "configure"
    27382819#include "confdefs.h"
    27392820#include <string.h>
     
    27532834  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
    27542835cat > conftest.$ac_ext <<EOF
    2755 #line 2756 "configure"
     2836#line 2837 "configure"
    27562837#include "confdefs.h"
    27572838#include <stdlib.h>
     
    27742855else
    27752856  cat > conftest.$ac_ext <<EOF
    2776 #line 2777 "configure"
     2857#line 2858 "configure"
    27772858#include "confdefs.h"
    27782859#include <ctype.h>
     
    27852866
    27862867EOF
    2787 if { (eval echo configure:2788: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
     2868if { (eval echo configure:2869: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
    27882869then
    27892870  :
     
    28132894ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
    28142895echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
    2815 echo "configure:2816: checking for $ac_hdr" >&5
     2896echo "configure:2897: checking for $ac_hdr" >&5
    28162897if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
    28172898  echo $ac_n "(cached) $ac_c" 1>&6
    28182899else
    28192900  cat > conftest.$ac_ext <<EOF
    2820 #line 2821 "configure"
     2901#line 2902 "configure"
    28212902#include "confdefs.h"
    28222903#include <$ac_hdr>
    28232904EOF
    28242905ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
    2825 { (eval echo configure:2826: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
     2906{ (eval echo configure:2907: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
    28262907ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
    28272908if test -z "$ac_err"; then
     
    28532934
    28542935echo $ac_n "checking for gthread cflags""... $ac_c" 1>&6
    2855 echo "configure:2856: checking for gthread cflags" >&5
     2936echo "configure:2937: checking for gthread cflags" >&5
    28562937if eval "test \"`echo '$''{'objc_cv_gthread_flags'+set}'`\" = set"; then
    28572938  echo $ac_n "(cached) $ac_c" 1>&6
     
    32763357toplevel_srcdir=${toplevel_srcdir}
    32773358CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
     3359ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
    32783360
    32793361EOF
  • branches/GNU/src/gcc/libobjc/configure.in

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11# Process this file with autoconf to produce a configure script.
    2 #   Copyright (C) 1995, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
     2#   Copyright (C) 1995, 1997, 1998, 1999, 2002, 2003
     3#   Free Software Foundation, Inc.
    34#   Contributed by Dave Love (d.love@dl.ac.uk).
    45#
     
    144145toplevel_srcdir=${toplevel_srcdir}
    145146CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
     147ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
    146148)
    147149
  • branches/GNU/src/gcc/libobjc/encoding.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* Encoding of types for Objective C.
    2    Copyright (C) 1993, 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
     2   Copyright (C) 1993, 1995, 1996, 1997, 1998, 2000, 2002
     3   Free Software Foundation, Inc.
    34   Contributed by Kresten Krab Thorup
    45   Bitfield support by Ovidiu Predescu
     
    3031#include "objc-api.h"
    3132#include "encoding.h"
     33#include <stdlib.h>
    3234
    3335#undef  MAX
    3436#define MAX(X, Y)                    \
    35   ({ typeof(X) __x = (X), __y = (Y); \
     37  ({ typeof (X) __x = (X), __y = (Y); \
    3638     (__x > __y ? __x : __y); })
    3739
    3840#undef  MIN
    3941#define MIN(X, Y)                    \
    40   ({ typeof(X) __x = (X), __y = (Y); \
     42  ({ typeof (X) __x = (X), __y = (Y); \
    4143     (__x < __y ? __x : __y); })
    4244
    4345#undef  ROUND
    4446#define ROUND(V, A) \
    45   ({ typeof(V) __v=(V); typeof(A) __a=(A); \
    46      __a*((__v+__a-1)/__a); })
     47  ({ typeof (V) __v = (V); typeof (A) __a = (A); \
     48     __a * ((__v+__a - 1)/__a); })
    4749
    4850
     
    7981/* Some ROUND_TYPE_ALIGN macros use TARGET_foo, and consequently
    8082   target_flags.  Define a dummy entry here to so we don't die.  */
    81 
    82 static int target_flags = 0;
    83 
    84 static inline int
    85 atoi (const char* str)
    86 {
    87   int res = 0;
    88  
    89   while (isdigit (*str))
    90     res *= 10, res += (*str++ - '0');
    91 
    92   return res;
    93 }
    94 
    95 /*
    96   return the size of an object specified by type
     83/* ??? FIXME: As of 2002-06-21, the attribute `unused' doesn't seem to
     84   eliminate the warning.  */
     85static int __attribute__ ((__unused__)) target_flags = 0;
     86
     87/*
     88  return the size of an object specified by type
    9789*/
    9890
    9991int
    100 objc_sizeof_type (const char* type)
     92objc_sizeof_type (const char *type)
    10193{
    10294  /* Skip the variable name if any */
     
    10799    }
    108100
    109   switch(*type) {
     101  switch (*type) {
    110102  case _C_ID:
    111     return sizeof(id);
     103    return sizeof (id);
    112104    break;
    113105
    114106  case _C_CLASS:
    115     return sizeof(Class);
     107    return sizeof (Class);
    116108    break;
    117109
    118110  case _C_SEL:
    119     return sizeof(SEL);
     111    return sizeof (SEL);
    120112    break;
    121113
    122114  case _C_CHR:
    123     return sizeof(char);
    124     break;
    125    
     115    return sizeof (char);
     116    break;
     117
    126118  case _C_UCHR:
    127     return sizeof(unsigned char);
     119    return sizeof (unsigned char);
    128120    break;
    129121
    130122  case _C_SHT:
    131     return sizeof(short);
     123    return sizeof (short);
    132124    break;
    133125
    134126  case _C_USHT:
    135     return sizeof(unsigned short);
     127    return sizeof (unsigned short);
    136128    break;
    137129
    138130  case _C_INT:
    139     return sizeof(int);
     131    return sizeof (int);
    140132    break;
    141133
    142134  case _C_UINT:
    143     return sizeof(unsigned int);
     135    return sizeof (unsigned int);
    144136    break;
    145137
    146138  case _C_LNG:
    147     return sizeof(long);
     139    return sizeof (long);
    148140    break;
    149141
    150142  case _C_ULNG:
    151     return sizeof(unsigned long);
     143    return sizeof (unsigned long);
    152144    break;
    153145
    154146  case _C_LNG_LNG:
    155     return sizeof(long long);
     147    return sizeof (long long);
    156148    break;
    157149
    158150  case _C_ULNG_LNG:
    159     return sizeof(unsigned long long);
     151    return sizeof (unsigned long long);
    160152    break;
    161153
    162154  case _C_FLT:
    163     return sizeof(float);
     155    return sizeof (float);
    164156    break;
    165157
    166158  case _C_DBL:
    167     return sizeof(double);
     159    return sizeof (double);
    168160    break;
    169161
    170162  case _C_VOID:
    171     return sizeof(void);
    172     break;
     163    return sizeof (void);
     164    break;
     165
    173166  case _C_PTR:
    174167  case _C_ATOM:
    175168  case _C_CHARPTR:
    176     return sizeof(char*);
     169    return sizeof (char *);
    177170    break;
    178171
    179172  case _C_ARY_B:
    180173    {
    181       int len = atoi(type+1);
    182       while (isdigit(*++type));
    183       return len*objc_aligned_size (type);
    184     }
    185     break;
     174      int len = atoi (type + 1);
     175      while (isdigit ((unsigned char)*++type))
     176        ;
     177      return len * objc_aligned_size (type);
     178    }
     179    break;
    186180
    187181  case _C_BFLD:
     
    192186
    193187      position = atoi (type + 1);
    194       while (isdigit (*++type));
     188      while (isdigit ((unsigned char)*++type))
     189        ;
    195190      size = atoi (type + 1);
    196191
     
    216211    {
    217212      int max_size = 0;
    218       while (*type != _C_UNION_E && *type++ != '=') /* do nothing */;
     213      while (*type != _C_UNION_E && *type++ != '=')
     214        /* do nothing */;
    219215      while (*type != _C_UNION_E)
    220216        {
     
    230226      return max_size;
    231227    }
    232    
     228
    233229  default:
    234230    {
    235       objc_error(nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type);
     231      objc_error (nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type);
    236232      return 0;
    237233    }
     
    241237
    242238/*
    243   Return the alignment of an object specified by type 
     239  Return the alignment of an object specified by type
    244240*/
    245241
    246242int
    247 objc_alignof_type(const char* type)
     243objc_alignof_type (const char *type)
    248244{
    249245  /* Skip the variable name if any */
     
    253249        /* do nothing */;
    254250    }
    255   switch(*type) {
     251  switch (*type) {
    256252  case _C_ID:
    257     return __alignof__(id);
     253    return __alignof__ (id);
    258254    break;
    259255
    260256  case _C_CLASS:
    261     return __alignof__(Class);
    262     break;
    263    
     257    return __alignof__ (Class);
     258    break;
     259
    264260  case _C_SEL:
    265     return __alignof__(SEL);
     261    return __alignof__ (SEL);
    266262    break;
    267263
    268264  case _C_CHR:
    269     return __alignof__(char);
    270     break;
    271    
     265    return __alignof__ (char);
     266    break;
     267
    272268  case _C_UCHR:
    273     return __alignof__(unsigned char);
     269    return __alignof__ (unsigned char);
    274270    break;
    275271
    276272  case _C_SHT:
    277     return __alignof__(short);
     273    return __alignof__ (short);
    278274    break;
    279275
    280276  case _C_USHT:
    281     return __alignof__(unsigned short);
     277    return __alignof__ (unsigned short);
    282278    break;
    283279
    284280  case _C_INT:
    285     return __alignof__(int);
     281    return __alignof__ (int);
    286282    break;
    287283
    288284  case _C_UINT:
    289     return __alignof__(unsigned int);
     285    return __alignof__ (unsigned int);
    290286    break;
    291287
    292288  case _C_LNG:
    293     return __alignof__(long);
     289    return __alignof__ (long);
    294290    break;
    295291
    296292  case _C_ULNG:
    297     return __alignof__(unsigned long);
     293    return __alignof__ (unsigned long);
    298294    break;
    299295
    300296  case _C_LNG_LNG:
    301     return __alignof__(long long);
     297    return __alignof__ (long long);
    302298    break;
    303299
    304300  case _C_ULNG_LNG:
    305     return __alignof__(unsigned long long);
     301    return __alignof__ (unsigned long long);
    306302    break;
    307303
    308304  case _C_FLT:
    309     return __alignof__(float);
     305    return __alignof__ (float);
    310306    break;
    311307
    312308  case _C_DBL:
    313     return __alignof__(double);
     309    return __alignof__ (double);
    314310    break;
    315311
     
    317313  case _C_ATOM:
    318314  case _C_CHARPTR:
    319     return __alignof__(char*);
     315    return __alignof__ (char *);
    320316    break;
    321317
    322318  case _C_ARY_B:
    323     while (isdigit(*++type)) /* do nothing */;
     319    while (isdigit ((unsigned char)*++type))
     320      /* do nothing */;
    324321    return objc_alignof_type (type);
    325322
     
    340337    {
    341338      int maxalign = 0;
    342       while (*type != _C_UNION_E && *type++ != '=') /* do nothing */;
     339      while (*type != _C_UNION_E && *type++ != '=')
     340        /* do nothing */;
    343341      while (*type != _C_UNION_E)
    344342        {
     
    357355  default:
    358356    {
    359       objc_error(nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type);
     357      objc_error (nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type);
    360358      return 0;
    361359    }
     
    368366
    369367int
    370 objc_aligned_size (const char* type)
     368objc_aligned_size (const char *type)
    371369{
    372370  int size, align;
     
    387385/*
    388386  The size rounded up to the nearest integral of the wordsize, taken
    389   to be the size of a void*.
    390 */
    391 
    392 int 
    393 objc_promoted_size (const char* type)
     387  to be the size of a void *.
     388*/
     389
     390int
     391objc_promoted_size (const char *type)
    394392{
    395393  int size, wordsize;
     
    403401
    404402  size = objc_sizeof_type (type);
    405   wordsize = sizeof (void*);
     403  wordsize = sizeof (void *);
    406404
    407405  return ROUND (size, wordsize);
     
    413411*/
    414412
    415 inline const char*
    416 objc_skip_type_qualifiers (const char* type)
     413inline const char *
     414objc_skip_type_qualifiers (const char *type)
    417415{
    418416  while (*type == _C_CONST
    419          || *type == _C_IN 
     417         || *type == _C_IN
    420418         || *type == _C_INOUT
    421          || *type == _C_OUT 
     419         || *type == _C_OUT
    422420         || *type == _C_BYCOPY
    423421         || *type == _C_BYREF
     
    430428}
    431429
    432  
     430
    433431/*
    434432  Skip one typespec element.  If the typespec is prepended by type
     
    436434*/
    437435
    438 const char*
    439 objc_skip_typespec (const char* type)
     436const char *
     437objc_skip_typespec (const char *type)
    440438{
    441439  /* Skip the variable name if any */
     
    447445
    448446  type = objc_skip_type_qualifiers (type);
    449  
     447
    450448  switch (*type) {
    451449
     
    458456    else
    459457      {
    460         while (*++type != '"') /* do nothing */;
     458        while (*++type != '"')
     459          /* do nothing */;
    461460        return type + 1;
    462461      }
     
    486485  case _C_ARY_B:
    487486    /* skip digits, typespec and closing ']' */
    488    
    489     while(isdigit(*++type));
    490     type = objc_skip_typespec(type);
     487
     488    while (isdigit ((unsigned char)*++type))
     489      ;
     490    type = objc_skip_typespec (type);
    491491    if (*type == _C_ARY_E)
    492492      return ++type;
    493493    else
    494494      {
    495         objc_error(nil, OBJC_ERR_BAD_TYPE, "bad array type %s\n", type);
     495        objc_error (nil, OBJC_ERR_BAD_TYPE, "bad array type %s\n", type);
    496496        return 0;
    497497      }
     
    499499  case _C_BFLD:
    500500    /* The new encoding of bitfields is: b 'position' 'type' 'size' */
    501     while (isdigit (*++type));  /* skip position */
    502     while (isdigit (*++type));  /* skip type and size */
     501    while (isdigit ((unsigned char)*++type))
     502      ; /* skip position */
     503    while (isdigit ((unsigned char)*++type))
     504      ; /* skip type and size */
    503505    return type;
    504506
    505507  case _C_STRUCT_B:
    506508    /* skip name, and elements until closing '}'  */
    507    
    508     while (*type != _C_STRUCT_E && *type++ != '=');
    509     while (*type != _C_STRUCT_E) { type = objc_skip_typespec (type); }
     509
     510    while (*type != _C_STRUCT_E && *type++ != '=')
     511      ;
     512    while (*type != _C_STRUCT_E)
     513      {
     514        type = objc_skip_typespec (type);
     515      }
    510516    return ++type;
    511517
    512518  case _C_UNION_B:
    513519    /* skip name, and elements until closing ')'  */
    514    
    515     while (*type != _C_UNION_E && *type++ != '=');
    516     while (*type != _C_UNION_E) { type = objc_skip_typespec (type); }
     520
     521    while (*type != _C_UNION_E && *type++ != '=')
     522      ;
     523    while (*type != _C_UNION_E)
     524      {
     525        type = objc_skip_typespec (type);
     526      }
    517527    return ++type;
    518528
    519529  case _C_PTR:
    520530    /* Just skip the following typespec */
    521    
     531
    522532    return objc_skip_typespec (++type);
    523    
     533
    524534  default:
    525535    {
    526       objc_error(nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type);
     536      objc_error (nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type);
    527537      return 0;
    528538    }
     
    534544  '+' if the argument is passed in registers.
    535545*/
    536 inline const char*
    537 objc_skip_offset (const char* type)
    538 {
    539   if (*type == '+') type++;
    540   while(isdigit(*++type));
     546inline const char *
     547objc_skip_offset (const char *type)
     548{
     549  if (*type == '+')
     550    type++;
     551  while (isdigit ((unsigned char) *++type))
     552    ;
    541553  return type;
    542554}
     
    545557  Skip an argument specification of a method encoding.
    546558*/
    547 const char*
    548 objc_skip_argspec (const char* type)
     559const char *
     560objc_skip_argspec (const char *type)
    549561{
    550562  type = objc_skip_typespec (type);
     
    556568  Return the number of arguments that the method MTH expects.
    557569  Note that all methods need two implicit arguments `self' and
    558   `_cmd'. 
     570  `_cmd'.
    559571*/
    560572int
    561 method_get_number_of_arguments (struct objc_method* mth)
     573method_get_number_of_arguments (struct objc_method *mth)
    562574{
    563575  int i = 0;
    564   const char* type = mth->method_types;
     576  const char *type = mth->method_types;
    565577  while (*type)
    566578    {
     
    578590
    579591int
    580 method_get_sizeof_arguments (struct objc_method* mth)
    581 {
    582   const char* type = objc_skip_typespec (mth->method_types);
     592method_get_sizeof_arguments (struct objc_method *mth)
     593{
     594  const char *type = objc_skip_typespec (mth->method_types);
    583595  return atoi (type);
    584596}
     
    589601
    590602  {
    591     char *datum, *type; 
     603    char *datum, *type;
    592604    for (datum = method_get_first_argument (method, argframe, &type);
    593605         datum; datum = method_get_next_argument (argframe, &type))
     
    600612          {
    601613            if ((flags & _F_IN) == _F_IN)
    602               [portal encodeData: *(char**)datum ofType: ++type];
     614              [portal encodeData: *(char **) datum ofType: ++type];
    603615          }
    604616      }
    605617  }
    606 */ 
    607 
    608 char*
    609 method_get_next_argument (arglist_t argframe,
    610                           const char **type)
     618*/
     619
     620char *
     621method_get_next_argument (arglist_t argframe, const char **type)
    611622{
    612623  const char *t = objc_skip_argspec (*type);
     
    625636
    626637/*
    627   Return a pointer to the value of the first argument of the method 
     638  Return a pointer to the value of the first argument of the method
    628639  described in M with the given argumentframe ARGFRAME.  The type
    629   is returned in TYPE.  type must be passed to successive calls of 
     640  is returned in TYPE.  type must be passed to successive calls of
    630641  method_get_next_argument.
    631642*/
    632 char*
    633 method_get_first_argument (struct objc_method* m,
    634                            arglist_t argframe, 
    635                            const char** type)
     643char *
     644method_get_first_argument (struct objc_method *m,
     645                           arglist_t argframe,
     646                           const char **type)
    636647{
    637648  *type = m->method_types;
     
    642653   Return a pointer to the ARGth argument of the method
    643654   M from the frame ARGFRAME.  The type of the argument
    644    is returned in the value-result argument TYPE 
    645 */
    646 
    647 char*
    648 method_get_nth_argument (struct objc_method* m,
    649                          arglist_t argframe, int arg, 
     655   is returned in the value-result argument TYPE
     656*/
     657
     658char *
     659method_get_nth_argument (struct objc_method *m,
     660                         arglist_t argframe, int arg,
    650661                         const char **type)
    651662{
    652   const char* t = objc_skip_argspec (m->method_types);
     663  const char *t = objc_skip_argspec (m->method_types);
    653664
    654665  if (arg > method_get_number_of_arguments (m))
     
    657668  while (arg--)
    658669    t = objc_skip_argspec (t);
    659  
     670
    660671  *type = t;
    661672  t = objc_skip_typespec (t);
     
    668679
    669680unsigned
    670 objc_get_type_qualifiers (const char* type)
     681objc_get_type_qualifiers (const char *type)
    671682{
    672683  unsigned res = 0;
     
    721732  if (*type++ != _C_STRUCT_B)
    722733    {
    723       objc_error(nil, OBJC_ERR_BAD_TYPE,
     734      objc_error (nil, OBJC_ERR_BAD_TYPE,
    724735                 "record type expected in objc_layout_structure, got %s\n",
    725736                 type);
     
    750761objc_layout_structure_next_member (struct objc_struct_layout *layout)
    751762{
    752   register int known_align = layout->record_size;
    753763  register int desired_align = 0;
    754764
    755765  /* The following are used only if the field is a bitfield */
    756   register const char *bfld_type;
    757   register int bfld_type_size, bfld_type_align, bfld_field_size;
     766  register const char *bfld_type = 0;
     767  register int bfld_type_size, bfld_type_align = 0, bfld_field_size = 0;
    758768
    759769  /* The current type without the type qualifiers */
     
    770780        /* Get the bitfield's type */
    771781        for (bfld_type = type + 1;
    772              isdigit(*bfld_type);
     782             isdigit ((unsigned char)*bfld_type);
    773783             bfld_type++)
    774784          /* do nothing */;
     
    794804
    795805  if (*type != _C_BFLD)
    796     desired_align = objc_alignof_type(type) * BITS_PER_UNIT;
     806    desired_align = objc_alignof_type (type) * BITS_PER_UNIT;
    797807  else
    798808    {
    799809      desired_align = 1;
    800810      /* Skip the bitfield's offset */
    801       for (bfld_type = type + 1; isdigit(*bfld_type); bfld_type++)
     811      for (bfld_type = type + 1;
     812           isdigit ((unsigned char) *bfld_type);
     813           bfld_type++)
    802814        /* do nothing */;
    803815
     
    819831#ifndef PCC_BITFIELD_TYPE_MATTERS
    820832  layout->record_align = MAX (layout->record_align, desired_align);
    821 #else
     833#else   /* PCC_BITFIELD_TYPE_MATTERS */
    822834  if (*type == _C_BFLD)
    823835    {
     
    851863  else
    852864    layout->record_align = MAX (layout->record_align, desired_align);
    853 #endif
     865#endif  /* PCC_BITFIELD_TYPE_MATTERS */
    854866
    855867  /* Does this field automatically have alignment it needs
     
    865877      layout->record_size = ROUND (layout->record_size, desired_align);
    866878    }
    867  
     879
    868880  /* Jump to the next field in record. */
    869881
     
    885897         alignment. */
    886898
    887 #if defined(ROUND_TYPE_ALIGN) && !defined(__sparc__)
     899#if defined (ROUND_TYPE_ALIGN) && ! defined (__sparc__)
    888900      layout->record_align = ROUND_TYPE_ALIGN (layout->original_type,
    889901                                               1,
  • branches/GNU/src/gcc/libobjc/gc.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* Basic data types for Objective C.
    2    Copyright (C) 1998 Free Software Foundation, Inc.
     2   Copyright (C) 1998, 2002 Free Software Foundation, Inc.
    33   Contributed by Ovidiu Predescu.
    44
     
    5959
    6060#define ROUND(V, A) \
    61   ({ typeof(V) __v=(V); typeof(A) __a=(A); \
    62      __a*((__v+__a-1)/__a); })
     61  ({ typeof (V) __v = (V); typeof (A) __a = (A); \
     62     __a * ((__v+__a - 1)/__a); })
    6363
    6464#define SET_BIT_FOR_OFFSET(mask, offset) \
    65   GC_set_bit(mask, offset / sizeof (void*))
     65  GC_set_bit (mask, offset / sizeof (void *))
    6666
    6767/* Some prototypes */
     
    7575__objc_gc_setup_array (GC_bitmap mask, const char *type, int offset)
    7676{
    77   int i, len = atoi(type + 1);
    78 
    79   while (isdigit(*++type))
     77  int i, len = atoi (type + 1);
     78
     79  while (isdigit (*++type))
    8080    /* do nothing */;           /* skip the size of the array */
    8181
     
    139139      case _C_CHARPTR:
    140140      case _C_ATOM:
    141         if (!gc_invisible)
    142           SET_BIT_FOR_OFFSET(mask, position);
     141        if (! gc_invisible)
     142          SET_BIT_FOR_OFFSET (mask, position);
    143143        break;
    144144
     
    179179  align = objc_alignof_type (type);
    180180
    181   offset = ROUND(offset, align);
    182   for (i = 0; i < size; i += sizeof (void*))
    183     {
    184       SET_BIT_FOR_OFFSET(mask, offset);
    185       offset += sizeof (void*);
     181  offset = ROUND (offset, align);
     182  for (i = 0; i < size; i += sizeof (void *))
     183    {
     184      SET_BIT_FOR_OFFSET (mask, offset);
     185      offset += sizeof (void *);
    186186    }
    187187}
     
    224224      case _C_PTR:
    225225      case _C_CHARPTR:
    226         if (!gc_invisible)
    227           SET_BIT_FOR_OFFSET(mask, offset);
     226        if (! gc_invisible)
     227          SET_BIT_FOR_OFFSET (mask, offset);
    228228        break;
    229229
     
    255255{
    256256  int i, ivar_count;
    257   struct objc_ivar_list* ivars;
    258 
    259   if (!class)
     257  struct objc_ivar_list *ivars;
     258
     259  if (! class)
    260260    {
    261261      strcat (*type, "{");
     
    268268
    269269  ivars = class->ivars;
    270   if (!ivars)
     270  if (! ivars)
    271271    return;
    272272
     
    283283          /* Increase the size of the encoding string so that it
    284284             contains this ivar's type. */
    285           *size = ROUND(*current + len + 1, 10);
     285          *size = ROUND (*current + len + 1, 10);
    286286          *type = objc_realloc (*type, *size);
    287287        }
     
    303303  char *class_structure_type;
    304304
    305   if (!CLS_ISCLASS(class))
     305  if (! CLS_ISCLASS (class))
    306306    return;
    307307
     
    312312  /* The number of bits in the mask is the size of an instance in bytes divided
    313313     by the size of a pointer. */
    314   bits_no = (ROUND(class_get_instance_size (class), sizeof(void*))
    315              / sizeof (void*));
    316   size = ROUND(bits_no, BITS_PER_WORD) / BITS_PER_WORD;
     314  bits_no = (ROUND (class_get_instance_size (class), sizeof (void *))
     315             / sizeof (void *));
     316  size = ROUND (bits_no, BITS_PER_WORD) / BITS_PER_WORD;
    317317  mask = objc_atomic_malloc (size * sizeof (int));
    318318  memset (mask, 0, size * sizeof (int));
     
    343343#endif
    344344
    345   class->gc_object_type = (void*)GC_make_descriptor (mask, bits_no);
     345  class->gc_object_type = (void *) GC_make_descriptor (mask, bits_no);
    346346}
    347347
     
    371371   pointers.  */
    372372void
    373 class_ivar_set_gcinvisible (Class class, const char* ivarname,
     373class_ivar_set_gcinvisible (Class class, const char *ivarname,
    374374                            BOOL gc_invisible)
    375375{
    376376  int i, ivar_count;
    377   struct objc_ivar_list* ivars;
    378 
    379   if (!class || !ivarname)
     377  struct objc_ivar_list *ivars;
     378
     379  if (! class || ! ivarname)
    380380    return;
    381381
    382382  ivars = class->ivars;
    383   if (!ivars)
     383  if (! ivars)
    384384    return;
    385385
     
    391391      const char *type;
    392392
    393       if (!ivar->ivar_name || strcmp (ivar->ivar_name, ivarname))
     393      if (! ivar->ivar_name || strcmp (ivar->ivar_name, ivarname))
    394394        continue;
    395395
     
    408408          char *new_type;
    409409
    410           if (gc_invisible || !__objc_ivar_pointer (type))
     410          if (gc_invisible || ! __objc_ivar_pointer (type))
    411411            return;     /* The type of the variable already matches the
    412412                           requested gc_invisible type */
     
    423423          char *new_type;
    424424
    425           if (!gc_invisible || !__objc_ivar_pointer (type))
     425          if (! gc_invisible || ! __objc_ivar_pointer (type))
    426426            return;     /* The type of the variable already matches the
    427427                           requested gc_invisible type */
     
    447447
    448448void
    449 __objc_generate_gc_type_description (Class class)
    450 {
    451 }
    452 
    453 void class_ivar_set_gcinvisible (Class class,
    454                                  const char* ivarname,
    455                                  BOOL gc_invisible)
     449__objc_generate_gc_type_description (Class class __attribute__ ((__unused__)))
     450{
     451}
     452
     453void class_ivar_set_gcinvisible (Class class __attribute__ ((__unused__)),
     454                                 const char *ivarname __attribute__ ((__unused__)),
     455                                 BOOL gc_invisible __attribute__ ((__unused__)))
    456456{
    457457}
  • branches/GNU/src/gcc/libobjc/hash.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    4848  /* Pass me a value greater than 0 and a power of 2.  */
    4949  assert (size);
    50   assert (!(size & (size - 1)));
     50  assert (! (size & (size - 1)));
    5151
    5252  /* Allocate the cache structure.  calloc insures
     
    197197      } else
    198198        prev = node, node = node->next;
    199     } while (!removed && node);
     199    } while (! removed && node);
    200200    assert (removed);
    201201  }
     
    211211  /* If the scan is being started then reset the last node
    212212     visitied pointer and bucket index.  */
    213   if (!node)
     213  if (! node)
    214214    cache->last_bucket  = 0;
    215215
     
    259259      } else
    260260        node = node->next;
    261     } while (!retval && node);
     261    } while (! retval && node);
    262262
    263263  return retval;
  • 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;
  • branches/GNU/src/gcc/libobjc/misc.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* GNU Objective C Runtime Miscellaneous
    2    Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
     2   Copyright (C) 1993, 1994, 1995, 1996, 1997, 2002
     3   Free Software Foundation, Inc.
    34   Contributed by Kresten Krab Thorup
    45
     
    3839/* Trigger an objc error */
    3940void
    40 objc_error(id object, int code, const char* fmt, ...)
     41objc_error (id object, int code, const char *fmt, ...)
    4142{
    4243  va_list ap;
    4344
    44   va_start(ap, fmt);
    45   objc_verror(object, code, fmt, ap);
    46   va_end(ap);
     45  va_start (ap, fmt);
     46  objc_verror (object, code, fmt, ap);
     47  va_end (ap);
    4748}
    4849
    4950/* Trigger an objc error */
    5051void
    51 objc_verror(id object, int code, const char* fmt, va_list ap)
     52objc_verror (id object, int code, const char *fmt, va_list ap)
    5253{
    5354  BOOL result = NO;
     
    5657     Otherwise print to stderr */
    5758  if (_objc_error_handler)
    58     result = (*_objc_error_handler)(object, code, fmt, ap);
     59    result = (*_objc_error_handler) (object, code, fmt, ap);
    5960  else
    6061    vfprintf (stderr, fmt, ap);
     
    6566    return;
    6667  else
    67     abort();
     68    abort ();
    6869}
    6970
    7071/* Set the error handler */
    7172objc_error_handler
    72 objc_set_error_handler(objc_error_handler func)
     73objc_set_error_handler (objc_error_handler func)
    7374{
    7475  objc_error_handler temp = _objc_error_handler;
     
    8586
    8687void *
    87 objc_malloc(size_t size)
     88objc_malloc (size_t size)
    8889{
    89   void* res = (void*) (*_objc_malloc)(size);
    90   if(!res)
    91     objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
     90  void *res = (void *) (*_objc_malloc) (size);
     91  if (! res)
     92    objc_error (nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
    9293  return res;
    9394}
    9495
    9596void *
    96 objc_atomic_malloc(size_t size)
     97objc_atomic_malloc (size_t size)
    9798{
    98   void* res = (void*) (*_objc_atomic_malloc)(size);
    99   if(!res)
    100     objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
     99  void *res = (void *) (*_objc_atomic_malloc) (size);
     100  if (! res)
     101    objc_error (nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
    101102  return res;
    102103}
    103104
    104105void *
    105 objc_valloc(size_t size)
     106objc_valloc (size_t size)
    106107{
    107   void* res = (void*) (*_objc_valloc)(size);
    108   if(!res)
    109     objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
     108  void *res = (void *) (*_objc_valloc) (size);
     109  if (! res)
     110    objc_error (nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
    110111  return res;
    111112}
    112113
    113114void *
    114 objc_realloc(void *mem, size_t size)
     115objc_realloc (void *mem, size_t size)
    115116{
    116   void* res = (void*) (*_objc_realloc)(mem, size);
    117   if(!res)
    118     objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
     117  void *res = (void *) (*_objc_realloc) (mem, size);
     118  if (! res)
     119    objc_error (nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
    119120  return res;
    120121}
    121122
    122123void *
    123 objc_calloc(size_t nelem, size_t size)
     124objc_calloc (size_t nelem, size_t size)
    124125{
    125   void* res = (void*) (*_objc_calloc)(nelem, size);
    126   if(!res)
    127     objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
     126  void *res = (void *) (*_objc_calloc) (nelem, size);
     127  if (! res)
     128    objc_error (nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
    128129  return res;
    129130}
    130131
    131132void
    132 objc_free(void *mem)
     133objc_free (void *mem)
    133134{
    134   (*_objc_free)(mem);
     135  (*_objc_free) (mem);
    135136}
    136137
     
    149150#include <gc.h>
    150151
    151 static void *GC_calloc (size_t nelem, size_t size)
     152static void *
     153GC_calloc (size_t nelem, size_t size)
    152154{
    153   void* p = GC_malloc (nelem * size);
    154   if (!p)
     155  void *p = GC_malloc (nelem * size);
     156  if (! p)
    155157    objc_error (nil, OBJC_ERR_MEMORY, "Virtual memory exhausted!\n");
    156158
     
    159161}
    160162
    161 static void noFree (void* p) {}
     163static void
     164noFree (void *p)
     165{
     166}
    162167
    163 void *(*_objc_malloc)(size_t) = GC_malloc;
    164 void *(*_objc_atomic_malloc)(size_t) = GC_malloc_atomic;
    165 void *(*_objc_valloc)(size_t) = GC_malloc;
    166 void *(*_objc_realloc)(void *, size_t) = GC_realloc;
    167 void *(*_objc_calloc)(size_t, size_t) = GC_calloc;
    168 void (*_objc_free)(void *) = noFree;
     168void *(*_objc_malloc) (size_t) = GC_malloc;
     169void *(*_objc_atomic_malloc) (size_t) = GC_malloc_atomic;
     170void *(*_objc_valloc) (size_t) = GC_malloc;
     171void *(*_objc_realloc) (void *, size_t) = GC_realloc;
     172void *(*_objc_calloc) (size_t, size_t) = GC_calloc;
     173void (*_objc_free) (void *) = noFree;
    169174
    170 #else
     175#else   /* !OBJC_WITH_GC */
    171176
    172 void *(*_objc_malloc)(size_t) = malloc;
    173 void *(*_objc_atomic_malloc)(size_t) = malloc;
    174 void *(*_objc_valloc)(size_t) = malloc;
    175 void *(*_objc_realloc)(void *, size_t) = realloc;
    176 void *(*_objc_calloc)(size_t, size_t) = calloc;
    177 void (*_objc_free)(void *) = free;
     177void *(*_objc_malloc) (size_t) = malloc;
     178void *(*_objc_atomic_malloc) (size_t) = malloc;
     179void *(*_objc_valloc) (size_t) = malloc;
     180void *(*_objc_realloc) (void *, size_t) = realloc;
     181void *(*_objc_calloc) (size_t, size_t) = calloc;
     182void (*_objc_free) (void *) = free;
    178183
    179184
    180 #endif
     185#endif  /* !OBJC_WITH_GC */
  • branches/GNU/src/gcc/libobjc/nil_method.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* GNU Objective C Runtime nil receiver function
    2    Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
     2   Copyright (C) 1993, 1995, 1996, 2002 Free Software Foundation, Inc.
    33   Contributed by Kresten Krab Thorup
    44
     
    3030#include "runtime.h"
    3131
     32/* When the receiver of a method invocation is nil, the runtime
     33   returns nil_method() as the method implementation.  This function
     34   will be casted to whatever function was supposed to be executed to
     35   execute that method (that function will take an id, followed by a
     36   SEL, followed by who knows what arguments, depends on the method),
     37   and executed.
     38   
     39   For this reason, nil_method() should be a function which can be
     40   called in place of any function taking an 'id' argument followed by
     41   a 'SEL' argument, followed by zero, or one, or any number of
     42   arguments (both a fixed number, or a variable number !).
     43   
     44   There is no "proper" implementation of such a nil_method function
     45   in C, however in all existing implementations it does not matter
     46   when extra arguments are present, so we can simply create a function
     47   taking a receiver and a selector, and all other arguments will be
     48   ignored. :-)
     49*/
     50
    3251id
    33 nil_method(id receiver, SEL op, ...)
     52nil_method (id receiver, SEL op __attribute__ ((__unused__)))
    3453{
    3554  return receiver;
    3655}
    37 
    38 
    39 
    40 
  • branches/GNU/src/gcc/libobjc/objc/encoding.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* Encoding of types for Objective C.
    2    Copyright (C) 1993, 1997 Free Software Foundation, Inc.
     2   Copyright (C) 1993, 1997, 2002 Free Software Foundation, Inc.
    33
    44Author: Kresten Krab Thorup
     
    5151#define _F_GCINVISIBLE  0x20
    5252
    53 int objc_aligned_size (const char* type);
    54 int objc_sizeof_type (const char* type);
    55 int objc_alignof_type (const char* type);
    56 int objc_aligned_size (const char* type);
    57 int objc_promoted_size (const char* type);
     53int objc_aligned_size (const char *type);
     54int objc_sizeof_type (const char *type);
     55int objc_alignof_type (const char *type);
     56int objc_aligned_size (const char *type);
     57int objc_promoted_size (const char *type);
    5858
    59 const char* objc_skip_type_qualifiers (const char* type);
    60 const char* objc_skip_typespec (const char* type);
    61 const char* objc_skip_offset (const char* type);
    62 const char* objc_skip_argspec (const char* type);
    63 int method_get_number_of_arguments (struct objc_method*);
    64 int method_get_sizeof_arguments (struct objc_method*);
     59const char *objc_skip_type_qualifiers (const char *type);
     60const char *objc_skip_typespec (const char *type);
     61const char *objc_skip_offset (const char *type);
     62const char *objc_skip_argspec (const char *type);
     63int method_get_number_of_arguments (struct objc_method *);
     64int method_get_sizeof_arguments (struct objc_method *);
    6565
    66 char* method_get_first_argument (struct objc_method*,
     66char *method_get_first_argument (struct objc_method *,
    6767                                 arglist_t argframe,
    68                                  const char** type);
    69 char* method_get_next_argument (arglist_t argframe,
     68                                 const char **type);
     69char *method_get_next_argument (arglist_t argframe,
    7070                                const char **type);
    71 char* method_get_nth_argument (struct objc_method* m,
     71char *method_get_nth_argument (struct objc_method *m,
    7272                               arglist_t argframe,
    7373                               int arg,
    7474                               const char **type);
    7575
    76 unsigned objc_get_type_qualifiers (const char* type);
     76unsigned objc_get_type_qualifiers (const char *type);
    7777
    7878
  • branches/GNU/src/gcc/libobjc/objc/hash.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    6161 * hash_new will have to be casted to this type.
    6262 */
    63 typedef unsigned int (*hash_func_type)(void *, const void *);
     63typedef unsigned int (*hash_func_type) (void *, const void *);
    6464
    6565/*
     
    7070 */
    7171
    72 typedef int (*compare_func_type)(const void *, const void *);
     72typedef int (*compare_func_type) (const void *, const void *);
    7373
    7474
     
    175175       
    176176       
    177   while (*(char*)key) {
    178     ret ^= *(char*)key++ << ctr;
     177  while (*(char *) key) {
     178    ret ^= *(char *) key++ << ctr;
    179179    ctr = (ctr + 1) % sizeof (void *);
    180180  }
     
    188188compare_ptrs (const void *k1, const void *k2)
    189189{
    190   return !(k1 - k2);
     190  return ! (k1 - k2);
    191191}
    192192
     
    201201    return 0;
    202202  else
    203     return !strcmp (k1, k2);
     203    return ! strcmp (k1, k2);
    204204}
    205205
  • branches/GNU/src/gcc/libobjc/objc/objc.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    7474/*
    7575** Definition of method type.  When retrieving the implementation of a
    76 ** method, this is type of the pointer returned
     76** method, this is type of the pointer returned.  The idea of the
     77** definition of IMP is to represent a 'pointer to a general function
     78** taking an id, a SEL, followed by other unspecified arguments'.  You
     79** must always cast an IMP to a pointer to a function taking the
     80** appropriate, specific types for that function, before calling it -
     81** to make sure the appropriate arguments are passed to it.  The code
     82** generated by the compiler to perform method calls automatically
     83** does this cast inside method calls.
    7784*/
    7885typedef id (*IMP)(id, SEL, ...);
  • branches/GNU/src/gcc/libobjc/objc/runtime.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* GNU Objective C Runtime internal declarations
    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
     
    6666
    6767/* Number of selectors stored in each of the selector  tables */
    68 extern int __objc_selector_max_index;
     68extern unsigned int __objc_selector_max_index;
    6969
    7070/* Mutex locking __objc_selector_max_index and its arrays. */
     
    8383SEL  __sel_register_typed_name (const char*, const char*,
    8484                                struct objc_selector*, BOOL is_const);
     85extern void __objc_generate_gc_type_description (Class);
    8586
    8687#endif /* not __objc_runtime_INCLUDE_GNU */
  • branches/GNU/src/gcc/libobjc/objc/thr.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* Thread and mutex controls for Objective C.
    2    Copyright (C) 1996, 1997 Free Software Foundation, Inc.
     2   Copyright (C) 1996, 1997, 2002 Free Software Foundation, Inc.
    33   Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
    44
     
    7575
    7676/* Frontend mutex functions */
    77 objc_mutex_t objc_mutex_allocate(void);
    78 int objc_mutex_deallocate(objc_mutex_t mutex);
    79 int objc_mutex_lock(objc_mutex_t mutex);
    80 int objc_mutex_unlock(objc_mutex_t mutex);
    81 int objc_mutex_trylock(objc_mutex_t mutex);
     77objc_mutex_t objc_mutex_allocate (void);
     78int objc_mutex_deallocate (objc_mutex_t mutex);
     79int objc_mutex_lock (objc_mutex_t mutex);
     80int objc_mutex_unlock (objc_mutex_t mutex);
     81int objc_mutex_trylock (objc_mutex_t mutex);
    8282
    8383/* Frontend condition mutex functions */
    84 objc_condition_t objc_condition_allocate(void);
    85 int objc_condition_deallocate(objc_condition_t condition);
    86 int objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex);
    87 int objc_condition_signal(objc_condition_t condition);
    88 int objc_condition_broadcast(objc_condition_t condition);
     84objc_condition_t objc_condition_allocate (void);
     85int objc_condition_deallocate (objc_condition_t condition);
     86int objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex);
     87int objc_condition_signal (objc_condition_t condition);
     88int objc_condition_broadcast (objc_condition_t condition);
    8989
    9090/* Frontend thread functions */
    91 objc_thread_t objc_thread_detach(SEL selector, id object, id argument);
    92 void objc_thread_yield(void);
    93 int objc_thread_exit(void);
    94 int objc_thread_set_priority(int priority);
    95 int objc_thread_get_priority(void);
    96 void * objc_thread_get_data(void);
    97 int objc_thread_set_data(void *value);
    98 objc_thread_t objc_thread_id(void);
    99 void objc_thread_add(void);
    100 void objc_thread_remove(void);
     91objc_thread_t objc_thread_detach (SEL selector, id object, id argument);
     92void objc_thread_yield (void);
     93int objc_thread_exit (void);
     94int objc_thread_set_priority (int priority);
     95int objc_thread_get_priority (void);
     96void * objc_thread_get_data (void);
     97int objc_thread_set_data (void *value);
     98objc_thread_t objc_thread_id (void);
     99void objc_thread_add (void);
     100void objc_thread_remove (void);
    101101
    102102/*
     
    112112  so it can implement the NSBecomingMultiThreaded notification.
    113113  */
    114 typedef void (*objc_thread_callback)();
    115 objc_thread_callback objc_set_thread_callback(objc_thread_callback func);
     114typedef void (*objc_thread_callback) (void);
     115objc_thread_callback objc_set_thread_callback (objc_thread_callback func);
    116116
    117117/* Backend initialization functions */
    118 int __objc_init_thread_system(void);
    119 int __objc_fini_thread_system(void);
     118int __objc_init_thread_system (void);
     119int __objc_fini_thread_system (void);
    120120
    121121/* Backend mutex functions */
    122 int __objc_mutex_allocate(objc_mutex_t mutex);
    123 int __objc_mutex_deallocate(objc_mutex_t mutex);
    124 int __objc_mutex_lock(objc_mutex_t mutex);
    125 int __objc_mutex_trylock(objc_mutex_t mutex);
    126 int __objc_mutex_unlock(objc_mutex_t mutex);
     122int __objc_mutex_allocate (objc_mutex_t mutex);
     123int __objc_mutex_deallocate (objc_mutex_t mutex);
     124int __objc_mutex_lock (objc_mutex_t mutex);
     125int __objc_mutex_trylock (objc_mutex_t mutex);
     126int __objc_mutex_unlock (objc_mutex_t mutex);
    127127
    128128/* Backend condition mutex functions */
    129 int __objc_condition_allocate(objc_condition_t condition);
    130 int __objc_condition_deallocate(objc_condition_t condition);
    131 int __objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex);
    132 int __objc_condition_broadcast(objc_condition_t condition);
    133 int __objc_condition_signal(objc_condition_t condition);
     129int __objc_condition_allocate (objc_condition_t condition);
     130int __objc_condition_deallocate (objc_condition_t condition);
     131int __objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex);
     132int __objc_condition_broadcast (objc_condition_t condition);
     133int __objc_condition_signal (objc_condition_t condition);
    134134
    135135/* Backend thread functions */
    136 objc_thread_t __objc_thread_detach(void (*func)(void *arg), void *arg);
    137 int __objc_thread_set_priority(int priority);
    138 int __objc_thread_get_priority(void);
    139 void __objc_thread_yield(void);
    140 int __objc_thread_exit(void);
    141 objc_thread_t __objc_thread_id(void);
    142 int __objc_thread_set_data(void *value);
    143 void * __objc_thread_get_data(void);
     136objc_thread_t __objc_thread_detach (void (*func) (void *arg), void *arg);
     137int __objc_thread_set_priority (int priority);
     138int __objc_thread_get_priority (void);
     139void __objc_thread_yield (void);
     140int __objc_thread_exit (void);
     141objc_thread_t __objc_thread_id (void);
     142int __objc_thread_set_data (void *value);
     143void * __objc_thread_get_data (void);
    144144
    145145#endif /* not __thread_INCLUDE_GNU */
  • branches/GNU/src/gcc/libobjc/objects.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    3333#endif
    3434
    35 id __objc_object_alloc(Class);
    36 id __objc_object_dispose(id);
    37 id __objc_object_copy(id);
     35id __objc_object_alloc (Class);
     36id __objc_object_dispose (id);
     37id __objc_object_copy (id);
    3838
    39 id (*_objc_object_alloc)(Class)   = __objc_object_alloc;   /* !T:SINGLE */
    40 id (*_objc_object_dispose)(id)    = __objc_object_dispose; /* !T:SINGLE */
    41 id (*_objc_object_copy)(id)       = __objc_object_copy;    /* !T:SINGLE */
     39id (*_objc_object_alloc) (Class)   = __objc_object_alloc;   /* !T:SINGLE */
     40id (*_objc_object_dispose) (id)    = __objc_object_dispose; /* !T:SINGLE */
     41id (*_objc_object_copy) (id)       = __objc_object_copy;    /* !T:SINGLE */
    4242
    4343id
    44 class_create_instance(Class class)
     44class_create_instance (Class class)
    4545{
    4646  id new = nil;
    4747
    4848#if OBJC_WITH_GC
    49   if (CLS_ISCLASS(class))
    50     new = (id)GC_malloc_explicitly_typed (class->instance_size,
    51                                           class->gc_object_type);
     49  if (CLS_ISCLASS (class))
     50    new = (id) GC_malloc_explicitly_typed (class->instance_size,
     51                                           class->gc_object_type);
    5252#else
    53   if (CLS_ISCLASS(class))
    54     new = (*_objc_object_alloc)(class);
     53  if (CLS_ISCLASS (class))
     54    new = (*_objc_object_alloc) (class);
    5555#endif
    5656
    57   if (new!=nil)
     57  if (new != nil)
    5858    {
    5959      memset (new, 0, class->instance_size);
     
    6464
    6565id
    66 object_copy(id object)
     66object_copy (id object)
    6767{
    68   if ((object!=nil)&&CLS_ISCLASS(object->class_pointer))
    69     return (*_objc_object_copy)(object);
     68  if ((object != nil) && CLS_ISCLASS (object->class_pointer))
     69    return (*_objc_object_copy) (object);
    7070  else
    7171    return nil;
     
    7373
    7474id
    75 object_dispose(id object)
     75object_dispose (id object)
    7676{
    77   if ((object!=nil)&&CLS_ISCLASS(object->class_pointer))
     77  if ((object != nil) && CLS_ISCLASS (object->class_pointer))
    7878    {
    7979      if (_objc_object_dispose)
    80         (*_objc_object_dispose)(object);
     80        (*_objc_object_dispose) (object);
    8181      else
    82         objc_free(object);
     82        objc_free (object);
    8383    }
    8484  return nil;
    8585}
    8686
    87 id __objc_object_alloc(Class class)
     87id __objc_object_alloc (Class class)
    8888{
    89   return (id)objc_malloc(class->instance_size);
     89  return (id) objc_malloc (class->instance_size);
    9090}
    9191
    92 id __objc_object_dispose(id object)
     92id __objc_object_dispose (id object)
    9393{
    94   objc_free(object);
     94  objc_free (object);
    9595  return 0;
    9696}
    9797
    98 id __objc_object_copy(id object)
     98id __objc_object_copy (id object)
    9999{
    100   id copy = class_create_instance(object->class_pointer);
    101   memcpy(copy, object, object->class_pointer->instance_size);
     100  id copy = class_create_instance (object->class_pointer);
     101  memcpy (copy, object, object->class_pointer->instance_size);
    102102  return copy;
    103103}
    104 
    105 
  • branches/GNU/src/gcc/libobjc/sarray.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* Sparse Arrays for Objective C dispatch tables
    2    Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
     2   Copyright (C) 1993, 1995, 1996, 2002 Free Software Foundation, Inc.
    33
    44This file is part of GNU CC.
     
    3535int idxsize = 0;                                        /* !T:MUTEX */
    3636
    37 static void *   first_free_data = NULL;                 /* !T:MUTEX */
     37static void *first_free_data = NULL;                    /* !T:MUTEX */
    3838
    3939#ifdef OBJC_SPARSE2
    40 const char* __objc_sparse2_id = "2 level sparse indices";
    41 #endif
    42 
    43 #ifdef OBJC_SPARSE3
    44 const char* __objc_sparse3_id = "3 level sparse indices";
     40const char *__objc_sparse2_id = "2 level sparse indices";
     41#endif
     42
     43#ifdef OBJC_SPARSE3
     44const char *__objc_sparse3_id = "3 level sparse indices";
    4545#endif
    4646
     
    4848   that were not safe in a multi-threaded environment. */
    4949void
    50 sarray_remove_garbage(void)
     50sarray_remove_garbage (void)
    5151{
    5252  void **vp;
    5353  void *np;
    5454 
    55   objc_mutex_lock(__objc_runtime_mutex);
     55  objc_mutex_lock (__objc_runtime_mutex);
    5656
    5757  vp = first_free_data;
     
    6060  while (vp) {
    6161    np = *vp;
    62     objc_free(vp);
     62    objc_free (vp);
    6363    vp = np;
    6464  }
    6565 
    66   objc_mutex_unlock(__objc_runtime_mutex);
     66  objc_mutex_unlock (__objc_runtime_mutex);
    6767}
    6868
     
    7272
    7373static void
    74 sarray_free_garbage(void *vp)
    75 {
    76   objc_mutex_lock(__objc_runtime_mutex);
     74sarray_free_garbage (void *vp)
     75{
     76  objc_mutex_lock (__objc_runtime_mutex);
    7777 
    7878  if (__objc_runtime_threads_alive == 1) {
    79     objc_free(vp);
     79    objc_free (vp);
    8080    if (first_free_data)
    81       sarray_remove_garbage();
     81      sarray_remove_garbage ();
    8282  }
    8383  else {
     
    8686  }
    8787     
    88   objc_mutex_unlock(__objc_runtime_mutex);
     88  objc_mutex_unlock (__objc_runtime_mutex);
    8989}
    9090
    9191/* sarray_at_put : copies data in such a way as to be thread reader safe. */
    9292void
    93 sarray_at_put(struct sarray* array, sidx index, void* element)
    94 {
    95 #ifdef OBJC_SPARSE3
    96   struct sindex** the_index;
    97   struct sindexnew_index;
    98 #endif
    99   struct sbucket** the_bucket;
    100   struct sbucketnew_bucket;
     93sarray_at_put (struct sarray *array, sidx index, void *element)
     94{
     95#ifdef OBJC_SPARSE3
     96  struct sindex **the_index;
     97  struct sindex *new_index;
     98#endif
     99  struct sbucket **the_bucket;
     100  struct sbucket *new_bucket;
    101101#ifdef OBJC_SPARSE3
    102102  size_t ioffset;
     
    123123#endif /* not PRECOMPUTE_SELECTORS */
    124124
    125   assert(soffset_decode(index) < array->capacity); /* Range check */
     125  assert (soffset_decode (index) < array->capacity); /* Range check */
    126126
    127127#ifdef OBJC_SPARSE3
     
    142142
    143143    /* The index was previously empty, allocate a new */
    144     new_index = (struct sindex*)objc_malloc(sizeof(struct sindex));
    145     memcpy(new_index, array->empty_index, sizeof(struct sindex));
     144    new_index = (struct sindex *) objc_malloc (sizeof (struct sindex));
     145    memcpy (new_index, array->empty_index, sizeof (struct sindex));
    146146    new_index->version.version = array->version.version;
    147147    *the_index = new_index;                     /* Prepared for install. */
     
    152152
    153153    /* This index must be lazy copied */
    154     struct sindex* old_index = *the_index;
    155     new_index = (struct sindex*)objc_malloc(sizeof(struct sindex));
    156     memcpy( new_index, old_index, sizeof(struct sindex));
     154    struct sindex *old_index = *the_index;
     155    new_index = (struct sindex *) objc_malloc (sizeof (struct sindex));
     156    memcpy (new_index, old_index, sizeof (struct sindex));
    157157    new_index->version.version = array->version.version;
    158158    *the_index = new_index;                     /* Prepared for install. */
     
    170170    /* The bucket was previously empty (or something like that), */
    171171    /* allocate a new.  This is the effect of `lazy' allocation */ 
    172     new_bucket = (struct sbucket*)objc_malloc(sizeof(struct sbucket));
    173     memcpy((void *) new_bucket, (const void*)array->empty_bucket,
    174            sizeof(struct sbucket));
     172    new_bucket = (struct sbucket *) objc_malloc (sizeof (struct sbucket));
     173    memcpy ((void *) new_bucket, (const void *) array->empty_bucket,
     174            sizeof (struct sbucket));
    175175    new_bucket->version.version = array->version.version;
    176176    *the_bucket = new_bucket;                   /* Prepared for install. */
     
    181181
    182182    /* Perform lazy copy. */
    183     struct sbucket* old_bucket = *the_bucket;
    184     new_bucket = (struct sbucket*)objc_malloc(sizeof(struct sbucket));
    185     memcpy( new_bucket, old_bucket, sizeof(struct sbucket));
     183    struct sbucket *old_bucket = *the_bucket;
     184    new_bucket = (struct sbucket *) objc_malloc (sizeof (struct sbucket));
     185    memcpy (new_bucket, old_bucket, sizeof (struct sbucket));
    186186    new_bucket->version.version = array->version.version;
    187187    *the_bucket = new_bucket;                   /* Prepared for install. */
     
    194194
    195195void
    196 sarray_at_put_safe(struct sarray* array, sidx index, void* element)
    197 {
    198   if(soffset_decode(index) >= array->capacity)
    199     sarray_realloc(array, soffset_decode(index)+1);
    200   sarray_at_put(array, index, element);
    201 }
    202 
    203 struct sarray*
    204 sarray_new (int size, void* default_element)
    205 {
    206   struct sarray* arr;
    207 #ifdef OBJC_SPARSE3
    208   size_t num_indices = ((size-1)/(INDEX_CAPACITY))+1;
    209   struct sindex ** new_indices;
    210 #else /* OBJC_SPARSE2 */
    211   size_t num_indices = ((size-1)/BUCKET_SIZE)+1;
    212   struct sbucket ** new_buckets;
    213 #endif
    214   int counter;
    215 
    216   assert(size > 0);
     196sarray_at_put_safe (struct sarray *array, sidx index, void *element)
     197{
     198  if (soffset_decode (index) >= array->capacity)
     199    sarray_realloc (array, soffset_decode (index) + 1);
     200  sarray_at_put (array, index, element);
     201}
     202
     203struct sarray *
     204sarray_new (int size, void *default_element)
     205{
     206  struct sarray *arr;
     207#ifdef OBJC_SPARSE3
     208  size_t num_indices = ((size - 1)/(INDEX_CAPACITY)) + 1;
     209  struct sindex **new_indices;
     210#else /* OBJC_SPARSE2 */
     211  size_t num_indices = ((size - 1)/BUCKET_SIZE) + 1;
     212  struct sbucket **new_buckets;
     213#endif
     214  size_t counter;
     215
     216  assert (size > 0);
    217217
    218218  /* Allocate core array */
    219   arr = (struct sarray*) objc_malloc(sizeof(struct sarray));
     219  arr = (struct sarray *) objc_malloc (sizeof (struct sarray));
    220220  arr->version.version = 0;
    221221 
     
    223223#ifdef OBJC_SPARSE3
    224224  arr->capacity = num_indices*INDEX_CAPACITY;
    225   new_indices = (struct sindex**)
    226     objc_malloc(sizeof(struct sindex*)*num_indices);
    227 
    228   arr->empty_index = (struct sindex*) objc_malloc(sizeof(struct sindex));
     225  new_indices = (struct sindex **)
     226    objc_malloc (sizeof (struct sindex *) * num_indices);
     227
     228  arr->empty_index = (struct sindex *) objc_malloc (sizeof (struct sindex));
    229229  arr->empty_index->version.version = 0;
    230230 
     
    235235#else /* OBJC_SPARSE2 */
    236236  arr->capacity = num_indices*BUCKET_SIZE;
    237   new_buckets = (struct sbucket**)
    238     objc_malloc(sizeof(struct sbucket*)*num_indices);
     237  new_buckets = (struct sbucket **)
     238    objc_malloc (sizeof (struct sbucket *) * num_indices);
    239239 
    240240  narrays  += 1;
     
    243243#endif
    244244
    245   arr->empty_bucket = (struct sbucket*) objc_malloc(sizeof(struct sbucket));
     245  arr->empty_bucket = (struct sbucket *) objc_malloc (sizeof (struct sbucket));
    246246  arr->empty_bucket->version.version = 0;
    247247 
     
    249249
    250250  arr->ref_count = 1;
    251   arr->is_copy_of = (struct sarray*)0;
    252  
    253   for (counter=0; counter<BUCKET_SIZE; counter++)
     251  arr->is_copy_of = (struct sarray *) 0;
     252 
     253  for (counter = 0; counter < BUCKET_SIZE; counter++)
    254254    arr->empty_bucket->elems[counter] = default_element;
    255255
    256256#ifdef OBJC_SPARSE3
    257   for (counter=0; counter<INDEX_SIZE; counter++)
     257  for (counter = 0; counter < INDEX_SIZE; counter++)
    258258    arr->empty_index->buckets[counter] = arr->empty_bucket;
    259259
    260   for (counter=0; counter<num_indices; counter++)
     260  for (counter = 0; counter < num_indices; counter++)
    261261    new_indices[counter] = arr->empty_index;
    262262
    263263#else /* OBJC_SPARSE2 */
    264264
    265   for (counter=0; counter<num_indices; counter++)
     265  for (counter = 0; counter < num_indices; counter++)
    266266    new_buckets[counter] = arr->empty_bucket;
    267267
     
    284284
    285285void
    286 sarray_realloc(struct sarray* array, int newsize)
    287 {
    288 #ifdef OBJC_SPARSE3
    289   size_t old_max_index = (array->capacity-1)/INDEX_CAPACITY;
    290   size_t new_max_index = ((newsize-1)/INDEX_CAPACITY);
    291   size_t rounded_size = (new_max_index+1)*INDEX_CAPACITY;
    292 
    293   struct sindex ** new_indices;
    294   struct sindex ** old_indices;
    295  
    296 #else /* OBJC_SPARSE2 */
    297   size_t old_max_index = (array->capacity-1)/BUCKET_SIZE;
    298   size_t new_max_index = ((newsize-1)/BUCKET_SIZE);
    299   size_t rounded_size = (new_max_index+1)*BUCKET_SIZE;
    300 
    301   struct sbucket ** new_buckets;
    302   struct sbucket ** old_buckets;
    303  
    304 #endif
    305 
    306   int counter;
    307 
    308   assert(newsize > 0);
     286sarray_realloc (struct sarray *array, int newsize)
     287{
     288#ifdef OBJC_SPARSE3
     289  size_t old_max_index = (array->capacity - 1)/INDEX_CAPACITY;
     290  size_t new_max_index = ((newsize - 1)/INDEX_CAPACITY);
     291  size_t rounded_size = (new_max_index + 1) * INDEX_CAPACITY;
     292
     293  struct sindex **new_indices;
     294  struct sindex **old_indices;
     295 
     296#else /* OBJC_SPARSE2 */
     297  size_t old_max_index = (array->capacity - 1)/BUCKET_SIZE;
     298  size_t new_max_index = ((newsize - 1)/BUCKET_SIZE);
     299  size_t rounded_size = (new_max_index + 1) * BUCKET_SIZE;
     300
     301  struct sbucket **new_buckets;
     302  struct sbucket **old_buckets;
     303 
     304#endif
     305
     306  size_t counter;
     307
     308  assert (newsize > 0);
    309309
    310310  /* The size is the same, just ignore the request */
    311   if(rounded_size <= array->capacity)
     311  if (rounded_size <= array->capacity)
    312312    return;
    313313
    314   assert(array->ref_count == 1);        /* stop if lazy copied... */
     314  assert (array->ref_count == 1);       /* stop if lazy copied... */
    315315
    316316  /* We are asked to extend the array -- allocate new bucket table, */
    317317  /* and insert empty_bucket in newly allocated places. */
    318   if(rounded_size > array->capacity)
     318  if (rounded_size > array->capacity)
    319319    {
    320320
    321321#ifdef OBJC_SPARSE3
    322322      new_max_index += 4;
    323       rounded_size = (new_max_index+1)*INDEX_CAPACITY;
     323      rounded_size = (new_max_index + 1) * INDEX_CAPACITY;
    324324     
    325325#else /* OBJC_SPARSE2 */
    326326      new_max_index += 4;
    327       rounded_size = (new_max_index+1)*BUCKET_SIZE;
     327      rounded_size = (new_max_index + 1) * BUCKET_SIZE;
    328328#endif
    329329     
     
    334334      /* alloc to force re-read by any concurrent readers. */
    335335      old_indices = array->indices;
    336       new_indices = (struct sindex**)
    337         objc_malloc((new_max_index+1)*sizeof(struct sindex*));
     336      new_indices = (struct sindex **)
     337        objc_malloc ((new_max_index + 1) * sizeof (struct sindex *));
    338338#else /* OBJC_SPARSE2 */
    339339      old_buckets = array->buckets;
    340       new_buckets = (struct sbucket**)
    341         objc_malloc((new_max_index+1)*sizeof(struct sbucket*));
     340      new_buckets = (struct sbucket **)
     341        objc_malloc ((new_max_index + 1) * sizeof (struct sbucket *));
    342342#endif
    343343
    344344      /* copy buckets below old_max_index (they are still valid) */
    345       for(counter = 0; counter <= old_max_index; counter++ ) {
     345      for (counter = 0; counter <= old_max_index; counter++ ) {
    346346#ifdef OBJC_SPARSE3
    347347        new_indices[counter] = old_indices[counter];
     
    353353#ifdef OBJC_SPARSE3
    354354      /* reset entries above old_max_index to empty_bucket */
    355       for(counter = old_max_index+1; counter <= new_max_index; counter++)
     355      for (counter = old_max_index + 1; counter <= new_max_index; counter++)
    356356        new_indices[counter] = array->empty_index;
    357357#else /* OBJC_SPARSE2 */
    358358      /* reset entries above old_max_index to empty_bucket */
    359       for(counter = old_max_index+1; counter <= new_max_index; counter++)
     359      for (counter = old_max_index + 1; counter <= new_max_index; counter++)
    360360        new_buckets[counter] = array->empty_bucket;
    361361#endif
     
    370370#ifdef OBJC_SPARSE3
    371371      /* free the old indices */
    372       sarray_free_garbage(old_indices);
    373 #else /* OBJC_SPARSE2 */
    374       sarray_free_garbage(old_buckets);
     372      sarray_free_garbage (old_indices);
     373#else /* OBJC_SPARSE2 */
     374      sarray_free_garbage (old_buckets);
    375375#endif
    376376     
     
    385385
    386386void
    387 sarray_free(struct sarray* array) {
    388 
    389 #ifdef OBJC_SPARSE3
    390   size_t old_max_index = (array->capacity-1)/INDEX_CAPACITY;
    391   struct sindex ** old_indices;
     387sarray_free (struct sarray *array) {
     388#ifdef OBJC_SPARSE3
     389  size_t old_max_index = (array->capacity - 1)/INDEX_CAPACITY;
     390  struct sindex **old_indices;
    392391#else
    393   size_t old_max_index = (array->capacity-1)/BUCKET_SIZE;
    394   struct sbucket ** old_buckets;
    395 #endif
    396   int counter = 0;
    397 
    398   assert(array->ref_count != 0);        /* Freed multiple times!!! */
    399 
    400   if(--(array->ref_count) != 0) /* There exists copies of me */
     392  size_t old_max_index = (array->capacity - 1)/BUCKET_SIZE;
     393  struct sbucket **old_buckets;
     394#endif
     395  size_t counter = 0;
     396
     397  assert (array->ref_count != 0);       /* Freed multiple times!!! */
     398
     399  if (--(array->ref_count) != 0)        /* There exists copies of me */
    401400    return;
    402401
     
    407406#endif
    408407 
    409   if((array->is_copy_of) && ((array->is_copy_of->ref_count - 1) == 0))
    410     sarray_free(array->is_copy_of);
     408  if ((array->is_copy_of) && ((array->is_copy_of->ref_count - 1) == 0))
     409    sarray_free (array->is_copy_of);
    411410
    412411  /* Free all entries that do not point to empty_bucket */
    413   for(counter = 0; counter <= old_max_index; counter++ ) {
    414 #ifdef OBJC_SPARSE3
    415     struct sindex* idx = old_indices[counter];
    416     if((idx != array->empty_index) &&
     412  for (counter = 0; counter <= old_max_index; counter++ ) {
     413#ifdef OBJC_SPARSE3
     414    struct sindex *idx = old_indices[counter];
     415    if ((idx != array->empty_index) &&
    417416       (idx->version.version == array->version.version)) {
    418417      int c2;
    419       for(c2=0; c2<INDEX_SIZE; c2++) {
    420         struct sbucket* bkt = idx->buckets[c2];
    421         if((bkt != array->empty_bucket) &&
     418      for (c2 = 0; c2 < INDEX_SIZE; c2++) {
     419        struct sbucket *bkt = idx->buckets[c2];
     420        if ((bkt != array->empty_bucket) &&
    422421           (bkt->version.version == array->version.version))
    423422          {
    424             sarray_free_garbage(bkt);
     423            sarray_free_garbage (bkt);
    425424            nbuckets -= 1;
    426425          }
    427426      }
    428       sarray_free_garbage(idx);
     427      sarray_free_garbage (idx);
    429428      nindices -= 1;
    430429    }
    431430#else /* OBJC_SPARSE2 */
    432     struct sbucket* bkt = array->buckets[counter];
     431    struct sbucket *bkt = array->buckets[counter];
    433432    if ((bkt != array->empty_bucket) &&
    434433        (bkt->version.version == array->version.version))
    435434      {
    436         sarray_free_garbage(bkt);
     435        sarray_free_garbage (bkt);
    437436        nbuckets -= 1;
    438437      }
     
    442441#ifdef OBJC_SPARSE3 
    443442  /* free empty_index */
    444   if(array->empty_index->version.version == array->version.version) {
    445     sarray_free_garbage(array->empty_index);
     443  if (array->empty_index->version.version == array->version.version) {
     444    sarray_free_garbage (array->empty_index);
    446445    nindices -= 1;
    447446  }
     
    449448
    450449  /* free empty_bucket */
    451   if(array->empty_bucket->version.version == array->version.version) {
    452     sarray_free_garbage(array->empty_bucket);
     450  if (array->empty_bucket->version.version == array->version.version) {
     451    sarray_free_garbage (array->empty_bucket);
    453452    nbuckets -= 1;
    454453  }
    455   idxsize -= (old_max_index+1);
     454  idxsize -= (old_max_index + 1);
    456455  narrays -= 1;
    457456
    458457#ifdef OBJC_SPARSE3
    459458  /* free bucket table */
    460   sarray_free_garbage(array->indices);
     459  sarray_free_garbage (array->indices);
    461460
    462461#else
    463462  /* free bucket table */
    464   sarray_free_garbage(array->buckets);
     463  sarray_free_garbage (array->buckets);
    465464
    466465#endif
    467466 
    468467  /* free array */
    469   sarray_free_garbage(array);
     468  sarray_free_garbage (array);
    470469}
    471470
     
    473472/* copied.   */
    474473
    475 struct sarray*
    476 sarray_lazy_copy(struct sarray* oarr)
    477 {
    478   struct sarray* arr;
    479 
    480 #ifdef OBJC_SPARSE3
    481   size_t num_indices = ((oarr->capacity-1)/INDEX_CAPACITY)+1;
    482   struct sindex ** new_indices;
    483 #else /* OBJC_SPARSE2 */
    484   size_t num_indices = ((oarr->capacity-1)/BUCKET_SIZE)+1;
    485   struct sbucket ** new_buckets;
     474struct sarray *
     475sarray_lazy_copy (struct sarray *oarr)
     476{
     477  struct sarray *arr;
     478
     479#ifdef OBJC_SPARSE3
     480  size_t num_indices = ((oarr->capacity - 1)/INDEX_CAPACITY) + 1;
     481  struct sindex **new_indices;
     482#else /* OBJC_SPARSE2 */
     483  size_t num_indices = ((oarr->capacity - 1)/BUCKET_SIZE) + 1;
     484  struct sbucket **new_buckets;
    486485#endif
    487486
    488487  /* Allocate core array */
    489   arr = (struct sarray*) objc_malloc(sizeof(struct sarray)); /* !!! */
     488  arr = (struct sarray *) objc_malloc (sizeof (struct sarray)); /* !!! */
    490489  arr->version.version = oarr->version.version + 1;
    491490#ifdef OBJC_SPARSE3
     
    500499#ifdef OBJC_SPARSE3
    501500  /* Copy bucket table */
    502   new_indices = (struct sindex**)
    503     objc_malloc(sizeof(struct sindex*)*num_indices);
    504   memcpy( new_indices,oarr->indices,
    505         sizeof(struct sindex*)*num_indices);
     501  new_indices = (struct sindex **)
     502    objc_malloc (sizeof (struct sindex *) * num_indices);
     503  memcpy (new_indices, oarr->indices, sizeof (struct sindex *) * num_indices);
    506504  arr->indices = new_indices;
    507505#else
    508506  /* Copy bucket table */
    509   new_buckets = (struct sbucket**)
    510     objc_malloc(sizeof(struct sbucket*)*num_indices);
    511   memcpy( new_buckets,oarr->buckets,
    512         sizeof(struct sbucket*)*num_indices);
     507  new_buckets = (struct sbucket **)
     508    objc_malloc (sizeof (struct sbucket *) * num_indices);
     509  memcpy (new_buckets, oarr->buckets, sizeof (struct sbucket *) * num_indices);
    513510  arr->buckets = new_buckets;
    514511#endif
  • branches/GNU/src/gcc/libobjc/selector.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* GNU Objective C Runtime selector related functions
    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
     
    3232
    3333/* Tables mapping selector names to uid and opposite */
    34 static struct sarray* __objc_selector_array = 0; /* uid -> sel  !T:MUTEX */
    35 static struct sarray* __objc_selector_names = 0; /* uid -> name !T:MUTEX */
     34static struct sarray *__objc_selector_array = 0; /* uid -> sel  !T:MUTEX */
     35static struct sarray *__objc_selector_names = 0; /* uid -> name !T:MUTEX */
    3636static cache_ptr      __objc_selector_hash  = 0; /* name -> uid !T:MUTEX */
    3737
    38 static void register_selectors_from_list(MethodList_t);
     38static void register_selectors_from_list (MethodList_t);
    3939
    4040/* Number of selectors stored in each of the above tables */
    41 int __objc_selector_max_index = 0;              /* !T:MUTEX */
    42 
    43 void __objc_init_selector_tables()
     41unsigned int __objc_selector_max_index = 0;     /* !T:MUTEX */
     42
     43void __objc_init_selector_tables ()
    4444{
    4545  __objc_selector_array = sarray_new (SELECTOR_HASH_SIZE, 0);
     
    8282      Method_t method = &method_list->method_list[i];
    8383      method->method_name
    84         = sel_register_typed_name ((const char*)method->method_name,
    85                                      method->method_types);
     84        = sel_register_typed_name ((const char *) method->method_name,
     85                                   method->method_types);
    8686      i += 1;
    8787    }
     
    9090
    9191/* Register instance methods as class methods for root classes */
    92 void __objc_register_instance_methods_to_class(Class class)
     92void __objc_register_instance_methods_to_class (Class class)
    9393{
    9494  MethodList_t method_list;
     
    9999
    100100  /* Only if a root class. */
    101   if(class->super_class)
     101  if (class->super_class)
    102102    return;
    103103
    104104  /* Allocate a method list to hold the new class methods */
    105   new_list = objc_calloc(sizeof(struct objc_method_list)
    106                             + sizeof(struct objc_method[max_methods_no]), 1);
     105  new_list = objc_calloc (sizeof (struct objc_method_list)
     106                            + sizeof (struct objc_method[max_methods_no]), 1);
    107107  method_list = class->methods;
    108108  class_method_list = class->class_pointer->methods;
     
    119119          Method_t mth = &method_list->method_list[i];
    120120          if (mth->method_name
    121               && !search_for_method_in_list (class_method_list,
     121              && ! search_for_method_in_list (class_method_list,
    122122                                              mth->method_name))
    123123            {
     
    127127 
    128128              /* Reallocate the method list if necessary */
    129               if(++new_list->method_count == max_methods_no)
     129              if (++new_list->method_count == max_methods_no)
    130130                new_list =
    131                   objc_realloc(new_list, sizeof(struct objc_method_list)
    132                                 + sizeof(struct
     131                  objc_realloc (new_list, sizeof (struct objc_method_list)
     132                                + sizeof (struct
    133133                                        objc_method[max_methods_no += 16]));
    134134              curr_method = &new_list->method_list[new_list->method_count];
     
    144144    {
    145145      new_list =
    146         objc_realloc(new_list, sizeof(struct objc_method_list)
    147                      + sizeof(struct objc_method[new_list->method_count]));
     146        objc_realloc (new_list, sizeof (struct objc_method_list)
     147                     + sizeof (struct objc_method[new_list->method_count]));
    148148      new_list->method_next = class->class_pointer->methods;
    149149      class->class_pointer->methods = new_list;
     
    157157   the argframe layout */
    158158BOOL
    159 sel_types_match (const char* t1, const char* t2)
    160 {
    161   if (!t1 || !t2)
     159sel_types_match (const char *t1, const char *t2)
     160{
     161  if (! t1 || ! t2)
    162162    return NO;
    163163  while (*t1 && *t2)
     
    165165      if (*t1 == '+') t1++;
    166166      if (*t2 == '+') t2++;
    167       while (isdigit(*t1)) t1++;
    168       while (isdigit(*t2)) t2++;
     167      while (isdigit ((unsigned char) *t1)) t1++;
     168      while (isdigit ((unsigned char) *t2)) t2++;
    169169      /* xxx Remove these next two lines when qualifiers are put in
    170170         all selectors, not just Protocol selectors. */
    171       t1 = objc_skip_type_qualifiers(t1);
    172       t2 = objc_skip_type_qualifiers(t2);
    173       if (!*t1 && !*t2)
     171      t1 = objc_skip_type_qualifiers (t1);
     172      t2 = objc_skip_type_qualifiers (t2);
     173      if (! *t1 && ! *t2)
    174174        return YES;
    175175      if (*t1 != *t2)
     
    188188  sidx i;
    189189
    190   objc_mutex_lock(__objc_runtime_mutex);
     190  objc_mutex_lock (__objc_runtime_mutex);
    191191
    192192  i = (sidx) hash_value_for_key (__objc_selector_hash, name);
    193193  if (i == 0)
    194194    {
    195       objc_mutex_unlock(__objc_runtime_mutex);
     195      objc_mutex_unlock (__objc_runtime_mutex);
    196196      return 0;
    197197    }
    198198
    199   for (l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i);
     199  for (l = (struct objc_list *) sarray_get_safe (__objc_selector_array, i);
    200200       l; l = l->tail)
    201201    {
    202       SEL s = (SEL)l->head;
     202      SEL s = (SEL) l->head;
    203203      if (types == 0 || s->sel_types == 0)
    204204        {
    205205          if (s->sel_types == types)
    206206            {
    207               objc_mutex_unlock(__objc_runtime_mutex);
     207              objc_mutex_unlock (__objc_runtime_mutex);
    208208              return s;
    209209            }
     
    211211      else if (sel_types_match (s->sel_types, types))
    212212        {
    213           objc_mutex_unlock(__objc_runtime_mutex);
     213          objc_mutex_unlock (__objc_runtime_mutex);
    214214          return s;
    215215        }
    216216    }
    217217
    218   objc_mutex_unlock(__objc_runtime_mutex);
     218  objc_mutex_unlock (__objc_runtime_mutex);
    219219  return 0;
    220220}
     
    228228  SEL s = NULL;
    229229
    230   objc_mutex_lock(__objc_runtime_mutex);
     230  objc_mutex_lock (__objc_runtime_mutex);
    231231
    232232  i = (sidx) hash_value_for_key (__objc_selector_hash, name);
    233233  if (i == 0)
    234234    {
    235       objc_mutex_unlock(__objc_runtime_mutex);
     235      objc_mutex_unlock (__objc_runtime_mutex);
    236236      return 0;
    237237    }
    238238
    239   for (l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i);
     239  for (l = (struct objc_list *) sarray_get_safe (__objc_selector_array, i);
    240240       l; l = l->tail)
    241241    {
     
    243243      if (s->sel_types)
    244244        {
    245             objc_mutex_unlock(__objc_runtime_mutex);
     245            objc_mutex_unlock (__objc_runtime_mutex);
    246246            return s;
    247247        }
    248248    }
    249249
    250   objc_mutex_unlock(__objc_runtime_mutex);
     250  objc_mutex_unlock (__objc_runtime_mutex);
    251251  return s;
    252252}
     
    259259  sidx i;
    260260
    261   objc_mutex_lock(__objc_runtime_mutex);
     261  objc_mutex_lock (__objc_runtime_mutex);
    262262
    263263  i = (sidx) hash_value_for_key (__objc_selector_hash, name);
    264264  if (soffset_decode (i) == 0)
    265265    {
    266       objc_mutex_unlock(__objc_runtime_mutex);
     266      objc_mutex_unlock (__objc_runtime_mutex);
    267267      return 0;
    268268    }
    269269
    270   l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i);
    271   objc_mutex_unlock(__objc_runtime_mutex);
     270  l = (struct objc_list *) sarray_get_safe (__objc_selector_array, i);
     271  objc_mutex_unlock (__objc_runtime_mutex);
    272272
    273273  if (l == 0)
    274274    return 0;
    275275
    276   return (SEL)l->head;
     276  return (SEL) l->head;
    277277}
    278278
     
    286286/* Get name of selector.  If selector is unknown, the empty string ""
    287287   is returned */
    288 const char*
    289 sel_get_name (SEL selector)
     288const char *sel_get_name (SEL selector)
    290289{
    291290  const char *ret;
    292291
    293   objc_mutex_lock(__objc_runtime_mutex);
    294   if ((soffset_decode((sidx)selector->sel_id) > 0)
    295       && (soffset_decode((sidx)selector->sel_id) <= __objc_selector_max_index))
     292  objc_mutex_lock (__objc_runtime_mutex);
     293  if ((soffset_decode ((sidx)selector->sel_id) > 0)
     294      && (soffset_decode ((sidx)selector->sel_id) <= __objc_selector_max_index))
    296295    ret = sarray_get_safe (__objc_selector_names, (sidx) selector->sel_id);
    297296  else
    298297    ret = 0;
    299   objc_mutex_unlock(__objc_runtime_mutex);
     298  objc_mutex_unlock (__objc_runtime_mutex);
    300299  return ret;
    301300}
     
    309308
    310309
    311 const char*
    312 sel_get_type (SEL selector)
     310const char *sel_get_type (SEL selector)
    313311{
    314312  if (selector)
     
    319317
    320318/* The uninstalled dispatch table */
    321 extern struct sarray* __objc_uninstalled_dtable;
     319extern struct sarray *__objc_uninstalled_dtable;
    322320
    323321/* Store the passed selector name in the selector record and return its
     
    332330                           struct objc_selector *orig, BOOL is_const)
    333331{
    334   struct objc_selector* j;
     332  struct objc_selector *j;
    335333  sidx i;
    336334  struct objc_list *l;
     
    339337  if (soffset_decode (i) != 0)
    340338    {
    341       for (l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i);
     339      for (l = (struct objc_list *) sarray_get_safe (__objc_selector_array, i);
    342340           l; l = l->tail)
    343341        {
    344           SEL s = (SEL)l->head;
     342          SEL s = (SEL) l->head;
    345343          if (types == 0 || s->sel_types == 0)
    346344            {
     
    349347                  if (orig)
    350348                    {
    351                       orig->sel_id = (void*)i;
     349                      orig->sel_id = (void *) i;
    352350                      return orig;
    353351                    }
     
    356354                }
    357355            }
    358           else if (!strcmp (s->sel_types, types))
     356          else if (! strcmp (s->sel_types, types))
    359357            {
    360358              if (orig)
    361359                {
    362                   orig->sel_id = (void*)i;
     360                  orig->sel_id = (void *) i;
    363361                  return orig;
    364362                }
     
    372370        j = objc_malloc (sizeof (struct objc_selector));
    373371
    374       j->sel_id = (void*)i;
     372      j->sel_id = (void *) i;
    375373      /* Can we use the pointer or must copy types?  Don't copy if NULL */
    376374      if ((is_const) || (types == 0))
    377         j->sel_types = (const char*)types;
     375        j->sel_types = (const char *) types;
    378376      else {
    379         j->sel_types = (char *) objc_malloc(strlen(types)+1);
    380         strcpy((char *)j->sel_types, types);
     377        j->sel_types = (char *) objc_malloc (strlen (types) + 1);
     378        strcpy ((char *) j->sel_types, types);
    381379      }
    382       l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i);
     380      l = (struct objc_list *) sarray_get_safe (__objc_selector_array, i);
    383381    }
    384382  else
    385383    {
    386384      __objc_selector_max_index += 1;
    387       i = soffset_encode(__objc_selector_max_index);
     385      i = soffset_encode (__objc_selector_max_index);
    388386      if (orig)
    389387        j = orig;
     
    391389        j = objc_malloc (sizeof (struct objc_selector));
    392390       
    393       j->sel_id = (void*)i;
     391      j->sel_id = (void *) i;
    394392      /* Can we use the pointer or must copy types?  Don't copy if NULL */
    395393      if ((is_const) || (types == 0))
    396         j->sel_types = (const char*)types;
     394        j->sel_types = (const char *) types;
    397395      else {
    398         j->sel_types = (char *) objc_malloc(strlen(types)+1);
    399         strcpy((char *)j->sel_types, types);
     396        j->sel_types = (char *) objc_malloc (strlen (types) + 1);
     397        strcpy ((char *) j->sel_types, types);
    400398      }
    401399      l = 0;
     
    413411      new_name = name;
    414412    else {
    415       new_name = (char *) objc_malloc(strlen(name)+1);
    416       strcpy((char *)new_name, name);
    417     }
    418 
    419     l = list_cons ((void*)j, l);
     413      new_name = (char *) objc_malloc (strlen (name) + 1);
     414      strcpy ((char *) new_name, name);
     415    }
     416
     417    l = list_cons ((void *) j, l);
    420418    sarray_at_put_safe (__objc_selector_names, i, (void *) new_name);
    421419    sarray_at_put_safe (__objc_selector_array, i, (void *) l);
     
    424422  }
    425423
    426   sarray_realloc(__objc_uninstalled_dtable, __objc_selector_max_index+1);
     424  sarray_realloc (__objc_uninstalled_dtable, __objc_selector_max_index + 1);
    427425
    428426  return (SEL) j;
     
    434432  SEL ret;
    435433   
    436   objc_mutex_lock(__objc_runtime_mutex);
     434  objc_mutex_lock (__objc_runtime_mutex);
    437435  /* Assume that name is not constant static memory and needs to be
    438436     copied before put into a runtime structure.  is_const == NO */
    439437  ret = __sel_register_typed_name (name, 0, 0, NO);
    440   objc_mutex_unlock(__objc_runtime_mutex);
     438  objc_mutex_unlock (__objc_runtime_mutex);
    441439 
    442440  return ret;
     
    448446  SEL ret;
    449447   
    450   objc_mutex_lock(__objc_runtime_mutex);
     448  objc_mutex_lock (__objc_runtime_mutex);
    451449  /* Assume that name and type are not constant static memory and need to
    452450     be copied before put into a runtime structure.  is_const == NO */
    453451  ret = __sel_register_typed_name (name, type, 0, NO);
    454   objc_mutex_unlock(__objc_runtime_mutex);
     452  objc_mutex_unlock (__objc_runtime_mutex);
    455453 
    456454  return ret;
    457455}
    458 
  • branches/GNU/src/gcc/libobjc/sendmsg.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* GNU Objective C Runtime message lookup
    22   Copyright (C) 1993, 1995, 1996, 1997, 1998,
    3    2001 Free Software Foundation, Inc.
     3   2001, 2002 Free Software Foundation, Inc.
    44   Contributed by Kresten Krab Thorup
    55
     
    3838#define rtx int
    3939
    40 #if !defined(STRUCT_VALUE) || STRUCT_VALUE == 0
     40#if ! defined (STRUCT_VALUE) || STRUCT_VALUE == 0
    4141#define INVISIBLE_STRUCT_RETURN 1
    4242#else
     
    4545
    4646/* The uninstalled dispatch table */
    47 struct sarray* __objc_uninstalled_dtable = 0;   /* !T:MUTEX */
     47struct sarray *__objc_uninstalled_dtable = 0;   /* !T:MUTEX */
    4848
    4949/* Hook for method forwarding. If it is set, is invoked to return a
    5050   function that performs the real forwarding. Otherwise the libgcc
    5151   based functions (__builtin_apply and friends) are used. */
    52 IMP (*__objc_msg_forward)(SEL) = NULL;
     52IMP (*__objc_msg_forward) (SEL) = NULL;
    5353
    5454/* Send +initialize to class */
    55 static void __objc_send_initialize(Class);
     55static void __objc_send_initialize (Class);
    5656
    5757static void __objc_install_dispatch_table_for_class (Class);
    5858
    5959/* Forward declare some functions */
    60 static void __objc_init_install_dtable(id, SEL);
     60static void __objc_init_install_dtable (id, SEL);
    6161
    6262/* Various forwarding functions that are used based upon the
     
    6666   __objc_word_forward for pointers or types that fit in registers.
    6767   */
    68 static double __objc_double_forward(id, SEL, ...);
    69 static id __objc_word_forward(id, SEL, ...);
     68static double __objc_double_forward (id, SEL, ...);
     69static id __objc_word_forward (id, SEL, ...);
    7070typedef struct { id many[8]; } __big;
    7171#if INVISIBLE_STRUCT_RETURN
     
    7474static id
    7575#endif
    76 __objc_block_forward(id, SEL, ...);
     76__objc_block_forward (id, SEL, ...);
    7777static Method_t search_for_method_in_hierarchy (Class class, SEL sel);
    78 Method_t search_for_method_in_list(MethodList_t list, SEL op);
    79 id nil_method(id, SEL, ...);
     78Method_t search_for_method_in_list (MethodList_t list, SEL op);
     79id nil_method (id, SEL);
    8080
    8181/* Given a selector, return the proper forwarding implementation. */
     
    8484__objc_get_forward_imp (SEL sel)
    8585{
     86  /* If a custom forwarding hook was registered, try getting a forwarding
     87   * function from it.  */
    8688  if (__objc_msg_forward)
    8789    {
    8890      IMP result;
    89       if ((result = __objc_msg_forward (sel)))
     91      if ((result = __objc_msg_forward (sel)) != NULL)
    9092        return result;
    9193    }
    92   else
     94
     95  /* In all other cases, use the default forwarding functions built using
     96   * __builtin_apply and friends.  */
    9397    {
    9498      const char *t = sel->sel_types;
     
    96100      if (t && (*t == '[' || *t == '(' || *t == '{')
    97101#ifdef OBJC_MAX_STRUCT_BY_VALUE
    98           && objc_sizeof_type(t) > OBJC_MAX_STRUCT_BY_VALUE
     102          && objc_sizeof_type (t) > OBJC_MAX_STRUCT_BY_VALUE
    99103#endif
    100104          )
     
    112116get_imp (Class class, SEL sel)
    113117{
    114   void* res = sarray_get_safe (class->dtable, (size_t) sel->sel_id);
     118  void *res = sarray_get_safe (class->dtable, (size_t) sel->sel_id);
    115119  if (res == 0)
    116120    {
    117121      /* Not a valid method */
    118       if(class->dtable == __objc_uninstalled_dtable)
     122      if (class->dtable == __objc_uninstalled_dtable)
    119123        {
    120124          /* The dispatch table needs to be installed. */
    121           objc_mutex_lock(__objc_runtime_mutex);
     125          objc_mutex_lock (__objc_runtime_mutex);
    122126          __objc_install_dispatch_table_for_class (class);
    123           objc_mutex_unlock(__objc_runtime_mutex);
     127          objc_mutex_unlock (__objc_runtime_mutex);
    124128          /* Call ourselves with the installed dispatch table
    125129             and get the real method */
    126           res = get_imp(class, sel);
     130          res = get_imp (class, sel);
    127131        }
    128132      else
     
    131135             method just doesn't exist for the class.
    132136             Return the forwarding implementation. */
    133           res = __objc_get_forward_imp(sel);
     137          res = __objc_get_forward_imp (sel);
    134138        }
    135139    }
     
    144148__objc_responds_to (id object, SEL sel)
    145149{
    146   void* res;
     150  void *res;
    147151
    148152  /* Install dispatch table if need be */
    149153  if (object->class_pointer->dtable == __objc_uninstalled_dtable)
    150154    {
    151       objc_mutex_lock(__objc_runtime_mutex);
     155      objc_mutex_lock (__objc_runtime_mutex);
    152156      __objc_install_dispatch_table_for_class (object->class_pointer);
    153       objc_mutex_unlock(__objc_runtime_mutex);
     157      objc_mutex_unlock (__objc_runtime_mutex);
    154158    }
    155159
     
    164168__inline__
    165169IMP
    166 objc_msg_lookup(id receiver, SEL op)
     170objc_msg_lookup (id receiver, SEL op)
    167171{
    168172  IMP result;
    169   if(receiver)
     173  if (receiver)
    170174    {
    171175      result = sarray_get_safe (receiver->class_pointer->dtable,
     
    174178        {
    175179          /* Not a valid method */
    176           if(receiver->class_pointer->dtable == __objc_uninstalled_dtable)
     180          if (receiver->class_pointer->dtable == __objc_uninstalled_dtable)
    177181            {
    178182              /* The dispatch table needs to be installed.
    179183                 This happens on the very first method call to the class. */
    180               __objc_init_install_dtable(receiver, op);
     184              __objc_init_install_dtable (receiver, op);
    181185
    182186              /* Get real method for this in newly installed dtable */
    183               result = get_imp(receiver->class_pointer, op);
     187              result = get_imp (receiver->class_pointer, op);
    184188            }
    185189          else
     
    188192                 method just doesn't exist for the class.
    189193                 Attempt to forward the method. */
    190               result = __objc_get_forward_imp(op);
     194              result = __objc_get_forward_imp (op);
    191195            }
    192196        }
     
    194198    }
    195199  else
    196     return nil_method;
     200    return (IMP)nil_method;
    197201}
    198202
     
    203207    return get_imp (super->class, sel);
    204208  else
    205     return nil_method;
    206 }
    207 
    208 int method_get_sizeof_arguments (Method*);
     209    return (IMP)nil_method;
     210}
     211
     212int method_get_sizeof_arguments (Method *);
    209213
    210214retval_t
    211 objc_msg_sendv(id object, SEL op, arglist_t arg_frame)
    212 {
    213   Method* m = class_get_instance_method(object->class_pointer, op);
     215objc_msg_sendv (id object, SEL op, arglist_t arg_frame)
     216{
     217  Method *m = class_get_instance_method (object->class_pointer, op);
    214218  const char *type;
    215   *((id*)method_get_first_argument (m, arg_frame, &type)) = object;
    216   *((SEL*)method_get_next_argument (arg_frame, &type)) = op;
    217   return __builtin_apply((apply_t)m->method_imp,
    218                          arg_frame,
    219                          method_get_sizeof_arguments (m));
     219  *((id *) method_get_first_argument (m, arg_frame, &type)) = object;
     220  *((SEL *) method_get_next_argument (arg_frame, &type)) = op;
     221  return __builtin_apply ((apply_t) m->method_imp,
     222                          arg_frame,
     223                          method_get_sizeof_arguments (m));
    220224}
    221225
    222226void
    223 __objc_init_dispatch_tables()
    224 {
    225   __objc_uninstalled_dtable
    226     = sarray_new(200, 0);
     227__objc_init_dispatch_tables ()
     228{
     229  __objc_uninstalled_dtable = sarray_new (200, 0);
    227230}
    228231
     
    231234   for each class, namely when the very first message is sent to it. */
    232235static void
    233 __objc_init_install_dtable(id receiver, SEL op)
     236__objc_init_install_dtable (id receiver, SEL op __attribute__ ((__unused__)))
    234237{
    235238  /* This may happen, if the programmer has taken the address of a
    236239     method before the dtable was initialized... too bad for him! */
    237   if(receiver->class_pointer->dtable != __objc_uninstalled_dtable)
     240  if (receiver->class_pointer->dtable != __objc_uninstalled_dtable)
    238241    return;
    239242
    240   objc_mutex_lock(__objc_runtime_mutex);
    241 
    242   if(CLS_ISCLASS(receiver->class_pointer))
     243  objc_mutex_lock (__objc_runtime_mutex);
     244
     245  if (CLS_ISCLASS (receiver->class_pointer))
    243246    {
    244247      /* receiver is an ordinary object */
    245       assert(CLS_ISCLASS(receiver->class_pointer));
     248      assert (CLS_ISCLASS (receiver->class_pointer));
    246249
    247250      /* install instance methods table */
     
    250253      /* call +initialize -- this will in turn install the factory
    251254         dispatch table if not already done :-) */
    252       __objc_send_initialize(receiver->class_pointer);
     255      __objc_send_initialize (receiver->class_pointer);
    253256    }
    254257  else
    255258    {
    256259      /* receiver is a class object */
    257       assert(CLS_ISCLASS((Class)receiver));
    258       assert(CLS_ISMETA(receiver->class_pointer));
     260      assert (CLS_ISCLASS ((Class)receiver));
     261      assert (CLS_ISMETA (receiver->class_pointer));
    259262
    260263      /* Install real dtable for factory methods */
    261264      __objc_install_dispatch_table_for_class (receiver->class_pointer);
    262265
    263       __objc_send_initialize((Class)receiver);
    264     }
    265   objc_mutex_unlock(__objc_runtime_mutex);
     266      __objc_send_initialize ((Class)receiver);
     267    }
     268  objc_mutex_unlock (__objc_runtime_mutex);
    266269}
    267270
     
    269272   that class (or instances hereof) to be initialized properly */
    270273void
    271 __objc_install_premature_dtable(Class class)
    272 {
    273   assert(__objc_uninstalled_dtable);
     274__objc_install_premature_dtable (Class class)
     275{
     276  assert (__objc_uninstalled_dtable);
    274277  class->dtable = __objc_uninstalled_dtable;
    275278}   
     
    277280/* Send +initialize to class if not already done */
    278281static void
    279 __objc_send_initialize(Class class)
     282__objc_send_initialize (Class class)
    280283{
    281284  /* This *must* be a class object */
    282   assert(CLS_ISCLASS(class));
    283   assert(!CLS_ISMETA(class));
    284 
    285   if (!CLS_ISINITIALIZED(class))
    286     {
    287       CLS_SETINITIALIZED(class);
    288       CLS_SETINITIALIZED(class->class_pointer);
     285  assert (CLS_ISCLASS (class));
     286  assert (! CLS_ISMETA (class));
     287
     288  if (! CLS_ISINITIALIZED (class))
     289    {
     290      CLS_SETINITIALIZED (class);
     291      CLS_SETINITIALIZED (class->class_pointer);
    289292
    290293      /* Create the garbage collector type memory description */
    291294      __objc_generate_gc_type_description (class);
    292295
    293       if(class->super_class)
    294         __objc_send_initialize(class->super_class);
     296      if (class->super_class)
     297        __objc_send_initialize (class->super_class);
    295298
    296299      {
     
    303306          Method_t method;
    304307
    305           for (i = 0; i< method_list->method_count; i++) {
     308          for (i = 0; i < method_list->method_count; i++) {
    306309            method = &(method_list->method_list[i]);
    307310            if (method->method_name
     
    319322        }
    320323        if (imp)
    321             (*imp)((id)class, op);
     324            (*imp) ((id) class, op);
    322325               
    323326      }
     
    336339  int i;
    337340
    338   if (!method_list)
     341  if (! method_list)
    339342    return;
    340343
     
    359362  /* If the class has not yet had its class links resolved, we must
    360363     re-compute all class links */
    361   if(!CLS_ISRESOLV(class))
    362     __objc_resolve_class_links();
     364  if (! CLS_ISRESOLV (class))
     365    __objc_resolve_class_links ();
    363366
    364367  super = class->super_class;
     
    370373  if (super == 0)
    371374    {
    372       objc_mutex_lock(__objc_runtime_mutex);
     375      objc_mutex_lock (__objc_runtime_mutex);
    373376      class->dtable = sarray_new (__objc_selector_max_index, 0);
    374       objc_mutex_unlock(__objc_runtime_mutex);
     377      objc_mutex_unlock (__objc_runtime_mutex);
    375378    }
    376379  else
     
    390393    return;
    391394
    392   objc_mutex_lock(__objc_runtime_mutex);
     395  objc_mutex_lock (__objc_runtime_mutex);
    393396
    394397  arr = class->dtable;
     
    403406      __objc_update_dispatch_table_for_class (next);
    404407
    405   objc_mutex_unlock(__objc_runtime_mutex);
     408  objc_mutex_unlock (__objc_runtime_mutex);
    406409}
    407410
     
    420423
    421424  /* Passing of a linked list is not allowed.  Do multiple calls.  */
    422   assert (!list->method_next);
     425  assert (! list->method_next);
    423426
    424427  /* Check for duplicates.  */
     
    431434          /* This is where selector names are transmogrified to SEL's */
    432435          method->method_name =
    433             sel_register_typed_name ((const char*)method->method_name,
     436            sel_register_typed_name ((const char *) method->method_name,
    434437                                     method->method_types);
    435438        }
     
    445448
    446449Method_t
    447 class_get_instance_method(Class class, SEL op)
    448 {
    449   return search_for_method_in_hierarchy(class, op);
     450class_get_instance_method (Class class, SEL op)
     451{
     452  return search_for_method_in_hierarchy (class, op);
    450453}
    451454
    452455Method_t
    453 class_get_class_method(MetaClass class, SEL op)
    454 {
    455   return search_for_method_in_hierarchy(class, op);
     456class_get_class_method (MetaClass class, SEL op)
     457{
     458  return search_for_method_in_hierarchy (class, op);
    456459}
    457460
     
    577580
    578581  /* first try if the object understands forward:: */
    579   if (!frwd_sel)
    580     frwd_sel = sel_get_any_uid("forward::");
     582  if (! frwd_sel)
     583    frwd_sel = sel_get_any_uid ("forward::");
    581584
    582585  if (__objc_responds_to (object, frwd_sel))
    583586    {
    584       imp = get_imp(object->class_pointer, frwd_sel);
    585       return (*imp)(object, frwd_sel, sel, args);
     587      imp = get_imp (object->class_pointer, frwd_sel);
     588      return (*imp) (object, frwd_sel, sel, args);
    586589    }
    587590
     
    598601     error:.  If it does then sent it. */
    599602  {
    600     char msg[256 + strlen ((const char*)sel_get_name (sel))
    601              + strlen ((const char*)object->class_pointer->name)];
     603    char msg[256 + strlen ((const char *) sel_get_name (sel))
     604             + strlen ((const char *) object->class_pointer->name)];
    602605
    603606    sprintf (msg, "(%s) %s does not recognize %s",
    604              (CLS_ISMETA(object->class_pointer)
     607             (CLS_ISMETA (object->class_pointer)
    605608              ? "class"
    606609              : "instance" ),
     
    623626
    624627void
    625 __objc_print_dtable_stats()
     628__objc_print_dtable_stats ()
    626629{
    627630  int total = 0;
    628631
    629   objc_mutex_lock(__objc_runtime_mutex);
     632  objc_mutex_lock (__objc_runtime_mutex);
    630633
    631634#ifdef OBJC_SPARSE2
    632   printf("memory usage: (%s)\n", "2-level sparse arrays");
     635  printf ("memory usage: (%s)\n", "2-level sparse arrays");
    633636#else
    634   printf("memory usage: (%s)\n", "3-level sparse arrays");
     637  printf ("memory usage: (%s)\n", "3-level sparse arrays");
    635638#endif
    636639
    637   printf("arrays: %d = %ld bytes\n", narrays,
    638          (long)narrays*sizeof(struct sarray));
    639   total += narrays*sizeof(struct sarray);
    640   printf("buckets: %d = %ld bytes\n", nbuckets,
    641          (long)nbuckets*sizeof(struct sbucket));
    642   total += nbuckets*sizeof(struct sbucket);
    643 
    644   printf("idxtables: %d = %ld bytes\n", idxsize, (long)idxsize*sizeof(void*));
    645   total += idxsize*sizeof(void*);
    646   printf("-----------------------------------\n");
    647   printf("total: %d bytes\n", total);
    648   printf("===================================\n");
    649 
    650   objc_mutex_unlock(__objc_runtime_mutex);
     640  printf ("arrays: %d = %ld bytes\n", narrays,
     641          (long) narrays * sizeof (struct sarray));
     642  total += narrays * sizeof (struct sarray);
     643  printf ("buckets: %d = %ld bytes\n", nbuckets,
     644          (long) nbuckets * sizeof (struct sbucket));
     645  total += nbuckets * sizeof (struct sbucket);
     646
     647  printf ("idxtables: %d = %ld bytes\n",
     648          idxsize, (long) idxsize * sizeof (void *));
     649  total += idxsize * sizeof (void *);
     650  printf ("-----------------------------------\n");
     651  printf ("total: %d bytes\n", total);
     652  printf ("===================================\n");
     653
     654  objc_mutex_unlock (__objc_runtime_mutex);
    651655}
    652656
     
    655659 then that means it needs its dispatch table to be installed. */
    656660__inline__
    657 struct sarray*
    658 objc_get_uninstalled_dtable()
     661struct sarray *
     662objc_get_uninstalled_dtable ()
    659663{
    660664  return __objc_uninstalled_dtable;
  • branches/GNU/src/gcc/libobjc/thr-mach.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11/* GNU Objective C Runtime Thread Implementation
    2    Copyright (C) 1996, 1997 Free Software Foundation, Inc.
     2   Copyright (C) 1996, 1997, 2002 Free Software Foundation, Inc.
    33   Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
    44   Modified for Mach threads by Bill Bumgarner <bbum@friday.com>
     
    3838  privileges.  Once lowered, it cannot be raised.
    3939  */
    40 static int __mach_get_max_thread_priority(cthread_t t, int *base)
     40static int
     41__mach_get_max_thread_priority (cthread_t t, int *base)
    4142{
    4243  thread_t threadP;
     
    4849    return -1;
    4950
    50   threadP  = cthread_thread(t);         /* get thread underlying */
    51 
    52   error=thread_info(threadP, THREAD_SCHED_INFO,
    53                     (thread_info_t)&info, &info_count);
     51  threadP  = cthread_thread (t);        /* get thread underlying */
     52
     53  error = thread_info (threadP, THREAD_SCHED_INFO,
     54                       (thread_info_t) &info, &info_count);
    5455
    5556  if (error != KERN_SUCCESS)
     
    6667/* Initialize the threads subsystem. */
    6768int
    68 __objc_init_thread_system(void)
     69__objc_init_thread_system (void)
    6970{
    7071  return 0;
     
    7374/* Close the threads subsystem. */
    7475int
    75 __objc_close_thread_system(void)
     76__objc_close_thread_system (void)
    7677{
    7778  return 0;
     
    8283/* Create a new thread of execution. */
    8384objc_thread_t
    84 __objc_thread_detach(void (*func)(void *arg), void *arg)
     85__objc_thread_detach (void (*func) (void *arg), void *arg)
    8586{
    8687  objc_thread_t thread_id;
     
    8889
    8990  /* create thread */
    90   new_thread_handle = cthread_fork((cthread_fn_t)func, arg);
    91 
    92   if(new_thread_handle)
     91  new_thread_handle = cthread_fork ((cthread_fn_t) func, arg);
     92
     93  if (new_thread_handle)
    9394    {
    9495      /* this is not terribly portable */
    95       thread_id = *(objc_thread_t *)&new_thread_handle;
    96       cthread_detach(new_thread_handle);
     96      thread_id = *(objc_thread_t *) &new_thread_handle;
     97      cthread_detach (new_thread_handle);
    9798    }
    9899  else
     
    104105/* Set the current thread's priority. */
    105106int
    106 __objc_thread_set_priority(int priority)
    107 {
    108   objc_thread_t *t = objc_thread_id();
     107__objc_thread_set_priority (int priority)
     108{
     109  objc_thread_t *t = objc_thread_id ();
    109110  cthread_t cT = (cthread_t) t;
    110   int maxPriority = __mach_get_max_thread_priority(cT, NULL);
     111  int maxPriority = __mach_get_max_thread_priority (cT, NULL);
    111112  int sys_priority = 0;
    112113
     
    133134
    134135  /* Change the priority */
    135   if (cthread_priority(cT, sys_priority, 0) == KERN_SUCCESS)
     136  if (cthread_priority (cT, sys_priority, 0) == KERN_SUCCESS)
    136137    return 0;
    137138  else
     
    141142/* Return the current thread's priority. */
    142143int
    143 __objc_thread_get_priority(void)
    144 {
    145   objc_thread_t *t = objc_thread_id();
    146   cthread_t cT = (cthread_t) t; /* see objc_thread_id() */
     144__objc_thread_get_priority (void)
     145{
     146  objc_thread_t *t = objc_thread_id ();
     147  cthread_t cT = (cthread_t) t; /* see objc_thread_id () */
    147148  int basePriority;
    148149  int maxPriority;
     
    151152  int interactiveT, backgroundT, lowT; /* thresholds */
    152153
    153   maxPriority = __mach_get_max_thread_priority(cT, &basePriority);
    154 
    155   if(maxPriority == -1)
     154  maxPriority = __mach_get_max_thread_priority (cT, &basePriority);
     155
     156  if (maxPriority == -1)
    156157    return -1;
    157158
     
    167168/* Yield our process time to another thread. */
    168169void
    169 __objc_thread_yield(void)
    170 {
    171   cthread_yield();
     170__objc_thread_yield (void)
     171{
     172  cthread_yield ();
    172173}
    173174
    174175/* Terminate the current thread. */
    175176int
    176 __objc_thread_exit(void)
     177__objc_thread_exit (void)
    177178{
    178179  /* exit the thread */
    179   cthread_exit(&__objc_thread_exit_status);
     180  cthread_exit (&__objc_thread_exit_status);
    180181
    181182  /* Failed if we reached here */
     
    185186/* Returns an integer value which uniquely describes a thread. */
    186187objc_thread_t
    187 __objc_thread_id(void)
    188 {
    189   cthread_t self = cthread_self();
    190 
    191   return *(objc_thread_t *)&self;
     188__objc_thread_id (void)
     189{
     190  cthread_t self = cthread_self ();
     191
     192  return *(objc_thread_t *) &self;
    192193}
    193194
    194195/* Sets the thread's local storage pointer. */
    195196int
    196 __objc_thread_set_data(void *value)
    197 {
    198   cthread_set_data(cthread_self(), (any_t) value);
     197__objc_thread_set_data (void *value)
     198{
     199  cthread_set_data (cthread_self (), (any_t) value);
    199200  return 0;
    200201}
     
    202203/* Returns the thread's local storage pointer. */
    203204void *
    204 __objc_thread_get_data(void)
    205 {
    206   return (void *) cthread_data(cthread_self());
     205__objc_thread_get_data (void)
     206{
     207  return (void *) cthread_data (cthread_self ());
    207208}
    208209
     
    211212/* Allocate a mutex. */
    212213int
    213 __objc_mutex_allocate(objc_mutex_t mutex)
     214__objc_mutex_allocate (objc_mutex_t mutex)
    214215{
    215216  int err = 0;
    216   mutex->backend = objc_malloc(sizeof(struct mutex));
    217 
    218   err = mutex_init((mutex_t)(mutex->backend));
     217  mutex->backend = objc_malloc (sizeof (struct mutex));
     218
     219  err = mutex_init ((mutex_t) (mutex->backend));
    219220
    220221  if (err != 0)
    221222    {
    222       objc_free(mutex->backend);
     223      objc_free (mutex->backend);
    223224      return -1;
    224225    }
     
    229230/* Deallocate a mutex. */
    230231int
    231 __objc_mutex_deallocate(objc_mutex_t mutex)
    232 {
    233   mutex_clear((mutex_t)(mutex->backend));
    234 
    235   objc_free(mutex->backend);
     232__objc_mutex_deallocate (objc_mutex_t mutex)
     233{
     234  mutex_clear ((mutex_t) (mutex->backend));
     235
     236  objc_free (mutex->backend);
    236237  mutex->backend = NULL;
    237238  return 0;
     
    240241/* Grab a lock on a mutex. */
    241242int
    242 __objc_mutex_lock(objc_mutex_t mutex)
    243 {
    244   mutex_lock((mutex_t)(mutex->backend));
     243__objc_mutex_lock (objc_mutex_t mutex)
     244{
     245  mutex_lock ((mutex_t) (mutex->backend));
    245246  return 0;
    246247}
     
    248249/* Try to grab a lock on a mutex. */
    249250int
    250 __objc_mutex_trylock(objc_mutex_t mutex)
    251 {
    252   if (mutex_try_lock((mutex_t)(mutex->backend)) == 0)
     251__objc_mutex_trylock (objc_mutex_t mutex)
     252{
     253  if (mutex_try_lock ((mutex_t) (mutex->backend)) == 0)
    253254    return -1;
    254255  else
     
    258259/* Unlock the mutex */
    259260int
    260 __objc_mutex_unlock(objc_mutex_t mutex)
    261 {
    262   mutex_unlock((mutex_t)(mutex->backend));
     261__objc_mutex_unlock (objc_mutex_t mutex)
     262{
     263  mutex_unlock ((mutex_t) (mutex->backend));
    263264  return 0;
    264265}
     
    268269/* Allocate a condition. */
    269270int
    270 __objc_condition_allocate(objc_condition_t condition)
    271 {
    272   condition->backend = objc_malloc(sizeof(struct condition));
    273   condition_init((condition_t)(condition->backend));
     271__objc_condition_allocate (objc_condition_t condition)
     272{
     273  condition->backend = objc_malloc (sizeof (struct condition));
     274  condition_init ((condition_t) (condition->backend));
    274275  return 0;
    275276}
     
    277278/* Deallocate a condition. */
    278279int
    279 __objc_condition_deallocate(objc_condition_t condition)
    280 {
    281   condition_clear((condition_t)(condition->backend));
    282   objc_free(condition->backend);
     280__objc_condition_deallocate (objc_condition_t condition)
     281{
     282  condition_clear ((condition_t) (condition->backend));
     283  objc_free (condition->backend);
    283284  condition->backend = NULL;
    284285  return 0;
     
    287288/* Wait on the condition */
    288289int
    289 __objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex)
    290 {
    291   condition_wait((condition_t)(condition->backend),
    292                  (mutex_t)(mutex->backend));
     290__objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
     291{
     292  condition_wait ((condition_t) (condition->backend),
     293                  (mutex_t) (mutex->backend));
    293294  return 0;
    294295}
     
    296297/* Wake up all threads waiting on this condition. */
    297298int
    298 __objc_condition_broadcast(objc_condition_t condition)
    299 {
    300   condition_broadcast((condition_t)(condition->backend));
     299__objc_condition_broadcast (objc_condition_t condition)
     300{
     301  condition_broadcast ((condition_t) (condition->backend));
    301302  return 0;
    302303}
     
    304305/* Wake up one thread waiting on this condition. */
    305306int
    306 __objc_condition_signal(objc_condition_t condition)
    307 {
    308   condition_signal((condition_t)(condition->backend));
     307__objc_condition_signal (objc_condition_t condition)
     308{
     309  condition_signal ((condition_t) (condition->backend));
    309310  return 0;
    310311}
  • branches/GNU/src/gcc/libobjc/thr.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    4949  so it can implement the NSBecomingMultiThreaded notification.
    5050  */
    51 objc_thread_callback objc_set_thread_callback(objc_thread_callback func)
     51objc_thread_callback objc_set_thread_callback (objc_thread_callback func)
    5252{
    5353  objc_thread_callback temp = _objc_became_multi_threaded;
     
    7777
    7878static volatile void
    79 __objc_thread_detach_function(struct __objc_thread_start_state *istate)
     79__objc_thread_detach_function (struct __objc_thread_start_state *istate)
    8080{
    8181  /* Valid state? */
    8282  if (istate) {
    83     id (*imp)(id,SEL,id);
     83    id (*imp) (id, SEL, id);
    8484    SEL selector = istate->selector;
    8585    id object   = istate->object;
     
    8787
    8888    /* Don't need anymore so free it */
    89     objc_free(istate);
     89    objc_free (istate);
    9090
    9191    /* Clear out the thread local storage */
    92     objc_thread_set_data(NULL);
     92    objc_thread_set_data (NULL);
    9393
    9494    /* Check to see if we just became multi threaded */
    95     if (!__objc_is_multi_threaded)
     95    if (! __objc_is_multi_threaded)
    9696      {
    9797        __objc_is_multi_threaded = 1;
     
    9999        /* Call the hook function */
    100100        if (_objc_became_multi_threaded != NULL)
    101           (*_objc_became_multi_threaded)();
     101          (*_objc_became_multi_threaded) ();
    102102      }
    103103
    104104    /* Call the method */
    105     if ((imp = (id(*)(id, SEL, id))objc_msg_lookup(object, selector)))
    106         (*imp)(object, selector, argument);
     105    if ((imp = (id (*) (id, SEL, id))objc_msg_lookup (object, selector)))
     106        (*imp) (object, selector, argument);
    107107    else
    108       objc_error(object, OBJC_ERR_UNIMPLEMENTED,
    109                  "objc_thread_detach called with bad selector.\n");
     108      objc_error (object, OBJC_ERR_UNIMPLEMENTED,
     109                  "objc_thread_detach called with bad selector.\n");
    110110  }
    111111  else
    112     objc_error(nil, OBJC_ERR_BAD_STATE,
    113                "objc_thread_detach called with NULL state.\n");
     112    objc_error (nil, OBJC_ERR_BAD_STATE,
     113                "objc_thread_detach called with NULL state.\n");
    114114
    115115  /* Exit the thread */
    116   objc_thread_exit();
     116  objc_thread_exit ();
    117117}
    118118
     
    132132  */
    133133objc_thread_t
    134 objc_thread_detach(SEL selector, id object, id argument)
     134objc_thread_detach (SEL selector, id object, id argument)
    135135{
    136136  struct __objc_thread_start_state *istate;
     
    138138
    139139  /* Allocate the state structure */
    140   if (!(istate = (struct __objc_thread_start_state *)
    141         objc_malloc(sizeof(*istate))))
     140  if (! (istate = (struct __objc_thread_start_state *)
     141         objc_malloc (sizeof (*istate))))
    142142    return NULL;
    143143
     
    148148
    149149  /* lock access */
    150   objc_mutex_lock(__objc_runtime_mutex);
     150  objc_mutex_lock (__objc_runtime_mutex);
    151151
    152152  /* Call the backend to spawn the thread */
    153   if ((thread_id = __objc_thread_detach((void *)__objc_thread_detach_function,
    154                                         istate)) == NULL)
     153  if ((thread_id = __objc_thread_detach ((void *)__objc_thread_detach_function,
     154                                         istate)) == NULL)
    155155    {
    156156      /* failed! */
    157       objc_mutex_unlock(__objc_runtime_mutex);
    158       objc_free(istate);
     157      objc_mutex_unlock (__objc_runtime_mutex);
     158      objc_free (istate);
    159159      return NULL;
    160160    }
     
    162162  /* Increment our thread counter */
    163163  __objc_runtime_threads_alive++;
    164   objc_mutex_unlock(__objc_runtime_mutex);
     164  objc_mutex_unlock (__objc_runtime_mutex);
    165165
    166166  return thread_id;
     
    169169/* Set the current thread's priority. */
    170170int
    171 objc_thread_set_priority(int priority)
     171objc_thread_set_priority (int priority)
    172172{
    173173  /* Call the backend */
    174   return __objc_thread_set_priority(priority);
     174  return __objc_thread_set_priority (priority);
    175175}
    176176
    177177/* Return the current thread's priority. */
    178178int
    179 objc_thread_get_priority(void)
     179objc_thread_get_priority (void)
    180180{
    181181  /* Call the backend */
    182   return __objc_thread_get_priority();
     182  return __objc_thread_get_priority ();
    183183}
    184184
     
    189189  */
    190190void
    191 objc_thread_yield(void)
     191objc_thread_yield (void)
    192192{
    193193  /* Call the backend */
    194   __objc_thread_yield();
     194  __objc_thread_yield ();
    195195}
    196196
     
    200200  */
    201201int
    202 objc_thread_exit(void)
     202objc_thread_exit (void)
    203203{
    204204  /* Decrement our counter of the number of threads alive */
    205   objc_mutex_lock(__objc_runtime_mutex);
     205  objc_mutex_lock (__objc_runtime_mutex);
    206206  __objc_runtime_threads_alive--;
    207   objc_mutex_unlock(__objc_runtime_mutex);
     207  objc_mutex_unlock (__objc_runtime_mutex);
    208208
    209209  /* Call the backend to terminate the thread */
    210   return __objc_thread_exit();
     210  return __objc_thread_exit ();
    211211}
    212212
     
    216216  */
    217217objc_thread_t
    218 objc_thread_id(void)
     218objc_thread_id (void)
    219219{
    220220  /* Call the backend */
    221   return __objc_thread_id();
     221  return __objc_thread_id ();
    222222}
    223223
     
    227227  */
    228228int
    229 objc_thread_set_data(void *value)
     229objc_thread_set_data (void *value)
    230230{
    231231  /* Call the backend */
    232   return __objc_thread_set_data(value);
     232  return __objc_thread_set_data (value);
    233233}
    234234
     
    237237  */
    238238void *
    239 objc_thread_get_data(void)
     239objc_thread_get_data (void)
    240240{
    241241  /* Call the backend */
    242   return __objc_thread_get_data();
     242  return __objc_thread_get_data ();
    243243}
    244244
     
    250250  */
    251251objc_mutex_t
    252 objc_mutex_allocate(void)
     252objc_mutex_allocate (void)
    253253{
    254254  objc_mutex_t mutex;
    255255
    256256  /* Allocate the mutex structure */
    257   if (!(mutex = (objc_mutex_t)objc_malloc(sizeof(struct objc_mutex))))
     257  if (! (mutex = (objc_mutex_t)objc_malloc (sizeof (struct objc_mutex))))
    258258    return NULL;
    259259
    260260  /* Call backend to create the mutex */
    261   if (__objc_mutex_allocate(mutex))
     261  if (__objc_mutex_allocate (mutex))
    262262    {
    263263      /* failed! */
    264       objc_free(mutex);
     264      objc_free (mutex);
    265265      return NULL;
    266266    }
     
    280280  */
    281281int
    282 objc_mutex_deallocate(objc_mutex_t mutex)
     282objc_mutex_deallocate (objc_mutex_t mutex)
    283283{
    284284  int depth;
    285285
    286286  /* Valid mutex? */
    287   if (!mutex)
     287  if (! mutex)
    288288    return -1;
    289289
    290290  /* Acquire lock on mutex */
    291   depth = objc_mutex_lock(mutex);
     291  depth = objc_mutex_lock (mutex);
    292292
    293293  /* Call backend to destroy mutex */
    294   if (__objc_mutex_deallocate(mutex))
     294  if (__objc_mutex_deallocate (mutex))
    295295    return -1;
    296296
    297297  /* Free the mutex structure */
    298   objc_free(mutex);
     298  objc_free (mutex);
    299299
    300300  /* Return last depth */
     
    309309  */
    310310int
    311 objc_mutex_lock(objc_mutex_t mutex)
     311objc_mutex_lock (objc_mutex_t mutex)
    312312{
    313313  objc_thread_t thread_id;
     
    315315
    316316  /* Valid mutex? */
    317   if (!mutex)
     317  if (! mutex)
    318318    return -1;
    319319
    320320  /* If we already own the lock then increment depth */
    321   thread_id = __objc_thread_id();
     321  thread_id = __objc_thread_id ();
    322322  if (mutex->owner == thread_id)
    323323    return ++mutex->depth;
    324324
    325325  /* Call the backend to lock the mutex */
    326   status = __objc_mutex_lock(mutex);
     326  status = __objc_mutex_lock (mutex);
    327327
    328328  /* Failed? */
     
    341341  */
    342342int
    343 objc_mutex_trylock(objc_mutex_t mutex)
     343objc_mutex_trylock (objc_mutex_t mutex)
    344344{
    345345  objc_thread_t thread_id;
     
    347347
    348348  /* Valid mutex? */
    349   if (!mutex)
     349  if (! mutex)
    350350    return -1;
    351351
    352352  /* If we already own the lock then increment depth */
    353   thread_id = __objc_thread_id();
     353  thread_id = __objc_thread_id ();
    354354  if (mutex->owner == thread_id)
    355355    return ++mutex->depth;
    356356   
    357357  /* Call the backend to try to lock the mutex */
    358   status = __objc_mutex_trylock(mutex);
     358  status = __objc_mutex_trylock (mutex);
    359359
    360360  /* Failed? */
     
    376376  */
    377377int
    378 objc_mutex_unlock(objc_mutex_t mutex)
     378objc_mutex_unlock (objc_mutex_t mutex)
    379379{
    380380  objc_thread_t thread_id;
     
    382382
    383383  /* Valid mutex? */
    384   if (!mutex)
     384  if (! mutex)
    385385    return -1;
    386386
    387387  /* If another thread owns the lock then abort */
    388   thread_id = __objc_thread_id();
     388  thread_id = __objc_thread_id ();
    389389  if (mutex->owner != thread_id)
    390390    return -1;
     
    399399
    400400  /* Have the backend unlock the mutex */
    401   status = __objc_mutex_unlock(mutex);
     401  status = __objc_mutex_unlock (mutex);
    402402
    403403  /* Failed? */
     
    415415  */
    416416objc_condition_t
    417 objc_condition_allocate(void)
     417objc_condition_allocate (void)
    418418{
    419419  objc_condition_t condition;
    420420   
    421421  /* Allocate the condition mutex structure */
    422   if (!(condition =
    423         (objc_condition_t)objc_malloc(sizeof(struct objc_condition))))
     422  if (! (condition =
     423         (objc_condition_t) objc_malloc (sizeof (struct objc_condition))))
    424424    return NULL;
    425425
    426426  /* Call the backend to create the condition mutex */
    427   if (__objc_condition_allocate(condition))
     427  if (__objc_condition_allocate (condition))
    428428    {
    429429      /* failed! */
    430       objc_free(condition);
     430      objc_free (condition);
    431431      return NULL;
    432432    }
     
    444444  */
    445445int
    446 objc_condition_deallocate(objc_condition_t condition)
     446objc_condition_deallocate (objc_condition_t condition)
    447447{
    448448  /* Broadcast the condition */
    449   if (objc_condition_broadcast(condition))
     449  if (objc_condition_broadcast (condition))
    450450    return -1;
    451451
    452452  /* Call the backend to destroy */
    453   if (__objc_condition_deallocate(condition))
     453  if (__objc_condition_deallocate (condition))
    454454    return -1;
    455455
    456456  /* Free the condition mutex structure */
    457   objc_free(condition);
     457  objc_free (condition);
    458458
    459459  return 0;
     
    461461
    462462/*
    463   Wait on the condition unlocking the mutex until objc_condition_signal()
    464   or objc_condition_broadcast() are called for the same condition. The
     463  Wait on the condition unlocking the mutex until objc_condition_signal ()
     464  or objc_condition_broadcast () are called for the same condition. The
    465465  given mutex *must* have the depth set to 1 so that it can be unlocked
    466466  here, so that someone else can lock it and signal/broadcast the condition.
     
    469469  */
    470470int
    471 objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex)
     471objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
    472472{
    473473  objc_thread_t thread_id;
    474474
    475475  /* Valid arguments? */
    476   if (!mutex || !condition)
     476  if (! mutex || ! condition)
    477477    return -1;
    478478
    479479  /* Make sure we are owner of mutex */
    480   thread_id = __objc_thread_id();
     480  thread_id = __objc_thread_id ();
    481481  if (mutex->owner != thread_id)
    482482    return -1;
     
    491491
    492492  /* Call the backend to wait */
    493   __objc_condition_wait(condition, mutex);
     493  __objc_condition_wait (condition, mutex);
    494494
    495495  /* Make ourselves owner of the mutex */
     
    507507  */
    508508int
    509 objc_condition_broadcast(objc_condition_t condition)
     509objc_condition_broadcast (objc_condition_t condition)
    510510{
    511511  /* Valid condition mutex? */
    512   if (!condition)
    513     return -1;
    514 
    515   return __objc_condition_broadcast(condition);
     512  if (! condition)
     513    return -1;
     514
     515  return __objc_condition_broadcast (condition);
    516516}
    517517
     
    523523  */
    524524int
    525 objc_condition_signal(objc_condition_t condition)
     525objc_condition_signal (objc_condition_t condition)
    526526{
    527527  /* Valid condition mutex? */
    528   if (!condition)
    529     return -1;
    530 
    531   return __objc_condition_signal(condition);
     528  if (! condition)
     529    return -1;
     530
     531  return __objc_condition_signal (condition);
    532532}
    533533
     
    536536   from now on.  This is used when you are interfacing with some
    537537   external non-objc-based environment/system - you must call
    538    objc_thread_add() before an alien thread makes any calls to
     538   objc_thread_add () before an alien thread makes any calls to
    539539   Objective-C.  Do not cause the _objc_became_multi_threaded hook to
    540540   be executed. */
    541541void
    542 objc_thread_add(void)
    543 {
    544   objc_mutex_lock(__objc_runtime_mutex);
     542objc_thread_add (void)
     543{
     544  objc_mutex_lock (__objc_runtime_mutex);
    545545  __objc_is_multi_threaded = 1;
    546546  __objc_runtime_threads_alive++;
    547   objc_mutex_unlock(__objc_runtime_mutex); 
     547  objc_mutex_unlock (__objc_runtime_mutex); 
    548548}
    549549
     
    551551   stopped) by some external code will no longer access objc and thus
    552552   can be forgotten by the objc thread system.  Call
    553    objc_thread_remove() when your alien thread is done with making
     553   objc_thread_remove () when your alien thread is done with making
    554554   calls to Objective-C. */
    555555void
    556 objc_thread_remove(void)
    557 {
    558   objc_mutex_lock(__objc_runtime_mutex);
     556objc_thread_remove (void)
     557{
     558  objc_mutex_lock (__objc_runtime_mutex);
    559559  __objc_runtime_threads_alive--;
    560   objc_mutex_unlock(__objc_runtime_mutex); 
     560  objc_mutex_unlock (__objc_runtime_mutex); 
    561561}
    562562
Note: See TracChangeset for help on using the changeset viewer.