1998-09-21 03:22:07 +02:00
|
|
|
/* GNU Objective C Runtime Thread Interface
|
2013-02-03 12:16:21 +01:00
|
|
|
Copyright (C) 1996-2013 Free Software Foundation, Inc.
|
1998-09-21 03:22:07 +02:00
|
|
|
Contributed by Galen C. Hunt (gchunt@cs.rochester.edu)
|
|
|
|
|
hash.c, [...]: Replace "GNU CC" with "GCC".
* hash.c, init.c, libobjc.def, libobjc_entry.c, linking.m,
makefile.dos, misc.c, nil_method.c, objects.c, sarray.c,
selector.c, sendmsg.c, thr-dce.c, thr-decosf1.c, thr-irix.c,
thr-mach.c, thr-objc.c, thr-os2.c, thr-posix.c, thr-pthreads.c,
thr-rtems.c, thr-single.c, thr-solaris.c, thr-vxworks.c,
thr-win32.c, thr.c: Replace "GNU CC" with "GCC".
From-SVN: r67134
2003-05-23 22:25:39 +02:00
|
|
|
This file is part of GCC.
|
1998-09-21 03:22:07 +02:00
|
|
|
|
hash.c, [...]: Replace "GNU CC" with "GCC".
* hash.c, init.c, libobjc.def, libobjc_entry.c, linking.m,
makefile.dos, misc.c, nil_method.c, objects.c, sarray.c,
selector.c, sendmsg.c, thr-dce.c, thr-decosf1.c, thr-irix.c,
thr-mach.c, thr-objc.c, thr-os2.c, thr-posix.c, thr-pthreads.c,
thr-rtems.c, thr-single.c, thr-solaris.c, thr-vxworks.c,
thr-win32.c, thr.c: Replace "GNU CC" with "GCC".
From-SVN: r67134
2003-05-23 22:25:39 +02:00
|
|
|
GCC is free software; you can redistribute it and/or modify it under the
|
1998-09-21 03:22:07 +02:00
|
|
|
terms of the GNU General Public License as published by the Free Software
|
2009-04-09 17:00:19 +02:00
|
|
|
Foundation; either version 3, or (at your option) any later version.
|
1998-09-21 03:22:07 +02:00
|
|
|
|
hash.c, [...]: Replace "GNU CC" with "GCC".
* hash.c, init.c, libobjc.def, libobjc_entry.c, linking.m,
makefile.dos, misc.c, nil_method.c, objects.c, sarray.c,
selector.c, sendmsg.c, thr-dce.c, thr-decosf1.c, thr-irix.c,
thr-mach.c, thr-objc.c, thr-os2.c, thr-posix.c, thr-pthreads.c,
thr-rtems.c, thr-single.c, thr-solaris.c, thr-vxworks.c,
thr-win32.c, thr.c: Replace "GNU CC" with "GCC".
From-SVN: r67134
2003-05-23 22:25:39 +02:00
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
1998-09-21 03:22:07 +02:00
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
details.
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
permissions described in the GCC Runtime Library Exception, version
|
|
|
|
3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License and
|
|
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-09-12 00:47:14 +02:00
|
|
|
#include "objc-private/common.h"
|
2010-09-12 02:43:15 +02:00
|
|
|
#include "objc-private/error.h"
|
2010-09-08 11:35:50 +02:00
|
|
|
#define _LIBOBJC
|
|
|
|
/* The line below is needed for declarations of functions such as
|
|
|
|
pthread_mutexattr_settype, without which gthr-posix.h may fail to
|
Remove obsolete Tru64 UNIX V5.1B support
libstdc++-v3:
* configure.host: Remove osf* handling.
* config/os/osf: Remove.
* doc/xml/manual/using.xml: Remove OSF reference.
* testsuite/18_support/pthread_guard.cc: Remove alpha*-*-osf*
handling.
* testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc:
Likewise.
* testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc:
Likewise.
* testsuite/21_strings/basic_string/pthread18185.cc: Likewise.
* testsuite/21_strings/basic_string/pthread4.cc: Likewise.
* testsuite/22_locale/locale/cons/12658_thread-1.cc: Likewise.
* testsuite/22_locale/locale/cons/12658_thread-2.cc: Likewise.
* testsuite/23_containers/list/pthread1.cc: Likewise.
* testsuite/23_containers/list/pthread5.cc: Likewise.
* testsuite/23_containers/map/pthread6.cc: Likewise.
* testsuite/23_containers/vector/debug/multithreaded_swap.cc:
Likewise.
* testsuite/27_io/basic_ofstream/pthread2.cc: Likewise.
* testsuite/27_io/basic_ostringstream/pthread3.cc: Likewise.
* testsuite/30_threads/async/42819.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/async/49668.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/async/any.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/async/async.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/async/launch.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/async/sync.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/call_once/39909.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/call_once/49668.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/call_once/call_once1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/condition_variable/cons/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/condition_variable/members/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/condition_variable/members/2.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/condition_variable/native_handle/typesizes.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/condition_variable_any/50862.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/condition_variable_any/cons/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/condition_variable_any/members/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/condition_variable_any/members/2.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/future/cons/move.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/future/members/45133.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/future/members/get.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/future/members/get2.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/future/members/share.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/future/members/valid.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/future/members/wait.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/future/members/wait_for.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/future/members/wait_until.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/lock/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/lock/2.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/lock/3.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/lock/4.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/lock_guard/cons/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/mutex/cons/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/mutex/dest/destructor_locked.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/mutex/lock/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/mutex/native_handle/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/mutex/native_handle/typesizes.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/mutex/try_lock/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/mutex/try_lock/2.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/mutex/unlock/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/49668.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/cons/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/cons/2.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/cons/3.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/cons/alloc.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/cons/move.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/cons/move_assign.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future2.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke2.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke3.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke4.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke5.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/members/reset.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/members/reset2.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/members/swap.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/packaged_task/members/valid.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/promise/cons/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/promise/cons/alloc.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/promise/cons/move.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/promise/cons/move_assign.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/promise/members/get_future.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/promise/members/get_future2.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/promise/members/set_exception.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/promise/members/set_exception2.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/promise/members/set_value.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/promise/members/set_value2.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/promise/members/set_value3.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/promise/members/swap.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_mutex/cons/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_mutex/lock/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_mutex/native_handle/typesizes.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_mutex/try_lock/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_mutex/try_lock/2.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_mutex/unlock/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/cons/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/dest/destructor_locked.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/lock/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/lock/2.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/native_handle/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/native_handle/typesizes.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock/2.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/2.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_for/3.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/try_lock_until/2.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/recursive_timed_mutex/unlock/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/shared_future/cons/move.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/shared_future/members/45133.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/shared_future/members/get.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/shared_future/members/get2.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/shared_future/members/valid.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/shared_future/members/wait.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/shared_future/members/wait_for.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/shared_future/members/wait_until.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/this_thread/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/this_thread/2.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/this_thread/3.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/this_thread/4.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/cons/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/cons/2.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/cons/3.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/cons/4.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/cons/49668.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/cons/5.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/cons/6.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/cons/7.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/cons/8.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/cons/9.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/cons/moveable.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/members/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/members/2.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/members/3.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/members/4.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/members/5.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/thread/members/hardware_concurrency.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/thread/swap/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/timed_mutex/cons/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/timed_mutex/dest/destructor_locked.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/timed_mutex/lock/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/timed_mutex/native_handle/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/timed_mutex/native_handle/typesizes.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock/2.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/2.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_for/3.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/timed_mutex/try_lock_until/2.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/timed_mutex/unlock/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/try_lock/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/try_lock/2.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/try_lock/3.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/try_lock/4.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/unique_lock/cons/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/unique_lock/cons/2.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/unique_lock/cons/3.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/unique_lock/cons/4.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/unique_lock/cons/5.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/unique_lock/cons/6.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/unique_lock/locking/1.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/unique_lock/locking/2.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/unique_lock/locking/3.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/unique_lock/locking/4.cc: Likewise.
* libstdc++-v3/testsuite/30_threads/unique_lock/modifiers/1.cc:
Likewise.
* libstdc++-v3/testsuite/30_threads/unique_lock/modifiers/2.cc:
Likewise.
* libstdc++-v3/testsuite/ext/rope/pthread7-rope.cc: Likewise.
* libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/default_weaktoshared.cc:
Likewise.
* libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/thread/mutex_weaktoshared.cc: Likewise.
libobjc:
* configure.ac (enable_objc_gc): Remove alpha*-dec-osf* handling.
* configure: Regenerate.
* thr.c (_XOPEN_SOURCE): Define unconditionally.
libjava:
* configure.ac (alpha*-dec-osf*): Remove.
* configure: Regenerate.
* configure.host (alpha*-dec-osf*): Remove.
* gnu/java/net/natPlainDatagramSocketImplPosix.cc (setOption): Use
IPV6_MULTICAST_IF unconditionally.
* gnu/java/net/natPlainDatagramSocketImplWin32.cc (setOption):
Likewise.
* gnu/java/net/natPlainSocketImplPosix.cc
(gnu::java::net::PlainSocketImpl::accept): Use ::accept instead of
_Jv_accept.
* include/posix-signal.h [__alpha__ && __osf__]: Remove.
* include/posix.h (_POSIX_PII_SOCKET): Don't define.
(_Jv_accept): Remove.
* java/io/File.java (File._access): Rename to access.
Change callers.
(File._stat): Likewise.
* java/io/File.h: Regenerate.
* classpath/lib/java/io/File.class: Regenerate.
* java/io/natFilePosix.cc (java::io::File::_access): Rename to
access.
(java::io::File::_stat): Rename to stat.
* java/io/natFileWin32.cc: Likewise.
* testsuite/libjava.jni/jni.exp (gcj_jni_get_cxxflags_invocation):
Remove alpha*-dec-osf* handling.
* testsuite/libjava.jvmti/jvmti-interp.exp
(gcj_jni_compile_c_to_so): Likewise.
* testsuite/libjava.jvmti/jvmti.exp (gcj_jvmti_compile_cxx_to_o):
Likewise.
libitm:
* configure.tgt (*-*-osf*): Remove.
* configure: Regenerate.
libgomp:
* configure.tgt (alpha*-dec-osf*): Remove.
* config/osf/sem.h: Remove.
* config/posix/lock.c (_XOPEN_SOURCE): Define unconditionally.
libgfortran:
* configure.ac: Remove Tru64 reference.
* acinclude.m4 (LIBGFOR_GTHREAD_WEAK): Remove alpha*-dec-osf*
handling.
* configure: Regenerate.
* intrinsics/c99_functions.c [__osf__]: Remove.
libgcc:
* config.host: Remove alpha*-dec-osf5.1* handling.
* config/alpha/gthr-posix.c: Remove.
* config/alpha/libgcc-osf5.ver: Remove.
* config/alpha/osf5-unwind.h: Remove.
* config/alpha/t-osf-pthread: Remove.
* config/alpha/t-slibgcc-osf: Remove.
* config/t-crtfm (crtfastmath.o): Remove -frandom-seed.
* gthr-posix.h [!_REENTRANT && __osf__] (_REENTRANT): Don't define.
[__osf__ && _PTHREAD_USE_MANGLED_NAMES_]: Remove.
* mkmap-flat.awk: Remove osf_export handling.
gnattools:
* configure.ac: Remove alpha*-dec-osf* handling.
* configure: Regenerate.
gcc/testsuite:
* g++.dg/abi/rtti3.C: Remove alpha*-dec-osf* handling.
* g++.dg/abi/thunk4.C: Likewise.
* g++.dg/cdce3.C: Don't skip on*-dec-osf5*.
Adapt line numbers.
* g++.dg/compat/struct-layout-1_generate.c: Remove alpha*-dec-osf*
handling.
* g++.dg/cpp0x/constexpr-rom.C: Likewise.
* g++.dg/eh/spbp.C: Likewise.
* g++.dg/ext/label13.C: Likewise.
* g++.dg/guality/guality.exp: Likewise.
* g++.dg/other/anon5.C: Likewise.
* g++.dg/other/pragma-ep-1.C: Remove.
* g++.dg/warn/miss-format-1.C: Remove alpha*-dec-osf* handling.
* g++.dg/warn/pr31246.C: Likewise.
* g++.dg/warn/weak1.C: Likewise.
* g++.old-deja/g++.eh/badalloc1.C: Likewise.
* g++.old-deja/g++.ext/attrib5.C: Likewise.
* gcc.c-torture/compile/limits-declparen.c: Likewise.
* gcc.c-torture/compile/limits-pointer.c: Likewise.
* gcc.c-torture/execute/20001229-1.c: Remove __osf__ handling.
* gcc.dg/attr-weakref-1.c: Remove alpha*-dec-osf* handling.
* gcc.dg/c99-stdint-6.c: Remove alpha*-dec-osf5* handling.
* gcc.dg/c99-tgmath-1.c: Likewise.
* gcc.dg/c99-tgmath-2.c: Likewise.
* gcc.dg/c99-tgmath-3.c: Likewise.
* gcc.dg/c99-tgmath-4.c: Likewise.
* gcc.dg/compat/struct-layout-1_generate.c: Remove alpha*-dec-osf*
handling.
* gcc.dg/debug/pr49032.c: Likewise.
* gcc.dg/guality/guality.exp: Likewise.
* gcc.dg/intmax_t-1.c: Likewise.
* gcc.dg/pr48616.c: Likewise.
* gcc.dg/pragma-ep-1.c: Remove.
* gcc.dg/pragma-ep-2.c: Remove.
* gcc.dg/pragma-ep-3.c: Remove.
* gcc.dg/torture/pr47917.c: Remove alpha*-dec-osf5* handling.
* gcc.dg/tree-ssa/pr42585.c: Remove alpha*-dec-osf* handling.
* gcc.misc-tests/gcov-14.c: Likewise.
* gfortran.dg/guality/guality.exp: Likewise.
* lib/target-supports.exp (check_weak_available): Likewise.
(add_options_for_tls): Likewise.
(check_ascii_locale_available): Likewise.
* obj-c++.dg/dwarf-2.mm: Likewise.
* objc.dg/dwarf-1.m: Likewise.
* objc.dg/dwarf-2.m: Likewise.
gcc/c-family:
* c-cppbuiltin.c (c_cpp_builtins): Remove #pragma extern_prefix
handling.
* c-pragma.c (handle_pragma_extern_prefix): Remove.
(init_pragma): Don't register extern_prefix.
gcc/po:
* EXCLUDES (mips-tdump.c, mips-tfile.c): Remove.
gcc:
* config.gcc (alpha*-dec-osf5.1*): Remove.
* config.host (alpha*-dec-osf*): Remove.
* configure.ac (*-*-osf*): Remove.
(alpha*-dec-osf*): Remove.
* configure: Regenerate.
* config/alpha/host-osf.c, config/alpha/osf5.h,
config/alpha/osf5.opt, config/alpha/va_list.h, config/alpha/x-osf:
Remove.
* config/alpha/alpha.h (TARGET_LD_BUGGY_LDGP): Remove.
* config/alpha/alpha.c (struct machine_function): Update comment.
(alpha_start_function): Remove Tru64 UNIX as handling for
max_frame_size.
* config/alpha/alpha.md ("exception_receiver"): Remove
TARGET_LD_BUGGY_LDGP.
("*exception_receiver_2"): Likewise.
* except.c (finish_eh_generation): Remove Tru64 reference.
* ginclude/stdarg.h [_HIDDEN_VA_LIST]: Don't undef _VA_LIST.
* system.h (TARGET_HANDLE_PRAGMA_EXTERN_PREFIX): Poison.
* target.def (handle_pragma_extern_prefix): Remove.
* Makefile.in (mips-tfile.o-warn): Remove.
(ALL_HOST_BACKEND_OBJS): Remove mips-tfile.o, mips-tdump.o.
(mips-tfile, mips-tfile.o, mips-tdump, mips-tdump.o): Remove.
* mips-tdump.c, mips-tfile.c: Remove.
* doc/extend.texi (Symbol-Renaming Pragmas): Remove #pragma
extern_prefix.
* doc/install.texi (Binaries): Remove Tru64 UNIX reference.
(Specific, alpha*-dec-osf5.1): Note removal.
* doc/tm.texi.in (Misc, TARGET_HANDLE_PRAGMA_EXTERN_PREFIX):
Remove.
* doc/tm.texi: Regenerate.
* doc/trouble.texi (Cross-Compiler Problems): Remove.
gcc/ada:
* gcc-interface/Makefile.in (alpha*-dec-osf*): Remove.
* a-intnam-tru64.ads, mlib-tgt-specific-tru64.adb,
s-mastop-tru64.adb, s-osinte-tru64.adb, s-osinte-tru64.ads,
s-taprop-tru64.adb, s-tasinf-tru64.ads, s-taspri-tru64.ads,
system-tru64.ads: Remove.
* adaint.c (__gnat_number_of_cpus) [__alpha__ && __osf__]:
Remove.
[IS_CROSS] [!(__alpha__ && __osf__)]: Remove.
* env.c [__alpha__ && __osf__]: Remove.
* gsocket.h (_OSF_SOURCE): Remove.
(HAVE_THREAD_SAFE_GETxxxBYyyy) [__osf__]: Remove.
* init.c [__alpha__ && __osf__]: Remove.
* link.c [__osf__]: Remove.
* s-oscons-tmplt.c [__alpha__ && __osf__]: Remove.
[__osf__ && !_SS_MAXSIZE]: Remove.
* sysdep.c [__osf__]: Remove.
* terminals.c [__alpha__ && __osf__]: Remove.
[OSF1]: Remove.
* g-traceb.ads: Remove Tru64 reference.
* g-trasym.ads: Likewise.
* gnat_ugn.texi (Linking a Mixed C++ & Ada Program): Likewise.
(Summary of Run-Time Configurations): Likewise.
* memtrack.adb: Likewise.
fixincludes:
* inclhack.def (alpha___extern_prefix): Remove.
(alpha___extern_prefix_standards): Remove.
(alpha___extern_prefix_sys_stat): Remove.
(alpha_bad_lval): Remove.
(alpha_pthread): Remove.
(alpha_pthread_gcc): Remove.
(alpha_pthread_init): Remove.
* fixincl.x: Regenerate.
* tests/base/pthread.h [ALPHA_PTHREAD_CHECK]: Remove.
[ALPHA_PTHREAD_GCC_CHECK]: Remove.
[ALPHA_PTHREAD_INIT_CHECK]: Remove.
* tests/base/standards.h: Remove.
* tests/base/sys/stat.h [ALPHA___EXTERN_PREFIX_SYS_STAT_CHECK]:
Remove.
* tests/base/testing.h [ALPHA___EXTERN_PREFIX_CHECK]: Remove.
[ALPHA_BAD_LVAL_CHECK]: Remove.
contrib:
* config-list.mk (LIST): Remove alpha-dec-osf5.1.
config:
* weakref.m4 (GCC_CHECK_ELF_STYLE_WEAKREF): Remove
alpha*-dec-osf*.
toplevel:
* MAINTAINERS (OS Port Maintainers): Remove osf.
* configure.ac (enable_libgomp): Remove *-*-osf*.
(with_stabs): Remove alpha*-*-osf*.
* configure: Regenerate.
From-SVN: r185240
2012-03-12 16:35:56 +01:00
|
|
|
compile within libobjc. */
|
2010-09-08 11:35:50 +02:00
|
|
|
#define _XOPEN_SOURCE 500
|
|
|
|
#include "config.h"
|
|
|
|
#include "tconfig.h"
|
|
|
|
#include "coretypes.h"
|
|
|
|
#include "tm.h"
|
|
|
|
#include "defaults.h"
|
|
|
|
#include "objc/thr.h"
|
2010-12-19 02:29:09 +01:00
|
|
|
#include "objc/message.h" /* For objc_msg_lookup(). */
|
2010-10-12 18:17:18 +02:00
|
|
|
#include "objc/runtime.h"
|
2011-06-07 21:37:35 +02:00
|
|
|
#include "objc-private/module-abi-8.h"
|
2010-09-11 14:58:27 +02:00
|
|
|
#include "objc-private/runtime.h"
|
2010-09-08 11:35:50 +02:00
|
|
|
#include <gthr.h>
|
1998-09-21 03:22:07 +02:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
/* Global exit status. */
|
|
|
|
int __objc_thread_exit_status = 0;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Flag which lets us know if we ever became multi threaded. */
|
1998-09-21 03:22:07 +02:00
|
|
|
int __objc_is_multi_threaded = 0;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* The hook function called when the runtime becomes multi
|
|
|
|
threaded. */
|
1998-09-21 03:22:07 +02:00
|
|
|
objc_thread_callback _objc_became_multi_threaded = NULL;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Use this to set the hook function that will be called when the
|
|
|
|
runtime initially becomes multi threaded. The hook function is
|
|
|
|
only called once, meaning only when the 2nd thread is spawned, not
|
|
|
|
for each and every thread.
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
It returns the previous hook function or NULL if there is none.
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
A program outside of the runtime could set this to some function so
|
|
|
|
it can be informed; for example, the GNUstep Base Library sets it
|
|
|
|
so it can implement the NSBecomingMultiThreaded notification. */
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_thread_callback objc_set_thread_callback (objc_thread_callback func)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
|
|
|
objc_thread_callback temp = _objc_became_multi_threaded;
|
|
|
|
_objc_became_multi_threaded = func;
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Private functions.
|
|
|
|
|
|
|
|
These functions are utilized by the runtime, but they are not
|
|
|
|
considered part of the public interface. */
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Initialize the threads subsystem. */
|
2010-09-08 11:35:50 +02:00
|
|
|
int
|
|
|
|
__objc_init_thread_system(void)
|
|
|
|
{
|
|
|
|
return __gthread_objc_init_thread_system ();
|
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* First function called in a thread, starts everything else.
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
This function is passed to the backend by objc_thread_detach as the
|
|
|
|
starting function for a new thread. */
|
1998-09-21 03:22:07 +02:00
|
|
|
struct __objc_thread_start_state
|
|
|
|
{
|
|
|
|
SEL selector;
|
|
|
|
id object;
|
|
|
|
id argument;
|
|
|
|
};
|
|
|
|
|
2004-07-23 00:20:08 +02:00
|
|
|
static void __attribute__((noreturn))
|
|
|
|
__objc_thread_detach_function (struct __objc_thread_start_state *istate)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
|
|
|
/* Valid state? */
|
2010-12-18 13:22:59 +01:00
|
|
|
if (istate)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
|
|
|
/* Clear out the thread local storage. */
|
|
|
|
objc_thread_set_data (NULL);
|
|
|
|
|
|
|
|
/* Check to see if we just became 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) ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the method. */
|
|
|
|
if ((imp = (id (*) (id, SEL, id))objc_msg_lookup (object, selector)))
|
2002-07-02 21:43:03 +02:00
|
|
|
(*imp) (object, selector, argument);
|
2010-12-18 13:22:59 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* FIXME: Should we abort here ? */
|
|
|
|
_objc_abort ("objc_thread_detach called with bad selector.\n");
|
|
|
|
}
|
|
|
|
}
|
1998-09-21 03:22:07 +02:00
|
|
|
else
|
2010-09-12 02:43:15 +02:00
|
|
|
{
|
|
|
|
/* FIXME: Should we abort here ? */
|
|
|
|
_objc_abort ("objc_thread_detach called with NULL state.\n");
|
|
|
|
}
|
2010-12-18 13:22:59 +01:00
|
|
|
|
|
|
|
/* Exit the thread. */
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_thread_exit ();
|
2008-11-21 13:07:43 +01:00
|
|
|
|
|
|
|
/* Make sure compiler detects no return. */
|
|
|
|
__builtin_trap ();
|
1998-09-21 03:22:07 +02:00
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Public functions.
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
These functions constitute the public interface to the Objective-C
|
|
|
|
thread and mutex functionality. */
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Detach a new thread of execution and return its id. Returns NULL
|
|
|
|
if fails. Thread is started by sending message with selector to
|
|
|
|
object. Message takes a single argument. */
|
1998-09-21 03:22:07 +02:00
|
|
|
objc_thread_t
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_thread_detach (SEL selector, id object, id argument)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
|
|
|
struct __objc_thread_start_state *istate;
|
|
|
|
objc_thread_t thread_id = NULL;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Allocate the state structure. */
|
|
|
|
if (!(istate = (struct __objc_thread_start_state *)objc_malloc
|
|
|
|
(sizeof (*istate))))
|
1998-09-21 03:22:07 +02:00
|
|
|
return NULL;
|
2010-12-18 13:22:59 +01:00
|
|
|
|
|
|
|
/* Initialize the state structure. */
|
1998-09-21 03:22:07 +02:00
|
|
|
istate->selector = selector;
|
|
|
|
istate->object = object;
|
|
|
|
istate->argument = argument;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Lock access. */
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_mutex_lock (__objc_runtime_mutex);
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Call the backend to spawn the thread. */
|
2010-09-08 11:35:50 +02:00
|
|
|
if ((thread_id = __gthread_objc_thread_detach ((void *)__objc_thread_detach_function,
|
|
|
|
istate)) == NULL)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Failed! */
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_mutex_unlock (__objc_runtime_mutex);
|
|
|
|
objc_free (istate);
|
1998-09-21 03:22:07 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Increment our thread counter. */
|
1998-09-21 03:22:07 +02:00
|
|
|
__objc_runtime_threads_alive++;
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_mutex_unlock (__objc_runtime_mutex);
|
1998-09-21 03:22:07 +02:00
|
|
|
|
|
|
|
return thread_id;
|
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Set the current thread's priority. */
|
1998-09-21 03:22:07 +02:00
|
|
|
int
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_thread_set_priority (int priority)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
2010-09-08 11:35:50 +02:00
|
|
|
return __gthread_objc_thread_set_priority (priority);
|
1998-09-21 03:22:07 +02:00
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Return the current thread's priority. */
|
1998-09-21 03:22:07 +02:00
|
|
|
int
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_thread_get_priority (void)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
2010-09-08 11:35:50 +02:00
|
|
|
return __gthread_objc_thread_get_priority ();
|
1998-09-21 03:22:07 +02:00
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Yield our process time to another thread. Any BUSY waiting that is
|
|
|
|
done by a thread should use this function to make sure that other
|
|
|
|
threads can make progress even on a lazy uniprocessor system. */
|
1998-09-21 03:22:07 +02:00
|
|
|
void
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_thread_yield (void)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
2010-09-08 11:35:50 +02:00
|
|
|
__gthread_objc_thread_yield ();
|
1998-09-21 03:22:07 +02:00
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Terminate the current tread. Doesn't return. Actually, if it
|
|
|
|
failed returns -1. */
|
1998-09-21 03:22:07 +02:00
|
|
|
int
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_thread_exit (void)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Decrement our counter of the number of threads alive. */
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_mutex_lock (__objc_runtime_mutex);
|
1998-09-21 03:22:07 +02:00
|
|
|
__objc_runtime_threads_alive--;
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_mutex_unlock (__objc_runtime_mutex);
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Call the backend to terminate the thread. */
|
2010-09-08 11:35:50 +02:00
|
|
|
return __gthread_objc_thread_exit ();
|
1998-09-21 03:22:07 +02:00
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Returns an integer value which uniquely describes a thread. Must
|
|
|
|
not be NULL which is reserved as a marker for "no thread". */
|
1998-09-21 03:22:07 +02:00
|
|
|
objc_thread_t
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_thread_id (void)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
2010-09-08 11:35:50 +02:00
|
|
|
return __gthread_objc_thread_id ();
|
1998-09-21 03:22:07 +02:00
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Sets the thread's local storage pointer. Returns 0 if successful
|
|
|
|
or -1 if failed. */
|
1998-09-21 03:22:07 +02:00
|
|
|
int
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_thread_set_data (void *value)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
2010-09-08 11:35:50 +02:00
|
|
|
return __gthread_objc_thread_set_data (value);
|
1998-09-21 03:22:07 +02:00
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Returns the thread's local storage pointer. Returns NULL on
|
|
|
|
failure. */
|
1998-09-21 03:22:07 +02:00
|
|
|
void *
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_thread_get_data (void)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
2010-09-08 11:35:50 +02:00
|
|
|
return __gthread_objc_thread_get_data ();
|
1998-09-21 03:22:07 +02:00
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Public mutex functions */
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Allocate a mutex. Return the mutex pointer if successful or NULL
|
|
|
|
if the allocation failed for any reason. */
|
1998-09-21 03:22:07 +02:00
|
|
|
objc_mutex_t
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_mutex_allocate (void)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
|
|
|
objc_mutex_t mutex;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Allocate the mutex structure. */
|
2002-07-02 21:43:03 +02:00
|
|
|
if (! (mutex = (objc_mutex_t)objc_malloc (sizeof (struct objc_mutex))))
|
1998-09-21 03:22:07 +02:00
|
|
|
return NULL;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Call backend to create the mutex. */
|
2010-09-08 11:35:50 +02:00
|
|
|
if (__gthread_objc_mutex_allocate (mutex))
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Failed! */
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_free (mutex);
|
1998-09-21 03:22:07 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Initialize mutex. */
|
1998-09-21 03:22:07 +02:00
|
|
|
mutex->owner = NULL;
|
|
|
|
mutex->depth = 0;
|
|
|
|
return mutex;
|
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Deallocate a mutex. Note that this includes an implicit mutex_lock
|
|
|
|
to insure that no one else is using the lock. It is legal to
|
|
|
|
deallocate a lock if we have a lock on it, but illegal to
|
|
|
|
deallocate a lock held by anyone else. Returns the number of locks
|
|
|
|
on the thread. (1 for deallocate). */
|
1998-09-21 03:22:07 +02:00
|
|
|
int
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_mutex_deallocate (objc_mutex_t mutex)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
|
|
|
int depth;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Valid mutex? */
|
2002-07-02 21:43:03 +02:00
|
|
|
if (! mutex)
|
1998-09-21 03:22:07 +02:00
|
|
|
return -1;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Acquire lock on mutex. */
|
2002-07-02 21:43:03 +02:00
|
|
|
depth = objc_mutex_lock (mutex);
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Call backend to destroy mutex. */
|
2010-09-08 11:35:50 +02:00
|
|
|
if (__gthread_objc_mutex_deallocate (mutex))
|
1998-09-21 03:22:07 +02:00
|
|
|
return -1;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Free the mutex structure. */
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_free (mutex);
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Return last depth. */
|
1998-09-21 03:22:07 +02:00
|
|
|
return depth;
|
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Grab a lock on a mutex. If this thread already has a lock on this
|
|
|
|
mutex then we increment the lock count. If another thread has a
|
|
|
|
lock on the mutex we block and wait for the thread to release the
|
|
|
|
lock. Returns the lock count on the mutex held by this thread. */
|
1998-09-21 03:22:07 +02:00
|
|
|
int
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_mutex_lock (objc_mutex_t mutex)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
|
|
|
objc_thread_t thread_id;
|
|
|
|
int status;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Valid mutex? */
|
2002-07-02 21:43:03 +02:00
|
|
|
if (! mutex)
|
1998-09-21 03:22:07 +02:00
|
|
|
return -1;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* If we already own the lock then increment depth. */
|
2010-09-08 11:35:50 +02:00
|
|
|
thread_id = __gthread_objc_thread_id ();
|
1998-09-21 03:22:07 +02:00
|
|
|
if (mutex->owner == thread_id)
|
|
|
|
return ++mutex->depth;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Call the backend to lock the mutex. */
|
2010-09-08 11:35:50 +02:00
|
|
|
status = __gthread_objc_mutex_lock (mutex);
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Failed? */
|
1998-09-21 03:22:07 +02:00
|
|
|
if (status)
|
|
|
|
return status;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Successfully locked the thread. */
|
1998-09-21 03:22:07 +02:00
|
|
|
mutex->owner = thread_id;
|
|
|
|
return mutex->depth = 1;
|
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Try to grab a lock on a mutex. If this thread already has a lock
|
|
|
|
on this mutex then we increment the lock count and return it. If
|
|
|
|
another thread has a lock on the mutex returns -1. */
|
1998-09-21 03:22:07 +02:00
|
|
|
int
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_mutex_trylock (objc_mutex_t mutex)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
|
|
|
objc_thread_t thread_id;
|
|
|
|
int status;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Valid mutex? */
|
2002-07-02 21:43:03 +02:00
|
|
|
if (! mutex)
|
1998-09-21 03:22:07 +02:00
|
|
|
return -1;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* If we already own the lock then increment depth. */
|
2010-09-08 11:35:50 +02:00
|
|
|
thread_id = __gthread_objc_thread_id ();
|
1998-09-21 03:22:07 +02:00
|
|
|
if (mutex->owner == thread_id)
|
|
|
|
return ++mutex->depth;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Call the backend to try to lock the mutex. */
|
2010-09-08 11:35:50 +02:00
|
|
|
status = __gthread_objc_mutex_trylock (mutex);
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Failed? */
|
1998-09-21 03:22:07 +02:00
|
|
|
if (status)
|
|
|
|
return status;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Successfully locked the thread. */
|
1998-09-21 03:22:07 +02:00
|
|
|
mutex->owner = thread_id;
|
|
|
|
return mutex->depth = 1;
|
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Unlocks the mutex by one level. Decrements the lock count on this
|
|
|
|
mutex by one. If the lock count reaches zero, release the lock on
|
|
|
|
the mutex. Returns the lock count on the mutex. It is an error to
|
|
|
|
attempt to unlock a mutex which this thread doesn't hold in which
|
|
|
|
case return -1 and the mutex is unaffected. */
|
1998-09-21 03:22:07 +02:00
|
|
|
int
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_mutex_unlock (objc_mutex_t mutex)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
|
|
|
objc_thread_t thread_id;
|
|
|
|
int status;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Valid mutex? */
|
2002-07-02 21:43:03 +02:00
|
|
|
if (! mutex)
|
1998-09-21 03:22:07 +02:00
|
|
|
return -1;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* If another thread owns the lock then abort. */
|
2010-09-08 11:35:50 +02:00
|
|
|
thread_id = __gthread_objc_thread_id ();
|
1998-09-21 03:22:07 +02:00
|
|
|
if (mutex->owner != thread_id)
|
|
|
|
return -1;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Decrement depth and return. */
|
1998-09-21 03:22:07 +02:00
|
|
|
if (mutex->depth > 1)
|
|
|
|
return --mutex->depth;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Depth down to zero so we are no longer the owner. */
|
1998-09-21 03:22:07 +02:00
|
|
|
mutex->depth = 0;
|
|
|
|
mutex->owner = NULL;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Have the backend unlock the mutex. */
|
2010-09-08 11:35:50 +02:00
|
|
|
status = __gthread_objc_mutex_unlock (mutex);
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Failed? */
|
1998-09-21 03:22:07 +02:00
|
|
|
if (status)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Public condition mutex functions */
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Allocate a condition. Return the condition pointer if successful
|
|
|
|
or NULL if the allocation failed for any reason. */
|
1998-09-21 03:22:07 +02:00
|
|
|
objc_condition_t
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_condition_allocate (void)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
|
|
|
objc_condition_t condition;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Allocate the condition mutex structure. */
|
2002-07-02 21:43:03 +02:00
|
|
|
if (! (condition =
|
|
|
|
(objc_condition_t) objc_malloc (sizeof (struct objc_condition))))
|
1998-09-21 03:22:07 +02:00
|
|
|
return NULL;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Call the backend to create the condition mutex. */
|
2010-09-08 11:35:50 +02:00
|
|
|
if (__gthread_objc_condition_allocate (condition))
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Failed! */
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_free (condition);
|
1998-09-21 03:22:07 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Success! */
|
1998-09-21 03:22:07 +02:00
|
|
|
return condition;
|
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Deallocate a condition. Note that this includes an implicit
|
|
|
|
condition_broadcast to insure that waiting threads have the
|
|
|
|
opportunity to wake. It is legal to dealloc a condition only if no
|
|
|
|
other thread is/will be using it. Here we do NOT check for other
|
|
|
|
threads waiting but just wake them up. */
|
1998-09-21 03:22:07 +02:00
|
|
|
int
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_condition_deallocate (objc_condition_t condition)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Broadcast the condition. */
|
2002-07-02 21:43:03 +02:00
|
|
|
if (objc_condition_broadcast (condition))
|
1998-09-21 03:22:07 +02:00
|
|
|
return -1;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Call the backend to destroy. */
|
2010-09-08 11:35:50 +02:00
|
|
|
if (__gthread_objc_condition_deallocate (condition))
|
1998-09-21 03:22:07 +02:00
|
|
|
return -1;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Free the condition mutex structure. */
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_free (condition);
|
1998-09-21 03:22:07 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* 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. */
|
1998-09-21 03:22:07 +02:00
|
|
|
int
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
|
|
|
objc_thread_t thread_id;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Valid arguments? */
|
2002-07-02 21:43:03 +02:00
|
|
|
if (! mutex || ! condition)
|
1998-09-21 03:22:07 +02:00
|
|
|
return -1;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Make sure we are owner of mutex. */
|
2010-09-08 11:35:50 +02:00
|
|
|
thread_id = __gthread_objc_thread_id ();
|
1998-09-21 03:22:07 +02:00
|
|
|
if (mutex->owner != thread_id)
|
|
|
|
return -1;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Cannot be locked more than once. */
|
1998-09-21 03:22:07 +02:00
|
|
|
if (mutex->depth > 1)
|
|
|
|
return -1;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Virtually unlock the mutex. */
|
1998-09-21 03:22:07 +02:00
|
|
|
mutex->depth = 0;
|
|
|
|
mutex->owner = (objc_thread_t)NULL;
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Call the backend to wait. */
|
2010-09-08 11:35:50 +02:00
|
|
|
__gthread_objc_condition_wait (condition, mutex);
|
1998-09-21 03:22:07 +02:00
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Make ourselves owner of the mutex. */
|
1998-09-21 03:22:07 +02:00
|
|
|
mutex->owner = thread_id;
|
|
|
|
mutex->depth = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Wake up all threads waiting on this condition. It is recommended
|
|
|
|
that the called would lock the same mutex as the threads in
|
|
|
|
objc_condition_wait before changing the "condition predicate" and
|
|
|
|
make this call and unlock it right away after this call. */
|
1998-09-21 03:22:07 +02:00
|
|
|
int
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_condition_broadcast (objc_condition_t condition)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Valid condition mutex? */
|
2002-07-02 21:43:03 +02:00
|
|
|
if (! condition)
|
1998-09-21 03:22:07 +02:00
|
|
|
return -1;
|
|
|
|
|
2010-09-08 11:35:50 +02:00
|
|
|
return __gthread_objc_condition_broadcast (condition);
|
1998-09-21 03:22:07 +02:00
|
|
|
}
|
|
|
|
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Wake up one thread waiting on this condition. It is recommended
|
|
|
|
that the called would lock the same mutex as the threads in
|
|
|
|
objc_condition_wait before changing the "condition predicate" and
|
|
|
|
make this call and unlock it right away after this call. */
|
1998-09-21 03:22:07 +02:00
|
|
|
int
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_condition_signal (objc_condition_t condition)
|
1998-09-21 03:22:07 +02:00
|
|
|
{
|
2010-12-18 13:22:59 +01:00
|
|
|
/* Valid condition mutex? */
|
2002-07-02 21:43:03 +02:00
|
|
|
if (! condition)
|
1998-09-21 03:22:07 +02:00
|
|
|
return -1;
|
|
|
|
|
2010-09-08 11:35:50 +02:00
|
|
|
return __gthread_objc_condition_signal (condition);
|
1998-09-21 03:22:07 +02:00
|
|
|
}
|
|
|
|
|
2001-03-15 03:18:09 +01:00
|
|
|
/* 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
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_thread_add () before an alien thread makes any calls to
|
2001-03-15 03:18:09 +01:00
|
|
|
Objective-C. Do not cause the _objc_became_multi_threaded hook to
|
|
|
|
be executed. */
|
|
|
|
void
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_thread_add (void)
|
2001-03-15 03:18:09 +01:00
|
|
|
{
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_mutex_lock (__objc_runtime_mutex);
|
2001-03-15 03:18:09 +01:00
|
|
|
__objc_is_multi_threaded = 1;
|
|
|
|
__objc_runtime_threads_alive++;
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_mutex_unlock (__objc_runtime_mutex);
|
2001-03-15 03:18:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_thread_remove () when your alien thread is done with making
|
2001-03-15 03:18:09 +01:00
|
|
|
calls to Objective-C. */
|
|
|
|
void
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_thread_remove (void)
|
2001-03-15 03:18:09 +01:00
|
|
|
{
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_mutex_lock (__objc_runtime_mutex);
|
2001-03-15 03:18:09 +01:00
|
|
|
__objc_runtime_threads_alive--;
|
2002-07-02 21:43:03 +02:00
|
|
|
objc_mutex_unlock (__objc_runtime_mutex);
|
2001-03-15 03:18:09 +01:00
|
|
|
}
|
|
|
|
|