This commit was generated by cvs2svn to compensate for changes in r16049,

which included commits to RCS files with non-trunk default branches.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/libobjc/trunk@16050 72102866-910b-0410-8b05-ffd578937521
main
fedor 23 years ago
parent eeb9393578
commit 5c8c6241e1

@ -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:

@ -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;
}

@ -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;
}

@ -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

231
aclocal.m4 vendored

@ -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])
])

@ -1,5 +1,5 @@
/* GNU Objective C Runtime archiving
Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
Contributed by Kresten Krab Thorup
This file is part of GNU CC.
@ -28,10 +28,7 @@ Boston, MA 02111-1307, USA. */
#include "runtime.h"
#include "typedstream.h"
#include "encoding.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
extern int fflush (FILE *);
@ -566,7 +563,7 @@ objc_read_short (struct objc_typed_stream* stream, short* value)
{
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
if (nbytes > sizeof (short))
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);
@ -595,7 +592,7 @@ objc_read_unsigned_short (struct objc_typed_stream* stream,
{
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
if (nbytes > sizeof (short))
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);
@ -622,7 +619,7 @@ objc_read_int (struct objc_typed_stream* stream, int* value)
{
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
if (nbytes > sizeof (int))
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;
@ -649,7 +646,7 @@ objc_read_long (struct objc_typed_stream* stream, long* value)
{
int pos = 1;
int nbytes = buf[0] & _B_NUMBER;
if (nbytes > sizeof (long))
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;
@ -666,7 +663,8 @@ __inline__ int
__objc_read_nbyte_uint (struct objc_typed_stream *stream,
unsigned int nbytes, unsigned int *val)
{
int len, pos = 0;
int len;
unsigned int pos = 0;
unsigned char buf[sizeof (unsigned int) + 1];
if (nbytes > sizeof (int))
@ -702,7 +700,8 @@ int
__objc_read_nbyte_ulong (struct objc_typed_stream *stream,
unsigned int nbytes, unsigned long *val)
{
int len, pos = 0;
int len;
unsigned int pos = 0;
unsigned char buf[sizeof (unsigned long) + 1];
if (nbytes > sizeof (long))
@ -909,7 +908,7 @@ objc_read_class (struct objc_typed_stream* stream, Class* class)
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));
*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);
@ -1032,7 +1031,8 @@ objc_write_type(TypedStream* stream, const char* type, const void* 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:
@ -1043,7 +1043,7 @@ objc_write_type(TypedStream* stream, const char* type, const void* data)
case _C_ARY_B:
{
int len = atoi (type + 1);
while (isdigit(*++type))
while (isdigit ((unsigned char) *++type))
;
return objc_write_array (stream, type, len, data);
}
@ -1139,7 +1139,7 @@ objc_read_type(TypedStream* stream, const char* type, void* data)
case _C_ARY_B:
{
int len = atoi (type + 1);
while (isdigit(*++type))
while (isdigit ((unsigned char) *++type))
;
return objc_read_array (stream, type, len, data);
}
@ -1257,7 +1257,7 @@ objc_write_types (TypedStream* stream, const char* type, ...)
{
int len = atoi (c + 1);
const char *t = c;
while (isdigit(*++t))
while (isdigit ((unsigned char) *++t))
;
res = objc_write_array (stream, t, len, va_arg (args, void *));
t = objc_skip_typespec (t);
@ -1349,7 +1349,7 @@ objc_read_types(TypedStream* stream, const char* type, ...)
{
int len = atoi (c + 1);
const char *t = c;
while (isdigit(*++t))
while (isdigit ((unsigned char) *++t))
;
res = objc_read_array (stream, t, len, va_arg (args, void *));
t = objc_skip_typespec (t);
@ -1428,14 +1428,18 @@ __objc_feof(FILE* 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;

@ -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,44 +27,412 @@ 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. */
/*
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 <objc/objc.h>
#include <objc/objc-api.h>
#include <objc/thr.h>
/* 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
**/
/* 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 ();
}
/* 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)
{
int hash, length;
class_node_ptr new_node;
/* 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);
}
/* 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_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;
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 */
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 */
/* True when class links has been resolved. */
BOOL __objc_class_links_resolved = NO; /* !T:UNUSED */
/* Initial number of buckets size of class hash table. */
#define CLASS_HASH_SIZE 32
void __objc_init_class_tables()
void
__objc_init_class_tables (void)
{
/* Allocate the class hash table */
/* Allocate the class hash table. */
if(__objc_class_hash)
if (__class_table_lock)
return;
objc_mutex_lock (__objc_runtime_mutex);
__objc_class_hash
= hash_new (CLASS_HASH_SIZE,
(hash_func_type) hash_string,
(compare_func_type) compare_strings);
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 */
class a number, unless it's already known. */
void
__objc_add_class_to_hash (Class class)
{
@ -68,14 +440,14 @@ __objc_add_class_to_hash(Class class)
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 */
/* 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);
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
@ -86,7 +458,7 @@ __objc_add_class_to_hash(Class class)
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);
@ -94,19 +466,13 @@ __objc_add_class_to_hash(Class class)
/* 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;
@ -119,20 +485,13 @@ Class objc_lookup_class (const char* name)
/* 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;
@ -166,47 +525,46 @@ objc_get_meta_class(const char *name)
Class
objc_next_class (void **enum_state)
{
Class class;
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);
*(node_ptr*)enum_state =
hash_next(__objc_class_hash, *(node_ptr*)enum_state);
class = class_table_next ((struct class_table_enumerator **) enum_state);
objc_mutex_unlock (__objc_runtime_mutex);
if (*(node_ptr*)enum_state)
return (*(node_ptr*)enum_state)->value;
return (Class)0;
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()
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);
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));
/* 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);
@ -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,11 +602,10 @@ 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)
@ -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))
__objc_resolve_class_links ();
/* preconditions */
/* Preconditions */
assert (impostor);
assert (super_class);
assert (impostor->super_class == super_class);
@ -286,7 +640,7 @@ 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;
@ -295,18 +649,19 @@ class_pose_as (Class impostor, Class super_class)
{
Class sub = *subclass;
/* classes */
/* 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. */
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 */
/* Meta classes */
CLASSOF (sub)->sibling_class =
CLASSOF (impostor)->subclass_list;
CLASSOF (sub)->super_class = CLASSOF (impostor);
@ -317,42 +672,32 @@ class_pose_as (Class impostor, Class super_class)
*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);
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);
/* 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;
}

1886
configure vendored

File diff suppressed because it is too large Load Diff

@ -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.],
@ -147,7 +104,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],
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: ""

@ -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,18 +27,26 @@ 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 <stdlib.h>
#undef MAX
#define MAX(X, Y) \
({ typeof (X) __x = (X), __y = (Y); \
(__x > __y ? __x : __y); })
#undef MIN
#define MIN(X, 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); })
@ -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,16 +82,11 @@ 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
@ -158,6 +166,7 @@ objc_sizeof_type (const char* type)
case _C_VOID:
return sizeof (void);
break;
case _C_PTR:
case _C_ATOM:
case _C_CHARPTR:
@ -167,7 +176,8 @@ objc_sizeof_type (const char* type)
case _C_ARY_B:
{
int len = atoi (type + 1);
while (isdigit(*++type));
while (isdigit ((unsigned char)*++type))
;
return len * objc_aligned_size (type);
}
break;
@ -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 */
@ -308,7 +320,8 @@ objc_alignof_type(const char* type)
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 */
@ -445,7 +459,8 @@ objc_skip_typespec (const char* type)
return type;
else
{
while (*++type != '"') /* do nothing */;
while (*++type != '"')
/* do nothing */;
return type + 1;
}
@ -474,7 +489,8 @@ objc_skip_typespec (const char* type)
case _C_ARY_B:
/* skip digits, typespec and closing ']' */
while(isdigit(*++type));
while (isdigit ((unsigned char)*++type))
;
type = objc_skip_typespec (type);
if (*type == _C_ARY_E)
return ++type;
@ -486,22 +502,32 @@ objc_skip_typespec (const char* type)
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:
@ -524,8 +550,10 @@ objc_skip_typespec (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;
}
@ -594,8 +622,7 @@ method_get_sizeof_arguments (struct objc_method* mth)
*/
char *
method_get_next_argument (arglist_t argframe,
const char **type)
method_get_next_argument (arglist_t argframe, const char **type)
{
const char *t = objc_skip_argspec (*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 */;
@ -786,7 +812,9 @@ objc_layout_structure_next_member (struct objc_struct_layout *layout)
{
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

15
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.
@ -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);
@ -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__)))
{
}

@ -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.
@ -148,7 +149,8 @@ objc_free(void *mem)
#if OBJC_WITH_GC
#include <gc.h>
static void *GC_calloc (size_t nelem, size_t size)
static void *
GC_calloc (size_t nelem, size_t size)
{
void *p = GC_malloc (nelem * size);
if (! p)
@ -158,7 +160,10 @@ static void *GC_calloc (size_t nelem, size_t 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;
@ -167,7 +172,7 @@ 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;
@ -177,4 +182,4 @@ void *(*_objc_calloc)(size_t, size_t) = calloc;
void (*_objc_free) (void *) = free;
#endif
#endif /* !OBJC_WITH_GC */

@ -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;
}

@ -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

@ -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, ...);

@ -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.
@ -111,7 +111,7 @@ 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)();
typedef void (*objc_thread_callback) (void);
objc_thread_callback objc_set_thread_callback (objc_thread_callback func);
/* Backend initialization functions */

@ -101,5 +101,3 @@ id __objc_object_copy(id object)
memcpy (copy, object, object->class_pointer->instance_size);
return copy;
}

@ -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.
@ -211,7 +211,7 @@ sarray_new (int size, void* default_element)
size_t num_indices = ((size - 1)/BUCKET_SIZE) + 1;
struct sbucket **new_buckets;
#endif
int counter;
size_t counter;
assert (size > 0);
@ -302,7 +302,7 @@ sarray_realloc(struct sarray* array, int newsize)
#endif
int counter;
size_t counter;
assert (newsize > 0);
@ -383,7 +383,6 @@ sarray_realloc(struct sarray* array, int newsize)
void
sarray_free (struct sarray *array) {
#ifdef OBJC_SPARSE3
size_t old_max_index = (array->capacity - 1)/INDEX_CAPACITY;
struct sindex **old_indices;
@ -391,7 +390,7 @@ sarray_free(struct sarray* array) {
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!!! */
@ -499,15 +498,13 @@ sarray_lazy_copy(struct sarray* oarr)
/* Copy bucket table */
new_indices = (struct sindex **)
objc_malloc (sizeof (struct sindex *) * num_indices);
memcpy( new_indices,oarr->indices,
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);
memcpy (new_buckets, oarr->buckets, sizeof (struct sbucket *) * num_indices);
arr->buckets = new_buckets;
#endif

@ -1,5 +1,5 @@
/* GNU Objective C Runtime Thread Implementation
Copyright (C) 1996, 1997 Free Software Foundation, Inc.
Copyright (C) 1996, 1997, 2002 Free Software Foundation, Inc.
Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
Modified for Mach threads by Bill Bumgarner <bbum@friday.com>
Condition functions added by Mircea Oancea <mircea@first.elcom.pub.ro>
@ -37,7 +37,8 @@ Boston, MA 02111-1307, USA. */
maximum priority downward only-- cannot be raised without superuser
privileges. Once lowered, it cannot be raised.
*/
static int __mach_get_max_thread_priority(cthread_t t, int *base)
static int
__mach_get_max_thread_priority (cthread_t t, int *base)
{
thread_t threadP;
kern_return_t error;

@ -25,6 +25,8 @@ Boston, MA 02111-1307, USA. */
#define _LIBOBJC
#include "tconfig.h"
#include "coretypes.h"
#include "tm.h"
#include "defaults.h"
#include <objc/thr.h>
#include "runtime.h"

@ -318,7 +318,7 @@ objc_mutex_lock(objc_mutex_t 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;
@ -350,7 +350,7 @@ objc_mutex_trylock(objc_mutex_t 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;
@ -385,7 +385,7 @@ objc_mutex_unlock(objc_mutex_t 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;
@ -477,7 +477,7 @@ objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex)
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;

Loading…
Cancel
Save