aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kabaev <kan@FreeBSD.org>2003-07-11 03:42:15 +0000
committerAlexander Kabaev <kan@FreeBSD.org>2003-07-11 03:42:15 +0000
commit63c14f51d5c7b6579c1eac10cec4b60f42b86e84 (patch)
treeb912048c8df69db39da9eded7043642b2854fa0d
parent1b86b14eacf30b52bd5b9e48116db15982432eda (diff)
downloadsrc-63c14f51d5c7b6579c1eac10cec4b60f42b86e84.tar.gz
src-63c14f51d5c7b6579c1eac10cec4b60f42b86e84.zip
Gcc 3.3.1-pre 2003-07-11 Objective C support bits.
Notes
Notes: svn path=/vendor/gcc/dist/; revision=117399
-rw-r--r--contrib/libobjc/ChangeLog156
-rw-r--r--contrib/libobjc/Makefile.in5
-rw-r--r--contrib/libobjc/Object.m7
-rw-r--r--contrib/libobjc/Protocol.m12
-rw-r--r--contrib/libobjc/aclocal.m42
-rw-r--r--contrib/libobjc/archive.c694
-rw-r--r--contrib/libobjc/class.c96
-rwxr-xr-xcontrib/libobjc/configure188
-rw-r--r--contrib/libobjc/configure.in4
-rw-r--r--contrib/libobjc/encoding.c294
-rw-r--r--contrib/libobjc/gc.c68
-rw-r--r--contrib/libobjc/hash.c8
-rw-r--r--contrib/libobjc/init.c380
-rw-r--r--contrib/libobjc/misc.c103
-rw-r--r--contrib/libobjc/nil_method.c27
-rw-r--r--contrib/libobjc/objc/encoding.h34
-rw-r--r--contrib/libobjc/objc/hash.h12
-rw-r--r--contrib/libobjc/objc/objc.h9
-rw-r--r--contrib/libobjc/objc/runtime.h5
-rw-r--r--contrib/libobjc/objc/thr.h86
-rw-r--r--contrib/libobjc/objects.c56
-rw-r--r--contrib/libobjc/sarray.c251
-rw-r--r--contrib/libobjc/selector.c149
-rw-r--r--contrib/libobjc/sendmsg.c212
-rw-r--r--contrib/libobjc/thr-mach.c117
-rw-r--r--contrib/libobjc/thr.c178
26 files changed, 1695 insertions, 1458 deletions
diff --git a/contrib/libobjc/ChangeLog b/contrib/libobjc/ChangeLog
index 70660786b7cc..1ea7cb21b930 100644
--- a/contrib/libobjc/ChangeLog
+++ b/contrib/libobjc/ChangeLog
@@ -1,12 +1,20 @@
-2003-02-05 Release Manager
+2003-05-13 Release Manager
- * GCC 3.2.2 Released.
+ * GCC 3.3 Released.
-2003-01-28 Christian Cornelssen <ccorn@cs.tu-berlin.de>
+2003-05-13 Release Manager
- * Makefile.in (FLAGS_TO_PASS): Also pass DESTDIR.
- (install-libs, install-headers): Prepend $(DESTDIR) to
- destination paths in all (un)installation commands.
+ * GCC 3.3 Released.
+
+2003-05-13 Release Manager
+
+ * GCC 3.3 Released.
+
+2003-02-20 Alexandre Oliva <aoliva@redhat.com>
+
+ * configure.in: Propagate ORIGINAL_LD_FOR_MULTILIBS to
+ config.status.
+ * configure: Rebuilt.
2003-01-27 Alexandre Oliva <aoliva@redhat.com>
@@ -15,29 +23,49 @@
version_specific_libs is enabled.
* configure: Rebuilt.
-2002-11-19 Release Manager
-
- * GCC 3.2.1 Released.
-
-2002-11-19 Release Manager
+2003-01-26 Christian Cornelssen <ccorn@cs.tu-berlin.de>
- * GCC 3.2.1 Released.
-
-2002-11-18 Release Manager
-
- * GCC 3.2.1 Released.
+ * Makefile.in (FLAGS_TO_PASS): Also pass DESTDIR.
+ (install-libs, install-headers): Prepend $(DESTDIR) to
+ destination paths in all (un)installation commands.
-2002-10-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+2002-09-22 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* Makefile.in (all): Fix multilib parallel build.
-2002-08-14 Release Manager
-
- * GCC 3.2 Released.
-
-2002-07-25 Release Manager
-
- * GCC 3.1.1 Released.
+Thu Sep 12 12:44:37 2002 Nicola Pero <n.pero@mi.flashnet.it>
+
+ * sendmsg.c (nil_method): Declare not to take a variable number of
+ args.
+ (objc_msg_lookup): Cast nil_method to IMP before returning it.
+ (objc_msg_lookup_super): The same.
+
+2002-09-10 Jan Hubicka <jh@suse.cz>
+
+ * nil_method.c (nil_method): No longer defined with variable
+ arguments.
+
+2002-07-02 Rodney Brown <rbrown64@csc.com.au>
+
+ * objc/encoding.h: Fix formatting.
+ * objc/hash.h: Likewise.
+ * objc/objc-api.h: Likewise.
+ * objc/runtime.h: Likewise.
+ * objc/thr.h: Likewise.
+ * archive.c: Likewise.
+ * class.c: Likewise.
+ * encoding.c: Likewise.
+ * gc.c: Likewise.
+ * hash.c: Likewise.
+ * init.c: Likewise.
+ * misc.c: Likewise.
+ * nil_method.c: Likewise.
+ * objects.c: Likewise.
+ * sarray.c: Likewise.
+ * selector.c: Likewise.
+ * sendmsg.c: Likewise.
+ * thr-mach.c: Likewise.
+ * thr.c: Likewise.
2002-06-25 DJ Delorie <dj@redhat.com>
@@ -46,13 +74,68 @@
* configure.in: Call it before AC_CANONICAL_SYSTEM.
* configure: Regenerate.
-2002-05-14 Release Manager
-
- * GCC 3.1 Released.
-
-2002-05-14 Release Manager
-
- * GCC 3.1 Released.
+2002-06-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * Object.m (forward, read, write): Fix unused parameter warnings.
+ * encoding.c: Include <stdlib.h>.
+ (target_flags): Mark with attribute unused.
+ (atoi): Delete.
+ * runtime.h (__objc_selector_max_index): Change to unsigned int.
+ (__objc_generate_gc_type_description): Prototype.
+ * selector.c (__objc_selector_max_index): Change to unsigned int.
+
+Mon Jun 17 18:37:42 2002 Nicola Pero <n.pero@mi.flashnet.it>
+
+ * sendmsg.c (__objc_get_forward_imp): Fix warning by making sure
+ we always have a return value: if __objc_msg_forward does not
+ supply a forwarding implementation, return the default
+ __builtin_apply based one.
+
+2002-06-15 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * Object.m: Fix signed/unsigned warning.
+ * Protocol.m: Likewise.
+ * archive.c: Always include stdlib.h.
+ (objc_read_short, objc_read_unsigned_short, objc_read_int,
+ objc_read_long, __objc_read_nbyte_uint, __objc_read_nbyte_ulong):
+ Fix signed/unsigned warning.
+ (objc_write_type, objc_read_type, objc_write_types,
+ objc_read_types): Ensure ctype 8-bit safety.
+ (__objc_no_write, __objc_no_read): Mark unused parameters.
+ * class.c (class_table_setup): Specify void arg.
+ * encoding.c (atoi, objc_sizeof_type, objc_alignof_type,
+ objc_skip_typespec, objc_skip_offset,
+ objc_layout_structure_next_member): Ensure ctype 8-bit safety.
+ (objc_layout_structure_next_member): Ensure variables are
+ initialized.
+ * gc.c (__objc_generate_gc_type_description,
+ class_ivar_set_gcinvisible): Mark unused parameters.
+ * init.c (__objc_send_load, __objc_destroy_class_tree_node): Mark
+ unused parameters.
+ (__objc_init_protocols) Fix signed/unsigned warning.
+ * nil_method.c (nil_method): Mark unused parameters.
+ * thr.h (objc_thread_callback): Specify void arg.
+ * sarray.c (sarray_new, sarray_realloc, sarray_free): Fix
+ signed/unsigned warning.
+ (sarray_free): Fix formatting.
+ * selector.c (sel_types_match): Ensure ctype 8-bit safety.
+ * sendmsg.c (__objc_init_install_dtable) Mark unused parameters.
+
+2002-06-09 Andreas Jaeger <aj@suse.de>
+
+ * encoding.c (objc_layout_structure_next_member): Remove unused
+ variable.
+
+2002-05-20 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * Makefile.in (SHELL): Set to @SHELL@.
+ (WARN_CFLAGS): New.
+ (ALL_CFLAGS): Add $(WARN_CFLAGS).
+
+2002-05-16 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+ * aclocal.m4: Allow for PWDCMD to override hardcoded pwd.
+ * configure: Regenerate.
2002-05-08 Alexandre Oliva <aoliva@redhat.com>
@@ -226,14 +309,14 @@ Wed Jan 3 00:49:10 2001 Ovidiu Predescu <ovidiu@cup.hp.com>
function. This can alleviate problems __builtin_apply() and
friends have on various platforms. (Solution suggested by Helge
Hess.)
-
+
* objc/objc-api.h: Define __objc_msg_forward.
* sendmsg.c: Define gen_rtx_REG.
2000-12-06 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
- * thr-rtems.c: New file. Stub to compile.
+ * thr-rtems.c: New file. Stub to compile.
2000-09-06 Alexandre Oliva <aoliva@redhat.com>
@@ -275,7 +358,7 @@ Sun Aug 6 22:51:16 2000 Ovidiu Predescu <ovidiu@cup.hp.com>
Fri Jul 28 08:58:02 2000 Nicola Pero <nicola@brainstorm.co.uk>
- * configure.in: Added libtool support; build shared libraries
+ * configure.in: Added libtool support; build shared libraries
if --enable-shared was passed on command line.
* Makefile.in: Modified most compilation commands to use libtool.
* aclocal.m4: New symbolic link to the ../libtool.m4, from the
@@ -336,7 +419,7 @@ Tue Sep 21 07:47:10 1999 Jeffrey A Law (law@cygnus.com)
* Makefile.in (gc.o, gc_gc.o): Do not pass -fgnu-runtime to
the compiler when building C code.
-
+
Fri Aug 6 23:32:29 1999 Daniel Jacobowitz <drow@drow.them.org>
* Makefile.in (FLAGS_TO_PASS): Include prefix, exec_prefix,
@@ -415,7 +498,7 @@ Sat Oct 17 05:21:31 1998 Ovidiu Predescu <ovidiu@slip.net>
Mon Oct 11 21:25:27 1998 Ovidiu Predescu <ovidiu@slip.net>
* encoding.c: Redefine get_inner_array_type to get the first entry
- in the structure.
+ in the structure.
Thu Oct 8 12:21:14 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
@@ -480,4 +563,3 @@ Mon Sep 21 23:27:10 1998 Ovidiu Predescu <ovidiu@slip.net>
1998-09-21 Ben Elliston <bje@cygnus.com>
* New directory. Moved files from ../gcc/objc.
-
diff --git a/contrib/libobjc/Makefile.in b/contrib/libobjc/Makefile.in
index 28361d26bb8f..244f1e75a1a3 100644
--- a/contrib/libobjc/Makefile.in
+++ b/contrib/libobjc/Makefile.in
@@ -22,7 +22,7 @@
#Makefile.in files. Some of this stuff may be unnecessary and
#worthless.
-SHELL = /bin/sh
+SHELL = @SHELL@
MAKEOVERRIDES=
#### Start of system configuration section. ####
@@ -67,8 +67,9 @@ RANLIB = @RANLIB@
CC = @CC@
CFLAGS = @CFLAGS@
+WARN_CFLAGS = -W -Wall -Wwrite-strings -Wstrict-prototypes
GTHREAD_FLAGS=@GTHREAD_FLAGS@
-ALL_CFLAGS = -I. -I$(srcdir) $(CPPFLAGS) $(DEFS) $(CFLAGS) \
+ALL_CFLAGS = -I. -I$(srcdir) $(CPPFLAGS) $(DEFS) $(CFLAGS) $(WARN_CFLAGS) \
$(GTHREAD_FLAGS) -DIN_GCC -DIN_TARGET_LIBS
# Libtool
diff --git a/contrib/libobjc/Object.m b/contrib/libobjc/Object.m
index f5f329482c97..1882754d605e 100644
--- a/contrib/libobjc/Object.m
+++ b/contrib/libobjc/Object.m
@@ -1,5 +1,5 @@
/* The implementation of class Object for Objective-C.
- Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 1995, 1997, 2002 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -199,7 +199,7 @@ extern int errno;
+ (BOOL) conformsTo: (Protocol*)aProtocol
{
- int i;
+ size_t i;
struct objc_protocol_list* proto_list;
id parent;
@@ -271,6 +271,7 @@ extern int errno;
- (retval_t)forward:(SEL)aSel :(arglist_t)argFrame
{
+ (void) argFrame; /* UNUSED */
return (retval_t)[self doesNotRecognize: aSel];
}
@@ -364,12 +365,14 @@ extern int errno;
- read: (TypedStream*)aStream
{
+ (void) aStream; /* UNUSED */
// [super read: aStream];
return self;
}
- write: (TypedStream*)aStream
{
+ (void) aStream; /* UNUSED */
// [super write: aStream];
return self;
}
diff --git a/contrib/libobjc/Protocol.m b/contrib/libobjc/Protocol.m
index 43ba44eaf4f7..3c18a02ce977 100644
--- a/contrib/libobjc/Protocol.m
+++ b/contrib/libobjc/Protocol.m
@@ -53,7 +53,7 @@ struct objc_method_description_list {
- (BOOL) conformsTo: (Protocol *)aProtocolObject
{
- int i;
+ size_t i;
struct objc_protocol_list* proto_list;
if (!strcmp(aProtocolObject->protocol_name, self->protocol_name))
@@ -88,9 +88,10 @@ struct objc_method_description_list {
for (proto_list = protocol_list; proto_list; proto_list = proto_list->next)
{
- for (i=0; i < proto_list->count; i++)
+ size_t j;
+ for (j=0; j < proto_list->count; j++)
{
- if ((result = [proto_list->list[i]
+ if ((result = [proto_list->list[j]
descriptionForInstanceMethod: aSel]))
return result;
}
@@ -114,9 +115,10 @@ struct objc_method_description_list {
for (proto_list = protocol_list; proto_list; proto_list = proto_list->next)
{
- for (i=0; i < proto_list->count; i++)
+ size_t j;
+ for (j=0; j < proto_list->count; j++)
{
- if ((result = [proto_list->list[i]
+ if ((result = [proto_list->list[j]
descriptionForClassMethod: aSel]))
return result;
}
diff --git a/contrib/libobjc/aclocal.m4 b/contrib/libobjc/aclocal.m4
index 07dcc56b0bfb..ed643f6038ce 100644
--- a/contrib/libobjc/aclocal.m4
+++ b/contrib/libobjc/aclocal.m4
@@ -54,7 +54,7 @@ AC_DEFUN(GLIBCPP_CONFIGURE, [
# These need to be absolute paths, yet at the same time need to
# canonicalize only relative paths, because then amd will not unmount
# drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
-glibcpp_builddir=`pwd`
+glibcpp_builddir=`${PWDCMD-pwd}`
case $srcdir in
[\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;;
*) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
diff --git a/contrib/libobjc/archive.c b/contrib/libobjc/archive.c
index 10106c1145e7..f98379bc99db 100644
--- a/contrib/libobjc/archive.c
+++ b/contrib/libobjc/archive.c
@@ -1,5 +1,5 @@
-/* GNU Objective C Runtime archiving
- Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ /* GNU Objective C Runtime archiving
+ Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
Contributed by Kresten Krab Thorup
This file is part of GNU CC.
@@ -28,45 +28,42 @@ Boston, MA 02111-1307, USA. */
#include "runtime.h"
#include "typedstream.h"
#include "encoding.h"
-
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
-extern int fflush(FILE*);
+extern int fflush (FILE *);
#define ROUND(V, A) \
- ({ typeof(V) __v=(V); typeof(A) __a=(A); \
- __a*((__v+__a-1)/__a); })
+ ({ typeof (V) __v = (V); typeof (A) __a = (A); \
+ __a * ((__v + __a - 1)/__a); })
-#define PTR2LONG(P) (((char*)(P))-(char*)0)
-#define LONG2PTR(L) (((char*)0)+(L))
+#define PTR2LONG(P) (((char *) (P))-(char *) 0)
+#define LONG2PTR(L) (((char *) 0) + (L))
/* Declare some functions... */
static int
-objc_read_class (struct objc_typed_stream* stream, Class* class);
+objc_read_class (struct objc_typed_stream *stream, Class *class);
-int objc_sizeof_type(const char* type);
+int objc_sizeof_type (const char *type);
static int
-objc_write_use_common (struct objc_typed_stream* stream, unsigned long key);
+objc_write_use_common (struct objc_typed_stream *stream, unsigned long key);
static int
-objc_write_register_common (struct objc_typed_stream* stream,
+objc_write_register_common (struct objc_typed_stream *stream,
unsigned long key);
static int
-objc_write_class (struct objc_typed_stream* stream,
- struct objc_class* class);
+objc_write_class (struct objc_typed_stream *stream,
+ struct objc_class *class);
-const char* objc_skip_type (const char* type);
+const char *objc_skip_type (const char *type);
-static void __objc_finish_write_root_object(struct objc_typed_stream*);
-static void __objc_finish_read_root_object(struct objc_typed_stream*);
+static void __objc_finish_write_root_object (struct objc_typed_stream *);
+static void __objc_finish_read_root_object (struct objc_typed_stream *);
static __inline__ int
-__objc_code_unsigned_char (unsigned char* buf, unsigned char val)
+__objc_code_unsigned_char (unsigned char *buf, unsigned char val)
{
if ((val&_B_VALUE) == val)
{
@@ -82,16 +79,16 @@ __objc_code_unsigned_char (unsigned char* buf, unsigned char val)
}
int
-objc_write_unsigned_char (struct objc_typed_stream* stream,
+objc_write_unsigned_char (struct objc_typed_stream *stream,
unsigned char value)
{
- unsigned char buf[sizeof (unsigned char)+1];
+ unsigned char buf[sizeof (unsigned char) + 1];
int len = __objc_code_unsigned_char (buf, value);
- return (*stream->write)(stream->physical, buf, len);
+ return (*stream->write) (stream->physical, buf, len);
}
static __inline__ int
-__objc_code_char (unsigned char* buf, signed char val)
+__objc_code_char (unsigned char *buf, signed char val)
{
if (val >= 0)
return __objc_code_unsigned_char (buf, val);
@@ -104,15 +101,15 @@ __objc_code_char (unsigned char* buf, signed char val)
}
int
-objc_write_char (struct objc_typed_stream* stream, signed char value)
+objc_write_char (struct objc_typed_stream *stream, signed char value)
{
- unsigned char buf[sizeof (char)+1];
+ unsigned char buf[sizeof (char) + 1];
int len = __objc_code_char (buf, value);
- return (*stream->write)(stream->physical, buf, len);
+ return (*stream->write) (stream->physical, buf, len);
}
static __inline__ int
-__objc_code_unsigned_short (unsigned char* buf, unsigned short val)
+__objc_code_unsigned_short (unsigned char *buf, unsigned short val)
{
if ((val&_B_VALUE) == val)
{
@@ -125,15 +122,15 @@ __objc_code_unsigned_short (unsigned char* buf, unsigned short val)
buf[0] = _B_NINT;
- for (c= sizeof(short); c != 0; c -= 1)
- if (((val>>(8*(c-1)))%0x100) != 0)
+ for (c = sizeof (short); c != 0; c -= 1)
+ if (((val >> (8*(c - 1)))%0x100) != 0)
break;
buf[0] |= c;
for (b = 1; c != 0; c--, b++)
{
- buf[b] = (val >> (8*(c-1)))%0x100;
+ buf[b] = (val >> (8*(c - 1)))%0x100;
}
return b;
@@ -141,16 +138,16 @@ __objc_code_unsigned_short (unsigned char* buf, unsigned short val)
}
int
-objc_write_unsigned_short (struct objc_typed_stream* stream,
+objc_write_unsigned_short (struct objc_typed_stream *stream,
unsigned short value)
{
- unsigned char buf[sizeof (unsigned short)+1];
+ unsigned char buf[sizeof (unsigned short) + 1];
int len = __objc_code_unsigned_short (buf, value);
- return (*stream->write)(stream->physical, buf, len);
+ return (*stream->write) (stream->physical, buf, len);
}
static __inline__ int
-__objc_code_short (unsigned char* buf, short val)
+__objc_code_short (unsigned char *buf, short val)
{
int sign = (val < 0);
int size = __objc_code_unsigned_short (buf, sign ? -val : val);
@@ -160,16 +157,16 @@ __objc_code_short (unsigned char* buf, short val)
}
int
-objc_write_short (struct objc_typed_stream* stream, short value)
+objc_write_short (struct objc_typed_stream *stream, short value)
{
- unsigned char buf[sizeof (short)+1];
+ unsigned char buf[sizeof (short) + 1];
int len = __objc_code_short (buf, value);
- return (*stream->write)(stream->physical, buf, len);
+ return (*stream->write) (stream->physical, buf, len);
}
static __inline__ int
-__objc_code_unsigned_int (unsigned char* buf, unsigned int val)
+__objc_code_unsigned_int (unsigned char *buf, unsigned int val)
{
if ((val&_B_VALUE) == val)
{
@@ -182,8 +179,8 @@ __objc_code_unsigned_int (unsigned char* buf, unsigned int val)
buf[0] = _B_NINT;
- for (c= sizeof(int); c != 0; c -= 1)
- if (((val>>(8*(c-1)))%0x100) != 0)
+ for (c = sizeof (int); c != 0; c -= 1)
+ if (((val >> (8*(c - 1)))%0x100) != 0)
break;
buf[0] |= c;
@@ -198,15 +195,15 @@ __objc_code_unsigned_int (unsigned char* buf, unsigned int val)
}
int
-objc_write_unsigned_int (struct objc_typed_stream* stream, unsigned int value)
+objc_write_unsigned_int (struct objc_typed_stream *stream, unsigned int value)
{
- unsigned char buf[sizeof(unsigned int)+1];
+ unsigned char buf[sizeof (unsigned int) + 1];
int len = __objc_code_unsigned_int (buf, value);
- return (*stream->write)(stream->physical, buf, len);
+ return (*stream->write) (stream->physical, buf, len);
}
static __inline__ int
-__objc_code_int (unsigned char* buf, int val)
+__objc_code_int (unsigned char *buf, int val)
{
int sign = (val < 0);
int size = __objc_code_unsigned_int (buf, sign ? -val : val);
@@ -216,15 +213,15 @@ __objc_code_int (unsigned char* buf, int val)
}
int
-objc_write_int (struct objc_typed_stream* stream, int value)
+objc_write_int (struct objc_typed_stream *stream, int value)
{
- unsigned char buf[sizeof(int)+1];
+ unsigned char buf[sizeof (int) + 1];
int len = __objc_code_int (buf, value);
- return (*stream->write)(stream->physical, buf, len);
+ return (*stream->write) (stream->physical, buf, len);
}
static __inline__ int
-__objc_code_unsigned_long (unsigned char* buf, unsigned long val)
+__objc_code_unsigned_long (unsigned char *buf, unsigned long val)
{
if ((val&_B_VALUE) == val)
{
@@ -237,15 +234,15 @@ __objc_code_unsigned_long (unsigned char* buf, unsigned long val)
buf[0] = _B_NINT;
- for (c= sizeof(long); c != 0; c -= 1)
- if (((val>>(8*(c-1)))%0x100) != 0)
+ for (c = sizeof (long); c != 0; c -= 1)
+ if (((val >> (8*(c - 1)))%0x100) != 0)
break;
buf[0] |= c;
for (b = 1; c != 0; c--, b++)
{
- buf[b] = (val >> (8*(c-1)))%0x100;
+ buf[b] = (val >> (8*(c - 1)))%0x100;
}
return b;
@@ -253,16 +250,16 @@ __objc_code_unsigned_long (unsigned char* buf, unsigned long val)
}
int
-objc_write_unsigned_long (struct objc_typed_stream* stream,
+objc_write_unsigned_long (struct objc_typed_stream *stream,
unsigned long value)
{
- unsigned char buf[sizeof(unsigned long)+1];
+ unsigned char buf[sizeof (unsigned long) + 1];
int len = __objc_code_unsigned_long (buf, value);
- return (*stream->write)(stream->physical, buf, len);
+ return (*stream->write) (stream->physical, buf, len);
}
static __inline__ int
-__objc_code_long (unsigned char* buf, long val)
+__objc_code_long (unsigned char *buf, long val)
{
int sign = (val < 0);
int size = __objc_code_unsigned_long (buf, sign ? -val : val);
@@ -272,19 +269,19 @@ __objc_code_long (unsigned char* buf, long val)
}
int
-objc_write_long (struct objc_typed_stream* stream, long value)
+objc_write_long (struct objc_typed_stream *stream, long value)
{
- unsigned char buf[sizeof(long)+1];
+ unsigned char buf[sizeof (long) + 1];
int len = __objc_code_long (buf, value);
- return (*stream->write)(stream->physical, buf, len);
+ return (*stream->write) (stream->physical, buf, len);
}
int
-objc_write_string (struct objc_typed_stream* stream,
- const unsigned char* string, unsigned int nbytes)
+objc_write_string (struct objc_typed_stream *stream,
+ const unsigned char *string, unsigned int nbytes)
{
- unsigned char buf[sizeof(unsigned int)+1];
+ unsigned char buf[sizeof (unsigned int) + 1];
int len = __objc_code_unsigned_int (buf, nbytes);
if ((buf[0]&_B_CODE) == _B_SINT)
@@ -293,15 +290,15 @@ objc_write_string (struct objc_typed_stream* stream,
else /* _B_NINT */
buf[0] = (buf[0]&_B_VALUE)|_B_NSTR;
- if ((*stream->write)(stream->physical, buf, len) != 0)
- return (*stream->write)(stream->physical, string, nbytes);
+ if ((*stream->write) (stream->physical, buf, len) != 0)
+ return (*stream->write) (stream->physical, string, nbytes);
else
return 0;
}
int
-objc_write_string_atomic (struct objc_typed_stream* stream,
- unsigned char* string, unsigned int nbytes)
+objc_write_string_atomic (struct objc_typed_stream *stream,
+ unsigned char *string, unsigned int nbytes)
{
unsigned long key;
if ((key = PTR2LONG(hash_value_for_key (stream->stream_table, string))))
@@ -317,60 +314,60 @@ objc_write_string_atomic (struct objc_typed_stream* stream,
}
static int
-objc_write_register_common (struct objc_typed_stream* stream,
+objc_write_register_common (struct objc_typed_stream *stream,
unsigned long key)
{
unsigned char buf[sizeof (unsigned long)+2];
- int len = __objc_code_unsigned_long (buf+1, key);
+ int len = __objc_code_unsigned_long (buf + 1, key);
if (len == 1)
{
buf[0] = _B_RCOMM|0x01;
buf[1] &= _B_VALUE;
- return (*stream->write)(stream->physical, buf, len+1);
+ return (*stream->write) (stream->physical, buf, len + 1);
}
else
{
buf[1] = (buf[1]&_B_VALUE)|_B_RCOMM;
- return (*stream->write)(stream->physical, buf+1, len);
+ return (*stream->write) (stream->physical, buf + 1, len);
}
}
static int
-objc_write_use_common (struct objc_typed_stream* stream, unsigned long key)
+objc_write_use_common (struct objc_typed_stream *stream, unsigned long key)
{
unsigned char buf[sizeof (unsigned long)+2];
- int len = __objc_code_unsigned_long (buf+1, key);
+ int len = __objc_code_unsigned_long (buf + 1, key);
if (len == 1)
{
buf[0] = _B_UCOMM|0x01;
buf[1] &= _B_VALUE;
- return (*stream->write)(stream->physical, buf, 2);
+ return (*stream->write) (stream->physical, buf, 2);
}
else
{
buf[1] = (buf[1]&_B_VALUE)|_B_UCOMM;
- return (*stream->write)(stream->physical, buf+1, len);
+ return (*stream->write) (stream->physical, buf + 1, len);
}
}
static __inline__ int
-__objc_write_extension (struct objc_typed_stream* stream, unsigned char code)
+__objc_write_extension (struct objc_typed_stream *stream, unsigned char code)
{
if (code <= _B_VALUE)
{
unsigned char buf = code|_B_EXT;
- return (*stream->write)(stream->physical, &buf, 1);
+ return (*stream->write) (stream->physical, &buf, 1);
}
else
{
- objc_error(nil, OBJC_ERR_BAD_OPCODE,
- "__objc_write_extension: bad opcode %c\n", code);
+ objc_error (nil, OBJC_ERR_BAD_OPCODE,
+ "__objc_write_extension: bad opcode %c\n", code);
return -1;
}
}
__inline__ int
-__objc_write_object (struct objc_typed_stream* stream, id object)
+__objc_write_object (struct objc_typed_stream *stream, id object)
{
unsigned char buf = '\0';
SEL write_sel = sel_get_any_uid ("write:");
@@ -378,15 +375,15 @@ __objc_write_object (struct objc_typed_stream* stream, id object)
{
__objc_write_extension (stream, _BX_OBJECT);
objc_write_class (stream, object->class_pointer);
- (*objc_msg_lookup(object, write_sel))(object, write_sel, stream);
- return (*stream->write)(stream->physical, &buf, 1);
+ (*objc_msg_lookup (object, write_sel)) (object, write_sel, stream);
+ return (*stream->write) (stream->physical, &buf, 1);
}
else
- return objc_write_use_common(stream, 0);
+ return objc_write_use_common (stream, 0);
}
int
-objc_write_object_reference (struct objc_typed_stream* stream, id object)
+objc_write_object_reference (struct objc_typed_stream *stream, id object)
{
unsigned long key;
if ((key = PTR2LONG(hash_value_for_key (stream->object_table, object))))
@@ -397,7 +394,7 @@ objc_write_object_reference (struct objc_typed_stream* stream, id object)
}
int
-objc_write_root_object (struct objc_typed_stream* stream, id object)
+objc_write_root_object (struct objc_typed_stream *stream, id object)
{
int len = 0;
if (stream->writing_root_p)
@@ -407,22 +404,22 @@ objc_write_root_object (struct objc_typed_stream* stream, id object)
{
stream->writing_root_p = 1;
__objc_write_extension (stream, _BX_OBJROOT);
- if((len = objc_write_object (stream, object)))
- __objc_finish_write_root_object(stream);
+ if ((len = objc_write_object (stream, object)))
+ __objc_finish_write_root_object (stream);
stream->writing_root_p = 0;
}
return len;
}
int
-objc_write_object (struct objc_typed_stream* stream, id object)
+objc_write_object (struct objc_typed_stream *stream, id object)
{
unsigned long key;
if ((key = PTR2LONG(hash_value_for_key (stream->object_table, object))))
return objc_write_use_common (stream, key);
else if (object == nil)
- return objc_write_use_common(stream, 0);
+ return objc_write_use_common (stream, 0);
else
{
@@ -435,18 +432,18 @@ objc_write_object (struct objc_typed_stream* stream, id object)
}
__inline__ int
-__objc_write_class (struct objc_typed_stream* stream, struct objc_class* class)
+__objc_write_class (struct objc_typed_stream *stream, struct objc_class *class)
{
__objc_write_extension (stream, _BX_CLASS);
- objc_write_string_atomic(stream, (char*)class->name,
- strlen((char*)class->name));
+ objc_write_string_atomic (stream, (char *) class->name,
+ strlen ((char *) class->name));
return objc_write_unsigned_long (stream, class->version);
}
static int
-objc_write_class (struct objc_typed_stream* stream,
- struct objc_class* class)
+objc_write_class (struct objc_typed_stream *stream,
+ struct objc_class *class)
{
unsigned long key;
if ((key = PTR2LONG(hash_value_for_key (stream->stream_table, class))))
@@ -454,7 +451,7 @@ objc_write_class (struct objc_typed_stream* stream,
else
{
int length;
- hash_add (&stream->stream_table, LONG2PTR(key=PTR2LONG(class)), class);
+ hash_add (&stream->stream_table, LONG2PTR(key = PTR2LONG(class)), class);
if ((length = objc_write_register_common (stream, key)))
return __objc_write_class (stream, class);
return length;
@@ -463,9 +460,9 @@ objc_write_class (struct objc_typed_stream* stream,
__inline__ int
-__objc_write_selector (struct objc_typed_stream* stream, SEL selector)
+__objc_write_selector (struct objc_typed_stream *stream, SEL selector)
{
- const char* sel_name;
+ const char *sel_name;
__objc_write_extension (stream, _BX_SEL);
/* to handle NULL selectors */
if ((SEL)0 == selector)
@@ -475,9 +472,9 @@ __objc_write_selector (struct objc_typed_stream* stream, SEL selector)
}
int
-objc_write_selector (struct objc_typed_stream* stream, SEL selector)
+objc_write_selector (struct objc_typed_stream *stream, SEL selector)
{
- const char* sel_name;
+ const char *sel_name;
unsigned long key;
/* to handle NULL selectors */
@@ -491,7 +488,7 @@ objc_write_selector (struct objc_typed_stream* stream, SEL selector)
{
int length;
hash_add (&stream->stream_table,
- LONG2PTR(key=PTR2LONG(sel_name)), (char*)sel_name);
+ LONG2PTR(key = PTR2LONG(sel_name)), (char *) sel_name);
if ((length = objc_write_register_common (stream, key)))
return __objc_write_selector (stream, selector);
return length;
@@ -505,11 +502,11 @@ objc_write_selector (struct objc_typed_stream* stream, SEL selector)
*/
__inline__ int
-objc_read_char (struct objc_typed_stream* stream, char* val)
+objc_read_char (struct objc_typed_stream *stream, char *val)
{
unsigned char buf;
int len;
- len = (*stream->read)(stream->physical, &buf, 1);
+ len = (*stream->read) (stream->physical, &buf, 1);
if (len != 0)
{
if ((buf & _B_CODE) == _B_SINT)
@@ -517,47 +514,47 @@ objc_read_char (struct objc_typed_stream* stream, char* val)
else if ((buf & _B_NUMBER) == 1)
{
- len = (*stream->read)(stream->physical, val, 1);
+ len = (*stream->read) (stream->physical, val, 1);
if (buf&_B_SIGN)
- (*val) = -1*(*val);
+ (*val) = -1 * (*val);
}
else
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected 8bit signed int, got %dbit int",
- (int)(buf&_B_NUMBER)*8);
+ objc_error (nil, OBJC_ERR_BAD_DATA,
+ "expected 8bit signed int, got %dbit int",
+ (int) (buf&_B_NUMBER)*8);
}
return len;
}
__inline__ int
-objc_read_unsigned_char (struct objc_typed_stream* stream, unsigned char* val)
+objc_read_unsigned_char (struct objc_typed_stream *stream, unsigned char *val)
{
unsigned char buf;
int len;
- if ((len = (*stream->read)(stream->physical, &buf, 1)))
+ if ((len = (*stream->read) (stream->physical, &buf, 1)))
{
if ((buf & _B_CODE) == _B_SINT)
(*val) = (buf & _B_VALUE);
else if ((buf & _B_NUMBER) == 1)
- len = (*stream->read)(stream->physical, val, 1);
+ len = (*stream->read) (stream->physical, val, 1);
else
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected 8bit unsigned int, got %dbit int",
- (int)(buf&_B_NUMBER)*8);
+ objc_error (nil, OBJC_ERR_BAD_DATA,
+ "expected 8bit unsigned int, got %dbit int",
+ (int) (buf&_B_NUMBER)*8);
}
return len;
}
__inline__ int
-objc_read_short (struct objc_typed_stream* stream, short* value)
+objc_read_short (struct objc_typed_stream *stream, short *value)
{
- unsigned char buf[sizeof(short)+1];
+ unsigned char buf[sizeof (short) + 1];
int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
+ if ((len = (*stream->read) (stream->physical, buf, 1)))
{
if ((buf[0] & _B_CODE) == _B_SINT)
(*value) = (buf[0] & _B_VALUE);
@@ -566,10 +563,10 @@ objc_read_short (struct objc_typed_stream* stream, short* value)
{
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
- if (nbytes > sizeof (short))
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected short, got bigger (%dbits)", nbytes*8);
- len = (*stream->read)(stream->physical, buf+1, nbytes);
+ if (nbytes > (int) sizeof (short))
+ objc_error (nil, OBJC_ERR_BAD_DATA,
+ "expected short, got bigger (%dbits)", nbytes*8);
+ len = (*stream->read) (stream->physical, buf + 1, nbytes);
(*value) = 0;
while (pos <= nbytes)
(*value) = ((*value)*0x100) + buf[pos++];
@@ -581,12 +578,12 @@ objc_read_short (struct objc_typed_stream* stream, short* value)
}
__inline__ int
-objc_read_unsigned_short (struct objc_typed_stream* stream,
- unsigned short* value)
+objc_read_unsigned_short (struct objc_typed_stream *stream,
+ unsigned short *value)
{
- unsigned char buf[sizeof(unsigned short)+1];
+ unsigned char buf[sizeof (unsigned short) + 1];
int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
+ if ((len = (*stream->read) (stream->physical, buf, 1)))
{
if ((buf[0] & _B_CODE) == _B_SINT)
(*value) = (buf[0] & _B_VALUE);
@@ -595,10 +592,10 @@ objc_read_unsigned_short (struct objc_typed_stream* stream,
{
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
- if (nbytes > sizeof (short))
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected short, got int or bigger");
- len = (*stream->read)(stream->physical, buf+1, nbytes);
+ if (nbytes > (int) sizeof (short))
+ objc_error (nil, OBJC_ERR_BAD_DATA,
+ "expected short, got int or bigger");
+ len = (*stream->read) (stream->physical, buf + 1, nbytes);
(*value) = 0;
while (pos <= nbytes)
(*value) = ((*value)*0x100) + buf[pos++];
@@ -609,11 +606,11 @@ objc_read_unsigned_short (struct objc_typed_stream* stream,
__inline__ int
-objc_read_int (struct objc_typed_stream* stream, int* value)
+objc_read_int (struct objc_typed_stream *stream, int *value)
{
- unsigned char buf[sizeof(int)+1];
+ unsigned char buf[sizeof (int) + 1];
int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
+ if ((len = (*stream->read) (stream->physical, buf, 1)))
{
if ((buf[0] & _B_CODE) == _B_SINT)
(*value) = (buf[0] & _B_VALUE);
@@ -622,9 +619,9 @@ objc_read_int (struct objc_typed_stream* stream, int* value)
{
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
- if (nbytes > sizeof (int))
- objc_error(nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
- len = (*stream->read)(stream->physical, buf+1, nbytes);
+ if (nbytes > (int) sizeof (int))
+ objc_error (nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
+ len = (*stream->read) (stream->physical, buf + 1, nbytes);
(*value) = 0;
while (pos <= nbytes)
(*value) = ((*value)*0x100) + buf[pos++];
@@ -636,11 +633,11 @@ objc_read_int (struct objc_typed_stream* stream, int* value)
}
__inline__ int
-objc_read_long (struct objc_typed_stream* stream, long* value)
+objc_read_long (struct objc_typed_stream *stream, long *value)
{
- unsigned char buf[sizeof(long)+1];
+ unsigned char buf[sizeof (long) + 1];
int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
+ if ((len = (*stream->read) (stream->physical, buf, 1)))
{
if ((buf[0] & _B_CODE) == _B_SINT)
(*value) = (buf[0] & _B_VALUE);
@@ -649,9 +646,9 @@ objc_read_long (struct objc_typed_stream* stream, long* value)
{
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
- if (nbytes > sizeof (long))
- objc_error(nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
- len = (*stream->read)(stream->physical, buf+1, nbytes);
+ if (nbytes > (int) sizeof (long))
+ objc_error (nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
+ len = (*stream->read) (stream->physical, buf + 1, nbytes);
(*value) = 0;
while (pos <= nbytes)
(*value) = ((*value)*0x100) + buf[pos++];
@@ -663,16 +660,17 @@ objc_read_long (struct objc_typed_stream* stream, long* value)
}
__inline__ int
-__objc_read_nbyte_uint (struct objc_typed_stream* stream,
- unsigned int nbytes, unsigned int* val)
+__objc_read_nbyte_uint (struct objc_typed_stream *stream,
+ unsigned int nbytes, unsigned int *val)
{
- int len, pos = 0;
- unsigned char buf[sizeof(unsigned int)+1];
+ int len;
+ unsigned int pos = 0;
+ unsigned char buf[sizeof (unsigned int) + 1];
if (nbytes > sizeof (int))
- objc_error(nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
+ objc_error (nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
- len = (*stream->read)(stream->physical, buf, nbytes);
+ len = (*stream->read) (stream->physical, buf, nbytes);
(*val) = 0;
while (pos < nbytes)
(*val) = ((*val)*0x100) + buf[pos++];
@@ -681,12 +679,12 @@ __objc_read_nbyte_uint (struct objc_typed_stream* stream,
__inline__ int
-objc_read_unsigned_int (struct objc_typed_stream* stream,
- unsigned int* value)
+objc_read_unsigned_int (struct objc_typed_stream *stream,
+ unsigned int *value)
{
- unsigned char buf[sizeof(unsigned int)+1];
+ unsigned char buf[sizeof (unsigned int) + 1];
int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
+ if ((len = (*stream->read) (stream->physical, buf, 1)))
{
if ((buf[0] & _B_CODE) == _B_SINT)
(*value) = (buf[0] & _B_VALUE);
@@ -699,16 +697,17 @@ objc_read_unsigned_int (struct objc_typed_stream* stream,
}
int
-__objc_read_nbyte_ulong (struct objc_typed_stream* stream,
- unsigned int nbytes, unsigned long* val)
+__objc_read_nbyte_ulong (struct objc_typed_stream *stream,
+ unsigned int nbytes, unsigned long *val)
{
- int len, pos = 0;
- unsigned char buf[sizeof(unsigned long)+1];
+ int len;
+ unsigned int pos = 0;
+ unsigned char buf[sizeof (unsigned long) + 1];
if (nbytes > sizeof (long))
- objc_error(nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
+ objc_error (nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
- len = (*stream->read)(stream->physical, buf, nbytes);
+ len = (*stream->read) (stream->physical, buf, nbytes);
(*val) = 0;
while (pos < nbytes)
(*val) = ((*val)*0x100) + buf[pos++];
@@ -717,12 +716,12 @@ __objc_read_nbyte_ulong (struct objc_typed_stream* stream,
__inline__ int
-objc_read_unsigned_long (struct objc_typed_stream* stream,
- unsigned long* value)
+objc_read_unsigned_long (struct objc_typed_stream *stream,
+ unsigned long *value)
{
- unsigned char buf[sizeof(unsigned long)+1];
+ unsigned char buf[sizeof (unsigned long) + 1];
int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
+ if ((len = (*stream->read) (stream->physical, buf, 1)))
{
if ((buf[0] & _B_CODE) == _B_SINT)
(*value) = (buf[0] & _B_VALUE);
@@ -735,29 +734,29 @@ objc_read_unsigned_long (struct objc_typed_stream* stream,
}
__inline__ int
-objc_read_string (struct objc_typed_stream* stream,
- char** string)
+objc_read_string (struct objc_typed_stream *stream,
+ char **string)
{
- unsigned char buf[sizeof(unsigned int)+1];
+ unsigned char buf[sizeof (unsigned int) + 1];
int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
+ if ((len = (*stream->read) (stream->physical, buf, 1)))
{
unsigned long key = 0;
if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */
{
- len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
- len = (*stream->read)(stream->physical, buf, 1);
+ len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
+ len = (*stream->read) (stream->physical, buf, 1);
}
switch (buf[0]&_B_CODE) {
case _B_SSTR:
{
int length = buf[0]&_B_VALUE;
- (*string) = (char*)objc_malloc(length+1);
+ (*string) = (char*)objc_malloc (length + 1);
if (key)
hash_add (&stream->stream_table, LONG2PTR(key), *string);
- len = (*stream->read)(stream->physical, *string, length);
+ len = (*stream->read) (stream->physical, *string, length);
(*string)[length] = '\0';
}
break;
@@ -765,9 +764,9 @@ objc_read_string (struct objc_typed_stream* stream,
case _B_UCOMM:
{
char *tmp;
- len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
+ len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
tmp = hash_value_for_key (stream->stream_table, LONG2PTR (key));
- *string = objc_malloc (strlen(tmp) + 1);
+ *string = objc_malloc (strlen (tmp) + 1);
strcpy (*string, tmp);
}
break;
@@ -775,20 +774,20 @@ objc_read_string (struct objc_typed_stream* stream,
case _B_NSTR:
{
unsigned int nbytes = buf[0]&_B_VALUE;
- len = __objc_read_nbyte_uint(stream, nbytes, &nbytes);
+ len = __objc_read_nbyte_uint (stream, nbytes, &nbytes);
if (len) {
- (*string) = (char*)objc_malloc(nbytes+1);
+ (*string) = (char*)objc_malloc (nbytes + 1);
if (key)
hash_add (&stream->stream_table, LONG2PTR(key), *string);
- len = (*stream->read)(stream->physical, *string, nbytes);
+ len = (*stream->read) (stream->physical, *string, nbytes);
(*string)[nbytes] = '\0';
}
}
break;
default:
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected string, got opcode %c\n", (buf[0]&_B_CODE));
+ objc_error (nil, OBJC_ERR_BAD_DATA,
+ "expected string, got opcode %c\n", (buf[0]&_B_CODE));
}
}
@@ -797,19 +796,19 @@ objc_read_string (struct objc_typed_stream* stream,
int
-objc_read_object (struct objc_typed_stream* stream, id* object)
+objc_read_object (struct objc_typed_stream *stream, id *object)
{
unsigned char buf[sizeof (unsigned int)];
int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
+ if ((len = (*stream->read) (stream->physical, buf, 1)))
{
SEL read_sel = sel_get_any_uid ("read:");
unsigned long key = 0;
if ((buf[0]&_B_CODE) == _B_RCOMM) /* register common */
{
- len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
- len = (*stream->read)(stream->physical, buf, 1);
+ len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
+ len = (*stream->read) (stream->physical, buf, 1);
}
if (buf[0] == (_B_EXT | _BX_OBJECT))
@@ -820,7 +819,7 @@ objc_read_object (struct objc_typed_stream* stream, id* object)
len = objc_read_class (stream, &class);
/* create instance */
- (*object) = class_create_instance(class);
+ (*object) = class_create_instance (class);
/* register? */
if (key)
@@ -828,148 +827,148 @@ objc_read_object (struct objc_typed_stream* stream, id* object)
/* send -read: */
if (__objc_responds_to (*object, read_sel))
- (*get_imp(class, read_sel))(*object, read_sel, stream);
+ (*get_imp (class, read_sel)) (*object, read_sel, stream);
/* check null-byte */
- len = (*stream->read)(stream->physical, buf, 1);
+ len = (*stream->read) (stream->physical, buf, 1);
if (buf[0] != '\0')
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected null-byte, got opcode %c", buf[0]);
+ objc_error (nil, OBJC_ERR_BAD_DATA,
+ "expected null-byte, got opcode %c", buf[0]);
}
else if ((buf[0]&_B_CODE) == _B_UCOMM)
{
if (key)
- objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
- len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
+ objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
+ len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
(*object) = hash_value_for_key (stream->object_table, LONG2PTR(key));
}
else if (buf[0] == (_B_EXT | _BX_OBJREF)) /* a forward reference */
{
- struct objc_list* other;
+ struct objc_list *other;
len = objc_read_unsigned_long (stream, &key);
- other = (struct objc_list*)hash_value_for_key (stream->object_refs,
- LONG2PTR(key));
+ other = (struct objc_list *) hash_value_for_key (stream->object_refs,
+ LONG2PTR(key));
hash_add (&stream->object_refs, LONG2PTR(key),
- (void*)list_cons(object, other));
+ (void *)list_cons (object, other));
}
else if (buf[0] == (_B_EXT | _BX_OBJROOT)) /* a root object */
{
if (key)
- objc_error(nil, OBJC_ERR_BAD_KEY,
- "cannot register root object...");
+ objc_error (nil, OBJC_ERR_BAD_KEY,
+ "cannot register root object...");
len = objc_read_object (stream, object);
__objc_finish_read_root_object (stream);
}
else
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected object, got opcode %c", buf[0]);
+ objc_error (nil, OBJC_ERR_BAD_DATA,
+ "expected object, got opcode %c", buf[0]);
}
return len;
}
static int
-objc_read_class (struct objc_typed_stream* stream, Class* class)
+objc_read_class (struct objc_typed_stream *stream, Class *class)
{
unsigned char buf[sizeof (unsigned int)];
int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
+ if ((len = (*stream->read) (stream->physical, buf, 1)))
{
unsigned long key = 0;
if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */
{
- len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
- len = (*stream->read)(stream->physical, buf, 1);
+ len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
+ len = (*stream->read) (stream->physical, buf, 1);
}
if (buf[0] == (_B_EXT | _BX_CLASS))
{
- char* class_name;
+ char *class_name;
unsigned long version;
/* get class */
len = objc_read_string (stream, &class_name);
- (*class) = objc_get_class(class_name);
- objc_free(class_name);
+ (*class) = objc_get_class (class_name);
+ objc_free (class_name);
/* register */
if (key)
hash_add (&stream->stream_table, LONG2PTR(key), *class);
- objc_read_unsigned_long(stream, &version);
- hash_add (&stream->class_table, (*class)->name, (void*)version);
+ objc_read_unsigned_long (stream, &version);
+ hash_add (&stream->class_table, (*class)->name, (void *)version);
}
else if ((buf[0]&_B_CODE) == _B_UCOMM)
{
if (key)
- objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
- len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
- (*class) = hash_value_for_key (stream->stream_table, LONG2PTR(key));
- if (!*class)
- objc_error(nil, OBJC_ERR_BAD_CLASS,
- "cannot find class for key %lu", key);
+ objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
+ len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
+ *class = hash_value_for_key (stream->stream_table, LONG2PTR(key));
+ if (! *class)
+ objc_error (nil, OBJC_ERR_BAD_CLASS,
+ "cannot find class for key %lu", key);
}
else
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected class, got opcode %c", buf[0]);
+ objc_error (nil, OBJC_ERR_BAD_DATA,
+ "expected class, got opcode %c", buf[0]);
}
return len;
}
int
-objc_read_selector (struct objc_typed_stream* stream, SEL* selector)
+objc_read_selector (struct objc_typed_stream *stream, SEL* selector)
{
unsigned char buf[sizeof (unsigned int)];
int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
+ if ((len = (*stream->read) (stream->physical, buf, 1)))
{
unsigned long key = 0;
if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */
{
- len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
- len = (*stream->read)(stream->physical, buf, 1);
+ len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
+ len = (*stream->read) (stream->physical, buf, 1);
}
if (buf[0] == (_B_EXT|_BX_SEL)) /* selector! */
{
- char* selector_name;
+ char *selector_name;
/* get selector */
len = objc_read_string (stream, &selector_name);
/* To handle NULL selectors */
- if (0 == strlen(selector_name))
+ if (0 == strlen (selector_name))
{
(*selector) = (SEL)0;
return 0;
}
else
- (*selector) = sel_get_any_uid(selector_name);
- objc_free(selector_name);
+ (*selector) = sel_get_any_uid (selector_name);
+ objc_free (selector_name);
/* register */
if (key)
- hash_add (&stream->stream_table, LONG2PTR(key), (void*)*selector);
+ hash_add (&stream->stream_table, LONG2PTR(key), (void *) *selector);
}
else if ((buf[0]&_B_CODE) == _B_UCOMM)
{
if (key)
- objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
- len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
+ objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
+ len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
(*selector) = hash_value_for_key (stream->stream_table,
LONG2PTR(key));
}
else
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected selector, got opcode %c", buf[0]);
+ objc_error (nil, OBJC_ERR_BAD_DATA,
+ "expected selector, got opcode %c", buf[0]);
}
return len;
}
@@ -984,66 +983,67 @@ objc_read_selector (struct objc_typed_stream* stream, SEL* selector)
*/
int
-objc_write_type(TypedStream* stream, const char* type, const void* data)
+objc_write_type (TypedStream *stream, const char *type, const void *data)
{
- switch(*type) {
+ switch (*type) {
case _C_ID:
- return objc_write_object (stream, *(id*)data);
+ return objc_write_object (stream, *(id *) data);
break;
case _C_CLASS:
- return objc_write_class (stream, *(Class*)data);
+ return objc_write_class (stream, *(Class *) data);
break;
case _C_SEL:
- return objc_write_selector (stream, *(SEL*)data);
+ return objc_write_selector (stream, *(SEL *) data);
break;
case _C_CHR:
- return objc_write_char(stream, *(signed char*)data);
+ return objc_write_char (stream, *(signed char *) data);
break;
case _C_UCHR:
- return objc_write_unsigned_char(stream, *(unsigned char*)data);
+ return objc_write_unsigned_char (stream, *(unsigned char *) data);
break;
case _C_SHT:
- return objc_write_short(stream, *(short*)data);
+ return objc_write_short (stream, *(short *) data);
break;
case _C_USHT:
- return objc_write_unsigned_short(stream, *(unsigned short*)data);
+ return objc_write_unsigned_short (stream, *(unsigned short *) data);
break;
case _C_INT:
- return objc_write_int(stream, *(int*)data);
+ return objc_write_int (stream, *(int *) data);
break;
case _C_UINT:
- return objc_write_unsigned_int(stream, *(unsigned int*)data);
+ return objc_write_unsigned_int (stream, *(unsigned int *) data);
break;
case _C_LNG:
- return objc_write_long(stream, *(long*)data);
+ return objc_write_long (stream, *(long *) data);
break;
case _C_ULNG:
- return objc_write_unsigned_long(stream, *(unsigned long*)data);
+ return objc_write_unsigned_long (stream, *(unsigned long *) data);
break;
case _C_CHARPTR:
- return objc_write_string (stream, *(char**)data, strlen(*(char**)data));
+ return objc_write_string (stream,
+ *(char **) data, strlen (*(char **) data));
break;
case _C_ATOM:
- return objc_write_string_atomic (stream, *(char**)data,
- strlen(*(char**)data));
+ return objc_write_string_atomic (stream, *(char **) data,
+ strlen (*(char **) data));
break;
case _C_ARY_B:
{
- int len = atoi(type+1);
- while (isdigit(*++type))
+ int len = atoi (type + 1);
+ while (isdigit ((unsigned char) *++type))
;
return objc_write_array (stream, type, len, data);
}
@@ -1059,7 +1059,7 @@ objc_write_type(TypedStream* stream, const char* type, const void* data)
{
align = objc_alignof_type (type); /* padd to alignment */
acc_size += ROUND (acc_size, align);
- objc_write_type (stream, type, ((char*)data)+acc_size);
+ objc_write_type (stream, type, ((char *) data) + acc_size);
acc_size += objc_sizeof_type (type); /* add component size */
type = objc_skip_typespec (type); /* skip component */
}
@@ -1068,8 +1068,8 @@ objc_write_type(TypedStream* stream, const char* type, const void* data)
default:
{
- objc_error(nil, OBJC_ERR_BAD_TYPE,
- "objc_write_type: cannot parse typespec: %s\n", type);
+ objc_error (nil, OBJC_ERR_BAD_TYPE,
+ "objc_write_type: cannot parse typespec: %s\n", type);
return 0;
}
}
@@ -1083,10 +1083,10 @@ objc_write_type(TypedStream* stream, const char* type, const void* data)
*/
int
-objc_read_type(TypedStream* stream, const char* type, void* data)
+objc_read_type(TypedStream *stream, const char *type, void *data)
{
char c;
- switch(c = *type) {
+ switch (c = *type) {
case _C_ID:
return objc_read_object (stream, (id*)data);
break;
@@ -1138,8 +1138,8 @@ objc_read_type(TypedStream* stream, const char* type, void* data)
case _C_ARY_B:
{
- int len = atoi(type+1);
- while (isdigit(*++type))
+ int len = atoi (type + 1);
+ while (isdigit ((unsigned char) *++type))
;
return objc_read_array (stream, type, len, data);
}
@@ -1164,8 +1164,8 @@ objc_read_type(TypedStream* stream, const char* type, void* data)
default:
{
- objc_error(nil, OBJC_ERR_BAD_TYPE,
- "objc_read_type: cannot parse typespec: %s\n", type);
+ objc_error (nil, OBJC_ERR_BAD_TYPE,
+ "objc_read_type: cannot parse typespec: %s\n", type);
return 0;
}
}
@@ -1182,7 +1182,7 @@ objc_read_type(TypedStream* stream, const char* type, void* data)
*/
int
-objc_write_types (TypedStream* stream, const char* type, ...)
+objc_write_types (TypedStream *stream, const char *type, ...)
{
va_list args;
const char *c;
@@ -1192,17 +1192,17 @@ objc_write_types (TypedStream* stream, const char* type, ...)
for (c = type; *c; c = objc_skip_typespec (c))
{
- switch(*c) {
+ switch (*c) {
case _C_ID:
res = objc_write_object (stream, *va_arg (args, id*));
break;
case _C_CLASS:
- res = objc_write_class (stream, *va_arg(args, Class*));
+ res = objc_write_class (stream, *va_arg (args, Class*));
break;
case _C_SEL:
- res = objc_write_selector (stream, *va_arg(args, SEL*));
+ res = objc_write_selector (stream, *va_arg (args, SEL*));
break;
case _C_CHR:
@@ -1215,60 +1215,60 @@ objc_write_types (TypedStream* stream, const char* type, ...)
break;
case _C_SHT:
- res = objc_write_short (stream, *va_arg(args, short*));
+ res = objc_write_short (stream, *va_arg (args, short*));
break;
case _C_USHT:
res = objc_write_unsigned_short (stream,
- *va_arg(args, unsigned short*));
+ *va_arg (args, unsigned short*));
break;
case _C_INT:
- res = objc_write_int(stream, *va_arg(args, int*));
+ res = objc_write_int(stream, *va_arg (args, int*));
break;
case _C_UINT:
- res = objc_write_unsigned_int(stream, *va_arg(args, unsigned int*));
+ res = objc_write_unsigned_int(stream, *va_arg (args, unsigned int*));
break;
case _C_LNG:
- res = objc_write_long(stream, *va_arg(args, long*));
+ res = objc_write_long(stream, *va_arg (args, long*));
break;
case _C_ULNG:
- res = objc_write_unsigned_long(stream, *va_arg(args, unsigned long*));
+ res = objc_write_unsigned_long(stream, *va_arg (args, unsigned long*));
break;
case _C_CHARPTR:
{
- char** str = va_arg(args, char**);
- res = objc_write_string (stream, *str, strlen(*str));
+ char **str = va_arg (args, char **);
+ res = objc_write_string (stream, *str, strlen (*str));
}
break;
case _C_ATOM:
{
- char** str = va_arg(args, char**);
- res = objc_write_string_atomic (stream, *str, strlen(*str));
+ char **str = va_arg (args, char **);
+ res = objc_write_string_atomic (stream, *str, strlen (*str));
}
break;
case _C_ARY_B:
{
- int len = atoi(c+1);
- const char* t = c;
- while (isdigit(*++t))
+ int len = atoi (c + 1);
+ const char *t = c;
+ while (isdigit ((unsigned char) *++t))
;
- res = objc_write_array (stream, t, len, va_arg(args, void*));
+ res = objc_write_array (stream, t, len, va_arg (args, void *));
t = objc_skip_typespec (t);
if (*t != _C_ARY_E)
- objc_error(nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
+ objc_error (nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
}
break;
default:
- objc_error(nil, OBJC_ERR_BAD_TYPE,
- "objc_write_types: cannot parse typespec: %s\n", type);
+ objc_error (nil, OBJC_ERR_BAD_TYPE,
+ "objc_write_types: cannot parse typespec: %s\n", type);
}
}
va_end(args);
@@ -1282,88 +1282,88 @@ objc_write_types (TypedStream* stream, const char* type, ...)
*/
int
-objc_read_types(TypedStream* stream, const char* type, ...)
+objc_read_types(TypedStream *stream, const char *type, ...)
{
va_list args;
const char *c;
int res = 0;
- va_start(args, type);
+ va_start (args, type);
for (c = type; *c; c = objc_skip_typespec(c))
{
- switch(*c) {
+ switch (*c) {
case _C_ID:
- res = objc_read_object(stream, va_arg(args, id*));
+ res = objc_read_object(stream, va_arg (args, id*));
break;
case _C_CLASS:
- res = objc_read_class(stream, va_arg(args, Class*));
+ res = objc_read_class(stream, va_arg (args, Class*));
break;
case _C_SEL:
- res = objc_read_selector(stream, va_arg(args, SEL*));
+ res = objc_read_selector(stream, va_arg (args, SEL*));
break;
case _C_CHR:
- res = objc_read_char(stream, va_arg(args, char*));
+ res = objc_read_char(stream, va_arg (args, char*));
break;
case _C_UCHR:
- res = objc_read_unsigned_char(stream, va_arg(args, unsigned char*));
+ res = objc_read_unsigned_char(stream, va_arg (args, unsigned char*));
break;
case _C_SHT:
- res = objc_read_short(stream, va_arg(args, short*));
+ res = objc_read_short(stream, va_arg (args, short*));
break;
case _C_USHT:
- res = objc_read_unsigned_short(stream, va_arg(args, unsigned short*));
+ res = objc_read_unsigned_short(stream, va_arg (args, unsigned short*));
break;
case _C_INT:
- res = objc_read_int(stream, va_arg(args, int*));
+ res = objc_read_int(stream, va_arg (args, int*));
break;
case _C_UINT:
- res = objc_read_unsigned_int(stream, va_arg(args, unsigned int*));
+ res = objc_read_unsigned_int(stream, va_arg (args, unsigned int*));
break;
case _C_LNG:
- res = objc_read_long(stream, va_arg(args, long*));
+ res = objc_read_long(stream, va_arg (args, long*));
break;
case _C_ULNG:
- res = objc_read_unsigned_long(stream, va_arg(args, unsigned long*));
+ res = objc_read_unsigned_long(stream, va_arg (args, unsigned long*));
break;
case _C_CHARPTR:
case _C_ATOM:
{
- char** str = va_arg(args, char**);
+ char **str = va_arg (args, char **);
res = objc_read_string (stream, str);
}
break;
case _C_ARY_B:
{
- int len = atoi(c+1);
- const char* t = c;
- while (isdigit(*++t))
+ int len = atoi (c + 1);
+ const char *t = c;
+ while (isdigit ((unsigned char) *++t))
;
- res = objc_read_array (stream, t, len, va_arg(args, void*));
+ res = objc_read_array (stream, t, len, va_arg (args, void *));
t = objc_skip_typespec (t);
if (*t != _C_ARY_E)
- objc_error(nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
+ objc_error (nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
}
break;
default:
- objc_error(nil, OBJC_ERR_BAD_TYPE,
- "objc_read_types: cannot parse typespec: %s\n", type);
+ objc_error (nil, OBJC_ERR_BAD_TYPE,
+ "objc_read_types: cannot parse typespec: %s\n", type);
}
}
- va_end(args);
+ va_end (args);
return res;
}
@@ -1373,11 +1373,11 @@ objc_read_types(TypedStream* stream, const char* type, ...)
*/
int
-objc_write_array (TypedStream* stream, const char* type,
- int count, const void* data)
+objc_write_array (TypedStream *stream, const char *type,
+ int count, const void *data)
{
int off = objc_sizeof_type(type);
- const char* where = data;
+ const char *where = data;
while (count-- > 0)
{
@@ -1395,11 +1395,11 @@ objc_write_array (TypedStream* stream, const char* type,
*/
int
-objc_read_array (TypedStream* stream, const char* type,
- int count, void* data)
+objc_read_array (TypedStream *stream, const char *type,
+ int count, void *data)
{
int off = objc_sizeof_type(type);
- char* where = (char*)data;
+ char *where = (char*)data;
while (count-- > 0)
{
@@ -1410,44 +1410,48 @@ objc_read_array (TypedStream* stream, const char* type,
}
static int
-__objc_fread(FILE* file, char* data, int len)
+__objc_fread (FILE *file, char *data, int len)
{
return fread(data, len, 1, file);
}
static int
-__objc_fwrite(FILE* file, char* data, int len)
+__objc_fwrite (FILE *file, char *data, int len)
{
return fwrite(data, len, 1, file);
}
static int
-__objc_feof(FILE* file)
+__objc_feof (FILE *file)
{
return feof(file);
}
static int
-__objc_no_write(FILE* file, char* data, int len)
+__objc_no_write (FILE *file __attribute__ ((__unused__)),
+ const char *data __attribute__ ((__unused__)),
+ int len __attribute__ ((__unused__)))
{
objc_error (nil, OBJC_ERR_NO_WRITE, "TypedStream not open for writing");
return 0;
}
static int
-__objc_no_read(FILE* file, char* data, int len)
+__objc_no_read (FILE *file __attribute__ ((__unused__)),
+ const char *data __attribute__ ((__unused__)),
+ int len __attribute__ ((__unused__)))
{
objc_error (nil, OBJC_ERR_NO_READ, "TypedStream not open for reading");
return 0;
}
static int
-__objc_read_typed_stream_signature (TypedStream* stream)
+__objc_read_typed_stream_signature (TypedStream *stream)
{
char buffer[80];
int pos = 0;
do
- (*stream->read)(stream->physical, buffer+pos, 1);
+ (*stream->read) (stream->physical, buffer+pos, 1);
while (buffer[pos++] != '\0')
;
sscanf (buffer, "GNU TypedStream %d", &stream->version);
@@ -1458,16 +1462,16 @@ __objc_read_typed_stream_signature (TypedStream* stream)
}
static int
-__objc_write_typed_stream_signature (TypedStream* stream)
+__objc_write_typed_stream_signature (TypedStream *stream)
{
char buffer[80];
sprintf(buffer, "GNU TypedStream %d", OBJC_TYPED_STREAM_VERSION);
stream->version = OBJC_TYPED_STREAM_VERSION;
- (*stream->write)(stream->physical, buffer, strlen(buffer)+1);
+ (*stream->write) (stream->physical, buffer, strlen (buffer) + 1);
return 1;
}
-static void __objc_finish_write_root_object(struct objc_typed_stream* stream)
+static void __objc_finish_write_root_object(struct objc_typed_stream *stream)
{
hash_delete (stream->object_table);
stream->object_table = hash_new(64,
@@ -1475,7 +1479,7 @@ static void __objc_finish_write_root_object(struct objc_typed_stream* stream)
(compare_func_type)compare_ptrs);
}
-static void __objc_finish_read_root_object(struct objc_typed_stream* stream)
+static void __objc_finish_read_root_object(struct objc_typed_stream *stream)
{
node_ptr node;
SEL awake_sel = sel_get_any_uid ("awake");
@@ -1487,12 +1491,12 @@ static void __objc_finish_read_root_object(struct objc_typed_stream* stream)
for (node = hash_next (stream->object_refs, NULL); node;
node = hash_next (stream->object_refs, node))
{
- struct objc_list* reflist = node->value;
- const void* key = node->key;
+ struct objc_list *reflist = node->value;
+ const void *key = node->key;
id object = hash_value_for_key (stream->object_table, key);
- while(reflist)
+ while (reflist)
{
- *((id*)reflist->head) = object;
+ *((id*) reflist->head) = object;
if (hash_value_for_key (free_list,reflist) == NULL)
hash_add (&free_list,reflist,reflist);
@@ -1520,7 +1524,7 @@ static void __objc_finish_read_root_object(struct objc_typed_stream* stream)
{
id object = node->value;
if (__objc_responds_to (object, awake_sel))
- (*objc_msg_lookup(object, awake_sel))(object, awake_sel);
+ (*objc_msg_lookup (object, awake_sel)) (object, awake_sel);
}
}
@@ -1535,38 +1539,38 @@ static void __objc_finish_read_root_object(struct objc_typed_stream* stream)
** Open the stream PHYSICAL in MODE
*/
-TypedStream*
-objc_open_typed_stream (FILE* physical, int mode)
+TypedStream *
+objc_open_typed_stream (FILE *physical, int mode)
{
- TypedStream* s = (TypedStream*)objc_malloc(sizeof(TypedStream));
+ TypedStream *s = (TypedStream *) objc_malloc (sizeof (TypedStream));
s->mode = mode;
s->physical = physical;
- s->stream_table = hash_new(64,
- (hash_func_type)hash_ptr,
- (compare_func_type)compare_ptrs);
- s->object_table = hash_new(64,
- (hash_func_type)hash_ptr,
- (compare_func_type)compare_ptrs);
- s->eof = (objc_typed_eof_func)__objc_feof;
- s->flush = (objc_typed_flush_func)fflush;
+ s->stream_table = hash_new (64,
+ (hash_func_type) hash_ptr,
+ (compare_func_type) compare_ptrs);
+ s->object_table = hash_new (64,
+ (hash_func_type) hash_ptr,
+ (compare_func_type) compare_ptrs);
+ s->eof = (objc_typed_eof_func) __objc_feof;
+ s->flush = (objc_typed_flush_func) fflush;
s->writing_root_p = 0;
if (mode == OBJC_READONLY)
{
- s->class_table = hash_new(8, (hash_func_type)hash_string,
- (compare_func_type)compare_strings);
- s->object_refs = hash_new(8, (hash_func_type)hash_ptr,
- (compare_func_type)compare_ptrs);
- s->read = (objc_typed_read_func)__objc_fread;
- s->write = (objc_typed_write_func)__objc_no_write;
+ s->class_table = hash_new (8, (hash_func_type) hash_string,
+ (compare_func_type) compare_strings);
+ s->object_refs = hash_new (8, (hash_func_type) hash_ptr,
+ (compare_func_type) compare_ptrs);
+ s->read = (objc_typed_read_func) __objc_fread;
+ s->write = (objc_typed_write_func) __objc_no_write;
__objc_read_typed_stream_signature (s);
}
else if (mode == OBJC_WRITEONLY)
{
s->class_table = 0;
s->object_refs = 0;
- s->read = (objc_typed_read_func)__objc_no_read;
- s->write = (objc_typed_write_func)__objc_fwrite;
+ s->read = (objc_typed_read_func) __objc_no_read;
+ s->write = (objc_typed_write_func) __objc_fwrite;
__objc_write_typed_stream_signature (s);
}
else
@@ -1583,10 +1587,10 @@ objc_open_typed_stream (FILE* physical, int mode)
*/
TypedStream*
-objc_open_typed_stream_for_file (const char* file_name, int mode)
+objc_open_typed_stream_for_file (const char *file_name, int mode)
{
- FILE* file = NULL;
- TypedStream* s;
+ FILE *file = NULL;
+ TypedStream *s;
if (mode == OBJC_READONLY)
file = fopen (file_name, "r");
@@ -1610,7 +1614,7 @@ objc_open_typed_stream_for_file (const char* file_name, int mode)
*/
void
-objc_close_typed_stream (TypedStream* stream)
+objc_close_typed_stream (TypedStream *stream)
{
if (stream->mode == OBJC_READONLY)
{
@@ -1623,25 +1627,25 @@ objc_close_typed_stream (TypedStream* stream)
hash_delete (stream->object_table);
if (stream->type == (OBJC_MANAGED_STREAM | OBJC_FILE_STREAM))
- fclose ((FILE*)stream->physical);
+ fclose ((FILE *)stream->physical);
objc_free(stream);
}
BOOL
-objc_end_of_typed_stream (TypedStream* stream)
+objc_end_of_typed_stream (TypedStream *stream)
{
- return (*stream->eof)(stream->physical);
+ return (*stream->eof) (stream->physical);
}
void
-objc_flush_typed_stream (TypedStream* stream)
+objc_flush_typed_stream (TypedStream *stream)
{
- (*stream->flush)(stream->physical);
+ (*stream->flush) (stream->physical);
}
long
-objc_get_stream_class_version (TypedStream* stream, Class class)
+objc_get_stream_class_version (TypedStream *stream, Class class)
{
if (stream->class_table)
return PTR2LONG(hash_value_for_key (stream->class_table, class->name));
diff --git a/contrib/libobjc/class.c b/contrib/libobjc/class.c
index e6c943779ff9..1740f38788ee 100644
--- a/contrib/libobjc/class.c
+++ b/contrib/libobjc/class.c
@@ -1,5 +1,6 @@
/* GNU Objective C Runtime class related functions
- Copyright (C) 1993, 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1995, 1996, 1997, 2001, 2002
+ Free Software Foundation, Inc.
Contributed by Kresten Krab Thorup and Dennis Glatting.
Lock-free class table code designed and written from scratch by
@@ -163,10 +164,10 @@ static objc_mutex_t __class_table_lock = NULL;
/* Setup the table. */
static void
-class_table_setup ()
+class_table_setup (void)
{
/* Start - nothing in the table. */
- memset (class_table_array, 0, sizeof(class_node_ptr) * CLASS_TABLE_SIZE);
+ memset (class_table_array, 0, sizeof (class_node_ptr) * CLASS_TABLE_SIZE);
/* The table writing mutex. */
__class_table_lock = objc_mutex_allocate ();
@@ -339,7 +340,7 @@ class_table_next (struct class_table_enumerator **e)
#if 0 /* DEBUGGING FUNCTIONS */
/* Debugging function - print the class table. */
void
-class_table_print ()
+class_table_print (void)
{
int i;
@@ -362,7 +363,7 @@ class_table_print ()
function of hash key values. Useful to evaluate the hash function
in real cases. */
void
-class_table_print_histogram ()
+class_table_print_histogram (void)
{
int i, j;
int counter = 0;
@@ -408,64 +409,66 @@ class_table_print_histogram ()
/* This is a hook which is called by objc_get_class and
objc_lookup_class if the runtime is not able to find the class.
This may e.g. try to load in the class using dynamic loading. */
-Class (*_objc_lookup_class)(const char* name) = 0; /* !T:SAFE */
+Class (*_objc_lookup_class) (const char *name) = 0; /* !T:SAFE */
/* True when class links has been resolved. */
BOOL __objc_class_links_resolved = NO; /* !T:UNUSED */
-void __objc_init_class_tables()
+void
+__objc_init_class_tables (void)
{
/* Allocate the class hash table. */
- if(__class_table_lock)
+ if (__class_table_lock)
return;
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
class_table_setup ();
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
}
/* This function adds a class to the class hash table, and assigns the
class a number, unless it's already known. */
void
-__objc_add_class_to_hash(Class class)
+__objc_add_class_to_hash (Class class)
{
Class h_class;
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
/* Make sure the table is there. */
- assert(__class_table_lock);
+ assert (__class_table_lock);
/* Make sure it's not a meta class. */
- assert(CLS_ISCLASS(class));
+ assert (CLS_ISCLASS (class));
/* Check to see if the class is already in the hash table. */
h_class = class_table_get_safe (class->name);
- if (!h_class)
+ if (! h_class)
{
/* The class isn't in the hash table. Add the class and assign a class
number. */
static unsigned int class_number = 1;
- CLS_SETNUMBER(class, class_number);
- CLS_SETNUMBER(class->class_pointer, class_number);
+ CLS_SETNUMBER (class, class_number);
+ CLS_SETNUMBER (class->class_pointer, class_number);
++class_number;
class_table_insert (class->name, class);
}
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
}
/* Get the class object for the class named NAME. If NAME does not
identify a known class, the hook _objc_lookup_class is called. If
this fails, nil is returned. */
-Class objc_lookup_class (const char* name)
+Class
+objc_lookup_class (const char *name)
{
Class class;
@@ -475,7 +478,7 @@ Class objc_lookup_class (const char* name)
return class;
if (_objc_lookup_class)
- return (*_objc_lookup_class)(name);
+ return (*_objc_lookup_class) (name);
else
return 0;
}
@@ -494,20 +497,20 @@ objc_get_class (const char *name)
return class;
if (_objc_lookup_class)
- class = (*_objc_lookup_class)(name);
+ class = (*_objc_lookup_class) (name);
- if(class)
+ if (class)
return class;
- objc_error(nil, OBJC_ERR_BAD_CLASS,
- "objc runtime: cannot find class %s\n", name);
+ objc_error (nil, OBJC_ERR_BAD_CLASS,
+ "objc runtime: cannot find class %s\n", name);
return 0;
}
MetaClass
-objc_get_meta_class(const char *name)
+objc_get_meta_class (const char *name)
{
- return objc_get_class(name)->class_pointer;
+ return objc_get_class (name)->class_pointer;
}
/* This function provides a way to enumerate all the classes in the
@@ -516,22 +519,22 @@ objc_get_meta_class(const char *name)
For example:
id class;
void *es = NULL;
- while ((class = objc_next_class(&es)))
+ while ((class = objc_next_class (&es)))
... do something with class;
*/
Class
-objc_next_class(void **enum_state)
+objc_next_class (void **enum_state)
{
Class class;
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
/* Make sure the table is there. */
- assert(__class_table_lock);
+ assert (__class_table_lock);
- class = class_table_next ((struct class_table_enumerator **)enum_state);
+ class = class_table_next ((struct class_table_enumerator **) enum_state);
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
return class;
}
@@ -539,33 +542,34 @@ objc_next_class(void **enum_state)
/* Resolve super/subclass links for all classes. The only thing we
can be sure of is that the class_pointer for class objects point to
the right meta class objects. */
-void __objc_resolve_class_links()
+void
+__objc_resolve_class_links (void)
{
struct class_table_enumerator *es = NULL;
Class object_class = objc_get_class ("Object");
Class class1;
- assert(object_class);
+ assert (object_class);
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
/* Assign subclass links. */
while ((class1 = class_table_next (&es)))
{
/* Make sure we have what we think we have. */
- assert (CLS_ISCLASS(class1));
- assert (CLS_ISMETA(class1->class_pointer));
+ assert (CLS_ISCLASS (class1));
+ assert (CLS_ISMETA (class1->class_pointer));
/* The class_pointer of all meta classes point to Object's meta
class. */
class1->class_pointer->class_pointer = object_class->class_pointer;
- if (!(CLS_ISRESOLV(class1)))
+ if (! CLS_ISRESOLV (class1))
{
- CLS_SETRESOLV(class1);
- CLS_SETRESOLV(class1->class_pointer);
+ CLS_SETRESOLV (class1);
+ CLS_SETRESOLV (class1->class_pointer);
- if(class1->super_class)
+ if (class1->super_class)
{
Class a_super_class
= objc_get_class ((char *) class1->super_class);
@@ -607,12 +611,12 @@ void __objc_resolve_class_links()
sub_class = sub_class->sibling_class)
{
sub_class->super_class = class1;
- if(CLS_ISCLASS(sub_class))
+ if (CLS_ISCLASS (sub_class))
sub_class->class_pointer->super_class = class1->class_pointer;
}
}
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
}
@@ -622,7 +626,7 @@ void __objc_resolve_class_links()
Class
class_pose_as (Class impostor, Class super_class)
{
- if (!CLS_ISRESOLV (impostor))
+ if (! CLS_ISRESOLV (impostor))
__objc_resolve_class_links ();
/* Preconditions */
@@ -685,11 +689,11 @@ class_pose_as (Class impostor, Class super_class)
keys of the hashtable is, change all values that are superclass
into impostor. */
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
class_table_replace (super_class, impostor);
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
/* Next, we update the dispatch tables... */
__objc_update_dispatch_table_for_class (CLASSOF (impostor));
diff --git a/contrib/libobjc/configure b/contrib/libobjc/configure
index c78ef1ed3c83..64bf24828390 100755
--- a/contrib/libobjc/configure
+++ b/contrib/libobjc/configure
@@ -772,7 +772,7 @@ test "$ac_cv_mingw32" = yes && MINGW32=yes
# These need to be absolute paths, yet at the same time need to
# canonicalize only relative paths, because then amd will not unmount
# drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
-glibcpp_builddir=`pwd`
+glibcpp_builddir=`${PWDCMD-pwd}`
case $srcdir in
\\/$* | ?:\\/*) glibcpp_srcdir=${srcdir} ;;
*) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
@@ -1604,9 +1604,18 @@ gnu*)
;;
hpux10.20*|hpux11*)
- lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
- lt_cv_file_magic_cmd=/usr/bin/file
- lt_cv_file_magic_test_file=/usr/lib/libc.sl
+ case $host_cpu in
+ hppa*)
+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=/usr/lib/libc.sl
+ ;;
+ ia64*)
+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+ ;;
+ esac
;;
irix5* | irix6*)
@@ -1696,13 +1705,13 @@ file_magic_cmd=$lt_cv_file_magic_cmd
deplibs_check_method=$lt_cv_deplibs_check_method
echo $ac_n "checking for object suffix""... $ac_c" 1>&6
-echo "configure:1700: checking for object suffix" >&5
+echo "configure:1709: checking for object suffix" >&5
if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
rm -f conftest*
echo 'int i = 1;' > conftest.$ac_ext
-if { (eval echo configure:1706: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1715: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
for ac_file in conftest.*; do
case $ac_file in
*.c) ;;
@@ -1726,7 +1735,7 @@ case $deplibs_check_method in
file_magic*)
if test "$file_magic_cmd" = '$MAGIC_CMD'; then
echo $ac_n "checking for ${ac_tool_prefix}file""... $ac_c" 1>&6
-echo "configure:1730: checking for ${ac_tool_prefix}file" >&5
+echo "configure:1739: checking for ${ac_tool_prefix}file" >&5
if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1788,7 +1797,7 @@ fi
if test -z "$lt_cv_path_MAGIC_CMD"; then
if test -n "$ac_tool_prefix"; then
echo $ac_n "checking for file""... $ac_c" 1>&6
-echo "configure:1792: checking for file" >&5
+echo "configure:1801: checking for file" >&5
if eval "test \"`echo '$''{'lt_cv_path_MAGIC_CMD'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1859,7 +1868,7 @@ esac
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1863: checking for $ac_word" >&5
+echo "configure:1872: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1891,7 +1900,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1895: checking for $ac_word" >&5
+echo "configure:1904: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1926,7 +1935,7 @@ fi
# Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
set dummy ${ac_tool_prefix}strip; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1930: checking for $ac_word" >&5
+echo "configure:1939: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1958,7 +1967,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "strip", so it can be a program name with args.
set dummy strip; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1962: checking for $ac_word" >&5
+echo "configure:1971: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2025,8 +2034,21 @@ test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic"
case $host in
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 2029 "configure"' > conftest.$ac_ext
- if { (eval echo configure:2030: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ echo '#line 2038 "configure"' > conftest.$ac_ext
+ if { (eval echo configure:2039: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -melf32bsmip"
+ ;;
+ *N32*)
+ LD="${LD-ld} -melf32bmipn32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -melf64bmip"
+ ;;
+ esac
+ else
case `/usr/bin/file conftest.$ac_objext` in
*32-bit*)
LD="${LD-ld} -32"
@@ -2038,6 +2060,65 @@ case $host in
LD="${LD-ld} -64"
;;
esac
+ fi
+ fi
+ rm -rf conftest*
+ ;;
+
+ia64-*-hpux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if { (eval echo configure:2072: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ case "`/usr/bin/file conftest.o`" in
+ *ELF-32*)
+ HPUX_IA64_MODE="32"
+ ;;
+ *ELF-64*)
+ HPUX_IA64_MODE="64"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+
+x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if { (eval echo configure:2088: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ case "`/usr/bin/file conftest.o`" in
+ *32-bit*)
+ case $host in
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_i386"
+ ;;
+ ppc64-*linux*)
+ LD="${LD-ld} -m elf32ppclinux"
+ ;;
+ s390x-*linux*)
+ LD="${LD-ld} -m elf_s390"
+ ;;
+ sparc64-*linux*)
+ LD="${LD-ld} -m elf32_sparc"
+ ;;
+ esac
+ ;;
+ *64-bit*)
+ case $host in
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_x86_64"
+ ;;
+ ppc*-*linux*|powerpc*-*linux*)
+ LD="${LD-ld} -m elf64ppc"
+ ;;
+ s390*-*linux*)
+ LD="${LD-ld} -m elf64_s390"
+ ;;
+ sparc*-*linux*)
+ LD="${LD-ld} -m elf64_sparc"
+ ;;
+ esac
+ ;;
+ esac
fi
rm -rf conftest*
;;
@@ -2047,7 +2128,7 @@ case $host in
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -belf"
echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
-echo "configure:2051: checking whether the C compiler needs -belf" >&5
+echo "configure:2132: checking whether the C compiler needs -belf" >&5
if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2060,14 +2141,14 @@ ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$a
cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext <<EOF
-#line 2064 "configure"
+#line 2145 "configure"
#include "confdefs.h"
int main() {
; return 0; }
EOF
-if { (eval echo configure:2071: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2152: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
lt_cv_cc_needs_belf=yes
else
@@ -2097,7 +2178,7 @@ echo "$ac_t""$lt_cv_cc_needs_belf" 1>&6
# Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
set dummy ${ac_tool_prefix}dlltool; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2101: checking for $ac_word" >&5
+echo "configure:2182: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2129,7 +2210,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "dlltool", so it can be a program name with args.
set dummy dlltool; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2133: checking for $ac_word" >&5
+echo "configure:2214: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2164,7 +2245,7 @@ fi
# Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args.
set dummy ${ac_tool_prefix}as; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2168: checking for $ac_word" >&5
+echo "configure:2249: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2196,7 +2277,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "as", so it can be a program name with args.
set dummy as; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2200: checking for $ac_word" >&5
+echo "configure:2281: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2231,7 +2312,7 @@ fi
# Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
set dummy ${ac_tool_prefix}objdump; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2235: checking for $ac_word" >&5
+echo "configure:2316: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2263,7 +2344,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "objdump", so it can be a program name with args.
set dummy objdump; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2267: checking for $ac_word" >&5
+echo "configure:2348: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2299,12 +2380,12 @@ fi
# recent cygwin and mingw systems supply a stub DllMain which the user
# can override, but on older systems we have to supply one
echo $ac_n "checking if libtool should supply DllMain function""... $ac_c" 1>&6
-echo "configure:2303: checking if libtool should supply DllMain function" >&5
+echo "configure:2384: checking if libtool should supply DllMain function" >&5
if eval "test \"`echo '$''{'lt_cv_need_dllmain'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2308 "configure"
+#line 2389 "configure"
#include "confdefs.h"
int main() {
@@ -2312,7 +2393,7 @@ extern int __attribute__((__stdcall__)) DllMain(void*, int, void*);
DllMain (0, 0, 0);
; return 0; }
EOF
-if { (eval echo configure:2316: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
lt_cv_need_dllmain=no
else
@@ -2333,19 +2414,19 @@ echo "$ac_t""$lt_cv_need_dllmain" 1>&6
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -mdll"
echo $ac_n "checking how to link DLLs""... $ac_c" 1>&6
-echo "configure:2337: checking how to link DLLs" >&5
+echo "configure:2418: checking how to link DLLs" >&5
if eval "test \"`echo '$''{'lt_cv_cc_dll_switch'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2342 "configure"
+#line 2423 "configure"
#include "confdefs.h"
int main() {
; return 0; }
EOF
-if { (eval echo configure:2349: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2430: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
lt_cv_cc_dll_switch=-mdll
else
@@ -2463,7 +2544,7 @@ else
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2467: checking for $ac_word" >&5
+echo "configure:2548: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2503,7 +2584,7 @@ fi
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:2507: checking for a BSD compatible install" >&5
+echo "configure:2588: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2556,7 +2637,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:2560: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:2641: checking whether ${MAKE-make} sets \${MAKE}" >&5
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2585,7 +2666,7 @@ fi
# Sanity check for the cross-compilation case:
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:2589: checking how to run the C preprocessor" >&5
+echo "configure:2670: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -2600,13 +2681,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 2604 "configure"
+#line 2685 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2610: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2691: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -2617,13 +2698,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 2621 "configure"
+#line 2702 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2627: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2708: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -2634,13 +2715,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 2638 "configure"
+#line 2719 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2644: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2725: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -2666,17 +2747,17 @@ echo "$ac_t""$CPP" 1>&6
ac_safe=`echo "stdio.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for stdio.h""... $ac_c" 1>&6
-echo "configure:2670: checking for stdio.h" >&5
+echo "configure:2751: checking for stdio.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2675 "configure"
+#line 2756 "configure"
#include "confdefs.h"
#include <stdio.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2680: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2761: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -2704,12 +2785,12 @@ fi
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:2708: checking for ANSI C header files" >&5
+echo "configure:2789: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2713 "configure"
+#line 2794 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@@ -2717,7 +2798,7 @@ else
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2721: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2802: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -2734,7 +2815,7 @@ rm -f conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 2738 "configure"
+#line 2819 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@@ -2752,7 +2833,7 @@ fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 2756 "configure"
+#line 2837 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@@ -2773,7 +2854,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
-#line 2777 "configure"
+#line 2858 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -2784,7 +2865,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
-if { (eval echo configure:2788: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2869: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
@@ -2812,17 +2893,17 @@ for ac_hdr in sched.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2816: checking for $ac_hdr" >&5
+echo "configure:2897: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2821 "configure"
+#line 2902 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2826: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2907: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -2852,7 +2933,7 @@ done
# Determine CFLAGS for gthread.
echo $ac_n "checking for gthread cflags""... $ac_c" 1>&6
-echo "configure:2856: checking for gthread cflags" >&5
+echo "configure:2937: checking for gthread cflags" >&5
if eval "test \"`echo '$''{'objc_cv_gthread_flags'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -3275,6 +3356,7 @@ with_multisubdir=${with_multisubdir}
ac_configure_args="--enable-multilib ${ac_configure_args}"
toplevel_srcdir=${toplevel_srcdir}
CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
EOF
cat >> $CONFIG_STATUS <<\EOF
diff --git a/contrib/libobjc/configure.in b/contrib/libobjc/configure.in
index 51554522e96a..ac92c4234503 100644
--- a/contrib/libobjc/configure.in
+++ b/contrib/libobjc/configure.in
@@ -1,5 +1,6 @@
# Process this file with autoconf to produce a configure script.
-# Copyright (C) 1995, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+# Copyright (C) 1995, 1997, 1998, 1999, 2002, 2003
+# Free Software Foundation, Inc.
# Contributed by Dave Love (d.love@dl.ac.uk).
#
#This file is part of GNU Objective C.
@@ -143,6 +144,7 @@ with_multisubdir=${with_multisubdir}
ac_configure_args="--enable-multilib ${ac_configure_args}"
toplevel_srcdir=${toplevel_srcdir}
CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
)
diff --git a/contrib/libobjc/encoding.c b/contrib/libobjc/encoding.c
index 39277235b1f3..be4c08b423e2 100644
--- a/contrib/libobjc/encoding.c
+++ b/contrib/libobjc/encoding.c
@@ -1,5 +1,6 @@
/* Encoding of types for Objective C.
- Copyright (C) 1993, 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1995, 1996, 1997, 1998, 2000, 2002
+ Free Software Foundation, Inc.
Contributed by Kresten Krab Thorup
Bitfield support by Ovidiu Predescu
@@ -29,21 +30,22 @@ Boston, MA 02111-1307, USA. */
#include "tconfig.h"
#include "objc-api.h"
#include "encoding.h"
+#include <stdlib.h>
#undef MAX
#define MAX(X, Y) \
- ({ typeof(X) __x = (X), __y = (Y); \
+ ({ typeof (X) __x = (X), __y = (Y); \
(__x > __y ? __x : __y); })
#undef MIN
#define MIN(X, Y) \
- ({ typeof(X) __x = (X), __y = (Y); \
+ ({ typeof (X) __x = (X), __y = (Y); \
(__x < __y ? __x : __y); })
#undef ROUND
#define ROUND(V, A) \
- ({ typeof(V) __v=(V); typeof(A) __a=(A); \
- __a*((__v+__a-1)/__a); })
+ ({ typeof (V) __v = (V); typeof (A) __a = (A); \
+ __a * ((__v+__a - 1)/__a); })
/* Various hacks for objc_layout_record. These are used by the target
@@ -78,26 +80,16 @@ Boston, MA 02111-1307, USA. */
/* Some ROUND_TYPE_ALIGN macros use TARGET_foo, and consequently
target_flags. Define a dummy entry here to so we don't die. */
-
-static int target_flags = 0;
-
-static inline int
-atoi (const char* str)
-{
- int res = 0;
-
- while (isdigit (*str))
- res *= 10, res += (*str++ - '0');
-
- return res;
-}
+/* ??? FIXME: As of 2002-06-21, the attribute `unused' doesn't seem to
+ eliminate the warning. */
+static int __attribute__ ((__unused__)) target_flags = 0;
/*
- return the size of an object specified by type
+ return the size of an object specified by type
*/
int
-objc_sizeof_type (const char* type)
+objc_sizeof_type (const char *type)
{
/* Skip the variable name if any */
if (*type == '"')
@@ -106,83 +98,85 @@ objc_sizeof_type (const char* type)
/* do nothing */;
}
- switch(*type) {
+ switch (*type) {
case _C_ID:
- return sizeof(id);
+ return sizeof (id);
break;
case _C_CLASS:
- return sizeof(Class);
+ return sizeof (Class);
break;
case _C_SEL:
- return sizeof(SEL);
+ return sizeof (SEL);
break;
case _C_CHR:
- return sizeof(char);
+ return sizeof (char);
break;
-
+
case _C_UCHR:
- return sizeof(unsigned char);
+ return sizeof (unsigned char);
break;
case _C_SHT:
- return sizeof(short);
+ return sizeof (short);
break;
case _C_USHT:
- return sizeof(unsigned short);
+ return sizeof (unsigned short);
break;
case _C_INT:
- return sizeof(int);
+ return sizeof (int);
break;
case _C_UINT:
- return sizeof(unsigned int);
+ return sizeof (unsigned int);
break;
case _C_LNG:
- return sizeof(long);
+ return sizeof (long);
break;
case _C_ULNG:
- return sizeof(unsigned long);
+ return sizeof (unsigned long);
break;
case _C_LNG_LNG:
- return sizeof(long long);
+ return sizeof (long long);
break;
case _C_ULNG_LNG:
- return sizeof(unsigned long long);
+ return sizeof (unsigned long long);
break;
case _C_FLT:
- return sizeof(float);
+ return sizeof (float);
break;
case _C_DBL:
- return sizeof(double);
+ return sizeof (double);
break;
case _C_VOID:
- return sizeof(void);
+ return sizeof (void);
break;
+
case _C_PTR:
case _C_ATOM:
case _C_CHARPTR:
- return sizeof(char*);
+ return sizeof (char *);
break;
case _C_ARY_B:
{
- int len = atoi(type+1);
- while (isdigit(*++type));
- return len*objc_aligned_size (type);
+ int len = atoi (type + 1);
+ while (isdigit ((unsigned char)*++type))
+ ;
+ return len * objc_aligned_size (type);
}
- break;
+ break;
case _C_BFLD:
{
@@ -191,7 +185,8 @@ objc_sizeof_type (const char* type)
int startByte, endByte;
position = atoi (type + 1);
- while (isdigit (*++type));
+ while (isdigit ((unsigned char)*++type))
+ ;
size = atoi (type + 1);
startByte = position / BITS_PER_UNIT;
@@ -215,7 +210,8 @@ objc_sizeof_type (const char* type)
case _C_UNION_B:
{
int max_size = 0;
- while (*type != _C_UNION_E && *type++ != '=') /* do nothing */;
+ while (*type != _C_UNION_E && *type++ != '=')
+ /* do nothing */;
while (*type != _C_UNION_E)
{
/* Skip the variable name if any */
@@ -229,10 +225,10 @@ objc_sizeof_type (const char* type)
}
return max_size;
}
-
+
default:
{
- objc_error(nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type);
+ objc_error (nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type);
return 0;
}
}
@@ -240,11 +236,11 @@ objc_sizeof_type (const char* type)
/*
- Return the alignment of an object specified by type
+ Return the alignment of an object specified by type
*/
int
-objc_alignof_type(const char* type)
+objc_alignof_type (const char *type)
{
/* Skip the variable name if any */
if (*type == '"')
@@ -252,75 +248,76 @@ objc_alignof_type(const char* type)
for (type++; *type++ != '"';)
/* do nothing */;
}
- switch(*type) {
+ switch (*type) {
case _C_ID:
- return __alignof__(id);
+ return __alignof__ (id);
break;
case _C_CLASS:
- return __alignof__(Class);
+ return __alignof__ (Class);
break;
-
+
case _C_SEL:
- return __alignof__(SEL);
+ return __alignof__ (SEL);
break;
case _C_CHR:
- return __alignof__(char);
+ return __alignof__ (char);
break;
-
+
case _C_UCHR:
- return __alignof__(unsigned char);
+ return __alignof__ (unsigned char);
break;
case _C_SHT:
- return __alignof__(short);
+ return __alignof__ (short);
break;
case _C_USHT:
- return __alignof__(unsigned short);
+ return __alignof__ (unsigned short);
break;
case _C_INT:
- return __alignof__(int);
+ return __alignof__ (int);
break;
case _C_UINT:
- return __alignof__(unsigned int);
+ return __alignof__ (unsigned int);
break;
case _C_LNG:
- return __alignof__(long);
+ return __alignof__ (long);
break;
case _C_ULNG:
- return __alignof__(unsigned long);
+ return __alignof__ (unsigned long);
break;
case _C_LNG_LNG:
- return __alignof__(long long);
+ return __alignof__ (long long);
break;
case _C_ULNG_LNG:
- return __alignof__(unsigned long long);
+ return __alignof__ (unsigned long long);
break;
case _C_FLT:
- return __alignof__(float);
+ return __alignof__ (float);
break;
case _C_DBL:
- return __alignof__(double);
+ return __alignof__ (double);
break;
case _C_PTR:
case _C_ATOM:
case _C_CHARPTR:
- return __alignof__(char*);
+ return __alignof__ (char *);
break;
case _C_ARY_B:
- while (isdigit(*++type)) /* do nothing */;
+ while (isdigit ((unsigned char)*++type))
+ /* do nothing */;
return objc_alignof_type (type);
case _C_STRUCT_B:
@@ -339,7 +336,8 @@ objc_alignof_type(const char* type)
case _C_UNION_B:
{
int maxalign = 0;
- while (*type != _C_UNION_E && *type++ != '=') /* do nothing */;
+ while (*type != _C_UNION_E && *type++ != '=')
+ /* do nothing */;
while (*type != _C_UNION_E)
{
/* Skip the variable name if any */
@@ -356,7 +354,7 @@ objc_alignof_type(const char* type)
default:
{
- objc_error(nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type);
+ objc_error (nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type);
return 0;
}
}
@@ -367,7 +365,7 @@ objc_alignof_type(const char* type)
*/
int
-objc_aligned_size (const char* type)
+objc_aligned_size (const char *type)
{
int size, align;
@@ -386,11 +384,11 @@ objc_aligned_size (const char* type)
/*
The size rounded up to the nearest integral of the wordsize, taken
- to be the size of a void*.
+ to be the size of a void *.
*/
-int
-objc_promoted_size (const char* type)
+int
+objc_promoted_size (const char *type)
{
int size, wordsize;
@@ -402,7 +400,7 @@ objc_promoted_size (const char* type)
}
size = objc_sizeof_type (type);
- wordsize = sizeof (void*);
+ wordsize = sizeof (void *);
return ROUND (size, wordsize);
}
@@ -412,13 +410,13 @@ objc_promoted_size (const char* type)
occurring in method prototype encodings.
*/
-inline const char*
-objc_skip_type_qualifiers (const char* type)
+inline const char *
+objc_skip_type_qualifiers (const char *type)
{
while (*type == _C_CONST
- || *type == _C_IN
+ || *type == _C_IN
|| *type == _C_INOUT
- || *type == _C_OUT
+ || *type == _C_OUT
|| *type == _C_BYCOPY
|| *type == _C_BYREF
|| *type == _C_ONEWAY
@@ -429,14 +427,14 @@ objc_skip_type_qualifiers (const char* type)
return type;
}
-
+
/*
Skip one typespec element. If the typespec is prepended by type
qualifiers, these are skipped as well.
*/
-const char*
-objc_skip_typespec (const char* type)
+const char *
+objc_skip_typespec (const char *type)
{
/* Skip the variable name if any */
if (*type == '"')
@@ -446,7 +444,7 @@ objc_skip_typespec (const char* type)
}
type = objc_skip_type_qualifiers (type);
-
+
switch (*type) {
case _C_ID:
@@ -457,7 +455,8 @@ objc_skip_typespec (const char* type)
return type;
else
{
- while (*++type != '"') /* do nothing */;
+ while (*++type != '"')
+ /* do nothing */;
return type + 1;
}
@@ -485,45 +484,56 @@ objc_skip_typespec (const char* type)
case _C_ARY_B:
/* skip digits, typespec and closing ']' */
-
- while(isdigit(*++type));
- type = objc_skip_typespec(type);
+
+ while (isdigit ((unsigned char)*++type))
+ ;
+ type = objc_skip_typespec (type);
if (*type == _C_ARY_E)
return ++type;
else
{
- objc_error(nil, OBJC_ERR_BAD_TYPE, "bad array type %s\n", type);
+ objc_error (nil, OBJC_ERR_BAD_TYPE, "bad array type %s\n", type);
return 0;
}
case _C_BFLD:
/* The new encoding of bitfields is: b 'position' 'type' 'size' */
- while (isdigit (*++type)); /* skip position */
- while (isdigit (*++type)); /* skip type and size */
+ while (isdigit ((unsigned char)*++type))
+ ; /* skip position */
+ while (isdigit ((unsigned char)*++type))
+ ; /* skip type and size */
return type;
case _C_STRUCT_B:
/* skip name, and elements until closing '}' */
-
- while (*type != _C_STRUCT_E && *type++ != '=');
- while (*type != _C_STRUCT_E) { type = objc_skip_typespec (type); }
+
+ while (*type != _C_STRUCT_E && *type++ != '=')
+ ;
+ while (*type != _C_STRUCT_E)
+ {
+ type = objc_skip_typespec (type);
+ }
return ++type;
case _C_UNION_B:
/* skip name, and elements until closing ')' */
-
- while (*type != _C_UNION_E && *type++ != '=');
- while (*type != _C_UNION_E) { type = objc_skip_typespec (type); }
+
+ while (*type != _C_UNION_E && *type++ != '=')
+ ;
+ while (*type != _C_UNION_E)
+ {
+ type = objc_skip_typespec (type);
+ }
return ++type;
case _C_PTR:
/* Just skip the following typespec */
-
+
return objc_skip_typespec (++type);
-
+
default:
{
- objc_error(nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type);
+ objc_error (nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type);
return 0;
}
}
@@ -533,19 +543,21 @@ objc_skip_typespec (const char* type)
Skip an offset as part of a method encoding. This is prepended by a
'+' if the argument is passed in registers.
*/
-inline const char*
-objc_skip_offset (const char* type)
+inline const char *
+objc_skip_offset (const char *type)
{
- if (*type == '+') type++;
- while(isdigit(*++type));
+ if (*type == '+')
+ type++;
+ while (isdigit ((unsigned char) *++type))
+ ;
return type;
}
/*
Skip an argument specification of a method encoding.
*/
-const char*
-objc_skip_argspec (const char* type)
+const char *
+objc_skip_argspec (const char *type)
{
type = objc_skip_typespec (type);
type = objc_skip_offset (type);
@@ -555,13 +567,13 @@ objc_skip_argspec (const char* type)
/*
Return the number of arguments that the method MTH expects.
Note that all methods need two implicit arguments `self' and
- `_cmd'.
+ `_cmd'.
*/
int
-method_get_number_of_arguments (struct objc_method* mth)
+method_get_number_of_arguments (struct objc_method *mth)
{
int i = 0;
- const char* type = mth->method_types;
+ const char *type = mth->method_types;
while (*type)
{
type = objc_skip_argspec (type);
@@ -577,9 +589,9 @@ method_get_number_of_arguments (struct objc_method* mth)
*/
int
-method_get_sizeof_arguments (struct objc_method* mth)
+method_get_sizeof_arguments (struct objc_method *mth)
{
- const char* type = objc_skip_typespec (mth->method_types);
+ const char *type = objc_skip_typespec (mth->method_types);
return atoi (type);
}
@@ -588,7 +600,7 @@ method_get_sizeof_arguments (struct objc_method* mth)
the last argument. Typical use of this look like:
{
- char *datum, *type;
+ char *datum, *type;
for (datum = method_get_first_argument (method, argframe, &type);
datum; datum = method_get_next_argument (argframe, &type))
{
@@ -599,15 +611,14 @@ method_get_sizeof_arguments (struct objc_method* mth)
else
{
if ((flags & _F_IN) == _F_IN)
- [portal encodeData: *(char**)datum ofType: ++type];
+ [portal encodeData: *(char **) datum ofType: ++type];
}
}
}
-*/
+*/
-char*
-method_get_next_argument (arglist_t argframe,
- const char **type)
+char *
+method_get_next_argument (arglist_t argframe, const char **type)
{
const char *t = objc_skip_argspec (*type);
@@ -624,15 +635,15 @@ method_get_next_argument (arglist_t argframe,
}
/*
- Return a pointer to the value of the first argument of the method
+ Return a pointer to the value of the first argument of the method
described in M with the given argumentframe ARGFRAME. The type
- is returned in TYPE. type must be passed to successive calls of
+ is returned in TYPE. type must be passed to successive calls of
method_get_next_argument.
*/
-char*
-method_get_first_argument (struct objc_method* m,
- arglist_t argframe,
- const char** type)
+char *
+method_get_first_argument (struct objc_method *m,
+ arglist_t argframe,
+ const char **type)
{
*type = m->method_types;
return method_get_next_argument (argframe, type);
@@ -641,22 +652,22 @@ method_get_first_argument (struct objc_method* m,
/*
Return a pointer to the ARGth argument of the method
M from the frame ARGFRAME. The type of the argument
- is returned in the value-result argument TYPE
+ is returned in the value-result argument TYPE
*/
-char*
-method_get_nth_argument (struct objc_method* m,
- arglist_t argframe, int arg,
+char *
+method_get_nth_argument (struct objc_method *m,
+ arglist_t argframe, int arg,
const char **type)
{
- const char* t = objc_skip_argspec (m->method_types);
+ const char *t = objc_skip_argspec (m->method_types);
if (arg > method_get_number_of_arguments (m))
return 0;
while (arg--)
t = objc_skip_argspec (t);
-
+
*type = t;
t = objc_skip_typespec (t);
@@ -667,7 +678,7 @@ method_get_nth_argument (struct objc_method* m,
}
unsigned
-objc_get_type_qualifiers (const char* type)
+objc_get_type_qualifiers (const char *type)
{
unsigned res = 0;
BOOL flag = YES;
@@ -720,7 +731,7 @@ objc_layout_structure (const char *type,
if (*type++ != _C_STRUCT_B)
{
- objc_error(nil, OBJC_ERR_BAD_TYPE,
+ objc_error (nil, OBJC_ERR_BAD_TYPE,
"record type expected in objc_layout_structure, got %s\n",
type);
}
@@ -749,12 +760,11 @@ objc_layout_structure (const char *type,
BOOL
objc_layout_structure_next_member (struct objc_struct_layout *layout)
{
- register int known_align = layout->record_size;
register int desired_align = 0;
/* The following are used only if the field is a bitfield */
- register const char *bfld_type;
- register int bfld_type_size, bfld_type_align, bfld_field_size;
+ register const char *bfld_type = 0;
+ register int bfld_type_size, bfld_type_align = 0, bfld_field_size = 0;
/* The current type without the type qualifiers */
const char *type;
@@ -769,7 +779,7 @@ objc_layout_structure_next_member (struct objc_struct_layout *layout)
else {
/* Get the bitfield's type */
for (bfld_type = type + 1;
- isdigit(*bfld_type);
+ isdigit ((unsigned char)*bfld_type);
bfld_type++)
/* do nothing */;
@@ -793,12 +803,14 @@ objc_layout_structure_next_member (struct objc_struct_layout *layout)
type = objc_skip_type_qualifiers (layout->type);
if (*type != _C_BFLD)
- desired_align = objc_alignof_type(type) * BITS_PER_UNIT;
+ desired_align = objc_alignof_type (type) * BITS_PER_UNIT;
else
{
desired_align = 1;
/* Skip the bitfield's offset */
- for (bfld_type = type + 1; isdigit(*bfld_type); bfld_type++)
+ for (bfld_type = type + 1;
+ isdigit ((unsigned char) *bfld_type);
+ bfld_type++)
/* do nothing */;
bfld_type_size = objc_sizeof_type (bfld_type) * BITS_PER_UNIT;
@@ -818,7 +830,7 @@ objc_layout_structure_next_member (struct objc_struct_layout *layout)
is meaningless. */
#ifndef PCC_BITFIELD_TYPE_MATTERS
layout->record_align = MAX (layout->record_align, desired_align);
-#else
+#else /* PCC_BITFIELD_TYPE_MATTERS */
if (*type == _C_BFLD)
{
/* For these machines, a zero-length field does not
@@ -850,7 +862,7 @@ objc_layout_structure_next_member (struct objc_struct_layout *layout)
}
else
layout->record_align = MAX (layout->record_align, desired_align);
-#endif
+#endif /* PCC_BITFIELD_TYPE_MATTERS */
/* Does this field automatically have alignment it needs
by virtue of the fields that precede it and the record's
@@ -864,7 +876,7 @@ objc_layout_structure_next_member (struct objc_struct_layout *layout)
Bump the cumulative size to multiple of field alignment. */
layout->record_size = ROUND (layout->record_size, desired_align);
}
-
+
/* Jump to the next field in record. */
layout->prev_type = layout->type;
@@ -884,7 +896,7 @@ void objc_layout_finish_structure (struct objc_struct_layout *layout,
in the record type. Round it up to a multiple of the record's
alignment. */
-#if defined(ROUND_TYPE_ALIGN) && !defined(__sparc__)
+#if defined (ROUND_TYPE_ALIGN) && ! defined (__sparc__)
layout->record_align = ROUND_TYPE_ALIGN (layout->original_type,
1,
layout->record_align);
diff --git a/contrib/libobjc/gc.c b/contrib/libobjc/gc.c
index d92c0c3fdc66..1010508f64cf 100644
--- a/contrib/libobjc/gc.c
+++ b/contrib/libobjc/gc.c
@@ -1,5 +1,5 @@
/* Basic data types for Objective C.
- Copyright (C) 1998 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2002 Free Software Foundation, Inc.
Contributed by Ovidiu Predescu.
This file is part of GNU CC.
@@ -58,11 +58,11 @@ typedef GC_signed_word signed_word;
The offset is incremented with the size of the type. */
#define ROUND(V, A) \
- ({ typeof(V) __v=(V); typeof(A) __a=(A); \
- __a*((__v+__a-1)/__a); })
+ ({ typeof (V) __v = (V); typeof (A) __a = (A); \
+ __a * ((__v+__a - 1)/__a); })
#define SET_BIT_FOR_OFFSET(mask, offset) \
- GC_set_bit(mask, offset / sizeof (void*))
+ GC_set_bit (mask, offset / sizeof (void *))
/* Some prototypes */
static void
@@ -74,9 +74,9 @@ __objc_gc_setup_union (GC_bitmap mask, const char *type, int offset);
static void
__objc_gc_setup_array (GC_bitmap mask, const char *type, int offset)
{
- int i, len = atoi(type + 1);
+ int i, len = atoi (type + 1);
- while (isdigit(*++type))
+ while (isdigit (*++type))
/* do nothing */; /* skip the size of the array */
switch (*type) {
@@ -138,8 +138,8 @@ __objc_gc_setup_struct (GC_bitmap mask, const char *type, int offset)
case _C_PTR:
case _C_CHARPTR:
case _C_ATOM:
- if (!gc_invisible)
- SET_BIT_FOR_OFFSET(mask, position);
+ if (! gc_invisible)
+ SET_BIT_FOR_OFFSET (mask, position);
break;
case _C_ARY_B:
@@ -178,11 +178,11 @@ __objc_gc_setup_union (GC_bitmap mask, const char *type, int offset)
size = objc_sizeof_type (type);
align = objc_alignof_type (type);
- offset = ROUND(offset, align);
- for (i = 0; i < size; i += sizeof (void*))
+ offset = ROUND (offset, align);
+ for (i = 0; i < size; i += sizeof (void *))
{
- SET_BIT_FOR_OFFSET(mask, offset);
- offset += sizeof (void*);
+ SET_BIT_FOR_OFFSET (mask, offset);
+ offset += sizeof (void *);
}
}
@@ -223,8 +223,8 @@ __objc_gc_type_description_from_type (GC_bitmap mask, const char *type)
case _C_SEL:
case _C_PTR:
case _C_CHARPTR:
- if (!gc_invisible)
- SET_BIT_FOR_OFFSET(mask, offset);
+ if (! gc_invisible)
+ SET_BIT_FOR_OFFSET (mask, offset);
break;
case _C_ARY_B:
@@ -254,9 +254,9 @@ __objc_class_structure_encoding (Class class, char **type, int *size,
int *current)
{
int i, ivar_count;
- struct objc_ivar_list* ivars;
+ struct objc_ivar_list *ivars;
- if (!class)
+ if (! class)
{
strcat (*type, "{");
*current++;
@@ -267,7 +267,7 @@ __objc_class_structure_encoding (Class class, char **type, int *size,
__objc_class_structure_encoding (class->super_class, type, size, current);
ivars = class->ivars;
- if (!ivars)
+ if (! ivars)
return;
ivar_count = ivars->ivar_count;
@@ -282,7 +282,7 @@ __objc_class_structure_encoding (Class class, char **type, int *size,
{
/* Increase the size of the encoding string so that it
contains this ivar's type. */
- *size = ROUND(*current + len + 1, 10);
+ *size = ROUND (*current + len + 1, 10);
*type = objc_realloc (*type, *size);
}
strcat (*type + *current, ivar_type);
@@ -302,7 +302,7 @@ __objc_generate_gc_type_description (Class class)
int type_size = 10, current;
char *class_structure_type;
- if (!CLS_ISCLASS(class))
+ if (! CLS_ISCLASS (class))
return;
/* We have to create a mask in which each bit counts for a pointer member.
@@ -311,9 +311,9 @@ __objc_generate_gc_type_description (Class class)
/* The number of bits in the mask is the size of an instance in bytes divided
by the size of a pointer. */
- bits_no = (ROUND(class_get_instance_size (class), sizeof(void*))
- / sizeof (void*));
- size = ROUND(bits_no, BITS_PER_WORD) / BITS_PER_WORD;
+ bits_no = (ROUND (class_get_instance_size (class), sizeof (void *))
+ / sizeof (void *));
+ size = ROUND (bits_no, BITS_PER_WORD) / BITS_PER_WORD;
mask = objc_atomic_malloc (size * sizeof (int));
memset (mask, 0, size * sizeof (int));
@@ -342,7 +342,7 @@ __objc_generate_gc_type_description (Class class)
puts ("");
#endif
- class->gc_object_type = (void*)GC_make_descriptor (mask, bits_no);
+ class->gc_object_type = (void *) GC_make_descriptor (mask, bits_no);
}
@@ -370,17 +370,17 @@ __objc_ivar_pointer (const char *type)
This operation only makes sense on instance variables that are
pointers. */
void
-class_ivar_set_gcinvisible (Class class, const char* ivarname,
+class_ivar_set_gcinvisible (Class class, const char *ivarname,
BOOL gc_invisible)
{
int i, ivar_count;
- struct objc_ivar_list* ivars;
+ struct objc_ivar_list *ivars;
- if (!class || !ivarname)
+ if (! class || ! ivarname)
return;
ivars = class->ivars;
- if (!ivars)
+ if (! ivars)
return;
ivar_count = ivars->ivar_count;
@@ -390,7 +390,7 @@ class_ivar_set_gcinvisible (Class class, const char* ivarname,
struct objc_ivar *ivar = &(ivars->ivar_list[i]);
const char *type;
- if (!ivar->ivar_name || strcmp (ivar->ivar_name, ivarname))
+ if (! ivar->ivar_name || strcmp (ivar->ivar_name, ivarname))
continue;
assert (ivar->ivar_type);
@@ -407,7 +407,7 @@ class_ivar_set_gcinvisible (Class class, const char* ivarname,
{
char *new_type;
- if (gc_invisible || !__objc_ivar_pointer (type))
+ if (gc_invisible || ! __objc_ivar_pointer (type))
return; /* The type of the variable already matches the
requested gc_invisible type */
@@ -422,7 +422,7 @@ class_ivar_set_gcinvisible (Class class, const char* ivarname,
{
char *new_type;
- if (!gc_invisible || !__objc_ivar_pointer (type))
+ if (! gc_invisible || ! __objc_ivar_pointer (type))
return; /* The type of the variable already matches the
requested gc_invisible type */
@@ -446,13 +446,13 @@ class_ivar_set_gcinvisible (Class class, const char* ivarname,
#else /* !OBJC_WITH_GC */
void
-__objc_generate_gc_type_description (Class class)
+__objc_generate_gc_type_description (Class class __attribute__ ((__unused__)))
{
}
-void class_ivar_set_gcinvisible (Class class,
- const char* ivarname,
- BOOL gc_invisible)
+void class_ivar_set_gcinvisible (Class class __attribute__ ((__unused__)),
+ const char *ivarname __attribute__ ((__unused__)),
+ BOOL gc_invisible __attribute__ ((__unused__)))
{
}
diff --git a/contrib/libobjc/hash.c b/contrib/libobjc/hash.c
index 223991f97f3e..2f58b2c54729 100644
--- a/contrib/libobjc/hash.c
+++ b/contrib/libobjc/hash.c
@@ -47,7 +47,7 @@ hash_new (unsigned int size, hash_func_type hash_func,
/* Pass me a value greater than 0 and a power of 2. */
assert (size);
- assert (!(size & (size - 1)));
+ assert (! (size & (size - 1)));
/* Allocate the cache structure. calloc insures
its initialization for default values. */
@@ -196,7 +196,7 @@ hash_remove (cache_ptr cache, const void *key)
objc_free(node);
} else
prev = node, node = node->next;
- } while (!removed && node);
+ } while (! removed && node);
assert (removed);
}
@@ -210,7 +210,7 @@ hash_next (cache_ptr cache, node_ptr node)
{
/* If the scan is being started then reset the last node
visitied pointer and bucket index. */
- if (!node)
+ if (! node)
cache->last_bucket = 0;
/* If there is a node visited last then check for another
@@ -258,7 +258,7 @@ hash_value_for_key (cache_ptr cache, const void *key)
break;
} else
node = node->next;
- } while (!retval && node);
+ } while (! retval && node);
return retval;
}
diff --git a/contrib/libobjc/init.c b/contrib/libobjc/init.c
index 552a74bb5499..098e253649ff 100644
--- a/contrib/libobjc/init.c
+++ b/contrib/libobjc/init.c
@@ -1,5 +1,5 @@
/* GNU Objective C Runtime initialization
- Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
Contributed by Kresten Krab Thorup
+load support contributed by Ovidiu Predescu <ovidiu@net-community.com>
@@ -27,62 +27,62 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "runtime.h"
/* The version number of this runtime. This must match the number
- defined in gcc (objc-act.c) */
+ defined in gcc (objc-act.c). */
#define OBJC_VERSION 8
#define PROTOCOL_VERSION 2
-/* This list contains all modules currently loaded into the runtime */
-static struct objc_list* __objc_module_list = 0; /* !T:MUTEX */
+/* This list contains all modules currently loaded into the runtime. */
+static struct objc_list *__objc_module_list = 0; /* !T:MUTEX */
-/* This list contains all proto_list's not yet assigned class links */
-static struct objc_list* unclaimed_proto_list = 0; /* !T:MUTEX */
+/* This list contains all proto_list's not yet assigned class links. */
+static struct objc_list *unclaimed_proto_list = 0; /* !T:MUTEX */
/* List of unresolved static instances. */
static struct objc_list *uninitialized_statics = 0; /* !T:MUTEX */
-/* Global runtime "write" mutex. */
+/* Global runtime "write" mutex. */
objc_mutex_t __objc_runtime_mutex = 0;
-/* Number of threads that are alive. */
+/* Number of threads that are alive. */
int __objc_runtime_threads_alive = 1; /* !T:MUTEX */
-/* Check compiler vs runtime version */
+/* Check compiler vs runtime version. */
static void init_check_module_version (Module_t);
-/* Assign isa links to protos */
-static void __objc_init_protocols (struct objc_protocol_list* protos);
+/* Assign isa links to protos. */
+static void __objc_init_protocols (struct objc_protocol_list *protos);
-/* Add protocol to class */
-static void __objc_class_add_protocols (Class, struct objc_protocol_list*);
+/* Add protocol to class. */
+static void __objc_class_add_protocols (Class, struct objc_protocol_list *);
-/* This is a hook which is called by __objc_exec_class every time a class
- or a category is loaded into the runtime. This may e.g. help a
- dynamic loader determine the classes that have been loaded when
- an object file is dynamically linked in */
-void (*_objc_load_callback)(Class class, Category* category); /* !T:SAFE */
+/* This is a hook which is called by __objc_exec_class every time a
+ class or a category is loaded into the runtime. This may e.g. help
+ a dynamic loader determine the classes that have been loaded when
+ an object file is dynamically linked in. */
+void (*_objc_load_callback) (Class class, Category *category); /* !T:SAFE */
-/* Is all categories/classes resolved? */
+/* Is all categories/classes resolved? */
BOOL __objc_dangling_categories = NO; /* !T:UNUSED */
extern SEL
__sel_register_typed_name (const char *name, const char *types,
struct objc_selector *orig, BOOL is_const);
-/* Sends +load to all classes and categories in certain situations. */
+/* Sends +load to all classes and categories in certain situations. */
static void objc_send_load (void);
/* Inserts all the classes defined in module in a tree of classes that
- resembles the class hierarchy. This tree is traversed in preorder and the
- classes in its nodes receive the +load message if these methods were not
- executed before. The algorithm ensures that when the +load method of a class
- is executed all the superclasses have been already received the +load
- message. */
+ resembles the class hierarchy. This tree is traversed in preorder
+ and the classes in its nodes receive the +load message if these
+ methods were not executed before. The algorithm ensures that when
+ the +load method of a class is executed all the superclasses have
+ been already received the +load message. */
static void __objc_create_classes_tree (Module_t module);
static void __objc_call_callback (Module_t module);
/* A special version that works only before the classes are completely
- installed in the runtime. */
+ installed in the runtime. */
static BOOL class_is_subclass_of_class (Class class, Class superclass);
typedef struct objc_class_tree {
@@ -90,24 +90,26 @@ typedef struct objc_class_tree {
struct objc_list *subclasses; /* `head' is pointer to an objc_class_tree */
} objc_class_tree;
-/* This is a linked list of objc_class_tree trees. The head of these trees
- are root classes (their super class is Nil). These different trees
- represent different class hierarchies. */
+/* This is a linked list of objc_class_tree trees. The head of these
+ trees are root classes (their super class is Nil). These different
+ trees represent different class hierarchies. */
static struct objc_list *__objc_class_tree_list = NULL;
-/* Keeps the +load methods who have been already executed. This hash should
- not be destroyed during the execution of the program. */
+/* Keeps the +load methods who have been already executed. This hash
+ should not be destroyed during the execution of the program. */
static cache_ptr __objc_load_methods = NULL;
-/* Creates a tree of classes whose topmost class is directly inherited from
- `upper' and the bottom class in this tree is `bottom_class'. The classes
- in this tree are super classes of `bottom_class'. `subclasses' member
- of each tree node point to the next subclass tree node. */
+/* Creates a tree of classes whose topmost class is directly inherited
+ from `upper' and the bottom class in this tree is
+ `bottom_class'. The classes in this tree are super classes of
+ `bottom_class'. `subclasses' member of each tree node point to the
+ next subclass tree node. */
+
static objc_class_tree *
create_tree_of_subclasses_inherited_from (Class bottom_class, Class upper)
{
Class superclass = bottom_class->super_class ?
- objc_lookup_class ((char*)bottom_class->super_class)
+ objc_lookup_class ((char *) bottom_class->super_class)
: Nil;
objc_class_tree *tree, *prev;
@@ -126,7 +128,7 @@ create_tree_of_subclasses_inherited_from (Class bottom_class, Class upper)
tree->class = superclass;
tree->subclasses = list_cons (prev, tree->subclasses);
superclass = (superclass->super_class ?
- objc_lookup_class ((char*)superclass->super_class)
+ objc_lookup_class ((char *) superclass->super_class)
: Nil);
prev = tree;
}
@@ -134,11 +136,13 @@ create_tree_of_subclasses_inherited_from (Class bottom_class, Class upper)
return tree;
}
-/* Insert the `class' into the proper place in the `tree' class hierarchy. This
- function returns a new tree if the class has been successfully inserted into
- the tree or NULL if the class is not part of the classes hierarchy described
- by `tree'. This function is private to objc_tree_insert_class(), you should
- not call it directly. */
+/* Insert the `class' into the proper place in the `tree' class
+ hierarchy. This function returns a new tree if the class has been
+ successfully inserted into the tree or NULL if the class is not
+ part of the classes hierarchy described by `tree'. This function is
+ private to objc_tree_insert_class (), you should not call it
+ directly. */
+
static objc_class_tree *
__objc_tree_insert_class (objc_class_tree *tree, Class class)
{
@@ -154,21 +158,21 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class)
return tree;
}
else if ((class->super_class ?
- objc_lookup_class ((char*)class->super_class)
+ objc_lookup_class ((char *) class->super_class)
: Nil)
== tree->class)
{
/* If class is a direct subclass of tree->class then add class to the
list of subclasses. First check to see if it wasn't already
- inserted. */
+ inserted. */
struct objc_list *list = tree->subclasses;
objc_class_tree *node;
while (list)
{
/* Class has been already inserted; do nothing just return
- the tree. */
- if (((objc_class_tree*)list->head)->class == class)
+ the tree. */
+ if (((objc_class_tree *) list->head)->class == class)
{
DEBUG_PRINTF ("2. class %s was previously inserted\n",
class->name);
@@ -186,24 +190,25 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class)
}
else
{
- /* The class is not a direct subclass of tree->class. Search for class's
- superclasses in the list of subclasses. */
+ /* The class is not a direct subclass of tree->class. Search for
+ class's superclasses in the list of subclasses. */
struct objc_list *subclasses = tree->subclasses;
- /* Precondition: the class must be a subclass of tree->class; otherwise
- return NULL to indicate our caller that it must take the next tree. */
- if (!class_is_subclass_of_class (class, tree->class))
+ /* Precondition: the class must be a subclass of tree->class;
+ otherwise return NULL to indicate our caller that it must
+ take the next tree. */
+ if (! class_is_subclass_of_class (class, tree->class))
return NULL;
for (; subclasses != NULL; subclasses = subclasses->tail)
{
- Class aClass = ((objc_class_tree*)(subclasses->head))->class;
+ Class aClass = ((objc_class_tree *) (subclasses->head))->class;
if (class_is_subclass_of_class (class, aClass))
{
- /* If we found one of class's superclasses we insert the class
- into its subtree and return the original tree since nothing
- has been changed. */
+ /* If we found one of class's superclasses we insert the
+ class into its subtree and return the original tree
+ since nothing has been changed. */
subclasses->head
= __objc_tree_insert_class (subclasses->head, class);
DEBUG_PRINTF ("4. class %s inserted\n", class->name);
@@ -211,12 +216,12 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class)
}
}
- /* We haven't found a subclass of `class' in the `subclasses' list.
- Create a new tree of classes whose topmost class is a direct subclass
- of tree->class. */
+ /* We haven't found a subclass of `class' in the `subclasses'
+ list. Create a new tree of classes whose topmost class is a
+ direct subclass of tree->class. */
{
objc_class_tree *new_tree
- = create_tree_of_subclasses_inherited_from (class, tree->class);
+ = create_tree_of_subclasses_inherited_from (class, tree->class);
tree->subclasses = list_cons (new_tree, tree->subclasses);
DEBUG_PRINTF ("5. class %s inserted\n", class->name);
return tree;
@@ -224,7 +229,8 @@ __objc_tree_insert_class (objc_class_tree *tree, Class class)
}
}
-/* This function inserts `class' in the right tree hierarchy classes. */
+/* This function inserts `class' in the right tree hierarchy classes. */
+
static void
objc_tree_insert_class (Class class)
{
@@ -244,20 +250,21 @@ objc_tree_insert_class (Class class)
list_node = list_node->tail;
}
- /* If the list was finished but the class hasn't been inserted, insert it
- here. */
- if (!list_node)
+ /* If the list was finished but the class hasn't been inserted,
+ insert it here. */
+ if (! list_node)
{
__objc_class_tree_list = list_cons (NULL, __objc_class_tree_list);
__objc_class_tree_list->head = __objc_tree_insert_class (NULL, class);
}
}
-/* Traverse tree in preorder. Used to send +load. */
+/* Traverse tree in preorder. Used to send +load. */
+
static void
objc_preorder_traverse (objc_class_tree *tree,
int level,
- void (*function)(objc_class_tree*, int))
+ void (*function) (objc_class_tree *, int))
{
struct objc_list *node;
@@ -266,11 +273,12 @@ objc_preorder_traverse (objc_class_tree *tree,
objc_preorder_traverse (node->head, level + 1, function);
}
-/* Traverse tree in postorder. Used to destroy a tree. */
+/* Traverse tree in postorder. Used to destroy a tree. */
+
static void
objc_postorder_traverse (objc_class_tree *tree,
- int level,
- void (*function)(objc_class_tree*, int))
+ int level,
+ void (*function) (objc_class_tree *, int))
{
struct objc_list *node;
@@ -279,7 +287,8 @@ objc_postorder_traverse (objc_class_tree *tree,
(*function) (tree, level);
}
-/* Used to print a tree class hierarchy. */
+/* Used to print a tree class hierarchy. */
+
#ifdef DEBUG
static void
__objc_tree_print (objc_class_tree *tree, int level)
@@ -292,35 +301,37 @@ __objc_tree_print (objc_class_tree *tree, int level)
}
#endif
-/* Walks on a linked list of methods in the reverse order and executes all
- the methods corresponding to `op' selector. Walking in the reverse order
- assures the +load of class is executed first and then +load of categories
- because of the way in which categories are added to the class methods. */
+/* Walks on a linked list of methods in the reverse order and executes
+ all the methods corresponding to `op' selector. Walking in the
+ reverse order assures the +load of class is executed first and then
+ +load of categories because of the way in which categories are
+ added to the class methods. */
+
static void
__objc_send_message_in_list (MethodList_t method_list, Class class, SEL op)
{
int i;
- if (!method_list)
+ if (! method_list)
return;
/* First execute the `op' message in the following method lists */
__objc_send_message_in_list (method_list->method_next, class, op);
- /* Search the method list. */
+ /* Search the method list. */
for (i = 0; i < method_list->method_count; i++)
{
Method_t mth = &method_list->method_list[i];
if (mth->method_name && sel_eq (mth->method_name, op)
- && !hash_is_key_in_hash (__objc_load_methods, mth->method_imp))
+ && ! hash_is_key_in_hash (__objc_load_methods, mth->method_imp))
{
/* Add this method into the +load hash table */
hash_add (&__objc_load_methods, mth->method_imp, mth->method_imp);
DEBUG_PRINTF ("sending +load in class: %s\n", class->name);
- /* The method was found and wasn't previously executed. */
+ /* The method was found and wasn't previously executed. */
(*mth->method_imp) ((id)class, mth->method_name);
break;
@@ -329,26 +340,29 @@ __objc_send_message_in_list (MethodList_t method_list, Class class, SEL op)
}
static void
-__objc_send_load (objc_class_tree *tree, int level)
+__objc_send_load (objc_class_tree *tree,
+ int level __attribute__ ((__unused__)))
{
static SEL load_sel = 0;
Class class = tree->class;
MethodList_t method_list = class->class_pointer->methods;
- if (!load_sel)
+ if (! load_sel)
load_sel = sel_register_name ("load");
__objc_send_message_in_list (method_list, class, load_sel);
}
static void
-__objc_destroy_class_tree_node (objc_class_tree *tree, int level)
+__objc_destroy_class_tree_node (objc_class_tree *tree,
+ int level __attribute__ ((__unused__)))
{
objc_free (tree);
}
-/* This is used to check if the relationship between two classes before the
- runtime completely installs the classes. */
+/* This is used to check if the relationship between two classes
+ before the runtime completely installs the classes. */
+
static BOOL
class_is_subclass_of_class (Class class, Class superclass)
{
@@ -357,19 +371,19 @@ class_is_subclass_of_class (Class class, Class superclass)
if (class == superclass)
return YES;
class = (class->super_class ?
- objc_lookup_class ((char*)class->super_class)
+ objc_lookup_class ((char *) class->super_class)
: Nil);
}
return NO;
}
-/* This list contains all the classes in the runtime system for whom their
- superclasses are not yet know to the runtime. */
-static struct objc_list* unresolved_classes = 0;
+/* This list contains all the classes in the runtime system for whom
+ their superclasses are not yet known to the runtime. */
+static struct objc_list *unresolved_classes = 0;
-/* Extern function used to reference the Object and NXConstantString classes.
- */
+/* Extern function used to reference the Object and NXConstantString
+ classes. */
extern void __objc_force_linking (void);
@@ -380,15 +394,16 @@ __objc_force_linking (void)
__objc_linking ();
}
-/* Run through the statics list, removing modules as soon as all its statics
- have been initialized. */
+/* Run through the statics list, removing modules as soon as all its
+ statics have been initialized. */
+
static void
objc_init_statics (void)
{
struct objc_list **cell = &uninitialized_statics;
struct objc_static_instances **statics_in_module;
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
while (*cell)
{
@@ -400,7 +415,7 @@ objc_init_statics (void)
struct objc_static_instances *statics = *statics_in_module;
Class class = objc_lookup_class (statics->class_name);
- if (!class)
+ if (! class)
module_initialized = 0;
/* Actually, the static's class_pointer will be NULL when we
haven't been here before. However, the comparison is to be
@@ -430,19 +445,19 @@ objc_init_statics (void)
/* Remove this module from the uninitialized list. */
struct objc_list *this = *cell;
*cell = this->tail;
- objc_free(this);
+ objc_free (this);
}
else
cell = &(*cell)->tail;
}
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
} /* objc_init_statics */
/* This function is called by constructor functions generated for each
- module compiled. (_GLOBAL_$I$...) The purpose of this function is to
- gather the module pointers so that they may be processed by the
- initialization routines as soon as possible */
+ module compiled. (_GLOBAL_$I$...) The purpose of this function is
+ to gather the module pointers so that they may be processed by the
+ initialization routines as soon as possible. */
void
__objc_exec_class (Module_t module)
@@ -451,7 +466,7 @@ __objc_exec_class (Module_t module)
indicate that some global data structures need to be built. */
static BOOL previous_constructors = 0;
- static struct objc_list* unclaimed_categories = 0;
+ static struct objc_list *unclaimed_categories = 0;
/* The symbol table (defined in objc-api.h) generated by gcc */
Symtab_t symtab = module->symtab;
@@ -461,7 +476,7 @@ __objc_exec_class (Module_t module)
= symtab->defs[symtab->cls_def_cnt + symtab->cat_def_cnt];
/* Entry used to traverse hash lists */
- struct objc_list** cell;
+ struct objc_list **cell;
/* The table of selector references for this module */
SEL selectors = symtab->refs;
@@ -472,19 +487,19 @@ __objc_exec_class (Module_t module)
DEBUG_PRINTF ("received module: %s\n", module->name);
/* check gcc version */
- init_check_module_version(module);
+ init_check_module_version (module);
/* On the first call of this routine, initialize some data structures. */
- if (!previous_constructors)
+ if (! previous_constructors)
{
/* Initialize thread-safe system */
- __objc_init_thread_system();
+ __objc_init_thread_system ();
__objc_runtime_threads_alive = 1;
- __objc_runtime_mutex = objc_mutex_allocate();
+ __objc_runtime_mutex = objc_mutex_allocate ();
- __objc_init_selector_tables();
- __objc_init_class_tables();
- __objc_init_dispatch_tables();
+ __objc_init_selector_tables ();
+ __objc_init_class_tables ();
+ __objc_init_dispatch_tables ();
__objc_class_tree_list = list_cons (NULL, __objc_class_tree_list);
__objc_load_methods
= hash_new (128, (hash_func_type)hash_ptr, compare_ptrs);
@@ -492,8 +507,8 @@ __objc_exec_class (Module_t module)
}
/* Save the module pointer for later processing. (not currently used) */
- objc_mutex_lock(__objc_runtime_mutex);
- __objc_module_list = list_cons(module, __objc_module_list);
+ objc_mutex_lock (__objc_runtime_mutex);
+ __objc_module_list = list_cons (module, __objc_module_list);
/* Replace referenced selectors from names to SEL's. */
if (selectors)
@@ -501,12 +516,12 @@ __objc_exec_class (Module_t module)
for (i = 0; selectors[i].sel_id; ++i)
{
const char *name, *type;
- name = (char*)selectors[i].sel_id;
- type = (char*)selectors[i].sel_types;
+ name = (char *) selectors[i].sel_id;
+ type = (char *) selectors[i].sel_types;
/* Constructors are constant static data so we can safely store
pointers to them in the runtime structures. is_const == YES */
__sel_register_typed_name (name, type,
- (struct objc_selector*)&(selectors[i]),
+ (struct objc_selector *) &(selectors[i]),
YES);
}
}
@@ -516,15 +531,15 @@ __objc_exec_class (Module_t module)
for (i = 0; i < symtab->cls_def_cnt; ++i)
{
Class class = (Class) symtab->defs[i];
- const char* superclass = (char*)class->super_class;
+ const char *superclass = (char *) class->super_class;
/* Make sure we have what we think. */
- assert (CLS_ISCLASS(class));
- assert (CLS_ISMETA(class->class_pointer));
+ assert (CLS_ISCLASS (class));
+ assert (CLS_ISMETA (class->class_pointer));
DEBUG_PRINTF ("phase 1, processing class: %s\n", class->name);
/* Initialize the subclass list to be NULL.
- In some cases it isn't and this crashes the program. */
+ In some cases it isn't and this crashes the program. */
class->subclass_list = NULL;
/* Store the class in the class table and assign class numbers. */
@@ -535,19 +550,19 @@ __objc_exec_class (Module_t module)
__objc_register_selectors_from_class ((Class) class->class_pointer);
/* Install the fake dispatch tables */
- __objc_install_premature_dtable(class);
- __objc_install_premature_dtable(class->class_pointer);
+ __objc_install_premature_dtable (class);
+ __objc_install_premature_dtable (class->class_pointer);
/* Register the instance methods as class methods, this is
- only done for root classes. */
- __objc_register_instance_methods_to_class(class);
+ only done for root classes. */
+ __objc_register_instance_methods_to_class (class);
if (class->protocols)
__objc_init_protocols (class->protocols);
/* Check to see if the superclass is known in this point. If it's not
- add the class to the unresolved_classes list. */
- if (superclass && !objc_lookup_class (superclass))
+ add the class to the unresolved_classes list. */
+ if (superclass && ! objc_lookup_class (superclass))
unresolved_classes = list_cons (class, unresolved_classes);
}
@@ -581,14 +596,14 @@ __objc_exec_class (Module_t module)
}
/* Register the instance methods as class methods, this is
- only done for root classes. */
- __objc_register_instance_methods_to_class(class);
+ only done for root classes. */
+ __objc_register_instance_methods_to_class (class);
}
else
{
/* The object to which the category methods belong can't be found.
Save the information. */
- unclaimed_categories = list_cons(category, unclaimed_categories);
+ unclaimed_categories = list_cons (category, unclaimed_categories);
}
}
@@ -625,8 +640,8 @@ __objc_exec_class (Module_t module)
}
/* Register the instance methods as class methods, this is
- only done for root classes. */
- __objc_register_instance_methods_to_class(class);
+ only done for root classes. */
+ __objc_register_instance_methods_to_class (class);
}
else
cell = &(*cell)->tail;
@@ -634,30 +649,32 @@ __objc_exec_class (Module_t module)
if (unclaimed_proto_list && objc_lookup_class ("Protocol"))
{
- list_mapcar (unclaimed_proto_list,(void(*)(void*))__objc_init_protocols);
+ list_mapcar (unclaimed_proto_list,
+ (void (*) (void *))__objc_init_protocols);
list_free (unclaimed_proto_list);
unclaimed_proto_list = 0;
}
objc_send_load ();
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
}
-static void objc_send_load (void)
+static void
+objc_send_load (void)
{
- if (!__objc_module_list)
+ if (! __objc_module_list)
return;
/* Try to find out if all the classes loaded so far also have their
- superclasses known to the runtime. We suppose that the objects that are
- allocated in the +load method are in general of a class declared in the
- same module. */
+ superclasses known to the runtime. We suppose that the objects
+ that are allocated in the +load method are in general of a class
+ declared in the same module. */
if (unresolved_classes)
{
Class class = unresolved_classes->head;
- while (objc_lookup_class ((char*)class->super_class))
+ while (objc_lookup_class ((char *) class->super_class))
{
list_remove_head (&unresolved_classes);
if (unresolved_classes)
@@ -666,25 +683,25 @@ static void objc_send_load (void)
break;
}
- /*
- * If we still have classes for whom we don't have yet their super
- * classes known to the runtime we don't send the +load messages.
- */
+ /* If we still have classes for whom we don't have yet their
+ super classes known to the runtime we don't send the +load
+ messages. */
if (unresolved_classes)
return;
}
- /* Special check to allow creating and sending messages to constant strings
- in +load methods. If these classes are not yet known, even if all the
- other classes are known, delay sending of +load. */
- if (!objc_lookup_class ("NXConstantString") ||
- !objc_lookup_class ("Object"))
+ /* Special check to allow creating and sending messages to constant
+ strings in +load methods. If these classes are not yet known,
+ even if all the other classes are known, delay sending of +load. */
+ if (! objc_lookup_class ("NXConstantString") ||
+ ! objc_lookup_class ("Object"))
return;
- /* Iterate over all modules in the __objc_module_list and call on them the
- __objc_create_classes_tree function. This function creates a tree of
- classes that resembles the class hierarchy. */
- list_mapcar (__objc_module_list, (void(*)(void*))__objc_create_classes_tree);
+ /* Iterate over all modules in the __objc_module_list and call on
+ them the __objc_create_classes_tree function. This function
+ creates a tree of classes that resembles the class hierarchy. */
+ list_mapcar (__objc_module_list,
+ (void (*) (void *)) __objc_create_classes_tree);
while (__objc_class_tree_list)
{
@@ -699,7 +716,7 @@ static void objc_send_load (void)
list_remove_head (&__objc_class_tree_list);
}
- list_mapcar (__objc_module_list, (void(*)(void*))__objc_call_callback);
+ list_mapcar (__objc_module_list, (void (*) (void *)) __objc_call_callback);
list_free (__objc_module_list);
__objc_module_list = NULL;
}
@@ -712,8 +729,8 @@ __objc_create_classes_tree (Module_t module)
Symtab_t symtab = module->symtab;
int i;
- /* Iterate thru classes defined in this module and insert them in the classes
- tree hierarchy. */
+ /* Iterate thru classes defined in this module and insert them in
+ the classes tree hierarchy. */
for (i = 0; i < symtab->cls_def_cnt; i++)
{
Class class = (Class) symtab->defs[i];
@@ -725,72 +742,74 @@ __objc_create_classes_tree (Module_t module)
static void
__objc_call_callback (Module_t module)
{
- /* The runtime mutex is locked in this point */
+ /* The runtime mutex is locked in this point. */
Symtab_t symtab = module->symtab;
int i;
- /* Iterate thru classes defined in this module and call the callback for
- each one. */
+ /* Iterate thru classes defined in this module and call the callback
+ for each one. */
for (i = 0; i < symtab->cls_def_cnt; i++)
{
Class class = (Class) symtab->defs[i];
- /* Call the _objc_load_callback for this class. */
+ /* Call the _objc_load_callback for this class. */
if (_objc_load_callback)
- _objc_load_callback(class, 0);
+ _objc_load_callback (class, 0);
}
- /* Call the _objc_load_callback for categories. Don't register the instance
- methods as class methods for categories to root classes since they were
- already added in the class. */
+ /* Call the _objc_load_callback for categories. Don't register the
+ instance methods as class methods for categories to root classes
+ since they were already added in the class. */
for (i = 0; i < symtab->cat_def_cnt; i++)
{
Category_t category = symtab->defs[i + symtab->cls_def_cnt];
Class class = objc_lookup_class (category->class_name);
if (_objc_load_callback)
- _objc_load_callback(class, category);
+ _objc_load_callback (class, category);
}
}
-/* Sanity check the version of gcc used to compile `module'*/
-static void init_check_module_version(Module_t module)
+/* Sanity check the version of gcc used to compile `module'. */
+
+static void
+init_check_module_version (Module_t module)
{
if ((module->version != OBJC_VERSION) || (module->size != sizeof (Module)))
{
int code;
- if(module->version > OBJC_VERSION)
+ if (module->version > OBJC_VERSION)
code = OBJC_ERR_OBJC_VERSION;
else if (module->version < OBJC_VERSION)
code = OBJC_ERR_GCC_VERSION;
else
code = OBJC_ERR_MODULE_SIZE;
- objc_error(nil, code, "Module %s version %d doesn't match runtime %d\n",
- module->name, (int)module->version, OBJC_VERSION);
+ objc_error (nil, code, "Module %s version %d doesn't match runtime %d\n",
+ module->name, (int)module->version, OBJC_VERSION);
}
}
static void
-__objc_init_protocols (struct objc_protocol_list* protos)
+__objc_init_protocols (struct objc_protocol_list *protos)
{
- int i;
+ size_t i;
static Class proto_class = 0;
if (! protos)
return;
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
- if (!proto_class)
- proto_class = objc_lookup_class("Protocol");
+ if (! proto_class)
+ proto_class = objc_lookup_class ("Protocol");
- if (!proto_class)
+ if (! proto_class)
{
unclaimed_proto_list = list_cons (protos, unclaimed_proto_list);
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
return;
}
@@ -798,9 +817,9 @@ __objc_init_protocols (struct objc_protocol_list* protos)
assert (protos->next == 0); /* only single ones allowed */
#endif
- for(i = 0; i < protos->count; i++)
+ for (i = 0; i < protos->count; i++)
{
- struct objc_protocol* aProto = protos->list[i];
+ struct objc_protocol *aProto = protos->list[i];
if (((size_t)aProto->class_pointer) == PROTOCOL_VERSION)
{
/* assign class pointer */
@@ -811,24 +830,25 @@ __objc_init_protocols (struct objc_protocol_list* protos)
}
else if (protos->list[i]->class_pointer != proto_class)
{
- objc_error(nil, OBJC_ERR_PROTOCOL_VERSION,
+ objc_error (nil, OBJC_ERR_PROTOCOL_VERSION,
"Version %d doesn't match runtime protocol version %d\n",
- (int)((char*)protos->list[i]->class_pointer-(char*)0),
+ (int) ((char *) protos->list[i]->class_pointer
+ - (char *) 0),
PROTOCOL_VERSION);
}
}
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
}
-static void __objc_class_add_protocols (Class class,
- struct objc_protocol_list* protos)
+static void
+__objc_class_add_protocols (Class class, struct objc_protocol_list *protos)
{
- /* Well... */
+ /* Well... */
if (! protos)
return;
- /* Add it... */
+ /* Add it... */
protos->next = class->protocols;
class->protocols = protos;
}
diff --git a/contrib/libobjc/misc.c b/contrib/libobjc/misc.c
index 7339888dc280..9572d3f00507 100644
--- a/contrib/libobjc/misc.c
+++ b/contrib/libobjc/misc.c
@@ -1,5 +1,6 @@
/* GNU Objective C Runtime Miscellaneous
- Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 1995, 1996, 1997, 2002
+ Free Software Foundation, Inc.
Contributed by Kresten Krab Thorup
This file is part of GNU CC.
@@ -37,25 +38,25 @@ static objc_error_handler _objc_error_handler = NULL;
/* Trigger an objc error */
void
-objc_error(id object, int code, const char* fmt, ...)
+objc_error (id object, int code, const char *fmt, ...)
{
va_list ap;
- va_start(ap, fmt);
- objc_verror(object, code, fmt, ap);
- va_end(ap);
+ va_start (ap, fmt);
+ objc_verror (object, code, fmt, ap);
+ va_end (ap);
}
/* Trigger an objc error */
void
-objc_verror(id object, int code, const char* fmt, va_list ap)
+objc_verror (id object, int code, const char *fmt, va_list ap)
{
BOOL result = NO;
/* Call the error handler if its there
Otherwise print to stderr */
if (_objc_error_handler)
- result = (*_objc_error_handler)(object, code, fmt, ap);
+ result = (*_objc_error_handler) (object, code, fmt, ap);
else
vfprintf (stderr, fmt, ap);
@@ -64,12 +65,12 @@ objc_verror(id object, int code, const char* fmt, va_list ap)
if (result)
return;
else
- abort();
+ abort ();
}
/* Set the error handler */
objc_error_handler
-objc_set_error_handler(objc_error_handler func)
+objc_set_error_handler (objc_error_handler func)
{
objc_error_handler temp = _objc_error_handler;
_objc_error_handler = func;
@@ -84,54 +85,54 @@ objc_set_error_handler(objc_error_handler func)
*/
void *
-objc_malloc(size_t size)
+objc_malloc (size_t size)
{
- void* res = (void*) (*_objc_malloc)(size);
- if(!res)
- objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
+ void *res = (void *) (*_objc_malloc) (size);
+ if (! res)
+ objc_error (nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
return res;
}
void *
-objc_atomic_malloc(size_t size)
+objc_atomic_malloc (size_t size)
{
- void* res = (void*) (*_objc_atomic_malloc)(size);
- if(!res)
- objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
+ void *res = (void *) (*_objc_atomic_malloc) (size);
+ if (! res)
+ objc_error (nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
return res;
}
void *
-objc_valloc(size_t size)
+objc_valloc (size_t size)
{
- void* res = (void*) (*_objc_valloc)(size);
- if(!res)
- objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
+ void *res = (void *) (*_objc_valloc) (size);
+ if (! res)
+ objc_error (nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
return res;
}
void *
-objc_realloc(void *mem, size_t size)
+objc_realloc (void *mem, size_t size)
{
- void* res = (void*) (*_objc_realloc)(mem, size);
- if(!res)
- objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
+ void *res = (void *) (*_objc_realloc) (mem, size);
+ if (! res)
+ objc_error (nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
return res;
}
void *
-objc_calloc(size_t nelem, size_t size)
+objc_calloc (size_t nelem, size_t size)
{
- void* res = (void*) (*_objc_calloc)(nelem, size);
- if(!res)
- objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
+ void *res = (void *) (*_objc_calloc) (nelem, size);
+ if (! res)
+ objc_error (nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
return res;
}
void
-objc_free(void *mem)
+objc_free (void *mem)
{
- (*_objc_free)(mem);
+ (*_objc_free) (mem);
}
/*
@@ -148,33 +149,37 @@ objc_free(void *mem)
#if OBJC_WITH_GC
#include <gc.h>
-static void *GC_calloc (size_t nelem, size_t size)
+static void *
+GC_calloc (size_t nelem, size_t size)
{
- void* p = GC_malloc (nelem * size);
- if (!p)
+ void *p = GC_malloc (nelem * size);
+ if (! p)
objc_error (nil, OBJC_ERR_MEMORY, "Virtual memory exhausted!\n");
memset (p, 0, nelem * size);
return p;
}
-static void noFree (void* p) {}
+static void
+noFree (void *p)
+{
+}
-void *(*_objc_malloc)(size_t) = GC_malloc;
-void *(*_objc_atomic_malloc)(size_t) = GC_malloc_atomic;
-void *(*_objc_valloc)(size_t) = GC_malloc;
-void *(*_objc_realloc)(void *, size_t) = GC_realloc;
-void *(*_objc_calloc)(size_t, size_t) = GC_calloc;
-void (*_objc_free)(void *) = noFree;
+void *(*_objc_malloc) (size_t) = GC_malloc;
+void *(*_objc_atomic_malloc) (size_t) = GC_malloc_atomic;
+void *(*_objc_valloc) (size_t) = GC_malloc;
+void *(*_objc_realloc) (void *, size_t) = GC_realloc;
+void *(*_objc_calloc) (size_t, size_t) = GC_calloc;
+void (*_objc_free) (void *) = noFree;
-#else
+#else /* !OBJC_WITH_GC */
-void *(*_objc_malloc)(size_t) = malloc;
-void *(*_objc_atomic_malloc)(size_t) = malloc;
-void *(*_objc_valloc)(size_t) = malloc;
-void *(*_objc_realloc)(void *, size_t) = realloc;
-void *(*_objc_calloc)(size_t, size_t) = calloc;
-void (*_objc_free)(void *) = free;
+void *(*_objc_malloc) (size_t) = malloc;
+void *(*_objc_atomic_malloc) (size_t) = malloc;
+void *(*_objc_valloc) (size_t) = malloc;
+void *(*_objc_realloc) (void *, size_t) = realloc;
+void *(*_objc_calloc) (size_t, size_t) = calloc;
+void (*_objc_free) (void *) = free;
-#endif
+#endif /* !OBJC_WITH_GC */
diff --git a/contrib/libobjc/nil_method.c b/contrib/libobjc/nil_method.c
index 1b6212826bda..5e37c4d5dfb4 100644
--- a/contrib/libobjc/nil_method.c
+++ b/contrib/libobjc/nil_method.c
@@ -1,5 +1,5 @@
/* GNU Objective C Runtime nil receiver function
- Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1995, 1996, 2002 Free Software Foundation, Inc.
Contributed by Kresten Krab Thorup
This file is part of GNU CC.
@@ -29,12 +29,27 @@ Boston, MA 02111-1307, USA. */
#include "runtime.h"
+/* When the receiver of a method invocation is nil, the runtime
+ returns nil_method() as the method implementation. This function
+ will be casted to whatever function was supposed to be executed to
+ execute that method (that function will take an id, followed by a
+ SEL, followed by who knows what arguments, depends on the method),
+ and executed.
+
+ For this reason, nil_method() should be a function which can be
+ called in place of any function taking an 'id' argument followed by
+ a 'SEL' argument, followed by zero, or one, or any number of
+ arguments (both a fixed number, or a variable number !).
+
+ There is no "proper" implementation of such a nil_method function
+ in C, however in all existing implementations it does not matter
+ when extra arguments are present, so we can simply create a function
+ taking a receiver and a selector, and all other arguments will be
+ ignored. :-)
+*/
+
id
-nil_method(id receiver, SEL op, ...)
+nil_method (id receiver, SEL op __attribute__ ((__unused__)))
{
return receiver;
}
-
-
-
-
diff --git a/contrib/libobjc/objc/encoding.h b/contrib/libobjc/objc/encoding.h
index b4def4302b53..36a3d892137d 100644
--- a/contrib/libobjc/objc/encoding.h
+++ b/contrib/libobjc/objc/encoding.h
@@ -1,5 +1,5 @@
/* Encoding of types for Objective C.
- Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1997, 2002 Free Software Foundation, Inc.
Author: Kresten Krab Thorup
@@ -50,30 +50,30 @@ Boston, MA 02111-1307, USA. */
#define _F_ONEWAY 0x10
#define _F_GCINVISIBLE 0x20
-int objc_aligned_size (const char* type);
-int objc_sizeof_type (const char* type);
-int objc_alignof_type (const char* type);
-int objc_aligned_size (const char* type);
-int objc_promoted_size (const char* type);
+int objc_aligned_size (const char *type);
+int objc_sizeof_type (const char *type);
+int objc_alignof_type (const char *type);
+int objc_aligned_size (const char *type);
+int objc_promoted_size (const char *type);
-const char* objc_skip_type_qualifiers (const char* type);
-const char* objc_skip_typespec (const char* type);
-const char* objc_skip_offset (const char* type);
-const char* objc_skip_argspec (const char* type);
-int method_get_number_of_arguments (struct objc_method*);
-int method_get_sizeof_arguments (struct objc_method*);
+const char *objc_skip_type_qualifiers (const char *type);
+const char *objc_skip_typespec (const char *type);
+const char *objc_skip_offset (const char *type);
+const char *objc_skip_argspec (const char *type);
+int method_get_number_of_arguments (struct objc_method *);
+int method_get_sizeof_arguments (struct objc_method *);
-char* method_get_first_argument (struct objc_method*,
+char *method_get_first_argument (struct objc_method *,
arglist_t argframe,
- const char** type);
-char* method_get_next_argument (arglist_t argframe,
+ const char **type);
+char *method_get_next_argument (arglist_t argframe,
const char **type);
-char* method_get_nth_argument (struct objc_method* m,
+char *method_get_nth_argument (struct objc_method *m,
arglist_t argframe,
int arg,
const char **type);
-unsigned objc_get_type_qualifiers (const char* type);
+unsigned objc_get_type_qualifiers (const char *type);
struct objc_struct_layout
diff --git a/contrib/libobjc/objc/hash.h b/contrib/libobjc/objc/hash.h
index fc3cc9eaa108..e695012aa437 100644
--- a/contrib/libobjc/objc/hash.h
+++ b/contrib/libobjc/objc/hash.h
@@ -60,7 +60,7 @@ typedef struct cache_node
* typedef. Therefore, to remove compiler warnings the functions passed to
* hash_new will have to be casted to this type.
*/
-typedef unsigned int (*hash_func_type)(void *, const void *);
+typedef unsigned int (*hash_func_type) (void *, const void *);
/*
* This data type is the function that compares two hash keys and returns an
@@ -69,7 +69,7 @@ typedef unsigned int (*hash_func_type)(void *, const void *);
* second.
*/
-typedef int (*compare_func_type)(const void *, const void *);
+typedef int (*compare_func_type) (const void *, const void *);
/*
@@ -174,8 +174,8 @@ hash_string (cache_ptr cache, const void *key)
unsigned int ctr = 0;
- while (*(char*)key) {
- ret ^= *(char*)key++ << ctr;
+ while (*(char *) key) {
+ ret ^= *(char *) key++ << ctr;
ctr = (ctr + 1) % sizeof (void *);
}
@@ -187,7 +187,7 @@ hash_string (cache_ptr cache, const void *key)
static inline int
compare_ptrs (const void *k1, const void *k2)
{
- return !(k1 - k2);
+ return ! (k1 - k2);
}
@@ -200,7 +200,7 @@ compare_strings (const void *k1, const void *k2)
else if (k1 == 0 || k2 == 0)
return 0;
else
- return !strcmp (k1, k2);
+ return ! strcmp (k1, k2);
}
diff --git a/contrib/libobjc/objc/objc.h b/contrib/libobjc/objc/objc.h
index 79b2519e5765..699542c493bc 100644
--- a/contrib/libobjc/objc/objc.h
+++ b/contrib/libobjc/objc/objc.h
@@ -73,7 +73,14 @@ typedef struct objc_object {
/*
** Definition of method type. When retrieving the implementation of a
-** method, this is type of the pointer returned
+** method, this is type of the pointer returned. The idea of the
+** definition of IMP is to represent a 'pointer to a general function
+** taking an id, a SEL, followed by other unspecified arguments'. You
+** must always cast an IMP to a pointer to a function taking the
+** appropriate, specific types for that function, before calling it -
+** to make sure the appropriate arguments are passed to it. The code
+** generated by the compiler to perform method calls automatically
+** does this cast inside method calls.
*/
typedef id (*IMP)(id, SEL, ...);
diff --git a/contrib/libobjc/objc/runtime.h b/contrib/libobjc/objc/runtime.h
index b0eae4a222d3..bea9253a8be1 100644
--- a/contrib/libobjc/objc/runtime.h
+++ b/contrib/libobjc/objc/runtime.h
@@ -1,5 +1,5 @@
/* GNU Objective C Runtime internal declarations
- Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
Contributed by Kresten Krab Thorup
This file is part of GNU CC.
@@ -65,7 +65,7 @@ extern Method_t search_for_method_in_list(MethodList_t list, SEL op);
extern BOOL __objc_class_links_resolved;
/* Number of selectors stored in each of the selector tables */
-extern int __objc_selector_max_index;
+extern unsigned int __objc_selector_max_index;
/* Mutex locking __objc_selector_max_index and its arrays. */
extern objc_mutex_t __objc_runtime_mutex;
@@ -82,6 +82,7 @@ extern int __objc_runtime_threads_alive;
BOOL __objc_responds_to (id object, SEL sel); /* for internal use only! */
SEL __sel_register_typed_name (const char*, const char*,
struct objc_selector*, BOOL is_const);
+extern void __objc_generate_gc_type_description (Class);
#endif /* not __objc_runtime_INCLUDE_GNU */
diff --git a/contrib/libobjc/objc/thr.h b/contrib/libobjc/objc/thr.h
index 59766f6ed7db..48ad0befa0df 100644
--- a/contrib/libobjc/objc/thr.h
+++ b/contrib/libobjc/objc/thr.h
@@ -1,5 +1,5 @@
/* Thread and mutex controls for Objective C.
- Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 2002 Free Software Foundation, Inc.
Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
This file is part of GNU CC.
@@ -74,30 +74,30 @@ struct objc_condition
typedef struct objc_condition *objc_condition_t;
/* Frontend mutex functions */
-objc_mutex_t objc_mutex_allocate(void);
-int objc_mutex_deallocate(objc_mutex_t mutex);
-int objc_mutex_lock(objc_mutex_t mutex);
-int objc_mutex_unlock(objc_mutex_t mutex);
-int objc_mutex_trylock(objc_mutex_t mutex);
+objc_mutex_t objc_mutex_allocate (void);
+int objc_mutex_deallocate (objc_mutex_t mutex);
+int objc_mutex_lock (objc_mutex_t mutex);
+int objc_mutex_unlock (objc_mutex_t mutex);
+int objc_mutex_trylock (objc_mutex_t mutex);
/* Frontend condition mutex functions */
-objc_condition_t objc_condition_allocate(void);
-int objc_condition_deallocate(objc_condition_t condition);
-int objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex);
-int objc_condition_signal(objc_condition_t condition);
-int objc_condition_broadcast(objc_condition_t condition);
+objc_condition_t objc_condition_allocate (void);
+int objc_condition_deallocate (objc_condition_t condition);
+int objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex);
+int objc_condition_signal (objc_condition_t condition);
+int objc_condition_broadcast (objc_condition_t condition);
/* Frontend thread functions */
-objc_thread_t objc_thread_detach(SEL selector, id object, id argument);
-void objc_thread_yield(void);
-int objc_thread_exit(void);
-int objc_thread_set_priority(int priority);
-int objc_thread_get_priority(void);
-void * objc_thread_get_data(void);
-int objc_thread_set_data(void *value);
-objc_thread_t objc_thread_id(void);
-void objc_thread_add(void);
-void objc_thread_remove(void);
+objc_thread_t objc_thread_detach (SEL selector, id object, id argument);
+void objc_thread_yield (void);
+int objc_thread_exit (void);
+int objc_thread_set_priority (int priority);
+int objc_thread_get_priority (void);
+void * objc_thread_get_data (void);
+int objc_thread_set_data (void *value);
+objc_thread_t objc_thread_id (void);
+void objc_thread_add (void);
+void objc_thread_remove (void);
/*
Use this to set the hook function that will be called when the
@@ -111,35 +111,35 @@ void objc_thread_remove(void);
it can be informed; for example, the GNUstep Base Library sets it
so it can implement the NSBecomingMultiThreaded notification.
*/
-typedef void (*objc_thread_callback)();
-objc_thread_callback objc_set_thread_callback(objc_thread_callback func);
+typedef void (*objc_thread_callback) (void);
+objc_thread_callback objc_set_thread_callback (objc_thread_callback func);
/* Backend initialization functions */
-int __objc_init_thread_system(void);
-int __objc_fini_thread_system(void);
+int __objc_init_thread_system (void);
+int __objc_fini_thread_system (void);
/* Backend mutex functions */
-int __objc_mutex_allocate(objc_mutex_t mutex);
-int __objc_mutex_deallocate(objc_mutex_t mutex);
-int __objc_mutex_lock(objc_mutex_t mutex);
-int __objc_mutex_trylock(objc_mutex_t mutex);
-int __objc_mutex_unlock(objc_mutex_t mutex);
+int __objc_mutex_allocate (objc_mutex_t mutex);
+int __objc_mutex_deallocate (objc_mutex_t mutex);
+int __objc_mutex_lock (objc_mutex_t mutex);
+int __objc_mutex_trylock (objc_mutex_t mutex);
+int __objc_mutex_unlock (objc_mutex_t mutex);
/* Backend condition mutex functions */
-int __objc_condition_allocate(objc_condition_t condition);
-int __objc_condition_deallocate(objc_condition_t condition);
-int __objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex);
-int __objc_condition_broadcast(objc_condition_t condition);
-int __objc_condition_signal(objc_condition_t condition);
+int __objc_condition_allocate (objc_condition_t condition);
+int __objc_condition_deallocate (objc_condition_t condition);
+int __objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex);
+int __objc_condition_broadcast (objc_condition_t condition);
+int __objc_condition_signal (objc_condition_t condition);
/* Backend thread functions */
-objc_thread_t __objc_thread_detach(void (*func)(void *arg), void *arg);
-int __objc_thread_set_priority(int priority);
-int __objc_thread_get_priority(void);
-void __objc_thread_yield(void);
-int __objc_thread_exit(void);
-objc_thread_t __objc_thread_id(void);
-int __objc_thread_set_data(void *value);
-void * __objc_thread_get_data(void);
+objc_thread_t __objc_thread_detach (void (*func) (void *arg), void *arg);
+int __objc_thread_set_priority (int priority);
+int __objc_thread_get_priority (void);
+void __objc_thread_yield (void);
+int __objc_thread_exit (void);
+objc_thread_t __objc_thread_id (void);
+int __objc_thread_set_data (void *value);
+void * __objc_thread_get_data (void);
#endif /* not __thread_INCLUDE_GNU */
diff --git a/contrib/libobjc/objects.c b/contrib/libobjc/objects.c
index df74b85de872..6858fed20131 100644
--- a/contrib/libobjc/objects.c
+++ b/contrib/libobjc/objects.c
@@ -32,29 +32,29 @@ Boston, MA 02111-1307, USA. */
# include <gc.h>
#endif
-id __objc_object_alloc(Class);
-id __objc_object_dispose(id);
-id __objc_object_copy(id);
+id __objc_object_alloc (Class);
+id __objc_object_dispose (id);
+id __objc_object_copy (id);
-id (*_objc_object_alloc)(Class) = __objc_object_alloc; /* !T:SINGLE */
-id (*_objc_object_dispose)(id) = __objc_object_dispose; /* !T:SINGLE */
-id (*_objc_object_copy)(id) = __objc_object_copy; /* !T:SINGLE */
+id (*_objc_object_alloc) (Class) = __objc_object_alloc; /* !T:SINGLE */
+id (*_objc_object_dispose) (id) = __objc_object_dispose; /* !T:SINGLE */
+id (*_objc_object_copy) (id) = __objc_object_copy; /* !T:SINGLE */
id
-class_create_instance(Class class)
+class_create_instance (Class class)
{
id new = nil;
#if OBJC_WITH_GC
- if (CLS_ISCLASS(class))
- new = (id)GC_malloc_explicitly_typed (class->instance_size,
- class->gc_object_type);
+ if (CLS_ISCLASS (class))
+ new = (id) GC_malloc_explicitly_typed (class->instance_size,
+ class->gc_object_type);
#else
- if (CLS_ISCLASS(class))
- new = (*_objc_object_alloc)(class);
+ if (CLS_ISCLASS (class))
+ new = (*_objc_object_alloc) (class);
#endif
- if (new!=nil)
+ if (new != nil)
{
memset (new, 0, class->instance_size);
new->class_pointer = class;
@@ -63,43 +63,41 @@ class_create_instance(Class class)
}
id
-object_copy(id object)
+object_copy (id object)
{
- if ((object!=nil)&&CLS_ISCLASS(object->class_pointer))
- return (*_objc_object_copy)(object);
+ if ((object != nil) && CLS_ISCLASS (object->class_pointer))
+ return (*_objc_object_copy) (object);
else
return nil;
}
id
-object_dispose(id object)
+object_dispose (id object)
{
- if ((object!=nil)&&CLS_ISCLASS(object->class_pointer))
+ if ((object != nil) && CLS_ISCLASS (object->class_pointer))
{
if (_objc_object_dispose)
- (*_objc_object_dispose)(object);
+ (*_objc_object_dispose) (object);
else
- objc_free(object);
+ objc_free (object);
}
return nil;
}
-id __objc_object_alloc(Class class)
+id __objc_object_alloc (Class class)
{
- return (id)objc_malloc(class->instance_size);
+ return (id) objc_malloc (class->instance_size);
}
-id __objc_object_dispose(id object)
+id __objc_object_dispose (id object)
{
- objc_free(object);
+ objc_free (object);
return 0;
}
-id __objc_object_copy(id object)
+id __objc_object_copy (id object)
{
- id copy = class_create_instance(object->class_pointer);
- memcpy(copy, object, object->class_pointer->instance_size);
+ id copy = class_create_instance (object->class_pointer);
+ memcpy (copy, object, object->class_pointer->instance_size);
return copy;
}
-
-
diff --git a/contrib/libobjc/sarray.c b/contrib/libobjc/sarray.c
index 4625fbe4559c..e78e36d01f18 100644
--- a/contrib/libobjc/sarray.c
+++ b/contrib/libobjc/sarray.c
@@ -1,5 +1,5 @@
/* Sparse Arrays for Objective C dispatch tables
- Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1995, 1996, 2002 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -34,36 +34,36 @@ int nindices = 0; /* !T:MUTEX */
int narrays = 0; /* !T:MUTEX */
int idxsize = 0; /* !T:MUTEX */
-static void * first_free_data = NULL; /* !T:MUTEX */
+static void *first_free_data = NULL; /* !T:MUTEX */
#ifdef OBJC_SPARSE2
-const char* __objc_sparse2_id = "2 level sparse indices";
+const char *__objc_sparse2_id = "2 level sparse indices";
#endif
#ifdef OBJC_SPARSE3
-const char* __objc_sparse3_id = "3 level sparse indices";
+const char *__objc_sparse3_id = "3 level sparse indices";
#endif
/* This function removes any structures left over from free operations
that were not safe in a multi-threaded environment. */
void
-sarray_remove_garbage(void)
+sarray_remove_garbage (void)
{
void **vp;
void *np;
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
vp = first_free_data;
first_free_data = NULL;
while (vp) {
np = *vp;
- objc_free(vp);
+ objc_free (vp);
vp = np;
}
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
}
/* Free a block of dynamically allocated memory. If we are in multi-threaded
@@ -71,33 +71,33 @@ sarray_remove_garbage(void)
freed later. */
static void
-sarray_free_garbage(void *vp)
+sarray_free_garbage (void *vp)
{
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
if (__objc_runtime_threads_alive == 1) {
- objc_free(vp);
+ objc_free (vp);
if (first_free_data)
- sarray_remove_garbage();
+ sarray_remove_garbage ();
}
else {
*(void **)vp = first_free_data;
first_free_data = vp;
}
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
}
/* sarray_at_put : copies data in such a way as to be thread reader safe. */
void
-sarray_at_put(struct sarray* array, sidx index, void* element)
+sarray_at_put (struct sarray *array, sidx index, void *element)
{
#ifdef OBJC_SPARSE3
- struct sindex** the_index;
- struct sindex* new_index;
+ struct sindex **the_index;
+ struct sindex *new_index;
#endif
- struct sbucket** the_bucket;
- struct sbucket* new_bucket;
+ struct sbucket **the_bucket;
+ struct sbucket *new_bucket;
#ifdef OBJC_SPARSE3
size_t ioffset;
#endif
@@ -122,7 +122,7 @@ sarray_at_put(struct sarray* array, sidx index, void* element)
#endif
#endif /* not PRECOMPUTE_SELECTORS */
- assert(soffset_decode(index) < array->capacity); /* Range check */
+ assert (soffset_decode (index) < array->capacity); /* Range check */
#ifdef OBJC_SPARSE3
the_index = &(array->indices[ioffset]);
@@ -141,8 +141,8 @@ sarray_at_put(struct sarray* array, sidx index, void* element)
if ((*the_index) == array->empty_index) {
/* The index was previously empty, allocate a new */
- new_index = (struct sindex*)objc_malloc(sizeof(struct sindex));
- memcpy(new_index, array->empty_index, sizeof(struct sindex));
+ new_index = (struct sindex *) objc_malloc (sizeof (struct sindex));
+ memcpy (new_index, array->empty_index, sizeof (struct sindex));
new_index->version.version = array->version.version;
*the_index = new_index; /* Prepared for install. */
the_bucket = &((*the_index)->buckets[boffset]);
@@ -151,9 +151,9 @@ sarray_at_put(struct sarray* array, sidx index, void* element)
} else if ((*the_index)->version.version != array->version.version) {
/* This index must be lazy copied */
- struct sindex* old_index = *the_index;
- new_index = (struct sindex*)objc_malloc(sizeof(struct sindex));
- memcpy( new_index, old_index, sizeof(struct sindex));
+ struct sindex *old_index = *the_index;
+ new_index = (struct sindex *) objc_malloc (sizeof (struct sindex));
+ memcpy (new_index, old_index, sizeof (struct sindex));
new_index->version.version = array->version.version;
*the_index = new_index; /* Prepared for install. */
the_bucket = &((*the_index)->buckets[boffset]);
@@ -169,9 +169,9 @@ sarray_at_put(struct sarray* array, sidx index, void* element)
/* The bucket was previously empty (or something like that), */
/* allocate a new. This is the effect of `lazy' allocation */
- new_bucket = (struct sbucket*)objc_malloc(sizeof(struct sbucket));
- memcpy((void *) new_bucket, (const void*)array->empty_bucket,
- sizeof(struct sbucket));
+ new_bucket = (struct sbucket *) objc_malloc (sizeof (struct sbucket));
+ memcpy ((void *) new_bucket, (const void *) array->empty_bucket,
+ sizeof (struct sbucket));
new_bucket->version.version = array->version.version;
*the_bucket = new_bucket; /* Prepared for install. */
@@ -180,9 +180,9 @@ sarray_at_put(struct sarray* array, sidx index, void* element)
} else if ((*the_bucket)->version.version != array->version.version) {
/* Perform lazy copy. */
- struct sbucket* old_bucket = *the_bucket;
- new_bucket = (struct sbucket*)objc_malloc(sizeof(struct sbucket));
- memcpy( new_bucket, old_bucket, sizeof(struct sbucket));
+ struct sbucket *old_bucket = *the_bucket;
+ new_bucket = (struct sbucket *) objc_malloc (sizeof (struct sbucket));
+ memcpy (new_bucket, old_bucket, sizeof (struct sbucket));
new_bucket->version.version = array->version.version;
*the_bucket = new_bucket; /* Prepared for install. */
@@ -193,39 +193,39 @@ sarray_at_put(struct sarray* array, sidx index, void* element)
}
void
-sarray_at_put_safe(struct sarray* array, sidx index, void* element)
+sarray_at_put_safe (struct sarray *array, sidx index, void *element)
{
- if(soffset_decode(index) >= array->capacity)
- sarray_realloc(array, soffset_decode(index)+1);
- sarray_at_put(array, index, element);
+ if (soffset_decode (index) >= array->capacity)
+ sarray_realloc (array, soffset_decode (index) + 1);
+ sarray_at_put (array, index, element);
}
-struct sarray*
-sarray_new (int size, void* default_element)
+struct sarray *
+sarray_new (int size, void *default_element)
{
- struct sarray* arr;
+ struct sarray *arr;
#ifdef OBJC_SPARSE3
- size_t num_indices = ((size-1)/(INDEX_CAPACITY))+1;
- struct sindex ** new_indices;
+ size_t num_indices = ((size - 1)/(INDEX_CAPACITY)) + 1;
+ struct sindex **new_indices;
#else /* OBJC_SPARSE2 */
- size_t num_indices = ((size-1)/BUCKET_SIZE)+1;
- struct sbucket ** new_buckets;
+ size_t num_indices = ((size - 1)/BUCKET_SIZE) + 1;
+ struct sbucket **new_buckets;
#endif
- int counter;
+ size_t counter;
- assert(size > 0);
+ assert (size > 0);
/* Allocate core array */
- arr = (struct sarray*) objc_malloc(sizeof(struct sarray));
+ arr = (struct sarray *) objc_malloc (sizeof (struct sarray));
arr->version.version = 0;
/* Initialize members */
#ifdef OBJC_SPARSE3
arr->capacity = num_indices*INDEX_CAPACITY;
- new_indices = (struct sindex**)
- objc_malloc(sizeof(struct sindex*)*num_indices);
+ new_indices = (struct sindex **)
+ objc_malloc (sizeof (struct sindex *) * num_indices);
- arr->empty_index = (struct sindex*) objc_malloc(sizeof(struct sindex));
+ arr->empty_index = (struct sindex *) objc_malloc (sizeof (struct sindex));
arr->empty_index->version.version = 0;
narrays += 1;
@@ -234,35 +234,35 @@ sarray_new (int size, void* default_element)
#else /* OBJC_SPARSE2 */
arr->capacity = num_indices*BUCKET_SIZE;
- new_buckets = (struct sbucket**)
- objc_malloc(sizeof(struct sbucket*)*num_indices);
+ new_buckets = (struct sbucket **)
+ objc_malloc (sizeof (struct sbucket *) * num_indices);
narrays += 1;
idxsize += num_indices;
#endif
- arr->empty_bucket = (struct sbucket*) objc_malloc(sizeof(struct sbucket));
+ arr->empty_bucket = (struct sbucket *) objc_malloc (sizeof (struct sbucket));
arr->empty_bucket->version.version = 0;
nbuckets += 1;
arr->ref_count = 1;
- arr->is_copy_of = (struct sarray*)0;
+ arr->is_copy_of = (struct sarray *) 0;
- for (counter=0; counter<BUCKET_SIZE; counter++)
+ for (counter = 0; counter < BUCKET_SIZE; counter++)
arr->empty_bucket->elems[counter] = default_element;
#ifdef OBJC_SPARSE3
- for (counter=0; counter<INDEX_SIZE; counter++)
+ for (counter = 0; counter < INDEX_SIZE; counter++)
arr->empty_index->buckets[counter] = arr->empty_bucket;
- for (counter=0; counter<num_indices; counter++)
+ for (counter = 0; counter < num_indices; counter++)
new_indices[counter] = arr->empty_index;
#else /* OBJC_SPARSE2 */
- for (counter=0; counter<num_indices; counter++)
+ for (counter = 0; counter < num_indices; counter++)
new_buckets[counter] = arr->empty_bucket;
#endif
@@ -282,48 +282,48 @@ sarray_new (int size, void* default_element)
any concurrent readers notice the update. */
void
-sarray_realloc(struct sarray* array, int newsize)
+sarray_realloc (struct sarray *array, int newsize)
{
#ifdef OBJC_SPARSE3
- size_t old_max_index = (array->capacity-1)/INDEX_CAPACITY;
- size_t new_max_index = ((newsize-1)/INDEX_CAPACITY);
- size_t rounded_size = (new_max_index+1)*INDEX_CAPACITY;
+ size_t old_max_index = (array->capacity - 1)/INDEX_CAPACITY;
+ size_t new_max_index = ((newsize - 1)/INDEX_CAPACITY);
+ size_t rounded_size = (new_max_index + 1) * INDEX_CAPACITY;
- struct sindex ** new_indices;
- struct sindex ** old_indices;
+ struct sindex **new_indices;
+ struct sindex **old_indices;
#else /* OBJC_SPARSE2 */
- size_t old_max_index = (array->capacity-1)/BUCKET_SIZE;
- size_t new_max_index = ((newsize-1)/BUCKET_SIZE);
- size_t rounded_size = (new_max_index+1)*BUCKET_SIZE;
+ size_t old_max_index = (array->capacity - 1)/BUCKET_SIZE;
+ size_t new_max_index = ((newsize - 1)/BUCKET_SIZE);
+ size_t rounded_size = (new_max_index + 1) * BUCKET_SIZE;
- struct sbucket ** new_buckets;
- struct sbucket ** old_buckets;
+ struct sbucket **new_buckets;
+ struct sbucket **old_buckets;
#endif
- int counter;
+ size_t counter;
- assert(newsize > 0);
+ assert (newsize > 0);
/* The size is the same, just ignore the request */
- if(rounded_size <= array->capacity)
+ if (rounded_size <= array->capacity)
return;
- assert(array->ref_count == 1); /* stop if lazy copied... */
+ assert (array->ref_count == 1); /* stop if lazy copied... */
/* We are asked to extend the array -- allocate new bucket table, */
/* and insert empty_bucket in newly allocated places. */
- if(rounded_size > array->capacity)
+ if (rounded_size > array->capacity)
{
#ifdef OBJC_SPARSE3
new_max_index += 4;
- rounded_size = (new_max_index+1)*INDEX_CAPACITY;
+ rounded_size = (new_max_index + 1) * INDEX_CAPACITY;
#else /* OBJC_SPARSE2 */
new_max_index += 4;
- rounded_size = (new_max_index+1)*BUCKET_SIZE;
+ rounded_size = (new_max_index + 1) * BUCKET_SIZE;
#endif
/* update capacity */
@@ -332,16 +332,16 @@ sarray_realloc(struct sarray* array, int newsize)
#ifdef OBJC_SPARSE3
/* alloc to force re-read by any concurrent readers. */
old_indices = array->indices;
- new_indices = (struct sindex**)
- objc_malloc((new_max_index+1)*sizeof(struct sindex*));
+ new_indices = (struct sindex **)
+ objc_malloc ((new_max_index + 1) * sizeof (struct sindex *));
#else /* OBJC_SPARSE2 */
old_buckets = array->buckets;
- new_buckets = (struct sbucket**)
- objc_malloc((new_max_index+1)*sizeof(struct sbucket*));
+ new_buckets = (struct sbucket **)
+ objc_malloc ((new_max_index + 1) * sizeof (struct sbucket *));
#endif
/* copy buckets below old_max_index (they are still valid) */
- for(counter = 0; counter <= old_max_index; counter++ ) {
+ for (counter = 0; counter <= old_max_index; counter++ ) {
#ifdef OBJC_SPARSE3
new_indices[counter] = old_indices[counter];
#else /* OBJC_SPARSE2 */
@@ -351,11 +351,11 @@ sarray_realloc(struct sarray* array, int newsize)
#ifdef OBJC_SPARSE3
/* reset entries above old_max_index to empty_bucket */
- for(counter = old_max_index+1; counter <= new_max_index; counter++)
+ for (counter = old_max_index + 1; counter <= new_max_index; counter++)
new_indices[counter] = array->empty_index;
#else /* OBJC_SPARSE2 */
/* reset entries above old_max_index to empty_bucket */
- for(counter = old_max_index+1; counter <= new_max_index; counter++)
+ for (counter = old_max_index + 1; counter <= new_max_index; counter++)
new_buckets[counter] = array->empty_bucket;
#endif
@@ -368,9 +368,9 @@ sarray_realloc(struct sarray* array, int newsize)
#ifdef OBJC_SPARSE3
/* free the old indices */
- sarray_free_garbage(old_indices);
+ sarray_free_garbage (old_indices);
#else /* OBJC_SPARSE2 */
- sarray_free_garbage(old_buckets);
+ sarray_free_garbage (old_buckets);
#endif
idxsize += (new_max_index-old_max_index);
@@ -382,20 +382,19 @@ sarray_realloc(struct sarray* array, int newsize)
/* Free a sparse array allocated with sarray_new */
void
-sarray_free(struct sarray* array) {
-
+sarray_free (struct sarray *array) {
#ifdef OBJC_SPARSE3
- size_t old_max_index = (array->capacity-1)/INDEX_CAPACITY;
- struct sindex ** old_indices;
+ size_t old_max_index = (array->capacity - 1)/INDEX_CAPACITY;
+ struct sindex **old_indices;
#else
- size_t old_max_index = (array->capacity-1)/BUCKET_SIZE;
- struct sbucket ** old_buckets;
+ size_t old_max_index = (array->capacity - 1)/BUCKET_SIZE;
+ struct sbucket **old_buckets;
#endif
- int counter = 0;
+ size_t counter = 0;
- assert(array->ref_count != 0); /* Freed multiple times!!! */
+ assert (array->ref_count != 0); /* Freed multiple times!!! */
- if(--(array->ref_count) != 0) /* There exists copies of me */
+ if (--(array->ref_count) != 0) /* There exists copies of me */
return;
#ifdef OBJC_SPARSE3
@@ -404,34 +403,34 @@ sarray_free(struct sarray* array) {
old_buckets = array->buckets;
#endif
- if((array->is_copy_of) && ((array->is_copy_of->ref_count - 1) == 0))
- sarray_free(array->is_copy_of);
+ if ((array->is_copy_of) && ((array->is_copy_of->ref_count - 1) == 0))
+ sarray_free (array->is_copy_of);
/* Free all entries that do not point to empty_bucket */
- for(counter = 0; counter <= old_max_index; counter++ ) {
+ for (counter = 0; counter <= old_max_index; counter++ ) {
#ifdef OBJC_SPARSE3
- struct sindex* idx = old_indices[counter];
- if((idx != array->empty_index) &&
+ struct sindex *idx = old_indices[counter];
+ if ((idx != array->empty_index) &&
(idx->version.version == array->version.version)) {
int c2;
- for(c2=0; c2<INDEX_SIZE; c2++) {
- struct sbucket* bkt = idx->buckets[c2];
- if((bkt != array->empty_bucket) &&
+ for (c2 = 0; c2 < INDEX_SIZE; c2++) {
+ struct sbucket *bkt = idx->buckets[c2];
+ if ((bkt != array->empty_bucket) &&
(bkt->version.version == array->version.version))
{
- sarray_free_garbage(bkt);
+ sarray_free_garbage (bkt);
nbuckets -= 1;
}
}
- sarray_free_garbage(idx);
+ sarray_free_garbage (idx);
nindices -= 1;
}
#else /* OBJC_SPARSE2 */
- struct sbucket* bkt = array->buckets[counter];
+ struct sbucket *bkt = array->buckets[counter];
if ((bkt != array->empty_bucket) &&
(bkt->version.version == array->version.version))
{
- sarray_free_garbage(bkt);
+ sarray_free_garbage (bkt);
nbuckets -= 1;
}
#endif
@@ -439,52 +438,52 @@ sarray_free(struct sarray* array) {
#ifdef OBJC_SPARSE3
/* free empty_index */
- if(array->empty_index->version.version == array->version.version) {
- sarray_free_garbage(array->empty_index);
+ if (array->empty_index->version.version == array->version.version) {
+ sarray_free_garbage (array->empty_index);
nindices -= 1;
}
#endif
/* free empty_bucket */
- if(array->empty_bucket->version.version == array->version.version) {
- sarray_free_garbage(array->empty_bucket);
+ if (array->empty_bucket->version.version == array->version.version) {
+ sarray_free_garbage (array->empty_bucket);
nbuckets -= 1;
}
- idxsize -= (old_max_index+1);
+ idxsize -= (old_max_index + 1);
narrays -= 1;
#ifdef OBJC_SPARSE3
/* free bucket table */
- sarray_free_garbage(array->indices);
+ sarray_free_garbage (array->indices);
#else
/* free bucket table */
- sarray_free_garbage(array->buckets);
+ sarray_free_garbage (array->buckets);
#endif
/* free array */
- sarray_free_garbage(array);
+ sarray_free_garbage (array);
}
/* This is a lazy copy. Only the core of the structure is actually */
/* copied. */
-struct sarray*
-sarray_lazy_copy(struct sarray* oarr)
+struct sarray *
+sarray_lazy_copy (struct sarray *oarr)
{
- struct sarray* arr;
+ struct sarray *arr;
#ifdef OBJC_SPARSE3
- size_t num_indices = ((oarr->capacity-1)/INDEX_CAPACITY)+1;
- struct sindex ** new_indices;
+ size_t num_indices = ((oarr->capacity - 1)/INDEX_CAPACITY) + 1;
+ struct sindex **new_indices;
#else /* OBJC_SPARSE2 */
- size_t num_indices = ((oarr->capacity-1)/BUCKET_SIZE)+1;
- struct sbucket ** new_buckets;
+ size_t num_indices = ((oarr->capacity - 1)/BUCKET_SIZE) + 1;
+ struct sbucket **new_buckets;
#endif
/* Allocate core array */
- arr = (struct sarray*) objc_malloc(sizeof(struct sarray)); /* !!! */
+ arr = (struct sarray *) objc_malloc (sizeof (struct sarray)); /* !!! */
arr->version.version = oarr->version.version + 1;
#ifdef OBJC_SPARSE3
arr->empty_index = oarr->empty_index;
@@ -497,17 +496,15 @@ sarray_lazy_copy(struct sarray* oarr)
#ifdef OBJC_SPARSE3
/* Copy bucket table */
- new_indices = (struct sindex**)
- objc_malloc(sizeof(struct sindex*)*num_indices);
- memcpy( new_indices,oarr->indices,
- sizeof(struct sindex*)*num_indices);
+ new_indices = (struct sindex **)
+ objc_malloc (sizeof (struct sindex *) * num_indices);
+ memcpy (new_indices, oarr->indices, sizeof (struct sindex *) * num_indices);
arr->indices = new_indices;
#else
/* Copy bucket table */
- new_buckets = (struct sbucket**)
- objc_malloc(sizeof(struct sbucket*)*num_indices);
- memcpy( new_buckets,oarr->buckets,
- sizeof(struct sbucket*)*num_indices);
+ new_buckets = (struct sbucket **)
+ objc_malloc (sizeof (struct sbucket *) * num_indices);
+ memcpy (new_buckets, oarr->buckets, sizeof (struct sbucket *) * num_indices);
arr->buckets = new_buckets;
#endif
diff --git a/contrib/libobjc/selector.c b/contrib/libobjc/selector.c
index 470a2c48cdd3..5f5a26bc9af0 100644
--- a/contrib/libobjc/selector.c
+++ b/contrib/libobjc/selector.c
@@ -1,5 +1,5 @@
/* GNU Objective C Runtime selector related functions
- Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
Contributed by Kresten Krab Thorup
This file is part of GNU CC.
@@ -31,16 +31,16 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define SELECTOR_HASH_SIZE 128
/* Tables mapping selector names to uid and opposite */
-static struct sarray* __objc_selector_array = 0; /* uid -> sel !T:MUTEX */
-static struct sarray* __objc_selector_names = 0; /* uid -> name !T:MUTEX */
+static struct sarray *__objc_selector_array = 0; /* uid -> sel !T:MUTEX */
+static struct sarray *__objc_selector_names = 0; /* uid -> name !T:MUTEX */
static cache_ptr __objc_selector_hash = 0; /* name -> uid !T:MUTEX */
-static void register_selectors_from_list(MethodList_t);
+static void register_selectors_from_list (MethodList_t);
/* Number of selectors stored in each of the above tables */
-int __objc_selector_max_index = 0; /* !T:MUTEX */
+unsigned int __objc_selector_max_index = 0; /* !T:MUTEX */
-void __objc_init_selector_tables()
+void __objc_init_selector_tables ()
{
__objc_selector_array = sarray_new (SELECTOR_HASH_SIZE, 0);
__objc_selector_names = sarray_new (SELECTOR_HASH_SIZE, 0);
@@ -81,15 +81,15 @@ register_selectors_from_list (MethodList_t method_list)
{
Method_t method = &method_list->method_list[i];
method->method_name
- = sel_register_typed_name ((const char*)method->method_name,
- method->method_types);
+ = sel_register_typed_name ((const char *) method->method_name,
+ method->method_types);
i += 1;
}
}
/* Register instance methods as class methods for root classes */
-void __objc_register_instance_methods_to_class(Class class)
+void __objc_register_instance_methods_to_class (Class class)
{
MethodList_t method_list;
MethodList_t class_method_list;
@@ -98,12 +98,12 @@ void __objc_register_instance_methods_to_class(Class class)
Method_t curr_method;
/* Only if a root class. */
- if(class->super_class)
+ if (class->super_class)
return;
/* Allocate a method list to hold the new class methods */
- new_list = objc_calloc(sizeof(struct objc_method_list)
- + sizeof(struct objc_method[max_methods_no]), 1);
+ new_list = objc_calloc (sizeof (struct objc_method_list)
+ + sizeof (struct objc_method[max_methods_no]), 1);
method_list = class->methods;
class_method_list = class->class_pointer->methods;
curr_method = &new_list->method_list[0];
@@ -118,7 +118,7 @@ void __objc_register_instance_methods_to_class(Class class)
{
Method_t mth = &method_list->method_list[i];
if (mth->method_name
- && !search_for_method_in_list (class_method_list,
+ && ! search_for_method_in_list (class_method_list,
mth->method_name))
{
/* This instance method isn't a class method.
@@ -126,10 +126,10 @@ void __objc_register_instance_methods_to_class(Class class)
*curr_method = *mth;
/* Reallocate the method list if necessary */
- if(++new_list->method_count == max_methods_no)
+ if (++new_list->method_count == max_methods_no)
new_list =
- objc_realloc(new_list, sizeof(struct objc_method_list)
- + sizeof(struct
+ objc_realloc (new_list, sizeof (struct objc_method_list)
+ + sizeof (struct
objc_method[max_methods_no += 16]));
curr_method = &new_list->method_list[new_list->method_count];
}
@@ -143,8 +143,8 @@ void __objc_register_instance_methods_to_class(Class class)
if (new_list->method_count)
{
new_list =
- objc_realloc(new_list, sizeof(struct objc_method_list)
- + sizeof(struct objc_method[new_list->method_count]));
+ objc_realloc (new_list, sizeof (struct objc_method_list)
+ + sizeof (struct objc_method[new_list->method_count]));
new_list->method_next = class->class_pointer->methods;
class->class_pointer->methods = new_list;
}
@@ -156,21 +156,21 @@ void __objc_register_instance_methods_to_class(Class class)
/* Returns YES iff t1 and t2 have same method types, but we ignore
the argframe layout */
BOOL
-sel_types_match (const char* t1, const char* t2)
+sel_types_match (const char *t1, const char *t2)
{
- if (!t1 || !t2)
+ if (! t1 || ! t2)
return NO;
while (*t1 && *t2)
{
if (*t1 == '+') t1++;
if (*t2 == '+') t2++;
- while (isdigit(*t1)) t1++;
- while (isdigit(*t2)) t2++;
+ while (isdigit ((unsigned char) *t1)) t1++;
+ while (isdigit ((unsigned char) *t2)) t2++;
/* xxx Remove these next two lines when qualifiers are put in
all selectors, not just Protocol selectors. */
- t1 = objc_skip_type_qualifiers(t1);
- t2 = objc_skip_type_qualifiers(t2);
- if (!*t1 && !*t2)
+ t1 = objc_skip_type_qualifiers (t1);
+ t2 = objc_skip_type_qualifiers (t2);
+ if (! *t1 && ! *t2)
return YES;
if (*t1 != *t2)
return NO;
@@ -187,35 +187,35 @@ sel_get_typed_uid (const char *name, const char *types)
struct objc_list *l;
sidx i;
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
i = (sidx) hash_value_for_key (__objc_selector_hash, name);
if (i == 0)
{
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
return 0;
}
- for (l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i);
+ for (l = (struct objc_list *) sarray_get_safe (__objc_selector_array, i);
l; l = l->tail)
{
- SEL s = (SEL)l->head;
+ SEL s = (SEL) l->head;
if (types == 0 || s->sel_types == 0)
{
if (s->sel_types == types)
{
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
return s;
}
}
else if (sel_types_match (s->sel_types, types))
{
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
return s;
}
}
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
return 0;
}
@@ -227,27 +227,27 @@ sel_get_any_typed_uid (const char *name)
sidx i;
SEL s = NULL;
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
i = (sidx) hash_value_for_key (__objc_selector_hash, name);
if (i == 0)
{
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
return 0;
}
- for (l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i);
+ for (l = (struct objc_list *) sarray_get_safe (__objc_selector_array, i);
l; l = l->tail)
{
s = (SEL) l->head;
if (s->sel_types)
{
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
return s;
}
}
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
return s;
}
@@ -258,22 +258,22 @@ sel_get_any_uid (const char *name)
struct objc_list *l;
sidx i;
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
i = (sidx) hash_value_for_key (__objc_selector_hash, name);
if (soffset_decode (i) == 0)
{
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
return 0;
}
- l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i);
- objc_mutex_unlock(__objc_runtime_mutex);
+ l = (struct objc_list *) sarray_get_safe (__objc_selector_array, i);
+ objc_mutex_unlock (__objc_runtime_mutex);
if (l == 0)
return 0;
- return (SEL)l->head;
+ return (SEL) l->head;
}
/* return selector representing name */
@@ -285,18 +285,17 @@ sel_get_uid (const char *name)
/* Get name of selector. If selector is unknown, the empty string ""
is returned */
-const char*
-sel_get_name (SEL selector)
+const char *sel_get_name (SEL selector)
{
const char *ret;
- objc_mutex_lock(__objc_runtime_mutex);
- if ((soffset_decode((sidx)selector->sel_id) > 0)
- && (soffset_decode((sidx)selector->sel_id) <= __objc_selector_max_index))
+ objc_mutex_lock (__objc_runtime_mutex);
+ if ((soffset_decode ((sidx)selector->sel_id) > 0)
+ && (soffset_decode ((sidx)selector->sel_id) <= __objc_selector_max_index))
ret = sarray_get_safe (__objc_selector_names, (sidx) selector->sel_id);
else
ret = 0;
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
return ret;
}
@@ -308,8 +307,7 @@ sel_is_mapped (SEL selector)
}
-const char*
-sel_get_type (SEL selector)
+const char *sel_get_type (SEL selector)
{
if (selector)
return selector->sel_types;
@@ -318,7 +316,7 @@ sel_get_type (SEL selector)
}
/* The uninstalled dispatch table */
-extern struct sarray* __objc_uninstalled_dtable;
+extern struct sarray *__objc_uninstalled_dtable;
/* Store the passed selector name in the selector record and return its
selector value (value returned by sel_get_uid).
@@ -331,35 +329,35 @@ SEL
__sel_register_typed_name (const char *name, const char *types,
struct objc_selector *orig, BOOL is_const)
{
- struct objc_selector* j;
+ struct objc_selector *j;
sidx i;
struct objc_list *l;
i = (sidx) hash_value_for_key (__objc_selector_hash, name);
if (soffset_decode (i) != 0)
{
- for (l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i);
+ for (l = (struct objc_list *) sarray_get_safe (__objc_selector_array, i);
l; l = l->tail)
{
- SEL s = (SEL)l->head;
+ SEL s = (SEL) l->head;
if (types == 0 || s->sel_types == 0)
{
if (s->sel_types == types)
{
if (orig)
{
- orig->sel_id = (void*)i;
+ orig->sel_id = (void *) i;
return orig;
}
else
return s;
}
}
- else if (!strcmp (s->sel_types, types))
+ else if (! strcmp (s->sel_types, types))
{
if (orig)
{
- orig->sel_id = (void*)i;
+ orig->sel_id = (void *) i;
return orig;
}
else
@@ -371,32 +369,32 @@ __sel_register_typed_name (const char *name, const char *types,
else
j = objc_malloc (sizeof (struct objc_selector));
- j->sel_id = (void*)i;
+ j->sel_id = (void *) i;
/* Can we use the pointer or must copy types? Don't copy if NULL */
if ((is_const) || (types == 0))
- j->sel_types = (const char*)types;
+ j->sel_types = (const char *) types;
else {
- j->sel_types = (char *) objc_malloc(strlen(types)+1);
- strcpy((char *)j->sel_types, types);
+ j->sel_types = (char *) objc_malloc (strlen (types) + 1);
+ strcpy ((char *) j->sel_types, types);
}
- l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i);
+ l = (struct objc_list *) sarray_get_safe (__objc_selector_array, i);
}
else
{
__objc_selector_max_index += 1;
- i = soffset_encode(__objc_selector_max_index);
+ i = soffset_encode (__objc_selector_max_index);
if (orig)
j = orig;
else
j = objc_malloc (sizeof (struct objc_selector));
- j->sel_id = (void*)i;
+ j->sel_id = (void *) i;
/* Can we use the pointer or must copy types? Don't copy if NULL */
if ((is_const) || (types == 0))
- j->sel_types = (const char*)types;
+ j->sel_types = (const char *) types;
else {
- j->sel_types = (char *) objc_malloc(strlen(types)+1);
- strcpy((char *)j->sel_types, types);
+ j->sel_types = (char *) objc_malloc (strlen (types) + 1);
+ strcpy ((char *) j->sel_types, types);
}
l = 0;
}
@@ -412,18 +410,18 @@ __sel_register_typed_name (const char *name, const char *types,
if ((is_const) || (name == 0))
new_name = name;
else {
- new_name = (char *) objc_malloc(strlen(name)+1);
- strcpy((char *)new_name, name);
+ new_name = (char *) objc_malloc (strlen (name) + 1);
+ strcpy ((char *) new_name, name);
}
- l = list_cons ((void*)j, l);
+ l = list_cons ((void *) j, l);
sarray_at_put_safe (__objc_selector_names, i, (void *) new_name);
sarray_at_put_safe (__objc_selector_array, i, (void *) l);
if (is_new)
hash_add (&__objc_selector_hash, (void *) new_name, (void *) i);
}
- sarray_realloc(__objc_uninstalled_dtable, __objc_selector_max_index+1);
+ sarray_realloc (__objc_uninstalled_dtable, __objc_selector_max_index + 1);
return (SEL) j;
}
@@ -433,11 +431,11 @@ sel_register_name (const char *name)
{
SEL ret;
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
/* Assume that name is not constant static memory and needs to be
copied before put into a runtime structure. is_const == NO */
ret = __sel_register_typed_name (name, 0, 0, NO);
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
return ret;
}
@@ -447,12 +445,11 @@ sel_register_typed_name (const char *name, const char *type)
{
SEL ret;
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
/* Assume that name and type are not constant static memory and need to
be copied before put into a runtime structure. is_const == NO */
ret = __sel_register_typed_name (name, type, 0, NO);
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
return ret;
}
-
diff --git a/contrib/libobjc/sendmsg.c b/contrib/libobjc/sendmsg.c
index 61fa28833b30..6ef711b50d35 100644
--- a/contrib/libobjc/sendmsg.c
+++ b/contrib/libobjc/sendmsg.c
@@ -1,6 +1,6 @@
/* GNU Objective C Runtime message lookup
Copyright (C) 1993, 1995, 1996, 1997, 1998,
- 2001 Free Software Foundation, Inc.
+ 2001, 2002 Free Software Foundation, Inc.
Contributed by Kresten Krab Thorup
This file is part of GNU CC.
@@ -37,27 +37,27 @@ Boston, MA 02111-1307, USA. */
#define gen_rtx_REG(args...) 1
#define rtx int
-#if !defined(STRUCT_VALUE) || STRUCT_VALUE == 0
+#if ! defined (STRUCT_VALUE) || STRUCT_VALUE == 0
#define INVISIBLE_STRUCT_RETURN 1
#else
#define INVISIBLE_STRUCT_RETURN 0
#endif
/* The uninstalled dispatch table */
-struct sarray* __objc_uninstalled_dtable = 0; /* !T:MUTEX */
+struct sarray *__objc_uninstalled_dtable = 0; /* !T:MUTEX */
/* Hook for method forwarding. If it is set, is invoked to return a
function that performs the real forwarding. Otherwise the libgcc
based functions (__builtin_apply and friends) are used. */
-IMP (*__objc_msg_forward)(SEL) = NULL;
+IMP (*__objc_msg_forward) (SEL) = NULL;
/* Send +initialize to class */
-static void __objc_send_initialize(Class);
+static void __objc_send_initialize (Class);
static void __objc_install_dispatch_table_for_class (Class);
/* Forward declare some functions */
-static void __objc_init_install_dtable(id, SEL);
+static void __objc_init_install_dtable (id, SEL);
/* Various forwarding functions that are used based upon the
return type for the selector.
@@ -65,37 +65,41 @@ static void __objc_init_install_dtable(id, SEL);
__objc_double_forward for floats/doubles.
__objc_word_forward for pointers or types that fit in registers.
*/
-static double __objc_double_forward(id, SEL, ...);
-static id __objc_word_forward(id, SEL, ...);
+static double __objc_double_forward (id, SEL, ...);
+static id __objc_word_forward (id, SEL, ...);
typedef struct { id many[8]; } __big;
#if INVISIBLE_STRUCT_RETURN
static __big
#else
static id
#endif
-__objc_block_forward(id, SEL, ...);
+__objc_block_forward (id, SEL, ...);
static Method_t search_for_method_in_hierarchy (Class class, SEL sel);
-Method_t search_for_method_in_list(MethodList_t list, SEL op);
-id nil_method(id, SEL, ...);
+Method_t search_for_method_in_list (MethodList_t list, SEL op);
+id nil_method (id, SEL);
/* Given a selector, return the proper forwarding implementation. */
__inline__
IMP
__objc_get_forward_imp (SEL sel)
{
+ /* If a custom forwarding hook was registered, try getting a forwarding
+ * function from it. */
if (__objc_msg_forward)
{
IMP result;
- if ((result = __objc_msg_forward (sel)))
+ if ((result = __objc_msg_forward (sel)) != NULL)
return result;
}
- else
+
+ /* In all other cases, use the default forwarding functions built using
+ * __builtin_apply and friends. */
{
const char *t = sel->sel_types;
if (t && (*t == '[' || *t == '(' || *t == '{')
#ifdef OBJC_MAX_STRUCT_BY_VALUE
- && objc_sizeof_type(t) > OBJC_MAX_STRUCT_BY_VALUE
+ && objc_sizeof_type (t) > OBJC_MAX_STRUCT_BY_VALUE
#endif
)
return (IMP)__objc_block_forward;
@@ -111,26 +115,26 @@ __inline__
IMP
get_imp (Class class, SEL sel)
{
- void* res = sarray_get_safe (class->dtable, (size_t) sel->sel_id);
+ void *res = sarray_get_safe (class->dtable, (size_t) sel->sel_id);
if (res == 0)
{
/* Not a valid method */
- if(class->dtable == __objc_uninstalled_dtable)
+ if (class->dtable == __objc_uninstalled_dtable)
{
/* The dispatch table needs to be installed. */
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
__objc_install_dispatch_table_for_class (class);
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
/* Call ourselves with the installed dispatch table
and get the real method */
- res = get_imp(class, sel);
+ res = get_imp (class, sel);
}
else
{
/* The dispatch table has been installed so the
method just doesn't exist for the class.
Return the forwarding implementation. */
- res = __objc_get_forward_imp(sel);
+ res = __objc_get_forward_imp (sel);
}
}
return res;
@@ -143,14 +147,14 @@ __inline__
BOOL
__objc_responds_to (id object, SEL sel)
{
- void* res;
+ void *res;
/* Install dispatch table if need be */
if (object->class_pointer->dtable == __objc_uninstalled_dtable)
{
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
__objc_install_dispatch_table_for_class (object->class_pointer);
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
}
/* Get the method from the dispatch table */
@@ -163,37 +167,37 @@ __objc_responds_to (id object, SEL sel)
needs to be installed or it doesn't exist and forwarding is attempted. */
__inline__
IMP
-objc_msg_lookup(id receiver, SEL op)
+objc_msg_lookup (id receiver, SEL op)
{
IMP result;
- if(receiver)
+ if (receiver)
{
result = sarray_get_safe (receiver->class_pointer->dtable,
(sidx)op->sel_id);
if (result == 0)
{
/* Not a valid method */
- if(receiver->class_pointer->dtable == __objc_uninstalled_dtable)
+ if (receiver->class_pointer->dtable == __objc_uninstalled_dtable)
{
/* The dispatch table needs to be installed.
This happens on the very first method call to the class. */
- __objc_init_install_dtable(receiver, op);
+ __objc_init_install_dtable (receiver, op);
/* Get real method for this in newly installed dtable */
- result = get_imp(receiver->class_pointer, op);
+ result = get_imp (receiver->class_pointer, op);
}
else
{
/* The dispatch table has been installed so the
method just doesn't exist for the class.
Attempt to forward the method. */
- result = __objc_get_forward_imp(op);
+ result = __objc_get_forward_imp (op);
}
}
return result;
}
else
- return nil_method;
+ return (IMP)nil_method;
}
IMP
@@ -202,96 +206,95 @@ objc_msg_lookup_super (Super_t super, SEL sel)
if (super->self)
return get_imp (super->class, sel);
else
- return nil_method;
+ return (IMP)nil_method;
}
-int method_get_sizeof_arguments (Method*);
+int method_get_sizeof_arguments (Method *);
retval_t
-objc_msg_sendv(id object, SEL op, arglist_t arg_frame)
+objc_msg_sendv (id object, SEL op, arglist_t arg_frame)
{
- Method* m = class_get_instance_method(object->class_pointer, op);
+ Method *m = class_get_instance_method (object->class_pointer, op);
const char *type;
- *((id*)method_get_first_argument (m, arg_frame, &type)) = object;
- *((SEL*)method_get_next_argument (arg_frame, &type)) = op;
- return __builtin_apply((apply_t)m->method_imp,
- arg_frame,
- method_get_sizeof_arguments (m));
+ *((id *) method_get_first_argument (m, arg_frame, &type)) = object;
+ *((SEL *) method_get_next_argument (arg_frame, &type)) = op;
+ return __builtin_apply ((apply_t) m->method_imp,
+ arg_frame,
+ method_get_sizeof_arguments (m));
}
void
-__objc_init_dispatch_tables()
+__objc_init_dispatch_tables ()
{
- __objc_uninstalled_dtable
- = sarray_new(200, 0);
+ __objc_uninstalled_dtable = sarray_new (200, 0);
}
/* This function is called by objc_msg_lookup when the
dispatch table needs to be installed; thus it is called once
for each class, namely when the very first message is sent to it. */
static void
-__objc_init_install_dtable(id receiver, SEL op)
+__objc_init_install_dtable (id receiver, SEL op __attribute__ ((__unused__)))
{
/* This may happen, if the programmer has taken the address of a
method before the dtable was initialized... too bad for him! */
- if(receiver->class_pointer->dtable != __objc_uninstalled_dtable)
+ if (receiver->class_pointer->dtable != __objc_uninstalled_dtable)
return;
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
- if(CLS_ISCLASS(receiver->class_pointer))
+ if (CLS_ISCLASS (receiver->class_pointer))
{
/* receiver is an ordinary object */
- assert(CLS_ISCLASS(receiver->class_pointer));
+ assert (CLS_ISCLASS (receiver->class_pointer));
/* install instance methods table */
__objc_install_dispatch_table_for_class (receiver->class_pointer);
/* call +initialize -- this will in turn install the factory
dispatch table if not already done :-) */
- __objc_send_initialize(receiver->class_pointer);
+ __objc_send_initialize (receiver->class_pointer);
}
else
{
/* receiver is a class object */
- assert(CLS_ISCLASS((Class)receiver));
- assert(CLS_ISMETA(receiver->class_pointer));
+ assert (CLS_ISCLASS ((Class)receiver));
+ assert (CLS_ISMETA (receiver->class_pointer));
/* Install real dtable for factory methods */
__objc_install_dispatch_table_for_class (receiver->class_pointer);
- __objc_send_initialize((Class)receiver);
+ __objc_send_initialize ((Class)receiver);
}
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
}
/* Install dummy table for class which causes the first message to
that class (or instances hereof) to be initialized properly */
void
-__objc_install_premature_dtable(Class class)
+__objc_install_premature_dtable (Class class)
{
- assert(__objc_uninstalled_dtable);
+ assert (__objc_uninstalled_dtable);
class->dtable = __objc_uninstalled_dtable;
}
/* Send +initialize to class if not already done */
static void
-__objc_send_initialize(Class class)
+__objc_send_initialize (Class class)
{
/* This *must* be a class object */
- assert(CLS_ISCLASS(class));
- assert(!CLS_ISMETA(class));
+ assert (CLS_ISCLASS (class));
+ assert (! CLS_ISMETA (class));
- if (!CLS_ISINITIALIZED(class))
+ if (! CLS_ISINITIALIZED (class))
{
- CLS_SETINITIALIZED(class);
- CLS_SETINITIALIZED(class->class_pointer);
+ CLS_SETINITIALIZED (class);
+ CLS_SETINITIALIZED (class->class_pointer);
/* Create the garbage collector type memory description */
__objc_generate_gc_type_description (class);
- if(class->super_class)
- __objc_send_initialize(class->super_class);
+ if (class->super_class)
+ __objc_send_initialize (class->super_class);
{
SEL op = sel_register_name ("initialize");
@@ -302,7 +305,7 @@ __objc_send_initialize(Class class)
int i;
Method_t method;
- for (i = 0; i< method_list->method_count; i++) {
+ for (i = 0; i < method_list->method_count; i++) {
method = &(method_list->method_list[i]);
if (method->method_name
&& method->method_name->sel_id == op->sel_id) {
@@ -318,7 +321,7 @@ __objc_send_initialize(Class class)
}
if (imp)
- (*imp)((id)class, op);
+ (*imp) ((id) class, op);
}
}
@@ -335,7 +338,7 @@ __objc_install_methods_in_dtable (Class class, MethodList_t method_list)
{
int i;
- if (!method_list)
+ if (! method_list)
return;
if (method_list->method_next)
@@ -358,8 +361,8 @@ __objc_install_dispatch_table_for_class (Class class)
/* If the class has not yet had its class links resolved, we must
re-compute all class links */
- if(!CLS_ISRESOLV(class))
- __objc_resolve_class_links();
+ if (! CLS_ISRESOLV (class))
+ __objc_resolve_class_links ();
super = class->super_class;
@@ -369,9 +372,9 @@ __objc_install_dispatch_table_for_class (Class class)
/* Allocate dtable if necessary */
if (super == 0)
{
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
class->dtable = sarray_new (__objc_selector_max_index, 0);
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
}
else
class->dtable = sarray_lazy_copy (super->dtable);
@@ -389,7 +392,7 @@ __objc_update_dispatch_table_for_class (Class class)
if (class->dtable == __objc_uninstalled_dtable)
return;
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
arr = class->dtable;
__objc_install_premature_dtable (class); /* someone might require it... */
@@ -402,7 +405,7 @@ __objc_update_dispatch_table_for_class (Class class)
for (next = class->subclass_list; next; next = next->sibling_class)
__objc_update_dispatch_table_for_class (next);
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
}
@@ -419,7 +422,7 @@ class_add_method_list (Class class, MethodList_t list)
int i;
/* Passing of a linked list is not allowed. Do multiple calls. */
- assert (!list->method_next);
+ assert (! list->method_next);
/* Check for duplicates. */
for (i = 0; i < list->method_count; ++i)
@@ -430,7 +433,7 @@ class_add_method_list (Class class, MethodList_t list)
{
/* This is where selector names are transmogrified to SEL's */
method->method_name =
- sel_register_typed_name ((const char*)method->method_name,
+ sel_register_typed_name ((const char *) method->method_name,
method->method_types);
}
}
@@ -444,15 +447,15 @@ class_add_method_list (Class class, MethodList_t list)
}
Method_t
-class_get_instance_method(Class class, SEL op)
+class_get_instance_method (Class class, SEL op)
{
- return search_for_method_in_hierarchy(class, op);
+ return search_for_method_in_hierarchy (class, op);
}
Method_t
-class_get_class_method(MetaClass class, SEL op)
+class_get_class_method (MetaClass class, SEL op)
{
- return search_for_method_in_hierarchy(class, op);
+ return search_for_method_in_hierarchy (class, op);
}
@@ -576,13 +579,13 @@ __objc_forward (id object, SEL sel, arglist_t args)
SEL err_sel;
/* first try if the object understands forward:: */
- if (!frwd_sel)
- frwd_sel = sel_get_any_uid("forward::");
+ if (! frwd_sel)
+ frwd_sel = sel_get_any_uid ("forward::");
if (__objc_responds_to (object, frwd_sel))
{
- imp = get_imp(object->class_pointer, frwd_sel);
- return (*imp)(object, frwd_sel, sel, args);
+ imp = get_imp (object->class_pointer, frwd_sel);
+ return (*imp) (object, frwd_sel, sel, args);
}
/* If the object recognizes the doesNotRecognize: method then we're going
@@ -597,11 +600,11 @@ __objc_forward (id object, SEL sel, arglist_t args)
/* The object doesn't recognize the method. Check for responding to
error:. If it does then sent it. */
{
- char msg[256 + strlen ((const char*)sel_get_name (sel))
- + strlen ((const char*)object->class_pointer->name)];
+ char msg[256 + strlen ((const char *) sel_get_name (sel))
+ + strlen ((const char *) object->class_pointer->name)];
sprintf (msg, "(%s) %s does not recognize %s",
- (CLS_ISMETA(object->class_pointer)
+ (CLS_ISMETA (object->class_pointer)
? "class"
: "instance" ),
object->class_pointer->name, sel_get_name (sel));
@@ -622,40 +625,41 @@ __objc_forward (id object, SEL sel, arglist_t args)
}
void
-__objc_print_dtable_stats()
+__objc_print_dtable_stats ()
{
int total = 0;
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
#ifdef OBJC_SPARSE2
- printf("memory usage: (%s)\n", "2-level sparse arrays");
+ printf ("memory usage: (%s)\n", "2-level sparse arrays");
#else
- printf("memory usage: (%s)\n", "3-level sparse arrays");
+ printf ("memory usage: (%s)\n", "3-level sparse arrays");
#endif
- printf("arrays: %d = %ld bytes\n", narrays,
- (long)narrays*sizeof(struct sarray));
- total += narrays*sizeof(struct sarray);
- printf("buckets: %d = %ld bytes\n", nbuckets,
- (long)nbuckets*sizeof(struct sbucket));
- total += nbuckets*sizeof(struct sbucket);
-
- printf("idxtables: %d = %ld bytes\n", idxsize, (long)idxsize*sizeof(void*));
- total += idxsize*sizeof(void*);
- printf("-----------------------------------\n");
- printf("total: %d bytes\n", total);
- printf("===================================\n");
-
- objc_mutex_unlock(__objc_runtime_mutex);
+ printf ("arrays: %d = %ld bytes\n", narrays,
+ (long) narrays * sizeof (struct sarray));
+ total += narrays * sizeof (struct sarray);
+ printf ("buckets: %d = %ld bytes\n", nbuckets,
+ (long) nbuckets * sizeof (struct sbucket));
+ total += nbuckets * sizeof (struct sbucket);
+
+ printf ("idxtables: %d = %ld bytes\n",
+ idxsize, (long) idxsize * sizeof (void *));
+ total += idxsize * sizeof (void *);
+ printf ("-----------------------------------\n");
+ printf ("total: %d bytes\n", total);
+ printf ("===================================\n");
+
+ objc_mutex_unlock (__objc_runtime_mutex);
}
/* Returns the uninstalled dispatch table indicator.
If a class' dispatch table points to __objc_uninstalled_dtable
then that means it needs its dispatch table to be installed. */
__inline__
-struct sarray*
-objc_get_uninstalled_dtable()
+struct sarray *
+objc_get_uninstalled_dtable ()
{
return __objc_uninstalled_dtable;
}
diff --git a/contrib/libobjc/thr-mach.c b/contrib/libobjc/thr-mach.c
index 44af0c1e2869..e95460746d11 100644
--- a/contrib/libobjc/thr-mach.c
+++ b/contrib/libobjc/thr-mach.c
@@ -1,5 +1,5 @@
/* GNU Objective C Runtime Thread Implementation
- Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 2002 Free Software Foundation, Inc.
Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
Modified for Mach threads by Bill Bumgarner <bbum@friday.com>
Condition functions added by Mircea Oancea <mircea@first.elcom.pub.ro>
@@ -37,7 +37,8 @@ Boston, MA 02111-1307, USA. */
maximum priority downward only-- cannot be raised without superuser
privileges. Once lowered, it cannot be raised.
*/
-static int __mach_get_max_thread_priority(cthread_t t, int *base)
+static int
+__mach_get_max_thread_priority (cthread_t t, int *base)
{
thread_t threadP;
kern_return_t error;
@@ -47,10 +48,10 @@ static int __mach_get_max_thread_priority(cthread_t t, int *base)
if (t == NULL)
return -1;
- threadP = cthread_thread(t); /* get thread underlying */
+ threadP = cthread_thread (t); /* get thread underlying */
- error=thread_info(threadP, THREAD_SCHED_INFO,
- (thread_info_t)&info, &info_count);
+ error = thread_info (threadP, THREAD_SCHED_INFO,
+ (thread_info_t) &info, &info_count);
if (error != KERN_SUCCESS)
return -1;
@@ -65,14 +66,14 @@ static int __mach_get_max_thread_priority(cthread_t t, int *base)
/* Initialize the threads subsystem. */
int
-__objc_init_thread_system(void)
+__objc_init_thread_system (void)
{
return 0;
}
/* Close the threads subsystem. */
int
-__objc_close_thread_system(void)
+__objc_close_thread_system (void)
{
return 0;
}
@@ -81,19 +82,19 @@ __objc_close_thread_system(void)
/* Create a new thread of execution. */
objc_thread_t
-__objc_thread_detach(void (*func)(void *arg), void *arg)
+__objc_thread_detach (void (*func) (void *arg), void *arg)
{
objc_thread_t thread_id;
cthread_t new_thread_handle;
/* create thread */
- new_thread_handle = cthread_fork((cthread_fn_t)func, arg);
+ new_thread_handle = cthread_fork ((cthread_fn_t) func, arg);
- if(new_thread_handle)
+ if (new_thread_handle)
{
/* this is not terribly portable */
- thread_id = *(objc_thread_t *)&new_thread_handle;
- cthread_detach(new_thread_handle);
+ thread_id = *(objc_thread_t *) &new_thread_handle;
+ cthread_detach (new_thread_handle);
}
else
thread_id = NULL;
@@ -103,11 +104,11 @@ __objc_thread_detach(void (*func)(void *arg), void *arg)
/* Set the current thread's priority. */
int
-__objc_thread_set_priority(int priority)
+__objc_thread_set_priority (int priority)
{
- objc_thread_t *t = objc_thread_id();
+ objc_thread_t *t = objc_thread_id ();
cthread_t cT = (cthread_t) t;
- int maxPriority = __mach_get_max_thread_priority(cT, NULL);
+ int maxPriority = __mach_get_max_thread_priority (cT, NULL);
int sys_priority = 0;
if (maxPriority == -1)
@@ -132,7 +133,7 @@ __objc_thread_set_priority(int priority)
return -1;
/* Change the priority */
- if (cthread_priority(cT, sys_priority, 0) == KERN_SUCCESS)
+ if (cthread_priority (cT, sys_priority, 0) == KERN_SUCCESS)
return 0;
else
return -1;
@@ -140,19 +141,19 @@ __objc_thread_set_priority(int priority)
/* Return the current thread's priority. */
int
-__objc_thread_get_priority(void)
+__objc_thread_get_priority (void)
{
- objc_thread_t *t = objc_thread_id();
- cthread_t cT = (cthread_t) t; /* see objc_thread_id() */
+ objc_thread_t *t = objc_thread_id ();
+ cthread_t cT = (cthread_t) t; /* see objc_thread_id () */
int basePriority;
int maxPriority;
int sys_priority = 0;
int interactiveT, backgroundT, lowT; /* thresholds */
- maxPriority = __mach_get_max_thread_priority(cT, &basePriority);
+ maxPriority = __mach_get_max_thread_priority (cT, &basePriority);
- if(maxPriority == -1)
+ if (maxPriority == -1)
return -1;
if (basePriority > ( (maxPriority * 2) / 3))
@@ -166,17 +167,17 @@ __objc_thread_get_priority(void)
/* Yield our process time to another thread. */
void
-__objc_thread_yield(void)
+__objc_thread_yield (void)
{
- cthread_yield();
+ cthread_yield ();
}
/* Terminate the current thread. */
int
-__objc_thread_exit(void)
+__objc_thread_exit (void)
{
/* exit the thread */
- cthread_exit(&__objc_thread_exit_status);
+ cthread_exit (&__objc_thread_exit_status);
/* Failed if we reached here */
return -1;
@@ -184,42 +185,42 @@ __objc_thread_exit(void)
/* Returns an integer value which uniquely describes a thread. */
objc_thread_t
-__objc_thread_id(void)
+__objc_thread_id (void)
{
- cthread_t self = cthread_self();
+ cthread_t self = cthread_self ();
- return *(objc_thread_t *)&self;
+ return *(objc_thread_t *) &self;
}
/* Sets the thread's local storage pointer. */
int
-__objc_thread_set_data(void *value)
+__objc_thread_set_data (void *value)
{
- cthread_set_data(cthread_self(), (any_t) value);
+ cthread_set_data (cthread_self (), (any_t) value);
return 0;
}
/* Returns the thread's local storage pointer. */
void *
-__objc_thread_get_data(void)
+__objc_thread_get_data (void)
{
- return (void *) cthread_data(cthread_self());
+ return (void *) cthread_data (cthread_self ());
}
/* Backend mutex functions */
/* Allocate a mutex. */
int
-__objc_mutex_allocate(objc_mutex_t mutex)
+__objc_mutex_allocate (objc_mutex_t mutex)
{
int err = 0;
- mutex->backend = objc_malloc(sizeof(struct mutex));
+ mutex->backend = objc_malloc (sizeof (struct mutex));
- err = mutex_init((mutex_t)(mutex->backend));
+ err = mutex_init ((mutex_t) (mutex->backend));
if (err != 0)
{
- objc_free(mutex->backend);
+ objc_free (mutex->backend);
return -1;
}
else
@@ -228,28 +229,28 @@ __objc_mutex_allocate(objc_mutex_t mutex)
/* Deallocate a mutex. */
int
-__objc_mutex_deallocate(objc_mutex_t mutex)
+__objc_mutex_deallocate (objc_mutex_t mutex)
{
- mutex_clear((mutex_t)(mutex->backend));
+ mutex_clear ((mutex_t) (mutex->backend));
- objc_free(mutex->backend);
+ objc_free (mutex->backend);
mutex->backend = NULL;
return 0;
}
/* Grab a lock on a mutex. */
int
-__objc_mutex_lock(objc_mutex_t mutex)
+__objc_mutex_lock (objc_mutex_t mutex)
{
- mutex_lock((mutex_t)(mutex->backend));
+ mutex_lock ((mutex_t) (mutex->backend));
return 0;
}
/* Try to grab a lock on a mutex. */
int
-__objc_mutex_trylock(objc_mutex_t mutex)
+__objc_mutex_trylock (objc_mutex_t mutex)
{
- if (mutex_try_lock((mutex_t)(mutex->backend)) == 0)
+ if (mutex_try_lock ((mutex_t) (mutex->backend)) == 0)
return -1;
else
return 0;
@@ -257,9 +258,9 @@ __objc_mutex_trylock(objc_mutex_t mutex)
/* Unlock the mutex */
int
-__objc_mutex_unlock(objc_mutex_t mutex)
+__objc_mutex_unlock (objc_mutex_t mutex)
{
- mutex_unlock((mutex_t)(mutex->backend));
+ mutex_unlock ((mutex_t) (mutex->backend));
return 0;
}
@@ -267,45 +268,45 @@ __objc_mutex_unlock(objc_mutex_t mutex)
/* Allocate a condition. */
int
-__objc_condition_allocate(objc_condition_t condition)
+__objc_condition_allocate (objc_condition_t condition)
{
- condition->backend = objc_malloc(sizeof(struct condition));
- condition_init((condition_t)(condition->backend));
+ condition->backend = objc_malloc (sizeof (struct condition));
+ condition_init ((condition_t) (condition->backend));
return 0;
}
/* Deallocate a condition. */
int
-__objc_condition_deallocate(objc_condition_t condition)
+__objc_condition_deallocate (objc_condition_t condition)
{
- condition_clear((condition_t)(condition->backend));
- objc_free(condition->backend);
+ condition_clear ((condition_t) (condition->backend));
+ objc_free (condition->backend);
condition->backend = NULL;
return 0;
}
/* Wait on the condition */
int
-__objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex)
+__objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
{
- condition_wait((condition_t)(condition->backend),
- (mutex_t)(mutex->backend));
+ condition_wait ((condition_t) (condition->backend),
+ (mutex_t) (mutex->backend));
return 0;
}
/* Wake up all threads waiting on this condition. */
int
-__objc_condition_broadcast(objc_condition_t condition)
+__objc_condition_broadcast (objc_condition_t condition)
{
- condition_broadcast((condition_t)(condition->backend));
+ condition_broadcast ((condition_t) (condition->backend));
return 0;
}
/* Wake up one thread waiting on this condition. */
int
-__objc_condition_signal(objc_condition_t condition)
+__objc_condition_signal (objc_condition_t condition)
{
- condition_signal((condition_t)(condition->backend));
+ condition_signal ((condition_t) (condition->backend));
return 0;
}
diff --git a/contrib/libobjc/thr.c b/contrib/libobjc/thr.c
index 13a22a5685f2..bc94473ce684 100644
--- a/contrib/libobjc/thr.c
+++ b/contrib/libobjc/thr.c
@@ -48,7 +48,7 @@ objc_thread_callback _objc_became_multi_threaded = NULL;
it can be informed; for example, the GNUstep Base Library sets it
so it can implement the NSBecomingMultiThreaded notification.
*/
-objc_thread_callback objc_set_thread_callback(objc_thread_callback func)
+objc_thread_callback objc_set_thread_callback (objc_thread_callback func)
{
objc_thread_callback temp = _objc_became_multi_threaded;
_objc_became_multi_threaded = func;
@@ -76,44 +76,44 @@ struct __objc_thread_start_state
};
static volatile void
-__objc_thread_detach_function(struct __objc_thread_start_state *istate)
+__objc_thread_detach_function (struct __objc_thread_start_state *istate)
{
/* Valid state? */
if (istate) {
- id (*imp)(id,SEL,id);
+ id (*imp) (id, SEL, id);
SEL selector = istate->selector;
id object = istate->object;
id argument = istate->argument;
/* Don't need anymore so free it */
- objc_free(istate);
+ objc_free (istate);
/* Clear out the thread local storage */
- objc_thread_set_data(NULL);
+ objc_thread_set_data (NULL);
/* Check to see if we just became multi threaded */
- if (!__objc_is_multi_threaded)
+ if (! __objc_is_multi_threaded)
{
__objc_is_multi_threaded = 1;
/* Call the hook function */
if (_objc_became_multi_threaded != NULL)
- (*_objc_became_multi_threaded)();
+ (*_objc_became_multi_threaded) ();
}
/* Call the method */
- if ((imp = (id(*)(id, SEL, id))objc_msg_lookup(object, selector)))
- (*imp)(object, selector, argument);
+ if ((imp = (id (*) (id, SEL, id))objc_msg_lookup (object, selector)))
+ (*imp) (object, selector, argument);
else
- objc_error(object, OBJC_ERR_UNIMPLEMENTED,
- "objc_thread_detach called with bad selector.\n");
+ objc_error (object, OBJC_ERR_UNIMPLEMENTED,
+ "objc_thread_detach called with bad selector.\n");
}
else
- objc_error(nil, OBJC_ERR_BAD_STATE,
- "objc_thread_detach called with NULL state.\n");
+ objc_error (nil, OBJC_ERR_BAD_STATE,
+ "objc_thread_detach called with NULL state.\n");
/* Exit the thread */
- objc_thread_exit();
+ objc_thread_exit ();
}
/*
@@ -131,14 +131,14 @@ __objc_thread_detach_function(struct __objc_thread_start_state *istate)
takes a single argument.
*/
objc_thread_t
-objc_thread_detach(SEL selector, id object, id argument)
+objc_thread_detach (SEL selector, id object, id argument)
{
struct __objc_thread_start_state *istate;
objc_thread_t thread_id = NULL;
/* Allocate the state structure */
- if (!(istate = (struct __objc_thread_start_state *)
- objc_malloc(sizeof(*istate))))
+ if (! (istate = (struct __objc_thread_start_state *)
+ objc_malloc (sizeof (*istate))))
return NULL;
/* Initialize the state structure */
@@ -147,39 +147,39 @@ objc_thread_detach(SEL selector, id object, id argument)
istate->argument = argument;
/* lock access */
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
/* Call the backend to spawn the thread */
- if ((thread_id = __objc_thread_detach((void *)__objc_thread_detach_function,
- istate)) == NULL)
+ if ((thread_id = __objc_thread_detach ((void *)__objc_thread_detach_function,
+ istate)) == NULL)
{
/* failed! */
- objc_mutex_unlock(__objc_runtime_mutex);
- objc_free(istate);
+ objc_mutex_unlock (__objc_runtime_mutex);
+ objc_free (istate);
return NULL;
}
/* Increment our thread counter */
__objc_runtime_threads_alive++;
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
return thread_id;
}
/* Set the current thread's priority. */
int
-objc_thread_set_priority(int priority)
+objc_thread_set_priority (int priority)
{
/* Call the backend */
- return __objc_thread_set_priority(priority);
+ return __objc_thread_set_priority (priority);
}
/* Return the current thread's priority. */
int
-objc_thread_get_priority(void)
+objc_thread_get_priority (void)
{
/* Call the backend */
- return __objc_thread_get_priority();
+ return __objc_thread_get_priority ();
}
/*
@@ -188,10 +188,10 @@ objc_thread_get_priority(void)
make progress even on a lazy uniprocessor system.
*/
void
-objc_thread_yield(void)
+objc_thread_yield (void)
{
/* Call the backend */
- __objc_thread_yield();
+ __objc_thread_yield ();
}
/*
@@ -199,15 +199,15 @@ objc_thread_yield(void)
Actually, if it failed returns -1.
*/
int
-objc_thread_exit(void)
+objc_thread_exit (void)
{
/* Decrement our counter of the number of threads alive */
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
__objc_runtime_threads_alive--;
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
/* Call the backend to terminate the thread */
- return __objc_thread_exit();
+ return __objc_thread_exit ();
}
/*
@@ -215,10 +215,10 @@ objc_thread_exit(void)
NULL which is reserved as a marker for "no thread".
*/
objc_thread_t
-objc_thread_id(void)
+objc_thread_id (void)
{
/* Call the backend */
- return __objc_thread_id();
+ return __objc_thread_id ();
}
/*
@@ -226,20 +226,20 @@ objc_thread_id(void)
Returns 0 if successful or -1 if failed.
*/
int
-objc_thread_set_data(void *value)
+objc_thread_set_data (void *value)
{
/* Call the backend */
- return __objc_thread_set_data(value);
+ return __objc_thread_set_data (value);
}
/*
Returns the thread's local storage pointer. Returns NULL on failure.
*/
void *
-objc_thread_get_data(void)
+objc_thread_get_data (void)
{
/* Call the backend */
- return __objc_thread_get_data();
+ return __objc_thread_get_data ();
}
/* Frontend mutex functions */
@@ -249,19 +249,19 @@ objc_thread_get_data(void)
allocation failed for any reason.
*/
objc_mutex_t
-objc_mutex_allocate(void)
+objc_mutex_allocate (void)
{
objc_mutex_t mutex;
/* Allocate the mutex structure */
- if (!(mutex = (objc_mutex_t)objc_malloc(sizeof(struct objc_mutex))))
+ if (! (mutex = (objc_mutex_t)objc_malloc (sizeof (struct objc_mutex))))
return NULL;
/* Call backend to create the mutex */
- if (__objc_mutex_allocate(mutex))
+ if (__objc_mutex_allocate (mutex))
{
/* failed! */
- objc_free(mutex);
+ objc_free (mutex);
return NULL;
}
@@ -279,23 +279,23 @@ objc_mutex_allocate(void)
Returns the number of locks on the thread. (1 for deallocate).
*/
int
-objc_mutex_deallocate(objc_mutex_t mutex)
+objc_mutex_deallocate (objc_mutex_t mutex)
{
int depth;
/* Valid mutex? */
- if (!mutex)
+ if (! mutex)
return -1;
/* Acquire lock on mutex */
- depth = objc_mutex_lock(mutex);
+ depth = objc_mutex_lock (mutex);
/* Call backend to destroy mutex */
- if (__objc_mutex_deallocate(mutex))
+ if (__objc_mutex_deallocate (mutex))
return -1;
/* Free the mutex structure */
- objc_free(mutex);
+ objc_free (mutex);
/* Return last depth */
return depth;
@@ -308,22 +308,22 @@ objc_mutex_deallocate(objc_mutex_t mutex)
Returns the lock count on the mutex held by this thread.
*/
int
-objc_mutex_lock(objc_mutex_t mutex)
+objc_mutex_lock (objc_mutex_t mutex)
{
objc_thread_t thread_id;
int status;
/* Valid mutex? */
- if (!mutex)
+ if (! mutex)
return -1;
/* If we already own the lock then increment depth */
- thread_id = __objc_thread_id();
+ thread_id = __objc_thread_id ();
if (mutex->owner == thread_id)
return ++mutex->depth;
/* Call the backend to lock the mutex */
- status = __objc_mutex_lock(mutex);
+ status = __objc_mutex_lock (mutex);
/* Failed? */
if (status)
@@ -340,22 +340,22 @@ objc_mutex_lock(objc_mutex_t mutex)
thread has a lock on the mutex returns -1.
*/
int
-objc_mutex_trylock(objc_mutex_t mutex)
+objc_mutex_trylock (objc_mutex_t mutex)
{
objc_thread_t thread_id;
int status;
/* Valid mutex? */
- if (!mutex)
+ if (! mutex)
return -1;
/* If we already own the lock then increment depth */
- thread_id = __objc_thread_id();
+ thread_id = __objc_thread_id ();
if (mutex->owner == thread_id)
return ++mutex->depth;
/* Call the backend to try to lock the mutex */
- status = __objc_mutex_trylock(mutex);
+ status = __objc_mutex_trylock (mutex);
/* Failed? */
if (status)
@@ -375,17 +375,17 @@ objc_mutex_trylock(objc_mutex_t mutex)
doesn't hold in which case return -1 and the mutex is unaffected.
*/
int
-objc_mutex_unlock(objc_mutex_t mutex)
+objc_mutex_unlock (objc_mutex_t mutex)
{
objc_thread_t thread_id;
int status;
/* Valid mutex? */
- if (!mutex)
+ if (! mutex)
return -1;
/* If another thread owns the lock then abort */
- thread_id = __objc_thread_id();
+ thread_id = __objc_thread_id ();
if (mutex->owner != thread_id)
return -1;
@@ -398,7 +398,7 @@ objc_mutex_unlock(objc_mutex_t mutex)
mutex->owner = NULL;
/* Have the backend unlock the mutex */
- status = __objc_mutex_unlock(mutex);
+ status = __objc_mutex_unlock (mutex);
/* Failed? */
if (status)
@@ -414,20 +414,20 @@ objc_mutex_unlock(objc_mutex_t mutex)
if the allocation failed for any reason.
*/
objc_condition_t
-objc_condition_allocate(void)
+objc_condition_allocate (void)
{
objc_condition_t condition;
/* Allocate the condition mutex structure */
- if (!(condition =
- (objc_condition_t)objc_malloc(sizeof(struct objc_condition))))
+ if (! (condition =
+ (objc_condition_t) objc_malloc (sizeof (struct objc_condition))))
return NULL;
/* Call the backend to create the condition mutex */
- if (__objc_condition_allocate(condition))
+ if (__objc_condition_allocate (condition))
{
/* failed! */
- objc_free(condition);
+ objc_free (condition);
return NULL;
}
@@ -443,41 +443,41 @@ objc_condition_allocate(void)
waiting but just wake them up.
*/
int
-objc_condition_deallocate(objc_condition_t condition)
+objc_condition_deallocate (objc_condition_t condition)
{
/* Broadcast the condition */
- if (objc_condition_broadcast(condition))
+ if (objc_condition_broadcast (condition))
return -1;
/* Call the backend to destroy */
- if (__objc_condition_deallocate(condition))
+ if (__objc_condition_deallocate (condition))
return -1;
/* Free the condition mutex structure */
- objc_free(condition);
+ objc_free (condition);
return 0;
}
/*
- Wait on the condition unlocking the mutex until objc_condition_signal()
- or objc_condition_broadcast() are called for the same condition. The
+ Wait on the condition unlocking the mutex until objc_condition_signal ()
+ or objc_condition_broadcast () are called for the same condition. The
given mutex *must* have the depth set to 1 so that it can be unlocked
here, so that someone else can lock it and signal/broadcast the condition.
The mutex is used to lock access to the shared data that make up the
"condition" predicate.
*/
int
-objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex)
+objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
{
objc_thread_t thread_id;
/* Valid arguments? */
- if (!mutex || !condition)
+ if (! mutex || ! condition)
return -1;
/* Make sure we are owner of mutex */
- thread_id = __objc_thread_id();
+ thread_id = __objc_thread_id ();
if (mutex->owner != thread_id)
return -1;
@@ -490,7 +490,7 @@ objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex)
mutex->owner = (objc_thread_t)NULL;
/* Call the backend to wait */
- __objc_condition_wait(condition, mutex);
+ __objc_condition_wait (condition, mutex);
/* Make ourselves owner of the mutex */
mutex->owner = thread_id;
@@ -506,13 +506,13 @@ objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex)
right away after this call.
*/
int
-objc_condition_broadcast(objc_condition_t condition)
+objc_condition_broadcast (objc_condition_t condition)
{
/* Valid condition mutex? */
- if (!condition)
+ if (! condition)
return -1;
- return __objc_condition_broadcast(condition);
+ return __objc_condition_broadcast (condition);
}
/*
@@ -522,42 +522,42 @@ objc_condition_broadcast(objc_condition_t condition)
right away after this call.
*/
int
-objc_condition_signal(objc_condition_t condition)
+objc_condition_signal (objc_condition_t condition)
{
/* Valid condition mutex? */
- if (!condition)
+ if (! condition)
return -1;
- return __objc_condition_signal(condition);
+ return __objc_condition_signal (condition);
}
/* Make the objc thread system aware that a thread which is managed
(started, stopped) by external code could access objc facilities
from now on. This is used when you are interfacing with some
external non-objc-based environment/system - you must call
- objc_thread_add() before an alien thread makes any calls to
+ objc_thread_add () before an alien thread makes any calls to
Objective-C. Do not cause the _objc_became_multi_threaded hook to
be executed. */
void
-objc_thread_add(void)
+objc_thread_add (void)
{
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
__objc_is_multi_threaded = 1;
__objc_runtime_threads_alive++;
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
}
/* Make the objc thread system aware that a thread managed (started,
stopped) by some external code will no longer access objc and thus
can be forgotten by the objc thread system. Call
- objc_thread_remove() when your alien thread is done with making
+ objc_thread_remove () when your alien thread is done with making
calls to Objective-C. */
void
-objc_thread_remove(void)
+objc_thread_remove (void)
{
- objc_mutex_lock(__objc_runtime_mutex);
+ objc_mutex_lock (__objc_runtime_mutex);
__objc_runtime_threads_alive--;
- objc_mutex_unlock(__objc_runtime_mutex);
+ objc_mutex_unlock (__objc_runtime_mutex);
}
/* End of File */