Changeset 1391 for branches/GNU/src/gcc/libobjc
- Timestamp:
- Apr 27, 2004, 8:39:34 PM (21 years ago)
- Location:
- branches/GNU/src/gcc
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/gcc
- Property svn:ignore
-
old new 26 26 configure.vr 27 27 configure.vrs 28 dir.info 28 29 Makefile 29 dir.info30 30 lost+found 31 31 update.out
-
- Property svn:ignore
-
branches/GNU/src/gcc/libobjc/ChangeLog
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.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> 1 2004-02-14 Release Manager 2 3 * GCC 3.3.3 Released. 4 5 2003-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 12 2003-10-16 Release Manager 13 14 * GCC 3.3.2 Released. 15 16 2003-09-09 Alan Modra <amodra@bigpond.net.au> 17 18 * configure: Regenerate. 19 20 2003-08-04 Release Manager 21 22 * GCC 3.3.1 Released. 23 24 2003-08-04 Release Manager 25 26 * GCC 3.3.1 Released. 27 28 2003-05-13 Release Manager 29 30 * GCC 3.3 Released. 31 32 2003-05-13 Release Manager 33 34 * GCC 3.3 Released. 35 36 2003-05-13 Release Manager 37 38 * GCC 3.3 Released. 39 40 2003-02-20 Alexandre Oliva <aoliva@redhat.com> 41 42 * configure.in: Propagate ORIGINAL_LD_FOR_MULTILIBS to 43 config.status. 44 * configure: Rebuilt. 45 46 2003-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 53 2003-01-26 Christian Cornelssen <ccorn@cs.tu-berlin.de> 6 54 7 55 * Makefile.in (FLAGS_TO_PASS): Also pass DESTDIR. … … 9 57 destination paths in all (un)installation commands. 10 58 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> 59 2002-09-22 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 31 60 32 61 * Makefile.in (all): Fix multilib parallel build. 33 62 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. 63 Thu 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 70 2002-09-10 Jan Hubicka <jh@suse.cz> 71 72 * nil_method.c (nil_method): No longer defined with variable 73 arguments. 74 75 2002-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. 41 96 42 97 2002-06-25 DJ Delorie <dj@redhat.com> … … 47 102 * configure: Regenerate. 48 103 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. 104 2002-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 114 Mon 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 121 2002-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 151 2002-06-09 Andreas Jaeger <aj@suse.de> 152 153 * encoding.c (objc_layout_structure_next_member): Remove unused 154 variable. 155 156 2002-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 162 2002-05-16 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> 163 164 * aclocal.m4: Allow for PWDCMD to override hardcoded pwd. 165 * configure: Regenerate. 56 166 57 167 2002-05-08 Alexandre Oliva <aoliva@redhat.com> … … 90 200 2001-11-14 Aldy Hernandez <aldyh@redhat.com> 91 201 92 202 * encoding.c: Add target_flags. 93 203 94 204 2001-11-07 Aldy Hernandez <aldyh@redhat.com> … … 101 211 102 212 * class.c: Rewritten the class table to use optimized, lock-free 103 104 105 106 107 108 109 110 111 112 113 114 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. 115 225 116 226 2001-09-10 Ovidiu Predescu <ovidiu@cup.hp.com> … … 227 337 friends have on various platforms. (Solution suggested by Helge 228 338 Hess.) 229 339 230 340 * objc/objc-api.h: Define __objc_msg_forward. 231 341 … … 234 344 2000-12-06 Ralf Corsepius <corsepiu@faw.uni-ulm.de> 235 345 236 * thr-rtems.c: New file. Stub to compile. 346 * thr-rtems.c: New file. Stub to compile. 237 347 238 348 2000-09-06 Alexandre Oliva <aoliva@redhat.com> … … 276 386 Fri Jul 28 08:58:02 2000 Nicola Pero <nicola@brainstorm.co.uk> 277 387 278 * configure.in: Added libtool support; build shared libraries 388 * configure.in: Added libtool support; build shared libraries 279 389 if --enable-shared was passed on command line. 280 390 * Makefile.in: Modified most compilation commands to use libtool. … … 337 447 * Makefile.in (gc.o, gc_gc.o): Do not pass -fgnu-runtime to 338 448 the compiler when building C code. 339 449 340 450 Fri Aug 6 23:32:29 1999 Daniel Jacobowitz <drow@drow.them.org> 341 451 … … 416 526 417 527 * encoding.c: Redefine get_inner_array_type to get the first entry 418 528 in the structure. 419 529 420 530 Thu Oct 8 12:21:14 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk> … … 481 591 482 592 * New directory. Moved files from ../gcc/objc. 483 -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/Makefile.in
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 23 23 #worthless. 24 24 25 SHELL = /bin/sh25 SHELL = @SHELL@ 26 26 MAKEOVERRIDES= 27 27 … … 68 68 CC = @CC@ 69 69 CFLAGS = @CFLAGS@ 70 WARN_CFLAGS = -W -Wall -Wwrite-strings -Wstrict-prototypes 70 71 GTHREAD_FLAGS=@GTHREAD_FLAGS@ 71 ALL_CFLAGS = -I. -I$(srcdir) $(CPPFLAGS) $(DEFS) $(CFLAGS) \72 ALL_CFLAGS = -I. -I$(srcdir) $(CPPFLAGS) $(DEFS) $(CFLAGS) $(WARN_CFLAGS) \ 72 73 $(GTHREAD_FLAGS) -DIN_GCC -DIN_TARGET_LIBS 73 74 -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/Object.m
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* 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. 3 3 4 4 This file is part of GNU CC. … … 200 200 + (BOOL) conformsTo: (Protocol*)aProtocol 201 201 { 202 int i;202 size_t i; 203 203 struct objc_protocol_list* proto_list; 204 204 id parent; … … 272 272 - (retval_t)forward:(SEL)aSel :(arglist_t)argFrame 273 273 { 274 (void) argFrame; /* UNUSED */ 274 275 return (retval_t)[self doesNotRecognize: aSel]; 275 276 } … … 365 366 - read: (TypedStream*)aStream 366 367 { 368 (void) aStream; /* UNUSED */ 367 369 // [super read: aStream]; 368 370 return self; … … 371 373 - write: (TypedStream*)aStream 372 374 { 375 (void) aStream; /* UNUSED */ 373 376 // [super write: aStream]; 374 377 return self; -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/Protocol.m
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 54 54 - (BOOL) conformsTo: (Protocol *)aProtocolObject 55 55 { 56 int i;56 size_t i; 57 57 struct objc_protocol_list* proto_list; 58 58 … … 81 81 struct objc_method_description *result; 82 82 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 } 88 89 89 90 for (proto_list = protocol_list; proto_list; proto_list = proto_list->next) 90 91 { 91 for (i=0; i < proto_list->count; i++) 92 size_t j; 93 for (j=0; j < proto_list->count; j++) 92 94 { 93 if ((result = [proto_list->list[ i]95 if ((result = [proto_list->list[j] 94 96 descriptionForInstanceMethod: aSel])) 95 97 return result; … … 107 109 struct objc_method_description *result; 108 110 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 } 114 117 115 118 for (proto_list = protocol_list; proto_list; proto_list = proto_list->next) 116 119 { 117 for (i=0; i < proto_list->count; i++) 120 size_t j; 121 for (j=0; j < proto_list->count; j++) 118 122 { 119 if ((result = [proto_list->list[ i]123 if ((result = [proto_list->list[j] 120 124 descriptionForClassMethod: aSel])) 121 125 return result; -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/aclocal.m4
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 55 55 # canonicalize only relative paths, because then amd will not unmount 56 56 # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd. 57 glibcpp_builddir=` pwd`57 glibcpp_builddir=`${PWDCMD-pwd}` 58 58 case $srcdir in 59 59 [\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;; -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/archive.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 /* GNU Objective C Runtime archiving2 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. 3 3 Contributed by Kresten Krab Thorup 4 4 … … 29 29 #include "typedstream.h" 30 30 #include "encoding.h" 31 32 #ifdef HAVE_STDLIB_H33 31 #include <stdlib.h> 34 #endif 35 36 extern int fflush(FILE*); 32 33 extern int fflush (FILE *); 37 34 38 35 #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)) 44 41 45 42 /* Declare some functions... */ 46 43 47 44 static int 48 objc_read_class (struct objc_typed_stream * stream, Class*class);49 50 int objc_sizeof_type (const char*type);45 objc_read_class (struct objc_typed_stream *stream, Class *class); 46 47 int objc_sizeof_type (const char *type); 51 48 52 49 static int 53 objc_write_use_common (struct objc_typed_stream *stream, unsigned long key);50 objc_write_use_common (struct objc_typed_stream *stream, unsigned long key); 54 51 55 52 static int 56 objc_write_register_common (struct objc_typed_stream *stream,53 objc_write_register_common (struct objc_typed_stream *stream, 57 54 unsigned long key); 58 55 59 56 static 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*);57 objc_write_class (struct objc_typed_stream *stream, 58 struct objc_class *class); 59 60 const char *objc_skip_type (const char *type); 61 62 static void __objc_finish_write_root_object (struct objc_typed_stream *); 63 static void __objc_finish_read_root_object (struct objc_typed_stream *); 67 64 68 65 static __inline__ int 69 __objc_code_unsigned_char (unsigned char *buf, unsigned char val)66 __objc_code_unsigned_char (unsigned char *buf, unsigned char val) 70 67 { 71 68 if ((val&_B_VALUE) == val) … … 83 80 84 81 int 85 objc_write_unsigned_char (struct objc_typed_stream *stream,82 objc_write_unsigned_char (struct objc_typed_stream *stream, 86 83 unsigned char value) 87 84 { 88 unsigned char buf[sizeof (unsigned char) +1];85 unsigned char buf[sizeof (unsigned char) + 1]; 89 86 int len = __objc_code_unsigned_char (buf, value); 90 return (*stream->write) (stream->physical, buf, len);87 return (*stream->write) (stream->physical, buf, len); 91 88 } 92 89 93 90 static __inline__ int 94 __objc_code_char (unsigned char *buf, signed char val)91 __objc_code_char (unsigned char *buf, signed char val) 95 92 { 96 93 if (val >= 0) … … 105 102 106 103 int 107 objc_write_char (struct objc_typed_stream *stream, signed char value)108 { 109 unsigned char buf[sizeof (char) +1];104 objc_write_char (struct objc_typed_stream *stream, signed char value) 105 { 106 unsigned char buf[sizeof (char) + 1]; 110 107 int len = __objc_code_char (buf, value); 111 return (*stream->write) (stream->physical, buf, len);108 return (*stream->write) (stream->physical, buf, len); 112 109 } 113 110 114 111 static __inline__ int 115 __objc_code_unsigned_short (unsigned char *buf, unsigned short val)112 __objc_code_unsigned_short (unsigned char *buf, unsigned short val) 116 113 { 117 114 if ((val&_B_VALUE) == val) … … 126 123 buf[0] = _B_NINT; 127 124 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) 130 127 break; 131 128 … … 134 131 for (b = 1; c != 0; c--, b++) 135 132 { 136 buf[b] = (val >> (8*(c -1)))%0x100;133 buf[b] = (val >> (8*(c - 1)))%0x100; 137 134 } 138 135 … … 142 139 143 140 int 144 objc_write_unsigned_short (struct objc_typed_stream *stream,141 objc_write_unsigned_short (struct objc_typed_stream *stream, 145 142 unsigned short value) 146 143 { 147 unsigned char buf[sizeof (unsigned short) +1];144 unsigned char buf[sizeof (unsigned short) + 1]; 148 145 int len = __objc_code_unsigned_short (buf, value); 149 return (*stream->write) (stream->physical, buf, len);146 return (*stream->write) (stream->physical, buf, len); 150 147 } 151 148 152 149 static __inline__ int 153 __objc_code_short (unsigned char *buf, short val)150 __objc_code_short (unsigned char *buf, short val) 154 151 { 155 152 int sign = (val < 0); … … 161 158 162 159 int 163 objc_write_short (struct objc_typed_stream *stream, short value)164 { 165 unsigned char buf[sizeof (short) +1];160 objc_write_short (struct objc_typed_stream *stream, short value) 161 { 162 unsigned char buf[sizeof (short) + 1]; 166 163 int len = __objc_code_short (buf, value); 167 return (*stream->write) (stream->physical, buf, len);164 return (*stream->write) (stream->physical, buf, len); 168 165 } 169 166 170 167 171 168 static __inline__ int 172 __objc_code_unsigned_int (unsigned char *buf, unsigned int val)169 __objc_code_unsigned_int (unsigned char *buf, unsigned int val) 173 170 { 174 171 if ((val&_B_VALUE) == val) … … 183 180 buf[0] = _B_NINT; 184 181 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) 187 184 break; 188 185 … … 199 196 200 197 int 201 objc_write_unsigned_int (struct objc_typed_stream *stream, unsigned int value)202 { 203 unsigned char buf[sizeof (unsigned int)+1];198 objc_write_unsigned_int (struct objc_typed_stream *stream, unsigned int value) 199 { 200 unsigned char buf[sizeof (unsigned int) + 1]; 204 201 int len = __objc_code_unsigned_int (buf, value); 205 return (*stream->write) (stream->physical, buf, len);202 return (*stream->write) (stream->physical, buf, len); 206 203 } 207 204 208 205 static __inline__ int 209 __objc_code_int (unsigned char *buf, int val)206 __objc_code_int (unsigned char *buf, int val) 210 207 { 211 208 int sign = (val < 0); … … 217 214 218 215 int 219 objc_write_int (struct objc_typed_stream *stream, int value)220 { 221 unsigned char buf[sizeof (int)+1];216 objc_write_int (struct objc_typed_stream *stream, int value) 217 { 218 unsigned char buf[sizeof (int) + 1]; 222 219 int len = __objc_code_int (buf, value); 223 return (*stream->write) (stream->physical, buf, len);220 return (*stream->write) (stream->physical, buf, len); 224 221 } 225 222 226 223 static __inline__ int 227 __objc_code_unsigned_long (unsigned char *buf, unsigned long val)224 __objc_code_unsigned_long (unsigned char *buf, unsigned long val) 228 225 { 229 226 if ((val&_B_VALUE) == val) … … 238 235 buf[0] = _B_NINT; 239 236 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) 242 239 break; 243 240 … … 246 243 for (b = 1; c != 0; c--, b++) 247 244 { 248 buf[b] = (val >> (8*(c -1)))%0x100;245 buf[b] = (val >> (8*(c - 1)))%0x100; 249 246 } 250 247 … … 254 251 255 252 int 256 objc_write_unsigned_long (struct objc_typed_stream *stream,253 objc_write_unsigned_long (struct objc_typed_stream *stream, 257 254 unsigned long value) 258 255 { 259 unsigned char buf[sizeof (unsigned long)+1];256 unsigned char buf[sizeof (unsigned long) + 1]; 260 257 int len = __objc_code_unsigned_long (buf, value); 261 return (*stream->write) (stream->physical, buf, len);258 return (*stream->write) (stream->physical, buf, len); 262 259 } 263 260 264 261 static __inline__ int 265 __objc_code_long (unsigned char *buf, long val)262 __objc_code_long (unsigned char *buf, long val) 266 263 { 267 264 int sign = (val < 0); … … 273 270 274 271 int 275 objc_write_long (struct objc_typed_stream *stream, long value)276 { 277 unsigned char buf[sizeof (long)+1];272 objc_write_long (struct objc_typed_stream *stream, long value) 273 { 274 unsigned char buf[sizeof (long) + 1]; 278 275 int len = __objc_code_long (buf, value); 279 return (*stream->write) (stream->physical, buf, len);276 return (*stream->write) (stream->physical, buf, len); 280 277 } 281 278 282 279 283 280 int 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];281 objc_write_string (struct objc_typed_stream *stream, 282 const unsigned char *string, unsigned int nbytes) 283 { 284 unsigned char buf[sizeof (unsigned int) + 1]; 288 285 int len = __objc_code_unsigned_int (buf, nbytes); 289 286 … … 294 291 buf[0] = (buf[0]&_B_VALUE)|_B_NSTR; 295 292 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); 298 295 else 299 296 return 0; … … 301 298 302 299 int 303 objc_write_string_atomic (struct objc_typed_stream *stream,304 unsigned char *string, unsigned int nbytes)300 objc_write_string_atomic (struct objc_typed_stream *stream, 301 unsigned char *string, unsigned int nbytes) 305 302 { 306 303 unsigned long key; … … 318 315 319 316 static int 320 objc_write_register_common (struct objc_typed_stream *stream,317 objc_write_register_common (struct objc_typed_stream *stream, 321 318 unsigned long key) 322 319 { 323 320 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); 325 322 if (len == 1) 326 323 { 327 324 buf[0] = _B_RCOMM|0x01; 328 325 buf[1] &= _B_VALUE; 329 return (*stream->write) (stream->physical, buf, len+1);326 return (*stream->write) (stream->physical, buf, len + 1); 330 327 } 331 328 else 332 329 { 333 330 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); 335 332 } 336 333 } 337 334 338 335 static int 339 objc_write_use_common (struct objc_typed_stream *stream, unsigned long key)336 objc_write_use_common (struct objc_typed_stream *stream, unsigned long key) 340 337 { 341 338 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); 343 340 if (len == 1) 344 341 { 345 342 buf[0] = _B_UCOMM|0x01; 346 343 buf[1] &= _B_VALUE; 347 return (*stream->write) (stream->physical, buf, 2);344 return (*stream->write) (stream->physical, buf, 2); 348 345 } 349 346 else 350 347 { 351 348 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); 353 350 } 354 351 } 355 352 356 353 static __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) 358 355 { 359 356 if (code <= _B_VALUE) 360 357 { 361 358 unsigned char buf = code|_B_EXT; 362 return (*stream->write) (stream->physical, &buf, 1);359 return (*stream->write) (stream->physical, &buf, 1); 363 360 } 364 361 else 365 362 { 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); 368 365 return -1; 369 366 } … … 371 368 372 369 __inline__ int 373 __objc_write_object (struct objc_typed_stream *stream, id object)370 __objc_write_object (struct objc_typed_stream *stream, id object) 374 371 { 375 372 unsigned char buf = '\0'; … … 379 376 __objc_write_extension (stream, _BX_OBJECT); 380 377 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); 383 380 } 384 381 else 385 return objc_write_use_common (stream, 0);382 return objc_write_use_common (stream, 0); 386 383 } 387 384 388 385 int 389 objc_write_object_reference (struct objc_typed_stream *stream, id object)386 objc_write_object_reference (struct objc_typed_stream *stream, id object) 390 387 { 391 388 unsigned long key; … … 398 395 399 396 int 400 objc_write_root_object (struct objc_typed_stream *stream, id object)397 objc_write_root_object (struct objc_typed_stream *stream, id object) 401 398 { 402 399 int len = 0; … … 408 405 stream->writing_root_p = 1; 409 406 __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); 412 409 stream->writing_root_p = 0; 413 410 } … … 416 413 417 414 int 418 objc_write_object (struct objc_typed_stream *stream, id object)415 objc_write_object (struct objc_typed_stream *stream, id object) 419 416 { 420 417 unsigned long key; … … 423 420 424 421 else if (object == nil) 425 return objc_write_use_common (stream, 0);422 return objc_write_use_common (stream, 0); 426 423 427 424 else … … 436 433 437 434 __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) 439 436 { 440 437 __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)); 443 440 return objc_write_unsigned_long (stream, class->version); 444 441 } … … 446 443 447 444 static int 448 objc_write_class (struct objc_typed_stream *stream,449 struct objc_class *class)445 objc_write_class (struct objc_typed_stream *stream, 446 struct objc_class *class) 450 447 { 451 448 unsigned long key; … … 455 452 { 456 453 int length; 457 hash_add (&stream->stream_table, LONG2PTR(key =PTR2LONG(class)), class);454 hash_add (&stream->stream_table, LONG2PTR(key = PTR2LONG(class)), class); 458 455 if ((length = objc_write_register_common (stream, key))) 459 456 return __objc_write_class (stream, class); … … 464 461 465 462 __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; 469 466 __objc_write_extension (stream, _BX_SEL); 470 467 /* to handle NULL selectors */ … … 476 473 477 474 int 478 objc_write_selector (struct objc_typed_stream *stream, SEL selector)479 { 480 const char *sel_name;475 objc_write_selector (struct objc_typed_stream *stream, SEL selector) 476 { 477 const char *sel_name; 481 478 unsigned long key; 482 479 … … 492 489 int length; 493 490 hash_add (&stream->stream_table, 494 LONG2PTR(key =PTR2LONG(sel_name)), (char*)sel_name);491 LONG2PTR(key = PTR2LONG(sel_name)), (char *) sel_name); 495 492 if ((length = objc_write_register_common (stream, key))) 496 493 return __objc_write_selector (stream, selector); … … 506 503 507 504 __inline__ int 508 objc_read_char (struct objc_typed_stream * stream, char*val)505 objc_read_char (struct objc_typed_stream *stream, char *val) 509 506 { 510 507 unsigned char buf; 511 508 int len; 512 len = (*stream->read) (stream->physical, &buf, 1);509 len = (*stream->read) (stream->physical, &buf, 1); 513 510 if (len != 0) 514 511 { … … 518 515 else if ((buf & _B_NUMBER) == 1) 519 516 { 520 len = (*stream->read) (stream->physical, val, 1);517 len = (*stream->read) (stream->physical, val, 1); 521 518 if (buf&_B_SIGN) 522 (*val) = -1 *(*val);519 (*val) = -1 * (*val); 523 520 } 524 521 525 522 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); 529 526 } 530 527 return len; … … 533 530 534 531 __inline__ int 535 objc_read_unsigned_char (struct objc_typed_stream * stream, unsigned char*val)532 objc_read_unsigned_char (struct objc_typed_stream *stream, unsigned char *val) 536 533 { 537 534 unsigned char buf; 538 535 int len; 539 if ((len = (*stream->read) (stream->physical, &buf, 1)))536 if ((len = (*stream->read) (stream->physical, &buf, 1))) 540 537 { 541 538 if ((buf & _B_CODE) == _B_SINT) … … 543 540 544 541 else if ((buf & _B_NUMBER) == 1) 545 len = (*stream->read) (stream->physical, val, 1);542 len = (*stream->read) (stream->physical, val, 1); 546 543 547 544 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); 551 548 } 552 549 return len; … … 554 551 555 552 __inline__ int 556 objc_read_short (struct objc_typed_stream * stream, short*value)557 { 558 unsigned char buf[sizeof (short)+1];553 objc_read_short (struct objc_typed_stream *stream, short *value) 554 { 555 unsigned char buf[sizeof (short) + 1]; 559 556 int len; 560 if ((len = (*stream->read) (stream->physical, buf, 1)))557 if ((len = (*stream->read) (stream->physical, buf, 1))) 561 558 { 562 559 if ((buf[0] & _B_CODE) == _B_SINT) … … 567 564 int pos = 1; 568 565 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); 573 570 (*value) = 0; 574 571 while (pos <= nbytes) … … 582 579 583 580 __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];581 objc_read_unsigned_short (struct objc_typed_stream *stream, 582 unsigned short *value) 583 { 584 unsigned char buf[sizeof (unsigned short) + 1]; 588 585 int len; 589 if ((len = (*stream->read) (stream->physical, buf, 1)))586 if ((len = (*stream->read) (stream->physical, buf, 1))) 590 587 { 591 588 if ((buf[0] & _B_CODE) == _B_SINT) … … 596 593 int pos = 1; 597 594 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); 602 599 (*value) = 0; 603 600 while (pos <= nbytes) … … 610 607 611 608 __inline__ int 612 objc_read_int (struct objc_typed_stream * stream, int*value)613 { 614 unsigned char buf[sizeof (int)+1];609 objc_read_int (struct objc_typed_stream *stream, int *value) 610 { 611 unsigned char buf[sizeof (int) + 1]; 615 612 int len; 616 if ((len = (*stream->read) (stream->physical, buf, 1)))613 if ((len = (*stream->read) (stream->physical, buf, 1))) 617 614 { 618 615 if ((buf[0] & _B_CODE) == _B_SINT) … … 623 620 int pos = 1; 624 621 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); 628 625 (*value) = 0; 629 626 while (pos <= nbytes) … … 637 634 638 635 __inline__ int 639 objc_read_long (struct objc_typed_stream * stream, long*value)640 { 641 unsigned char buf[sizeof (long)+1];636 objc_read_long (struct objc_typed_stream *stream, long *value) 637 { 638 unsigned char buf[sizeof (long) + 1]; 642 639 int len; 643 if ((len = (*stream->read) (stream->physical, buf, 1)))640 if ((len = (*stream->read) (stream->physical, buf, 1))) 644 641 { 645 642 if ((buf[0] & _B_CODE) == _B_SINT) … … 650 647 int pos = 1; 651 648 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); 655 652 (*value) = 0; 656 653 while (pos <= nbytes) … … 664 661 665 662 __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]; 671 669 672 670 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); 676 674 (*val) = 0; 677 675 while (pos < nbytes) … … 682 680 683 681 __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];682 objc_read_unsigned_int (struct objc_typed_stream *stream, 683 unsigned int *value) 684 { 685 unsigned char buf[sizeof (unsigned int) + 1]; 688 686 int len; 689 if ((len = (*stream->read) (stream->physical, buf, 1)))687 if ((len = (*stream->read) (stream->physical, buf, 1))) 690 688 { 691 689 if ((buf[0] & _B_CODE) == _B_SINT) … … 700 698 701 699 int 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]; 707 706 708 707 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); 712 711 (*val) = 0; 713 712 while (pos < nbytes) … … 718 717 719 718 __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];719 objc_read_unsigned_long (struct objc_typed_stream *stream, 720 unsigned long *value) 721 { 722 unsigned char buf[sizeof (unsigned long) + 1]; 724 723 int len; 725 if ((len = (*stream->read) (stream->physical, buf, 1)))724 if ((len = (*stream->read) (stream->physical, buf, 1))) 726 725 { 727 726 if ((buf[0] & _B_CODE) == _B_SINT) … … 736 735 737 736 __inline__ int 738 objc_read_string (struct objc_typed_stream *stream,739 char **string)740 { 741 unsigned char buf[sizeof (unsigned int)+1];737 objc_read_string (struct objc_typed_stream *stream, 738 char **string) 739 { 740 unsigned char buf[sizeof (unsigned int) + 1]; 742 741 int len; 743 if ((len = (*stream->read) (stream->physical, buf, 1)))742 if ((len = (*stream->read) (stream->physical, buf, 1))) 744 743 { 745 744 unsigned long key = 0; … … 747 746 if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */ 748 747 { 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); 751 750 } 752 751 … … 755 754 { 756 755 int length = buf[0]&_B_VALUE; 757 (*string) = (char*)objc_malloc (length+1);756 (*string) = (char*)objc_malloc (length + 1); 758 757 if (key) 759 758 hash_add (&stream->stream_table, LONG2PTR(key), *string); 760 len = (*stream->read) (stream->physical, *string, length);759 len = (*stream->read) (stream->physical, *string, length); 761 760 (*string)[length] = '\0'; 762 761 } … … 766 765 { 767 766 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); 769 768 tmp = hash_value_for_key (stream->stream_table, LONG2PTR (key)); 770 *string = objc_malloc (strlen (tmp) + 1);769 *string = objc_malloc (strlen (tmp) + 1); 771 770 strcpy (*string, tmp); 772 771 } … … 776 775 { 777 776 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); 779 778 if (len) { 780 (*string) = (char*)objc_malloc (nbytes+1);779 (*string) = (char*)objc_malloc (nbytes + 1); 781 780 if (key) 782 781 hash_add (&stream->stream_table, LONG2PTR(key), *string); 783 len = (*stream->read) (stream->physical, *string, nbytes);782 len = (*stream->read) (stream->physical, *string, nbytes); 784 783 (*string)[nbytes] = '\0'; 785 784 } … … 788 787 789 788 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)); 792 791 } 793 792 } … … 798 797 799 798 int 800 objc_read_object (struct objc_typed_stream * stream, id*object)799 objc_read_object (struct objc_typed_stream *stream, id *object) 801 800 { 802 801 unsigned char buf[sizeof (unsigned int)]; 803 802 int len; 804 if ((len = (*stream->read) (stream->physical, buf, 1)))803 if ((len = (*stream->read) (stream->physical, buf, 1))) 805 804 { 806 805 SEL read_sel = sel_get_any_uid ("read:"); … … 809 808 if ((buf[0]&_B_CODE) == _B_RCOMM) /* register common */ 810 809 { 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); 813 812 } 814 813 … … 821 820 822 821 /* create instance */ 823 (*object) = class_create_instance (class);822 (*object) = class_create_instance (class); 824 823 825 824 /* register? */ … … 829 828 /* send -read: */ 830 829 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); 832 831 833 832 /* check null-byte */ 834 len = (*stream->read) (stream->physical, buf, 1);833 len = (*stream->read) (stream->physical, buf, 1); 835 834 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]); 838 837 } 839 838 … … 841 840 { 842 841 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); 845 844 (*object) = hash_value_for_key (stream->object_table, LONG2PTR(key)); 846 845 } … … 848 847 else if (buf[0] == (_B_EXT | _BX_OBJREF)) /* a forward reference */ 849 848 { 850 struct objc_list *other;849 struct objc_list *other; 851 850 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)); 854 853 hash_add (&stream->object_refs, LONG2PTR(key), 855 (void *)list_cons(object, other));854 (void *)list_cons (object, other)); 856 855 } 857 856 … … 859 858 { 860 859 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..."); 863 862 len = objc_read_object (stream, object); 864 863 __objc_finish_read_root_object (stream); … … 866 865 867 866 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]); 870 869 } 871 870 return len; … … 873 872 874 873 static int 875 objc_read_class (struct objc_typed_stream * stream, Class*class)874 objc_read_class (struct objc_typed_stream *stream, Class *class) 876 875 { 877 876 unsigned char buf[sizeof (unsigned int)]; 878 877 int len; 879 if ((len = (*stream->read) (stream->physical, buf, 1)))878 if ((len = (*stream->read) (stream->physical, buf, 1))) 880 879 { 881 880 unsigned long key = 0; … … 883 882 if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */ 884 883 { 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); 887 886 } 888 887 889 888 if (buf[0] == (_B_EXT | _BX_CLASS)) 890 889 { 891 char *class_name;890 char *class_name; 892 891 unsigned long version; 893 892 894 893 /* get class */ 895 894 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); 898 897 899 898 /* register */ … … 901 900 hash_add (&stream->stream_table, LONG2PTR(key), *class); 902 901 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); 905 904 } 906 905 … … 908 907 { 909 908 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); 916 915 } 917 916 918 917 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]); 921 920 } 922 921 return len; … … 924 923 925 924 int 926 objc_read_selector (struct objc_typed_stream *stream, SEL* selector)925 objc_read_selector (struct objc_typed_stream *stream, SEL* selector) 927 926 { 928 927 unsigned char buf[sizeof (unsigned int)]; 929 928 int len; 930 if ((len = (*stream->read) (stream->physical, buf, 1)))929 if ((len = (*stream->read) (stream->physical, buf, 1))) 931 930 { 932 931 unsigned long key = 0; … … 934 933 if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */ 935 934 { 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); 938 937 } 939 938 940 939 if (buf[0] == (_B_EXT|_BX_SEL)) /* selector! */ 941 940 { 942 char *selector_name;941 char *selector_name; 943 942 944 943 /* get selector */ 945 944 len = objc_read_string (stream, &selector_name); 946 945 /* To handle NULL selectors */ 947 if (0 == strlen (selector_name))946 if (0 == strlen (selector_name)) 948 947 { 949 948 (*selector) = (SEL)0; … … 951 950 } 952 951 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); 955 954 956 955 /* register */ 957 956 if (key) 958 hash_add (&stream->stream_table, LONG2PTR(key), (void *)*selector);957 hash_add (&stream->stream_table, LONG2PTR(key), (void *) *selector); 959 958 } 960 959 … … 962 961 { 963 962 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); 966 965 (*selector) = hash_value_for_key (stream->stream_table, 967 966 LONG2PTR(key)); … … 969 968 970 969 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]); 973 972 } 974 973 return len; … … 985 984 986 985 int 987 objc_write_type (TypedStream* stream, const char* type, const void*data)988 { 989 switch (*type) {986 objc_write_type (TypedStream *stream, const char *type, const void *data) 987 { 988 switch (*type) { 990 989 case _C_ID: 991 return objc_write_object (stream, *(id *)data);990 return objc_write_object (stream, *(id *) data); 992 991 break; 993 992 994 993 case _C_CLASS: 995 return objc_write_class (stream, *(Class *)data);994 return objc_write_class (stream, *(Class *) data); 996 995 break; 997 996 998 997 case _C_SEL: 999 return objc_write_selector (stream, *(SEL *)data);998 return objc_write_selector (stream, *(SEL *) data); 1000 999 break; 1001 1000 1002 1001 case _C_CHR: 1003 return objc_write_char (stream, *(signed char*)data);1002 return objc_write_char (stream, *(signed char *) data); 1004 1003 break; 1005 1004 1006 1005 case _C_UCHR: 1007 return objc_write_unsigned_char (stream, *(unsigned char*)data);1006 return objc_write_unsigned_char (stream, *(unsigned char *) data); 1008 1007 break; 1009 1008 1010 1009 case _C_SHT: 1011 return objc_write_short (stream, *(short*)data);1010 return objc_write_short (stream, *(short *) data); 1012 1011 break; 1013 1012 1014 1013 case _C_USHT: 1015 return objc_write_unsigned_short (stream, *(unsigned short*)data);1014 return objc_write_unsigned_short (stream, *(unsigned short *) data); 1016 1015 break; 1017 1016 1018 1017 case _C_INT: 1019 return objc_write_int (stream, *(int*)data);1018 return objc_write_int (stream, *(int *) data); 1020 1019 break; 1021 1020 1022 1021 case _C_UINT: 1023 return objc_write_unsigned_int (stream, *(unsigned int*)data);1022 return objc_write_unsigned_int (stream, *(unsigned int *) data); 1024 1023 break; 1025 1024 1026 1025 case _C_LNG: 1027 return objc_write_long (stream, *(long*)data);1026 return objc_write_long (stream, *(long *) data); 1028 1027 break; 1029 1028 1030 1029 case _C_ULNG: 1031 return objc_write_unsigned_long (stream, *(unsigned long*)data);1030 return objc_write_unsigned_long (stream, *(unsigned long *) data); 1032 1031 break; 1033 1032 1034 1033 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)); 1036 1036 break; 1037 1037 1038 1038 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)); 1041 1041 break; 1042 1042 1043 1043 case _C_ARY_B: 1044 1044 { 1045 int len = atoi (type+1);1046 while (isdigit (*++type))1045 int len = atoi (type + 1); 1046 while (isdigit ((unsigned char) *++type)) 1047 1047 ; 1048 1048 return objc_write_array (stream, type, len, data); … … 1060 1060 align = objc_alignof_type (type); /* padd to alignment */ 1061 1061 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); 1063 1063 acc_size += objc_sizeof_type (type); /* add component size */ 1064 1064 type = objc_skip_typespec (type); /* skip component */ … … 1069 1069 default: 1070 1070 { 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); 1073 1073 return 0; 1074 1074 } … … 1084 1084 1085 1085 int 1086 objc_read_type(TypedStream * stream, const char* type, void*data)1086 objc_read_type(TypedStream *stream, const char *type, void *data) 1087 1087 { 1088 1088 char c; 1089 switch (c = *type) {1089 switch (c = *type) { 1090 1090 case _C_ID: 1091 1091 return objc_read_object (stream, (id*)data); … … 1139 1139 case _C_ARY_B: 1140 1140 { 1141 int len = atoi (type+1);1142 while (isdigit (*++type))1141 int len = atoi (type + 1); 1142 while (isdigit ((unsigned char) *++type)) 1143 1143 ; 1144 1144 return objc_read_array (stream, type, len, data); … … 1165 1165 default: 1166 1166 { 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); 1169 1169 return 0; 1170 1170 } … … 1183 1183 1184 1184 int 1185 objc_write_types (TypedStream * stream, const char*type, ...)1185 objc_write_types (TypedStream *stream, const char *type, ...) 1186 1186 { 1187 1187 va_list args; … … 1193 1193 for (c = type; *c; c = objc_skip_typespec (c)) 1194 1194 { 1195 switch (*c) {1195 switch (*c) { 1196 1196 case _C_ID: 1197 1197 res = objc_write_object (stream, *va_arg (args, id*)); … … 1199 1199 1200 1200 case _C_CLASS: 1201 res = objc_write_class (stream, *va_arg (args, Class*));1201 res = objc_write_class (stream, *va_arg (args, Class*)); 1202 1202 break; 1203 1203 1204 1204 case _C_SEL: 1205 res = objc_write_selector (stream, *va_arg (args, SEL*));1205 res = objc_write_selector (stream, *va_arg (args, SEL*)); 1206 1206 break; 1207 1207 … … 1216 1216 1217 1217 case _C_SHT: 1218 res = objc_write_short (stream, *va_arg (args, short*));1218 res = objc_write_short (stream, *va_arg (args, short*)); 1219 1219 break; 1220 1220 1221 1221 case _C_USHT: 1222 1222 res = objc_write_unsigned_short (stream, 1223 *va_arg (args, unsigned short*));1223 *va_arg (args, unsigned short*)); 1224 1224 break; 1225 1225 1226 1226 case _C_INT: 1227 res = objc_write_int(stream, *va_arg (args, int*));1227 res = objc_write_int(stream, *va_arg (args, int*)); 1228 1228 break; 1229 1229 1230 1230 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*)); 1232 1232 break; 1233 1233 1234 1234 case _C_LNG: 1235 res = objc_write_long(stream, *va_arg (args, long*));1235 res = objc_write_long(stream, *va_arg (args, long*)); 1236 1236 break; 1237 1237 1238 1238 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*)); 1240 1240 break; 1241 1241 1242 1242 case _C_CHARPTR: 1243 1243 { 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)); 1246 1246 } 1247 1247 break; … … 1249 1249 case _C_ATOM: 1250 1250 { 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)); 1253 1253 } 1254 1254 break; … … 1256 1256 case _C_ARY_B: 1257 1257 { 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)) 1261 1261 ; 1262 res = objc_write_array (stream, t, len, va_arg (args, void*));1262 res = objc_write_array (stream, t, len, va_arg (args, void *)); 1263 1263 t = objc_skip_typespec (t); 1264 1264 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); 1266 1266 } 1267 1267 break; 1268 1268 1269 1269 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); 1272 1272 } 1273 1273 } … … 1283 1283 1284 1284 int 1285 objc_read_types(TypedStream * stream, const char*type, ...)1285 objc_read_types(TypedStream *stream, const char *type, ...) 1286 1286 { 1287 1287 va_list args; … … 1289 1289 int res = 0; 1290 1290 1291 va_start (args, type);1291 va_start (args, type); 1292 1292 1293 1293 for (c = type; *c; c = objc_skip_typespec(c)) 1294 1294 { 1295 switch (*c) {1295 switch (*c) { 1296 1296 case _C_ID: 1297 res = objc_read_object(stream, va_arg (args, id*));1297 res = objc_read_object(stream, va_arg (args, id*)); 1298 1298 break; 1299 1299 1300 1300 case _C_CLASS: 1301 res = objc_read_class(stream, va_arg (args, Class*));1301 res = objc_read_class(stream, va_arg (args, Class*)); 1302 1302 break; 1303 1303 1304 1304 case _C_SEL: 1305 res = objc_read_selector(stream, va_arg (args, SEL*));1305 res = objc_read_selector(stream, va_arg (args, SEL*)); 1306 1306 break; 1307 1307 1308 1308 case _C_CHR: 1309 res = objc_read_char(stream, va_arg (args, char*));1309 res = objc_read_char(stream, va_arg (args, char*)); 1310 1310 break; 1311 1311 1312 1312 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*)); 1314 1314 break; 1315 1315 1316 1316 case _C_SHT: 1317 res = objc_read_short(stream, va_arg (args, short*));1317 res = objc_read_short(stream, va_arg (args, short*)); 1318 1318 break; 1319 1319 1320 1320 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*)); 1322 1322 break; 1323 1323 1324 1324 case _C_INT: 1325 res = objc_read_int(stream, va_arg (args, int*));1325 res = objc_read_int(stream, va_arg (args, int*)); 1326 1326 break; 1327 1327 1328 1328 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*)); 1330 1330 break; 1331 1331 1332 1332 case _C_LNG: 1333 res = objc_read_long(stream, va_arg (args, long*));1333 res = objc_read_long(stream, va_arg (args, long*)); 1334 1334 break; 1335 1335 1336 1336 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*)); 1338 1338 break; 1339 1339 … … 1341 1341 case _C_ATOM: 1342 1342 { 1343 char ** str = va_arg(args, char**);1343 char **str = va_arg (args, char **); 1344 1344 res = objc_read_string (stream, str); 1345 1345 } … … 1348 1348 case _C_ARY_B: 1349 1349 { 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)) 1353 1353 ; 1354 res = objc_read_array (stream, t, len, va_arg (args, void*));1354 res = objc_read_array (stream, t, len, va_arg (args, void *)); 1355 1355 t = objc_skip_typespec (t); 1356 1356 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); 1358 1358 } 1359 1359 break; 1360 1360 1361 1361 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); 1364 1364 } 1365 1365 } 1366 va_end (args);1366 va_end (args); 1367 1367 return res; 1368 1368 } … … 1374 1374 1375 1375 int 1376 objc_write_array (TypedStream * stream, const char*type,1377 int count, const void *data)1376 objc_write_array (TypedStream *stream, const char *type, 1377 int count, const void *data) 1378 1378 { 1379 1379 int off = objc_sizeof_type(type); 1380 const char *where = data;1380 const char *where = data; 1381 1381 1382 1382 while (count-- > 0) … … 1396 1396 1397 1397 int 1398 objc_read_array (TypedStream * stream, const char*type,1399 int count, void *data)1398 objc_read_array (TypedStream *stream, const char *type, 1399 int count, void *data) 1400 1400 { 1401 1401 int off = objc_sizeof_type(type); 1402 char *where = (char*)data;1402 char *where = (char*)data; 1403 1403 1404 1404 while (count-- > 0) … … 1411 1411 1412 1412 static int 1413 __objc_fread (FILE* file, char*data, int len)1413 __objc_fread (FILE *file, char *data, int len) 1414 1414 { 1415 1415 return fread(data, len, 1, file); … … 1417 1417 1418 1418 static int 1419 __objc_fwrite (FILE* file, char*data, int len)1419 __objc_fwrite (FILE *file, char *data, int len) 1420 1420 { 1421 1421 return fwrite(data, len, 1, file); … … 1423 1423 1424 1424 static int 1425 __objc_feof (FILE*file)1425 __objc_feof (FILE *file) 1426 1426 { 1427 1427 return feof(file); … … 1429 1429 1430 1430 static 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__))) 1432 1434 { 1433 1435 objc_error (nil, OBJC_ERR_NO_WRITE, "TypedStream not open for writing"); … … 1436 1438 1437 1439 static 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__))) 1439 1443 { 1440 1444 objc_error (nil, OBJC_ERR_NO_READ, "TypedStream not open for reading"); … … 1443 1447 1444 1448 static int 1445 __objc_read_typed_stream_signature (TypedStream *stream)1449 __objc_read_typed_stream_signature (TypedStream *stream) 1446 1450 { 1447 1451 char buffer[80]; 1448 1452 int pos = 0; 1449 1453 do 1450 (*stream->read) (stream->physical, buffer+pos, 1);1454 (*stream->read) (stream->physical, buffer+pos, 1); 1451 1455 while (buffer[pos++] != '\0') 1452 1456 ; … … 1459 1463 1460 1464 static int 1461 __objc_write_typed_stream_signature (TypedStream *stream)1465 __objc_write_typed_stream_signature (TypedStream *stream) 1462 1466 { 1463 1467 char buffer[80]; 1464 1468 sprintf(buffer, "GNU TypedStream %d", OBJC_TYPED_STREAM_VERSION); 1465 1469 stream->version = OBJC_TYPED_STREAM_VERSION; 1466 (*stream->write) (stream->physical, buffer, strlen(buffer)+1);1470 (*stream->write) (stream->physical, buffer, strlen (buffer) + 1); 1467 1471 return 1; 1468 1472 } 1469 1473 1470 static void __objc_finish_write_root_object(struct objc_typed_stream *stream)1474 static void __objc_finish_write_root_object(struct objc_typed_stream *stream) 1471 1475 { 1472 1476 hash_delete (stream->object_table); … … 1476 1480 } 1477 1481 1478 static void __objc_finish_read_root_object(struct objc_typed_stream *stream)1482 static void __objc_finish_read_root_object(struct objc_typed_stream *stream) 1479 1483 { 1480 1484 node_ptr node; … … 1488 1492 node = hash_next (stream->object_refs, node)) 1489 1493 { 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; 1492 1496 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; 1496 1500 if (hash_value_for_key (free_list,reflist) == NULL) 1497 1501 hash_add (&free_list,reflist,reflist); … … 1521 1525 id object = node->value; 1522 1526 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); 1524 1528 } 1525 1529 } … … 1536 1540 */ 1537 1541 1538 TypedStream *1539 objc_open_typed_stream (FILE *physical, int mode)1540 { 1541 TypedStream * s = (TypedStream*)objc_malloc(sizeof(TypedStream));1542 TypedStream * 1543 objc_open_typed_stream (FILE *physical, int mode) 1544 { 1545 TypedStream *s = (TypedStream *) objc_malloc (sizeof (TypedStream)); 1542 1546 1543 1547 s->mode = mode; 1544 1548 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; 1553 1557 s->writing_root_p = 0; 1554 1558 if (mode == OBJC_READONLY) 1555 1559 { 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; 1562 1566 __objc_read_typed_stream_signature (s); 1563 1567 } … … 1566 1570 s->class_table = 0; 1567 1571 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; 1570 1574 __objc_write_typed_stream_signature (s); 1571 1575 } … … 1584 1588 1585 1589 TypedStream* 1586 objc_open_typed_stream_for_file (const char *file_name, int mode)1587 { 1588 FILE *file = NULL;1589 TypedStream *s;1590 objc_open_typed_stream_for_file (const char *file_name, int mode) 1591 { 1592 FILE *file = NULL; 1593 TypedStream *s; 1590 1594 1591 1595 if (mode == OBJC_READONLY) … … 1611 1615 1612 1616 void 1613 objc_close_typed_stream (TypedStream *stream)1617 objc_close_typed_stream (TypedStream *stream) 1614 1618 { 1615 1619 if (stream->mode == OBJC_READONLY) … … 1624 1628 1625 1629 if (stream->type == (OBJC_MANAGED_STREAM | OBJC_FILE_STREAM)) 1626 fclose ((FILE *)stream->physical);1630 fclose ((FILE *)stream->physical); 1627 1631 1628 1632 objc_free(stream); … … 1630 1634 1631 1635 BOOL 1632 objc_end_of_typed_stream (TypedStream *stream)1633 { 1634 return (*stream->eof) (stream->physical);1636 objc_end_of_typed_stream (TypedStream *stream) 1637 { 1638 return (*stream->eof) (stream->physical); 1635 1639 } 1636 1640 1637 1641 void 1638 objc_flush_typed_stream (TypedStream *stream)1639 { 1640 (*stream->flush) (stream->physical);1642 objc_flush_typed_stream (TypedStream *stream) 1643 { 1644 (*stream->flush) (stream->physical); 1641 1645 } 1642 1646 1643 1647 long 1644 objc_get_stream_class_version (TypedStream *stream, Class class)1648 objc_get_stream_class_version (TypedStream *stream, Class class) 1645 1649 { 1646 1650 if (stream->class_table) -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/class.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* 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. 3 4 Contributed by Kresten Krab Thorup and Dennis Glatting. 4 5 … … 164 165 /* Setup the table. */ 165 166 static void 166 class_table_setup ( )167 class_table_setup (void) 167 168 { 168 169 /* 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); 170 171 171 172 /* The table writing mutex. */ … … 340 341 /* Debugging function - print the class table. */ 341 342 void 342 class_table_print ( )343 class_table_print (void) 343 344 { 344 345 int i; … … 363 364 in real cases. */ 364 365 void 365 class_table_print_histogram ( )366 class_table_print_histogram (void) 366 367 { 367 368 int i, j; … … 409 410 objc_lookup_class if the runtime is not able to find the class. 410 411 This may e.g. try to load in the class using dynamic loading. */ 411 Class (*_objc_lookup_class) (const char*name) = 0; /* !T:SAFE */412 Class (*_objc_lookup_class) (const char *name) = 0; /* !T:SAFE */ 412 413 413 414 … … 416 417 417 418 418 void __objc_init_class_tables() 419 void 420 __objc_init_class_tables (void) 419 421 { 420 422 /* Allocate the class hash table. */ 421 423 422 if (__class_table_lock)424 if (__class_table_lock) 423 425 return; 424 426 425 objc_mutex_lock (__objc_runtime_mutex);427 objc_mutex_lock (__objc_runtime_mutex); 426 428 427 429 class_table_setup (); 428 430 429 objc_mutex_unlock (__objc_runtime_mutex);431 objc_mutex_unlock (__objc_runtime_mutex); 430 432 } 431 433 … … 433 435 class a number, unless it's already known. */ 434 436 void 435 __objc_add_class_to_hash (Class class)437 __objc_add_class_to_hash (Class class) 436 438 { 437 439 Class h_class; 438 440 439 objc_mutex_lock (__objc_runtime_mutex);441 objc_mutex_lock (__objc_runtime_mutex); 440 442 441 443 /* Make sure the table is there. */ 442 assert (__class_table_lock);444 assert (__class_table_lock); 443 445 444 446 /* Make sure it's not a meta class. */ 445 assert (CLS_ISCLASS(class));447 assert (CLS_ISCLASS (class)); 446 448 447 449 /* Check to see if the class is already in the hash table. */ 448 450 h_class = class_table_get_safe (class->name); 449 if (! h_class)451 if (! h_class) 450 452 { 451 453 /* The class isn't in the hash table. Add the class and assign a class … … 453 455 static unsigned int class_number = 1; 454 456 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); 457 459 458 460 ++class_number; … … 460 462 } 461 463 462 objc_mutex_unlock (__objc_runtime_mutex);464 objc_mutex_unlock (__objc_runtime_mutex); 463 465 } 464 466 … … 466 468 identify a known class, the hook _objc_lookup_class is called. If 467 469 this fails, nil is returned. */ 468 Class objc_lookup_class (const char* name) 470 Class 471 objc_lookup_class (const char *name) 469 472 { 470 473 Class class; … … 476 479 477 480 if (_objc_lookup_class) 478 return (*_objc_lookup_class) (name);481 return (*_objc_lookup_class) (name); 479 482 else 480 483 return 0; … … 495 498 496 499 if (_objc_lookup_class) 497 class = (*_objc_lookup_class) (name);498 499 if (class)500 class = (*_objc_lookup_class) (name); 501 502 if (class) 500 503 return class; 501 504 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); 504 507 return 0; 505 508 } 506 509 507 510 MetaClass 508 objc_get_meta_class (const char *name)509 { 510 return objc_get_class (name)->class_pointer;511 objc_get_meta_class (const char *name) 512 { 513 return objc_get_class (name)->class_pointer; 511 514 } 512 515 … … 517 520 id class; 518 521 void *es = NULL; 519 while ((class = objc_next_class (&es)))522 while ((class = objc_next_class (&es))) 520 523 ... do something with class; 521 524 */ 522 525 Class 523 objc_next_class (void **enum_state)526 objc_next_class (void **enum_state) 524 527 { 525 528 Class class; 526 529 527 objc_mutex_lock (__objc_runtime_mutex);530 objc_mutex_lock (__objc_runtime_mutex); 528 531 529 532 /* 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); 535 538 536 539 return class; … … 540 543 can be sure of is that the class_pointer for class objects point to 541 544 the right meta class objects. */ 542 void __objc_resolve_class_links() 545 void 546 __objc_resolve_class_links (void) 543 547 { 544 548 struct class_table_enumerator *es = NULL; … … 546 550 Class class1; 547 551 548 assert (object_class);549 550 objc_mutex_lock (__objc_runtime_mutex);552 assert (object_class); 553 554 objc_mutex_lock (__objc_runtime_mutex); 551 555 552 556 /* Assign subclass links. */ … … 554 558 { 555 559 /* 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)); 558 562 559 563 /* The class_pointer of all meta classes point to Object's meta … … 561 565 class1->class_pointer->class_pointer = object_class->class_pointer; 562 566 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); 567 571 568 if (class1->super_class)572 if (class1->super_class) 569 573 { 570 574 Class a_super_class … … 608 612 { 609 613 sub_class->super_class = class1; 610 if (CLS_ISCLASS(sub_class))614 if (CLS_ISCLASS (sub_class)) 611 615 sub_class->class_pointer->super_class = class1->class_pointer; 612 616 } 613 617 } 614 618 615 objc_mutex_unlock (__objc_runtime_mutex);619 objc_mutex_unlock (__objc_runtime_mutex); 616 620 } 617 621 … … 623 627 class_pose_as (Class impostor, Class super_class) 624 628 { 625 if (! CLS_ISRESOLV (impostor))629 if (! CLS_ISRESOLV (impostor)) 626 630 __objc_resolve_class_links (); 627 631 … … 686 690 into impostor. */ 687 691 688 objc_mutex_lock (__objc_runtime_mutex);692 objc_mutex_lock (__objc_runtime_mutex); 689 693 690 694 class_table_replace (super_class, impostor); 691 695 692 objc_mutex_unlock (__objc_runtime_mutex);696 objc_mutex_unlock (__objc_runtime_mutex); 693 697 694 698 /* Next, we update the dispatch tables... */ -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/configure
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 773 773 # canonicalize only relative paths, because then amd will not unmount 774 774 # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd. 775 glibcpp_builddir=` pwd`775 glibcpp_builddir=`${PWDCMD-pwd}` 776 776 case $srcdir in 777 777 \\/$* | ?:\\/*) glibcpp_srcdir=${srcdir} ;; … … 1605 1605 1606 1606 hpux10.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 1610 1619 ;; 1611 1620 … … 1697 1706 1698 1707 echo $ac_n "checking for object suffix""... $ac_c" 1>&6 1699 echo "configure:170 0: checking for object suffix" >&51708 echo "configure:1709: checking for object suffix" >&5 1700 1709 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then 1701 1710 echo $ac_n "(cached) $ac_c" 1>&6 … … 1703 1712 rm -f conftest* 1704 1713 echo 'int i = 1;' > conftest.$ac_ext 1705 if { (eval echo configure:17 06: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then1714 if { (eval echo configure:1715: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then 1706 1715 for ac_file in conftest.*; do 1707 1716 case $ac_file in … … 1727 1736 if test "$file_magic_cmd" = '$MAGIC_CMD'; then 1728 1737 echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6 1729 echo "configure:173 0: checking for ${ac_tool_prefix}file" >&51738 echo "configure:1739: checking for ${ac_tool_prefix}file" >&5 1730 1739 if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then 1731 1740 echo $ac_n "(cached) $ac_c" 1>&6 … … 1789 1798 if test -n "$ac_tool_prefix"; then 1790 1799 echo $ac_n "checking for file""... $ac_c" 1>&6 1791 echo "configure:1 792: checking for file" >&51800 echo "configure:1801: checking for file" >&5 1792 1801 if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then 1793 1802 echo $ac_n "(cached) $ac_c" 1>&6 … … 1860 1869 set dummy ${ac_tool_prefix}ranlib; ac_word=$2 1861 1870 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 1862 echo "configure:18 63: checking for $ac_word" >&51871 echo "configure:1872: checking for $ac_word" >&5 1863 1872 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then 1864 1873 echo $ac_n "(cached) $ac_c" 1>&6 … … 1892 1901 set dummy ranlib; ac_word=$2 1893 1902 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 1894 echo "configure:1 895: checking for $ac_word" >&51903 echo "configure:1904: checking for $ac_word" >&5 1895 1904 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then 1896 1905 echo $ac_n "(cached) $ac_c" 1>&6 … … 1927 1936 set dummy ${ac_tool_prefix}strip; ac_word=$2 1928 1937 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 1929 echo "configure:193 0: checking for $ac_word" >&51938 echo "configure:1939: checking for $ac_word" >&5 1930 1939 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then 1931 1940 echo $ac_n "(cached) $ac_c" 1>&6 … … 1959 1968 set dummy strip; ac_word=$2 1960 1969 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 1961 echo "configure:19 62: checking for $ac_word" >&51970 echo "configure:1971: checking for $ac_word" >&5 1962 1971 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then 1963 1972 echo $ac_n "(cached) $ac_c" 1>&6 … … 2026 2035 *-*-irix6*) 2027 2036 # 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 2030 2052 case `/usr/bin/file conftest.$ac_objext` in 2031 2053 *32-bit*) … … 2039 2061 ;; 2040 2062 esac 2063 fi 2064 fi 2065 rm -rf conftest* 2066 ;; 2067 2068 ia64-*-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 2084 x86_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 2041 2122 fi 2042 2123 rm -rf conftest* … … 2048 2129 CFLAGS="$CFLAGS -belf" 2049 2130 echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6 2050 echo "configure:2 051: checking whether the C compiler needs -belf" >&52131 echo "configure:2132: checking whether the C compiler needs -belf" >&5 2051 2132 if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then 2052 2133 echo $ac_n "(cached) $ac_c" 1>&6 … … 2061 2142 2062 2143 cat > conftest.$ac_ext <<EOF 2063 #line 2 064"configure"2144 #line 2145 "configure" 2064 2145 #include "confdefs.h" 2065 2146 … … 2068 2149 ; return 0; } 2069 2150 EOF 2070 if { (eval echo configure:2 071: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then2151 if { (eval echo configure:2152: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 2071 2152 rm -rf conftest* 2072 2153 lt_cv_cc_needs_belf=yes … … 2098 2179 set dummy ${ac_tool_prefix}dlltool; ac_word=$2 2099 2180 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 2100 echo "configure:21 01: checking for $ac_word" >&52181 echo "configure:2182: checking for $ac_word" >&5 2101 2182 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then 2102 2183 echo $ac_n "(cached) $ac_c" 1>&6 … … 2130 2211 set dummy dlltool; ac_word=$2 2131 2212 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 2132 echo "configure:2 133: checking for $ac_word" >&52213 echo "configure:2214: checking for $ac_word" >&5 2133 2214 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then 2134 2215 echo $ac_n "(cached) $ac_c" 1>&6 … … 2165 2246 set dummy ${ac_tool_prefix}as; ac_word=$2 2166 2247 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 2167 echo "configure:2 168: checking for $ac_word" >&52248 echo "configure:2249: checking for $ac_word" >&5 2168 2249 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then 2169 2250 echo $ac_n "(cached) $ac_c" 1>&6 … … 2197 2278 set dummy as; ac_word=$2 2198 2279 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 2199 echo "configure:22 00: checking for $ac_word" >&52280 echo "configure:2281: checking for $ac_word" >&5 2200 2281 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then 2201 2282 echo $ac_n "(cached) $ac_c" 1>&6 … … 2232 2313 set dummy ${ac_tool_prefix}objdump; ac_word=$2 2233 2314 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 2234 echo "configure:2 235: checking for $ac_word" >&52315 echo "configure:2316: checking for $ac_word" >&5 2235 2316 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then 2236 2317 echo $ac_n "(cached) $ac_c" 1>&6 … … 2264 2345 set dummy objdump; ac_word=$2 2265 2346 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 2266 echo "configure:2 267: checking for $ac_word" >&52347 echo "configure:2348: checking for $ac_word" >&5 2267 2348 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then 2268 2349 echo $ac_n "(cached) $ac_c" 1>&6 … … 2300 2381 # can override, but on older systems we have to supply one 2301 2382 echo $ac_n "checking if libtool should supply DllMain function""... $ac_c" 1>&6 2302 echo "configure:23 03: checking if libtool should supply DllMain function" >&52383 echo "configure:2384: checking if libtool should supply DllMain function" >&5 2303 2384 if eval "test \"`echo '$''{'lt_cv_need_dllmain'+set}'`\" = set"; then 2304 2385 echo $ac_n "(cached) $ac_c" 1>&6 2305 2386 else 2306 2387 cat > conftest.$ac_ext <<EOF 2307 #line 23 08"configure"2388 #line 2389 "configure" 2308 2389 #include "confdefs.h" 2309 2390 … … 2313 2394 ; return 0; } 2314 2395 EOF 2315 if { (eval echo configure:23 16: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then2396 if { (eval echo configure:2397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 2316 2397 rm -rf conftest* 2317 2398 lt_cv_need_dllmain=no … … 2334 2415 CFLAGS="$CFLAGS -mdll" 2335 2416 echo $ac_n "checking how to link DLLs""... $ac_c" 1>&6 2336 echo "configure:2 337: checking how to link DLLs" >&52417 echo "configure:2418: checking how to link DLLs" >&5 2337 2418 if eval "test \"`echo '$''{'lt_cv_cc_dll_switch'+set}'`\" = set"; then 2338 2419 echo $ac_n "(cached) $ac_c" 1>&6 2339 2420 else 2340 2421 cat > conftest.$ac_ext <<EOF 2341 #line 2 342"configure"2422 #line 2423 "configure" 2342 2423 #include "confdefs.h" 2343 2424 … … 2346 2427 ; return 0; } 2347 2428 EOF 2348 if { (eval echo configure:2 349: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then2429 if { (eval echo configure:2430: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then 2349 2430 rm -rf conftest* 2350 2431 lt_cv_cc_dll_switch=-mdll … … 2464 2545 set dummy ranlib; ac_word=$2 2465 2546 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 2466 echo "configure:2 467: checking for $ac_word" >&52547 echo "configure:2548: checking for $ac_word" >&5 2467 2548 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then 2468 2549 echo $ac_n "(cached) $ac_c" 1>&6 … … 2504 2585 # ./install, which can be erroneously created by make from ./install.sh. 2505 2586 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 2506 echo "configure:25 07: checking for a BSD compatible install" >&52587 echo "configure:2588: checking for a BSD compatible install" >&5 2507 2588 if test -z "$INSTALL"; then 2508 2589 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then … … 2557 2638 2558 2639 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 2559 echo "configure:2 560: checking whether ${MAKE-make} sets \${MAKE}" >&52640 echo "configure:2641: checking whether ${MAKE-make} sets \${MAKE}" >&5 2560 2641 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` 2561 2642 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then … … 2586 2667 # Sanity check for the cross-compilation case: 2587 2668 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 2588 echo "configure:2 589: checking how to run the C preprocessor" >&52669 echo "configure:2670: checking how to run the C preprocessor" >&5 2589 2670 # On Suns, sometimes $CPP names a directory. 2590 2671 if test -n "$CPP" && test -d "$CPP"; then … … 2601 2682 # not just through cpp. 2602 2683 cat > conftest.$ac_ext <<EOF 2603 #line 26 04"configure"2684 #line 2685 "configure" 2604 2685 #include "confdefs.h" 2605 2686 #include <assert.h> … … 2607 2688 EOF 2608 2689 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 2609 { (eval echo configure:26 10: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }2690 { (eval echo configure:2691: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } 2610 2691 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` 2611 2692 if test -z "$ac_err"; then … … 2618 2699 CPP="${CC-cc} -E -traditional-cpp" 2619 2700 cat > conftest.$ac_ext <<EOF 2620 #line 2 621"configure"2701 #line 2702 "configure" 2621 2702 #include "confdefs.h" 2622 2703 #include <assert.h> … … 2624 2705 EOF 2625 2706 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 2626 { (eval echo configure:2 627: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }2707 { (eval echo configure:2708: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } 2627 2708 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` 2628 2709 if test -z "$ac_err"; then … … 2635 2716 CPP="${CC-cc} -nologo -E" 2636 2717 cat > conftest.$ac_ext <<EOF 2637 #line 2 638"configure"2718 #line 2719 "configure" 2638 2719 #include "confdefs.h" 2639 2720 #include <assert.h> … … 2641 2722 EOF 2642 2723 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 2643 { (eval echo configure:2 644: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }2724 { (eval echo configure:2725: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } 2644 2725 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` 2645 2726 if test -z "$ac_err"; then … … 2667 2748 ac_safe=`echo "stdio.h" | sed 'y%./+-%__p_%'` 2668 2749 echo $ac_n "checking for stdio.h""... $ac_c" 1>&6 2669 echo "configure:2 670: checking for stdio.h" >&52750 echo "configure:2751: checking for stdio.h" >&5 2670 2751 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then 2671 2752 echo $ac_n "(cached) $ac_c" 1>&6 2672 2753 else 2673 2754 cat > conftest.$ac_ext <<EOF 2674 #line 2 675"configure"2755 #line 2756 "configure" 2675 2756 #include "confdefs.h" 2676 2757 #include <stdio.h> 2677 2758 EOF 2678 2759 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 2679 { (eval echo configure:2 680: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }2760 { (eval echo configure:2761: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } 2680 2761 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` 2681 2762 if test -z "$ac_err"; then … … 2705 2786 2706 2787 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 2707 echo "configure:27 08: checking for ANSI C header files" >&52788 echo "configure:2789: checking for ANSI C header files" >&5 2708 2789 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then 2709 2790 echo $ac_n "(cached) $ac_c" 1>&6 2710 2791 else 2711 2792 cat > conftest.$ac_ext <<EOF 2712 #line 27 13"configure"2793 #line 2794 "configure" 2713 2794 #include "confdefs.h" 2714 2795 #include <stdlib.h> … … 2718 2799 EOF 2719 2800 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 2720 { (eval echo configure:2 721: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }2801 { (eval echo configure:2802: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } 2721 2802 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` 2722 2803 if test -z "$ac_err"; then … … 2735 2816 # SunOS 4.x string.h does not declare mem*, contrary to ANSI. 2736 2817 cat > conftest.$ac_ext <<EOF 2737 #line 2 738"configure"2818 #line 2819 "configure" 2738 2819 #include "confdefs.h" 2739 2820 #include <string.h> … … 2753 2834 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. 2754 2835 cat > conftest.$ac_ext <<EOF 2755 #line 2 756"configure"2836 #line 2837 "configure" 2756 2837 #include "confdefs.h" 2757 2838 #include <stdlib.h> … … 2774 2855 else 2775 2856 cat > conftest.$ac_ext <<EOF 2776 #line 2 777"configure"2857 #line 2858 "configure" 2777 2858 #include "confdefs.h" 2778 2859 #include <ctype.h> … … 2785 2866 2786 2867 EOF 2787 if { (eval echo configure:2 788: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null2868 if { (eval echo configure:2869: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null 2788 2869 then 2789 2870 : … … 2813 2894 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` 2814 2895 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 2815 echo "configure:28 16: checking for $ac_hdr" >&52896 echo "configure:2897: checking for $ac_hdr" >&5 2816 2897 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then 2817 2898 echo $ac_n "(cached) $ac_c" 1>&6 2818 2899 else 2819 2900 cat > conftest.$ac_ext <<EOF 2820 #line 2 821"configure"2901 #line 2902 "configure" 2821 2902 #include "confdefs.h" 2822 2903 #include <$ac_hdr> 2823 2904 EOF 2824 2905 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 2825 { (eval echo configure:2 826: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }2906 { (eval echo configure:2907: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } 2826 2907 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` 2827 2908 if test -z "$ac_err"; then … … 2853 2934 2854 2935 echo $ac_n "checking for gthread cflags""... $ac_c" 1>&6 2855 echo "configure:2 856: checking for gthread cflags" >&52936 echo "configure:2937: checking for gthread cflags" >&5 2856 2937 if eval "test \"`echo '$''{'objc_cv_gthread_flags'+set}'`\" = set"; then 2857 2938 echo $ac_n "(cached) $ac_c" 1>&6 … … 3276 3357 toplevel_srcdir=${toplevel_srcdir} 3277 3358 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} 3359 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}" 3278 3360 3279 3361 EOF -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/configure.in
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 # 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. 3 4 # Contributed by Dave Love (d.love@dl.ac.uk). 4 5 # … … 144 145 toplevel_srcdir=${toplevel_srcdir} 145 146 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} 147 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}" 146 148 ) 147 149 -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/encoding.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* 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. 3 4 Contributed by Kresten Krab Thorup 4 5 Bitfield support by Ovidiu Predescu … … 30 31 #include "objc-api.h" 31 32 #include "encoding.h" 33 #include <stdlib.h> 32 34 33 35 #undef MAX 34 36 #define MAX(X, Y) \ 35 ({ typeof (X) __x = (X), __y = (Y); \37 ({ typeof (X) __x = (X), __y = (Y); \ 36 38 (__x > __y ? __x : __y); }) 37 39 38 40 #undef MIN 39 41 #define MIN(X, Y) \ 40 ({ typeof (X) __x = (X), __y = (Y); \42 ({ typeof (X) __x = (X), __y = (Y); \ 41 43 (__x < __y ? __x : __y); }) 42 44 43 45 #undef ROUND 44 46 #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); }) 47 49 48 50 … … 79 81 /* Some ROUND_TYPE_ALIGN macros use TARGET_foo, and consequently 80 82 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. */ 85 static int __attribute__ ((__unused__)) target_flags = 0; 86 87 /* 88 return the size of an object specified by type 97 89 */ 98 90 99 91 int 100 objc_sizeof_type (const char *type)92 objc_sizeof_type (const char *type) 101 93 { 102 94 /* Skip the variable name if any */ … … 107 99 } 108 100 109 switch (*type) {101 switch (*type) { 110 102 case _C_ID: 111 return sizeof (id);103 return sizeof (id); 112 104 break; 113 105 114 106 case _C_CLASS: 115 return sizeof (Class);107 return sizeof (Class); 116 108 break; 117 109 118 110 case _C_SEL: 119 return sizeof (SEL);111 return sizeof (SEL); 120 112 break; 121 113 122 114 case _C_CHR: 123 return sizeof (char);124 break; 125 115 return sizeof (char); 116 break; 117 126 118 case _C_UCHR: 127 return sizeof (unsigned char);119 return sizeof (unsigned char); 128 120 break; 129 121 130 122 case _C_SHT: 131 return sizeof (short);123 return sizeof (short); 132 124 break; 133 125 134 126 case _C_USHT: 135 return sizeof (unsigned short);127 return sizeof (unsigned short); 136 128 break; 137 129 138 130 case _C_INT: 139 return sizeof (int);131 return sizeof (int); 140 132 break; 141 133 142 134 case _C_UINT: 143 return sizeof (unsigned int);135 return sizeof (unsigned int); 144 136 break; 145 137 146 138 case _C_LNG: 147 return sizeof (long);139 return sizeof (long); 148 140 break; 149 141 150 142 case _C_ULNG: 151 return sizeof (unsigned long);143 return sizeof (unsigned long); 152 144 break; 153 145 154 146 case _C_LNG_LNG: 155 return sizeof (long long);147 return sizeof (long long); 156 148 break; 157 149 158 150 case _C_ULNG_LNG: 159 return sizeof (unsigned long long);151 return sizeof (unsigned long long); 160 152 break; 161 153 162 154 case _C_FLT: 163 return sizeof (float);155 return sizeof (float); 164 156 break; 165 157 166 158 case _C_DBL: 167 return sizeof (double);159 return sizeof (double); 168 160 break; 169 161 170 162 case _C_VOID: 171 return sizeof(void); 172 break; 163 return sizeof (void); 164 break; 165 173 166 case _C_PTR: 174 167 case _C_ATOM: 175 168 case _C_CHARPTR: 176 return sizeof (char*);169 return sizeof (char *); 177 170 break; 178 171 179 172 case _C_ARY_B: 180 173 { 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; 186 180 187 181 case _C_BFLD: … … 192 186 193 187 position = atoi (type + 1); 194 while (isdigit (*++type)); 188 while (isdigit ((unsigned char)*++type)) 189 ; 195 190 size = atoi (type + 1); 196 191 … … 216 211 { 217 212 int max_size = 0; 218 while (*type != _C_UNION_E && *type++ != '=') /* do nothing */; 213 while (*type != _C_UNION_E && *type++ != '=') 214 /* do nothing */; 219 215 while (*type != _C_UNION_E) 220 216 { … … 230 226 return max_size; 231 227 } 232 228 233 229 default: 234 230 { 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); 236 232 return 0; 237 233 } … … 241 237 242 238 /* 243 Return the alignment of an object specified by type 239 Return the alignment of an object specified by type 244 240 */ 245 241 246 242 int 247 objc_alignof_type (const char*type)243 objc_alignof_type (const char *type) 248 244 { 249 245 /* Skip the variable name if any */ … … 253 249 /* do nothing */; 254 250 } 255 switch (*type) {251 switch (*type) { 256 252 case _C_ID: 257 return __alignof__ (id);253 return __alignof__ (id); 258 254 break; 259 255 260 256 case _C_CLASS: 261 return __alignof__ (Class);262 break; 263 257 return __alignof__ (Class); 258 break; 259 264 260 case _C_SEL: 265 return __alignof__ (SEL);261 return __alignof__ (SEL); 266 262 break; 267 263 268 264 case _C_CHR: 269 return __alignof__ (char);270 break; 271 265 return __alignof__ (char); 266 break; 267 272 268 case _C_UCHR: 273 return __alignof__ (unsigned char);269 return __alignof__ (unsigned char); 274 270 break; 275 271 276 272 case _C_SHT: 277 return __alignof__ (short);273 return __alignof__ (short); 278 274 break; 279 275 280 276 case _C_USHT: 281 return __alignof__ (unsigned short);277 return __alignof__ (unsigned short); 282 278 break; 283 279 284 280 case _C_INT: 285 return __alignof__ (int);281 return __alignof__ (int); 286 282 break; 287 283 288 284 case _C_UINT: 289 return __alignof__ (unsigned int);285 return __alignof__ (unsigned int); 290 286 break; 291 287 292 288 case _C_LNG: 293 return __alignof__ (long);289 return __alignof__ (long); 294 290 break; 295 291 296 292 case _C_ULNG: 297 return __alignof__ (unsigned long);293 return __alignof__ (unsigned long); 298 294 break; 299 295 300 296 case _C_LNG_LNG: 301 return __alignof__ (long long);297 return __alignof__ (long long); 302 298 break; 303 299 304 300 case _C_ULNG_LNG: 305 return __alignof__ (unsigned long long);301 return __alignof__ (unsigned long long); 306 302 break; 307 303 308 304 case _C_FLT: 309 return __alignof__ (float);305 return __alignof__ (float); 310 306 break; 311 307 312 308 case _C_DBL: 313 return __alignof__ (double);309 return __alignof__ (double); 314 310 break; 315 311 … … 317 313 case _C_ATOM: 318 314 case _C_CHARPTR: 319 return __alignof__ (char*);315 return __alignof__ (char *); 320 316 break; 321 317 322 318 case _C_ARY_B: 323 while (isdigit(*++type)) /* do nothing */; 319 while (isdigit ((unsigned char)*++type)) 320 /* do nothing */; 324 321 return objc_alignof_type (type); 325 322 … … 340 337 { 341 338 int maxalign = 0; 342 while (*type != _C_UNION_E && *type++ != '=') /* do nothing */; 339 while (*type != _C_UNION_E && *type++ != '=') 340 /* do nothing */; 343 341 while (*type != _C_UNION_E) 344 342 { … … 357 355 default: 358 356 { 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); 360 358 return 0; 361 359 } … … 368 366 369 367 int 370 objc_aligned_size (const char *type)368 objc_aligned_size (const char *type) 371 369 { 372 370 int size, align; … … 387 385 /* 388 386 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 390 int 391 objc_promoted_size (const char *type) 394 392 { 395 393 int size, wordsize; … … 403 401 404 402 size = objc_sizeof_type (type); 405 wordsize = sizeof (void *);403 wordsize = sizeof (void *); 406 404 407 405 return ROUND (size, wordsize); … … 413 411 */ 414 412 415 inline const char *416 objc_skip_type_qualifiers (const char *type)413 inline const char * 414 objc_skip_type_qualifiers (const char *type) 417 415 { 418 416 while (*type == _C_CONST 419 || *type == _C_IN 417 || *type == _C_IN 420 418 || *type == _C_INOUT 421 || *type == _C_OUT 419 || *type == _C_OUT 422 420 || *type == _C_BYCOPY 423 421 || *type == _C_BYREF … … 430 428 } 431 429 432 430 433 431 /* 434 432 Skip one typespec element. If the typespec is prepended by type … … 436 434 */ 437 435 438 const char *439 objc_skip_typespec (const char *type)436 const char * 437 objc_skip_typespec (const char *type) 440 438 { 441 439 /* Skip the variable name if any */ … … 447 445 448 446 type = objc_skip_type_qualifiers (type); 449 447 450 448 switch (*type) { 451 449 … … 458 456 else 459 457 { 460 while (*++type != '"') /* do nothing */; 458 while (*++type != '"') 459 /* do nothing */; 461 460 return type + 1; 462 461 } … … 486 485 case _C_ARY_B: 487 486 /* 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); 491 491 if (*type == _C_ARY_E) 492 492 return ++type; 493 493 else 494 494 { 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); 496 496 return 0; 497 497 } … … 499 499 case _C_BFLD: 500 500 /* 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 */ 503 505 return type; 504 506 505 507 case _C_STRUCT_B: 506 508 /* 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 } 510 516 return ++type; 511 517 512 518 case _C_UNION_B: 513 519 /* 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 } 517 527 return ++type; 518 528 519 529 case _C_PTR: 520 530 /* Just skip the following typespec */ 521 531 522 532 return objc_skip_typespec (++type); 523 533 524 534 default: 525 535 { 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); 527 537 return 0; 528 538 } … … 534 544 '+' if the argument is passed in registers. 535 545 */ 536 inline const char* 537 objc_skip_offset (const char* type) 538 { 539 if (*type == '+') type++; 540 while(isdigit(*++type)); 546 inline const char * 547 objc_skip_offset (const char *type) 548 { 549 if (*type == '+') 550 type++; 551 while (isdigit ((unsigned char) *++type)) 552 ; 541 553 return type; 542 554 } … … 545 557 Skip an argument specification of a method encoding. 546 558 */ 547 const char *548 objc_skip_argspec (const char *type)559 const char * 560 objc_skip_argspec (const char *type) 549 561 { 550 562 type = objc_skip_typespec (type); … … 556 568 Return the number of arguments that the method MTH expects. 557 569 Note that all methods need two implicit arguments `self' and 558 `_cmd'. 570 `_cmd'. 559 571 */ 560 572 int 561 method_get_number_of_arguments (struct objc_method *mth)573 method_get_number_of_arguments (struct objc_method *mth) 562 574 { 563 575 int i = 0; 564 const char *type = mth->method_types;576 const char *type = mth->method_types; 565 577 while (*type) 566 578 { … … 578 590 579 591 int 580 method_get_sizeof_arguments (struct objc_method *mth)581 { 582 const char *type = objc_skip_typespec (mth->method_types);592 method_get_sizeof_arguments (struct objc_method *mth) 593 { 594 const char *type = objc_skip_typespec (mth->method_types); 583 595 return atoi (type); 584 596 } … … 589 601 590 602 { 591 char *datum, *type; 603 char *datum, *type; 592 604 for (datum = method_get_first_argument (method, argframe, &type); 593 605 datum; datum = method_get_next_argument (argframe, &type)) … … 600 612 { 601 613 if ((flags & _F_IN) == _F_IN) 602 [portal encodeData: *(char **)datum ofType: ++type];614 [portal encodeData: *(char **) datum ofType: ++type]; 603 615 } 604 616 } 605 617 } 606 */ 607 608 char* 609 method_get_next_argument (arglist_t argframe, 610 const char **type) 618 */ 619 620 char * 621 method_get_next_argument (arglist_t argframe, const char **type) 611 622 { 612 623 const char *t = objc_skip_argspec (*type); … … 625 636 626 637 /* 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 628 639 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 630 641 method_get_next_argument. 631 642 */ 632 char *633 method_get_first_argument (struct objc_method *m,634 arglist_t argframe, 635 const char **type)643 char * 644 method_get_first_argument (struct objc_method *m, 645 arglist_t argframe, 646 const char **type) 636 647 { 637 648 *type = m->method_types; … … 642 653 Return a pointer to the ARGth argument of the method 643 654 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 658 char * 659 method_get_nth_argument (struct objc_method *m, 660 arglist_t argframe, int arg, 650 661 const char **type) 651 662 { 652 const char *t = objc_skip_argspec (m->method_types);663 const char *t = objc_skip_argspec (m->method_types); 653 664 654 665 if (arg > method_get_number_of_arguments (m)) … … 657 668 while (arg--) 658 669 t = objc_skip_argspec (t); 659 670 660 671 *type = t; 661 672 t = objc_skip_typespec (t); … … 668 679 669 680 unsigned 670 objc_get_type_qualifiers (const char *type)681 objc_get_type_qualifiers (const char *type) 671 682 { 672 683 unsigned res = 0; … … 721 732 if (*type++ != _C_STRUCT_B) 722 733 { 723 objc_error (nil, OBJC_ERR_BAD_TYPE,734 objc_error (nil, OBJC_ERR_BAD_TYPE, 724 735 "record type expected in objc_layout_structure, got %s\n", 725 736 type); … … 750 761 objc_layout_structure_next_member (struct objc_struct_layout *layout) 751 762 { 752 register int known_align = layout->record_size;753 763 register int desired_align = 0; 754 764 755 765 /* 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; 758 768 759 769 /* The current type without the type qualifiers */ … … 770 780 /* Get the bitfield's type */ 771 781 for (bfld_type = type + 1; 772 isdigit (*bfld_type);782 isdigit ((unsigned char)*bfld_type); 773 783 bfld_type++) 774 784 /* do nothing */; … … 794 804 795 805 if (*type != _C_BFLD) 796 desired_align = objc_alignof_type (type) * BITS_PER_UNIT;806 desired_align = objc_alignof_type (type) * BITS_PER_UNIT; 797 807 else 798 808 { 799 809 desired_align = 1; 800 810 /* 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++) 802 814 /* do nothing */; 803 815 … … 819 831 #ifndef PCC_BITFIELD_TYPE_MATTERS 820 832 layout->record_align = MAX (layout->record_align, desired_align); 821 #else 833 #else /* PCC_BITFIELD_TYPE_MATTERS */ 822 834 if (*type == _C_BFLD) 823 835 { … … 851 863 else 852 864 layout->record_align = MAX (layout->record_align, desired_align); 853 #endif 865 #endif /* PCC_BITFIELD_TYPE_MATTERS */ 854 866 855 867 /* Does this field automatically have alignment it needs … … 865 877 layout->record_size = ROUND (layout->record_size, desired_align); 866 878 } 867 879 868 880 /* Jump to the next field in record. */ 869 881 … … 885 897 alignment. */ 886 898 887 #if defined (ROUND_TYPE_ALIGN) && !defined(__sparc__)899 #if defined (ROUND_TYPE_ALIGN) && ! defined (__sparc__) 888 900 layout->record_align = ROUND_TYPE_ALIGN (layout->original_type, 889 901 1, -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/gc.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* Basic data types for Objective C. 2 Copyright (C) 1998 Free Software Foundation, Inc.2 Copyright (C) 1998, 2002 Free Software Foundation, Inc. 3 3 Contributed by Ovidiu Predescu. 4 4 … … 59 59 60 60 #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); }) 63 63 64 64 #define SET_BIT_FOR_OFFSET(mask, offset) \ 65 GC_set_bit (mask, offset / sizeof (void*))65 GC_set_bit (mask, offset / sizeof (void *)) 66 66 67 67 /* Some prototypes */ … … 75 75 __objc_gc_setup_array (GC_bitmap mask, const char *type, int offset) 76 76 { 77 int i, len = atoi (type + 1);78 79 while (isdigit (*++type))77 int i, len = atoi (type + 1); 78 79 while (isdigit (*++type)) 80 80 /* do nothing */; /* skip the size of the array */ 81 81 … … 139 139 case _C_CHARPTR: 140 140 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); 143 143 break; 144 144 … … 179 179 align = objc_alignof_type (type); 180 180 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 *); 186 186 } 187 187 } … … 224 224 case _C_PTR: 225 225 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); 228 228 break; 229 229 … … 255 255 { 256 256 int i, ivar_count; 257 struct objc_ivar_list *ivars;258 259 if (! class)257 struct objc_ivar_list *ivars; 258 259 if (! class) 260 260 { 261 261 strcat (*type, "{"); … … 268 268 269 269 ivars = class->ivars; 270 if (! ivars)270 if (! ivars) 271 271 return; 272 272 … … 283 283 /* Increase the size of the encoding string so that it 284 284 contains this ivar's type. */ 285 *size = ROUND (*current + len + 1, 10);285 *size = ROUND (*current + len + 1, 10); 286 286 *type = objc_realloc (*type, *size); 287 287 } … … 303 303 char *class_structure_type; 304 304 305 if (! CLS_ISCLASS(class))305 if (! CLS_ISCLASS (class)) 306 306 return; 307 307 … … 312 312 /* The number of bits in the mask is the size of an instance in bytes divided 313 313 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; 317 317 mask = objc_atomic_malloc (size * sizeof (int)); 318 318 memset (mask, 0, size * sizeof (int)); … … 343 343 #endif 344 344 345 class->gc_object_type = (void *)GC_make_descriptor (mask, bits_no);345 class->gc_object_type = (void *) GC_make_descriptor (mask, bits_no); 346 346 } 347 347 … … 371 371 pointers. */ 372 372 void 373 class_ivar_set_gcinvisible (Class class, const char *ivarname,373 class_ivar_set_gcinvisible (Class class, const char *ivarname, 374 374 BOOL gc_invisible) 375 375 { 376 376 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) 380 380 return; 381 381 382 382 ivars = class->ivars; 383 if (! ivars)383 if (! ivars) 384 384 return; 385 385 … … 391 391 const char *type; 392 392 393 if (! ivar->ivar_name || strcmp (ivar->ivar_name, ivarname))393 if (! ivar->ivar_name || strcmp (ivar->ivar_name, ivarname)) 394 394 continue; 395 395 … … 408 408 char *new_type; 409 409 410 if (gc_invisible || ! __objc_ivar_pointer (type))410 if (gc_invisible || ! __objc_ivar_pointer (type)) 411 411 return; /* The type of the variable already matches the 412 412 requested gc_invisible type */ … … 423 423 char *new_type; 424 424 425 if (! gc_invisible || !__objc_ivar_pointer (type))425 if (! gc_invisible || ! __objc_ivar_pointer (type)) 426 426 return; /* The type of the variable already matches the 427 427 requested gc_invisible type */ … … 447 447 448 448 void 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 453 void class_ivar_set_gcinvisible (Class class __attribute__ ((__unused__)), 454 const char *ivarname __attribute__ ((__unused__)), 455 BOOL gc_invisible __attribute__ ((__unused__))) 456 456 { 457 457 } -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/hash.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 48 48 /* Pass me a value greater than 0 and a power of 2. */ 49 49 assert (size); 50 assert (! (size & (size - 1)));50 assert (! (size & (size - 1))); 51 51 52 52 /* Allocate the cache structure. calloc insures … … 197 197 } else 198 198 prev = node, node = node->next; 199 } while (! removed && node);199 } while (! removed && node); 200 200 assert (removed); 201 201 } … … 211 211 /* If the scan is being started then reset the last node 212 212 visitied pointer and bucket index. */ 213 if (! node)213 if (! node) 214 214 cache->last_bucket = 0; 215 215 … … 259 259 } else 260 260 node = node->next; 261 } while (! retval && node);261 } while (! retval && node); 262 262 263 263 return retval; -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/init.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* 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. 3 3 Contributed by Kresten Krab Thorup 4 4 +load support contributed by Ovidiu Predescu <ovidiu@net-community.com> … … 28 28 29 29 /* 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). */ 31 31 #define OBJC_VERSION 8 32 32 #define PROTOCOL_VERSION 2 33 33 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. */ 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 */ 39 39 40 40 /* List of unresolved static instances. */ 41 41 static struct objc_list *uninitialized_statics = 0; /* !T:MUTEX */ 42 42 43 /* Global runtime "write" mutex. */43 /* Global runtime "write" mutex. */ 44 44 objc_mutex_t __objc_runtime_mutex = 0; 45 45 46 /* Number of threads that are alive. */46 /* Number of threads that are alive. */ 47 47 int __objc_runtime_threads_alive = 1; /* !T:MUTEX */ 48 48 49 /* Check compiler vs runtime version */49 /* Check compiler vs runtime version. */ 50 50 static void init_check_module_version (Module_t); 51 51 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 class59 or a category is loaded into the runtime. This may e.g. help a60 dynamic loader determine the classes that have been loaded when61 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. */ 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 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. */ 62 void (*_objc_load_callback) (Class class, Category *category); /* !T:SAFE */ 63 64 /* Is all categories/classes resolved? */ 65 65 BOOL __objc_dangling_categories = NO; /* !T:UNUSED */ 66 66 … … 69 69 struct objc_selector *orig, BOOL is_const); 70 70 71 /* Sends +load to all classes and categories in certain situations. */71 /* Sends +load to all classes and categories in certain situations. */ 72 72 static void objc_send_load (void); 73 73 74 74 /* 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 the76 classes in its nodes receive the +load message if these methods were not77 executed before. The algorithm ensures that when the +load method of a class78 is executed all the superclasses have been already received the +load79 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. */ 80 80 static void __objc_create_classes_tree (Module_t module); 81 81 … … 83 83 84 84 /* A special version that works only before the classes are completely 85 installed in the runtime. */85 installed in the runtime. */ 86 86 static BOOL class_is_subclass_of_class (Class class, Class superclass); 87 87 … … 91 91 } objc_class_tree; 92 92 93 /* This is a linked list of objc_class_tree trees. The head of these trees94 are root classes (their super class is Nil). These different trees95 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. */ 96 96 static struct objc_list *__objc_class_tree_list = NULL; 97 97 98 /* Keeps the +load methods who have been already executed. This hash should99 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. */ 100 100 static cache_ptr __objc_load_methods = NULL; 101 101 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 106 108 static objc_class_tree * 107 109 create_tree_of_subclasses_inherited_from (Class bottom_class, Class upper) 108 110 { 109 111 Class superclass = bottom_class->super_class ? 110 objc_lookup_class ((char *)bottom_class->super_class)112 objc_lookup_class ((char *) bottom_class->super_class) 111 113 : Nil; 112 114 … … 127 129 tree->subclasses = list_cons (prev, tree->subclasses); 128 130 superclass = (superclass->super_class ? 129 objc_lookup_class ((char *)superclass->super_class)131 objc_lookup_class ((char *) superclass->super_class) 130 132 : Nil); 131 133 prev = tree; … … 135 137 } 136 138 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 142 146 static objc_class_tree * 143 147 __objc_tree_insert_class (objc_class_tree *tree, Class class) … … 155 159 } 156 160 else if ((class->super_class ? 157 objc_lookup_class ((char *)class->super_class)161 objc_lookup_class ((char *) class->super_class) 158 162 : Nil) 159 163 == tree->class) … … 161 165 /* If class is a direct subclass of tree->class then add class to the 162 166 list of subclasses. First check to see if it wasn't already 163 inserted. */167 inserted. */ 164 168 struct objc_list *list = tree->subclasses; 165 169 objc_class_tree *node; … … 168 172 { 169 173 /* 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) 172 176 { 173 177 DEBUG_PRINTF ("2. class %s was previously inserted\n", … … 187 191 else 188 192 { 189 /* The class is not a direct subclass of tree->class. Search for class's190 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. */ 191 195 struct objc_list *subclasses = tree->subclasses; 192 196 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)) 196 201 return NULL; 197 202 198 203 for (; subclasses != NULL; subclasses = subclasses->tail) 199 204 { 200 Class aClass = ((objc_class_tree *)(subclasses->head))->class;205 Class aClass = ((objc_class_tree *) (subclasses->head))->class; 201 206 202 207 if (class_is_subclass_of_class (class, aClass)) 203 208 { 204 /* If we found one of class's superclasses we insert the class205 into its subtree and return the original tree since nothing206 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. */ 207 212 subclasses->head 208 213 = __objc_tree_insert_class (subclasses->head, class); … … 212 217 } 213 218 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 subclass216 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. */ 217 222 { 218 223 objc_class_tree *new_tree 219 224 = create_tree_of_subclasses_inherited_from (class, tree->class); 220 225 tree->subclasses = list_cons (new_tree, tree->subclasses); 221 226 DEBUG_PRINTF ("5. class %s inserted\n", class->name); … … 225 230 } 226 231 227 /* This function inserts `class' in the right tree hierarchy classes. */ 232 /* This function inserts `class' in the right tree hierarchy classes. */ 233 228 234 static void 229 235 objc_tree_insert_class (Class class) … … 245 251 } 246 252 247 /* If the list was finished but the class hasn't been inserted, insert it248 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) 250 256 { 251 257 __objc_class_tree_list = list_cons (NULL, __objc_class_tree_list); … … 254 260 } 255 261 256 /* Traverse tree in preorder. Used to send +load. */ 262 /* Traverse tree in preorder. Used to send +load. */ 263 257 264 static void 258 265 objc_preorder_traverse (objc_class_tree *tree, 259 266 int level, 260 void (*function) (objc_class_tree*, int))267 void (*function) (objc_class_tree *, int)) 261 268 { 262 269 struct objc_list *node; … … 267 274 } 268 275 269 /* Traverse tree in postorder. Used to destroy a tree. */ 276 /* Traverse tree in postorder. Used to destroy a tree. */ 277 270 278 static void 271 279 objc_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)) 274 282 { 275 283 struct objc_list *node; … … 280 288 } 281 289 282 /* Used to print a tree class hierarchy. */ 290 /* Used to print a tree class hierarchy. */ 291 283 292 #ifdef DEBUG 284 293 static void … … 293 302 #endif 294 303 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 299 310 static void 300 311 __objc_send_message_in_list (MethodList_t method_list, Class class, SEL op) … … 302 313 int i; 303 314 304 if (! method_list)315 if (! method_list) 305 316 return; 306 317 … … 308 319 __objc_send_message_in_list (method_list->method_next, class, op); 309 320 310 /* Search the method list. */321 /* Search the method list. */ 311 322 for (i = 0; i < method_list->method_count; i++) 312 323 { … … 314 325 315 326 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)) 317 328 { 318 329 /* Add this method into the +load hash table */ … … 321 332 DEBUG_PRINTF ("sending +load in class: %s\n", class->name); 322 333 323 /* The method was found and wasn't previously executed. */334 /* The method was found and wasn't previously executed. */ 324 335 (*mth->method_imp) ((id)class, mth->method_name); 325 336 … … 330 341 331 342 static void 332 __objc_send_load (objc_class_tree *tree, int level) 343 __objc_send_load (objc_class_tree *tree, 344 int level __attribute__ ((__unused__))) 333 345 { 334 346 static SEL load_sel = 0; … … 336 348 MethodList_t method_list = class->class_pointer->methods; 337 349 338 if (! load_sel)350 if (! load_sel) 339 351 load_sel = sel_register_name ("load"); 340 352 … … 343 355 344 356 static 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__))) 346 359 { 347 360 objc_free (tree); 348 361 } 349 362 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 352 366 static BOOL 353 367 class_is_subclass_of_class (Class class, Class superclass) … … 358 372 return YES; 359 373 class = (class->super_class ? 360 objc_lookup_class ((char *)class->super_class)374 objc_lookup_class ((char *) class->super_class) 361 375 : Nil); 362 376 } … … 365 379 } 366 380 367 /* This list contains all the classes in the runtime system for whom their368 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. */ 383 static struct objc_list *unresolved_classes = 0; 384 385 /* Extern function used to reference the Object and NXConstantString 386 classes. */ 373 387 374 388 extern void __objc_force_linking (void); … … 381 395 } 382 396 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 385 400 static void 386 401 objc_init_statics (void) … … 389 404 struct objc_static_instances **statics_in_module; 390 405 391 objc_mutex_lock (__objc_runtime_mutex);406 objc_mutex_lock (__objc_runtime_mutex); 392 407 393 408 while (*cell) … … 401 416 Class class = objc_lookup_class (statics->class_name); 402 417 403 if (! class)418 if (! class) 404 419 module_initialized = 0; 405 420 /* Actually, the static's class_pointer will be NULL when we … … 431 446 struct objc_list *this = *cell; 432 447 *cell = this->tail; 433 objc_free (this);448 objc_free (this); 434 449 } 435 450 else … … 437 452 } 438 453 439 objc_mutex_unlock (__objc_runtime_mutex);454 objc_mutex_unlock (__objc_runtime_mutex); 440 455 } /* objc_init_statics */ 441 456 442 457 /* This function is called by constructor functions generated for each 443 module compiled. (_GLOBAL_$I$...) The purpose of this function is to444 gather the module pointers so that they may be processed by the445 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. */ 446 461 447 462 void … … 452 467 static BOOL previous_constructors = 0; 453 468 454 static struct objc_list *unclaimed_categories = 0;469 static struct objc_list *unclaimed_categories = 0; 455 470 456 471 /* The symbol table (defined in objc-api.h) generated by gcc */ … … 462 477 463 478 /* Entry used to traverse hash lists */ 464 struct objc_list **cell;479 struct objc_list **cell; 465 480 466 481 /* The table of selector references for this module */ … … 473 488 474 489 /* check gcc version */ 475 init_check_module_version (module);490 init_check_module_version (module); 476 491 477 492 /* On the first call of this routine, initialize some data structures. */ 478 if (! previous_constructors)493 if (! previous_constructors) 479 494 { 480 495 /* Initialize thread-safe system */ 481 __objc_init_thread_system ();496 __objc_init_thread_system (); 482 497 __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 (); 488 503 __objc_class_tree_list = list_cons (NULL, __objc_class_tree_list); 489 504 __objc_load_methods … … 493 508 494 509 /* 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); 497 512 498 513 /* Replace referenced selectors from names to SEL's. */ … … 502 517 { 503 518 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; 506 521 /* Constructors are constant static data so we can safely store 507 522 pointers to them in the runtime structures. is_const == YES */ 508 523 __sel_register_typed_name (name, type, 509 (struct objc_selector *)&(selectors[i]),524 (struct objc_selector *) &(selectors[i]), 510 525 YES); 511 526 } … … 517 532 { 518 533 Class class = (Class) symtab->defs[i]; 519 const char * superclass = (char*)class->super_class;534 const char *superclass = (char *) class->super_class; 520 535 521 536 /* 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)); 524 539 DEBUG_PRINTF ("phase 1, processing class: %s\n", class->name); 525 540 526 541 /* 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. */ 528 543 class->subclass_list = NULL; 529 544 … … 536 551 537 552 /* 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); 540 555 541 556 /* 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); 544 559 545 560 if (class->protocols) … … 547 562 548 563 /* 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)) 551 566 unresolved_classes = list_cons (class, unresolved_classes); 552 567 } … … 582 597 583 598 /* 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); 586 601 } 587 602 else … … 589 604 /* The object to which the category methods belong can't be found. 590 605 Save the information. */ 591 unclaimed_categories = list_cons (category, unclaimed_categories);606 unclaimed_categories = list_cons (category, unclaimed_categories); 592 607 } 593 608 } … … 626 641 627 642 /* 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); 630 645 } 631 646 else … … 635 650 if (unclaimed_proto_list && objc_lookup_class ("Protocol")) 636 651 { 637 list_mapcar (unclaimed_proto_list,(void(*)(void*))__objc_init_protocols); 652 list_mapcar (unclaimed_proto_list, 653 (void (*) (void *))__objc_init_protocols); 638 654 list_free (unclaimed_proto_list); 639 655 unclaimed_proto_list = 0; … … 642 658 objc_send_load (); 643 659 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 663 static void 664 objc_send_load (void) 665 { 666 if (! __objc_module_list) 650 667 return; 651 668 652 669 /* 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 are654 allocated in the +load method are in general of a class declared in the655 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. */ 656 673 if (unresolved_classes) 657 674 { 658 675 Class class = unresolved_classes->head; 659 676 660 while (objc_lookup_class ((char *)class->super_class))677 while (objc_lookup_class ((char *) class->super_class)) 661 678 { 662 679 list_remove_head (&unresolved_classes); … … 667 684 } 668 685 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. */ 673 689 if (unresolved_classes) 674 690 return; 675 691 } 676 692 677 /* Special check to allow creating and sending messages to constant strings678 in +load methods. If these classes are not yet known, even if all the679 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")) 682 698 return; 683 699 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); 688 705 689 706 while (__objc_class_tree_list) … … 700 717 } 701 718 702 list_mapcar (__objc_module_list, (void (*)(void*))__objc_call_callback);719 list_mapcar (__objc_module_list, (void (*) (void *)) __objc_call_callback); 703 720 list_free (__objc_module_list); 704 721 __objc_module_list = NULL; … … 713 730 int i; 714 731 715 /* Iterate thru classes defined in this module and insert them in the classes716 t ree hierarchy.*/732 /* Iterate thru classes defined in this module and insert them in 733 the classes tree hierarchy. */ 717 734 for (i = 0; i < symtab->cls_def_cnt; i++) 718 735 { … … 726 743 __objc_call_callback (Module_t module) 727 744 { 728 /* The runtime mutex is locked in this point */745 /* The runtime mutex is locked in this point. */ 729 746 730 747 Symtab_t symtab = module->symtab; 731 748 int i; 732 749 733 /* Iterate thru classes defined in this module and call the callback for734 each one.*/750 /* Iterate thru classes defined in this module and call the callback 751 for each one. */ 735 752 for (i = 0; i < symtab->cls_def_cnt; i++) 736 753 { 737 754 Class class = (Class) symtab->defs[i]; 738 755 739 /* Call the _objc_load_callback for this class. */756 /* Call the _objc_load_callback for this class. */ 740 757 if (_objc_load_callback) 741 _objc_load_callback (class, 0);742 } 743 744 /* Call the _objc_load_callback for categories. Don't register the instance745 methods as class methods for categories to root classes since they were746 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. */ 747 764 for (i = 0; i < symtab->cat_def_cnt; i++) 748 765 { … … 751 768 752 769 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 776 static void 777 init_check_module_version (Module_t module) 759 778 { 760 779 if ((module->version != OBJC_VERSION) || (module->size != sizeof (Module))) … … 762 781 int code; 763 782 764 if (module->version > OBJC_VERSION)783 if (module->version > OBJC_VERSION) 765 784 code = OBJC_ERR_OBJC_VERSION; 766 785 else if (module->version < OBJC_VERSION) … … 769 788 code = OBJC_ERR_MODULE_SIZE; 770 789 771 objc_error (nil, code, "Module %s version %d doesn't match runtime %d\n",772 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 795 static void 796 __objc_init_protocols (struct objc_protocol_list *protos) 797 { 798 size_t i; 780 799 static Class proto_class = 0; 781 800 … … 783 802 return; 784 803 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) 791 810 { 792 811 unclaimed_proto_list = list_cons (protos, unclaimed_proto_list); 793 objc_mutex_unlock (__objc_runtime_mutex);812 objc_mutex_unlock (__objc_runtime_mutex); 794 813 return; 795 814 } … … 799 818 #endif 800 819 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]; 804 823 if (((size_t)aProto->class_pointer) == PROTOCOL_VERSION) 805 824 { … … 812 831 else if (protos->list[i]->class_pointer != proto_class) 813 832 { 814 objc_error (nil, OBJC_ERR_PROTOCOL_VERSION,833 objc_error (nil, OBJC_ERR_PROTOCOL_VERSION, 815 834 "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), 817 837 PROTOCOL_VERSION); 818 838 } 819 839 } 820 840 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 844 static void 845 __objc_class_add_protocols (Class class, struct objc_protocol_list *protos) 846 { 847 /* Well... */ 828 848 if (! protos) 829 849 return; 830 850 831 /* Add it... */851 /* Add it... */ 832 852 protos->next = class->protocols; 833 853 class->protocols = protos; -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/misc.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* 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. 3 4 Contributed by Kresten Krab Thorup 4 5 … … 38 39 /* Trigger an objc error */ 39 40 void 40 objc_error (id object, int code, const char*fmt, ...)41 objc_error (id object, int code, const char *fmt, ...) 41 42 { 42 43 va_list ap; 43 44 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); 47 48 } 48 49 49 50 /* Trigger an objc error */ 50 51 void 51 objc_verror (id object, int code, const char*fmt, va_list ap)52 objc_verror (id object, int code, const char *fmt, va_list ap) 52 53 { 53 54 BOOL result = NO; … … 56 57 Otherwise print to stderr */ 57 58 if (_objc_error_handler) 58 result = (*_objc_error_handler) (object, code, fmt, ap);59 result = (*_objc_error_handler) (object, code, fmt, ap); 59 60 else 60 61 vfprintf (stderr, fmt, ap); … … 65 66 return; 66 67 else 67 abort ();68 abort (); 68 69 } 69 70 70 71 /* Set the error handler */ 71 72 objc_error_handler 72 objc_set_error_handler (objc_error_handler func)73 objc_set_error_handler (objc_error_handler func) 73 74 { 74 75 objc_error_handler temp = _objc_error_handler; … … 85 86 86 87 void * 87 objc_malloc (size_t size)88 objc_malloc (size_t size) 88 89 { 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"); 92 93 return res; 93 94 } 94 95 95 96 void * 96 objc_atomic_malloc (size_t size)97 objc_atomic_malloc (size_t size) 97 98 { 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"); 101 102 return res; 102 103 } 103 104 104 105 void * 105 objc_valloc (size_t size)106 objc_valloc (size_t size) 106 107 { 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"); 110 111 return res; 111 112 } 112 113 113 114 void * 114 objc_realloc (void *mem, size_t size)115 objc_realloc (void *mem, size_t size) 115 116 { 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"); 119 120 return res; 120 121 } 121 122 122 123 void * 123 objc_calloc (size_t nelem, size_t size)124 objc_calloc (size_t nelem, size_t size) 124 125 { 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"); 128 129 return res; 129 130 } 130 131 131 132 void 132 objc_free (void *mem)133 objc_free (void *mem) 133 134 { 134 (*_objc_free) (mem);135 (*_objc_free) (mem); 135 136 } 136 137 … … 149 150 #include <gc.h> 150 151 151 static void *GC_calloc (size_t nelem, size_t size) 152 static void * 153 GC_calloc (size_t nelem, size_t size) 152 154 { 153 void *p = GC_malloc (nelem * size);154 if (! p)155 void *p = GC_malloc (nelem * size); 156 if (! p) 155 157 objc_error (nil, OBJC_ERR_MEMORY, "Virtual memory exhausted!\n"); 156 158 … … 159 161 } 160 162 161 static void noFree (void* p) {} 163 static void 164 noFree (void *p) 165 { 166 } 162 167 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;168 void *(*_objc_malloc) (size_t) = GC_malloc; 169 void *(*_objc_atomic_malloc) (size_t) = GC_malloc_atomic; 170 void *(*_objc_valloc) (size_t) = GC_malloc; 171 void *(*_objc_realloc) (void *, size_t) = GC_realloc; 172 void *(*_objc_calloc) (size_t, size_t) = GC_calloc; 173 void (*_objc_free) (void *) = noFree; 169 174 170 #else 175 #else /* !OBJC_WITH_GC */ 171 176 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;177 void *(*_objc_malloc) (size_t) = malloc; 178 void *(*_objc_atomic_malloc) (size_t) = malloc; 179 void *(*_objc_valloc) (size_t) = malloc; 180 void *(*_objc_realloc) (void *, size_t) = realloc; 181 void *(*_objc_calloc) (size_t, size_t) = calloc; 182 void (*_objc_free) (void *) = free; 178 183 179 184 180 #endif 185 #endif /* !OBJC_WITH_GC */ -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/nil_method.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* 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. 3 3 Contributed by Kresten Krab Thorup 4 4 … … 30 30 #include "runtime.h" 31 31 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 32 51 id 33 nil_method (id receiver, SEL op, ...)52 nil_method (id receiver, SEL op __attribute__ ((__unused__))) 34 53 { 35 54 return receiver; 36 55 } 37 38 39 40 -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/objc/encoding.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* 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. 3 3 4 4 Author: Kresten Krab Thorup … … 51 51 #define _F_GCINVISIBLE 0x20 52 52 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);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); 58 58 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 *);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 *); 65 65 66 char * method_get_first_argument (struct objc_method*,66 char *method_get_first_argument (struct objc_method *, 67 67 arglist_t argframe, 68 const char **type);69 char *method_get_next_argument (arglist_t argframe,68 const char **type); 69 char *method_get_next_argument (arglist_t argframe, 70 70 const char **type); 71 char * method_get_nth_argument (struct objc_method*m,71 char *method_get_nth_argument (struct objc_method *m, 72 72 arglist_t argframe, 73 73 int arg, 74 74 const char **type); 75 75 76 unsigned objc_get_type_qualifiers (const char *type);76 unsigned objc_get_type_qualifiers (const char *type); 77 77 78 78 -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/objc/hash.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 61 61 * hash_new will have to be casted to this type. 62 62 */ 63 typedef unsigned int (*hash_func_type) (void *, const void *);63 typedef unsigned int (*hash_func_type) (void *, const void *); 64 64 65 65 /* … … 70 70 */ 71 71 72 typedef int (*compare_func_type) (const void *, const void *);72 typedef int (*compare_func_type) (const void *, const void *); 73 73 74 74 … … 175 175 176 176 177 while (*(char *)key) {178 ret ^= *(char *)key++ << ctr;177 while (*(char *) key) { 178 ret ^= *(char *) key++ << ctr; 179 179 ctr = (ctr + 1) % sizeof (void *); 180 180 } … … 188 188 compare_ptrs (const void *k1, const void *k2) 189 189 { 190 return ! (k1 - k2);190 return ! (k1 - k2); 191 191 } 192 192 … … 201 201 return 0; 202 202 else 203 return ! strcmp (k1, k2);203 return ! strcmp (k1, k2); 204 204 } 205 205 -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/objc/objc.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 74 74 /* 75 75 ** 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. 77 84 */ 78 85 typedef id (*IMP)(id, SEL, ...); -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/objc/runtime.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* 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. 3 3 Contributed by Kresten Krab Thorup 4 4 … … 66 66 67 67 /* Number of selectors stored in each of the selector tables */ 68 extern int __objc_selector_max_index;68 extern unsigned int __objc_selector_max_index; 69 69 70 70 /* Mutex locking __objc_selector_max_index and its arrays. */ … … 83 83 SEL __sel_register_typed_name (const char*, const char*, 84 84 struct objc_selector*, BOOL is_const); 85 extern void __objc_generate_gc_type_description (Class); 85 86 86 87 #endif /* not __objc_runtime_INCLUDE_GNU */ -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/objc/thr.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* 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. 3 3 Contributed by Galen C. Hunt (gchunt@cs.rochester.edu) 4 4 … … 75 75 76 76 /* 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);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); 82 82 83 83 /* 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);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); 89 89 90 90 /* 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);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); 101 101 102 102 /* … … 112 112 so it can implement the NSBecomingMultiThreaded notification. 113 113 */ 114 typedef void (*objc_thread_callback) ();115 objc_thread_callback objc_set_thread_callback (objc_thread_callback func);114 typedef void (*objc_thread_callback) (void); 115 objc_thread_callback objc_set_thread_callback (objc_thread_callback func); 116 116 117 117 /* Backend initialization functions */ 118 int __objc_init_thread_system (void);119 int __objc_fini_thread_system (void);118 int __objc_init_thread_system (void); 119 int __objc_fini_thread_system (void); 120 120 121 121 /* 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);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); 127 127 128 128 /* 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);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); 134 134 135 135 /* 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);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); 144 144 145 145 #endif /* not __thread_INCLUDE_GNU */ -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/objects.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 33 33 #endif 34 34 35 id __objc_object_alloc (Class);36 id __objc_object_dispose (id);37 id __objc_object_copy (id);35 id __objc_object_alloc (Class); 36 id __objc_object_dispose (id); 37 id __objc_object_copy (id); 38 38 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 */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 */ 42 42 43 43 id 44 class_create_instance (Class class)44 class_create_instance (Class class) 45 45 { 46 46 id new = nil; 47 47 48 48 #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); 52 52 #else 53 if (CLS_ISCLASS (class))54 new = (*_objc_object_alloc) (class);53 if (CLS_ISCLASS (class)) 54 new = (*_objc_object_alloc) (class); 55 55 #endif 56 56 57 if (new !=nil)57 if (new != nil) 58 58 { 59 59 memset (new, 0, class->instance_size); … … 64 64 65 65 id 66 object_copy (id object)66 object_copy (id object) 67 67 { 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); 70 70 else 71 71 return nil; … … 73 73 74 74 id 75 object_dispose (id object)75 object_dispose (id object) 76 76 { 77 if ((object !=nil)&&CLS_ISCLASS(object->class_pointer))77 if ((object != nil) && CLS_ISCLASS (object->class_pointer)) 78 78 { 79 79 if (_objc_object_dispose) 80 (*_objc_object_dispose) (object);80 (*_objc_object_dispose) (object); 81 81 else 82 objc_free (object);82 objc_free (object); 83 83 } 84 84 return nil; 85 85 } 86 86 87 id __objc_object_alloc (Class class)87 id __objc_object_alloc (Class class) 88 88 { 89 return (id) objc_malloc(class->instance_size);89 return (id) objc_malloc (class->instance_size); 90 90 } 91 91 92 id __objc_object_dispose (id object)92 id __objc_object_dispose (id object) 93 93 { 94 objc_free (object);94 objc_free (object); 95 95 return 0; 96 96 } 97 97 98 id __objc_object_copy (id object)98 id __objc_object_copy (id object) 99 99 { 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); 102 102 return copy; 103 103 } 104 105 -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/sarray.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* 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. 3 3 4 4 This file is part of GNU CC. … … 35 35 int idxsize = 0; /* !T:MUTEX */ 36 36 37 static void * 37 static void *first_free_data = NULL; /* !T:MUTEX */ 38 38 39 39 #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";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"; 45 45 #endif 46 46 … … 48 48 that were not safe in a multi-threaded environment. */ 49 49 void 50 sarray_remove_garbage (void)50 sarray_remove_garbage (void) 51 51 { 52 52 void **vp; 53 53 void *np; 54 54 55 objc_mutex_lock (__objc_runtime_mutex);55 objc_mutex_lock (__objc_runtime_mutex); 56 56 57 57 vp = first_free_data; … … 60 60 while (vp) { 61 61 np = *vp; 62 objc_free (vp);62 objc_free (vp); 63 63 vp = np; 64 64 } 65 65 66 objc_mutex_unlock (__objc_runtime_mutex);66 objc_mutex_unlock (__objc_runtime_mutex); 67 67 } 68 68 … … 72 72 73 73 static void 74 sarray_free_garbage (void *vp)75 { 76 objc_mutex_lock (__objc_runtime_mutex);74 sarray_free_garbage (void *vp) 75 { 76 objc_mutex_lock (__objc_runtime_mutex); 77 77 78 78 if (__objc_runtime_threads_alive == 1) { 79 objc_free (vp);79 objc_free (vp); 80 80 if (first_free_data) 81 sarray_remove_garbage ();81 sarray_remove_garbage (); 82 82 } 83 83 else { … … 86 86 } 87 87 88 objc_mutex_unlock (__objc_runtime_mutex);88 objc_mutex_unlock (__objc_runtime_mutex); 89 89 } 90 90 91 91 /* sarray_at_put : copies data in such a way as to be thread reader safe. */ 92 92 void 93 sarray_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;93 sarray_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; 101 101 #ifdef OBJC_SPARSE3 102 102 size_t ioffset; … … 123 123 #endif /* not PRECOMPUTE_SELECTORS */ 124 124 125 assert (soffset_decode(index) < array->capacity); /* Range check */125 assert (soffset_decode (index) < array->capacity); /* Range check */ 126 126 127 127 #ifdef OBJC_SPARSE3 … … 142 142 143 143 /* 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)); 146 146 new_index->version.version = array->version.version; 147 147 *the_index = new_index; /* Prepared for install. */ … … 152 152 153 153 /* 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)); 157 157 new_index->version.version = array->version.version; 158 158 *the_index = new_index; /* Prepared for install. */ … … 170 170 /* The bucket was previously empty (or something like that), */ 171 171 /* 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)); 175 175 new_bucket->version.version = array->version.version; 176 176 *the_bucket = new_bucket; /* Prepared for install. */ … … 181 181 182 182 /* 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)); 186 186 new_bucket->version.version = array->version.version; 187 187 *the_bucket = new_bucket; /* Prepared for install. */ … … 194 194 195 195 void 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 ** 210 #else /* OBJC_SPARSE2 */ 211 size_t num_indices = ((size -1)/BUCKET_SIZE)+1;212 struct sbucket ** 213 #endif 214 int counter;215 216 assert (size > 0);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 size_t counter; 215 216 assert (size > 0); 217 217 218 218 /* Allocate core array */ 219 arr = (struct sarray *) objc_malloc(sizeof(struct sarray));219 arr = (struct sarray *) objc_malloc (sizeof (struct sarray)); 220 220 arr->version.version = 0; 221 221 … … 223 223 #ifdef OBJC_SPARSE3 224 224 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)); 229 229 arr->empty_index->version.version = 0; 230 230 … … 235 235 #else /* OBJC_SPARSE2 */ 236 236 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); 239 239 240 240 narrays += 1; … … 243 243 #endif 244 244 245 arr->empty_bucket = (struct sbucket *) objc_malloc(sizeof(struct sbucket));245 arr->empty_bucket = (struct sbucket *) objc_malloc (sizeof (struct sbucket)); 246 246 arr->empty_bucket->version.version = 0; 247 247 … … 249 249 250 250 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++) 254 254 arr->empty_bucket->elems[counter] = default_element; 255 255 256 256 #ifdef OBJC_SPARSE3 257 for (counter =0; counter<INDEX_SIZE; counter++)257 for (counter = 0; counter < INDEX_SIZE; counter++) 258 258 arr->empty_index->buckets[counter] = arr->empty_bucket; 259 259 260 for (counter =0; counter<num_indices; counter++)260 for (counter = 0; counter < num_indices; counter++) 261 261 new_indices[counter] = arr->empty_index; 262 262 263 263 #else /* OBJC_SPARSE2 */ 264 264 265 for (counter =0; counter<num_indices; counter++)265 for (counter = 0; counter < num_indices; counter++) 266 266 new_buckets[counter] = arr->empty_bucket; 267 267 … … 284 284 285 285 void 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 ** 294 struct sindex ** 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 ** 302 struct sbucket ** 303 304 #endif 305 306 int counter;307 308 assert (newsize > 0);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 size_t counter; 307 308 assert (newsize > 0); 309 309 310 310 /* The size is the same, just ignore the request */ 311 if (rounded_size <= array->capacity)311 if (rounded_size <= array->capacity) 312 312 return; 313 313 314 assert (array->ref_count == 1); /* stop if lazy copied... */314 assert (array->ref_count == 1); /* stop if lazy copied... */ 315 315 316 316 /* We are asked to extend the array -- allocate new bucket table, */ 317 317 /* and insert empty_bucket in newly allocated places. */ 318 if (rounded_size > array->capacity)318 if (rounded_size > array->capacity) 319 319 { 320 320 321 321 #ifdef OBJC_SPARSE3 322 322 new_max_index += 4; 323 rounded_size = (new_max_index +1)*INDEX_CAPACITY;323 rounded_size = (new_max_index + 1) * INDEX_CAPACITY; 324 324 325 325 #else /* OBJC_SPARSE2 */ 326 326 new_max_index += 4; 327 rounded_size = (new_max_index +1)*BUCKET_SIZE;327 rounded_size = (new_max_index + 1) * BUCKET_SIZE; 328 328 #endif 329 329 … … 334 334 /* alloc to force re-read by any concurrent readers. */ 335 335 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 *)); 338 338 #else /* OBJC_SPARSE2 */ 339 339 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 *)); 342 342 #endif 343 343 344 344 /* 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++ ) { 346 346 #ifdef OBJC_SPARSE3 347 347 new_indices[counter] = old_indices[counter]; … … 353 353 #ifdef OBJC_SPARSE3 354 354 /* 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++) 356 356 new_indices[counter] = array->empty_index; 357 357 #else /* OBJC_SPARSE2 */ 358 358 /* 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++) 360 360 new_buckets[counter] = array->empty_bucket; 361 361 #endif … … 370 370 #ifdef OBJC_SPARSE3 371 371 /* 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); 375 375 #endif 376 376 … … 385 385 386 386 void 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; 387 sarray_free (struct sarray *array) { 388 #ifdef OBJC_SPARSE3 389 size_t old_max_index = (array->capacity - 1)/INDEX_CAPACITY; 390 struct sindex **old_indices; 392 391 #else 393 size_t old_max_index = (array->capacity -1)/BUCKET_SIZE;394 struct sbucket ** 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 */ 401 400 return; 402 401 … … 407 406 #endif 408 407 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); 411 410 412 411 /* 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) && 417 416 (idx->version.version == array->version.version)) { 418 417 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) && 422 421 (bkt->version.version == array->version.version)) 423 422 { 424 sarray_free_garbage (bkt);423 sarray_free_garbage (bkt); 425 424 nbuckets -= 1; 426 425 } 427 426 } 428 sarray_free_garbage (idx);427 sarray_free_garbage (idx); 429 428 nindices -= 1; 430 429 } 431 430 #else /* OBJC_SPARSE2 */ 432 struct sbucket *bkt = array->buckets[counter];431 struct sbucket *bkt = array->buckets[counter]; 433 432 if ((bkt != array->empty_bucket) && 434 433 (bkt->version.version == array->version.version)) 435 434 { 436 sarray_free_garbage (bkt);435 sarray_free_garbage (bkt); 437 436 nbuckets -= 1; 438 437 } … … 442 441 #ifdef OBJC_SPARSE3 443 442 /* 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); 446 445 nindices -= 1; 447 446 } … … 449 448 450 449 /* 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); 453 452 nbuckets -= 1; 454 453 } 455 idxsize -= (old_max_index +1);454 idxsize -= (old_max_index + 1); 456 455 narrays -= 1; 457 456 458 457 #ifdef OBJC_SPARSE3 459 458 /* free bucket table */ 460 sarray_free_garbage (array->indices);459 sarray_free_garbage (array->indices); 461 460 462 461 #else 463 462 /* free bucket table */ 464 sarray_free_garbage (array->buckets);463 sarray_free_garbage (array->buckets); 465 464 466 465 #endif 467 466 468 467 /* free array */ 469 sarray_free_garbage (array);468 sarray_free_garbage (array); 470 469 } 471 470 … … 473 472 /* copied. */ 474 473 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 ** 483 #else /* OBJC_SPARSE2 */ 484 size_t num_indices = ((oarr->capacity -1)/BUCKET_SIZE)+1;485 struct sbucket ** 474 struct sarray * 475 sarray_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; 486 485 #endif 487 486 488 487 /* Allocate core array */ 489 arr = (struct sarray *) objc_malloc(sizeof(struct sarray)); /* !!! */488 arr = (struct sarray *) objc_malloc (sizeof (struct sarray)); /* !!! */ 490 489 arr->version.version = oarr->version.version + 1; 491 490 #ifdef OBJC_SPARSE3 … … 500 499 #ifdef OBJC_SPARSE3 501 500 /* 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); 506 504 arr->indices = new_indices; 507 505 #else 508 506 /* 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); 513 510 arr->buckets = new_buckets; 514 511 #endif -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/selector.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* 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. 3 3 Contributed by Kresten Krab Thorup 4 4 … … 32 32 33 33 /* 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 */34 static struct sarray *__objc_selector_array = 0; /* uid -> sel !T:MUTEX */ 35 static struct sarray *__objc_selector_names = 0; /* uid -> name !T:MUTEX */ 36 36 static cache_ptr __objc_selector_hash = 0; /* name -> uid !T:MUTEX */ 37 37 38 static void register_selectors_from_list (MethodList_t);38 static void register_selectors_from_list (MethodList_t); 39 39 40 40 /* 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 ()41 unsigned int __objc_selector_max_index = 0; /* !T:MUTEX */ 42 43 void __objc_init_selector_tables () 44 44 { 45 45 __objc_selector_array = sarray_new (SELECTOR_HASH_SIZE, 0); … … 82 82 Method_t method = &method_list->method_list[i]; 83 83 method->method_name 84 = sel_register_typed_name ((const char *)method->method_name,85 84 = sel_register_typed_name ((const char *) method->method_name, 85 method->method_types); 86 86 i += 1; 87 87 } … … 90 90 91 91 /* Register instance methods as class methods for root classes */ 92 void __objc_register_instance_methods_to_class (Class class)92 void __objc_register_instance_methods_to_class (Class class) 93 93 { 94 94 MethodList_t method_list; … … 99 99 100 100 /* Only if a root class. */ 101 if (class->super_class)101 if (class->super_class) 102 102 return; 103 103 104 104 /* 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); 107 107 method_list = class->methods; 108 108 class_method_list = class->class_pointer->methods; … … 119 119 Method_t mth = &method_list->method_list[i]; 120 120 if (mth->method_name 121 && ! search_for_method_in_list (class_method_list,121 && ! search_for_method_in_list (class_method_list, 122 122 mth->method_name)) 123 123 { … … 127 127 128 128 /* Reallocate the method list if necessary */ 129 if (++new_list->method_count == max_methods_no)129 if (++new_list->method_count == max_methods_no) 130 130 new_list = 131 objc_realloc (new_list, sizeof(struct objc_method_list)132 + sizeof (struct131 objc_realloc (new_list, sizeof (struct objc_method_list) 132 + sizeof (struct 133 133 objc_method[max_methods_no += 16])); 134 134 curr_method = &new_list->method_list[new_list->method_count]; … … 144 144 { 145 145 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])); 148 148 new_list->method_next = class->class_pointer->methods; 149 149 class->class_pointer->methods = new_list; … … 157 157 the argframe layout */ 158 158 BOOL 159 sel_types_match (const char * t1, const char*t2)160 { 161 if (! t1 || !t2)159 sel_types_match (const char *t1, const char *t2) 160 { 161 if (! t1 || ! t2) 162 162 return NO; 163 163 while (*t1 && *t2) … … 165 165 if (*t1 == '+') t1++; 166 166 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++; 169 169 /* xxx Remove these next two lines when qualifiers are put in 170 170 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) 174 174 return YES; 175 175 if (*t1 != *t2) … … 188 188 sidx i; 189 189 190 objc_mutex_lock (__objc_runtime_mutex);190 objc_mutex_lock (__objc_runtime_mutex); 191 191 192 192 i = (sidx) hash_value_for_key (__objc_selector_hash, name); 193 193 if (i == 0) 194 194 { 195 objc_mutex_unlock (__objc_runtime_mutex);195 objc_mutex_unlock (__objc_runtime_mutex); 196 196 return 0; 197 197 } 198 198 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); 200 200 l; l = l->tail) 201 201 { 202 SEL s = (SEL) l->head;202 SEL s = (SEL) l->head; 203 203 if (types == 0 || s->sel_types == 0) 204 204 { 205 205 if (s->sel_types == types) 206 206 { 207 objc_mutex_unlock (__objc_runtime_mutex);207 objc_mutex_unlock (__objc_runtime_mutex); 208 208 return s; 209 209 } … … 211 211 else if (sel_types_match (s->sel_types, types)) 212 212 { 213 objc_mutex_unlock (__objc_runtime_mutex);213 objc_mutex_unlock (__objc_runtime_mutex); 214 214 return s; 215 215 } 216 216 } 217 217 218 objc_mutex_unlock (__objc_runtime_mutex);218 objc_mutex_unlock (__objc_runtime_mutex); 219 219 return 0; 220 220 } … … 228 228 SEL s = NULL; 229 229 230 objc_mutex_lock (__objc_runtime_mutex);230 objc_mutex_lock (__objc_runtime_mutex); 231 231 232 232 i = (sidx) hash_value_for_key (__objc_selector_hash, name); 233 233 if (i == 0) 234 234 { 235 objc_mutex_unlock (__objc_runtime_mutex);235 objc_mutex_unlock (__objc_runtime_mutex); 236 236 return 0; 237 237 } 238 238 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); 240 240 l; l = l->tail) 241 241 { … … 243 243 if (s->sel_types) 244 244 { 245 objc_mutex_unlock (__objc_runtime_mutex);245 objc_mutex_unlock (__objc_runtime_mutex); 246 246 return s; 247 247 } 248 248 } 249 249 250 objc_mutex_unlock (__objc_runtime_mutex);250 objc_mutex_unlock (__objc_runtime_mutex); 251 251 return s; 252 252 } … … 259 259 sidx i; 260 260 261 objc_mutex_lock (__objc_runtime_mutex);261 objc_mutex_lock (__objc_runtime_mutex); 262 262 263 263 i = (sidx) hash_value_for_key (__objc_selector_hash, name); 264 264 if (soffset_decode (i) == 0) 265 265 { 266 objc_mutex_unlock (__objc_runtime_mutex);266 objc_mutex_unlock (__objc_runtime_mutex); 267 267 return 0; 268 268 } 269 269 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); 272 272 273 273 if (l == 0) 274 274 return 0; 275 275 276 return (SEL) l->head;276 return (SEL) l->head; 277 277 } 278 278 … … 286 286 /* Get name of selector. If selector is unknown, the empty string "" 287 287 is returned */ 288 const char* 289 sel_get_name (SEL selector) 288 const char *sel_get_name (SEL selector) 290 289 { 291 290 const char *ret; 292 291 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)) 296 295 ret = sarray_get_safe (__objc_selector_names, (sidx) selector->sel_id); 297 296 else 298 297 ret = 0; 299 objc_mutex_unlock (__objc_runtime_mutex);298 objc_mutex_unlock (__objc_runtime_mutex); 300 299 return ret; 301 300 } … … 309 308 310 309 311 const char* 312 sel_get_type (SEL selector) 310 const char *sel_get_type (SEL selector) 313 311 { 314 312 if (selector) … … 319 317 320 318 /* The uninstalled dispatch table */ 321 extern struct sarray *__objc_uninstalled_dtable;319 extern struct sarray *__objc_uninstalled_dtable; 322 320 323 321 /* Store the passed selector name in the selector record and return its … … 332 330 struct objc_selector *orig, BOOL is_const) 333 331 { 334 struct objc_selector *j;332 struct objc_selector *j; 335 333 sidx i; 336 334 struct objc_list *l; … … 339 337 if (soffset_decode (i) != 0) 340 338 { 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); 342 340 l; l = l->tail) 343 341 { 344 SEL s = (SEL) l->head;342 SEL s = (SEL) l->head; 345 343 if (types == 0 || s->sel_types == 0) 346 344 { … … 349 347 if (orig) 350 348 { 351 orig->sel_id = (void *)i;349 orig->sel_id = (void *) i; 352 350 return orig; 353 351 } … … 356 354 } 357 355 } 358 else if (! strcmp (s->sel_types, types))356 else if (! strcmp (s->sel_types, types)) 359 357 { 360 358 if (orig) 361 359 { 362 orig->sel_id = (void *)i;360 orig->sel_id = (void *) i; 363 361 return orig; 364 362 } … … 372 370 j = objc_malloc (sizeof (struct objc_selector)); 373 371 374 j->sel_id = (void *)i;372 j->sel_id = (void *) i; 375 373 /* Can we use the pointer or must copy types? Don't copy if NULL */ 376 374 if ((is_const) || (types == 0)) 377 j->sel_types = (const char *)types;375 j->sel_types = (const char *) types; 378 376 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); 381 379 } 382 l = (struct objc_list *)sarray_get_safe (__objc_selector_array, i);380 l = (struct objc_list *) sarray_get_safe (__objc_selector_array, i); 383 381 } 384 382 else 385 383 { 386 384 __objc_selector_max_index += 1; 387 i = soffset_encode (__objc_selector_max_index);385 i = soffset_encode (__objc_selector_max_index); 388 386 if (orig) 389 387 j = orig; … … 391 389 j = objc_malloc (sizeof (struct objc_selector)); 392 390 393 j->sel_id = (void *)i;391 j->sel_id = (void *) i; 394 392 /* Can we use the pointer or must copy types? Don't copy if NULL */ 395 393 if ((is_const) || (types == 0)) 396 j->sel_types = (const char *)types;394 j->sel_types = (const char *) types; 397 395 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); 400 398 } 401 399 l = 0; … … 413 411 new_name = name; 414 412 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); 420 418 sarray_at_put_safe (__objc_selector_names, i, (void *) new_name); 421 419 sarray_at_put_safe (__objc_selector_array, i, (void *) l); … … 424 422 } 425 423 426 sarray_realloc (__objc_uninstalled_dtable, __objc_selector_max_index+1);424 sarray_realloc (__objc_uninstalled_dtable, __objc_selector_max_index + 1); 427 425 428 426 return (SEL) j; … … 434 432 SEL ret; 435 433 436 objc_mutex_lock (__objc_runtime_mutex);434 objc_mutex_lock (__objc_runtime_mutex); 437 435 /* Assume that name is not constant static memory and needs to be 438 436 copied before put into a runtime structure. is_const == NO */ 439 437 ret = __sel_register_typed_name (name, 0, 0, NO); 440 objc_mutex_unlock (__objc_runtime_mutex);438 objc_mutex_unlock (__objc_runtime_mutex); 441 439 442 440 return ret; … … 448 446 SEL ret; 449 447 450 objc_mutex_lock (__objc_runtime_mutex);448 objc_mutex_lock (__objc_runtime_mutex); 451 449 /* Assume that name and type are not constant static memory and need to 452 450 be copied before put into a runtime structure. is_const == NO */ 453 451 ret = __sel_register_typed_name (name, type, 0, NO); 454 objc_mutex_unlock (__objc_runtime_mutex);452 objc_mutex_unlock (__objc_runtime_mutex); 455 453 456 454 return ret; 457 455 } 458 -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/sendmsg.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* GNU Objective C Runtime message lookup 2 2 Copyright (C) 1993, 1995, 1996, 1997, 1998, 3 2001 Free Software Foundation, Inc.3 2001, 2002 Free Software Foundation, Inc. 4 4 Contributed by Kresten Krab Thorup 5 5 … … 38 38 #define rtx int 39 39 40 #if ! defined(STRUCT_VALUE) || STRUCT_VALUE == 040 #if ! defined (STRUCT_VALUE) || STRUCT_VALUE == 0 41 41 #define INVISIBLE_STRUCT_RETURN 1 42 42 #else … … 45 45 46 46 /* The uninstalled dispatch table */ 47 struct sarray *__objc_uninstalled_dtable = 0; /* !T:MUTEX */47 struct sarray *__objc_uninstalled_dtable = 0; /* !T:MUTEX */ 48 48 49 49 /* Hook for method forwarding. If it is set, is invoked to return a 50 50 function that performs the real forwarding. Otherwise the libgcc 51 51 based functions (__builtin_apply and friends) are used. */ 52 IMP (*__objc_msg_forward) (SEL) = NULL;52 IMP (*__objc_msg_forward) (SEL) = NULL; 53 53 54 54 /* Send +initialize to class */ 55 static void __objc_send_initialize (Class);55 static void __objc_send_initialize (Class); 56 56 57 57 static void __objc_install_dispatch_table_for_class (Class); 58 58 59 59 /* Forward declare some functions */ 60 static void __objc_init_install_dtable (id, SEL);60 static void __objc_init_install_dtable (id, SEL); 61 61 62 62 /* Various forwarding functions that are used based upon the … … 66 66 __objc_word_forward for pointers or types that fit in registers. 67 67 */ 68 static double __objc_double_forward (id, SEL, ...);69 static id __objc_word_forward (id, SEL, ...);68 static double __objc_double_forward (id, SEL, ...); 69 static id __objc_word_forward (id, SEL, ...); 70 70 typedef struct { id many[8]; } __big; 71 71 #if INVISIBLE_STRUCT_RETURN … … 74 74 static id 75 75 #endif 76 __objc_block_forward (id, SEL, ...);76 __objc_block_forward (id, SEL, ...); 77 77 static 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, ...);78 Method_t search_for_method_in_list (MethodList_t list, SEL op); 79 id nil_method (id, SEL); 80 80 81 81 /* Given a selector, return the proper forwarding implementation. */ … … 84 84 __objc_get_forward_imp (SEL sel) 85 85 { 86 /* If a custom forwarding hook was registered, try getting a forwarding 87 * function from it. */ 86 88 if (__objc_msg_forward) 87 89 { 88 90 IMP result; 89 if ((result = __objc_msg_forward (sel)) )91 if ((result = __objc_msg_forward (sel)) != NULL) 90 92 return result; 91 93 } 92 else 94 95 /* In all other cases, use the default forwarding functions built using 96 * __builtin_apply and friends. */ 93 97 { 94 98 const char *t = sel->sel_types; … … 96 100 if (t && (*t == '[' || *t == '(' || *t == '{') 97 101 #ifdef OBJC_MAX_STRUCT_BY_VALUE 98 && objc_sizeof_type (t) > OBJC_MAX_STRUCT_BY_VALUE102 && objc_sizeof_type (t) > OBJC_MAX_STRUCT_BY_VALUE 99 103 #endif 100 104 ) … … 112 116 get_imp (Class class, SEL sel) 113 117 { 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); 115 119 if (res == 0) 116 120 { 117 121 /* Not a valid method */ 118 if (class->dtable == __objc_uninstalled_dtable)122 if (class->dtable == __objc_uninstalled_dtable) 119 123 { 120 124 /* The dispatch table needs to be installed. */ 121 objc_mutex_lock (__objc_runtime_mutex);125 objc_mutex_lock (__objc_runtime_mutex); 122 126 __objc_install_dispatch_table_for_class (class); 123 objc_mutex_unlock (__objc_runtime_mutex);127 objc_mutex_unlock (__objc_runtime_mutex); 124 128 /* Call ourselves with the installed dispatch table 125 129 and get the real method */ 126 res = get_imp (class, sel);130 res = get_imp (class, sel); 127 131 } 128 132 else … … 131 135 method just doesn't exist for the class. 132 136 Return the forwarding implementation. */ 133 res = __objc_get_forward_imp (sel);137 res = __objc_get_forward_imp (sel); 134 138 } 135 139 } … … 144 148 __objc_responds_to (id object, SEL sel) 145 149 { 146 void *res;150 void *res; 147 151 148 152 /* Install dispatch table if need be */ 149 153 if (object->class_pointer->dtable == __objc_uninstalled_dtable) 150 154 { 151 objc_mutex_lock (__objc_runtime_mutex);155 objc_mutex_lock (__objc_runtime_mutex); 152 156 __objc_install_dispatch_table_for_class (object->class_pointer); 153 objc_mutex_unlock (__objc_runtime_mutex);157 objc_mutex_unlock (__objc_runtime_mutex); 154 158 } 155 159 … … 164 168 __inline__ 165 169 IMP 166 objc_msg_lookup (id receiver, SEL op)170 objc_msg_lookup (id receiver, SEL op) 167 171 { 168 172 IMP result; 169 if (receiver)173 if (receiver) 170 174 { 171 175 result = sarray_get_safe (receiver->class_pointer->dtable, … … 174 178 { 175 179 /* Not a valid method */ 176 if (receiver->class_pointer->dtable == __objc_uninstalled_dtable)180 if (receiver->class_pointer->dtable == __objc_uninstalled_dtable) 177 181 { 178 182 /* The dispatch table needs to be installed. 179 183 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); 181 185 182 186 /* 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); 184 188 } 185 189 else … … 188 192 method just doesn't exist for the class. 189 193 Attempt to forward the method. */ 190 result = __objc_get_forward_imp (op);194 result = __objc_get_forward_imp (op); 191 195 } 192 196 } … … 194 198 } 195 199 else 196 return nil_method;200 return (IMP)nil_method; 197 201 } 198 202 … … 203 207 return get_imp (super->class, sel); 204 208 else 205 return nil_method;206 } 207 208 int method_get_sizeof_arguments (Method *);209 return (IMP)nil_method; 210 } 211 212 int method_get_sizeof_arguments (Method *); 209 213 210 214 retval_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);215 objc_msg_sendv (id object, SEL op, arglist_t arg_frame) 216 { 217 Method *m = class_get_instance_method (object->class_pointer, op); 214 218 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)); 220 224 } 221 225 222 226 void 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); 227 230 } 228 231 … … 231 234 for each class, namely when the very first message is sent to it. */ 232 235 static void 233 __objc_init_install_dtable (id receiver, SEL op)236 __objc_init_install_dtable (id receiver, SEL op __attribute__ ((__unused__))) 234 237 { 235 238 /* This may happen, if the programmer has taken the address of a 236 239 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) 238 241 return; 239 242 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)) 243 246 { 244 247 /* receiver is an ordinary object */ 245 assert (CLS_ISCLASS(receiver->class_pointer));248 assert (CLS_ISCLASS (receiver->class_pointer)); 246 249 247 250 /* install instance methods table */ … … 250 253 /* call +initialize -- this will in turn install the factory 251 254 dispatch table if not already done :-) */ 252 __objc_send_initialize (receiver->class_pointer);255 __objc_send_initialize (receiver->class_pointer); 253 256 } 254 257 else 255 258 { 256 259 /* 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)); 259 262 260 263 /* Install real dtable for factory methods */ 261 264 __objc_install_dispatch_table_for_class (receiver->class_pointer); 262 265 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); 266 269 } 267 270 … … 269 272 that class (or instances hereof) to be initialized properly */ 270 273 void 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); 274 277 class->dtable = __objc_uninstalled_dtable; 275 278 } … … 277 280 /* Send +initialize to class if not already done */ 278 281 static void 279 __objc_send_initialize (Class class)282 __objc_send_initialize (Class class) 280 283 { 281 284 /* 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); 289 292 290 293 /* Create the garbage collector type memory description */ 291 294 __objc_generate_gc_type_description (class); 292 295 293 if (class->super_class)294 __objc_send_initialize (class->super_class);296 if (class->super_class) 297 __objc_send_initialize (class->super_class); 295 298 296 299 { … … 303 306 Method_t method; 304 307 305 for (i = 0; i < method_list->method_count; i++) {308 for (i = 0; i < method_list->method_count; i++) { 306 309 method = &(method_list->method_list[i]); 307 310 if (method->method_name … … 319 322 } 320 323 if (imp) 321 (*imp) ((id)class, op);324 (*imp) ((id) class, op); 322 325 323 326 } … … 336 339 int i; 337 340 338 if (! method_list)341 if (! method_list) 339 342 return; 340 343 … … 359 362 /* If the class has not yet had its class links resolved, we must 360 363 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 (); 363 366 364 367 super = class->super_class; … … 370 373 if (super == 0) 371 374 { 372 objc_mutex_lock (__objc_runtime_mutex);375 objc_mutex_lock (__objc_runtime_mutex); 373 376 class->dtable = sarray_new (__objc_selector_max_index, 0); 374 objc_mutex_unlock (__objc_runtime_mutex);377 objc_mutex_unlock (__objc_runtime_mutex); 375 378 } 376 379 else … … 390 393 return; 391 394 392 objc_mutex_lock (__objc_runtime_mutex);395 objc_mutex_lock (__objc_runtime_mutex); 393 396 394 397 arr = class->dtable; … … 403 406 __objc_update_dispatch_table_for_class (next); 404 407 405 objc_mutex_unlock (__objc_runtime_mutex);408 objc_mutex_unlock (__objc_runtime_mutex); 406 409 } 407 410 … … 420 423 421 424 /* Passing of a linked list is not allowed. Do multiple calls. */ 422 assert (! list->method_next);425 assert (! list->method_next); 423 426 424 427 /* Check for duplicates. */ … … 431 434 /* This is where selector names are transmogrified to SEL's */ 432 435 method->method_name = 433 sel_register_typed_name ((const char *)method->method_name,436 sel_register_typed_name ((const char *) method->method_name, 434 437 method->method_types); 435 438 } … … 445 448 446 449 Method_t 447 class_get_instance_method (Class class, SEL op)448 { 449 return search_for_method_in_hierarchy (class, op);450 class_get_instance_method (Class class, SEL op) 451 { 452 return search_for_method_in_hierarchy (class, op); 450 453 } 451 454 452 455 Method_t 453 class_get_class_method (MetaClass class, SEL op)454 { 455 return search_for_method_in_hierarchy (class, op);456 class_get_class_method (MetaClass class, SEL op) 457 { 458 return search_for_method_in_hierarchy (class, op); 456 459 } 457 460 … … 577 580 578 581 /* 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::"); 581 584 582 585 if (__objc_responds_to (object, frwd_sel)) 583 586 { 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); 586 589 } 587 590 … … 598 601 error:. If it does then sent it. */ 599 602 { 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)]; 602 605 603 606 sprintf (msg, "(%s) %s does not recognize %s", 604 (CLS_ISMETA (object->class_pointer)607 (CLS_ISMETA (object->class_pointer) 605 608 ? "class" 606 609 : "instance" ), … … 623 626 624 627 void 625 __objc_print_dtable_stats ()628 __objc_print_dtable_stats () 626 629 { 627 630 int total = 0; 628 631 629 objc_mutex_lock (__objc_runtime_mutex);632 objc_mutex_lock (__objc_runtime_mutex); 630 633 631 634 #ifdef OBJC_SPARSE2 632 printf ("memory usage: (%s)\n", "2-level sparse arrays");635 printf ("memory usage: (%s)\n", "2-level sparse arrays"); 633 636 #else 634 printf ("memory usage: (%s)\n", "3-level sparse arrays");637 printf ("memory usage: (%s)\n", "3-level sparse arrays"); 635 638 #endif 636 639 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); 651 655 } 652 656 … … 655 659 then that means it needs its dispatch table to be installed. */ 656 660 __inline__ 657 struct sarray *658 objc_get_uninstalled_dtable ()661 struct sarray * 662 objc_get_uninstalled_dtable () 659 663 { 660 664 return __objc_uninstalled_dtable; -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/thr-mach.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* 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. 3 3 Contributed by Galen C. Hunt (gchunt@cs.rochester.edu) 4 4 Modified for Mach threads by Bill Bumgarner <bbum@friday.com> … … 38 38 privileges. Once lowered, it cannot be raised. 39 39 */ 40 static int __mach_get_max_thread_priority(cthread_t t, int *base) 40 static int 41 __mach_get_max_thread_priority (cthread_t t, int *base) 41 42 { 42 43 thread_t threadP; … … 48 49 return -1; 49 50 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); 54 55 55 56 if (error != KERN_SUCCESS) … … 66 67 /* Initialize the threads subsystem. */ 67 68 int 68 __objc_init_thread_system (void)69 __objc_init_thread_system (void) 69 70 { 70 71 return 0; … … 73 74 /* Close the threads subsystem. */ 74 75 int 75 __objc_close_thread_system (void)76 __objc_close_thread_system (void) 76 77 { 77 78 return 0; … … 82 83 /* Create a new thread of execution. */ 83 84 objc_thread_t 84 __objc_thread_detach (void (*func)(void *arg), void *arg)85 __objc_thread_detach (void (*func) (void *arg), void *arg) 85 86 { 86 87 objc_thread_t thread_id; … … 88 89 89 90 /* 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) 93 94 { 94 95 /* 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); 97 98 } 98 99 else … … 104 105 /* Set the current thread's priority. */ 105 106 int 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 (); 109 110 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); 111 112 int sys_priority = 0; 112 113 … … 133 134 134 135 /* Change the priority */ 135 if (cthread_priority (cT, sys_priority, 0) == KERN_SUCCESS)136 if (cthread_priority (cT, sys_priority, 0) == KERN_SUCCESS) 136 137 return 0; 137 138 else … … 141 142 /* Return the current thread's priority. */ 142 143 int 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 () */ 147 148 int basePriority; 148 149 int maxPriority; … … 151 152 int interactiveT, backgroundT, lowT; /* thresholds */ 152 153 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) 156 157 return -1; 157 158 … … 167 168 /* Yield our process time to another thread. */ 168 169 void 169 __objc_thread_yield (void)170 { 171 cthread_yield ();170 __objc_thread_yield (void) 171 { 172 cthread_yield (); 172 173 } 173 174 174 175 /* Terminate the current thread. */ 175 176 int 176 __objc_thread_exit (void)177 __objc_thread_exit (void) 177 178 { 178 179 /* exit the thread */ 179 cthread_exit (&__objc_thread_exit_status);180 cthread_exit (&__objc_thread_exit_status); 180 181 181 182 /* Failed if we reached here */ … … 185 186 /* Returns an integer value which uniquely describes a thread. */ 186 187 objc_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; 192 193 } 193 194 194 195 /* Sets the thread's local storage pointer. */ 195 196 int 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); 199 200 return 0; 200 201 } … … 202 203 /* Returns the thread's local storage pointer. */ 203 204 void * 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 ()); 207 208 } 208 209 … … 211 212 /* Allocate a mutex. */ 212 213 int 213 __objc_mutex_allocate (objc_mutex_t mutex)214 __objc_mutex_allocate (objc_mutex_t mutex) 214 215 { 215 216 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)); 219 220 220 221 if (err != 0) 221 222 { 222 objc_free (mutex->backend);223 objc_free (mutex->backend); 223 224 return -1; 224 225 } … … 229 230 /* Deallocate a mutex. */ 230 231 int 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); 236 237 mutex->backend = NULL; 237 238 return 0; … … 240 241 /* Grab a lock on a mutex. */ 241 242 int 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)); 245 246 return 0; 246 247 } … … 248 249 /* Try to grab a lock on a mutex. */ 249 250 int 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) 253 254 return -1; 254 255 else … … 258 259 /* Unlock the mutex */ 259 260 int 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)); 263 264 return 0; 264 265 } … … 268 269 /* Allocate a condition. */ 269 270 int 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)); 274 275 return 0; 275 276 } … … 277 278 /* Deallocate a condition. */ 278 279 int 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); 283 284 condition->backend = NULL; 284 285 return 0; … … 287 288 /* Wait on the condition */ 288 289 int 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)); 293 294 return 0; 294 295 } … … 296 297 /* Wake up all threads waiting on this condition. */ 297 298 int 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)); 301 302 return 0; 302 303 } … … 304 305 /* Wake up one thread waiting on this condition. */ 305 306 int 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)); 309 310 return 0; 310 311 } -
Property cvs2svn:cvs-rev
changed from
-
branches/GNU/src/gcc/libobjc/thr.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 49 49 so it can implement the NSBecomingMultiThreaded notification. 50 50 */ 51 objc_thread_callback objc_set_thread_callback (objc_thread_callback func)51 objc_thread_callback objc_set_thread_callback (objc_thread_callback func) 52 52 { 53 53 objc_thread_callback temp = _objc_became_multi_threaded; … … 77 77 78 78 static volatile void 79 __objc_thread_detach_function (struct __objc_thread_start_state *istate)79 __objc_thread_detach_function (struct __objc_thread_start_state *istate) 80 80 { 81 81 /* Valid state? */ 82 82 if (istate) { 83 id (*imp) (id,SEL,id);83 id (*imp) (id, SEL, id); 84 84 SEL selector = istate->selector; 85 85 id object = istate->object; … … 87 87 88 88 /* Don't need anymore so free it */ 89 objc_free (istate);89 objc_free (istate); 90 90 91 91 /* Clear out the thread local storage */ 92 objc_thread_set_data (NULL);92 objc_thread_set_data (NULL); 93 93 94 94 /* Check to see if we just became multi threaded */ 95 if (! __objc_is_multi_threaded)95 if (! __objc_is_multi_threaded) 96 96 { 97 97 __objc_is_multi_threaded = 1; … … 99 99 /* Call the hook function */ 100 100 if (_objc_became_multi_threaded != NULL) 101 (*_objc_became_multi_threaded) ();101 (*_objc_became_multi_threaded) (); 102 102 } 103 103 104 104 /* 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); 107 107 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"); 110 110 } 111 111 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"); 114 114 115 115 /* Exit the thread */ 116 objc_thread_exit ();116 objc_thread_exit (); 117 117 } 118 118 … … 132 132 */ 133 133 objc_thread_t 134 objc_thread_detach (SEL selector, id object, id argument)134 objc_thread_detach (SEL selector, id object, id argument) 135 135 { 136 136 struct __objc_thread_start_state *istate; … … 138 138 139 139 /* 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)))) 142 142 return NULL; 143 143 … … 148 148 149 149 /* lock access */ 150 objc_mutex_lock (__objc_runtime_mutex);150 objc_mutex_lock (__objc_runtime_mutex); 151 151 152 152 /* 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) 155 155 { 156 156 /* failed! */ 157 objc_mutex_unlock (__objc_runtime_mutex);158 objc_free (istate);157 objc_mutex_unlock (__objc_runtime_mutex); 158 objc_free (istate); 159 159 return NULL; 160 160 } … … 162 162 /* Increment our thread counter */ 163 163 __objc_runtime_threads_alive++; 164 objc_mutex_unlock (__objc_runtime_mutex);164 objc_mutex_unlock (__objc_runtime_mutex); 165 165 166 166 return thread_id; … … 169 169 /* Set the current thread's priority. */ 170 170 int 171 objc_thread_set_priority (int priority)171 objc_thread_set_priority (int priority) 172 172 { 173 173 /* Call the backend */ 174 return __objc_thread_set_priority (priority);174 return __objc_thread_set_priority (priority); 175 175 } 176 176 177 177 /* Return the current thread's priority. */ 178 178 int 179 objc_thread_get_priority (void)179 objc_thread_get_priority (void) 180 180 { 181 181 /* Call the backend */ 182 return __objc_thread_get_priority ();182 return __objc_thread_get_priority (); 183 183 } 184 184 … … 189 189 */ 190 190 void 191 objc_thread_yield (void)191 objc_thread_yield (void) 192 192 { 193 193 /* Call the backend */ 194 __objc_thread_yield ();194 __objc_thread_yield (); 195 195 } 196 196 … … 200 200 */ 201 201 int 202 objc_thread_exit (void)202 objc_thread_exit (void) 203 203 { 204 204 /* Decrement our counter of the number of threads alive */ 205 objc_mutex_lock (__objc_runtime_mutex);205 objc_mutex_lock (__objc_runtime_mutex); 206 206 __objc_runtime_threads_alive--; 207 objc_mutex_unlock (__objc_runtime_mutex);207 objc_mutex_unlock (__objc_runtime_mutex); 208 208 209 209 /* Call the backend to terminate the thread */ 210 return __objc_thread_exit ();210 return __objc_thread_exit (); 211 211 } 212 212 … … 216 216 */ 217 217 objc_thread_t 218 objc_thread_id (void)218 objc_thread_id (void) 219 219 { 220 220 /* Call the backend */ 221 return __objc_thread_id ();221 return __objc_thread_id (); 222 222 } 223 223 … … 227 227 */ 228 228 int 229 objc_thread_set_data (void *value)229 objc_thread_set_data (void *value) 230 230 { 231 231 /* Call the backend */ 232 return __objc_thread_set_data (value);232 return __objc_thread_set_data (value); 233 233 } 234 234 … … 237 237 */ 238 238 void * 239 objc_thread_get_data (void)239 objc_thread_get_data (void) 240 240 { 241 241 /* Call the backend */ 242 return __objc_thread_get_data ();242 return __objc_thread_get_data (); 243 243 } 244 244 … … 250 250 */ 251 251 objc_mutex_t 252 objc_mutex_allocate (void)252 objc_mutex_allocate (void) 253 253 { 254 254 objc_mutex_t mutex; 255 255 256 256 /* 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)))) 258 258 return NULL; 259 259 260 260 /* Call backend to create the mutex */ 261 if (__objc_mutex_allocate (mutex))261 if (__objc_mutex_allocate (mutex)) 262 262 { 263 263 /* failed! */ 264 objc_free (mutex);264 objc_free (mutex); 265 265 return NULL; 266 266 } … … 280 280 */ 281 281 int 282 objc_mutex_deallocate (objc_mutex_t mutex)282 objc_mutex_deallocate (objc_mutex_t mutex) 283 283 { 284 284 int depth; 285 285 286 286 /* Valid mutex? */ 287 if (! mutex)287 if (! mutex) 288 288 return -1; 289 289 290 290 /* Acquire lock on mutex */ 291 depth = objc_mutex_lock (mutex);291 depth = objc_mutex_lock (mutex); 292 292 293 293 /* Call backend to destroy mutex */ 294 if (__objc_mutex_deallocate (mutex))294 if (__objc_mutex_deallocate (mutex)) 295 295 return -1; 296 296 297 297 /* Free the mutex structure */ 298 objc_free (mutex);298 objc_free (mutex); 299 299 300 300 /* Return last depth */ … … 309 309 */ 310 310 int 311 objc_mutex_lock (objc_mutex_t mutex)311 objc_mutex_lock (objc_mutex_t mutex) 312 312 { 313 313 objc_thread_t thread_id; … … 315 315 316 316 /* Valid mutex? */ 317 if (! mutex)317 if (! mutex) 318 318 return -1; 319 319 320 320 /* If we already own the lock then increment depth */ 321 thread_id = __objc_thread_id ();321 thread_id = __objc_thread_id (); 322 322 if (mutex->owner == thread_id) 323 323 return ++mutex->depth; 324 324 325 325 /* Call the backend to lock the mutex */ 326 status = __objc_mutex_lock (mutex);326 status = __objc_mutex_lock (mutex); 327 327 328 328 /* Failed? */ … … 341 341 */ 342 342 int 343 objc_mutex_trylock (objc_mutex_t mutex)343 objc_mutex_trylock (objc_mutex_t mutex) 344 344 { 345 345 objc_thread_t thread_id; … … 347 347 348 348 /* Valid mutex? */ 349 if (! mutex)349 if (! mutex) 350 350 return -1; 351 351 352 352 /* If we already own the lock then increment depth */ 353 thread_id = __objc_thread_id ();353 thread_id = __objc_thread_id (); 354 354 if (mutex->owner == thread_id) 355 355 return ++mutex->depth; 356 356 357 357 /* Call the backend to try to lock the mutex */ 358 status = __objc_mutex_trylock (mutex);358 status = __objc_mutex_trylock (mutex); 359 359 360 360 /* Failed? */ … … 376 376 */ 377 377 int 378 objc_mutex_unlock (objc_mutex_t mutex)378 objc_mutex_unlock (objc_mutex_t mutex) 379 379 { 380 380 objc_thread_t thread_id; … … 382 382 383 383 /* Valid mutex? */ 384 if (! mutex)384 if (! mutex) 385 385 return -1; 386 386 387 387 /* If another thread owns the lock then abort */ 388 thread_id = __objc_thread_id ();388 thread_id = __objc_thread_id (); 389 389 if (mutex->owner != thread_id) 390 390 return -1; … … 399 399 400 400 /* Have the backend unlock the mutex */ 401 status = __objc_mutex_unlock (mutex);401 status = __objc_mutex_unlock (mutex); 402 402 403 403 /* Failed? */ … … 415 415 */ 416 416 objc_condition_t 417 objc_condition_allocate (void)417 objc_condition_allocate (void) 418 418 { 419 419 objc_condition_t condition; 420 420 421 421 /* 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)))) 424 424 return NULL; 425 425 426 426 /* Call the backend to create the condition mutex */ 427 if (__objc_condition_allocate (condition))427 if (__objc_condition_allocate (condition)) 428 428 { 429 429 /* failed! */ 430 objc_free (condition);430 objc_free (condition); 431 431 return NULL; 432 432 } … … 444 444 */ 445 445 int 446 objc_condition_deallocate (objc_condition_t condition)446 objc_condition_deallocate (objc_condition_t condition) 447 447 { 448 448 /* Broadcast the condition */ 449 if (objc_condition_broadcast (condition))449 if (objc_condition_broadcast (condition)) 450 450 return -1; 451 451 452 452 /* Call the backend to destroy */ 453 if (__objc_condition_deallocate (condition))453 if (__objc_condition_deallocate (condition)) 454 454 return -1; 455 455 456 456 /* Free the condition mutex structure */ 457 objc_free (condition);457 objc_free (condition); 458 458 459 459 return 0; … … 461 461 462 462 /* 463 Wait on the condition unlocking the mutex until objc_condition_signal ()464 or objc_condition_broadcast () are called for the same condition. The463 Wait on the condition unlocking the mutex until objc_condition_signal () 464 or objc_condition_broadcast () are called for the same condition. The 465 465 given mutex *must* have the depth set to 1 so that it can be unlocked 466 466 here, so that someone else can lock it and signal/broadcast the condition. … … 469 469 */ 470 470 int 471 objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)471 objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) 472 472 { 473 473 objc_thread_t thread_id; 474 474 475 475 /* Valid arguments? */ 476 if (! mutex || !condition)476 if (! mutex || ! condition) 477 477 return -1; 478 478 479 479 /* Make sure we are owner of mutex */ 480 thread_id = __objc_thread_id ();480 thread_id = __objc_thread_id (); 481 481 if (mutex->owner != thread_id) 482 482 return -1; … … 491 491 492 492 /* Call the backend to wait */ 493 __objc_condition_wait (condition, mutex);493 __objc_condition_wait (condition, mutex); 494 494 495 495 /* Make ourselves owner of the mutex */ … … 507 507 */ 508 508 int 509 objc_condition_broadcast (objc_condition_t condition)509 objc_condition_broadcast (objc_condition_t condition) 510 510 { 511 511 /* 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); 516 516 } 517 517 … … 523 523 */ 524 524 int 525 objc_condition_signal (objc_condition_t condition)525 objc_condition_signal (objc_condition_t condition) 526 526 { 527 527 /* 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); 532 532 } 533 533 … … 536 536 from now on. This is used when you are interfacing with some 537 537 external non-objc-based environment/system - you must call 538 objc_thread_add () before an alien thread makes any calls to538 objc_thread_add () before an alien thread makes any calls to 539 539 Objective-C. Do not cause the _objc_became_multi_threaded hook to 540 540 be executed. */ 541 541 void 542 objc_thread_add (void)543 { 544 objc_mutex_lock (__objc_runtime_mutex);542 objc_thread_add (void) 543 { 544 objc_mutex_lock (__objc_runtime_mutex); 545 545 __objc_is_multi_threaded = 1; 546 546 __objc_runtime_threads_alive++; 547 objc_mutex_unlock (__objc_runtime_mutex);547 objc_mutex_unlock (__objc_runtime_mutex); 548 548 } 549 549 … … 551 551 stopped) by some external code will no longer access objc and thus 552 552 can be forgotten by the objc thread system. Call 553 objc_thread_remove () when your alien thread is done with making553 objc_thread_remove () when your alien thread is done with making 554 554 calls to Objective-C. */ 555 555 void 556 objc_thread_remove (void)557 { 558 objc_mutex_lock (__objc_runtime_mutex);556 objc_thread_remove (void) 557 { 558 objc_mutex_lock (__objc_runtime_mutex); 559 559 __objc_runtime_threads_alive--; 560 objc_mutex_unlock (__objc_runtime_mutex);560 objc_mutex_unlock (__objc_runtime_mutex); 561 561 } 562 562 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.