diff --git a/Makefile.in b/Makefile.in index 9c21b0c..244f1e7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -22,21 +22,28 @@ #Makefile.in files. Some of this stuff may be unnecessary and #worthless. -SHELL = /bin/sh +SHELL = @SHELL@ +MAKEOVERRIDES= #### Start of system configuration section. #### -srcdir = @srcdir@ -VPATH = @srcdir@ +srcdir = @glibcpp_srcdir@ +VPATH = @glibcpp_srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ target_alias = @target_alias@ gcc_version = @gcc_version@ gcc_version_trigger = @gcc_version_trigger@ +top_srcdir = @top_srcdir@ +toplevel_srcdir = @toplevel_srcdir@ +toolexecdir = @glibcpp_toolexecdir@ +glibcpp_toolexecdir = @glibcpp_toolexecdir@ +glibcpp_toolexeclibdir = @glibcpp_toolexeclibdir@ + +top_builddir = . libdir = $(exec_prefix)/lib libsubdir = $(libdir)/gcc-lib/$(target_alias)/$(gcc_version) -incinstalldir = $(libsubdir)/include # Multilib support variables. MULTISRCTOP = @@ -60,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 @@ -110,6 +118,7 @@ FLAGS_TO_PASS = \ "AR_FLAGS=$(AR_FLAGS)" \ "CC=$(CC)" \ "CFLAGS=$(CFLAGS)" \ + "DESTDIR=$(DESTDIR)" \ "LIBCFLAGS=$(LIBCFLAGS)" \ "EXTRA_OFILES=$(EXTRA_OFILES)" \ "HDEFINES=$(HDEFINES)" \ @@ -129,7 +138,7 @@ FLAGS_TO_PASS = \ "tooldir=$(tooldir)" all: libobjc.la $(OBJC_BOEHM_GC) - $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all + : $(MAKE) ; exec $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all # User-visible header files. @@ -253,11 +262,13 @@ $(OBJC_THREAD_FILE)_gc.lo: $(OBJC_THREAD_FILE).c doc: info dvi html libobjc.la: $(OBJS) - $(LIBTOOL_LINK) $(CC) -o $@ $(OBJS) -rpath $(libsubdir) \ + $(LIBTOOL_LINK) $(CC) -o $@ $(OBJS) \ + -rpath $(glibcpp_toolexeclibdir) \ -version-info $(LIBOBJC_VERSION) libobjc_gc.la: $(OBJS_GC) - $(LIBTOOL_LINK) $(CC) -o $@ $(OBJS_GC) -rpath $(libsubdir) \ + $(LIBTOOL_LINK) $(CC) -o $@ $(OBJS_GC) \ + -rpath $(glibcpp_toolexeclibdir) \ -version-info $(LIBOBJC_GC_VERSION) # @@ -289,18 +300,9 @@ libobjc.dll: libobjc_s.a libobjc_entry.o # # -info: objc-features.info -dvi: objc-features.dvi -html: objc-features_toc.html - -objc-features.info: $(srcdir)/objc-features.texi - makeinfo -I$(srcdir) $(srcdir)/objc-features.texi - -objc-features.dvi: $(srcdir)/objc-features.texi - TEXINPUTS="$(srcdir):${TEXINPUTS}" texi2dvi $(srcdir)/objc-features.texi - -objc-features_toc.html: objc-features.texi - texi2html -split_node $(srcdir)/objc-features.texi +info: +dvi: +html: Makefile: Makefile.in config.status $(SHELL) config.status @@ -314,24 +316,24 @@ ${srcdir}/configure: configure.in rm -f config.cache cd ${srcdir} && autoconf -install: install-libs copy-headers +install: install-libs install-headers install-libs: installdirs - $(LIBTOOL_INSTALL) $(INSTALL_DATA) libobjc.la $(libsubdir)/libobjc.la; + $(SHELL) $(toplevel_srcdir)/mkinstalldirs $(DESTDIR)$(glibcpp_toolexeclibdir) + $(LIBTOOL_INSTALL) $(INSTALL) libobjc.la $(DESTDIR)$(glibcpp_toolexeclibdir); if [ "$(OBJC_BOEHM_GC)" ]; then \ - $(LIBTOOL_INSTALL) $(INSTALL_DATA) libobjc_gc.la \ - $(libsubdir)/libobjc_gc.la;\ + $(LIBTOOL_INSTALL) $(INSTALL) libobjc_gc.la \ + $(DESTDIR)$(glibcpp_toolexeclibdir);\ fi + $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO="$@" + @-$(LIBTOOL) --mode=finish $(DESTDIR)$(glibcpp_toolexeclibdir) # Copy Objective C headers to installation include directory. -copy-headers: - -rm -rf $(incinstalldir)/objc - -mkdir $(incinstalldir)/objc - -chmod a+rx $(incinstalldir)/objc +install-headers: + $(SHELL) $(toplevel_srcdir)/mkinstalldirs $(DESTDIR)$(libsubdir)/include/objc for file in $(OBJC_H); do \ realfile=$(srcdir)/objc/$${file}; \ - cp $${realfile} $(incinstalldir)/objc; \ - chmod a+r $(incinstalldir)/objc/$${file}; \ + $(INSTALL_DATA) $${realfile} $(DESTDIR)$(libsubdir)/include/objc; \ done check uninstall install-strip dist installcheck installdirs: diff --git a/Object.m b/Object.m index f5f3294..1882754 100644 --- a/Object.m +++ b/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/Protocol.m b/Protocol.m index 43ba44e..3c18a02 100644 --- a/Protocol.m +++ b/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/THREADS b/THREADS index 9dfbbed..8a43683 100644 --- a/THREADS +++ b/THREADS @@ -102,30 +102,33 @@ high degree of portability across platforms. The backend is composed of a file with the necessary code to map the ObjC thread and mutex to a platform specific implementation. For example, the -file thr-solaris.c contains the implementation for Solaris. When you -configure GCC, it attempts to pick an appropriate backend file for the -target platform; however, you can override this choice by assign the -OBJC_THREAD_FILE make variable to the basename of the backend file. This -is especially useful on platforms which have multiple thread libraries. -For example: - - make OBJC_THREAD_FILE=thr-posix - -would indicate that the generic posix backend file, thr-posix.c, should be -compiled with the ObjC runtime library. If your platform does not support -threads then you should specify the OBJC_THREAD_FILE=thr-single backend file -to compile the ObjC runtime library without thread or mutex support; note -that programs which rely upon the ObjC thread and mutex functions will -compile and link correctly but attempting to create a thread or mutex will -result in an error. - +file thr-solaris.c contains the implementation for Solaris. + +If you are compiling libobjc as part of GCC, the thr-objc.c backend is +always used; this backend uses GCC's gthread code. The thread system +is automatically configured when GCC is configured. Important: make +sure you configure GCC using `--enable-threads' if you want threads ! + +If you want to compile libobjc standalone, then you would need to +modify the configure.in and makefiles for it; and you need to pick an +appropriate backend file for the target platform; you make this choice +by assigning the OBJC_THREAD_FILE make variable to the basename of the +backend file. For example, OBJC_THREAD_FILE=thr-posix would indicate +that the generic posix backend file, thr-posix.c, should be compiled +with the ObjC runtime library. If your platform does not support +threads then you should specify the OBJC_THREAD_FILE=thr-single +backend file to compile the ObjC runtime library without thread or +mutex support; note that programs which rely upon the ObjC thread and +mutex functions will compile and link correctly but attempting to +create a thread or mutex will result in an error. + It is questionable whether it is really necessary to have both a frontend and backend function for all available functionality. On the one hand, it provides a clear, consistent differentiation between what is public and what is private with the downside of having the overhead -of multiple functions calls. For example, the function to have a thread -yield the processor is objc_thread_yield; in the current implementation -this produces a function call set: +of multiple functions calls. For example, the function to have a +thread yield the processor is objc_thread_yield; in the current +implementation this produces a function call set: objc_thread_yield() -> __objc_thread_yield() -> system yield function diff --git a/aclocal.m4 b/aclocal.m4 index a30c70c..ed643f6 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,2 +1,231 @@ -# Just a clone of ../libtool.m4. +dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without +dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A +dnl PARTICULAR PURPOSE. + +dnl +dnl Initialize configure bits. +dnl +dnl GLIBCPP_TOPREL_CONFIGURE +AC_DEFUN(GLIBCPP_TOPREL_CONFIGURE, [ + dnl Default to --enable-multilib + AC_ARG_ENABLE(multilib, + [ --enable-multilib build hella library versions (default)], + [case "${enableval}" in + yes) multilib=yes ;; + no) multilib=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for multilib option) ;; + esac], [multilib=yes])dnl + +# When building with srcdir == objdir, links to the source files will +# be created in directories within the target_subdir. We have to +# adjust toplevel_srcdir accordingly, so that configure finds +# install-sh and other auxiliary files that live in the top-level +# source directory. +if test "${srcdir}" = "."; then + if test -z "${with_target_subdir}"; then + toprel=".." + else + if test "${with_target_subdir}" != "."; then + toprel="${with_multisrctop}../.." + else + toprel="${with_multisrctop}.." + fi + fi +else + toprel=".." +fi +AC_CONFIG_AUX_DIR(${srcdir}/$toprel) +toplevel_srcdir=\${top_srcdir}/$toprel +AC_SUBST(toplevel_srcdir) +]) + +dnl +dnl Initialize configure bits. +dnl +dnl GLIBCPP_CONFIGURE +AC_DEFUN(GLIBCPP_CONFIGURE, [ +# Export build and source directories. +# 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=`${PWDCMD-pwd}` +case $srcdir in +[\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;; +*) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;; +esac +AC_SUBST(glibcpp_builddir) +AC_SUBST(glibcpp_srcdir) + +dnl This is here just to satisfy automake. +ifelse(not,equal,[AC_CONFIG_AUX_DIR(..)]) + +# Will set LN_S to either 'ln -s' or 'ln'. With autoconf 2.50+, can also +# be 'cp -p' if linking isn't available. +#ac_cv_prog_LN_S='cp -p' +AC_PROG_LN_S + +# We use these options to decide which functions to include. +AC_ARG_WITH(target-subdir, +[ --with-target-subdir=SUBDIR + configuring in a subdirectory]) +AC_ARG_WITH(cross-host, +[ --with-cross-host=HOST configuring with a cross compiler]) + + # Never versions of autoconf add an underscore to these functions. + # Prevent future problems ... + ifdef([AC_PROG_CC_G],[],[define([AC_PROG_CC_G],defn([_AC_PROG_CC_G]))]) + ifdef([AC_PROG_CC_GNU],[],[define([AC_PROG_CC_GNU],defn([_AC_PROG_CC_GNU]))]) + ifdef([AC_PROG_CXX_G],[],[define([AC_PROG_CXX_G],defn([_AC_PROG_CXX_G]))]) + ifdef([AC_PROG_CXX_GNU],[],[define([AC_PROG_CXX_GNU],defn([_AC_PROG_CXX_GNU]))]) + +# AC_PROG_CC + +# FIXME: We temporarily define our own version of AC_PROG_CC. This is +# copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We +# are probably using a cross compiler, which will not be able to fully +# link an executable. This should really be fixed in autoconf +# itself. + +AC_DEFUN(LIB_AC_PROG_CC, +[AC_BEFORE([$0], [AC_PROG_CPP])dnl +dnl Fool anybody using AC_PROG_CC. +AC_PROVIDE([AC_PROG_CC]) +AC_CHECK_PROG(CC, gcc, gcc) +if test -z "$CC"; then + AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc) + test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH]) +fi + +AC_PROG_CC_GNU + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +dnl Check whether -g works, even if CFLAGS is set, in case the package +dnl plays around with CFLAGS (such as to build both debugging and +dnl normal versions of a library), tasteless as that idea is. + ac_test_CFLAGS="${CFLAGS+set}" + ac_save_CFLAGS="$CFLAGS" + CFLAGS= + AC_PROG_CC_G + if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" + elif test $ac_cv_prog_cc_g = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-O2" + fi +else + GCC= + test "${CFLAGS+set}" = set || CFLAGS="-g" +fi +]) + +LIB_AC_PROG_CC + + AC_CHECK_TOOL(AS, as) + AC_CHECK_TOOL(AR, ar) + AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error) + AC_PROG_INSTALL + + # We need AC_EXEEXT to keep automake happy in cygnus mode. However, + # at least currently, we never actually build a program, so we never + # need to use $(EXEEXT). Moreover, the test for EXEEXT normally + # fails, because we are probably configuring with a cross compiler + # which can't create executables. So we include AC_EXEEXT to keep + # automake happy, but we don't execute it, since we don't care about + # the result. + if false; then + # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands + # to nothing, so nothing would remain between `then' and `fi' if it + # were not for the `:' below. + : + AC_EXEEXT + fi +]) + + +dnl +dnl GLIBCPP_EXPORT_INSTALL_INFO +dnl calculates gxx_install_dir +dnl exports glibcpp_toolexecdir +dnl exports glibcpp_toolexeclibdir +dnl exports glibcpp_prefixdir +dnl +dnl Assumes cross_compiling bits already done, and with_cross_host in +dnl particular +dnl +dnl GLIBCPP_EXPORT_INSTALL_INFO +AC_DEFUN(GLIBCPP_EXPORT_INSTALL_INFO, [ +# Assumes glibcpp_builddir, glibcpp_srcdir are alreay set up and +# exported correctly in GLIBCPP_CONFIGURE. +glibcpp_toolexecdir=no +glibcpp_toolexeclibdir=no +glibcpp_prefixdir=${prefix} + +AC_MSG_CHECKING([for interface version number]) +libstdcxx_interface=$INTERFACE +AC_MSG_RESULT($libstdcxx_interface) + +# Process the option "--enable-version-specific-runtime-libs" +AC_MSG_CHECKING([for --enable-version-specific-runtime-libs]) +AC_ARG_ENABLE(version-specific-runtime-libs, +[ --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory ], +[case "$enableval" in + yes) version_specific_libs=yes ;; + no) version_specific_libs=no ;; + *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);; + esac], +version_specific_libs=no)dnl +# Option set, now we can test it. +AC_MSG_RESULT($version_specific_libs) + +gcc_version_trigger=${srcdir}/../gcc/version.c +gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([[^ \"]]*\)[[ \"]].*/\1/'` +gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'` +AC_SUBST(gcc_version) +AC_SUBST(gcc_version_trigger) + +if test $version_specific_libs = yes; then + # Need the gcc compiler version to know where to install libraries + # and header files if --enable-version-specific-runtime-libs option + # is selected. + changequote(,)dnl + glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)' + glibcpp_toolexeclibdir='$(toolexecdir)/'${gcc_version}'$(MULTISUBDIR)' + changequote([,])dnl +fi + +# Calculate glibcpp_toolexecdir, glibcpp_toolexeclibdir +# Install a library built with a cross compiler in tooldir, not libdir. +if test x"$glibcpp_toolexecdir" = x"no"; then + if test -n "$with_cross_host" && + test x"$with_cross_host" != x"no"; then + glibcpp_toolexecdir='$(exec_prefix)/$(target_alias)' + glibcpp_toolexeclibdir='$(toolexecdir)/lib' + else + glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)' + glibcpp_toolexeclibdir='$(libdir)' + fi + glibcpp_toolexeclibdir=$glibcpp_toolexeclibdir/`$CC -print-multi-os-directory` +fi + +AC_SUBST(glibcpp_prefixdir) +AC_SUBST(glibcpp_toolexecdir) +AC_SUBST(glibcpp_toolexeclibdir) +]) + sinclude(../libtool.m4) +dnl The lines below arrange for aclocal not to bring an installed +dnl libtool.m4 into aclocal.m4, while still arranging for automake to +dnl add a definition of LIBTOOL to Makefile.in. +ifelse(,,,[AC_SUBST(LIBTOOL) +AC_DEFUN([AM_PROG_LIBTOOL]) +AC_DEFUN([AC_LIBTOOL_DLOPEN]) +AC_DEFUN([AC_PROG_LD]) +]) diff --git a/archive.c b/archive.c index 10106c1..f98379b 100644 --- a/archive.c +++ b/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 -#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/class.c b/class.c index 44aa1b9..1740f38 100644 --- a/class.c +++ b/class.c @@ -1,7 +1,11 @@ /* GNU Objective C Runtime class related functions - Copyright (C) 1993, 1995, 1996, 1997 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 + Nicola Pero, 2001. + This file is part of GNU CC. GNU CC is free software; you can redistribute it and/or modify it under the @@ -23,135 +27,490 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ however invalidate any other reasons why the executable file might be covered by the GNU General Public License. */ -#include "runtime.h" /* the kitchen sink */ +/* + The code in this file critically affects class method invocation + speed. This long preamble comment explains why, and the issues + involved. + + + One of the traditional weaknesses of the GNU Objective-C runtime is + that class method invocations are slow. The reason is that when you + write + + array = [NSArray new]; + + this gets basically compiled into the equivalent of + + array = [(objc_get_class ("NSArray")) new]; + + objc_get_class returns the class pointer corresponding to the string + `NSArray'; and because of the lookup, the operation is more + complicated and slow than a simple instance method invocation. + + Most high performance Objective-C code (using the GNU Objc runtime) + I had the opportunity to read (or write) work around this problem by + caching the class pointer: + + Class arrayClass = [NSArray class]; + + ... later on ... + + array = [arrayClass new]; + array = [arrayClass new]; + array = [arrayClass new]; + + In this case, you always perform a class lookup (the first one), but + then all the [arrayClass new] methods run exactly as fast as an + instance method invocation. It helps if you have many class method + invocations to the same class. + + The long-term solution to this problem would be to modify the + compiler to output tables of class pointers corresponding to all the + class method invocations, and to add code to the runtime to update + these tables - that should in the end allow class method invocations + to perform precisely as fast as instance method invocations, because + no class lookup would be involved. I think the Apple Objective-C + runtime uses this technique. Doing this involves synchronized + modifications in the runtime and in the compiler. + + As a first medicine to the problem, I [NP] have redesigned and + rewritten the way the runtime is performing class lookup. This + doesn't give as much speed as the other (definitive) approach, but + at least a class method invocation now takes approximately 4.5 times + an instance method invocation on my machine (it would take approx 12 + times before the rewriting), which is a lot better. + + One of the main reason the new class lookup is so faster is because + I implemented it in a way that can safely run multithreaded without + using locks - a so-called `lock-free' data structure. The atomic + operation is pointer assignment. The reason why in this problem + lock-free data structures work so well is that you never remove + classes from the table - and the difficult thing with lock-free data + structures is freeing data when is removed from the structures. */ + +#include "runtime.h" /* the kitchen sink */ #include "sarray.h" -/* The table of classname->class. Used for objc_lookup_class and friends */ -static cache_ptr __objc_class_hash = 0; /* !T:MUTEX */ +#include +#include +#include -/* 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 */ +/* We use a table which maps a class name to the corresponding class + * pointer. The first part of this file defines this table, and + * functions to do basic operations on the table. The second part of + * the file implements some higher level Objective-C functionality for + * classes by using the functions provided in the first part to manage + * the table. */ +/** + ** Class Table Internals + **/ -/* True when class links has been resolved */ -BOOL __objc_class_links_resolved = NO; /* !T:UNUSED */ +/* A node holding a class */ +typedef struct class_node +{ + struct class_node *next; /* Pointer to next entry on the list. + NULL indicates end of list. */ + + const char *name; /* The class name string */ + int length; /* The class name string length */ + Class pointer; /* The Class pointer */ + +} *class_node_ptr; + +/* A table containing classes is a class_node_ptr (pointing to the + first entry in the table - if it is NULL, then the table is + empty). */ + +/* We have 1024 tables. Each table contains all class names which + have the same hash (which is a number between 0 and 1023). To look + up a class_name, we compute its hash, and get the corresponding + table. Once we have the table, we simply compare strings directly + till we find the one which we want (using the length first). The + number of tables is quite big on purpose (a normal big application + has less than 1000 classes), so that you shouldn't normally get any + collisions, and get away with a single comparison (which we can't + avoid since we need to know that you have got the right thing). */ +#define CLASS_TABLE_SIZE 1024 +#define CLASS_TABLE_MASK 1023 + +static class_node_ptr class_table_array[CLASS_TABLE_SIZE]; + +/* The table writing mutex - we lock on writing to avoid conflicts + between different writers, but we read without locks. That is + possible because we assume pointer assignment to be an atomic + operation. */ +static objc_mutex_t __class_table_lock = NULL; + +/* CLASS_TABLE_HASH is how we compute the hash of a class name. It is + a macro - *not* a function - arguments *are* modified directly. + + INDEX should be a variable holding an int; + HASH should be a variable holding an int; + CLASS_NAME should be a variable holding a (char *) to the class_name. + + After the macro is executed, INDEX contains the length of the + string, and HASH the computed hash of the string; CLASS_NAME is + untouched. */ + +#define CLASS_TABLE_HASH(INDEX, HASH, CLASS_NAME) \ + HASH = 0; \ + for (INDEX = 0; CLASS_NAME[INDEX] != '\0'; INDEX++) \ + { \ + HASH = (HASH << 4) ^ (HASH >> 28) ^ CLASS_NAME[INDEX]; \ + } \ + \ + HASH = (HASH ^ (HASH >> 10) ^ (HASH >> 20)) & CLASS_TABLE_MASK; + +/* Setup the table. */ +static void +class_table_setup (void) +{ + /* Start - nothing in the table. */ + memset (class_table_array, 0, sizeof (class_node_ptr) * CLASS_TABLE_SIZE); + /* The table writing mutex. */ + __class_table_lock = objc_mutex_allocate (); +} -/* Initial number of buckets size of class hash table. */ -#define CLASS_HASH_SIZE 32 -void __objc_init_class_tables() +/* Insert a class in the table (used when a new class is registered). */ +static void +class_table_insert (const char *class_name, Class class_pointer) { - /* Allocate the class hash table */ + int hash, length; + class_node_ptr new_node; - if(__objc_class_hash) - return; + /* Find out the class name's hash and length. */ + CLASS_TABLE_HASH (length, hash, class_name); + + /* Prepare the new node holding the class. */ + new_node = objc_malloc (sizeof (struct class_node)); + new_node->name = class_name; + new_node->length = length; + new_node->pointer = class_pointer; + + /* Lock the table for modifications. */ + objc_mutex_lock (__class_table_lock); + + /* Insert the new node in the table at the beginning of the table at + class_table_array[hash]. */ + new_node->next = class_table_array[hash]; + class_table_array[hash] = new_node; + + objc_mutex_unlock (__class_table_lock); +} - objc_mutex_lock(__objc_runtime_mutex); +/* Replace a class in the table (used only by poseAs:). */ +static void +class_table_replace (Class old_class_pointer, Class new_class_pointer) +{ + int hash; + class_node_ptr node; - __objc_class_hash - = hash_new (CLASS_HASH_SIZE, - (hash_func_type) hash_string, - (compare_func_type) compare_strings); + objc_mutex_lock (__class_table_lock); + + hash = 0; + node = class_table_array[hash]; + + while (hash < CLASS_TABLE_SIZE) + { + if (node == NULL) + { + hash++; + if (hash < CLASS_TABLE_SIZE) + { + node = class_table_array[hash]; + } + } + else + { + Class class1 = node->pointer; - objc_mutex_unlock(__objc_runtime_mutex); + if (class1 == old_class_pointer) + { + node->pointer = new_class_pointer; + } + node = node->next; + } + } + + objc_mutex_unlock (__class_table_lock); +} + + +/* Get a class from the table. This does not need mutex protection. + Currently, this function is called each time you call a static + method, this is why it must be very fast. */ +static inline Class +class_table_get_safe (const char *class_name) +{ + class_node_ptr node; + int length, hash; + + /* Compute length and hash. */ + CLASS_TABLE_HASH (length, hash, class_name); + + node = class_table_array[hash]; + + if (node != NULL) + { + do + { + if (node->length == length) + { + /* Compare the class names. */ + int i; + + for (i = 0; i < length; i++) + { + if ((node->name)[i] != class_name[i]) + { + break; + } + } + + if (i == length) + { + /* They are equal! */ + return node->pointer; + } + } + } + while ((node = node->next) != NULL); + } + + return Nil; +} + +/* Enumerate over the class table. */ +struct class_table_enumerator +{ + int hash; + class_node_ptr node; +}; + + +static Class +class_table_next (struct class_table_enumerator **e) +{ + struct class_table_enumerator *enumerator = *e; + class_node_ptr next; + + if (enumerator == NULL) + { + *e = objc_malloc (sizeof (struct class_table_enumerator)); + enumerator = *e; + enumerator->hash = 0; + enumerator->node = NULL; + + next = class_table_array[enumerator->hash]; + } + else + { + next = enumerator->node->next; + } + + if (next != NULL) + { + enumerator->node = next; + return enumerator->node->pointer; + } + else + { + enumerator->hash++; + + while (enumerator->hash < CLASS_TABLE_SIZE) + { + next = class_table_array[enumerator->hash]; + if (next != NULL) + { + enumerator->node = next; + return enumerator->node->pointer; + } + enumerator->hash++; + } + + /* Ok - table finished - done. */ + objc_free (enumerator); + return Nil; + } +} + +#if 0 /* DEBUGGING FUNCTIONS */ +/* Debugging function - print the class table. */ +void +class_table_print (void) +{ + int i; + + for (i = 0; i < CLASS_TABLE_SIZE; i++) + { + class_node_ptr node; + + printf ("%d:\n", i); + node = class_table_array[i]; + + while (node != NULL) + { + printf ("\t%s\n", node->name); + node = node->next; + } + } +} + +/* Debugging function - print an histogram of number of classes in + function of hash key values. Useful to evaluate the hash function + in real cases. */ +void +class_table_print_histogram (void) +{ + int i, j; + int counter = 0; + + for (i = 0; i < CLASS_TABLE_SIZE; i++) + { + class_node_ptr node; + + node = class_table_array[i]; + + while (node != NULL) + { + counter++; + node = node->next; + } + if (((i + 1) % 50) == 0) + { + printf ("%4d:", i + 1); + for (j = 0; j < counter; j++) + { + printf ("X"); + } + printf ("\n"); + counter = 0; + } + } + printf ("%4d:", i + 1); + for (j = 0; j < counter; j++) + { + printf ("X"); + } + printf ("\n"); +} +#endif /* DEBUGGING FUNCTIONS */ + +/** + ** Objective-C runtime functions + **/ + +/* From now on, the only access to the class table data structure + should be via the class_table_* functions. */ + +/* 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 */ + + +/* True when class links has been resolved. */ +BOOL __objc_class_links_resolved = NO; /* !T:UNUSED */ + + +void +__objc_init_class_tables (void) +{ + /* Allocate the class hash table. */ + + if (__class_table_lock) + return; + + objc_mutex_lock (__objc_runtime_mutex); + + class_table_setup (); + + 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 */ +/* 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(__objc_class_hash); + /* Make sure the table is there. */ + assert (__class_table_lock); - /* make sure it's not a meta class */ - assert(CLS_ISCLASS(class)); + /* Make sure it's not a meta class. */ + assert (CLS_ISCLASS (class)); /* Check to see if the class is already in the hash table. */ - h_class = hash_value_for_key (__objc_class_hash, class->name); - if (!h_class) + h_class = class_table_get_safe (class->name); + 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; - hash_add (&__objc_class_hash, class->name, class); + 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) + this fails, nil is returned. */ +Class +objc_lookup_class (const char *name) { Class class; - objc_mutex_lock(__objc_runtime_mutex); - - /* Make sure the class hash table exists. */ - assert (__objc_class_hash); - - class = hash_value_for_key (__objc_class_hash, name); - - objc_mutex_unlock(__objc_runtime_mutex); + class = class_table_get_safe (name); if (class) return class; if (_objc_lookup_class) - return (*_objc_lookup_class)(name); + return (*_objc_lookup_class) (name); else return 0; } /* 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, an error message is issued and the system aborts */ + this fails, an error message is issued and the system aborts. */ Class objc_get_class (const char *name) { Class class; - objc_mutex_lock(__objc_runtime_mutex); - - /* Make sure the class hash table exists. */ - assert (__objc_class_hash); - - class = hash_value_for_key (__objc_class_hash, name); - - objc_mutex_unlock(__objc_runtime_mutex); + class = class_table_get_safe (name); if (class) 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 @@ -160,58 +519,57 @@ 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) { - objc_mutex_lock(__objc_runtime_mutex); - - /* make sure the table is there */ - assert(__objc_class_hash); + Class class; - *(node_ptr*)enum_state = - hash_next(__objc_class_hash, *(node_ptr*)enum_state); + objc_mutex_lock (__objc_runtime_mutex); + + /* Make sure the table is there. */ + assert (__class_table_lock); - objc_mutex_unlock(__objc_runtime_mutex); + class = class_table_next ((struct class_table_enumerator **) enum_state); - if (*(node_ptr*)enum_state) - return (*(node_ptr*)enum_state)->value; - return (Class)0; + objc_mutex_unlock (__objc_runtime_mutex); + + return class; } -/* 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() +/* 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) { - node_ptr node; + 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 */ - for (node = hash_next (__objc_class_hash, NULL); node; - node = hash_next (__objc_class_hash, node)) + /* Assign subclass links. */ + while ((class1 = class_table_next (&es))) { - Class class1 = node->value; - /* 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. */ + /* 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); @@ -221,11 +579,11 @@ void __objc_resolve_class_links() DEBUG_PRINTF ("making class connections for: %s\n", class1->name); - /* assign subclass links for superclass */ + /* Assign subclass links for superclass. */ class1->sibling_class = a_super_class->subclass_list; a_super_class->subclass_list = class1; - /* Assign subclass links for meta class of superclass */ + /* Assign subclass links for meta class of superclass. */ if (a_super_class->class_pointer) { class1->class_pointer->sibling_class @@ -234,8 +592,8 @@ void __objc_resolve_class_links() = class1->class_pointer; } } - else /* a root class, make its meta object */ - /* be a subclass of Object */ + else /* A root class, make its meta object be a subclass of + Object. */ { class1->class_pointer->sibling_class = object_class->subclass_list; @@ -244,22 +602,21 @@ void __objc_resolve_class_links() } } - /* Assign superclass links */ - for (node = hash_next (__objc_class_hash, NULL); node; - node = hash_next (__objc_class_hash, node)) + /* Assign superclass links. */ + es = NULL; + while ((class1 = class_table_next (&es))) { - Class class1 = node->value; Class sub_class; for (sub_class = class1->subclass_list; sub_class; 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); } @@ -269,13 +626,10 @@ void __objc_resolve_class_links() Class class_pose_as (Class impostor, Class super_class) { - node_ptr node; - Class class1; - - if (!CLS_ISRESOLV (impostor)) + if (! CLS_ISRESOLV (impostor)) __objc_resolve_class_links (); - /* preconditions */ + /* Preconditions */ assert (impostor); assert (super_class); assert (impostor->super_class == super_class); @@ -286,73 +640,64 @@ class_pose_as (Class impostor, Class super_class) { Class *subclass = &(super_class->subclass_list); - /* move subclasses of super_class to impostor */ + /* Move subclasses of super_class to impostor. */ while (*subclass) { - Class nextSub = (*subclass)->sibling_class; - - if (*subclass != impostor) - { - Class sub = *subclass; - - /* classes */ - sub->sibling_class = impostor->subclass_list; - sub->super_class = impostor; - impostor->subclass_list = sub; - - /* It will happen that SUB is not a class object if it is - the top of the meta class hierarchy chain. (root - meta-class objects inherit their class object) If that is - the case... don't mess with the meta-meta class. */ - if (CLS_ISCLASS (sub)) - { - /* meta classes */ - CLASSOF (sub)->sibling_class = - CLASSOF (impostor)->subclass_list; - CLASSOF (sub)->super_class = CLASSOF (impostor); - CLASSOF (impostor)->subclass_list = CLASSOF (sub); - } - } - - *subclass = nextSub; + Class nextSub = (*subclass)->sibling_class; + + if (*subclass != impostor) + { + Class sub = *subclass; + + /* Classes */ + sub->sibling_class = impostor->subclass_list; + sub->super_class = impostor; + impostor->subclass_list = sub; + + /* It will happen that SUB is not a class object if it is + the top of the meta class hierarchy chain (root + meta-class objects inherit their class object). If + that is the case... don't mess with the meta-meta + class. */ + if (CLS_ISCLASS (sub)) + { + /* Meta classes */ + CLASSOF (sub)->sibling_class = + CLASSOF (impostor)->subclass_list; + CLASSOF (sub)->super_class = CLASSOF (impostor); + CLASSOF (impostor)->subclass_list = CLASSOF (sub); + } + } + + *subclass = nextSub; } - /* set subclasses of superclass to be impostor only */ + /* Set subclasses of superclass to be impostor only. */ super_class->subclass_list = impostor; CLASSOF (super_class)->subclass_list = CLASSOF (impostor); - /* set impostor to have no sibling classes */ + /* Set impostor to have no sibling classes. */ impostor->sibling_class = 0; CLASSOF (impostor)->sibling_class = 0; } - /* check relationship of impostor and super_class is kept. */ + /* Check relationship of impostor and super_class is kept. */ assert (impostor->super_class == super_class); assert (CLASSOF (impostor)->super_class == CLASSOF (super_class)); - /* This is how to update the lookup table. Regardless of - what the keys of the hashtable is, change all values that are - superclass into impostor. */ + /* This is how to update the lookup table. Regardless of what the + 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); - for (node = hash_next (__objc_class_hash, NULL); node; - node = hash_next (__objc_class_hash, node)) - { - class1 = (Class)node->value; - if (class1 == super_class) - { - node->value = impostor; /* change hash table value */ - } - } + class_table_replace (super_class, impostor); - objc_mutex_unlock(__objc_runtime_mutex); + objc_mutex_unlock (__objc_runtime_mutex); - /* next, we update the dispatch tables... */ + /* Next, we update the dispatch tables... */ __objc_update_dispatch_table_for_class (CLASSOF (impostor)); __objc_update_dispatch_table_for_class (impostor); return impostor; } - - diff --git a/configure b/configure index b3be902..08d0b0f 100755 --- a/configure +++ b/configure @@ -11,6 +11,15 @@ ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: +ac_help="$ac_help + --enable-multilib build hella library versions (default)" +ac_help="$ac_help + --with-target-subdir=SUBDIR + configuring in a subdirectory" +ac_help="$ac_help + --with-cross-host=HOST configuring with a cross compiler" +ac_help="$ac_help + --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory " ac_help="$ac_help --enable-shared[=PKGS] build shared libraries [default=no]" ac_help="$ac_help @@ -538,17 +547,45 @@ fi -if test "${srcdir}" = "." ; then - if test "${with_target_subdir}" != "." ; then - topsrcdir=${with_multisrctop}../.. +# This works around the fact that libtool configuration may change LD +# for this particular configuration, but some shells, instead of +# keeping the changes in LD private, export them just because LD is +# exported. +ORIGINAL_LD_FOR_MULTILIBS=$LD + + + # Check whether --enable-multilib or --disable-multilib was given. +if test "${enable_multilib+set}" = set; then + enableval="$enable_multilib" + case "${enableval}" in + yes) multilib=yes ;; + no) multilib=no ;; + *) { echo "configure: error: bad value ${enableval} for multilib option" 1>&2; exit 1; } ;; + esac +else + multilib=yes +fi + +# When building with srcdir == objdir, links to the source files will +# be created in directories within the target_subdir. We have to +# adjust toplevel_srcdir accordingly, so that configure finds +# install-sh and other auxiliary files that live in the top-level +# source directory. +if test "${srcdir}" = "."; then + if test -z "${with_target_subdir}"; then + toprel=".." else - topsrcdir=${with_multisrctop}.. + if test "${with_target_subdir}" != "."; then + toprel="${with_multisrctop}../.." + else + toprel="${with_multisrctop}.." + fi fi else - topsrcdir=${srcdir}/.. + toprel=".." fi ac_aux_dir= -for ac_dir in $topsrcdir $srcdir/$topsrcdir; do +for ac_dir in ${srcdir}/$toprel $srcdir/${srcdir}/$toprel; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" @@ -560,55 +597,252 @@ for ac_dir in $topsrcdir $srcdir/$topsrcdir; do fi done if test -z "$ac_aux_dir"; then - { echo "configure: error: can not find install-sh or install.sh in $topsrcdir $srcdir/$topsrcdir" 1>&2; exit 1; } + { echo "configure: error: can not find install-sh or install.sh in ${srcdir}/$toprel $srcdir/${srcdir}/$toprel" 1>&2; exit 1; } fi ac_config_guess=$ac_aux_dir/config.guess ac_config_sub=$ac_aux_dir/config.sub ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. +toplevel_srcdir=\${top_srcdir}/$toprel + + + + +# Do some error checking and defaulting for the host and target type. +# The inputs are: +# configure --host=HOST --target=TARGET --build=BUILD NONOPT +# +# The rules are: +# 1. You are not allowed to specify --host, --target, and nonopt at the +# same time. +# 2. Host defaults to nonopt. +# 3. If nonopt is not specified, then host defaults to the current host, +# as determined by config.guess. +# 4. Target and build default to nonopt. +# 5. If nonopt is not specified, then target and build default to host. + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +case $host---$target---$nonopt in +NONE---*---* | *---NONE---* | *---*---NONE) ;; +*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;; +esac + + +# Make sure we can run config.sub. +if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : +else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } +fi + +echo $ac_n "checking host system type""... $ac_c" 1>&6 +echo "configure:639: checking host system type" >&5 + +host_alias=$host +case "$host_alias" in +NONE) + case $nonopt in + NONE) + if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : + else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } + fi ;; + *) host_alias=$nonopt ;; + esac ;; +esac + +host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$host" 1>&6 + +echo $ac_n "checking target system type""... $ac_c" 1>&6 +echo "configure:660: checking target system type" >&5 + +target_alias=$target +case "$target_alias" in +NONE) + case $nonopt in + NONE) target_alias=$host_alias ;; + *) target_alias=$nonopt ;; + esac ;; +esac + +target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias` +target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$target" 1>&6 + +echo $ac_n "checking build system type""... $ac_c" 1>&6 +echo "configure:678: checking build system type" >&5 + +build_alias=$build +case "$build_alias" in +NONE) + case $nonopt in + NONE) build_alias=$host_alias ;; + *) build_alias=$nonopt ;; + esac ;; +esac + +build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` +build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$build" 1>&6 + +test "$host_alias" != "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + +target_alias=${target_alias-$target} + + +if test $host != $build; then + ac_tool_prefix=${host_alias}- +else + ac_tool_prefix= +fi -# If the language specific compiler does not exist, but the "gcc" directory -# does, we do not build anything. Note, $r is set by the top-level Makefile. -# Note that when we look for the compiler, we search both with and without -# extension to handle cross and canadian cross builds. -compiler_name=cc1obj -rm -f skip-this-dir -echo $ac_n "checking if compiler $compiler_name has been built""... $ac_c" 1>&6 -echo "configure:578: checking if compiler $compiler_name has been built" >&5 -if eval "test \"`echo '$''{'objc_cv_compiler_exists'+set}'`\" = set"; then +echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 +echo "configure:710: checking for Cygwin environment" >&5 +if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - objc_cv_compiler_exists=yes -if test -n "$r"; then - if test -d "$r"/gcc; then - if test -f "$r"/gcc/$compiler_name \ - || test -f "$r"/gcc/$compiler_name.exe; then - true - else - objc_cv_compiler_exists=no - echo "rm -f config.cache config.log multilib.out" > skip-this-dir - fi - fi + cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_cygwin=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_cygwin=no +fi +rm -f conftest* +rm -f conftest* fi +echo "$ac_t""$ac_cv_cygwin" 1>&6 +CYGWIN= +test "$ac_cv_cygwin" = yes && CYGWIN=yes +echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 +echo "configure:743: checking for mingw32 environment" >&5 +if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_mingw32=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_mingw32=no +fi +rm -f conftest* +rm -f conftest* fi -echo "$ac_t""$objc_cv_compiler_exists" 1>&6 -if test x$objc_cv_compiler_exists = xno +echo "$ac_t""$ac_cv_mingw32" 1>&6 +MINGW32= +test "$ac_cv_mingw32" = yes && MINGW32=yes + +# Export build and source directories. +# 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=`${PWDCMD-pwd}` +case $srcdir in +\\/$* | ?:\\/*) glibcpp_srcdir=${srcdir} ;; +*) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;; +esac + + + + + +# Will set LN_S to either 'ln -s' or 'ln'. With autoconf 2.50+, can also +# be 'cp -p' if linking isn't available. +#ac_cv_prog_LN_S='cp -p' +echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 +echo "configure:790: checking whether ln -s works" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + rm -f conftestdata +if ln -s X conftestdata 2>/dev/null then - rm -f Makefile conftest* confdefs* core - exit 0 + rm -f conftestdata + ac_cv_prog_LN_S="ln -s" +else + ac_cv_prog_LN_S=ln +fi +fi +LN_S="$ac_cv_prog_LN_S" +if test "$ac_cv_prog_LN_S" = "ln -s"; then + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 fi +# We use these options to decide which functions to include. +# Check whether --with-target-subdir or --without-target-subdir was given. +if test "${with_target_subdir+set}" = set; then + withval="$with_target_subdir" + : +fi + +# Check whether --with-cross-host or --without-cross-host was given. +if test "${with_cross_host+set}" = set; then + withval="$with_cross_host" + : +fi + + + # Never versions of autoconf add an underscore to these functions. + # Prevent future problems ... + + + + + +# AC_PROG_CC + +# FIXME: We temporarily define our own version of AC_PROG_CC. This is +# copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We +# are probably using a cross compiler, which will not be able to fully +# link an executable. This should really be fixed in autoconf +# itself. + + -# For ObjC we'll set CC to point at the built gcc, but this will get it into -# the makefiles # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:612: checking for $ac_word" >&5 +echo "configure:846: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -638,7 +872,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:642: checking for $ac_word" >&5 +echo "configure:876: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -683,46 +917,11 @@ else echo "$ac_t""no" 1>&6 fi - if test -z "$CC"; then - case "`uname -s`" in - *win32* | *WIN32*) - # Extract the first word of "cl", so it can be a program name with args. -set dummy cl; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:693: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_CC="cl" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -CC="$ac_cv_prog_CC" -if test -n "$CC"; then - echo "$ac_t""$CC" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - ;; - esac - fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi - echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:726: checking whether we are using GNU C" >&5 +echo "configure:925: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -731,7 +930,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:735: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:934: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -742,15 +941,11 @@ echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes -else - GCC= -fi - -ac_test_CFLAGS="${CFLAGS+set}" -ac_save_CFLAGS="$CFLAGS" -CFLAGS= -echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:754: checking whether ${CC-cc} accepts -g" >&5 + ac_test_CFLAGS="${CFLAGS+set}" + ac_save_CFLAGS="$CFLAGS" + CFLAGS= + echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:949: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -765,87 +960,178 @@ rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 -if test "$ac_test_CFLAGS" = set; then - CFLAGS="$ac_save_CFLAGS" -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then + if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" + elif test $ac_cv_prog_cc_g = yes; then CFLAGS="-g -O2" else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then CFLAGS="-O2" - else - CFLAGS= fi +else + GCC= + test "${CFLAGS+set}" = set || CFLAGS="-g" fi -test "$AR" || AR=ar - -if test "$RANLIB"; then : - -else - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 + # 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:794: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then +echo "configure:980: 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 - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. + if test -n "$AS"; then + ac_cv_prog_AS="$AS" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then - ac_cv_prog_RANLIB="ranlib" + ac_cv_prog_AS="${ac_tool_prefix}as" break fi done IFS="$ac_save_ifs" - test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" + test -z "$ac_cv_prog_AS" && ac_cv_prog_AS="as" fi fi -RANLIB="$ac_cv_prog_RANLIB" -if test -n "$RANLIB"; then - echo "$ac_t""$RANLIB" 1>&6 +AS="$ac_cv_prog_AS" +if test -n "$AS"; then + echo "$ac_t""$AS" 1>&6 else echo "$ac_t""no" 1>&6 fi -fi -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# 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:834: checking for a BSD compatible install" >&5 -if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + + + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1012: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" - for ac_dir in $PATH; do - # Account for people who put trailing slashes in PATH elements. - case "$ac_dir/" in - /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - if test -f $ac_dir/$ac_prog; then + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_AR" && ac_cv_prog_AR="ar" +fi +fi +AR="$ac_cv_prog_AR" +if test -n "$AR"; then + echo "$ac_t""$AR" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + + + # 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:1044: 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 + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +if test -z "$ac_cv_prog_RANLIB"; then +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:1076: 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 + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB="ranlib-not-found-in-path-error" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +else + RANLIB="ranlib-not-found-in-path-error" +fi +fi + + # Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# 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:1120: 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 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -883,80 +1169,22 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' -# We need AC_EXEEXT to keep automake happy in cygnus mode. However, -# at least currently, we never actually build a program, so we never -# need to use $(EXEEXT). Moreover, the test for EXEEXT normally -# fails, because we are probably configuring with a cross compiler -# which cant create executables. So we include AC_EXEEXT to keep -# automake happy, but we dont execute it, since we dont care about -# the result. -if false; then - echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:896: checking for Cygwin environment" >&5 -if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_cygwin=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_cygwin=no -fi -rm -f conftest* -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_cygwin" 1>&6 -CYGWIN= -test "$ac_cv_cygwin" = yes && CYGWIN=yes -echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:929: checking for mingw32 environment" >&5 -if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then - rm -rf conftest* - ac_cv_mingw32=yes -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_mingw32=no -fi -rm -f conftest* -rm -f conftest* -fi - -echo "$ac_t""$ac_cv_mingw32" 1>&6 -MINGW32= -test "$ac_cv_mingw32" = yes && MINGW32=yes - + # We need AC_EXEEXT to keep automake happy in cygnus mode. However, + # at least currently, we never actually build a program, so we never + # need to use $(EXEEXT). Moreover, the test for EXEEXT normally + # fails, because we are probably configuring with a cross compiler + # which can't create executables. So we include AC_EXEEXT to keep + # automake happy, but we don't execute it, since we don't care about + # the result. + if false; then + # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands + # to nothing, so nothing would remain between `then' and `fi' if it + # were not for the `:' below. + : + echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:960: checking for executable suffix" >&5 +echo "configure:1188: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -966,7 +1194,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:970: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:1198: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.o | *.obj) ;; @@ -986,292 +1214,69 @@ test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext} echo "$ac_t""${ac_cv_exeext}" 1>&6 ac_exeext=$EXEEXT -fi + fi -# Sanity check for the cross-compilation case: -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:995: checking how to run the C preprocessor" >&5 -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then -if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1016: \"$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 - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -E -traditional-cpp" - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1033: \"$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 - : -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP="${CC-cc} -nologo -E" - cat > conftest.$ac_ext < -Syntax Error -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1050: \"$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 - : +# Assumes glibcpp_builddir, glibcpp_srcdir are alreay set up and +# exported correctly in GLIBCPP_CONFIGURE. +glibcpp_toolexecdir=no +glibcpp_toolexeclibdir=no +glibcpp_prefixdir=${prefix} + +echo $ac_n "checking for interface version number""... $ac_c" 1>&6 +echo "configure:1228: checking for interface version number" >&5 +libstdcxx_interface=$INTERFACE +echo "$ac_t""$libstdcxx_interface" 1>&6 + +# Process the option "--enable-version-specific-runtime-libs" +echo $ac_n "checking for --enable-version-specific-runtime-libs""... $ac_c" 1>&6 +echo "configure:1234: checking for --enable-version-specific-runtime-libs" >&5 +# Check whether --enable-version-specific-runtime-libs or --disable-version-specific-runtime-libs was given. +if test "${enable_version_specific_runtime_libs+set}" = set; then + enableval="$enable_version_specific_runtime_libs" + case "$enableval" in + yes) version_specific_libs=yes ;; + no) version_specific_libs=no ;; + *) { echo "configure: error: Unknown argument to enable/disable version-specific libs" 1>&2; exit 1; };; + esac else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - CPP=/lib/cpp -fi -rm -f conftest* -fi -rm -f conftest* -fi -rm -f conftest* - ac_cv_prog_CPP="$CPP" + version_specific_libs=no fi - CPP="$ac_cv_prog_CPP" -else - ac_cv_prog_CPP="$CPP" +# Option set, now we can test it. +echo "$ac_t""$version_specific_libs" 1>&6 + +gcc_version_trigger=${srcdir}/../gcc/version.c +gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([^ \"]*\)[ \"].*/\1/'` +gcc_version=`echo ${gcc_version_full} | sed -e 's/\(^ *\) .*/\1/'` + + + +if test $version_specific_libs = yes; then + # Need the gcc compiler version to know where to install libraries + # and header files if --enable-version-specific-runtime-libs option + # is selected. + glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)' + glibcpp_toolexeclibdir='$(toolexecdir)/'${gcc_version}'$(MULTISUBDIR)' + fi + +# Calculate glibcpp_toolexecdir, glibcpp_toolexeclibdir +# Install a library built with a cross compiler in tooldir, not libdir. +if test x"$glibcpp_toolexecdir" = x"no"; then + if test -n "$with_cross_host" && + test x"$with_cross_host" != x"no"; then + glibcpp_toolexecdir='$(exec_prefix)/$(target_alias)' + glibcpp_toolexeclibdir='$(toolexecdir)/lib' + else + glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)' + glibcpp_toolexeclibdir='$(libdir)' + fi + glibcpp_toolexeclibdir=$glibcpp_toolexeclibdir/`$CC -print-multi-os-directory` fi -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:1076: 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 -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1086: \"$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* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 -{ echo "configure: error: Can't find stdio.h. -You must have a usable C system for the target already installed, at least -including headers and, preferably, the library, before you can configure -the Objective C runtime system. If necessary, install gcc now with -\`LANGUAGES=c', then the target library, then build with \`LANGUAGES=objc'." 1>&2; exit 1; } -fi - - -echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1114: 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 < -#include -#include -#include -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1127: \"$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* - ac_cv_header_stdc=yes -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - ac_cv_header_stdc=no -fi -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 -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "memchr" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -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 -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - egrep "free" >/dev/null 2>&1; then - : -else - rm -rf conftest* - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. -if test "$cross_compiling" = yes; then - : -else - cat > conftest.$ac_ext < -#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int main () { int i; for (i = 0; i < 256; i++) -if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); -exit (0); } - -EOF -if { (eval echo configure:1194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null -then - : -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -fr conftest* - ac_cv_header_stdc=no -fi -rm -fr conftest* -fi - -fi -fi - -echo "$ac_t""$ac_cv_header_stdc" 1>&6 -if test $ac_cv_header_stdc = yes; then - cat >> confdefs.h <<\EOF -#define STDC_HEADERS 1 -EOF - -fi - - -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:1222: 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 -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1232: \"$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* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <&6 -fi -done -# Determine CFLAGS for gthread. -echo $ac_n "checking for gthread cflags""... $ac_c" 1>&6 -echo "configure:1262: 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 - if test -f "$r"/gcc/Makefile -then - objc_cv_gthread_flags=`grep \^GTHREAD_FLAGS "$r"/gcc/Makefile | awk -F= '{ print $2 }'` -else - { echo "configure: error: not found" 1>&2; exit 1; } -fi -fi -echo "$ac_t""$objc_cv_gthread_flags" 1>&6 -GTHREAD_FLAGS=$objc_cv_gthread_flags # Disable shared libs by default @@ -1279,7 +1284,7 @@ GTHREAD_FLAGS=$objc_cv_gthread_flags if test "${enable_shared+set}" = set; then enableval="$enable_shared" p=${PACKAGE-default} -case "$enableval" in +case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) @@ -1300,12 +1305,12 @@ fi # Enable Win32 DLL on MS Windows - FIXME -# Use libtool + # Check whether --enable-static or --disable-static was given. if test "${enable_static+set}" = set; then enableval="$enable_static" p=${PACKAGE-default} -case "$enableval" in +case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) @@ -1328,7 +1333,7 @@ fi if test "${enable_fast_install+set}" = set; then enableval="$enable_fast_install" p=${PACKAGE-default} -case "$enableval" in +case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) @@ -1347,51 +1352,6 @@ else enable_fast_install=yes fi - -# Make sure we can run config.sub. -if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : -else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } -fi - -echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:1358: checking host system type" >&5 - -host_alias=$host -case "$host_alias" in -NONE) - case $nonopt in - NONE) - if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : - else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } - fi ;; - *) host_alias=$nonopt ;; - esac ;; -esac - -host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` -host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$host" 1>&6 - -echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:1379: checking build system type" >&5 - -build_alias=$build -case "$build_alias" in -NONE) - case $nonopt in - NONE) build_alias=$host_alias ;; - *) build_alias=$nonopt ;; - esac ;; -esac - -build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` -build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$build" 1>&6 - # Check whether --with-gnu-ld or --without-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then withval="$with_gnu_ld" @@ -1401,10 +1361,10 @@ else fi ac_prog=ld -if test "$ac_cv_prog_gcc" = yes; then +if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6 -echo "configure:1408: checking for ld used by GCC" >&5 +echo "configure:1368: checking for ld used by GCC" >&5 case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw @@ -1412,7 +1372,7 @@ echo "configure:1408: checking for ld used by GCC" >&5 *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac - case "$ac_prog" in + case $ac_prog in # Accept absolute paths. [\\/]* | [A-Za-z]:[\\/]*) re_direlt='/[^/][^/]*/\.\./' @@ -1434,12 +1394,12 @@ echo "configure:1408: checking for ld used by GCC" >&5 esac elif test "$with_gnu_ld" = yes; then echo $ac_n "checking for GNU ld""... $ac_c" 1>&6 -echo "configure:1438: checking for GNU ld" >&5 +echo "configure:1398: checking for GNU ld" >&5 else echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 -echo "configure:1441: checking for non-GNU ld" >&5 +echo "configure:1401: checking for non-GNU ld" >&5 fi -if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then +if eval "test \"`echo '$''{'lt_cv_path_LD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -z "$LD"; then @@ -1447,11 +1407,11 @@ else for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - ac_cv_path_LD="$ac_dir/$ac_prog" + lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some GNU ld's only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. - if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then test "$with_gnu_ld" != no && break else test "$with_gnu_ld" != yes && break @@ -1460,11 +1420,11 @@ else done IFS="$ac_save_ifs" else - ac_cv_path_LD="$LD" # Let the user override the test with a path. + lt_cv_path_LD="$LD" # Let the user override the test with a path. fi fi -LD="$ac_cv_path_LD" +LD="$lt_cv_path_LD" if test -n "$LD"; then echo "$ac_t""$LD" 1>&6 else @@ -1472,24 +1432,24 @@ else fi test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; } echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6 -echo "configure:1476: checking if the linker ($LD) is GNU ld" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_gnu_ld'+set}'`\" = set"; then +echo "configure:1436: checking if the linker ($LD) is GNU ld" >&5 +if eval "test \"`echo '$''{'lt_cv_prog_gnu_ld'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # I'd rather use --version here, but apparently some GNU ld's only accept -v. if $LD -v 2>&1 &5; then - ac_cv_prog_gnu_ld=yes + lt_cv_prog_gnu_ld=yes else - ac_cv_prog_gnu_ld=no + lt_cv_prog_gnu_ld=no fi fi -echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6 -with_gnu_ld=$ac_cv_prog_gnu_ld +echo "$ac_t""$lt_cv_prog_gnu_ld" 1>&6 +with_gnu_ld=$lt_cv_prog_gnu_ld echo $ac_n "checking for $LD option to reload object files""... $ac_c" 1>&6 -echo "configure:1493: checking for $LD option to reload object files" >&5 +echo "configure:1453: checking for $LD option to reload object files" >&5 if eval "test \"`echo '$''{'lt_cv_ld_reload_flag'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1501,13 +1461,13 @@ reload_flag=$lt_cv_ld_reload_flag test -n "$reload_flag" && reload_flag=" $reload_flag" echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6 -echo "configure:1505: checking for BSD-compatible nm" >&5 -if eval "test \"`echo '$''{'ac_cv_path_NM'+set}'`\" = set"; then +echo "configure:1465: checking for BSD-compatible nm" >&5 +if eval "test \"`echo '$''{'lt_cv_path_NM'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$NM"; then # Let the user override the test. - ac_cv_path_NM="$NM" + lt_cv_path_NM="$NM" else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do @@ -1519,48 +1479,27 @@ else # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then - ac_cv_path_NM="$tmp_nm -B" + lt_cv_path_NM="$tmp_nm -B" break elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then - ac_cv_path_NM="$tmp_nm -p" + lt_cv_path_NM="$tmp_nm -p" break else - ac_cv_path_NM=${ac_cv_path_NM="$tmp_nm"} # keep the first match, but + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags fi fi done IFS="$ac_save_ifs" - test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm + test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm fi fi -NM="$ac_cv_path_NM" +NM="$lt_cv_path_NM" echo "$ac_t""$NM" 1>&6 -echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:1543: checking whether ln -s works" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - rm -f conftestdata -if ln -s X conftestdata 2>/dev/null -then - rm -f conftestdata - ac_cv_prog_LN_S="ln -s" -else - ac_cv_prog_LN_S=ln -fi -fi -LN_S="$ac_cv_prog_LN_S" -if test "$ac_cv_prog_LN_S" = "ln -s"; then - echo "$ac_t""yes" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - echo $ac_n "checking how to recognise dependant libraries""... $ac_c" 1>&6 -echo "configure:1564: checking how to recognise dependant libraries" >&5 +echo "configure:1503: checking how to recognise dependant libraries" >&5 if eval "test \"`echo '$''{'lt_cv_deplibs_check_method'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1578,8 +1517,8 @@ lt_cv_deplibs_check_method='unknown' # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. -case "$host_os" in -aix4*) +case $host_os in +aix*) lt_cv_deplibs_check_method=pass_all ;; @@ -1588,8 +1527,8 @@ beos*) ;; bsdi4*) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' - lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; @@ -1598,14 +1537,27 @@ cygwin* | mingw* |pw32*) lt_cv_file_magic_cmd='$OBJDUMP -f' ;; +darwin* | rhapsody*) + lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library' + lt_cv_file_magic_cmd='/usr/bin/file -L' + case "$host_os" in + rhapsody* | darwin1.012) + lt_cv_file_magic_test_file='/System/Library/Frameworks/System.framework/System' + ;; + *) # Darwin 1.3 on + lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib' + ;; + esac + ;; + freebsd* ) if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then - case "$host_cpu" in + case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac @@ -1618,29 +1570,37 @@ gnu*) lt_cv_deplibs_check_method=pass_all ;; -hpux10.20*) - # TODO: Does this work for hpux-11 too? - lt_cv_deplibs_check_method='file_magic (s0-90-90-9|PA-RISC0-9.0-9) shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libc.sl +hpux10.20*|hpux11*) + 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*) - case "$host_os" in + case $host_os in irix5*) # this will be overridden with pass_all, but let us keep it just in case lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" ;; *) - case "$LD" in + case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac # this will be overridden with pass_all, but let us keep it just in case - lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1" - ;; + lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1" + ;; esac lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*` lt_cv_deplibs_check_method=pass_all @@ -1648,25 +1608,30 @@ irix5* | irix6*) # This must be Linux ELF. linux-gnu*) - case "$host_cpu" in - alpha* | i*86 | powerpc* | sparc* | ia64* ) + case $host_cpu in + alpha* | hppa* | i*86 | powerpc* | sparc* | ia64* ) lt_cv_deplibs_check_method=pass_all ;; *) # glibc up to 2.1.1 does not perform some relocations on ARM - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; - esac + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; + esac lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so` ;; netbsd*) - if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then : + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$' else - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object' - lt_cv_file_magic_cmd='/usr/bin/file -L' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so$' fi ;; +newsos6) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + osf3* | osf4* | osf5*) # this will be overridden with pass_all, but let us keep it just in case lt_cv_deplibs_check_method='file_magic COFF format alpha shared library' @@ -1683,14 +1648,18 @@ solaris*) lt_cv_file_magic_test_file=/lib/libc.so ;; -sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - case "$host_vendor" in +sysv5uw[78]* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + case $host_vendor in ncr) lt_cv_deplibs_check_method=pass_all ;; motorola) - lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; esac ;; @@ -1703,13 +1672,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:1707: checking for object suffix" >&5 +echo "configure:1676: 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:1713: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1682: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then for ac_file in conftest.*; do case $ac_file in *.c) ;; @@ -1726,24 +1695,18 @@ echo "$ac_t""$ac_cv_objext" 1>&6 OBJEXT=$ac_cv_objext ac_objext=$ac_cv_objext -if test $host != $build; then - ac_tool_prefix=${host_alias}- -else - ac_tool_prefix= -fi - # Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! # Only perform the check for file, if the check method requires it -case "$deplibs_check_method" in +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:1743: checking for ${ac_tool_prefix}file" >&5 +echo "configure:1706: 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 - case "$MAGIC_CMD" in + case $MAGIC_CMD in /*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; @@ -1759,7 +1722,7 @@ else if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then - case "$deplibs_check_method" in + case $deplibs_check_method in "file_magic "*) file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" MAGIC_CMD="$lt_cv_path_MAGIC_CMD" @@ -1801,11 +1764,11 @@ 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:1805: checking for file" >&5 +echo "configure:1768: 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 - case "$MAGIC_CMD" in + case $MAGIC_CMD in /*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; @@ -1821,7 +1784,7 @@ else if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then - case "$deplibs_check_method" in + case $deplibs_check_method in "file_magic "*) file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" MAGIC_CMD="$lt_cv_path_MAGIC_CMD" @@ -1872,7 +1835,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:1876: checking for $ac_word" >&5 +echo "configure:1839: 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 @@ -1904,7 +1867,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:1908: checking for $ac_word" >&5 +echo "configure:1871: 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 @@ -1939,7 +1902,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:1943: checking for $ac_word" >&5 +echo "configure:1906: 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 @@ -1971,7 +1934,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:1975: checking for $ac_word" >&5 +echo "configure:1938: 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 @@ -2009,8 +1972,8 @@ libtool_flags="--cache-file=$cache_file" test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static" test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" -test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc" -test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld" +test "$GCC" = yes && libtool_flags="$libtool_flags --with-gcc" +test "$lt_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld" libtool_flags="$libtool_flags --enable-win32-dll" # Check whether --enable-libtool-lock or --disable-libtool-lock was given. @@ -2035,12 +1998,25 @@ test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic" # Some flags need to be propagated to the compiler or linker for good # libtool support. -case "$host" in +case $host in *-*-irix6*) # Find out which ABI we are using. - echo '#line 2042 "configure"' > conftest.$ac_ext - if { (eval echo configure:2043: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then - case "`/usr/bin/file conftest.o`" in + echo '#line 2005 "configure"' > conftest.$ac_ext + if { (eval echo configure:2006: \"$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" ;; @@ -2051,6 +2027,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:2039: \"$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:2055: \"$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* ;; @@ -2060,7 +2095,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:2064: checking whether the C compiler needs -belf" >&5 +echo "configure:2099: 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 @@ -2073,14 +2108,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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2119: \"$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 @@ -2110,7 +2145,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:2114: checking for $ac_word" >&5 +echo "configure:2149: 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 @@ -2142,7 +2177,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:2146: checking for $ac_word" >&5 +echo "configure:2181: 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 @@ -2177,7 +2212,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:2181: checking for $ac_word" >&5 +echo "configure:2216: 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 @@ -2209,7 +2244,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:2213: checking for $ac_word" >&5 +echo "configure:2248: 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 @@ -2244,7 +2279,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:2248: checking for $ac_word" >&5 +echo "configure:2283: 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 @@ -2270,204 +2305,616 @@ else echo "$ac_t""no" 1>&6 fi - -if test -z "$ac_cv_prog_OBJDUMP"; then -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:2280: 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 - if test -n "$OBJDUMP"; then - ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. + +if test -z "$ac_cv_prog_OBJDUMP"; then +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:2315: 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 + if test -n "$OBJDUMP"; then + ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_OBJDUMP="objdump" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_OBJDUMP" && ac_cv_prog_OBJDUMP="false" +fi +fi +OBJDUMP="$ac_cv_prog_OBJDUMP" +if test -n "$OBJDUMP"; then + echo "$ac_t""$OBJDUMP" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +else + OBJDUMP="false" +fi +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:2351: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + lt_cv_need_dllmain=no +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + lt_cv_need_dllmain=yes +fi +rm -f conftest* +fi + +echo "$ac_t""$lt_cv_need_dllmain" 1>&6 + + case $host/$CC in + *-*-cygwin*/gcc*-mno-cygwin*|*-*-mingw*) + # old mingw systems require "-dll" to link a DLL, while more recent ones + # require "-mdll" + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -mdll" + echo $ac_n "checking how to link DLLs""... $ac_c" 1>&6 +echo "configure:2385: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + lt_cv_cc_dll_switch=-mdll +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + lt_cv_cc_dll_switch=-dll +fi +rm -f conftest* +fi + +echo "$ac_t""$lt_cv_cc_dll_switch" 1>&6 + CFLAGS="$SAVE_CFLAGS" ;; + *-*-cygwin* | *-*-pw32*) + # cygwin systems need to pass --dll to the linker, and not link + # crt.o which will require a WinMain@16 definition. + lt_cv_cc_dll_switch="-Wl,--dll -nostartfiles" ;; + esac + ;; + +esac + + +# Save cache, so that ltconfig can load it +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + + +# Actually configure libtool. ac_aux_dir is where install-sh is found. +AR="$AR" LTCC="$CC" CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ +MAGIC_CMD="$MAGIC_CMD" LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" STRIP="$STRIP" \ +AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" \ +objext="$OBJEXT" exeext="$EXEEXT" reload_flag="$reload_flag" \ +deplibs_check_method="$deplibs_check_method" file_magic_cmd="$file_magic_cmd" \ +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ +$libtool_flags --no-verify --build="$build" $ac_aux_dir/ltmain.sh $host \ +|| { echo "configure: error: libtool configure failed" 1>&2; exit 1; } + +# Reload cache, that may have been modified by ltconfig +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh $ac_aux_dir/ltcf-c.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + +# Redirect the config.log output again, so that the ltconfig log is not +# clobbered by the next message. +exec 5>>./config.log + + + + + + + +test "$AR" || AR=ar + +if test "$RANLIB"; then : + +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:2515: 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 + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +fi +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# 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:2555: 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 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +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:2608: 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 +else + cat > conftestmake <<\EOF +all: + @echo 'ac_maketemp="${MAKE}"' +EOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftestmake +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$ac_t""yes" 1>&6 + SET_MAKE= +else + echo "$ac_t""no" 1>&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + + +# Sanity check for the cross-compilation case: +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:2637: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2658: \"$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 + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2675: \"$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 + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2692: \"$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 + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +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:2718: 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 +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2728: \"$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* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + : +else + echo "$ac_t""no" 1>&6 +{ echo "configure: error: Can't find stdio.h. +You must have a usable C system for the target already installed, at least +including headers and, preferably, the library, before you can configure +the Objective C runtime system. If necessary, install gcc now with +\`LANGUAGES=c', then the target library, then build with \`LANGUAGES=objc'." 1>&2; exit 1; } +fi + + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:2756: 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 < +#include +#include +#include +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2769: \"$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* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +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 +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_OBJDUMP="objdump" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_prog_OBJDUMP" && ac_cv_prog_OBJDUMP="false" -fi + rm -rf conftest* + ac_cv_header_stdc=no fi -OBJDUMP="$ac_cv_prog_OBJDUMP" -if test -n "$OBJDUMP"; then - echo "$ac_t""$OBJDUMP" 1>&6 -else - echo "$ac_t""no" 1>&6 +rm -f conftest* + 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 +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : else - OBJDUMP="false" -fi + rm -rf conftest* + ac_cv_header_stdc=no fi +rm -f conftest* +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:2316: 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 +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : else cat > conftest.$ac_ext < +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } -int main() { -extern int __attribute__((__stdcall__)) DllMain(void*, int, void*); - DllMain (0, 0, 0); -; return 0; } EOF -if { (eval echo configure:2329: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - lt_cv_need_dllmain=no +if { (eval echo configure:2836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 - rm -rf conftest* - lt_cv_need_dllmain=yes + rm -fr conftest* + ac_cv_header_stdc=no fi -rm -f conftest* +rm -fr conftest* fi -echo "$ac_t""$lt_cv_need_dllmain" 1>&6 +fi +fi - case "$host/$CC" in - *-*-cygwin*/gcc*-mno-cygwin*|*-*-mingw*) - # old mingw systems require "-dll" to link a DLL, while more recent ones - # require "-mdll" - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -mdll" - echo $ac_n "checking how to link DLLs""... $ac_c" 1>&6 -echo "configure:2350: checking how to link DLLs" >&5 -if eval "test \"`echo '$''{'lt_cv_cc_dll_switch'+set}'`\" = set"; then +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + + +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:2864: 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 -if { (eval echo configure:2362: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:2874: \"$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* - lt_cv_cc_dll_switch=-mdll + eval "ac_cv_header_$ac_safe=yes" else + echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* - lt_cv_cc_dll_switch=-dll + eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi - -echo "$ac_t""$lt_cv_cc_dll_switch" 1>&6 - CFLAGS="$SAVE_CFLAGS" ;; - *-*-cygwin* | *-*-pw32*) - # cygwin systems need to pass --dll to the linker, and not link - # crt.o which will require a WinMain@16 definition. - lt_cv_cc_dll_switch="-Wl,--dll -nostartfiles" ;; - esac - ;; - -esac - - -# Save cache, so that ltconfig can load it -cat > confcache <<\EOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. -# -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. -# +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote substitution - # turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - -e "s/'/'\\\\''/g" \ - -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' - ;; - esac >> confcache -if cmp -s $cache_file confcache; then - : + else - if test -w $cache_file; then - echo "updating cache $cache_file" - cat confcache > $cache_file - else - echo "not updating unwritable cache $cache_file" - fi + echo "$ac_t""no" 1>&6 fi -rm -f confcache +done -# Actually configure libtool. ac_aux_dir is where install-sh is found. -AR="$AR" LTCC="$CC" CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ -MAGIC_CMD="$MAGIC_CMD" LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ -LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" STRIP="$STRIP" \ -AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" \ -objext="$OBJEXT" exeext="$EXEEXT" reload_flag="$reload_flag" \ -deplibs_check_method="$deplibs_check_method" file_magic_cmd="$file_magic_cmd" \ -${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ -$libtool_flags --no-verify --build="$build" $ac_aux_dir/ltmain.sh $host \ -|| { echo "configure: error: libtool configure failed" 1>&2; exit 1; } +# Determine CFLAGS for gthread. -# Reload cache, that may have been modified by ltconfig -if test -r "$cache_file"; then - echo "loading cache $cache_file" - . $cache_file +echo $ac_n "checking for gthread cflags""... $ac_c" 1>&6 +echo "configure:2904: 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 - echo "creating cache $cache_file" - > $cache_file + if test -f "$r"/gcc/Makefile +then + objc_cv_gthread_flags=`grep \^GTHREAD_FLAGS "$r"/gcc/Makefile | awk -F= '{ print $2 }'` +else + { echo "configure: error: not found" 1>&2; exit 1; } +fi fi +echo "$ac_t""$objc_cv_gthread_flags" 1>&6 +GTHREAD_FLAGS=$objc_cv_gthread_flags -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh $ac_aux_dir/ltcf-c.sh" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' - -# Redirect the config.log output again, so that the ltconfig log is not -# clobbered by the next message. -exec 5>>./config.log - - - - - - - # Check whether --enable-objc-gc or --disable-objc-gc was given. if test "${enable_objc_gc+set}" = set; then @@ -2618,32 +3065,46 @@ s%@includedir@%$includedir%g s%@oldincludedir@%$oldincludedir%g s%@infodir@%$infodir%g s%@mandir@%$mandir%g -s%@CC@%$CC%g -s%@AR@%$AR%g -s%@RANLIB@%$RANLIB%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@EXEEXT@%$EXEEXT%g -s%@CPP@%$CPP%g -s%@GTHREAD_FLAGS@%$GTHREAD_FLAGS%g +s%@toplevel_srcdir@%$toplevel_srcdir%g s%@host@%$host%g s%@host_alias@%$host_alias%g s%@host_cpu@%$host_cpu%g s%@host_vendor@%$host_vendor%g s%@host_os@%$host_os%g +s%@target@%$target%g +s%@target_alias@%$target_alias%g +s%@target_cpu@%$target_cpu%g +s%@target_vendor@%$target_vendor%g +s%@target_os@%$target_os%g s%@build@%$build%g s%@build_alias@%$build_alias%g s%@build_cpu@%$build_cpu%g s%@build_vendor@%$build_vendor%g s%@build_os@%$build_os%g +s%@glibcpp_builddir@%$glibcpp_builddir%g +s%@glibcpp_srcdir@%$glibcpp_srcdir%g s%@LN_S@%$LN_S%g +s%@CC@%$CC%g +s%@AS@%$AS%g +s%@AR@%$AR%g +s%@RANLIB@%$RANLIB%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@EXEEXT@%$EXEEXT%g +s%@gcc_version@%$gcc_version%g +s%@gcc_version_trigger@%$gcc_version_trigger%g +s%@glibcpp_prefixdir@%$glibcpp_prefixdir%g +s%@glibcpp_toolexecdir@%$glibcpp_toolexecdir%g +s%@glibcpp_toolexeclibdir@%$glibcpp_toolexeclibdir%g s%@OBJEXT@%$OBJEXT%g s%@STRIP@%$STRIP%g s%@DLLTOOL@%$DLLTOOL%g -s%@AS@%$AS%g s%@OBJDUMP@%$OBJDUMP%g s%@LIBTOOL@%$LIBTOOL%g +s%@SET_MAKE@%$SET_MAKE%g +s%@CPP@%$CPP%g +s%@GTHREAD_FLAGS@%$GTHREAD_FLAGS%g s%@OBJC_BOEHM_GC@%$OBJC_BOEHM_GC%g CEOF @@ -2860,8 +3321,9 @@ target=${target} with_target_subdir=${with_target_subdir} with_multisubdir=${with_multisubdir} ac_configure_args="--enable-multilib ${ac_configure_args}" +toplevel_srcdir=${toplevel_srcdir} CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} -topsrcdir=${topsrcdir} +ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}" EOF cat >> $CONFIG_STATUS <<\EOF @@ -2870,7 +3332,8 @@ if test -n "$CONFIG_FILES"; then if test -n "${with_target_subdir}"; then # FIXME: We shouldn't need to set ac_file ac_file=Makefile - . ${topsrcdir}/config-ml.in + LD="${ORIGINAL_LD_FOR_MULTILIBS}" + . ${toplevel_srcdir}/config-ml.in fi fi exit 0 @@ -2880,3 +3343,4 @@ rm -fr confdefs* $ac_clean_files test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + diff --git a/configure.in b/configure.in index d568610..b20671f 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,6 @@ # Process this file with autoconf to produce a configure script. -# Copyright (C) 1995, 1997, 1998, 1999 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. @@ -23,57 +24,32 @@ AC_PREREQ(2.13) AC_INIT(objc/objc.h) AC_CONFIG_HEADER(config.h) -if test "${srcdir}" = "." ; then - if test "${with_target_subdir}" != "." ; then - topsrcdir=${with_multisrctop}../.. - else - topsrcdir=${with_multisrctop}.. - fi -else - topsrcdir=${srcdir}/.. -fi -dnl This is needed for a multilibbed build in the source tree so -dnl that install-sh and config.sub get found. -AC_CONFIG_AUX_DIR($topsrcdir) - -# If the language specific compiler does not exist, but the "gcc" directory -# does, we do not build anything. Note, $r is set by the top-level Makefile. -# Note that when we look for the compiler, we search both with and without -# extension to handle cross and canadian cross builds. -compiler_name=cc1obj -rm -f skip-this-dir -AC_MSG_CHECKING(if compiler $compiler_name has been built) -AC_CACHE_VAL(objc_cv_compiler_exists, -[objc_cv_compiler_exists=yes -if test -n "$r"; then - if test -d "$r"/gcc; then - if test -f "$r"/gcc/$compiler_name \ - || test -f "$r"/gcc/$compiler_name.exe; then - true - else - objc_cv_compiler_exists=no - echo "rm -f config.cache config.log multilib.out" > skip-this-dir - fi - fi -fi -]) -AC_MSG_RESULT($objc_cv_compiler_exists) -if test x$objc_cv_compiler_exists = xno -then - rm -f Makefile conftest* confdefs* core - exit 0 -fi +# This works around the fact that libtool configuration may change LD +# for this particular configuration, but some shells, instead of +# keeping the changes in LD private, export them just because LD is +# exported. +ORIGINAL_LD_FOR_MULTILIBS=$LD + +GLIBCPP_TOPREL_CONFIGURE + +AC_CANONICAL_SYSTEM +target_alias=${target_alias-$target} +AC_SUBST(target_alias) + +GLIBCPP_CONFIGURE(.) +GLIBCPP_EXPORT_INSTALL_INFO dnl Checks for programs. -dnl FIXME AC_PROG_CC wants CC to be able to link things, but it may -dnl not be able to. -define([AC_PROG_CC_WORKS],[]) +# Disable shared libs by default +AC_DISABLE_SHARED +# Enable Win32 DLL on MS Windows - FIXME +AC_LIBTOOL_WIN32_DLL -# For ObjC we'll set CC to point at the built gcc, but this will get it into -# the makefiles -AC_PROG_CC +AC_PROG_LIBTOOL +dnl These should be inherited in the recursive make, but ensure they are +dnl defined: test "$AR" || AR=ar AC_SUBST(AR) if test "$RANLIB"; then : @@ -82,19 +58,7 @@ else AC_PROG_RANLIB fi AC_PROG_INSTALL - -# We need AC_EXEEXT to keep automake happy in cygnus mode. However, -# at least currently, we never actually build a program, so we never -# need to use $(EXEEXT). Moreover, the test for EXEEXT normally -# fails, because we are probably configuring with a cross compiler -# which cant create executables. So we include AC_EXEEXT to keep -# automake happy, but we dont execute it, since we dont care about -# the result. -if false; then - AC_EXEEXT -fi - -dnl Checks for libraries. +AC_PROG_MAKE_SET dnl Checks for header files. # Sanity check for the cross-compilation case: @@ -121,13 +85,6 @@ fi]) GTHREAD_FLAGS=$objc_cv_gthread_flags AC_SUBST(GTHREAD_FLAGS) -# Disable shared libs by default -AC_DISABLE_SHARED -# Enable Win32 DLL on MS Windows - FIXME -AC_LIBTOOL_WIN32_DLL -# Use libtool -AC_PROG_LIBTOOL - AC_ARG_ENABLE(objc-gc, [ --enable-objc-gc enable the use of Boehm's garbage collector with the GNU Objective-C runtime.], @@ -142,12 +99,13 @@ AC_SUBST(OBJC_BOEHM_GC) # We need multilib support, but only if configuring for the target. AC_OUTPUT(Makefile, -[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h + [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h if test -n "$CONFIG_FILES"; then if test -n "${with_target_subdir}"; then # FIXME: We shouldn't need to set ac_file ac_file=Makefile - . ${topsrcdir}/config-ml.in + LD="${ORIGINAL_LD_FOR_MULTILIBS}" + . ${toplevel_srcdir}/config-ml.in fi fi], srcdir=${srcdir} @@ -156,10 +114,12 @@ target=${target} with_target_subdir=${with_target_subdir} with_multisubdir=${with_multisubdir} ac_configure_args="--enable-multilib ${ac_configure_args}" +toplevel_srcdir=${toplevel_srcdir} CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} -topsrcdir=${topsrcdir} +ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}" ) + dnl Local Variables: dnl comment-start: "dnl " dnl comment-end: "" diff --git a/encoding.c b/encoding.c index a87f981..7bde284 100644 --- a/encoding.c +++ b/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 @@ -26,21 +27,29 @@ Boston, MA 02111-1307, USA. */ This exception does not however invalidate any other reasons why the executable file might be covered by the GNU General Public License. */ +/* FIXME: This file has no business including tm.h. */ + #include "tconfig.h" +#include "coretypes.h" +#include "tm.h" #include "objc-api.h" #include "encoding.h" +#include +#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 @@ -54,6 +63,10 @@ Boston, MA 02111-1307, USA. */ #define QUAL_UNION_TYPE _C_UNION_B #define ARRAY_TYPE _C_ARY_B +#define REAL_TYPE _C_DBL + +#define VECTOR_TYPE _C_VECTOR + #define TYPE_FIELDS(TYPE) objc_skip_typespec (TYPE) #define DECL_MODE(TYPE) *(TYPE) @@ -69,23 +82,18 @@ Boston, MA 02111-1307, USA. */ #undef STRUCTURE_SIZE_BOUNDARY #define STRUCTURE_SIZE_BOUNDARY (BITS_PER_UNIT * sizeof (struct{char a;})) -static inline int -atoi (const char* str) -{ - int res = 0; - - while (isdigit (*str)) - res *= 10, res += (*str++ - '0'); - - return res; -} +/* Some ROUND_TYPE_ALIGN macros use TARGET_foo, and consequently + target_flags. Define a dummy entry here to so we don't die. */ +/* ??? 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 == '"') @@ -94,83 +102,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: { @@ -179,7 +189,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; @@ -203,7 +214,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 */ @@ -217,10 +229,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; } } @@ -228,11 +240,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 == '"') @@ -240,75 +252,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: @@ -327,7 +340,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 */ @@ -344,7 +358,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; } } @@ -355,7 +369,7 @@ objc_alignof_type(const char* type) */ int -objc_aligned_size (const char* type) +objc_aligned_size (const char *type) { int size, align; @@ -374,11 +388,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; @@ -390,7 +404,7 @@ objc_promoted_size (const char* type) } size = objc_sizeof_type (type); - wordsize = sizeof (void*); + wordsize = sizeof (void *); return ROUND (size, wordsize); } @@ -400,13 +414,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 @@ -417,14 +431,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 == '"') @@ -434,7 +448,7 @@ objc_skip_typespec (const char* type) } type = objc_skip_type_qualifiers (type); - + switch (*type) { case _C_ID: @@ -445,7 +459,8 @@ objc_skip_typespec (const char* type) return type; else { - while (*++type != '"') /* do nothing */; + while (*++type != '"') + /* do nothing */; return type + 1; } @@ -473,45 +488,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; } } @@ -521,19 +547,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); @@ -543,13 +571,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); @@ -565,9 +593,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); } @@ -576,7 +604,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)) { @@ -587,15 +615,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); @@ -612,15 +639,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); @@ -629,22 +656,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); @@ -655,7 +682,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; @@ -708,7 +735,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); } @@ -737,12 +764,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; @@ -757,7 +783,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 */; @@ -781,12 +807,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; @@ -806,7 +834,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 @@ -838,7 +866,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 @@ -852,7 +880,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; @@ -872,7 +900,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/gc.c b/gc.c index 8ca6de8..1010508 100644 --- a/gc.c +++ b/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)); @@ -324,12 +324,13 @@ __objc_generate_gc_type_description (Class class) if (current + 1 == type_size) class_structure_type = objc_realloc (class_structure_type, ++type_size); strcat (class_structure_type + current, "}"); -// printf ("type description for '%s' is %s\n", class->name, class_structure_type); +#ifdef DEBUG + printf ("type description for '%s' is %s\n", class->name, class_structure_type); +#endif __objc_gc_type_description_from_type (mask, class_structure_type); objc_free (class_structure_type); -#define DEBUG 1 #ifdef DEBUG printf (" mask for '%s', type '%s' (bits %d, mask size %d) is:", class_structure_type, class->name, bits_no, size); @@ -341,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); } @@ -369,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; @@ -389,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); @@ -406,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 */ @@ -421,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 */ @@ -445,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/misc.c b/misc.c index 7339888..9572d3f 100644 --- a/misc.c +++ b/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 -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/nil_method.c b/nil_method.c index 1b62128..5e37c4d 100644 --- a/nil_method.c +++ b/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/objc/encoding.h b/objc/encoding.h index b4def43..36a3d89 100644 --- a/objc/encoding.h +++ b/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/objc/objc.h b/objc/objc.h index 79b2519..699542c 100644 --- a/objc/objc.h +++ b/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/objc/thr.h b/objc/thr.h index 59766f6..48ad0be 100644 --- a/objc/thr.h +++ b/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/objects.c b/objects.c index df74b85..6858fed 100644 --- a/objects.c +++ b/objects.c @@ -32,29 +32,29 @@ Boston, MA 02111-1307, USA. */ # include #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/sarray.c b/sarray.c index 4625fbe..e78e36d 100644 --- a/sarray.c +++ b/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; counterempty_bucket->elems[counter] = default_element; #ifdef OBJC_SPARSE3 - for (counter=0; counterempty_index->buckets[counter] = arr->empty_bucket; - for (counter=0; counterempty_index; #else /* OBJC_SPARSE2 */ - for (counter=0; counterempty_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; c2buckets[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/thr-mach.c b/thr-mach.c index 44af0c1..e954607 100644 --- a/thr-mach.c +++ b/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 Condition functions added by Mircea Oancea @@ -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/thr-objc.c b/thr-objc.c index 48150f0..f57073e 100644 --- a/thr-objc.c +++ b/thr-objc.c @@ -25,6 +25,8 @@ Boston, MA 02111-1307, USA. */ #define _LIBOBJC #include "tconfig.h" +#include "coretypes.h" +#include "tm.h" #include "defaults.h" #include #include "runtime.h" diff --git a/thr.c b/thr.c index 437ee57..bc94473 100644 --- a/thr.c +++ b/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 */