From 630d52ca0a88d173f89634a5d7dd8aee07d04d80 Mon Sep 17 00:00:00 2001 From: ro Date: Wed, 2 Nov 2011 15:28:43 +0000 Subject: Move gthr to toplevel libgcc gcc: * gthr-single.h, gthr.h: Move to ../libgcc. * gthr-aix.h: Move to ../libgcc/config/rs6000. * gthr-dce.h: Move to ../libgcc/config/pa. * gthr-lynx.h: Move to ../libgcc/config. * gthr-mipssde.h: Move to ../libgcc/config/mips. * gthr-posix.h: Move to ../libgcc/config. * gthr-rtems.h: Likewise. * gthr-tpf.h: Move to ../libgcc/config/s390. * gthr-vxworks.h: Move to ../libgcc/config. * gthr-win32.h: Move to ../libgcc/config/i386. * configure.ac (gthread_flags): Remove (gthr-default.h): Don't create. (thread_file): Don't substitute. * configure: Regenerate. * Makefile.in (GCC_THREAD_FILE): Remove. (GTHREAD_FLAGS): Remove. (libgcc.mvars): Remove GTHREAD_FLAGS. * config/t-vxworks (EXTRA_HEADERS): Remove. gcc/po: * EXCLUDES (gthr-aix.h, gthr-dce.h, gthr-posix.c, gthr-posix.h) (gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h) (gthr-win32.h, gthr.h): Remove. libgcc: * gthr-single.h, gthr.h: New files. * config/gthr-lynx.h, config/gthr-posix.h., config/gthr-rtems.h, config/gthr-vxworks.h, config/i386/gthr-win32.h, config/mips/gthr-mipssde.h, config/pa/gthr-dce.h, config/rs6000/gthr-aix.h, config/s390/gthr-tpf.h: New files. * config/i386/gthr-win32.c: Include "gthr-win32.h". * configure.ac (thread_header): New variable. Set it depending on target_thread_file. (gthr-default.h): Link from $thread_header. * configure: Regenerate. * Makefile.in (LIBGCC2_CFLAGS): Remove $(GTHREAD_FLAGS). libgfortran: * Makefile.am (AM_CPPFLAGS): Add -I$(srcdir)/$(MULTISRCTOP)../libgcc, -I$(MULTIBUILDTOP)../libgcc. * Makefile.in: Regenerate. * acinclude.m4 (LIBGFOR_CHECK_GTHR_DEFAULT): Remove. * configure.ac (LIBGFOR_CHECK_GTHR_DEFAULT): Likewise. * configure: Regenerate. * config.h.in: Regenerate. libobjc: * Makefile.in (INCLUDES): Add -I$(MULTIBUILDTOP)../libgcc. * configure.ac (target_thread_file, HAVE_GTHR_DEFAULT): Remove. * configure: Regenerate. * config.h.in: Regenerate. libstdc++-v3: * acinclude.m4 (GLIBCXX_CONFIGURE): Determine and substitute toplevel_builddir. (GLIBCXX_ENABLE_THREADS): Remove glibcxx_thread_h, HAVE_GTHR_DEFAULT, enable_thread. (GLIBCXX_CHECK_GTHREADS): Reflect gthr move to libgcc. * include/Makefile.am (thread_host_headers): Remove ${host_builddir}/gthr-tpf.h. (${host_builddir}/gthr.h): Reflect gthr move to libgcc. Use $<. (${host_builddir}/gthr-single.h): Likewise. (${host_builddir}/gthr-posix.h): Likewise. (${host_builddir}/gthr-tpf.h): Remove. (${host_builddir}/gthr-default.h): Likewise. * configure, config.h.in: Regenerate. * Makefile.in, doc/Makefile.in, include/Makefile.in, libsupc++/Makefile.in, po/Makefile.in, python/Makefile.in, src/Makefile.intestsuite/Makefile.in: Regenerate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180776 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 21 + gcc/Makefile.in | 3 - gcc/config/t-vxworks | 4 - gcc/configure | 20 +- gcc/configure.ac | 14 - gcc/gthr-aix.h | 35 -- gcc/gthr-dce.h | 563 ------------------------ gcc/gthr-lynx.h | 61 --- gcc/gthr-mipssde.h | 230 ---------- gcc/gthr-posix.h | 879 ------------------------------------- gcc/gthr-rtems.h | 157 ------- gcc/gthr-single.h | 292 ------------ gcc/gthr-tpf.h | 229 ---------- gcc/gthr-vxworks.h | 169 ------- gcc/gthr-win32.h | 772 -------------------------------- gcc/gthr.h | 168 ------- gcc/po/ChangeLog | 6 + gcc/po/EXCLUDES | 10 - libgcc/ChangeLog | 14 + libgcc/Makefile.in | 3 +- libgcc/config/gthr-lynx.h | 61 +++ libgcc/config/gthr-posix.h | 879 +++++++++++++++++++++++++++++++++++++ libgcc/config/gthr-rtems.h | 157 +++++++ libgcc/config/gthr-vxworks.h | 170 +++++++ libgcc/config/i386/gthr-win32.c | 5 +- libgcc/config/i386/gthr-win32.h | 772 ++++++++++++++++++++++++++++++++ libgcc/config/mips/gthr-mipssde.h | 230 ++++++++++ libgcc/config/pa/gthr-dce.h | 563 ++++++++++++++++++++++++ libgcc/config/rs6000/gthr-aix.h | 35 ++ libgcc/config/s390/gthr-tpf.h | 229 ++++++++++ libgcc/configure | 52 ++- libgcc/configure.ac | 15 + libgcc/gthr-single.h | 292 ++++++++++++ libgcc/gthr.h | 148 +++++++ libgfortran/ChangeLog | 10 + libgfortran/Makefile.am | 4 +- libgfortran/Makefile.in | 4 +- libgfortran/acinclude.m4 | 11 - libgfortran/config.h.in | 3 - libgfortran/configure | 19 - libgfortran/configure.ac | 3 - libobjc/ChangeLog | 7 + libobjc/Makefile.in | 1 + libobjc/config.h.in | 3 - libobjc/configure | 14 +- libobjc/configure.ac | 9 - libstdc++-v3/ChangeLog | 20 + libstdc++-v3/Makefile.in | 2 +- libstdc++-v3/acinclude.m4 | 30 +- libstdc++-v3/config.h.in | 4 - libstdc++-v3/configure | 44 +- libstdc++-v3/doc/Makefile.in | 2 +- libstdc++-v3/include/Makefile.am | 25 +- libstdc++-v3/include/Makefile.in | 27 +- libstdc++-v3/libsupc++/Makefile.in | 2 +- libstdc++-v3/po/Makefile.in | 2 +- libstdc++-v3/python/Makefile.in | 2 +- libstdc++-v3/src/Makefile.in | 2 +- libstdc++-v3/testsuite/Makefile.in | 2 +- 59 files changed, 3721 insertions(+), 3789 deletions(-) delete mode 100644 gcc/gthr-aix.h delete mode 100644 gcc/gthr-dce.h delete mode 100644 gcc/gthr-lynx.h delete mode 100644 gcc/gthr-mipssde.h delete mode 100644 gcc/gthr-posix.h delete mode 100644 gcc/gthr-rtems.h delete mode 100644 gcc/gthr-single.h delete mode 100644 gcc/gthr-tpf.h delete mode 100644 gcc/gthr-vxworks.h delete mode 100644 gcc/gthr-win32.h delete mode 100644 gcc/gthr.h create mode 100644 libgcc/config/gthr-lynx.h create mode 100644 libgcc/config/gthr-posix.h create mode 100644 libgcc/config/gthr-rtems.h create mode 100644 libgcc/config/gthr-vxworks.h create mode 100644 libgcc/config/i386/gthr-win32.h create mode 100644 libgcc/config/mips/gthr-mipssde.h create mode 100644 libgcc/config/pa/gthr-dce.h create mode 100644 libgcc/config/rs6000/gthr-aix.h create mode 100644 libgcc/config/s390/gthr-tpf.h create mode 100644 libgcc/gthr-single.h create mode 100644 libgcc/gthr.h diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f1e4860d1b9..817abbde214 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,24 @@ +2011-11-02 Rainer Orth + + * gthr-single.h, gthr.h: Move to ../libgcc. + * gthr-aix.h: Move to ../libgcc/config/rs6000. + * gthr-dce.h: Move to ../libgcc/config/pa. + * gthr-lynx.h: Move to ../libgcc/config. + * gthr-mipssde.h: Move to ../libgcc/config/mips. + * gthr-posix.h: Move to ../libgcc/config. + * gthr-rtems.h: Likewise. + * gthr-tpf.h: Move to ../libgcc/config/s390. + * gthr-vxworks.h: Move to ../libgcc/config. + * gthr-win32.h: Move to ../libgcc/config/i386. + * configure.ac (gthread_flags): Remove + (gthr-default.h): Don't create. + (thread_file): Don't substitute. + * configure: Regenerate. + * Makefile.in (GCC_THREAD_FILE): Remove. + (GTHREAD_FLAGS): Remove. + (libgcc.mvars): Remove GTHREAD_FLAGS. + * config/t-vxworks (EXTRA_HEADERS): Remove. + 2011-11-02 Rainer Orth Paolo Bonzini diff --git a/gcc/Makefile.in b/gcc/Makefile.in index cf1c8a7f30b..229e8c10fce 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -532,9 +532,7 @@ lang_opt_files=@lang_opt_files@ $(srcdir)/c-family/c.opt $(srcdir)/common.opt lang_specs_files=@lang_specs_files@ lang_tree_files=@lang_tree_files@ target_cpu_default=@target_cpu_default@ -GCC_THREAD_FILE=@thread_file@ OBJC_BOEHM_GC=@objc_boehm_gc@ -GTHREAD_FLAGS=@gthread_flags@ extra_modes_file=@extra_modes_file@ extra_opt_files=@extra_opt_files@ host_hook_obj=@out_host_hook_obj@ @@ -1808,7 +1806,6 @@ libgcc-support: libgcc.mvars stmp-int-hdrs $(TCONFIG_H) \ libgcc.mvars: config.status Makefile specs xgcc$(exeext) : > tmp-libgcc.mvars echo GCC_CFLAGS = '$(GCC_CFLAGS)' >> tmp-libgcc.mvars - echo GTHREAD_FLAGS = '$(GTHREAD_FLAGS)' >> tmp-libgcc.mvars echo INHIBIT_LIBC_CFLAGS = '$(INHIBIT_LIBC_CFLAGS)' >> tmp-libgcc.mvars echo TARGET_SYSTEM_ROOT = '$(TARGET_SYSTEM_ROOT)' >> tmp-libgcc.mvars diff --git a/gcc/config/t-vxworks b/gcc/config/t-vxworks index 9564e1bef55..61d6e710aca 100644 --- a/gcc/config/t-vxworks +++ b/gcc/config/t-vxworks @@ -17,10 +17,6 @@ # along with GCC; see the file COPYING3. If not see # . -# Some runtime modules need these. Can't set extra_headers in config.gcc -# because the paths are always made absolute to the cpu config dir. -EXTRA_HEADERS += $(srcdir)/gthr-vxworks.h gthr-default.h - # Both the kernel and RTP headers provide limits.h. LIMITS_H_TEST = true diff --git a/gcc/configure b/gcc/configure index cb116d22993..3b0b39b484a 100755 --- a/gcc/configure +++ b/gcc/configure @@ -621,7 +621,6 @@ tm_p_file_list tm_defines tm_include_list tm_file_list -thread_file common_out_object_file common_out_file out_object_file @@ -724,7 +723,6 @@ LIBINTL USE_NLS extra_opt_files extra_modes_file -gthread_flags NATIVE_SYSTEM_HEADER_DIR objext manext @@ -11353,19 +11351,6 @@ if test x${thread_file} = x; then thread_file=${target_thread_file} fi -# Make gthr-default.h if we have a thread file. -gthread_flags= -if test $thread_file != single; then - echo "#include \"gthr-${thread_file}.h\"" > gthr-default.h-t - if diff gthr-default.h-t gthr-default.h 2>/dev/null; then - rm -f gthr-default.h-t - else - mv -f gthr-default.h-t gthr-default.h - fi - gthread_flags=-DHAVE_GTHR_DEFAULT -fi - - # -------- # UNSORTED # -------- @@ -18059,7 +18044,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18062 "configure" +#line 18047 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18165,7 +18150,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18168 "configure" +#line 18153 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -26986,7 +26971,6 @@ fi - diff --git a/gcc/configure.ac b/gcc/configure.ac index 6ef0b84c6da..dd6cf2f17f3 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1416,19 +1416,6 @@ if test x${thread_file} = x; then thread_file=${target_thread_file} fi -# Make gthr-default.h if we have a thread file. -gthread_flags= -if test $thread_file != single; then - echo "#include \"gthr-${thread_file}.h\"" > gthr-default.h-t - if diff gthr-default.h-t gthr-default.h 2>/dev/null; then - rm -f gthr-default.h-t - else - mv -f gthr-default.h-t gthr-default.h - fi - gthread_flags=-DHAVE_GTHR_DEFAULT -fi -AC_SUBST(gthread_flags) - # -------- # UNSORTED # -------- @@ -4961,7 +4948,6 @@ AC_SUBST(out_file) AC_SUBST(out_object_file) AC_SUBST(common_out_file) AC_SUBST(common_out_object_file) -AC_SUBST(thread_file) AC_SUBST(tm_file_list) AC_SUBST(tm_include_list) AC_SUBST(tm_defines) diff --git a/gcc/gthr-aix.h b/gcc/gthr-aix.h deleted file mode 100644 index 6827e8f316d..00000000000 --- a/gcc/gthr-aix.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Threads compatibility routines for libgcc2 and libobjc. */ -/* Compile this one with gcc. */ -/* Copyright (C) 2000, 2009 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -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 -. */ - -#ifndef GCC_GTHR_AIX_H -#define GCC_GTHR_AIX_H - -#ifdef _THREAD_SAFE -#include "gthr-posix.h" -#else -#include "gthr-single.h" -#endif - -#endif /* GCC_GTHR_AIX_H */ diff --git a/gcc/gthr-dce.h b/gcc/gthr-dce.h deleted file mode 100644 index d32155a9352..00000000000 --- a/gcc/gthr-dce.h +++ /dev/null @@ -1,563 +0,0 @@ -/* Threads compatibility routines for libgcc2 and libobjc. */ -/* Compile this one with gcc. */ -/* Copyright (C) 1997, 1999, 2000, 2001, 2004, 2005, 2008, 2009 - Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -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 -. */ - -#ifndef GCC_GTHR_DCE_H -#define GCC_GTHR_DCE_H - -/* If _DCE_THREADS is not defined, then we're building the single - threaded version of the libraries and do not want to reference - anything related to pthreads or dce. */ -#ifndef _DCE_THREADS -#include "gthr-single.h" -#else -/* DCE threads interface. - DCE threads are based on POSIX threads draft 4, and many things - have changed since then. */ - -/* Make sure CONST_CAST2 (original in system.h) is defined. */ -#ifndef CONST_CAST2 -#ifdef __cplusplus -#define CONST_CAST2(TOTYPE,FROMTYPE,X) (const_cast (X)) -#else -#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq) -#endif -#endif - -#define __GTHREADS 1 - -#include - -typedef pthread_key_t __gthread_key_t; -typedef pthread_once_t __gthread_once_t; -typedef pthread_mutex_t __gthread_mutex_t; -typedef pthread_mutex_t __gthread_recursive_mutex_t; - -#define __GTHREAD_ONCE_INIT pthread_once_init - -#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function -#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function - -#define __GTHREAD_MUTEX_INIT_DEFAULT pthread_once_init - -#if SUPPORTS_WEAK && GTHREAD_USE_WEAK -# define __gthrw(name) \ - static __typeof(name) __gthrw_ ## name __attribute__ ((__weakref__(#name))); -# define __gthrw_(name) __gthrw_ ## name -#else -# define __gthrw(name) -# define __gthrw_(name) name -#endif - -__gthrw(pthread_once) -__gthrw(pthread_keycreate) -__gthrw(pthread_getspecific) -__gthrw(pthread_setspecific) -__gthrw(pthread_create) -__gthrw(pthread_mutex_init) -__gthrw(pthread_mutex_destroy) -__gthrw(pthread_mutex_lock) -__gthrw(pthread_mutex_trylock) -__gthrw(pthread_mutex_unlock) -__gthrw(pthread_mutexattr_create) -__gthrw(pthread_mutexattr_setkind_np) -__gthrw(pthread_mutexattr_delete) - -#ifdef _LIBOBJC -/* Objective-C. */ -__gthrw(pthread_cond_broadcast) -__gthrw(pthread_cond_destroy) -__gthrw(pthread_cond_init) -__gthrw(pthread_cond_signal) -__gthrw(pthread_cond_wait) -__gthrw(pthread_exit) - -#ifdef pthread_getunique_np -# define __gthrw_pthread_getunique_np pthread_getunique_np -#else -__gthrw(pthread_getunique_np) -# define __gthrw_pthread_getunique_np __gthrw_(pthread_getunique_np) -#endif - -__gthrw(pthread_mutex_destroy) -__gthrw(pthread_self) -__gthrw(pthread_yield) -#endif - -#if SUPPORTS_WEAK && GTHREAD_USE_WEAK - -static inline int -__gthread_active_p (void) -{ - static void *const __gthread_active_ptr = (void *) &__gthrw_(pthread_create); - return __gthread_active_ptr != 0; -} - -#else /* not SUPPORTS_WEAK */ - -static inline int -__gthread_active_p (void) -{ - return 1; -} - -#endif /* SUPPORTS_WEAK */ - -#ifdef _LIBOBJC - -/* Key structure for maintaining thread specific storage */ -static pthread_key_t _objc_thread_storage; - -/* Thread local storage for a single thread */ -static void *thread_local_storage = NULL; - -/* Backend initialization functions */ - -/* Initialize the threads subsystem. */ -static inline int -__gthread_objc_init_thread_system (void) -{ - if (__gthread_active_p ()) - /* Initialize the thread storage key. */ - return __gthrw_(pthread_keycreate) (&_objc_thread_storage, NULL); - else - return -1; -} - -/* Close the threads subsystem. */ -static inline int -__gthread_objc_close_thread_system (void) -{ - if (__gthread_active_p ()) - return 0; - else - return -1; -} - -/* Backend thread functions */ - -/* Create a new thread of execution. */ -static inline objc_thread_t -__gthread_objc_thread_detach (void (*func)(void *), void *arg) -{ - objc_thread_t thread_id; - pthread_t new_thread_handle; - - if (!__gthread_active_p ()) - return NULL; - - if (!(__gthrw_(pthread_create) (&new_thread_handle, pthread_attr_default, - (void *) func, arg))) - { - /* ??? May not work! (64bit) */ - thread_id = *(objc_thread_t *) &new_thread_handle; - pthread_detach (&new_thread_handle); /* Fully detach thread. */ - } - else - thread_id = NULL; - - return thread_id; -} - -/* Set the current thread's priority. */ -static inline int -__gthread_objc_thread_set_priority (int priority) -{ - int sys_priority = 0; - - if (!__gthread_active_p ()) - return -1; - - switch (priority) - { - case OBJC_THREAD_INTERACTIVE_PRIORITY: - sys_priority = (PRI_FG_MIN_NP + PRI_FG_MAX_NP) / 2; - break; - default: - case OBJC_THREAD_BACKGROUND_PRIORITY: - sys_priority = (PRI_BG_MIN_NP + PRI_BG_MAX_NP) / 2; - break; - case OBJC_THREAD_LOW_PRIORITY: - sys_priority = (PRI_BG_MIN_NP + PRI_BG_MAX_NP) / 2; - break; - } - - /* Change the priority. */ - if (pthread_setprio (__gthrw_(pthread_self) (), sys_priority) >= 0) - return 0; - else - /* Failed */ - return -1; -} - -/* Return the current thread's priority. */ -static inline int -__gthread_objc_thread_get_priority (void) -{ - int sys_priority; - - if (__gthread_active_p ()) - { - if ((sys_priority = pthread_getprio (__gthrw_(pthread_self) ())) >= 0) - { - if (sys_priority >= PRI_FG_MIN_NP - && sys_priority <= PRI_FG_MAX_NP) - return OBJC_THREAD_INTERACTIVE_PRIORITY; - if (sys_priority >= PRI_BG_MIN_NP - && sys_priority <= PRI_BG_MAX_NP) - return OBJC_THREAD_BACKGROUND_PRIORITY; - return OBJC_THREAD_LOW_PRIORITY; - } - - /* Failed */ - return -1; - } - else - return OBJC_THREAD_INTERACTIVE_PRIORITY; -} - -/* Yield our process time to another thread. */ -static inline void -__gthread_objc_thread_yield (void) -{ - if (__gthread_active_p ()) - __gthrw_(pthread_yield) (); -} - -/* Terminate the current thread. */ -static inline int -__gthread_objc_thread_exit (void) -{ - if (__gthread_active_p ()) - /* exit the thread */ - __gthrw_(pthread_exit) (&__objc_thread_exit_status); - - /* Failed if we reached here */ - return -1; -} - -/* Returns an integer value which uniquely describes a thread. */ -static inline objc_thread_t -__gthread_objc_thread_id (void) -{ - if (__gthread_active_p ()) - { - pthread_t self = __gthrw_(pthread_self) (); - - return (objc_thread_t) __gthrw_pthread_getunique_np (&self); - } - else - return (objc_thread_t) 1; -} - -/* Sets the thread's local storage pointer. */ -static inline int -__gthread_objc_thread_set_data (void *value) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_setspecific) (_objc_thread_storage, value); - else - { - thread_local_storage = value; - return 0; - } -} - -/* Returns the thread's local storage pointer. */ -static inline void * -__gthread_objc_thread_get_data (void) -{ - void *value = NULL; - - if (__gthread_active_p ()) - { - if (!(__gthrw_(pthread_getspecific) (_objc_thread_storage, &value))) - return value; - - return NULL; - } - else - return thread_local_storage; -} - -/* Backend mutex functions */ - -/* Allocate a mutex. */ -static inline int -__gthread_objc_mutex_allocate (objc_mutex_t mutex) -{ - if (__gthread_active_p ()) - { - mutex->backend = objc_malloc (sizeof (pthread_mutex_t)); - - if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, - pthread_mutexattr_default)) - { - objc_free (mutex->backend); - mutex->backend = NULL; - return -1; - } - } - - return 0; -} - -/* Deallocate a mutex. */ -static inline int -__gthread_objc_mutex_deallocate (objc_mutex_t mutex) -{ - if (__gthread_active_p ()) - { - if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend)) - return -1; - - objc_free (mutex->backend); - mutex->backend = NULL; - } - - return 0; -} - -/* Grab a lock on a mutex. */ -static inline int -__gthread_objc_mutex_lock (objc_mutex_t mutex) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend); - else - return 0; -} - -/* Try to grab a lock on a mutex. */ -static inline int -__gthread_objc_mutex_trylock (objc_mutex_t mutex) -{ - if (__gthread_active_p () - && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 1) - return -1; - - return 0; -} - -/* Unlock the mutex */ -static inline int -__gthread_objc_mutex_unlock (objc_mutex_t mutex) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend); - else - return 0; -} - -/* Backend condition mutex functions */ - -/* Allocate a condition. */ -static inline int -__gthread_objc_condition_allocate (objc_condition_t condition - __attribute__ ((__unused__))) -{ - if (__gthread_active_p ()) - /* Unimplemented. */ - return -1; - else - return 0; -} - -/* Deallocate a condition. */ -static inline int -__gthread_objc_condition_deallocate (objc_condition_t condition - __attribute__ ((__unused__))) -{ - if (__gthread_active_p ()) - /* Unimplemented. */ - return -1; - else - return 0; -} - -/* Wait on the condition */ -static inline int -__gthread_objc_condition_wait (objc_condition_t condition - __attribute__ ((__unused__)), - objc_mutex_t mutex __attribute__ ((__unused__))) -{ - if (__gthread_active_p ()) - /* Unimplemented. */ - return -1; - else - return 0; -} - -/* Wake up all threads waiting on this condition. */ -static inline int -__gthread_objc_condition_broadcast (objc_condition_t condition - __attribute__ ((__unused__))) -{ - if (__gthread_active_p ()) - /* Unimplemented. */ - return -1; - else - return 0; -} - -/* Wake up one thread waiting on this condition. */ -static inline int -__gthread_objc_condition_signal (objc_condition_t condition - __attribute__ ((__unused__))) -{ - if (__gthread_active_p ()) - /* Unimplemented. */ - return -1; - else - return 0; -} - -#else /* _LIBOBJC */ - -static inline int -__gthread_once (__gthread_once_t *__once, void (*__func) (void)) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_once) (__once, __func); - else - return -1; -} - -static inline int -__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) -{ - return __gthrw_(pthread_keycreate) (__key, __dtor); -} - -static inline int -__gthread_key_delete (__gthread_key_t __key __attribute__ ((__unused__))) -{ - /* Operation is not supported. */ - return -1; -} - -static inline void * -__gthread_getspecific (__gthread_key_t __key) -{ - void *__ptr; - if (__gthrw_(pthread_getspecific) (__key, &__ptr) == 0) - return __ptr; - else - return 0; -} - -static inline int -__gthread_setspecific (__gthread_key_t __key, const void *__ptr) -{ - return __gthrw_(pthread_setspecific) - (__key, CONST_CAST2(void *, const void *, __ptr)); -} - -static inline void -__gthread_mutex_init_function (__gthread_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - __gthrw_(pthread_mutex_init) (__mutex, pthread_mutexattr_default); -} - -static inline int -__gthread_mutex_destroy (__gthread_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_mutex_destroy) (__mutex); - else - return 0; -} - -static inline int -__gthread_mutex_lock (__gthread_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_mutex_lock) (__mutex); - else - return 0; -} - -static inline int -__gthread_mutex_trylock (__gthread_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_mutex_trylock) (__mutex); - else - return 0; -} - -static inline int -__gthread_mutex_unlock (__gthread_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_mutex_unlock) (__mutex); - else - return 0; -} - -static inline int -__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - { - pthread_mutexattr_t __attr; - int __r; - - __r = __gthrw_(pthread_mutexattr_create) (&__attr); - if (!__r) - __r = __gthrw_(pthread_mutexattr_setkind_np) (&__attr, - MUTEX_RECURSIVE_NP); - if (!__r) - __r = __gthrw_(pthread_mutex_init) (__mutex, __attr); - if (!__r) - __r = __gthrw_(pthread_mutexattr_delete) (&__attr); - return __r; - } - return 0; -} - -static inline int -__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) -{ - return __gthread_mutex_lock (__mutex); -} - -static inline int -__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) -{ - return __gthread_mutex_trylock (__mutex); -} - -static inline int -__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) -{ - return __gthread_mutex_unlock (__mutex); -} - -#endif /* _LIBOBJC */ - -#endif -#endif /* ! GCC_GTHR_DCE_H */ diff --git a/gcc/gthr-lynx.h b/gcc/gthr-lynx.h deleted file mode 100644 index 13b81d2fedb..00000000000 --- a/gcc/gthr-lynx.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Threads compatibility routines for libgcc2 and libobjc for - LynxOS. */ -/* Compile this one with gcc. */ -/* Copyright (C) 2004, 2008, 2009 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -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 -. */ - -#ifndef GCC_GTHR_LYNX_H -#define GCC_GTHR_LYNX_H - -#ifdef _MULTITHREADED - -/* Using the macro version of pthread_setspecific leads to a - compilation error. Instead we have two choices either kill all - macros in pthread.h with defining _POSIX_THREADS_CALLS or undefine - individual macros where we should fall back on the function - implementation. We choose the second approach. */ - -#include -#undef pthread_setspecific - -/* When using static libc on LynxOS, we cannot define pthread_create - weak. If the multi-threaded application includes iostream.h, - gthr-posix.h is included and pthread_create will be defined weak. - If pthread_create is weak its defining module in libc is not - necessarily included in the link and the symbol is resolved to zero. - Therefore the first call to it will crash. - - Since -mthreads is a multilib switch on LynxOS we know that at this - point we are compiling for multi-threaded. Omitting the weak - definitions at this point should have no effect. */ - -#undef GTHREAD_USE_WEAK -#define GTHREAD_USE_WEAK 0 - -#include "gthr-posix.h" - -#else -#include "gthr-single.h" -#endif - -#endif /* GCC_GTHR_LYNX_H */ diff --git a/gcc/gthr-mipssde.h b/gcc/gthr-mipssde.h deleted file mode 100644 index 34f9b6cf54b..00000000000 --- a/gcc/gthr-mipssde.h +++ /dev/null @@ -1,230 +0,0 @@ -/* MIPS SDE threads compatibility routines for libgcc2 and libobjc. */ -/* Compile this one with gcc. */ -/* Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc. - Contributed by Nigel Stephens - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -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 -. */ - -#ifndef GCC_GTHR_MIPSSDE_H -#define GCC_GTHR_MIPSSDE_H - -/* MIPS SDE threading API specific definitions. - Easy, since the interface is pretty much one-to-one. */ - -#define __GTHREADS 1 - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef __sdethread_key_t __gthread_key_t; -typedef __sdethread_once_t __gthread_once_t; -typedef __sdethread_mutex_t __gthread_mutex_t; - -typedef struct { - long depth; - __sdethread_t owner; - __sdethread_mutex_t actual; -} __gthread_recursive_mutex_t; - -#define __GTHREAD_MUTEX_INIT __SDETHREAD_MUTEX_INITIALIZER("gthr") -#define __GTHREAD_ONCE_INIT __SDETHREAD_ONCE_INIT -static inline int -__gthread_recursive_mutex_init_function(__gthread_recursive_mutex_t *__mutex); -#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function - -#if SUPPORTS_WEAK && GTHREAD_USE_WEAK -# define __gthrw(name) \ - static __typeof(name) __gthrw_ ## name __attribute__ ((__weakref__(#name))); -# define __gthrw_(name) __gthrw_ ## name -#else -# define __gthrw(name) -# define __gthrw_(name) name -#endif - -__gthrw(__sdethread_once) -__gthrw(__sdethread_key_create) -__gthrw(__sdethread_key_delete) -__gthrw(__sdethread_getspecific) -__gthrw(__sdethread_setspecific) - -__gthrw(__sdethread_self) - -__gthrw(__sdethread_mutex_lock) -__gthrw(__sdethread_mutex_trylock) -__gthrw(__sdethread_mutex_unlock) - -__gthrw(__sdethread_mutex_init) - -__gthrw(__sdethread_threading) - -#if SUPPORTS_WEAK && GTHREAD_USE_WEAK - -static inline int -__gthread_active_p (void) -{ - return !!(void *)&__sdethread_threading; -} - -#else /* not SUPPORTS_WEAK */ - -static inline int -__gthread_active_p (void) -{ - return 1; -} - -#endif /* SUPPORTS_WEAK */ - -static inline int -__gthread_once (__gthread_once_t *__once, void (*__func) (void)) -{ - if (__gthread_active_p ()) - return __gthrw_(__sdethread_once) (__once, __func); - else - return -1; -} - -static inline int -__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) -{ - return __gthrw_(__sdethread_key_create) (__key, __dtor); -} - -static inline int -__gthread_key_delete (__gthread_key_t __key) -{ - return __gthrw_(__sdethread_key_delete) (__key); -} - -static inline void * -__gthread_getspecific (__gthread_key_t __key) -{ - return __gthrw_(__sdethread_getspecific) (__key); -} - -static inline int -__gthread_setspecific (__gthread_key_t __key, const void *__ptr) -{ - return __gthrw_(__sdethread_setspecific) (__key, __ptr); -} - -static inline int -__gthread_mutex_destroy (__gthread_mutex_t * UNUSED(__mutex)) -{ - return 0; -} - -static inline int -__gthread_mutex_lock (__gthread_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthrw_(__sdethread_mutex_lock) (__mutex); - else - return 0; -} - -static inline int -__gthread_mutex_trylock (__gthread_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthrw_(__sdethread_mutex_trylock) (__mutex); - else - return 0; -} - -static inline int -__gthread_mutex_unlock (__gthread_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthrw_(__sdethread_mutex_unlock) (__mutex); - else - return 0; -} - -static inline int -__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) -{ - __mutex->depth = 0; - __mutex->owner = __gthrw_(__sdethread_self) (); - return __gthrw_(__sdethread_mutex_init) (&__mutex->actual, NULL); -} - -static inline int -__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - { - __sdethread_t __me = __gthrw_(__sdethread_self) (); - - if (__mutex->owner != __me) - { - __gthrw_(__sdethread_mutex_lock) (&__mutex->actual); - __mutex->owner = __me; - } - - __mutex->depth++; - } - return 0; -} - -static inline int -__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - { - __sdethread_t __me = __gthrw_(__sdethread_self) (); - - if (__mutex->owner != __me) - { - if (__gthrw_(__sdethread_mutex_trylock) (&__mutex->actual)) - return 1; - __mutex->owner = __me; - } - - __mutex->depth++; - } - return 0; -} - -static inline int -__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - { - if (--__mutex->depth == 0) - { - __mutex->owner = (__sdethread_t) 0; - __gthrw_(__sdethread_mutex_unlock) (&__mutex->actual); - } - } - return 0; -} - -#ifdef __cplusplus -} -#endif - -#endif /* ! GCC_GTHR_MIPSSDE_H */ diff --git a/gcc/gthr-posix.h b/gcc/gthr-posix.h deleted file mode 100644 index 46054f6a7c2..00000000000 --- a/gcc/gthr-posix.h +++ /dev/null @@ -1,879 +0,0 @@ -/* Threads compatibility routines for libgcc2 and libobjc. */ -/* Compile this one with gcc. */ -/* Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010, 2011 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -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 -. */ - -#ifndef GCC_GTHR_POSIX_H -#define GCC_GTHR_POSIX_H - -/* POSIX threads specific definitions. - Easy, since the interface is just one-to-one mapping. */ - -#define __GTHREADS 1 -#define __GTHREADS_CXX0X 1 - -/* Some implementations of require this to be defined. */ -#if !defined(_REENTRANT) && defined(__osf__) -#define _REENTRANT 1 -#endif - -#include - -#if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \ - || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK)) -# include -# if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0 -# define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 -# else -# define _GTHREAD_USE_MUTEX_TIMEDLOCK 0 -# endif -#endif - -typedef pthread_t __gthread_t; -typedef pthread_key_t __gthread_key_t; -typedef pthread_once_t __gthread_once_t; -typedef pthread_mutex_t __gthread_mutex_t; -typedef pthread_mutex_t __gthread_recursive_mutex_t; -typedef pthread_cond_t __gthread_cond_t; -typedef struct timespec __gthread_time_t; - -/* POSIX like conditional variables are supported. Please look at comments - in gthr.h for details. */ -#define __GTHREAD_HAS_COND 1 - -#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER -#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT -#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) -#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER -#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) -#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP -#else -#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function -#endif -#define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER -#define __GTHREAD_TIME_INIT {0,0} - -#if SUPPORTS_WEAK && GTHREAD_USE_WEAK -# ifndef __gthrw_pragma -# define __gthrw_pragma(pragma) -# endif -# define __gthrw2(name,name2,type) \ - static __typeof(type) name __attribute__ ((__weakref__(#name2))); \ - __gthrw_pragma(weak type) -# define __gthrw_(name) __gthrw_ ## name -#else -# define __gthrw2(name,name2,type) -# define __gthrw_(name) name -#endif - -/* Typically, __gthrw_foo is a weak reference to symbol foo. */ -#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name) - -/* On Tru64, /usr/include/pthread.h uses #pragma extern_prefix "__" to - map a subset of the POSIX pthread API to mangled versions of their - names. */ -#if defined(__osf__) && defined(_PTHREAD_USE_MANGLED_NAMES_) -#define __gthrw3(name) __gthrw2(__gthrw_ ## name, __ ## name, name) -__gthrw3(pthread_once) -__gthrw3(pthread_getspecific) -__gthrw3(pthread_setspecific) - -__gthrw3(pthread_create) -__gthrw3(pthread_join) -__gthrw3(pthread_detach) -__gthrw3(pthread_equal) -__gthrw3(pthread_self) -__gthrw3(pthread_cancel) -__gthrw3(sched_yield) - -__gthrw3(pthread_mutex_lock) -__gthrw3(pthread_mutex_trylock) -#if _GTHREAD_USE_MUTEX_TIMEDLOCK -__gthrw3(pthread_mutex_timedlock) -#endif -__gthrw3(pthread_mutex_unlock) -__gthrw3(pthread_mutex_init) -__gthrw3(pthread_mutex_destroy) - -__gthrw3(pthread_cond_broadcast) -__gthrw3(pthread_cond_signal) -__gthrw3(pthread_cond_wait) -__gthrw3(pthread_cond_timedwait) -__gthrw3(pthread_cond_destroy) -#else -__gthrw(pthread_once) -__gthrw(pthread_getspecific) -__gthrw(pthread_setspecific) - -__gthrw(pthread_create) -__gthrw(pthread_join) -__gthrw(pthread_equal) -__gthrw(pthread_self) -__gthrw(pthread_detach) -#ifndef __BIONIC__ -__gthrw(pthread_cancel) -#endif -__gthrw(sched_yield) - -__gthrw(pthread_mutex_lock) -__gthrw(pthread_mutex_trylock) -#if _GTHREAD_USE_MUTEX_TIMEDLOCK -__gthrw(pthread_mutex_timedlock) -#endif -__gthrw(pthread_mutex_unlock) -__gthrw(pthread_mutex_init) -__gthrw(pthread_mutex_destroy) - -__gthrw(pthread_cond_broadcast) -__gthrw(pthread_cond_signal) -__gthrw(pthread_cond_wait) -__gthrw(pthread_cond_timedwait) -__gthrw(pthread_cond_destroy) -#endif - -__gthrw(pthread_key_create) -__gthrw(pthread_key_delete) -__gthrw(pthread_mutexattr_init) -__gthrw(pthread_mutexattr_settype) -__gthrw(pthread_mutexattr_destroy) - - -#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK) -/* Objective-C. */ -#if defined(__osf__) && defined(_PTHREAD_USE_MANGLED_NAMES_) -__gthrw3(pthread_cond_init) -__gthrw3(pthread_exit) -#else -__gthrw(pthread_cond_init) -__gthrw(pthread_exit) -#endif /* __osf__ && _PTHREAD_USE_MANGLED_NAMES_ */ -#ifdef _POSIX_PRIORITY_SCHEDULING -#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING -__gthrw(sched_get_priority_max) -__gthrw(sched_get_priority_min) -#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ -#endif /* _POSIX_PRIORITY_SCHEDULING */ -__gthrw(pthread_attr_destroy) -__gthrw(pthread_attr_init) -__gthrw(pthread_attr_setdetachstate) -#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING -__gthrw(pthread_getschedparam) -__gthrw(pthread_setschedparam) -#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ -#endif /* _LIBOBJC || _LIBOBJC_WEAK */ - -#if SUPPORTS_WEAK && GTHREAD_USE_WEAK - -/* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if - -pthreads is not specified. The functions are dummies and most return an - error value. However pthread_once returns 0 without invoking the routine - it is passed so we cannot pretend that the interface is active if -pthreads - is not specified. On Solaris 2.5.1, the interface is not exposed at all so - we need to play the usual game with weak symbols. On Solaris 10 and up, a - working interface is always exposed. On FreeBSD 6 and later, libc also - exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up - to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc, - which means the alternate __gthread_active_p below cannot be used there. */ - -#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__)) - -static volatile int __gthread_active = -1; - -static void -__gthread_trigger (void) -{ - __gthread_active = 1; -} - -static inline int -__gthread_active_p (void) -{ - static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER; - static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT; - - /* Avoid reading __gthread_active twice on the main code path. */ - int __gthread_active_latest_value = __gthread_active; - - /* This test is not protected to avoid taking a lock on the main code - path so every update of __gthread_active in a threaded program must - be atomic with regard to the result of the test. */ - if (__builtin_expect (__gthread_active_latest_value < 0, 0)) - { - if (__gthrw_(pthread_once)) - { - /* If this really is a threaded program, then we must ensure that - __gthread_active has been set to 1 before exiting this block. */ - __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex); - __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger); - __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex); - } - - /* Make sure we'll never enter this block again. */ - if (__gthread_active < 0) - __gthread_active = 0; - - __gthread_active_latest_value = __gthread_active; - } - - return __gthread_active_latest_value != 0; -} - -#else /* neither FreeBSD nor Solaris */ - -static inline int -__gthread_active_p (void) -{ -/* Android's C library does not provide pthread_cancel, check for - `pthread_create' instead. */ -#ifndef __BIONIC__ - static void *const __gthread_active_ptr - = __extension__ (void *) &__gthrw_(pthread_cancel); -#else - static void *const __gthread_active_ptr - = __extension__ (void *) &__gthrw_(pthread_create); -#endif - return __gthread_active_ptr != 0; -} - -#endif /* FreeBSD or Solaris */ - -#else /* not SUPPORTS_WEAK */ - -/* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread - calls in shared flavors of the HP-UX C library. Most of the stubs - have no functionality. The details are described in the "libc cumulative - patch" for each subversion of HP-UX 11. There are two special interfaces - provided for checking whether an application is linked to a shared pthread - library or not. However, these interfaces aren't available in early - libpthread libraries. We also need a test that works for archive - libraries. We can't use pthread_once as some libc versions call the - init function. We also can't use pthread_create or pthread_attr_init - as these create a thread and thereby prevent changing the default stack - size. The function pthread_default_stacksize_np is available in both - the archive and shared versions of libpthread. It can be used to - determine the default pthread stack size. There is a stub in some - shared libc versions which returns a zero size if pthreads are not - active. We provide an equivalent stub to handle cases where libc - doesn't provide one. */ - -#if defined(__hppa__) && defined(__hpux__) - -static volatile int __gthread_active = -1; - -static inline int -__gthread_active_p (void) -{ - /* Avoid reading __gthread_active twice on the main code path. */ - int __gthread_active_latest_value = __gthread_active; - size_t __s; - - if (__builtin_expect (__gthread_active_latest_value < 0, 0)) - { - pthread_default_stacksize_np (0, &__s); - __gthread_active = __s ? 1 : 0; - __gthread_active_latest_value = __gthread_active; - } - - return __gthread_active_latest_value != 0; -} - -#else /* not hppa-hpux */ - -static inline int -__gthread_active_p (void) -{ - return 1; -} - -#endif /* hppa-hpux */ - -#endif /* SUPPORTS_WEAK */ - -#ifdef _LIBOBJC - -/* This is the config.h file in libobjc/ */ -#include - -#ifdef HAVE_SCHED_H -# include -#endif - -/* Key structure for maintaining thread specific storage */ -static pthread_key_t _objc_thread_storage; -static pthread_attr_t _objc_thread_attribs; - -/* Thread local storage for a single thread */ -static void *thread_local_storage = NULL; - -/* Backend initialization functions */ - -/* Initialize the threads subsystem. */ -static inline int -__gthread_objc_init_thread_system (void) -{ - if (__gthread_active_p ()) - { - /* Initialize the thread storage key. */ - if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0) - { - /* The normal default detach state for threads is - * PTHREAD_CREATE_JOINABLE which causes threads to not die - * when you think they should. */ - if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0 - && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs, - PTHREAD_CREATE_DETACHED) == 0) - return 0; - } - } - - return -1; -} - -/* Close the threads subsystem. */ -static inline int -__gthread_objc_close_thread_system (void) -{ - if (__gthread_active_p () - && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0 - && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0) - return 0; - - return -1; -} - -/* Backend thread functions */ - -/* Create a new thread of execution. */ -static inline objc_thread_t -__gthread_objc_thread_detach (void (*func)(void *), void *arg) -{ - objc_thread_t thread_id; - pthread_t new_thread_handle; - - if (!__gthread_active_p ()) - return NULL; - - if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs, - (void *) func, arg))) - thread_id = (objc_thread_t) new_thread_handle; - else - thread_id = NULL; - - return thread_id; -} - -/* Set the current thread's priority. */ -static inline int -__gthread_objc_thread_set_priority (int priority) -{ - if (!__gthread_active_p ()) - return -1; - else - { -#ifdef _POSIX_PRIORITY_SCHEDULING -#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING - pthread_t thread_id = __gthrw_(pthread_self) (); - int policy; - struct sched_param params; - int priority_min, priority_max; - - if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0) - { - if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1) - return -1; - - if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1) - return -1; - - if (priority > priority_max) - priority = priority_max; - else if (priority < priority_min) - priority = priority_min; - params.sched_priority = priority; - - /* - * The solaris 7 and several other man pages incorrectly state that - * this should be a pointer to policy but pthread.h is universally - * at odds with this. - */ - if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0) - return 0; - } -#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ -#endif /* _POSIX_PRIORITY_SCHEDULING */ - return -1; - } -} - -/* Return the current thread's priority. */ -static inline int -__gthread_objc_thread_get_priority (void) -{ -#ifdef _POSIX_PRIORITY_SCHEDULING -#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING - if (__gthread_active_p ()) - { - int policy; - struct sched_param params; - - if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0) - return params.sched_priority; - else - return -1; - } - else -#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ -#endif /* _POSIX_PRIORITY_SCHEDULING */ - return OBJC_THREAD_INTERACTIVE_PRIORITY; -} - -/* Yield our process time to another thread. */ -static inline void -__gthread_objc_thread_yield (void) -{ - if (__gthread_active_p ()) - __gthrw_(sched_yield) (); -} - -/* Terminate the current thread. */ -static inline int -__gthread_objc_thread_exit (void) -{ - if (__gthread_active_p ()) - /* exit the thread */ - __gthrw_(pthread_exit) (&__objc_thread_exit_status); - - /* Failed if we reached here */ - return -1; -} - -/* Returns an integer value which uniquely describes a thread. */ -static inline objc_thread_t -__gthread_objc_thread_id (void) -{ - if (__gthread_active_p ()) - return (objc_thread_t) __gthrw_(pthread_self) (); - else - return (objc_thread_t) 1; -} - -/* Sets the thread's local storage pointer. */ -static inline int -__gthread_objc_thread_set_data (void *value) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_setspecific) (_objc_thread_storage, value); - else - { - thread_local_storage = value; - return 0; - } -} - -/* Returns the thread's local storage pointer. */ -static inline void * -__gthread_objc_thread_get_data (void) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_getspecific) (_objc_thread_storage); - else - return thread_local_storage; -} - -/* Backend mutex functions */ - -/* Allocate a mutex. */ -static inline int -__gthread_objc_mutex_allocate (objc_mutex_t mutex) -{ - if (__gthread_active_p ()) - { - mutex->backend = objc_malloc (sizeof (pthread_mutex_t)); - - if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL)) - { - objc_free (mutex->backend); - mutex->backend = NULL; - return -1; - } - } - - return 0; -} - -/* Deallocate a mutex. */ -static inline int -__gthread_objc_mutex_deallocate (objc_mutex_t mutex) -{ - if (__gthread_active_p ()) - { - int count; - - /* - * Posix Threads specifically require that the thread be unlocked - * for __gthrw_(pthread_mutex_destroy) to work. - */ - - do - { - count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend); - if (count < 0) - return -1; - } - while (count); - - if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend)) - return -1; - - objc_free (mutex->backend); - mutex->backend = NULL; - } - return 0; -} - -/* Grab a lock on a mutex. */ -static inline int -__gthread_objc_mutex_lock (objc_mutex_t mutex) -{ - if (__gthread_active_p () - && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0) - { - return -1; - } - - return 0; -} - -/* Try to grab a lock on a mutex. */ -static inline int -__gthread_objc_mutex_trylock (objc_mutex_t mutex) -{ - if (__gthread_active_p () - && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0) - { - return -1; - } - - return 0; -} - -/* Unlock the mutex */ -static inline int -__gthread_objc_mutex_unlock (objc_mutex_t mutex) -{ - if (__gthread_active_p () - && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0) - { - return -1; - } - - return 0; -} - -/* Backend condition mutex functions */ - -/* Allocate a condition. */ -static inline int -__gthread_objc_condition_allocate (objc_condition_t condition) -{ - if (__gthread_active_p ()) - { - condition->backend = objc_malloc (sizeof (pthread_cond_t)); - - if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL)) - { - objc_free (condition->backend); - condition->backend = NULL; - return -1; - } - } - - return 0; -} - -/* Deallocate a condition. */ -static inline int -__gthread_objc_condition_deallocate (objc_condition_t condition) -{ - if (__gthread_active_p ()) - { - if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend)) - return -1; - - objc_free (condition->backend); - condition->backend = NULL; - } - return 0; -} - -/* Wait on the condition */ -static inline int -__gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend, - (pthread_mutex_t *) mutex->backend); - else - return 0; -} - -/* Wake up all threads waiting on this condition. */ -static inline int -__gthread_objc_condition_broadcast (objc_condition_t condition) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend); - else - return 0; -} - -/* Wake up one thread waiting on this condition. */ -static inline int -__gthread_objc_condition_signal (objc_condition_t condition) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend); - else - return 0; -} - -#else /* _LIBOBJC */ - -static inline int -__gthread_create (__gthread_t *__threadid, void *(*__func) (void*), - void *__args) -{ - return __gthrw_(pthread_create) (__threadid, NULL, __func, __args); -} - -static inline int -__gthread_join (__gthread_t __threadid, void **__value_ptr) -{ - return __gthrw_(pthread_join) (__threadid, __value_ptr); -} - -static inline int -__gthread_detach (__gthread_t __threadid) -{ - return __gthrw_(pthread_detach) (__threadid); -} - -static inline int -__gthread_equal (__gthread_t __t1, __gthread_t __t2) -{ - return __gthrw_(pthread_equal) (__t1, __t2); -} - -static inline __gthread_t -__gthread_self (void) -{ - return __gthrw_(pthread_self) (); -} - -static inline int -__gthread_yield (void) -{ - return __gthrw_(sched_yield) (); -} - -static inline int -__gthread_once (__gthread_once_t *__once, void (*__func) (void)) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_once) (__once, __func); - else - return -1; -} - -static inline int -__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) -{ - return __gthrw_(pthread_key_create) (__key, __dtor); -} - -static inline int -__gthread_key_delete (__gthread_key_t __key) -{ - return __gthrw_(pthread_key_delete) (__key); -} - -static inline void * -__gthread_getspecific (__gthread_key_t __key) -{ - return __gthrw_(pthread_getspecific) (__key); -} - -static inline int -__gthread_setspecific (__gthread_key_t __key, const void *__ptr) -{ - return __gthrw_(pthread_setspecific) (__key, __ptr); -} - -static inline int -__gthread_mutex_destroy (__gthread_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_mutex_destroy) (__mutex); - else - return 0; -} - -static inline int -__gthread_mutex_lock (__gthread_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_mutex_lock) (__mutex); - else - return 0; -} - -static inline int -__gthread_mutex_trylock (__gthread_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_mutex_trylock) (__mutex); - else - return 0; -} - -#if _GTHREAD_USE_MUTEX_TIMEDLOCK -static inline int -__gthread_mutex_timedlock (__gthread_mutex_t *__mutex, - const __gthread_time_t *__abs_timeout) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout); - else - return 0; -} -#endif - -static inline int -__gthread_mutex_unlock (__gthread_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthrw_(pthread_mutex_unlock) (__mutex); - else - return 0; -} - -#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP -static inline int -__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - { - pthread_mutexattr_t __attr; - int __r; - - __r = __gthrw_(pthread_mutexattr_init) (&__attr); - if (!__r) - __r = __gthrw_(pthread_mutexattr_settype) (&__attr, - PTHREAD_MUTEX_RECURSIVE); - if (!__r) - __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); - if (!__r) - __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); - return __r; - } - return 0; -} -#endif - -static inline int -__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) -{ - return __gthread_mutex_lock (__mutex); -} - -static inline int -__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) -{ - return __gthread_mutex_trylock (__mutex); -} - -#if _GTHREAD_USE_MUTEX_TIMEDLOCK -static inline int -__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex, - const __gthread_time_t *__abs_timeout) -{ - return __gthread_mutex_timedlock (__mutex, __abs_timeout); -} -#endif - -static inline int -__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) -{ - return __gthread_mutex_unlock (__mutex); -} - -static inline int -__gthread_cond_broadcast (__gthread_cond_t *__cond) -{ - return __gthrw_(pthread_cond_broadcast) (__cond); -} - -static inline int -__gthread_cond_signal (__gthread_cond_t *__cond) -{ - return __gthrw_(pthread_cond_signal) (__cond); -} - -static inline int -__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex) -{ - return __gthrw_(pthread_cond_wait) (__cond, __mutex); -} - -static inline int -__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, - const __gthread_time_t *__abs_timeout) -{ - return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout); -} - -static inline int -__gthread_cond_wait_recursive (__gthread_cond_t *__cond, - __gthread_recursive_mutex_t *__mutex) -{ - return __gthread_cond_wait (__cond, __mutex); -} - -static inline int -__gthread_cond_timedwait_recursive (__gthread_cond_t *__cond, - __gthread_recursive_mutex_t *__mutex, - const __gthread_time_t *__abs_timeout) -{ - return __gthread_cond_timedwait (__cond, __mutex, __abs_timeout); -} - -static inline int -__gthread_cond_destroy (__gthread_cond_t* __cond) -{ - return __gthrw_(pthread_cond_destroy) (__cond); -} - -#endif /* _LIBOBJC */ - -#endif /* ! GCC_GTHR_POSIX_H */ diff --git a/gcc/gthr-rtems.h b/gcc/gthr-rtems.h deleted file mode 100644 index c5bd52292cf..00000000000 --- a/gcc/gthr-rtems.h +++ /dev/null @@ -1,157 +0,0 @@ -/* RTEMS threads compatibility routines for libgcc2 and libobjc. - by: Rosimildo da Silva( rdasilva@connecttel.com ) */ -/* Compile this one with gcc. */ -/* Copyright (C) 1997, 1999, 2000, 2002, 2003, 2005, 2008, 2009 - Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -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 -. */ - -#ifndef GCC_GTHR_RTEMS_H -#define GCC_GTHR_RTEMS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define __GTHREADS 1 - -#define __GTHREAD_ONCE_INIT 0 -#define __GTHREAD_MUTEX_INIT_FUNCTION rtems_gxx_mutex_init -#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION rtems_gxx_recursive_mutex_init - -/* Avoid dependency on rtems specific headers. */ -typedef void *__gthread_key_t; -typedef int __gthread_once_t; -typedef void *__gthread_mutex_t; -typedef void *__gthread_recursive_mutex_t; - -/* - * External functions provided by RTEMS. They are very similar to their POSIX - * counterparts. A "Wrapper API" is being use to avoid dependency on any RTEMS - * header files. - */ - -/* generic per task variables */ -extern int rtems_gxx_once (__gthread_once_t *__once, void (*__func) (void)); -extern int rtems_gxx_key_create (__gthread_key_t *__key, void (*__dtor) (void *)); -extern int rtems_gxx_key_delete (__gthread_key_t __key); -extern void *rtems_gxx_getspecific (__gthread_key_t __key); -extern int rtems_gxx_setspecific (__gthread_key_t __key, const void *__ptr); - -/* mutex support */ -extern void rtems_gxx_mutex_init (__gthread_mutex_t *__mutex); -extern int rtems_gxx_mutex_destroy (__gthread_mutex_t *__mutex); -extern int rtems_gxx_mutex_lock (__gthread_mutex_t *__mutex); -extern int rtems_gxx_mutex_trylock (__gthread_mutex_t *__mutex); -extern int rtems_gxx_mutex_unlock (__gthread_mutex_t *__mutex); - -/* recursive mutex support */ -extern void rtems_gxx_recursive_mutex_init (__gthread_recursive_mutex_t *__mutex); -extern int rtems_gxx_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex); -extern int rtems_gxx_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex); -extern int rtems_gxx_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex); - -/* RTEMS threading is always active */ -static inline int -__gthread_active_p (void) -{ - return 1; -} - -/* Wrapper calls */ -static inline int -__gthread_once (__gthread_once_t *__once, void (*__func) (void)) -{ - return rtems_gxx_once( __once, __func ); -} - -static inline int -__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) -{ - return rtems_gxx_key_create( __key, __dtor ); -} - -static inline int -__gthread_key_delete (__gthread_key_t __key) -{ - return rtems_gxx_key_delete (__key); -} - -static inline void * -__gthread_getspecific (__gthread_key_t __key) -{ - return rtems_gxx_getspecific (__key); -} - -static inline int -__gthread_setspecific (__gthread_key_t __key, const void *__ptr) -{ - return rtems_gxx_setspecific (__key, __ptr); -} - -static inline int -__gthread_mutex_destroy (__gthread_mutex_t *__mutex) -{ - return rtems_gxx_mutex_destroy (__mutex); -} - -static inline int -__gthread_mutex_lock (__gthread_mutex_t *__mutex) -{ - return rtems_gxx_mutex_lock (__mutex); -} - -static inline int -__gthread_mutex_trylock (__gthread_mutex_t *__mutex) -{ - return rtems_gxx_mutex_trylock (__mutex); -} - -static inline int -__gthread_mutex_unlock (__gthread_mutex_t *__mutex) -{ - return rtems_gxx_mutex_unlock( __mutex ); -} - -static inline int -__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) -{ - return rtems_gxx_recursive_mutex_lock (__mutex); -} - -static inline int -__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) -{ - return rtems_gxx_recursive_mutex_trylock (__mutex); -} - -static inline int -__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) -{ - return rtems_gxx_recursive_mutex_unlock( __mutex ); -} - -#ifdef __cplusplus -} -#endif - -#endif /* ! GCC_GTHR_RTEMS_H */ diff --git a/gcc/gthr-single.h b/gcc/gthr-single.h deleted file mode 100644 index 357528ad1f1..00000000000 --- a/gcc/gthr-single.h +++ /dev/null @@ -1,292 +0,0 @@ -/* Threads compatibility routines for libgcc2 and libobjc. */ -/* Compile this one with gcc. */ -/* Copyright (C) 1997, 1999, 2000, 2004, 2008, 2009 - Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -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 -. */ - -#ifndef GCC_GTHR_SINGLE_H -#define GCC_GTHR_SINGLE_H - -/* Just provide compatibility for mutex handling. */ - -typedef int __gthread_key_t; -typedef int __gthread_once_t; -typedef int __gthread_mutex_t; -typedef int __gthread_recursive_mutex_t; - -#define __GTHREAD_ONCE_INIT 0 -#define __GTHREAD_MUTEX_INIT 0 -#define __GTHREAD_RECURSIVE_MUTEX_INIT 0 - -#define UNUSED __attribute__((unused)) - -#ifdef _LIBOBJC - -/* Thread local storage for a single thread */ -static void *thread_local_storage = NULL; - -/* Backend initialization functions */ - -/* Initialize the threads subsystem. */ -static inline int -__gthread_objc_init_thread_system (void) -{ - /* No thread support available */ - return -1; -} - -/* Close the threads subsystem. */ -static inline int -__gthread_objc_close_thread_system (void) -{ - /* No thread support available */ - return -1; -} - -/* Backend thread functions */ - -/* Create a new thread of execution. */ -static inline objc_thread_t -__gthread_objc_thread_detach (void (* func)(void *), void * arg UNUSED) -{ - /* No thread support available */ - return NULL; -} - -/* Set the current thread's priority. */ -static inline int -__gthread_objc_thread_set_priority (int priority UNUSED) -{ - /* No thread support available */ - return -1; -} - -/* Return the current thread's priority. */ -static inline int -__gthread_objc_thread_get_priority (void) -{ - return OBJC_THREAD_INTERACTIVE_PRIORITY; -} - -/* Yield our process time to another thread. */ -static inline void -__gthread_objc_thread_yield (void) -{ - return; -} - -/* Terminate the current thread. */ -static inline int -__gthread_objc_thread_exit (void) -{ - /* No thread support available */ - /* Should we really exit the program */ - /* exit (&__objc_thread_exit_status); */ - return -1; -} - -/* Returns an integer value which uniquely describes a thread. */ -static inline objc_thread_t -__gthread_objc_thread_id (void) -{ - /* No thread support, use 1. */ - return (objc_thread_t) 1; -} - -/* Sets the thread's local storage pointer. */ -static inline int -__gthread_objc_thread_set_data (void *value) -{ - thread_local_storage = value; - return 0; -} - -/* Returns the thread's local storage pointer. */ -static inline void * -__gthread_objc_thread_get_data (void) -{ - return thread_local_storage; -} - -/* Backend mutex functions */ - -/* Allocate a mutex. */ -static inline int -__gthread_objc_mutex_allocate (objc_mutex_t mutex UNUSED) -{ - return 0; -} - -/* Deallocate a mutex. */ -static inline int -__gthread_objc_mutex_deallocate (objc_mutex_t mutex UNUSED) -{ - return 0; -} - -/* Grab a lock on a mutex. */ -static inline int -__gthread_objc_mutex_lock (objc_mutex_t mutex UNUSED) -{ - /* There can only be one thread, so we always get the lock */ - return 0; -} - -/* Try to grab a lock on a mutex. */ -static inline int -__gthread_objc_mutex_trylock (objc_mutex_t mutex UNUSED) -{ - /* There can only be one thread, so we always get the lock */ - return 0; -} - -/* Unlock the mutex */ -static inline int -__gthread_objc_mutex_unlock (objc_mutex_t mutex UNUSED) -{ - return 0; -} - -/* Backend condition mutex functions */ - -/* Allocate a condition. */ -static inline int -__gthread_objc_condition_allocate (objc_condition_t condition UNUSED) -{ - return 0; -} - -/* Deallocate a condition. */ -static inline int -__gthread_objc_condition_deallocate (objc_condition_t condition UNUSED) -{ - return 0; -} - -/* Wait on the condition */ -static inline int -__gthread_objc_condition_wait (objc_condition_t condition UNUSED, - objc_mutex_t mutex UNUSED) -{ - return 0; -} - -/* Wake up all threads waiting on this condition. */ -static inline int -__gthread_objc_condition_broadcast (objc_condition_t condition UNUSED) -{ - return 0; -} - -/* Wake up one thread waiting on this condition. */ -static inline int -__gthread_objc_condition_signal (objc_condition_t condition UNUSED) -{ - return 0; -} - -#else /* _LIBOBJC */ - -static inline int -__gthread_active_p (void) -{ - return 0; -} - -static inline int -__gthread_once (__gthread_once_t *__once UNUSED, void (*__func) (void) UNUSED) -{ - return 0; -} - -static inline int UNUSED -__gthread_key_create (__gthread_key_t *__key UNUSED, void (*__func) (void *) UNUSED) -{ - return 0; -} - -static int UNUSED -__gthread_key_delete (__gthread_key_t __key UNUSED) -{ - return 0; -} - -static inline void * -__gthread_getspecific (__gthread_key_t __key UNUSED) -{ - return 0; -} - -static inline int -__gthread_setspecific (__gthread_key_t __key UNUSED, const void *__v UNUSED) -{ - return 0; -} - -static inline int -__gthread_mutex_destroy (__gthread_mutex_t *__mutex UNUSED) -{ - return 0; -} - -static inline int -__gthread_mutex_lock (__gthread_mutex_t *__mutex UNUSED) -{ - return 0; -} - -static inline int -__gthread_mutex_trylock (__gthread_mutex_t *__mutex UNUSED) -{ - return 0; -} - -static inline int -__gthread_mutex_unlock (__gthread_mutex_t *__mutex UNUSED) -{ - return 0; -} - -static inline int -__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) -{ - return __gthread_mutex_lock (__mutex); -} - -static inline int -__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) -{ - return __gthread_mutex_trylock (__mutex); -} - -static inline int -__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) -{ - return __gthread_mutex_unlock (__mutex); -} - -#endif /* _LIBOBJC */ - -#undef UNUSED - -#endif /* ! GCC_GTHR_SINGLE_H */ diff --git a/gcc/gthr-tpf.h b/gcc/gthr-tpf.h deleted file mode 100644 index fb23e91cfcd..00000000000 --- a/gcc/gthr-tpf.h +++ /dev/null @@ -1,229 +0,0 @@ -/* Threads compatibility routines for libgcc2 and libobjc. - Compile this one with gcc. - Copyright (C) 2004, 2005, 2008, 2009 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -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 -. */ - -/* TPF needs its own version of gthr-*.h because TPF always links to - the thread library. However, for performance reasons we still do not - want to issue thread api calls unless a check is made to see that we - are running as a thread. */ - -#ifndef GCC_GTHR_TPF_H -#define GCC_GTHR_TPF_H - -/* POSIX threads specific definitions. - Easy, since the interface is just one-to-one mapping. */ - -#define __GTHREADS 1 - -/* Some implementations of require this to be defined. */ -#ifndef _REENTRANT -#define _REENTRANT 1 -#endif - -#include -#include - -typedef pthread_key_t __gthread_key_t; -typedef pthread_once_t __gthread_once_t; -typedef pthread_mutex_t __gthread_mutex_t; -typedef pthread_mutex_t __gthread_recursive_mutex_t; - -#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) -#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER -#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) -#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP -#endif - -#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER -#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT -#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function - -#define NOTATHREAD 00 -#define ECBBASEPTR (unsigned long int) *(unsigned int *)0x00000514u -#define ECBPG2PTR ECBBASEPTR + 0x1000 -#define CE2THRCPTR *((unsigned char *)(ECBPG2PTR + 16)) -#define __tpf_pthread_active() (CE2THRCPTR != NOTATHREAD) - -#if SUPPORTS_WEAK && GTHREAD_USE_WEAK -# define __gthrw(name) \ - static __typeof(name) __gthrw_ ## name __attribute__ ((__weakref__(#name))); -# define __gthrw_(name) __gthrw_ ## name -#else -# define __gthrw(name) -# define __gthrw_(name) name -#endif - -__gthrw(pthread_once) -__gthrw(pthread_key_create) -__gthrw(pthread_key_delete) -__gthrw(pthread_getspecific) -__gthrw(pthread_setspecific) -__gthrw(pthread_create) - -__gthrw(pthread_mutex_lock) -__gthrw(pthread_mutex_trylock) -__gthrw(pthread_mutex_unlock) -__gthrw(pthread_mutexattr_init) -__gthrw(pthread_mutexattr_settype) -__gthrw(pthread_mutexattr_destroy) -__gthrw(pthread_mutex_init) -__gthrw(pthread_mutex_destroy) - -static inline int -__gthread_active_p (void) -{ - return 1; -} - -static inline int -__gthread_once (__gthread_once_t *__once, void (*__func) (void)) -{ - if (__tpf_pthread_active ()) - return __gthrw_(pthread_once) (__once, __func); - else - return -1; -} - -static inline int -__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) -{ - if (__tpf_pthread_active ()) - return __gthrw_(pthread_key_create) (__key, __dtor); - else - return -1; -} - -static inline int -__gthread_key_delete (__gthread_key_t __key) -{ - if (__tpf_pthread_active ()) - return __gthrw_(pthread_key_delete) (__key); - else - return -1; -} - -static inline void * -__gthread_getspecific (__gthread_key_t __key) -{ - if (__tpf_pthread_active ()) - return __gthrw_(pthread_getspecific) (__key); - else - return NULL; -} - -static inline int -__gthread_setspecific (__gthread_key_t __key, const void *__ptr) -{ - if (__tpf_pthread_active ()) - return __gthrw_(pthread_setspecific) (__key, __ptr); - else - return -1; -} - -static inline int -__gthread_mutex_destroy (__gthread_mutex_t *__mutex) -{ - if (__tpf_pthread_active ()) - return __gthrw_(pthread_mutex_destroy) (__mutex); - else - return 0; -} - -static inline int -__gthread_mutex_lock (__gthread_mutex_t *__mutex) -{ - if (__tpf_pthread_active ()) - return __gthrw_(pthread_mutex_lock) (__mutex); - else - return 0; -} - -static inline int -__gthread_mutex_trylock (__gthread_mutex_t *__mutex) -{ - if (__tpf_pthread_active ()) - return __gthrw_(pthread_mutex_trylock) (__mutex); - else - return 0; -} - -static inline int -__gthread_mutex_unlock (__gthread_mutex_t *__mutex) -{ - if (__tpf_pthread_active ()) - return __gthrw_(pthread_mutex_unlock) (__mutex); - else - return 0; -} - -static inline int -__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) -{ - if (__tpf_pthread_active ()) - return __gthread_mutex_lock (__mutex); - else - return 0; -} - -static inline int -__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) -{ - if (__tpf_pthread_active ()) - return __gthread_mutex_trylock (__mutex); - else - return 0; -} - -static inline int -__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) -{ - if (__tpf_pthread_active ()) - return __gthread_mutex_unlock (__mutex); - else - return 0; -} - -static inline int -__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) -{ - if (__tpf_pthread_active ()) - { - pthread_mutexattr_t __attr; - int __r; - - __r = __gthrw_(pthread_mutexattr_init) (&__attr); - if (!__r) - __r = __gthrw_(pthread_mutexattr_settype) (&__attr, - PTHREAD_MUTEX_RECURSIVE); - if (!__r) - __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); - if (!__r) - __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); - return __r; - } - return 0; -} - - -#endif /* ! GCC_GTHR_TPF_H */ diff --git a/gcc/gthr-vxworks.h b/gcc/gthr-vxworks.h deleted file mode 100644 index d4da14ef492..00000000000 --- a/gcc/gthr-vxworks.h +++ /dev/null @@ -1,169 +0,0 @@ -/* Threads compatibility routines for libgcc2 and libobjc for VxWorks. */ -/* Compile this one with gcc. */ -/* Copyright (C) 1997, 1999, 2000, 2008, 2009 Free Software Foundation, Inc. - Contributed by Mike Stump . - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -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 -. */ - -#ifndef GCC_GTHR_VXWORKS_H -#define GCC_GTHR_VXWORKS_H - -#ifdef _LIBOBJC - -/* libobjc requires the optional pthreads component. */ -#include "gthr-posix.h" - -#else -#ifdef __cplusplus -#define UNUSED(x) -#else -#define UNUSED(x) x __attribute__((unused)) -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#define __GTHREADS 1 -#define __gthread_active_p() 1 - -/* Mutexes are easy, except that they need to be initialized at runtime. */ - -#include - -typedef SEM_ID __gthread_mutex_t; -/* All VxWorks mutexes are recursive. */ -typedef SEM_ID __gthread_recursive_mutex_t; -#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function -#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function - -static inline void -__gthread_mutex_init_function (__gthread_mutex_t *mutex) -{ - *mutex = semMCreate (SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE); -} - -static inline int -__gthread_mutex_destroy (__gthread_mutex_t * UNUSED(mutex)) -{ - return 0; -} - -static inline int -__gthread_mutex_lock (__gthread_mutex_t *mutex) -{ - return semTake (*mutex, WAIT_FOREVER); -} - -static inline int -__gthread_mutex_trylock (__gthread_mutex_t *mutex) -{ - return semTake (*mutex, NO_WAIT); -} - -static inline int -__gthread_mutex_unlock (__gthread_mutex_t *mutex) -{ - return semGive (*mutex); -} - -static inline void -__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex) -{ - __gthread_mutex_init_function (mutex); -} - -static inline int -__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex) -{ - return __gthread_mutex_lock (mutex); -} - -static inline int -__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex) -{ - return __gthread_mutex_trylock (mutex); -} - -static inline int -__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex) -{ - return __gthread_mutex_unlock (mutex); -} - -/* pthread_once is complicated enough that it's implemented - out-of-line. See config/vxlib.c. */ - -typedef struct -{ -#if !defined(__RTP__) -#if defined(__PPC__) - __attribute ((aligned (__alignof (unsigned)))) -#endif - volatile unsigned char busy; -#endif - volatile unsigned char done; -#if !defined(__RTP__) && defined(__PPC__) - /* PPC's test-and-set implementation requires a 4 byte aligned - object, of which it only sets the first byte. We use padding - here, in order to maintain some amount of backwards - compatibility. Without this padding, gthread_once objects worked - by accident because they happen to be static objects and the ppc - port automatically increased their alignment to 4 bytes. */ - unsigned char pad1; - unsigned char pad2; -#endif -} -__gthread_once_t; - -#if defined (__RTP__) -# define __GTHREAD_ONCE_INIT { 0 } -#elif defined (__PPC__) -# define __GTHREAD_ONCE_INIT { 0, 0, 0, 0 } -#else -# define __GTHREAD_ONCE_INIT { 0, 0 } -#endif - -extern int __gthread_once (__gthread_once_t *__once, void (*__func)(void)); - -/* Thread-specific data requires a great deal of effort, since VxWorks - is not really set up for it. See config/vxlib.c for the gory - details. All the TSD routines are sufficiently complex that they - need to be implemented out of line. */ - -typedef unsigned int __gthread_key_t; - -extern int __gthread_key_create (__gthread_key_t *__keyp, void (*__dtor)(void *)); -extern int __gthread_key_delete (__gthread_key_t __key); - -extern void *__gthread_getspecific (__gthread_key_t __key); -extern int __gthread_setspecific (__gthread_key_t __key, void *__ptr); - -#undef UNUSED - -#ifdef __cplusplus -} -#endif - -#endif /* not _LIBOBJC */ - -#endif /* gthr-vxworks.h */ diff --git a/gcc/gthr-win32.h b/gcc/gthr-win32.h deleted file mode 100644 index 53f8396cc81..00000000000 --- a/gcc/gthr-win32.h +++ /dev/null @@ -1,772 +0,0 @@ -/* Threads compatibility routines for libgcc2 and libobjc. */ -/* Compile this one with gcc. */ - -/* Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2008, 2009 - Free Software Foundation, Inc. - Contributed by Mumit Khan . - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -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 -. */ - -#ifndef GCC_GTHR_WIN32_H -#define GCC_GTHR_WIN32_H - -/* Make sure CONST_CAST2 (origin in system.h) is declared. */ -#ifndef CONST_CAST2 -#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq) -#endif - -/* Windows32 threads specific definitions. The windows32 threading model - does not map well into pthread-inspired gcc's threading model, and so - there are caveats one needs to be aware of. - - 1. The destructor supplied to __gthread_key_create is ignored for - generic x86-win32 ports. This will certainly cause memory leaks - due to unreclaimed eh contexts (sizeof (eh_context) is at least - 24 bytes for x86 currently). - - This memory leak may be significant for long-running applications - that make heavy use of C++ EH. - - However, Mingw runtime (version 0.3 or newer) provides a mechanism - to emulate pthreads key dtors; the runtime provides a special DLL, - linked in if -mthreads option is specified, that runs the dtors in - the reverse order of registration when each thread exits. If - -mthreads option is not given, a stub is linked in instead of the - DLL, which results in memory leak. Other x86-win32 ports can use - the same technique of course to avoid the leak. - - 2. The error codes returned are non-POSIX like, and cast into ints. - This may cause incorrect error return due to truncation values on - hw where sizeof (DWORD) > sizeof (int). - - 3. We are currently using a special mutex instead of the Critical - Sections, since Win9x does not support TryEnterCriticalSection - (while NT does). - - The basic framework should work well enough. In the long term, GCC - needs to use Structured Exception Handling on Windows32. */ - -#define __GTHREADS 1 - -#include -#ifdef __MINGW32__ -#include <_mingw.h> -#endif - -#ifndef __UNUSED_PARAM -#define __UNUSED_PARAM(x) x -#endif - -#ifdef _LIBOBJC - -/* This is necessary to prevent windef.h (included from windows.h) from - defining its own BOOL as a typedef. */ -#ifndef __OBJC__ -#define __OBJC__ -#endif -#include -/* Now undef the windows BOOL. */ -#undef BOOL - -/* Key structure for maintaining thread specific storage */ -static DWORD __gthread_objc_data_tls = (DWORD) -1; - -/* Backend initialization functions */ - -/* Initialize the threads subsystem. */ -int -__gthread_objc_init_thread_system (void) -{ - /* Initialize the thread storage key. */ - if ((__gthread_objc_data_tls = TlsAlloc ()) != (DWORD) -1) - return 0; - else - return -1; -} - -/* Close the threads subsystem. */ -int -__gthread_objc_close_thread_system (void) -{ - if (__gthread_objc_data_tls != (DWORD) -1) - TlsFree (__gthread_objc_data_tls); - return 0; -} - -/* Backend thread functions */ - -/* Create a new thread of execution. */ -objc_thread_t -__gthread_objc_thread_detach (void (*func)(void *arg), void *arg) -{ - DWORD thread_id = 0; - HANDLE win32_handle; - - if (!(win32_handle = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) func, - arg, 0, &thread_id))) - thread_id = 0; - - return (objc_thread_t) (INT_PTR) thread_id; -} - -/* Set the current thread's priority. */ -int -__gthread_objc_thread_set_priority (int priority) -{ - int sys_priority = 0; - - switch (priority) - { - case OBJC_THREAD_INTERACTIVE_PRIORITY: - sys_priority = THREAD_PRIORITY_NORMAL; - break; - default: - case OBJC_THREAD_BACKGROUND_PRIORITY: - sys_priority = THREAD_PRIORITY_BELOW_NORMAL; - break; - case OBJC_THREAD_LOW_PRIORITY: - sys_priority = THREAD_PRIORITY_LOWEST; - break; - } - - /* Change priority */ - if (SetThreadPriority (GetCurrentThread (), sys_priority)) - return 0; - else - return -1; -} - -/* Return the current thread's priority. */ -int -__gthread_objc_thread_get_priority (void) -{ - int sys_priority; - - sys_priority = GetThreadPriority (GetCurrentThread ()); - - switch (sys_priority) - { - case THREAD_PRIORITY_HIGHEST: - case THREAD_PRIORITY_TIME_CRITICAL: - case THREAD_PRIORITY_ABOVE_NORMAL: - case THREAD_PRIORITY_NORMAL: - return OBJC_THREAD_INTERACTIVE_PRIORITY; - - default: - case THREAD_PRIORITY_BELOW_NORMAL: - return OBJC_THREAD_BACKGROUND_PRIORITY; - - case THREAD_PRIORITY_IDLE: - case THREAD_PRIORITY_LOWEST: - return OBJC_THREAD_LOW_PRIORITY; - } - - /* Couldn't get priority. */ - return -1; -} - -/* Yield our process time to another thread. */ -void -__gthread_objc_thread_yield (void) -{ - Sleep (0); -} - -/* Terminate the current thread. */ -int -__gthread_objc_thread_exit (void) -{ - /* exit the thread */ - ExitThread (__objc_thread_exit_status); - - /* Failed if we reached here */ - return -1; -} - -/* Returns an integer value which uniquely describes a thread. */ -objc_thread_t -__gthread_objc_thread_id (void) -{ - return (objc_thread_t) (INT_PTR) GetCurrentThreadId (); -} - -/* Sets the thread's local storage pointer. */ -int -__gthread_objc_thread_set_data (void *value) -{ - if (TlsSetValue (__gthread_objc_data_tls, value)) - return 0; - else - return -1; -} - -/* Returns the thread's local storage pointer. */ -void * -__gthread_objc_thread_get_data (void) -{ - DWORD lasterror; - void *ptr; - - lasterror = GetLastError (); - - ptr = TlsGetValue (__gthread_objc_data_tls); /* Return thread data. */ - - SetLastError (lasterror); - - return ptr; -} - -/* Backend mutex functions */ - -/* Allocate a mutex. */ -int -__gthread_objc_mutex_allocate (objc_mutex_t mutex) -{ - if ((mutex->backend = (void *) CreateMutex (NULL, 0, NULL)) == NULL) - return -1; - else - return 0; -} - -/* Deallocate a mutex. */ -int -__gthread_objc_mutex_deallocate (objc_mutex_t mutex) -{ - CloseHandle ((HANDLE) (mutex->backend)); - return 0; -} - -/* Grab a lock on a mutex. */ -int -__gthread_objc_mutex_lock (objc_mutex_t mutex) -{ - int status; - - status = WaitForSingleObject ((HANDLE) (mutex->backend), INFINITE); - if (status != WAIT_OBJECT_0 && status != WAIT_ABANDONED) - return -1; - else - return 0; -} - -/* Try to grab a lock on a mutex. */ -int -__gthread_objc_mutex_trylock (objc_mutex_t mutex) -{ - int status; - - status = WaitForSingleObject ((HANDLE) (mutex->backend), 0); - if (status != WAIT_OBJECT_0 && status != WAIT_ABANDONED) - return -1; - else - return 0; -} - -/* Unlock the mutex */ -int -__gthread_objc_mutex_unlock (objc_mutex_t mutex) -{ - if (ReleaseMutex ((HANDLE) (mutex->backend)) == 0) - return -1; - else - return 0; -} - -/* Backend condition mutex functions */ - -/* Allocate a condition. */ -int -__gthread_objc_condition_allocate (objc_condition_t __UNUSED_PARAM(condition)) -{ - /* Unimplemented. */ - return -1; -} - -/* Deallocate a condition. */ -int -__gthread_objc_condition_deallocate (objc_condition_t __UNUSED_PARAM(condition)) -{ - /* Unimplemented. */ - return -1; -} - -/* Wait on the condition */ -int -__gthread_objc_condition_wait (objc_condition_t __UNUSED_PARAM(condition), - objc_mutex_t __UNUSED_PARAM(mutex)) -{ - /* Unimplemented. */ - return -1; -} - -/* Wake up all threads waiting on this condition. */ -int -__gthread_objc_condition_broadcast (objc_condition_t __UNUSED_PARAM(condition)) -{ - /* Unimplemented. */ - return -1; -} - -/* Wake up one thread waiting on this condition. */ -int -__gthread_objc_condition_signal (objc_condition_t __UNUSED_PARAM(condition)) -{ - /* Unimplemented. */ - return -1; -} - -#else /* _LIBOBJC */ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef unsigned long __gthread_key_t; - -typedef struct { - int done; - long started; -} __gthread_once_t; - -typedef struct { - long counter; - void *sema; -} __gthread_mutex_t; - -typedef struct { - long counter; - long depth; - unsigned long owner; - void *sema; -} __gthread_recursive_mutex_t; - -#define __GTHREAD_ONCE_INIT {0, -1} -#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function -#define __GTHREAD_MUTEX_INIT_DEFAULT {-1, 0} -#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION \ - __gthread_recursive_mutex_init_function -#define __GTHREAD_RECURSIVE_MUTEX_INIT_DEFAULT {-1, 0, 0, 0} - -#if defined (_WIN32) && !defined(__CYGWIN__) -#define MINGW32_SUPPORTS_MT_EH 1 -/* Mingw runtime >= v0.3 provides a magic variable that is set to nonzero - if -mthreads option was specified, or 0 otherwise. This is to get around - the lack of weak symbols in PE-COFF. */ -extern int _CRT_MT; -extern int __mingwthr_key_dtor (unsigned long, void (*) (void *)); -#endif /* _WIN32 && !__CYGWIN__ */ - -/* The Windows95 kernel does not export InterlockedCompareExchange. - This provides a substitute. When building apps that reference - gthread_mutex_try_lock, the __GTHREAD_I486_INLINE_LOCK_PRIMITIVES - macro must be defined if Windows95 is a target. Currently - gthread_mutex_try_lock is not referenced by libgcc or libstdc++. */ -#ifdef __GTHREAD_I486_INLINE_LOCK_PRIMITIVES -static inline long -__gthr_i486_lock_cmp_xchg(long *__dest, long __xchg, long __comperand) -{ - long result; - __asm__ __volatile__ ("\n\ - lock\n\ - cmpxchg{l} {%4, %1|%1, %4}\n" - : "=a" (result), "=m" (*__dest) - : "0" (__comperand), "m" (*__dest), "r" (__xchg) - : "cc"); - return result; -} -#define __GTHR_W32_InterlockedCompareExchange __gthr_i486_lock_cmp_xchg -#else /* __GTHREAD_I486_INLINE_LOCK_PRIMITIVES */ -#define __GTHR_W32_InterlockedCompareExchange InterlockedCompareExchange -#endif /* __GTHREAD_I486_INLINE_LOCK_PRIMITIVES */ - -static inline int -__gthread_active_p (void) -{ -#ifdef MINGW32_SUPPORTS_MT_EH - return _CRT_MT; -#else - return 1; -#endif -} - -#if __GTHREAD_HIDE_WIN32API - -/* The implementations are in config/i386/gthr-win32.c in libgcc.a. - Only stubs are exposed to avoid polluting the C++ namespace with - windows api definitions. */ - -extern int __gthr_win32_once (__gthread_once_t *, void (*) (void)); -extern int __gthr_win32_key_create (__gthread_key_t *, void (*) (void*)); -extern int __gthr_win32_key_delete (__gthread_key_t); -extern void * __gthr_win32_getspecific (__gthread_key_t); -extern int __gthr_win32_setspecific (__gthread_key_t, const void *); -extern void __gthr_win32_mutex_init_function (__gthread_mutex_t *); -extern int __gthr_win32_mutex_lock (__gthread_mutex_t *); -extern int __gthr_win32_mutex_trylock (__gthread_mutex_t *); -extern int __gthr_win32_mutex_unlock (__gthread_mutex_t *); -extern void - __gthr_win32_recursive_mutex_init_function (__gthread_recursive_mutex_t *); -extern int __gthr_win32_recursive_mutex_lock (__gthread_recursive_mutex_t *); -extern int - __gthr_win32_recursive_mutex_trylock (__gthread_recursive_mutex_t *); -extern int __gthr_win32_recursive_mutex_unlock (__gthread_recursive_mutex_t *); -extern void __gthr_win32_mutex_destroy (__gthread_mutex_t *); - -static inline int -__gthread_once (__gthread_once_t *__once, void (*__func) (void)) -{ - if (__gthread_active_p ()) - return __gthr_win32_once (__once, __func); - else - return -1; -} - -static inline int -__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) -{ - return __gthr_win32_key_create (__key, __dtor); -} - -static inline int -__gthread_key_delete (__gthread_key_t __key) -{ - return __gthr_win32_key_delete (__key); -} - -static inline void * -__gthread_getspecific (__gthread_key_t __key) -{ - return __gthr_win32_getspecific (__key); -} - -static inline int -__gthread_setspecific (__gthread_key_t __key, const void *__ptr) -{ - return __gthr_win32_setspecific (__key, __ptr); -} - -static inline void -__gthread_mutex_init_function (__gthread_mutex_t *__mutex) -{ - __gthr_win32_mutex_init_function (__mutex); -} - -static inline void -__gthread_mutex_destroy (__gthread_mutex_t *__mutex) -{ - __gthr_win32_mutex_destroy (__mutex); -} - -static inline int -__gthread_mutex_lock (__gthread_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthr_win32_mutex_lock (__mutex); - else - return 0; -} - -static inline int -__gthread_mutex_trylock (__gthread_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthr_win32_mutex_trylock (__mutex); - else - return 0; -} - -static inline int -__gthread_mutex_unlock (__gthread_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthr_win32_mutex_unlock (__mutex); - else - return 0; -} - -static inline void -__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) -{ - __gthr_win32_recursive_mutex_init_function (__mutex); -} - -static inline int -__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthr_win32_recursive_mutex_lock (__mutex); - else - return 0; -} - -static inline int -__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthr_win32_recursive_mutex_trylock (__mutex); - else - return 0; -} - -static inline int -__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - return __gthr_win32_recursive_mutex_unlock (__mutex); - else - return 0; -} - -#else /* ! __GTHREAD_HIDE_WIN32API */ - -#include -#include - -static inline int -__gthread_once (__gthread_once_t *__once, void (*__func) (void)) -{ - if (! __gthread_active_p ()) - return -1; - else if (__once == NULL || __func == NULL) - return EINVAL; - - if (! __once->done) - { - if (InterlockedIncrement (&(__once->started)) == 0) - { - (*__func) (); - __once->done = TRUE; - } - else - { - /* Another thread is currently executing the code, so wait for it - to finish; yield the CPU in the meantime. If performance - does become an issue, the solution is to use an Event that - we wait on here (and set above), but that implies a place to - create the event before this routine is called. */ - while (! __once->done) - Sleep (0); - } - } - - return 0; -} - -/* Windows32 thread local keys don't support destructors; this leads to - leaks, especially in threaded applications making extensive use of - C++ EH. Mingw uses a thread-support DLL to work-around this problem. */ -static inline int -__gthread_key_create (__gthread_key_t *__key, - void (*__dtor) (void *) __attribute__((unused))) -{ - int __status = 0; - DWORD __tls_index = TlsAlloc (); - if (__tls_index != 0xFFFFFFFF) - { - *__key = __tls_index; -#ifdef MINGW32_SUPPORTS_MT_EH - /* Mingw runtime will run the dtors in reverse order for each thread - when the thread exits. */ - __status = __mingwthr_key_dtor (*__key, __dtor); -#endif - } - else - __status = (int) GetLastError (); - return __status; -} - -static inline int -__gthread_key_delete (__gthread_key_t __key) -{ - return (TlsFree (__key) != 0) ? 0 : (int) GetLastError (); -} - -static inline void * -__gthread_getspecific (__gthread_key_t __key) -{ - DWORD __lasterror; - void *__ptr; - - __lasterror = GetLastError (); - - __ptr = TlsGetValue (__key); - - SetLastError (__lasterror); - - return __ptr; -} - -static inline int -__gthread_setspecific (__gthread_key_t __key, const void *__ptr) -{ - if (TlsSetValue (__key, CONST_CAST2(void *, const void *, __ptr)) != 0) - return 0; - else - return GetLastError (); -} - -static inline void -__gthread_mutex_init_function (__gthread_mutex_t *__mutex) -{ - __mutex->counter = -1; - __mutex->sema = CreateSemaphore (NULL, 0, 65535, NULL); -} - -static inline void -__gthread_mutex_destroy (__gthread_mutex_t *__mutex) -{ - CloseHandle ((HANDLE) __mutex->sema); -} - -static inline int -__gthread_mutex_lock (__gthread_mutex_t *__mutex) -{ - int __status = 0; - - if (__gthread_active_p ()) - { - if (InterlockedIncrement (&__mutex->counter) == 0 || - WaitForSingleObject (__mutex->sema, INFINITE) == WAIT_OBJECT_0) - __status = 0; - else - { - /* WaitForSingleObject returns WAIT_FAILED, and we can only do - some best-effort cleanup here. */ - InterlockedDecrement (&__mutex->counter); - __status = 1; - } - } - return __status; -} - -static inline int -__gthread_mutex_trylock (__gthread_mutex_t *__mutex) -{ - int __status = 0; - - if (__gthread_active_p ()) - { - if (__GTHR_W32_InterlockedCompareExchange (&__mutex->counter, 0, -1) < 0) - __status = 0; - else - __status = 1; - } - return __status; -} - -static inline int -__gthread_mutex_unlock (__gthread_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - { - if (InterlockedDecrement (&__mutex->counter) >= 0) - return ReleaseSemaphore (__mutex->sema, 1, NULL) ? 0 : 1; - } - return 0; -} - -static inline void -__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) -{ - __mutex->counter = -1; - __mutex->depth = 0; - __mutex->owner = 0; - __mutex->sema = CreateSemaphore (NULL, 0, 65535, NULL); -} - -static inline int -__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - { - DWORD __me = GetCurrentThreadId(); - if (InterlockedIncrement (&__mutex->counter) == 0) - { - __mutex->depth = 1; - __mutex->owner = __me; - } - else if (__mutex->owner == __me) - { - InterlockedDecrement (&__mutex->counter); - ++(__mutex->depth); - } - else if (WaitForSingleObject (__mutex->sema, INFINITE) == WAIT_OBJECT_0) - { - __mutex->depth = 1; - __mutex->owner = __me; - } - else - { - /* WaitForSingleObject returns WAIT_FAILED, and we can only do - some best-effort cleanup here. */ - InterlockedDecrement (&__mutex->counter); - return 1; - } - } - return 0; -} - -static inline int -__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - { - DWORD __me = GetCurrentThreadId(); - if (__GTHR_W32_InterlockedCompareExchange (&__mutex->counter, 0, -1) < 0) - { - __mutex->depth = 1; - __mutex->owner = __me; - } - else if (__mutex->owner == __me) - ++(__mutex->depth); - else - return 1; - } - return 0; -} - -static inline int -__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) -{ - if (__gthread_active_p ()) - { - --(__mutex->depth); - if (__mutex->depth == 0) - { - __mutex->owner = 0; - - if (InterlockedDecrement (&__mutex->counter) >= 0) - return ReleaseSemaphore (__mutex->sema, 1, NULL) ? 0 : 1; - } - } - return 0; -} - -#endif /* __GTHREAD_HIDE_WIN32API */ - -#ifdef __cplusplus -} -#endif - -#endif /* _LIBOBJC */ - -#endif /* ! GCC_GTHR_WIN32_H */ diff --git a/gcc/gthr.h b/gcc/gthr.h deleted file mode 100644 index 0c7bfb17aa3..00000000000 --- a/gcc/gthr.h +++ /dev/null @@ -1,168 +0,0 @@ -/* Threads compatibility routines for libgcc2. */ -/* Compile this one with gcc. */ -/* Copyright (C) 1997, 1998, 2004, 2008, 2009, 2011 - Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -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 -. */ - -#ifndef GCC_GTHR_H -#define GCC_GTHR_H - -#ifndef HIDE_EXPORTS -#pragma GCC visibility push(default) -#endif - -/* If this file is compiled with threads support, it must - #define __GTHREADS 1 - to indicate that threads support is present. Also it has define - function - int __gthread_active_p () - that returns 1 if thread system is active, 0 if not. - - The threads interface must define the following types: - __gthread_key_t - __gthread_once_t - __gthread_mutex_t - __gthread_recursive_mutex_t - - The threads interface must define the following macros: - - __GTHREAD_ONCE_INIT - to initialize __gthread_once_t - __GTHREAD_MUTEX_INIT - to initialize __gthread_mutex_t to get a fast - non-recursive mutex. - __GTHREAD_MUTEX_INIT_FUNCTION - some systems can't initialize a mutex without a - function call. On such systems, define this to a - function which looks like this: - void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *) - Don't define __GTHREAD_MUTEX_INIT in this case - __GTHREAD_RECURSIVE_MUTEX_INIT - __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION - as above, but for a recursive mutex. - - The threads interface must define the following static functions: - - int __gthread_once (__gthread_once_t *once, void (*func) ()) - - int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *)) - int __gthread_key_delete (__gthread_key_t key) - - void *__gthread_getspecific (__gthread_key_t key) - int __gthread_setspecific (__gthread_key_t key, const void *ptr) - - int __gthread_mutex_destroy (__gthread_mutex_t *mutex); - - int __gthread_mutex_lock (__gthread_mutex_t *mutex); - int __gthread_mutex_trylock (__gthread_mutex_t *mutex); - int __gthread_mutex_unlock (__gthread_mutex_t *mutex); - - int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex); - int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex); - int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex); - - The following are supported in POSIX threads only. They are required to - fix a deadlock in static initialization inside libsupc++. The header file - gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra - features are supported. - - Types: - __gthread_cond_t - - Macros: - __GTHREAD_COND_INIT - __GTHREAD_COND_INIT_FUNCTION - - Interface: - int __gthread_cond_broadcast (__gthread_cond_t *cond); - int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex); - int __gthread_cond_wait_recursive (__gthread_cond_t *cond, - __gthread_recursive_mutex_t *mutex); - - All functions returning int should return zero on success or the error - number. If the operation is not supported, -1 is returned. - - If the following are also defined, you should - #define __GTHREADS_CXX0X 1 - to enable the c++0x thread library. - - Types: - __gthread_t - __gthread_time_t - - Interface: - int __gthread_create (__gthread_t *thread, void *(*func) (void*), - void *args); - int __gthread_join (__gthread_t thread, void **value_ptr); - int __gthread_detach (__gthread_t thread); - int __gthread_equal (__gthread_t t1, __gthread_t t2); - __gthread_t __gthread_self (void); - int __gthread_yield (void); - - int __gthread_mutex_timedlock (__gthread_mutex_t *m, - const __gthread_time_t *abs_timeout); - int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m, - const __gthread_time_t *abs_time); - - int __gthread_cond_signal (__gthread_cond_t *cond); - int __gthread_cond_timedwait (__gthread_cond_t *cond, - __gthread_mutex_t *mutex, - const __gthread_time_t *abs_timeout); - int __gthread_cond_timedwait_recursive (__gthread_cond_t *cond, - __gthread_recursive_mutex_t *mutex, - const __gthread_time_t *abs_time) - - Currently supported threads packages are - TPF threads with -D__tpf__ - POSIX/Unix98 threads with -D_PTHREADS - DCE threads with -D_DCE_THREADS - -*/ - -/* Check first for thread specific defines. */ -#if defined (__tpf__) -#include "gthr-tpf.h" -#elif _PTHREADS -#include "gthr-posix.h" -#elif _DCE_THREADS -#include "gthr-dce.h" - -/* Include GTHREAD_FILE if one is defined. */ -#elif defined(HAVE_GTHR_DEFAULT) -#if SUPPORTS_WEAK -#ifndef GTHREAD_USE_WEAK -#define GTHREAD_USE_WEAK 1 -#endif -#endif -#include "gthr-default.h" - -/* Fallback to single thread definitions. */ -#else -#include "gthr-single.h" -#endif - -#ifndef HIDE_EXPORTS -#pragma GCC visibility pop -#endif - -#endif /* ! GCC_GTHR_H */ diff --git a/gcc/po/ChangeLog b/gcc/po/ChangeLog index 5cc12f4372c..c7164125d0c 100644 --- a/gcc/po/ChangeLog +++ b/gcc/po/ChangeLog @@ -1,3 +1,9 @@ +2011-11-02 Rainer Orth + + * EXCLUDES (gthr-aix.h, gthr-dce.h, gthr-posix.c, gthr-posix.h) + (gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h) + (gthr-win32.h, gthr.h): Remove. + 2011-11-02 Rainer Orth * EXCLUDES (config/vxlib.c, gbl-ctors.h, libgcc2.c, libgcc2.h) diff --git a/gcc/po/EXCLUDES b/gcc/po/EXCLUDES index c969910fa56..e04b9239363 100644 --- a/gcc/po/EXCLUDES +++ b/gcc/po/EXCLUDES @@ -24,16 +24,6 @@ # These files are part of libgcc, or target headers provided by gcc. gcov-io.h gcov-iov.c -gthr-aix.h -gthr-dce.h -gthr-posix.c -gthr-posix.h -gthr-rtems.h -gthr-single.h -gthr-solaris.h -gthr-vxworks.h -gthr-win32.h -gthr.h limitx.h limity.h diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index c169190c397..1bbe29afd05 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,17 @@ +2011-11-02 Rainer Orth + + * gthr-single.h, gthr.h: New files. + * config/gthr-lynx.h, config/gthr-posix.h., config/gthr-rtems.h, + config/gthr-vxworks.h, config/i386/gthr-win32.h, + config/mips/gthr-mipssde.h, config/pa/gthr-dce.h, + config/rs6000/gthr-aix.h, config/s390/gthr-tpf.h: New files. + * config/i386/gthr-win32.c: Include "gthr-win32.h". + * configure.ac (thread_header): New variable. + Set it depending on target_thread_file. + (gthr-default.h): Link from $thread_header. + * configure: Regenerate. + * Makefile.in (LIBGCC2_CFLAGS): Remove $(GTHREAD_FLAGS). + 2011-11-02 Rainer Orth * configure.ac (tm_file_): New variable. diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in index 2ea6ca69d64..8f0c02ff3ec 100644 --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -223,8 +223,7 @@ endif # LIBGCC2_DEBUG_CFLAGS = -g LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \ - $(LIBGCC2_DEBUG_CFLAGS) $(GTHREAD_FLAGS) \ - -DIN_LIBGCC2 \ + $(LIBGCC2_DEBUG_CFLAGS) -DIN_LIBGCC2 \ -fbuilding-libgcc -fno-stack-protector \ $(INHIBIT_LIBC_CFLAGS) diff --git a/libgcc/config/gthr-lynx.h b/libgcc/config/gthr-lynx.h new file mode 100644 index 00000000000..c98c2e6693e --- /dev/null +++ b/libgcc/config/gthr-lynx.h @@ -0,0 +1,61 @@ +/* Threads compatibility routines for libgcc2 and libobjc for + LynxOS. */ +/* Compile this one with gcc. */ +/* Copyright (C) 2004, 2008, 2009, 2011 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +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 +. */ + +#ifndef GCC_GTHR_LYNX_H +#define GCC_GTHR_LYNX_H + +#ifdef _MULTITHREADED + +/* Using the macro version of pthread_setspecific leads to a + compilation error. Instead we have two choices either kill all + macros in pthread.h with defining _POSIX_THREADS_CALLS or undefine + individual macros where we should fall back on the function + implementation. We choose the second approach. */ + +#include +#undef pthread_setspecific + +/* When using static libc on LynxOS, we cannot define pthread_create + weak. If the multi-threaded application includes iostream.h, + gthr-posix.h is included and pthread_create will be defined weak. + If pthread_create is weak its defining module in libc is not + necessarily included in the link and the symbol is resolved to zero. + Therefore the first call to it will crash. + + Since -mthreads is a multilib switch on LynxOS we know that at this + point we are compiling for multi-threaded. Omitting the weak + definitions at this point should have no effect. */ + +#undef GTHREAD_USE_WEAK +#define GTHREAD_USE_WEAK 0 + +#include "config/gthr-posix.h" + +#else +#include "gthr-single.h" +#endif + +#endif /* GCC_GTHR_LYNX_H */ diff --git a/libgcc/config/gthr-posix.h b/libgcc/config/gthr-posix.h new file mode 100644 index 00000000000..46054f6a7c2 --- /dev/null +++ b/libgcc/config/gthr-posix.h @@ -0,0 +1,879 @@ +/* Threads compatibility routines for libgcc2 and libobjc. */ +/* Compile this one with gcc. */ +/* Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + 2008, 2009, 2010, 2011 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +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 +. */ + +#ifndef GCC_GTHR_POSIX_H +#define GCC_GTHR_POSIX_H + +/* POSIX threads specific definitions. + Easy, since the interface is just one-to-one mapping. */ + +#define __GTHREADS 1 +#define __GTHREADS_CXX0X 1 + +/* Some implementations of require this to be defined. */ +#if !defined(_REENTRANT) && defined(__osf__) +#define _REENTRANT 1 +#endif + +#include + +#if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \ + || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK)) +# include +# if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0 +# define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 +# else +# define _GTHREAD_USE_MUTEX_TIMEDLOCK 0 +# endif +#endif + +typedef pthread_t __gthread_t; +typedef pthread_key_t __gthread_key_t; +typedef pthread_once_t __gthread_once_t; +typedef pthread_mutex_t __gthread_mutex_t; +typedef pthread_mutex_t __gthread_recursive_mutex_t; +typedef pthread_cond_t __gthread_cond_t; +typedef struct timespec __gthread_time_t; + +/* POSIX like conditional variables are supported. Please look at comments + in gthr.h for details. */ +#define __GTHREAD_HAS_COND 1 + +#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER +#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT +#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) +#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER +#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) +#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP +#else +#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function +#endif +#define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER +#define __GTHREAD_TIME_INIT {0,0} + +#if SUPPORTS_WEAK && GTHREAD_USE_WEAK +# ifndef __gthrw_pragma +# define __gthrw_pragma(pragma) +# endif +# define __gthrw2(name,name2,type) \ + static __typeof(type) name __attribute__ ((__weakref__(#name2))); \ + __gthrw_pragma(weak type) +# define __gthrw_(name) __gthrw_ ## name +#else +# define __gthrw2(name,name2,type) +# define __gthrw_(name) name +#endif + +/* Typically, __gthrw_foo is a weak reference to symbol foo. */ +#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name) + +/* On Tru64, /usr/include/pthread.h uses #pragma extern_prefix "__" to + map a subset of the POSIX pthread API to mangled versions of their + names. */ +#if defined(__osf__) && defined(_PTHREAD_USE_MANGLED_NAMES_) +#define __gthrw3(name) __gthrw2(__gthrw_ ## name, __ ## name, name) +__gthrw3(pthread_once) +__gthrw3(pthread_getspecific) +__gthrw3(pthread_setspecific) + +__gthrw3(pthread_create) +__gthrw3(pthread_join) +__gthrw3(pthread_detach) +__gthrw3(pthread_equal) +__gthrw3(pthread_self) +__gthrw3(pthread_cancel) +__gthrw3(sched_yield) + +__gthrw3(pthread_mutex_lock) +__gthrw3(pthread_mutex_trylock) +#if _GTHREAD_USE_MUTEX_TIMEDLOCK +__gthrw3(pthread_mutex_timedlock) +#endif +__gthrw3(pthread_mutex_unlock) +__gthrw3(pthread_mutex_init) +__gthrw3(pthread_mutex_destroy) + +__gthrw3(pthread_cond_broadcast) +__gthrw3(pthread_cond_signal) +__gthrw3(pthread_cond_wait) +__gthrw3(pthread_cond_timedwait) +__gthrw3(pthread_cond_destroy) +#else +__gthrw(pthread_once) +__gthrw(pthread_getspecific) +__gthrw(pthread_setspecific) + +__gthrw(pthread_create) +__gthrw(pthread_join) +__gthrw(pthread_equal) +__gthrw(pthread_self) +__gthrw(pthread_detach) +#ifndef __BIONIC__ +__gthrw(pthread_cancel) +#endif +__gthrw(sched_yield) + +__gthrw(pthread_mutex_lock) +__gthrw(pthread_mutex_trylock) +#if _GTHREAD_USE_MUTEX_TIMEDLOCK +__gthrw(pthread_mutex_timedlock) +#endif +__gthrw(pthread_mutex_unlock) +__gthrw(pthread_mutex_init) +__gthrw(pthread_mutex_destroy) + +__gthrw(pthread_cond_broadcast) +__gthrw(pthread_cond_signal) +__gthrw(pthread_cond_wait) +__gthrw(pthread_cond_timedwait) +__gthrw(pthread_cond_destroy) +#endif + +__gthrw(pthread_key_create) +__gthrw(pthread_key_delete) +__gthrw(pthread_mutexattr_init) +__gthrw(pthread_mutexattr_settype) +__gthrw(pthread_mutexattr_destroy) + + +#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK) +/* Objective-C. */ +#if defined(__osf__) && defined(_PTHREAD_USE_MANGLED_NAMES_) +__gthrw3(pthread_cond_init) +__gthrw3(pthread_exit) +#else +__gthrw(pthread_cond_init) +__gthrw(pthread_exit) +#endif /* __osf__ && _PTHREAD_USE_MANGLED_NAMES_ */ +#ifdef _POSIX_PRIORITY_SCHEDULING +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING +__gthrw(sched_get_priority_max) +__gthrw(sched_get_priority_min) +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _POSIX_PRIORITY_SCHEDULING */ +__gthrw(pthread_attr_destroy) +__gthrw(pthread_attr_init) +__gthrw(pthread_attr_setdetachstate) +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING +__gthrw(pthread_getschedparam) +__gthrw(pthread_setschedparam) +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _LIBOBJC || _LIBOBJC_WEAK */ + +#if SUPPORTS_WEAK && GTHREAD_USE_WEAK + +/* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if + -pthreads is not specified. The functions are dummies and most return an + error value. However pthread_once returns 0 without invoking the routine + it is passed so we cannot pretend that the interface is active if -pthreads + is not specified. On Solaris 2.5.1, the interface is not exposed at all so + we need to play the usual game with weak symbols. On Solaris 10 and up, a + working interface is always exposed. On FreeBSD 6 and later, libc also + exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up + to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc, + which means the alternate __gthread_active_p below cannot be used there. */ + +#if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__)) + +static volatile int __gthread_active = -1; + +static void +__gthread_trigger (void) +{ + __gthread_active = 1; +} + +static inline int +__gthread_active_p (void) +{ + static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER; + static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT; + + /* Avoid reading __gthread_active twice on the main code path. */ + int __gthread_active_latest_value = __gthread_active; + + /* This test is not protected to avoid taking a lock on the main code + path so every update of __gthread_active in a threaded program must + be atomic with regard to the result of the test. */ + if (__builtin_expect (__gthread_active_latest_value < 0, 0)) + { + if (__gthrw_(pthread_once)) + { + /* If this really is a threaded program, then we must ensure that + __gthread_active has been set to 1 before exiting this block. */ + __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex); + __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger); + __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex); + } + + /* Make sure we'll never enter this block again. */ + if (__gthread_active < 0) + __gthread_active = 0; + + __gthread_active_latest_value = __gthread_active; + } + + return __gthread_active_latest_value != 0; +} + +#else /* neither FreeBSD nor Solaris */ + +static inline int +__gthread_active_p (void) +{ +/* Android's C library does not provide pthread_cancel, check for + `pthread_create' instead. */ +#ifndef __BIONIC__ + static void *const __gthread_active_ptr + = __extension__ (void *) &__gthrw_(pthread_cancel); +#else + static void *const __gthread_active_ptr + = __extension__ (void *) &__gthrw_(pthread_create); +#endif + return __gthread_active_ptr != 0; +} + +#endif /* FreeBSD or Solaris */ + +#else /* not SUPPORTS_WEAK */ + +/* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread + calls in shared flavors of the HP-UX C library. Most of the stubs + have no functionality. The details are described in the "libc cumulative + patch" for each subversion of HP-UX 11. There are two special interfaces + provided for checking whether an application is linked to a shared pthread + library or not. However, these interfaces aren't available in early + libpthread libraries. We also need a test that works for archive + libraries. We can't use pthread_once as some libc versions call the + init function. We also can't use pthread_create or pthread_attr_init + as these create a thread and thereby prevent changing the default stack + size. The function pthread_default_stacksize_np is available in both + the archive and shared versions of libpthread. It can be used to + determine the default pthread stack size. There is a stub in some + shared libc versions which returns a zero size if pthreads are not + active. We provide an equivalent stub to handle cases where libc + doesn't provide one. */ + +#if defined(__hppa__) && defined(__hpux__) + +static volatile int __gthread_active = -1; + +static inline int +__gthread_active_p (void) +{ + /* Avoid reading __gthread_active twice on the main code path. */ + int __gthread_active_latest_value = __gthread_active; + size_t __s; + + if (__builtin_expect (__gthread_active_latest_value < 0, 0)) + { + pthread_default_stacksize_np (0, &__s); + __gthread_active = __s ? 1 : 0; + __gthread_active_latest_value = __gthread_active; + } + + return __gthread_active_latest_value != 0; +} + +#else /* not hppa-hpux */ + +static inline int +__gthread_active_p (void) +{ + return 1; +} + +#endif /* hppa-hpux */ + +#endif /* SUPPORTS_WEAK */ + +#ifdef _LIBOBJC + +/* This is the config.h file in libobjc/ */ +#include + +#ifdef HAVE_SCHED_H +# include +#endif + +/* Key structure for maintaining thread specific storage */ +static pthread_key_t _objc_thread_storage; +static pthread_attr_t _objc_thread_attribs; + +/* Thread local storage for a single thread */ +static void *thread_local_storage = NULL; + +/* Backend initialization functions */ + +/* Initialize the threads subsystem. */ +static inline int +__gthread_objc_init_thread_system (void) +{ + if (__gthread_active_p ()) + { + /* Initialize the thread storage key. */ + if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0) + { + /* The normal default detach state for threads is + * PTHREAD_CREATE_JOINABLE which causes threads to not die + * when you think they should. */ + if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0 + && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs, + PTHREAD_CREATE_DETACHED) == 0) + return 0; + } + } + + return -1; +} + +/* Close the threads subsystem. */ +static inline int +__gthread_objc_close_thread_system (void) +{ + if (__gthread_active_p () + && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0 + && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0) + return 0; + + return -1; +} + +/* Backend thread functions */ + +/* Create a new thread of execution. */ +static inline objc_thread_t +__gthread_objc_thread_detach (void (*func)(void *), void *arg) +{ + objc_thread_t thread_id; + pthread_t new_thread_handle; + + if (!__gthread_active_p ()) + return NULL; + + if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs, + (void *) func, arg))) + thread_id = (objc_thread_t) new_thread_handle; + else + thread_id = NULL; + + return thread_id; +} + +/* Set the current thread's priority. */ +static inline int +__gthread_objc_thread_set_priority (int priority) +{ + if (!__gthread_active_p ()) + return -1; + else + { +#ifdef _POSIX_PRIORITY_SCHEDULING +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING + pthread_t thread_id = __gthrw_(pthread_self) (); + int policy; + struct sched_param params; + int priority_min, priority_max; + + if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0) + { + if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1) + return -1; + + if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1) + return -1; + + if (priority > priority_max) + priority = priority_max; + else if (priority < priority_min) + priority = priority_min; + params.sched_priority = priority; + + /* + * The solaris 7 and several other man pages incorrectly state that + * this should be a pointer to policy but pthread.h is universally + * at odds with this. + */ + if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0) + return 0; + } +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _POSIX_PRIORITY_SCHEDULING */ + return -1; + } +} + +/* Return the current thread's priority. */ +static inline int +__gthread_objc_thread_get_priority (void) +{ +#ifdef _POSIX_PRIORITY_SCHEDULING +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING + if (__gthread_active_p ()) + { + int policy; + struct sched_param params; + + if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0) + return params.sched_priority; + else + return -1; + } + else +#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ +#endif /* _POSIX_PRIORITY_SCHEDULING */ + return OBJC_THREAD_INTERACTIVE_PRIORITY; +} + +/* Yield our process time to another thread. */ +static inline void +__gthread_objc_thread_yield (void) +{ + if (__gthread_active_p ()) + __gthrw_(sched_yield) (); +} + +/* Terminate the current thread. */ +static inline int +__gthread_objc_thread_exit (void) +{ + if (__gthread_active_p ()) + /* exit the thread */ + __gthrw_(pthread_exit) (&__objc_thread_exit_status); + + /* Failed if we reached here */ + return -1; +} + +/* Returns an integer value which uniquely describes a thread. */ +static inline objc_thread_t +__gthread_objc_thread_id (void) +{ + if (__gthread_active_p ()) + return (objc_thread_t) __gthrw_(pthread_self) (); + else + return (objc_thread_t) 1; +} + +/* Sets the thread's local storage pointer. */ +static inline int +__gthread_objc_thread_set_data (void *value) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_setspecific) (_objc_thread_storage, value); + else + { + thread_local_storage = value; + return 0; + } +} + +/* Returns the thread's local storage pointer. */ +static inline void * +__gthread_objc_thread_get_data (void) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_getspecific) (_objc_thread_storage); + else + return thread_local_storage; +} + +/* Backend mutex functions */ + +/* Allocate a mutex. */ +static inline int +__gthread_objc_mutex_allocate (objc_mutex_t mutex) +{ + if (__gthread_active_p ()) + { + mutex->backend = objc_malloc (sizeof (pthread_mutex_t)); + + if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL)) + { + objc_free (mutex->backend); + mutex->backend = NULL; + return -1; + } + } + + return 0; +} + +/* Deallocate a mutex. */ +static inline int +__gthread_objc_mutex_deallocate (objc_mutex_t mutex) +{ + if (__gthread_active_p ()) + { + int count; + + /* + * Posix Threads specifically require that the thread be unlocked + * for __gthrw_(pthread_mutex_destroy) to work. + */ + + do + { + count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend); + if (count < 0) + return -1; + } + while (count); + + if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend)) + return -1; + + objc_free (mutex->backend); + mutex->backend = NULL; + } + return 0; +} + +/* Grab a lock on a mutex. */ +static inline int +__gthread_objc_mutex_lock (objc_mutex_t mutex) +{ + if (__gthread_active_p () + && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0) + { + return -1; + } + + return 0; +} + +/* Try to grab a lock on a mutex. */ +static inline int +__gthread_objc_mutex_trylock (objc_mutex_t mutex) +{ + if (__gthread_active_p () + && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0) + { + return -1; + } + + return 0; +} + +/* Unlock the mutex */ +static inline int +__gthread_objc_mutex_unlock (objc_mutex_t mutex) +{ + if (__gthread_active_p () + && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0) + { + return -1; + } + + return 0; +} + +/* Backend condition mutex functions */ + +/* Allocate a condition. */ +static inline int +__gthread_objc_condition_allocate (objc_condition_t condition) +{ + if (__gthread_active_p ()) + { + condition->backend = objc_malloc (sizeof (pthread_cond_t)); + + if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL)) + { + objc_free (condition->backend); + condition->backend = NULL; + return -1; + } + } + + return 0; +} + +/* Deallocate a condition. */ +static inline int +__gthread_objc_condition_deallocate (objc_condition_t condition) +{ + if (__gthread_active_p ()) + { + if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend)) + return -1; + + objc_free (condition->backend); + condition->backend = NULL; + } + return 0; +} + +/* Wait on the condition */ +static inline int +__gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend, + (pthread_mutex_t *) mutex->backend); + else + return 0; +} + +/* Wake up all threads waiting on this condition. */ +static inline int +__gthread_objc_condition_broadcast (objc_condition_t condition) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend); + else + return 0; +} + +/* Wake up one thread waiting on this condition. */ +static inline int +__gthread_objc_condition_signal (objc_condition_t condition) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend); + else + return 0; +} + +#else /* _LIBOBJC */ + +static inline int +__gthread_create (__gthread_t *__threadid, void *(*__func) (void*), + void *__args) +{ + return __gthrw_(pthread_create) (__threadid, NULL, __func, __args); +} + +static inline int +__gthread_join (__gthread_t __threadid, void **__value_ptr) +{ + return __gthrw_(pthread_join) (__threadid, __value_ptr); +} + +static inline int +__gthread_detach (__gthread_t __threadid) +{ + return __gthrw_(pthread_detach) (__threadid); +} + +static inline int +__gthread_equal (__gthread_t __t1, __gthread_t __t2) +{ + return __gthrw_(pthread_equal) (__t1, __t2); +} + +static inline __gthread_t +__gthread_self (void) +{ + return __gthrw_(pthread_self) (); +} + +static inline int +__gthread_yield (void) +{ + return __gthrw_(sched_yield) (); +} + +static inline int +__gthread_once (__gthread_once_t *__once, void (*__func) (void)) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_once) (__once, __func); + else + return -1; +} + +static inline int +__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) +{ + return __gthrw_(pthread_key_create) (__key, __dtor); +} + +static inline int +__gthread_key_delete (__gthread_key_t __key) +{ + return __gthrw_(pthread_key_delete) (__key); +} + +static inline void * +__gthread_getspecific (__gthread_key_t __key) +{ + return __gthrw_(pthread_getspecific) (__key); +} + +static inline int +__gthread_setspecific (__gthread_key_t __key, const void *__ptr) +{ + return __gthrw_(pthread_setspecific) (__key, __ptr); +} + +static inline int +__gthread_mutex_destroy (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_destroy) (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_lock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_lock) (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_trylock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_trylock) (__mutex); + else + return 0; +} + +#if _GTHREAD_USE_MUTEX_TIMEDLOCK +static inline int +__gthread_mutex_timedlock (__gthread_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout); + else + return 0; +} +#endif + +static inline int +__gthread_mutex_unlock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_unlock) (__mutex); + else + return 0; +} + +#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP +static inline int +__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + { + pthread_mutexattr_t __attr; + int __r; + + __r = __gthrw_(pthread_mutexattr_init) (&__attr); + if (!__r) + __r = __gthrw_(pthread_mutexattr_settype) (&__attr, + PTHREAD_MUTEX_RECURSIVE); + if (!__r) + __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); + if (!__r) + __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); + return __r; + } + return 0; +} +#endif + +static inline int +__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_lock (__mutex); +} + +static inline int +__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_trylock (__mutex); +} + +#if _GTHREAD_USE_MUTEX_TIMEDLOCK +static inline int +__gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + return __gthread_mutex_timedlock (__mutex, __abs_timeout); +} +#endif + +static inline int +__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_unlock (__mutex); +} + +static inline int +__gthread_cond_broadcast (__gthread_cond_t *__cond) +{ + return __gthrw_(pthread_cond_broadcast) (__cond); +} + +static inline int +__gthread_cond_signal (__gthread_cond_t *__cond) +{ + return __gthrw_(pthread_cond_signal) (__cond); +} + +static inline int +__gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex) +{ + return __gthrw_(pthread_cond_wait) (__cond, __mutex); +} + +static inline int +__gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout); +} + +static inline int +__gthread_cond_wait_recursive (__gthread_cond_t *__cond, + __gthread_recursive_mutex_t *__mutex) +{ + return __gthread_cond_wait (__cond, __mutex); +} + +static inline int +__gthread_cond_timedwait_recursive (__gthread_cond_t *__cond, + __gthread_recursive_mutex_t *__mutex, + const __gthread_time_t *__abs_timeout) +{ + return __gthread_cond_timedwait (__cond, __mutex, __abs_timeout); +} + +static inline int +__gthread_cond_destroy (__gthread_cond_t* __cond) +{ + return __gthrw_(pthread_cond_destroy) (__cond); +} + +#endif /* _LIBOBJC */ + +#endif /* ! GCC_GTHR_POSIX_H */ diff --git a/libgcc/config/gthr-rtems.h b/libgcc/config/gthr-rtems.h new file mode 100644 index 00000000000..c5bd52292cf --- /dev/null +++ b/libgcc/config/gthr-rtems.h @@ -0,0 +1,157 @@ +/* RTEMS threads compatibility routines for libgcc2 and libobjc. + by: Rosimildo da Silva( rdasilva@connecttel.com ) */ +/* Compile this one with gcc. */ +/* Copyright (C) 1997, 1999, 2000, 2002, 2003, 2005, 2008, 2009 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +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 +. */ + +#ifndef GCC_GTHR_RTEMS_H +#define GCC_GTHR_RTEMS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define __GTHREADS 1 + +#define __GTHREAD_ONCE_INIT 0 +#define __GTHREAD_MUTEX_INIT_FUNCTION rtems_gxx_mutex_init +#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION rtems_gxx_recursive_mutex_init + +/* Avoid dependency on rtems specific headers. */ +typedef void *__gthread_key_t; +typedef int __gthread_once_t; +typedef void *__gthread_mutex_t; +typedef void *__gthread_recursive_mutex_t; + +/* + * External functions provided by RTEMS. They are very similar to their POSIX + * counterparts. A "Wrapper API" is being use to avoid dependency on any RTEMS + * header files. + */ + +/* generic per task variables */ +extern int rtems_gxx_once (__gthread_once_t *__once, void (*__func) (void)); +extern int rtems_gxx_key_create (__gthread_key_t *__key, void (*__dtor) (void *)); +extern int rtems_gxx_key_delete (__gthread_key_t __key); +extern void *rtems_gxx_getspecific (__gthread_key_t __key); +extern int rtems_gxx_setspecific (__gthread_key_t __key, const void *__ptr); + +/* mutex support */ +extern void rtems_gxx_mutex_init (__gthread_mutex_t *__mutex); +extern int rtems_gxx_mutex_destroy (__gthread_mutex_t *__mutex); +extern int rtems_gxx_mutex_lock (__gthread_mutex_t *__mutex); +extern int rtems_gxx_mutex_trylock (__gthread_mutex_t *__mutex); +extern int rtems_gxx_mutex_unlock (__gthread_mutex_t *__mutex); + +/* recursive mutex support */ +extern void rtems_gxx_recursive_mutex_init (__gthread_recursive_mutex_t *__mutex); +extern int rtems_gxx_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex); +extern int rtems_gxx_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex); +extern int rtems_gxx_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex); + +/* RTEMS threading is always active */ +static inline int +__gthread_active_p (void) +{ + return 1; +} + +/* Wrapper calls */ +static inline int +__gthread_once (__gthread_once_t *__once, void (*__func) (void)) +{ + return rtems_gxx_once( __once, __func ); +} + +static inline int +__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) +{ + return rtems_gxx_key_create( __key, __dtor ); +} + +static inline int +__gthread_key_delete (__gthread_key_t __key) +{ + return rtems_gxx_key_delete (__key); +} + +static inline void * +__gthread_getspecific (__gthread_key_t __key) +{ + return rtems_gxx_getspecific (__key); +} + +static inline int +__gthread_setspecific (__gthread_key_t __key, const void *__ptr) +{ + return rtems_gxx_setspecific (__key, __ptr); +} + +static inline int +__gthread_mutex_destroy (__gthread_mutex_t *__mutex) +{ + return rtems_gxx_mutex_destroy (__mutex); +} + +static inline int +__gthread_mutex_lock (__gthread_mutex_t *__mutex) +{ + return rtems_gxx_mutex_lock (__mutex); +} + +static inline int +__gthread_mutex_trylock (__gthread_mutex_t *__mutex) +{ + return rtems_gxx_mutex_trylock (__mutex); +} + +static inline int +__gthread_mutex_unlock (__gthread_mutex_t *__mutex) +{ + return rtems_gxx_mutex_unlock( __mutex ); +} + +static inline int +__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) +{ + return rtems_gxx_recursive_mutex_lock (__mutex); +} + +static inline int +__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) +{ + return rtems_gxx_recursive_mutex_trylock (__mutex); +} + +static inline int +__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) +{ + return rtems_gxx_recursive_mutex_unlock( __mutex ); +} + +#ifdef __cplusplus +} +#endif + +#endif /* ! GCC_GTHR_RTEMS_H */ diff --git a/libgcc/config/gthr-vxworks.h b/libgcc/config/gthr-vxworks.h new file mode 100644 index 00000000000..2346b528660 --- /dev/null +++ b/libgcc/config/gthr-vxworks.h @@ -0,0 +1,170 @@ +/* Threads compatibility routines for libgcc2 and libobjc for VxWorks. */ +/* Compile this one with gcc. */ +/* Copyright (C) 1997, 1999, 2000, 2008, 2009, 2011 + Free Software Foundation, Inc. + Contributed by Mike Stump . + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +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 +. */ + +#ifndef GCC_GTHR_VXWORKS_H +#define GCC_GTHR_VXWORKS_H + +#ifdef _LIBOBJC + +/* libobjc requires the optional pthreads component. */ +#include "config/gthr-posix.h" + +#else +#ifdef __cplusplus +#define UNUSED(x) +#else +#define UNUSED(x) x __attribute__((unused)) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define __GTHREADS 1 +#define __gthread_active_p() 1 + +/* Mutexes are easy, except that they need to be initialized at runtime. */ + +#include + +typedef SEM_ID __gthread_mutex_t; +/* All VxWorks mutexes are recursive. */ +typedef SEM_ID __gthread_recursive_mutex_t; +#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function +#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function + +static inline void +__gthread_mutex_init_function (__gthread_mutex_t *mutex) +{ + *mutex = semMCreate (SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE); +} + +static inline int +__gthread_mutex_destroy (__gthread_mutex_t * UNUSED(mutex)) +{ + return 0; +} + +static inline int +__gthread_mutex_lock (__gthread_mutex_t *mutex) +{ + return semTake (*mutex, WAIT_FOREVER); +} + +static inline int +__gthread_mutex_trylock (__gthread_mutex_t *mutex) +{ + return semTake (*mutex, NO_WAIT); +} + +static inline int +__gthread_mutex_unlock (__gthread_mutex_t *mutex) +{ + return semGive (*mutex); +} + +static inline void +__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex) +{ + __gthread_mutex_init_function (mutex); +} + +static inline int +__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex) +{ + return __gthread_mutex_lock (mutex); +} + +static inline int +__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex) +{ + return __gthread_mutex_trylock (mutex); +} + +static inline int +__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex) +{ + return __gthread_mutex_unlock (mutex); +} + +/* pthread_once is complicated enough that it's implemented + out-of-line. See config/vxlib.c. */ + +typedef struct +{ +#if !defined(__RTP__) +#if defined(__PPC__) + __attribute ((aligned (__alignof (unsigned)))) +#endif + volatile unsigned char busy; +#endif + volatile unsigned char done; +#if !defined(__RTP__) && defined(__PPC__) + /* PPC's test-and-set implementation requires a 4 byte aligned + object, of which it only sets the first byte. We use padding + here, in order to maintain some amount of backwards + compatibility. Without this padding, gthread_once objects worked + by accident because they happen to be static objects and the ppc + port automatically increased their alignment to 4 bytes. */ + unsigned char pad1; + unsigned char pad2; +#endif +} +__gthread_once_t; + +#if defined (__RTP__) +# define __GTHREAD_ONCE_INIT { 0 } +#elif defined (__PPC__) +# define __GTHREAD_ONCE_INIT { 0, 0, 0, 0 } +#else +# define __GTHREAD_ONCE_INIT { 0, 0 } +#endif + +extern int __gthread_once (__gthread_once_t *__once, void (*__func)(void)); + +/* Thread-specific data requires a great deal of effort, since VxWorks + is not really set up for it. See config/vxlib.c for the gory + details. All the TSD routines are sufficiently complex that they + need to be implemented out of line. */ + +typedef unsigned int __gthread_key_t; + +extern int __gthread_key_create (__gthread_key_t *__keyp, void (*__dtor)(void *)); +extern int __gthread_key_delete (__gthread_key_t __key); + +extern void *__gthread_getspecific (__gthread_key_t __key); +extern int __gthread_setspecific (__gthread_key_t __key, void *__ptr); + +#undef UNUSED + +#ifdef __cplusplus +} +#endif + +#endif /* not _LIBOBJC */ + +#endif /* gthr-vxworks.h */ diff --git a/libgcc/config/i386/gthr-win32.c b/libgcc/config/i386/gthr-win32.c index 46ecb0d4b26..ab1b69fd4cf 100644 --- a/libgcc/config/i386/gthr-win32.c +++ b/libgcc/config/i386/gthr-win32.c @@ -1,7 +1,8 @@ /* Implementation of W32-specific threads compatibility routines for libgcc2. */ -/* Copyright (C) 1999, 2000, 2002, 2004, 2008, 2009 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000, 2002, 2004, 2008, 2009, 2011 + Free Software Foundation, Inc. Contributed by Mumit Khan . Modified and moved to separate file by Danny Smith . @@ -33,7 +34,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #endif #undef __GTHREAD_I486_INLINE_LOCK_PRIMITIVES #define __GTHREAD_I486_INLINE_LOCK_PRIMITIVES -#include +#include "gthr-win32.h" /* Windows32 threads specific definitions. The windows32 threading model does not map well into pthread-inspired gcc's threading model, and so diff --git a/libgcc/config/i386/gthr-win32.h b/libgcc/config/i386/gthr-win32.h new file mode 100644 index 00000000000..53f8396cc81 --- /dev/null +++ b/libgcc/config/i386/gthr-win32.h @@ -0,0 +1,772 @@ +/* Threads compatibility routines for libgcc2 and libobjc. */ +/* Compile this one with gcc. */ + +/* Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2008, 2009 + Free Software Foundation, Inc. + Contributed by Mumit Khan . + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +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 +. */ + +#ifndef GCC_GTHR_WIN32_H +#define GCC_GTHR_WIN32_H + +/* Make sure CONST_CAST2 (origin in system.h) is declared. */ +#ifndef CONST_CAST2 +#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq) +#endif + +/* Windows32 threads specific definitions. The windows32 threading model + does not map well into pthread-inspired gcc's threading model, and so + there are caveats one needs to be aware of. + + 1. The destructor supplied to __gthread_key_create is ignored for + generic x86-win32 ports. This will certainly cause memory leaks + due to unreclaimed eh contexts (sizeof (eh_context) is at least + 24 bytes for x86 currently). + + This memory leak may be significant for long-running applications + that make heavy use of C++ EH. + + However, Mingw runtime (version 0.3 or newer) provides a mechanism + to emulate pthreads key dtors; the runtime provides a special DLL, + linked in if -mthreads option is specified, that runs the dtors in + the reverse order of registration when each thread exits. If + -mthreads option is not given, a stub is linked in instead of the + DLL, which results in memory leak. Other x86-win32 ports can use + the same technique of course to avoid the leak. + + 2. The error codes returned are non-POSIX like, and cast into ints. + This may cause incorrect error return due to truncation values on + hw where sizeof (DWORD) > sizeof (int). + + 3. We are currently using a special mutex instead of the Critical + Sections, since Win9x does not support TryEnterCriticalSection + (while NT does). + + The basic framework should work well enough. In the long term, GCC + needs to use Structured Exception Handling on Windows32. */ + +#define __GTHREADS 1 + +#include +#ifdef __MINGW32__ +#include <_mingw.h> +#endif + +#ifndef __UNUSED_PARAM +#define __UNUSED_PARAM(x) x +#endif + +#ifdef _LIBOBJC + +/* This is necessary to prevent windef.h (included from windows.h) from + defining its own BOOL as a typedef. */ +#ifndef __OBJC__ +#define __OBJC__ +#endif +#include +/* Now undef the windows BOOL. */ +#undef BOOL + +/* Key structure for maintaining thread specific storage */ +static DWORD __gthread_objc_data_tls = (DWORD) -1; + +/* Backend initialization functions */ + +/* Initialize the threads subsystem. */ +int +__gthread_objc_init_thread_system (void) +{ + /* Initialize the thread storage key. */ + if ((__gthread_objc_data_tls = TlsAlloc ()) != (DWORD) -1) + return 0; + else + return -1; +} + +/* Close the threads subsystem. */ +int +__gthread_objc_close_thread_system (void) +{ + if (__gthread_objc_data_tls != (DWORD) -1) + TlsFree (__gthread_objc_data_tls); + return 0; +} + +/* Backend thread functions */ + +/* Create a new thread of execution. */ +objc_thread_t +__gthread_objc_thread_detach (void (*func)(void *arg), void *arg) +{ + DWORD thread_id = 0; + HANDLE win32_handle; + + if (!(win32_handle = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) func, + arg, 0, &thread_id))) + thread_id = 0; + + return (objc_thread_t) (INT_PTR) thread_id; +} + +/* Set the current thread's priority. */ +int +__gthread_objc_thread_set_priority (int priority) +{ + int sys_priority = 0; + + switch (priority) + { + case OBJC_THREAD_INTERACTIVE_PRIORITY: + sys_priority = THREAD_PRIORITY_NORMAL; + break; + default: + case OBJC_THREAD_BACKGROUND_PRIORITY: + sys_priority = THREAD_PRIORITY_BELOW_NORMAL; + break; + case OBJC_THREAD_LOW_PRIORITY: + sys_priority = THREAD_PRIORITY_LOWEST; + break; + } + + /* Change priority */ + if (SetThreadPriority (GetCurrentThread (), sys_priority)) + return 0; + else + return -1; +} + +/* Return the current thread's priority. */ +int +__gthread_objc_thread_get_priority (void) +{ + int sys_priority; + + sys_priority = GetThreadPriority (GetCurrentThread ()); + + switch (sys_priority) + { + case THREAD_PRIORITY_HIGHEST: + case THREAD_PRIORITY_TIME_CRITICAL: + case THREAD_PRIORITY_ABOVE_NORMAL: + case THREAD_PRIORITY_NORMAL: + return OBJC_THREAD_INTERACTIVE_PRIORITY; + + default: + case THREAD_PRIORITY_BELOW_NORMAL: + return OBJC_THREAD_BACKGROUND_PRIORITY; + + case THREAD_PRIORITY_IDLE: + case THREAD_PRIORITY_LOWEST: + return OBJC_THREAD_LOW_PRIORITY; + } + + /* Couldn't get priority. */ + return -1; +} + +/* Yield our process time to another thread. */ +void +__gthread_objc_thread_yield (void) +{ + Sleep (0); +} + +/* Terminate the current thread. */ +int +__gthread_objc_thread_exit (void) +{ + /* exit the thread */ + ExitThread (__objc_thread_exit_status); + + /* Failed if we reached here */ + return -1; +} + +/* Returns an integer value which uniquely describes a thread. */ +objc_thread_t +__gthread_objc_thread_id (void) +{ + return (objc_thread_t) (INT_PTR) GetCurrentThreadId (); +} + +/* Sets the thread's local storage pointer. */ +int +__gthread_objc_thread_set_data (void *value) +{ + if (TlsSetValue (__gthread_objc_data_tls, value)) + return 0; + else + return -1; +} + +/* Returns the thread's local storage pointer. */ +void * +__gthread_objc_thread_get_data (void) +{ + DWORD lasterror; + void *ptr; + + lasterror = GetLastError (); + + ptr = TlsGetValue (__gthread_objc_data_tls); /* Return thread data. */ + + SetLastError (lasterror); + + return ptr; +} + +/* Backend mutex functions */ + +/* Allocate a mutex. */ +int +__gthread_objc_mutex_allocate (objc_mutex_t mutex) +{ + if ((mutex->backend = (void *) CreateMutex (NULL, 0, NULL)) == NULL) + return -1; + else + return 0; +} + +/* Deallocate a mutex. */ +int +__gthread_objc_mutex_deallocate (objc_mutex_t mutex) +{ + CloseHandle ((HANDLE) (mutex->backend)); + return 0; +} + +/* Grab a lock on a mutex. */ +int +__gthread_objc_mutex_lock (objc_mutex_t mutex) +{ + int status; + + status = WaitForSingleObject ((HANDLE) (mutex->backend), INFINITE); + if (status != WAIT_OBJECT_0 && status != WAIT_ABANDONED) + return -1; + else + return 0; +} + +/* Try to grab a lock on a mutex. */ +int +__gthread_objc_mutex_trylock (objc_mutex_t mutex) +{ + int status; + + status = WaitForSingleObject ((HANDLE) (mutex->backend), 0); + if (status != WAIT_OBJECT_0 && status != WAIT_ABANDONED) + return -1; + else + return 0; +} + +/* Unlock the mutex */ +int +__gthread_objc_mutex_unlock (objc_mutex_t mutex) +{ + if (ReleaseMutex ((HANDLE) (mutex->backend)) == 0) + return -1; + else + return 0; +} + +/* Backend condition mutex functions */ + +/* Allocate a condition. */ +int +__gthread_objc_condition_allocate (objc_condition_t __UNUSED_PARAM(condition)) +{ + /* Unimplemented. */ + return -1; +} + +/* Deallocate a condition. */ +int +__gthread_objc_condition_deallocate (objc_condition_t __UNUSED_PARAM(condition)) +{ + /* Unimplemented. */ + return -1; +} + +/* Wait on the condition */ +int +__gthread_objc_condition_wait (objc_condition_t __UNUSED_PARAM(condition), + objc_mutex_t __UNUSED_PARAM(mutex)) +{ + /* Unimplemented. */ + return -1; +} + +/* Wake up all threads waiting on this condition. */ +int +__gthread_objc_condition_broadcast (objc_condition_t __UNUSED_PARAM(condition)) +{ + /* Unimplemented. */ + return -1; +} + +/* Wake up one thread waiting on this condition. */ +int +__gthread_objc_condition_signal (objc_condition_t __UNUSED_PARAM(condition)) +{ + /* Unimplemented. */ + return -1; +} + +#else /* _LIBOBJC */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned long __gthread_key_t; + +typedef struct { + int done; + long started; +} __gthread_once_t; + +typedef struct { + long counter; + void *sema; +} __gthread_mutex_t; + +typedef struct { + long counter; + long depth; + unsigned long owner; + void *sema; +} __gthread_recursive_mutex_t; + +#define __GTHREAD_ONCE_INIT {0, -1} +#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function +#define __GTHREAD_MUTEX_INIT_DEFAULT {-1, 0} +#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION \ + __gthread_recursive_mutex_init_function +#define __GTHREAD_RECURSIVE_MUTEX_INIT_DEFAULT {-1, 0, 0, 0} + +#if defined (_WIN32) && !defined(__CYGWIN__) +#define MINGW32_SUPPORTS_MT_EH 1 +/* Mingw runtime >= v0.3 provides a magic variable that is set to nonzero + if -mthreads option was specified, or 0 otherwise. This is to get around + the lack of weak symbols in PE-COFF. */ +extern int _CRT_MT; +extern int __mingwthr_key_dtor (unsigned long, void (*) (void *)); +#endif /* _WIN32 && !__CYGWIN__ */ + +/* The Windows95 kernel does not export InterlockedCompareExchange. + This provides a substitute. When building apps that reference + gthread_mutex_try_lock, the __GTHREAD_I486_INLINE_LOCK_PRIMITIVES + macro must be defined if Windows95 is a target. Currently + gthread_mutex_try_lock is not referenced by libgcc or libstdc++. */ +#ifdef __GTHREAD_I486_INLINE_LOCK_PRIMITIVES +static inline long +__gthr_i486_lock_cmp_xchg(long *__dest, long __xchg, long __comperand) +{ + long result; + __asm__ __volatile__ ("\n\ + lock\n\ + cmpxchg{l} {%4, %1|%1, %4}\n" + : "=a" (result), "=m" (*__dest) + : "0" (__comperand), "m" (*__dest), "r" (__xchg) + : "cc"); + return result; +} +#define __GTHR_W32_InterlockedCompareExchange __gthr_i486_lock_cmp_xchg +#else /* __GTHREAD_I486_INLINE_LOCK_PRIMITIVES */ +#define __GTHR_W32_InterlockedCompareExchange InterlockedCompareExchange +#endif /* __GTHREAD_I486_INLINE_LOCK_PRIMITIVES */ + +static inline int +__gthread_active_p (void) +{ +#ifdef MINGW32_SUPPORTS_MT_EH + return _CRT_MT; +#else + return 1; +#endif +} + +#if __GTHREAD_HIDE_WIN32API + +/* The implementations are in config/i386/gthr-win32.c in libgcc.a. + Only stubs are exposed to avoid polluting the C++ namespace with + windows api definitions. */ + +extern int __gthr_win32_once (__gthread_once_t *, void (*) (void)); +extern int __gthr_win32_key_create (__gthread_key_t *, void (*) (void*)); +extern int __gthr_win32_key_delete (__gthread_key_t); +extern void * __gthr_win32_getspecific (__gthread_key_t); +extern int __gthr_win32_setspecific (__gthread_key_t, const void *); +extern void __gthr_win32_mutex_init_function (__gthread_mutex_t *); +extern int __gthr_win32_mutex_lock (__gthread_mutex_t *); +extern int __gthr_win32_mutex_trylock (__gthread_mutex_t *); +extern int __gthr_win32_mutex_unlock (__gthread_mutex_t *); +extern void + __gthr_win32_recursive_mutex_init_function (__gthread_recursive_mutex_t *); +extern int __gthr_win32_recursive_mutex_lock (__gthread_recursive_mutex_t *); +extern int + __gthr_win32_recursive_mutex_trylock (__gthread_recursive_mutex_t *); +extern int __gthr_win32_recursive_mutex_unlock (__gthread_recursive_mutex_t *); +extern void __gthr_win32_mutex_destroy (__gthread_mutex_t *); + +static inline int +__gthread_once (__gthread_once_t *__once, void (*__func) (void)) +{ + if (__gthread_active_p ()) + return __gthr_win32_once (__once, __func); + else + return -1; +} + +static inline int +__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) +{ + return __gthr_win32_key_create (__key, __dtor); +} + +static inline int +__gthread_key_delete (__gthread_key_t __key) +{ + return __gthr_win32_key_delete (__key); +} + +static inline void * +__gthread_getspecific (__gthread_key_t __key) +{ + return __gthr_win32_getspecific (__key); +} + +static inline int +__gthread_setspecific (__gthread_key_t __key, const void *__ptr) +{ + return __gthr_win32_setspecific (__key, __ptr); +} + +static inline void +__gthread_mutex_init_function (__gthread_mutex_t *__mutex) +{ + __gthr_win32_mutex_init_function (__mutex); +} + +static inline void +__gthread_mutex_destroy (__gthread_mutex_t *__mutex) +{ + __gthr_win32_mutex_destroy (__mutex); +} + +static inline int +__gthread_mutex_lock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthr_win32_mutex_lock (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_trylock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthr_win32_mutex_trylock (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_unlock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthr_win32_mutex_unlock (__mutex); + else + return 0; +} + +static inline void +__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) +{ + __gthr_win32_recursive_mutex_init_function (__mutex); +} + +static inline int +__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthr_win32_recursive_mutex_lock (__mutex); + else + return 0; +} + +static inline int +__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthr_win32_recursive_mutex_trylock (__mutex); + else + return 0; +} + +static inline int +__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthr_win32_recursive_mutex_unlock (__mutex); + else + return 0; +} + +#else /* ! __GTHREAD_HIDE_WIN32API */ + +#include +#include + +static inline int +__gthread_once (__gthread_once_t *__once, void (*__func) (void)) +{ + if (! __gthread_active_p ()) + return -1; + else if (__once == NULL || __func == NULL) + return EINVAL; + + if (! __once->done) + { + if (InterlockedIncrement (&(__once->started)) == 0) + { + (*__func) (); + __once->done = TRUE; + } + else + { + /* Another thread is currently executing the code, so wait for it + to finish; yield the CPU in the meantime. If performance + does become an issue, the solution is to use an Event that + we wait on here (and set above), but that implies a place to + create the event before this routine is called. */ + while (! __once->done) + Sleep (0); + } + } + + return 0; +} + +/* Windows32 thread local keys don't support destructors; this leads to + leaks, especially in threaded applications making extensive use of + C++ EH. Mingw uses a thread-support DLL to work-around this problem. */ +static inline int +__gthread_key_create (__gthread_key_t *__key, + void (*__dtor) (void *) __attribute__((unused))) +{ + int __status = 0; + DWORD __tls_index = TlsAlloc (); + if (__tls_index != 0xFFFFFFFF) + { + *__key = __tls_index; +#ifdef MINGW32_SUPPORTS_MT_EH + /* Mingw runtime will run the dtors in reverse order for each thread + when the thread exits. */ + __status = __mingwthr_key_dtor (*__key, __dtor); +#endif + } + else + __status = (int) GetLastError (); + return __status; +} + +static inline int +__gthread_key_delete (__gthread_key_t __key) +{ + return (TlsFree (__key) != 0) ? 0 : (int) GetLastError (); +} + +static inline void * +__gthread_getspecific (__gthread_key_t __key) +{ + DWORD __lasterror; + void *__ptr; + + __lasterror = GetLastError (); + + __ptr = TlsGetValue (__key); + + SetLastError (__lasterror); + + return __ptr; +} + +static inline int +__gthread_setspecific (__gthread_key_t __key, const void *__ptr) +{ + if (TlsSetValue (__key, CONST_CAST2(void *, const void *, __ptr)) != 0) + return 0; + else + return GetLastError (); +} + +static inline void +__gthread_mutex_init_function (__gthread_mutex_t *__mutex) +{ + __mutex->counter = -1; + __mutex->sema = CreateSemaphore (NULL, 0, 65535, NULL); +} + +static inline void +__gthread_mutex_destroy (__gthread_mutex_t *__mutex) +{ + CloseHandle ((HANDLE) __mutex->sema); +} + +static inline int +__gthread_mutex_lock (__gthread_mutex_t *__mutex) +{ + int __status = 0; + + if (__gthread_active_p ()) + { + if (InterlockedIncrement (&__mutex->counter) == 0 || + WaitForSingleObject (__mutex->sema, INFINITE) == WAIT_OBJECT_0) + __status = 0; + else + { + /* WaitForSingleObject returns WAIT_FAILED, and we can only do + some best-effort cleanup here. */ + InterlockedDecrement (&__mutex->counter); + __status = 1; + } + } + return __status; +} + +static inline int +__gthread_mutex_trylock (__gthread_mutex_t *__mutex) +{ + int __status = 0; + + if (__gthread_active_p ()) + { + if (__GTHR_W32_InterlockedCompareExchange (&__mutex->counter, 0, -1) < 0) + __status = 0; + else + __status = 1; + } + return __status; +} + +static inline int +__gthread_mutex_unlock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + { + if (InterlockedDecrement (&__mutex->counter) >= 0) + return ReleaseSemaphore (__mutex->sema, 1, NULL) ? 0 : 1; + } + return 0; +} + +static inline void +__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) +{ + __mutex->counter = -1; + __mutex->depth = 0; + __mutex->owner = 0; + __mutex->sema = CreateSemaphore (NULL, 0, 65535, NULL); +} + +static inline int +__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + { + DWORD __me = GetCurrentThreadId(); + if (InterlockedIncrement (&__mutex->counter) == 0) + { + __mutex->depth = 1; + __mutex->owner = __me; + } + else if (__mutex->owner == __me) + { + InterlockedDecrement (&__mutex->counter); + ++(__mutex->depth); + } + else if (WaitForSingleObject (__mutex->sema, INFINITE) == WAIT_OBJECT_0) + { + __mutex->depth = 1; + __mutex->owner = __me; + } + else + { + /* WaitForSingleObject returns WAIT_FAILED, and we can only do + some best-effort cleanup here. */ + InterlockedDecrement (&__mutex->counter); + return 1; + } + } + return 0; +} + +static inline int +__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + { + DWORD __me = GetCurrentThreadId(); + if (__GTHR_W32_InterlockedCompareExchange (&__mutex->counter, 0, -1) < 0) + { + __mutex->depth = 1; + __mutex->owner = __me; + } + else if (__mutex->owner == __me) + ++(__mutex->depth); + else + return 1; + } + return 0; +} + +static inline int +__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + { + --(__mutex->depth); + if (__mutex->depth == 0) + { + __mutex->owner = 0; + + if (InterlockedDecrement (&__mutex->counter) >= 0) + return ReleaseSemaphore (__mutex->sema, 1, NULL) ? 0 : 1; + } + } + return 0; +} + +#endif /* __GTHREAD_HIDE_WIN32API */ + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBOBJC */ + +#endif /* ! GCC_GTHR_WIN32_H */ diff --git a/libgcc/config/mips/gthr-mipssde.h b/libgcc/config/mips/gthr-mipssde.h new file mode 100644 index 00000000000..34f9b6cf54b --- /dev/null +++ b/libgcc/config/mips/gthr-mipssde.h @@ -0,0 +1,230 @@ +/* MIPS SDE threads compatibility routines for libgcc2 and libobjc. */ +/* Compile this one with gcc. */ +/* Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc. + Contributed by Nigel Stephens + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +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 +. */ + +#ifndef GCC_GTHR_MIPSSDE_H +#define GCC_GTHR_MIPSSDE_H + +/* MIPS SDE threading API specific definitions. + Easy, since the interface is pretty much one-to-one. */ + +#define __GTHREADS 1 + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef __sdethread_key_t __gthread_key_t; +typedef __sdethread_once_t __gthread_once_t; +typedef __sdethread_mutex_t __gthread_mutex_t; + +typedef struct { + long depth; + __sdethread_t owner; + __sdethread_mutex_t actual; +} __gthread_recursive_mutex_t; + +#define __GTHREAD_MUTEX_INIT __SDETHREAD_MUTEX_INITIALIZER("gthr") +#define __GTHREAD_ONCE_INIT __SDETHREAD_ONCE_INIT +static inline int +__gthread_recursive_mutex_init_function(__gthread_recursive_mutex_t *__mutex); +#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function + +#if SUPPORTS_WEAK && GTHREAD_USE_WEAK +# define __gthrw(name) \ + static __typeof(name) __gthrw_ ## name __attribute__ ((__weakref__(#name))); +# define __gthrw_(name) __gthrw_ ## name +#else +# define __gthrw(name) +# define __gthrw_(name) name +#endif + +__gthrw(__sdethread_once) +__gthrw(__sdethread_key_create) +__gthrw(__sdethread_key_delete) +__gthrw(__sdethread_getspecific) +__gthrw(__sdethread_setspecific) + +__gthrw(__sdethread_self) + +__gthrw(__sdethread_mutex_lock) +__gthrw(__sdethread_mutex_trylock) +__gthrw(__sdethread_mutex_unlock) + +__gthrw(__sdethread_mutex_init) + +__gthrw(__sdethread_threading) + +#if SUPPORTS_WEAK && GTHREAD_USE_WEAK + +static inline int +__gthread_active_p (void) +{ + return !!(void *)&__sdethread_threading; +} + +#else /* not SUPPORTS_WEAK */ + +static inline int +__gthread_active_p (void) +{ + return 1; +} + +#endif /* SUPPORTS_WEAK */ + +static inline int +__gthread_once (__gthread_once_t *__once, void (*__func) (void)) +{ + if (__gthread_active_p ()) + return __gthrw_(__sdethread_once) (__once, __func); + else + return -1; +} + +static inline int +__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) +{ + return __gthrw_(__sdethread_key_create) (__key, __dtor); +} + +static inline int +__gthread_key_delete (__gthread_key_t __key) +{ + return __gthrw_(__sdethread_key_delete) (__key); +} + +static inline void * +__gthread_getspecific (__gthread_key_t __key) +{ + return __gthrw_(__sdethread_getspecific) (__key); +} + +static inline int +__gthread_setspecific (__gthread_key_t __key, const void *__ptr) +{ + return __gthrw_(__sdethread_setspecific) (__key, __ptr); +} + +static inline int +__gthread_mutex_destroy (__gthread_mutex_t * UNUSED(__mutex)) +{ + return 0; +} + +static inline int +__gthread_mutex_lock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(__sdethread_mutex_lock) (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_trylock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(__sdethread_mutex_trylock) (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_unlock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(__sdethread_mutex_unlock) (__mutex); + else + return 0; +} + +static inline int +__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) +{ + __mutex->depth = 0; + __mutex->owner = __gthrw_(__sdethread_self) (); + return __gthrw_(__sdethread_mutex_init) (&__mutex->actual, NULL); +} + +static inline int +__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + { + __sdethread_t __me = __gthrw_(__sdethread_self) (); + + if (__mutex->owner != __me) + { + __gthrw_(__sdethread_mutex_lock) (&__mutex->actual); + __mutex->owner = __me; + } + + __mutex->depth++; + } + return 0; +} + +static inline int +__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + { + __sdethread_t __me = __gthrw_(__sdethread_self) (); + + if (__mutex->owner != __me) + { + if (__gthrw_(__sdethread_mutex_trylock) (&__mutex->actual)) + return 1; + __mutex->owner = __me; + } + + __mutex->depth++; + } + return 0; +} + +static inline int +__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + { + if (--__mutex->depth == 0) + { + __mutex->owner = (__sdethread_t) 0; + __gthrw_(__sdethread_mutex_unlock) (&__mutex->actual); + } + } + return 0; +} + +#ifdef __cplusplus +} +#endif + +#endif /* ! GCC_GTHR_MIPSSDE_H */ diff --git a/libgcc/config/pa/gthr-dce.h b/libgcc/config/pa/gthr-dce.h new file mode 100644 index 00000000000..d32155a9352 --- /dev/null +++ b/libgcc/config/pa/gthr-dce.h @@ -0,0 +1,563 @@ +/* Threads compatibility routines for libgcc2 and libobjc. */ +/* Compile this one with gcc. */ +/* Copyright (C) 1997, 1999, 2000, 2001, 2004, 2005, 2008, 2009 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +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 +. */ + +#ifndef GCC_GTHR_DCE_H +#define GCC_GTHR_DCE_H + +/* If _DCE_THREADS is not defined, then we're building the single + threaded version of the libraries and do not want to reference + anything related to pthreads or dce. */ +#ifndef _DCE_THREADS +#include "gthr-single.h" +#else +/* DCE threads interface. + DCE threads are based on POSIX threads draft 4, and many things + have changed since then. */ + +/* Make sure CONST_CAST2 (original in system.h) is defined. */ +#ifndef CONST_CAST2 +#ifdef __cplusplus +#define CONST_CAST2(TOTYPE,FROMTYPE,X) (const_cast (X)) +#else +#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq) +#endif +#endif + +#define __GTHREADS 1 + +#include + +typedef pthread_key_t __gthread_key_t; +typedef pthread_once_t __gthread_once_t; +typedef pthread_mutex_t __gthread_mutex_t; +typedef pthread_mutex_t __gthread_recursive_mutex_t; + +#define __GTHREAD_ONCE_INIT pthread_once_init + +#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function +#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function + +#define __GTHREAD_MUTEX_INIT_DEFAULT pthread_once_init + +#if SUPPORTS_WEAK && GTHREAD_USE_WEAK +# define __gthrw(name) \ + static __typeof(name) __gthrw_ ## name __attribute__ ((__weakref__(#name))); +# define __gthrw_(name) __gthrw_ ## name +#else +# define __gthrw(name) +# define __gthrw_(name) name +#endif + +__gthrw(pthread_once) +__gthrw(pthread_keycreate) +__gthrw(pthread_getspecific) +__gthrw(pthread_setspecific) +__gthrw(pthread_create) +__gthrw(pthread_mutex_init) +__gthrw(pthread_mutex_destroy) +__gthrw(pthread_mutex_lock) +__gthrw(pthread_mutex_trylock) +__gthrw(pthread_mutex_unlock) +__gthrw(pthread_mutexattr_create) +__gthrw(pthread_mutexattr_setkind_np) +__gthrw(pthread_mutexattr_delete) + +#ifdef _LIBOBJC +/* Objective-C. */ +__gthrw(pthread_cond_broadcast) +__gthrw(pthread_cond_destroy) +__gthrw(pthread_cond_init) +__gthrw(pthread_cond_signal) +__gthrw(pthread_cond_wait) +__gthrw(pthread_exit) + +#ifdef pthread_getunique_np +# define __gthrw_pthread_getunique_np pthread_getunique_np +#else +__gthrw(pthread_getunique_np) +# define __gthrw_pthread_getunique_np __gthrw_(pthread_getunique_np) +#endif + +__gthrw(pthread_mutex_destroy) +__gthrw(pthread_self) +__gthrw(pthread_yield) +#endif + +#if SUPPORTS_WEAK && GTHREAD_USE_WEAK + +static inline int +__gthread_active_p (void) +{ + static void *const __gthread_active_ptr = (void *) &__gthrw_(pthread_create); + return __gthread_active_ptr != 0; +} + +#else /* not SUPPORTS_WEAK */ + +static inline int +__gthread_active_p (void) +{ + return 1; +} + +#endif /* SUPPORTS_WEAK */ + +#ifdef _LIBOBJC + +/* Key structure for maintaining thread specific storage */ +static pthread_key_t _objc_thread_storage; + +/* Thread local storage for a single thread */ +static void *thread_local_storage = NULL; + +/* Backend initialization functions */ + +/* Initialize the threads subsystem. */ +static inline int +__gthread_objc_init_thread_system (void) +{ + if (__gthread_active_p ()) + /* Initialize the thread storage key. */ + return __gthrw_(pthread_keycreate) (&_objc_thread_storage, NULL); + else + return -1; +} + +/* Close the threads subsystem. */ +static inline int +__gthread_objc_close_thread_system (void) +{ + if (__gthread_active_p ()) + return 0; + else + return -1; +} + +/* Backend thread functions */ + +/* Create a new thread of execution. */ +static inline objc_thread_t +__gthread_objc_thread_detach (void (*func)(void *), void *arg) +{ + objc_thread_t thread_id; + pthread_t new_thread_handle; + + if (!__gthread_active_p ()) + return NULL; + + if (!(__gthrw_(pthread_create) (&new_thread_handle, pthread_attr_default, + (void *) func, arg))) + { + /* ??? May not work! (64bit) */ + thread_id = *(objc_thread_t *) &new_thread_handle; + pthread_detach (&new_thread_handle); /* Fully detach thread. */ + } + else + thread_id = NULL; + + return thread_id; +} + +/* Set the current thread's priority. */ +static inline int +__gthread_objc_thread_set_priority (int priority) +{ + int sys_priority = 0; + + if (!__gthread_active_p ()) + return -1; + + switch (priority) + { + case OBJC_THREAD_INTERACTIVE_PRIORITY: + sys_priority = (PRI_FG_MIN_NP + PRI_FG_MAX_NP) / 2; + break; + default: + case OBJC_THREAD_BACKGROUND_PRIORITY: + sys_priority = (PRI_BG_MIN_NP + PRI_BG_MAX_NP) / 2; + break; + case OBJC_THREAD_LOW_PRIORITY: + sys_priority = (PRI_BG_MIN_NP + PRI_BG_MAX_NP) / 2; + break; + } + + /* Change the priority. */ + if (pthread_setprio (__gthrw_(pthread_self) (), sys_priority) >= 0) + return 0; + else + /* Failed */ + return -1; +} + +/* Return the current thread's priority. */ +static inline int +__gthread_objc_thread_get_priority (void) +{ + int sys_priority; + + if (__gthread_active_p ()) + { + if ((sys_priority = pthread_getprio (__gthrw_(pthread_self) ())) >= 0) + { + if (sys_priority >= PRI_FG_MIN_NP + && sys_priority <= PRI_FG_MAX_NP) + return OBJC_THREAD_INTERACTIVE_PRIORITY; + if (sys_priority >= PRI_BG_MIN_NP + && sys_priority <= PRI_BG_MAX_NP) + return OBJC_THREAD_BACKGROUND_PRIORITY; + return OBJC_THREAD_LOW_PRIORITY; + } + + /* Failed */ + return -1; + } + else + return OBJC_THREAD_INTERACTIVE_PRIORITY; +} + +/* Yield our process time to another thread. */ +static inline void +__gthread_objc_thread_yield (void) +{ + if (__gthread_active_p ()) + __gthrw_(pthread_yield) (); +} + +/* Terminate the current thread. */ +static inline int +__gthread_objc_thread_exit (void) +{ + if (__gthread_active_p ()) + /* exit the thread */ + __gthrw_(pthread_exit) (&__objc_thread_exit_status); + + /* Failed if we reached here */ + return -1; +} + +/* Returns an integer value which uniquely describes a thread. */ +static inline objc_thread_t +__gthread_objc_thread_id (void) +{ + if (__gthread_active_p ()) + { + pthread_t self = __gthrw_(pthread_self) (); + + return (objc_thread_t) __gthrw_pthread_getunique_np (&self); + } + else + return (objc_thread_t) 1; +} + +/* Sets the thread's local storage pointer. */ +static inline int +__gthread_objc_thread_set_data (void *value) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_setspecific) (_objc_thread_storage, value); + else + { + thread_local_storage = value; + return 0; + } +} + +/* Returns the thread's local storage pointer. */ +static inline void * +__gthread_objc_thread_get_data (void) +{ + void *value = NULL; + + if (__gthread_active_p ()) + { + if (!(__gthrw_(pthread_getspecific) (_objc_thread_storage, &value))) + return value; + + return NULL; + } + else + return thread_local_storage; +} + +/* Backend mutex functions */ + +/* Allocate a mutex. */ +static inline int +__gthread_objc_mutex_allocate (objc_mutex_t mutex) +{ + if (__gthread_active_p ()) + { + mutex->backend = objc_malloc (sizeof (pthread_mutex_t)); + + if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, + pthread_mutexattr_default)) + { + objc_free (mutex->backend); + mutex->backend = NULL; + return -1; + } + } + + return 0; +} + +/* Deallocate a mutex. */ +static inline int +__gthread_objc_mutex_deallocate (objc_mutex_t mutex) +{ + if (__gthread_active_p ()) + { + if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend)) + return -1; + + objc_free (mutex->backend); + mutex->backend = NULL; + } + + return 0; +} + +/* Grab a lock on a mutex. */ +static inline int +__gthread_objc_mutex_lock (objc_mutex_t mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend); + else + return 0; +} + +/* Try to grab a lock on a mutex. */ +static inline int +__gthread_objc_mutex_trylock (objc_mutex_t mutex) +{ + if (__gthread_active_p () + && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 1) + return -1; + + return 0; +} + +/* Unlock the mutex */ +static inline int +__gthread_objc_mutex_unlock (objc_mutex_t mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend); + else + return 0; +} + +/* Backend condition mutex functions */ + +/* Allocate a condition. */ +static inline int +__gthread_objc_condition_allocate (objc_condition_t condition + __attribute__ ((__unused__))) +{ + if (__gthread_active_p ()) + /* Unimplemented. */ + return -1; + else + return 0; +} + +/* Deallocate a condition. */ +static inline int +__gthread_objc_condition_deallocate (objc_condition_t condition + __attribute__ ((__unused__))) +{ + if (__gthread_active_p ()) + /* Unimplemented. */ + return -1; + else + return 0; +} + +/* Wait on the condition */ +static inline int +__gthread_objc_condition_wait (objc_condition_t condition + __attribute__ ((__unused__)), + objc_mutex_t mutex __attribute__ ((__unused__))) +{ + if (__gthread_active_p ()) + /* Unimplemented. */ + return -1; + else + return 0; +} + +/* Wake up all threads waiting on this condition. */ +static inline int +__gthread_objc_condition_broadcast (objc_condition_t condition + __attribute__ ((__unused__))) +{ + if (__gthread_active_p ()) + /* Unimplemented. */ + return -1; + else + return 0; +} + +/* Wake up one thread waiting on this condition. */ +static inline int +__gthread_objc_condition_signal (objc_condition_t condition + __attribute__ ((__unused__))) +{ + if (__gthread_active_p ()) + /* Unimplemented. */ + return -1; + else + return 0; +} + +#else /* _LIBOBJC */ + +static inline int +__gthread_once (__gthread_once_t *__once, void (*__func) (void)) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_once) (__once, __func); + else + return -1; +} + +static inline int +__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) +{ + return __gthrw_(pthread_keycreate) (__key, __dtor); +} + +static inline int +__gthread_key_delete (__gthread_key_t __key __attribute__ ((__unused__))) +{ + /* Operation is not supported. */ + return -1; +} + +static inline void * +__gthread_getspecific (__gthread_key_t __key) +{ + void *__ptr; + if (__gthrw_(pthread_getspecific) (__key, &__ptr) == 0) + return __ptr; + else + return 0; +} + +static inline int +__gthread_setspecific (__gthread_key_t __key, const void *__ptr) +{ + return __gthrw_(pthread_setspecific) + (__key, CONST_CAST2(void *, const void *, __ptr)); +} + +static inline void +__gthread_mutex_init_function (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + __gthrw_(pthread_mutex_init) (__mutex, pthread_mutexattr_default); +} + +static inline int +__gthread_mutex_destroy (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_destroy) (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_lock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_lock) (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_trylock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_trylock) (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_unlock (__gthread_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + return __gthrw_(pthread_mutex_unlock) (__mutex); + else + return 0; +} + +static inline int +__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) +{ + if (__gthread_active_p ()) + { + pthread_mutexattr_t __attr; + int __r; + + __r = __gthrw_(pthread_mutexattr_create) (&__attr); + if (!__r) + __r = __gthrw_(pthread_mutexattr_setkind_np) (&__attr, + MUTEX_RECURSIVE_NP); + if (!__r) + __r = __gthrw_(pthread_mutex_init) (__mutex, __attr); + if (!__r) + __r = __gthrw_(pthread_mutexattr_delete) (&__attr); + return __r; + } + return 0; +} + +static inline int +__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_lock (__mutex); +} + +static inline int +__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_trylock (__mutex); +} + +static inline int +__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_unlock (__mutex); +} + +#endif /* _LIBOBJC */ + +#endif +#endif /* ! GCC_GTHR_DCE_H */ diff --git a/libgcc/config/rs6000/gthr-aix.h b/libgcc/config/rs6000/gthr-aix.h new file mode 100644 index 00000000000..342f09187f0 --- /dev/null +++ b/libgcc/config/rs6000/gthr-aix.h @@ -0,0 +1,35 @@ +/* Threads compatibility routines for libgcc2 and libobjc. */ +/* Compile this one with gcc. */ +/* Copyright (C) 2000, 2009, 2011 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +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 +. */ + +#ifndef GCC_GTHR_AIX_H +#define GCC_GTHR_AIX_H + +#ifdef _THREAD_SAFE +#include "config/gthr-posix.h" +#else +#include "gthr-single.h" +#endif + +#endif /* GCC_GTHR_AIX_H */ diff --git a/libgcc/config/s390/gthr-tpf.h b/libgcc/config/s390/gthr-tpf.h new file mode 100644 index 00000000000..fb23e91cfcd --- /dev/null +++ b/libgcc/config/s390/gthr-tpf.h @@ -0,0 +1,229 @@ +/* Threads compatibility routines for libgcc2 and libobjc. + Compile this one with gcc. + Copyright (C) 2004, 2005, 2008, 2009 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +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 +. */ + +/* TPF needs its own version of gthr-*.h because TPF always links to + the thread library. However, for performance reasons we still do not + want to issue thread api calls unless a check is made to see that we + are running as a thread. */ + +#ifndef GCC_GTHR_TPF_H +#define GCC_GTHR_TPF_H + +/* POSIX threads specific definitions. + Easy, since the interface is just one-to-one mapping. */ + +#define __GTHREADS 1 + +/* Some implementations of require this to be defined. */ +#ifndef _REENTRANT +#define _REENTRANT 1 +#endif + +#include +#include + +typedef pthread_key_t __gthread_key_t; +typedef pthread_once_t __gthread_once_t; +typedef pthread_mutex_t __gthread_mutex_t; +typedef pthread_mutex_t __gthread_recursive_mutex_t; + +#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) +#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER +#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) +#define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP +#endif + +#define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER +#define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT +#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function + +#define NOTATHREAD 00 +#define ECBBASEPTR (unsigned long int) *(unsigned int *)0x00000514u +#define ECBPG2PTR ECBBASEPTR + 0x1000 +#define CE2THRCPTR *((unsigned char *)(ECBPG2PTR + 16)) +#define __tpf_pthread_active() (CE2THRCPTR != NOTATHREAD) + +#if SUPPORTS_WEAK && GTHREAD_USE_WEAK +# define __gthrw(name) \ + static __typeof(name) __gthrw_ ## name __attribute__ ((__weakref__(#name))); +# define __gthrw_(name) __gthrw_ ## name +#else +# define __gthrw(name) +# define __gthrw_(name) name +#endif + +__gthrw(pthread_once) +__gthrw(pthread_key_create) +__gthrw(pthread_key_delete) +__gthrw(pthread_getspecific) +__gthrw(pthread_setspecific) +__gthrw(pthread_create) + +__gthrw(pthread_mutex_lock) +__gthrw(pthread_mutex_trylock) +__gthrw(pthread_mutex_unlock) +__gthrw(pthread_mutexattr_init) +__gthrw(pthread_mutexattr_settype) +__gthrw(pthread_mutexattr_destroy) +__gthrw(pthread_mutex_init) +__gthrw(pthread_mutex_destroy) + +static inline int +__gthread_active_p (void) +{ + return 1; +} + +static inline int +__gthread_once (__gthread_once_t *__once, void (*__func) (void)) +{ + if (__tpf_pthread_active ()) + return __gthrw_(pthread_once) (__once, __func); + else + return -1; +} + +static inline int +__gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) +{ + if (__tpf_pthread_active ()) + return __gthrw_(pthread_key_create) (__key, __dtor); + else + return -1; +} + +static inline int +__gthread_key_delete (__gthread_key_t __key) +{ + if (__tpf_pthread_active ()) + return __gthrw_(pthread_key_delete) (__key); + else + return -1; +} + +static inline void * +__gthread_getspecific (__gthread_key_t __key) +{ + if (__tpf_pthread_active ()) + return __gthrw_(pthread_getspecific) (__key); + else + return NULL; +} + +static inline int +__gthread_setspecific (__gthread_key_t __key, const void *__ptr) +{ + if (__tpf_pthread_active ()) + return __gthrw_(pthread_setspecific) (__key, __ptr); + else + return -1; +} + +static inline int +__gthread_mutex_destroy (__gthread_mutex_t *__mutex) +{ + if (__tpf_pthread_active ()) + return __gthrw_(pthread_mutex_destroy) (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_lock (__gthread_mutex_t *__mutex) +{ + if (__tpf_pthread_active ()) + return __gthrw_(pthread_mutex_lock) (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_trylock (__gthread_mutex_t *__mutex) +{ + if (__tpf_pthread_active ()) + return __gthrw_(pthread_mutex_trylock) (__mutex); + else + return 0; +} + +static inline int +__gthread_mutex_unlock (__gthread_mutex_t *__mutex) +{ + if (__tpf_pthread_active ()) + return __gthrw_(pthread_mutex_unlock) (__mutex); + else + return 0; +} + +static inline int +__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) +{ + if (__tpf_pthread_active ()) + return __gthread_mutex_lock (__mutex); + else + return 0; +} + +static inline int +__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) +{ + if (__tpf_pthread_active ()) + return __gthread_mutex_trylock (__mutex); + else + return 0; +} + +static inline int +__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) +{ + if (__tpf_pthread_active ()) + return __gthread_mutex_unlock (__mutex); + else + return 0; +} + +static inline int +__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) +{ + if (__tpf_pthread_active ()) + { + pthread_mutexattr_t __attr; + int __r; + + __r = __gthrw_(pthread_mutexattr_init) (&__attr); + if (!__r) + __r = __gthrw_(pthread_mutexattr_settype) (&__attr, + PTHREAD_MUTEX_RECURSIVE); + if (!__r) + __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); + if (!__r) + __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); + return __r; + } + return 0; +} + + +#endif /* ! GCC_GTHR_TPF_H */ diff --git a/libgcc/configure b/libgcc/configure index 63b91b47a55..0d91645ed67 100644 --- a/libgcc/configure +++ b/libgcc/configure @@ -2273,7 +2273,7 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac - # FIXME: Do we need something for CFLAGS below? + case "${host}" in # PIC is the default on some targets or must not be used. @@ -2288,24 +2288,23 @@ case "${host}" in hppa*64*-*-hpux*) # PIC is the default for 64-bit PA HP-UX. ;; - i3456786-*-cygwin* | i3456786-*-mingw* | x86_64-*-mingw*) + i[34567]86-*-cygwin* | i[34567]86-*-mingw* | x86_64-*-mingw*) ;; - i3456786-*-interix3*) + i[34567]86-*-interix3*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; - i3456786-*-nto-qnx*) + i[34567]86-*-nto-qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. PICFLAG='-fPIC -shared' ;; - i3456786-pc-msdosdjgpp*) + i[34567]86-pc-msdosdjgpp*) # DJGPP does not support shared libraries at all. ;; ia64*-*-hpux*) # On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. - # FIXME: Still in gcc 4.7? PICFLAG=-fPIC ;; mips-sgi-irix6*) @@ -2317,7 +2316,7 @@ case "${host}" in # Some targets support both -fPIC and -fpic, but prefer the latter. # FIXME: Why? - i3456786-*-* | x86_64-*-*) + i[34567]86-*-* | x86_64-*-*) PICFLAG=-fpic ;; m68k-*-*) @@ -2327,7 +2326,7 @@ case "${host}" in PICFLAG=-fpic ;; # FIXME: Override -fPIC default in libgcc only? - sh-*-linux* | sh2346lbe*-*-linux*) + sh-*-linux* | sh[2346lbe]*-*-linux*) PICFLAG=-fpic ;; # FIXME: Simplify to sh*-*-netbsd*? @@ -2335,22 +2334,22 @@ case "${host}" in sh64-*-netbsd* | sh64l*-*-netbsd*) PICFLAG=-fpic ;; - sparc*-*-*) - # FIXME: This could be done everywhere -fpic and -fPIC differ. - case "${CFLAGS}" in - *-fpic*) - PICFLAG=-fpic - ;; - *) - PICFLAG=-fPIC - ;; - esac ;; # Default to -fPIC unless specified otherwise. *) PICFLAG=-fPIC ;; esac +# If the user explicitly uses -fpic/-fPIC, keep that. +case "${CFLAGS}" in + *-fpic*) + PICFLAG=-fpic + ;; + *-fPIC*) + PICFLAG=-fPIC + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --enable-version-specific-runtime-libs" >&5 @@ -4797,6 +4796,20 @@ tm_file="${tm_file_}" +# Map from thread model to thread header. +case $target_thread_file in + aix) thread_header=config/rs6000/gthr-aix.h ;; + dce) thread_header=config/pa/gthr-dce.h ;; + lynx) thread_header=config/gthr-lynx.h ;; + mipssde) thread_header=config/mips/gthr-mipssde.h ;; + posix) thread_header=config/gthr-posix.h ;; + rtems) thread_header=config/gthr-rtems.h ;; + single) thread_header=gthr-single.h ;; + tpf) thread_header=config/s390/gthr-tpf.h ;; + vxworks) thread_header=config/gthr-vxworks.h ;; + win32) thread_header=config/i386/gthr-win32.h ;; +esac + # Substitute configuration variables @@ -4809,6 +4822,8 @@ ac_config_links="$ac_config_links md-unwind-support.h:config/$md_unwind_header" ac_config_links="$ac_config_links sfp-machine.h:config/$sfp_machine_header" +ac_config_links="$ac_config_links gthr-default.h:$thread_header" + # We need multilib support. ac_config_files="$ac_config_files Makefile" @@ -5538,6 +5553,7 @@ do "unwind.h") CONFIG_LINKS="$CONFIG_LINKS unwind.h:$unwind_header" ;; "md-unwind-support.h") CONFIG_LINKS="$CONFIG_LINKS md-unwind-support.h:config/$md_unwind_header" ;; "sfp-machine.h") CONFIG_LINKS="$CONFIG_LINKS sfp-machine.h:config/$sfp_machine_header" ;; + "gthr-default.h") CONFIG_LINKS="$CONFIG_LINKS gthr-default.h:$thread_header" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; diff --git a/libgcc/configure.ac b/libgcc/configure.ac index 303a95ff54b..a505257ac23 100644 --- a/libgcc/configure.ac +++ b/libgcc/configure.ac @@ -364,6 +364,20 @@ tm_file="${tm_file_}" AC_SUBST(tm_file) AC_SUBST(tm_defines) +# Map from thread model to thread header. +case $target_thread_file in + aix) thread_header=config/rs6000/gthr-aix.h ;; + dce) thread_header=config/pa/gthr-dce.h ;; + lynx) thread_header=config/gthr-lynx.h ;; + mipssde) thread_header=config/mips/gthr-mipssde.h ;; + posix) thread_header=config/gthr-posix.h ;; + rtems) thread_header=config/gthr-rtems.h ;; + single) thread_header=gthr-single.h ;; + tpf) thread_header=config/s390/gthr-tpf.h ;; + vxworks) thread_header=config/gthr-vxworks.h ;; + win32) thread_header=config/i386/gthr-win32.h ;; +esac + # Substitute configuration variables AC_SUBST(cpu_type) AC_SUBST(extra_parts) @@ -372,6 +386,7 @@ AC_CONFIG_LINKS([enable-execute-stack.c:$enable_execute_stack]) AC_CONFIG_LINKS([unwind.h:$unwind_header]) AC_CONFIG_LINKS([md-unwind-support.h:config/$md_unwind_header]) AC_CONFIG_LINKS([sfp-machine.h:config/$sfp_machine_header]) +AC_CONFIG_LINKS([gthr-default.h:$thread_header]) # We need multilib support. AC_CONFIG_FILES([Makefile]) diff --git a/libgcc/gthr-single.h b/libgcc/gthr-single.h new file mode 100644 index 00000000000..357528ad1f1 --- /dev/null +++ b/libgcc/gthr-single.h @@ -0,0 +1,292 @@ +/* Threads compatibility routines for libgcc2 and libobjc. */ +/* Compile this one with gcc. */ +/* Copyright (C) 1997, 1999, 2000, 2004, 2008, 2009 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +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 +. */ + +#ifndef GCC_GTHR_SINGLE_H +#define GCC_GTHR_SINGLE_H + +/* Just provide compatibility for mutex handling. */ + +typedef int __gthread_key_t; +typedef int __gthread_once_t; +typedef int __gthread_mutex_t; +typedef int __gthread_recursive_mutex_t; + +#define __GTHREAD_ONCE_INIT 0 +#define __GTHREAD_MUTEX_INIT 0 +#define __GTHREAD_RECURSIVE_MUTEX_INIT 0 + +#define UNUSED __attribute__((unused)) + +#ifdef _LIBOBJC + +/* Thread local storage for a single thread */ +static void *thread_local_storage = NULL; + +/* Backend initialization functions */ + +/* Initialize the threads subsystem. */ +static inline int +__gthread_objc_init_thread_system (void) +{ + /* No thread support available */ + return -1; +} + +/* Close the threads subsystem. */ +static inline int +__gthread_objc_close_thread_system (void) +{ + /* No thread support available */ + return -1; +} + +/* Backend thread functions */ + +/* Create a new thread of execution. */ +static inline objc_thread_t +__gthread_objc_thread_detach (void (* func)(void *), void * arg UNUSED) +{ + /* No thread support available */ + return NULL; +} + +/* Set the current thread's priority. */ +static inline int +__gthread_objc_thread_set_priority (int priority UNUSED) +{ + /* No thread support available */ + return -1; +} + +/* Return the current thread's priority. */ +static inline int +__gthread_objc_thread_get_priority (void) +{ + return OBJC_THREAD_INTERACTIVE_PRIORITY; +} + +/* Yield our process time to another thread. */ +static inline void +__gthread_objc_thread_yield (void) +{ + return; +} + +/* Terminate the current thread. */ +static inline int +__gthread_objc_thread_exit (void) +{ + /* No thread support available */ + /* Should we really exit the program */ + /* exit (&__objc_thread_exit_status); */ + return -1; +} + +/* Returns an integer value which uniquely describes a thread. */ +static inline objc_thread_t +__gthread_objc_thread_id (void) +{ + /* No thread support, use 1. */ + return (objc_thread_t) 1; +} + +/* Sets the thread's local storage pointer. */ +static inline int +__gthread_objc_thread_set_data (void *value) +{ + thread_local_storage = value; + return 0; +} + +/* Returns the thread's local storage pointer. */ +static inline void * +__gthread_objc_thread_get_data (void) +{ + return thread_local_storage; +} + +/* Backend mutex functions */ + +/* Allocate a mutex. */ +static inline int +__gthread_objc_mutex_allocate (objc_mutex_t mutex UNUSED) +{ + return 0; +} + +/* Deallocate a mutex. */ +static inline int +__gthread_objc_mutex_deallocate (objc_mutex_t mutex UNUSED) +{ + return 0; +} + +/* Grab a lock on a mutex. */ +static inline int +__gthread_objc_mutex_lock (objc_mutex_t mutex UNUSED) +{ + /* There can only be one thread, so we always get the lock */ + return 0; +} + +/* Try to grab a lock on a mutex. */ +static inline int +__gthread_objc_mutex_trylock (objc_mutex_t mutex UNUSED) +{ + /* There can only be one thread, so we always get the lock */ + return 0; +} + +/* Unlock the mutex */ +static inline int +__gthread_objc_mutex_unlock (objc_mutex_t mutex UNUSED) +{ + return 0; +} + +/* Backend condition mutex functions */ + +/* Allocate a condition. */ +static inline int +__gthread_objc_condition_allocate (objc_condition_t condition UNUSED) +{ + return 0; +} + +/* Deallocate a condition. */ +static inline int +__gthread_objc_condition_deallocate (objc_condition_t condition UNUSED) +{ + return 0; +} + +/* Wait on the condition */ +static inline int +__gthread_objc_condition_wait (objc_condition_t condition UNUSED, + objc_mutex_t mutex UNUSED) +{ + return 0; +} + +/* Wake up all threads waiting on this condition. */ +static inline int +__gthread_objc_condition_broadcast (objc_condition_t condition UNUSED) +{ + return 0; +} + +/* Wake up one thread waiting on this condition. */ +static inline int +__gthread_objc_condition_signal (objc_condition_t condition UNUSED) +{ + return 0; +} + +#else /* _LIBOBJC */ + +static inline int +__gthread_active_p (void) +{ + return 0; +} + +static inline int +__gthread_once (__gthread_once_t *__once UNUSED, void (*__func) (void) UNUSED) +{ + return 0; +} + +static inline int UNUSED +__gthread_key_create (__gthread_key_t *__key UNUSED, void (*__func) (void *) UNUSED) +{ + return 0; +} + +static int UNUSED +__gthread_key_delete (__gthread_key_t __key UNUSED) +{ + return 0; +} + +static inline void * +__gthread_getspecific (__gthread_key_t __key UNUSED) +{ + return 0; +} + +static inline int +__gthread_setspecific (__gthread_key_t __key UNUSED, const void *__v UNUSED) +{ + return 0; +} + +static inline int +__gthread_mutex_destroy (__gthread_mutex_t *__mutex UNUSED) +{ + return 0; +} + +static inline int +__gthread_mutex_lock (__gthread_mutex_t *__mutex UNUSED) +{ + return 0; +} + +static inline int +__gthread_mutex_trylock (__gthread_mutex_t *__mutex UNUSED) +{ + return 0; +} + +static inline int +__gthread_mutex_unlock (__gthread_mutex_t *__mutex UNUSED) +{ + return 0; +} + +static inline int +__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_lock (__mutex); +} + +static inline int +__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_trylock (__mutex); +} + +static inline int +__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) +{ + return __gthread_mutex_unlock (__mutex); +} + +#endif /* _LIBOBJC */ + +#undef UNUSED + +#endif /* ! GCC_GTHR_SINGLE_H */ diff --git a/libgcc/gthr.h b/libgcc/gthr.h new file mode 100644 index 00000000000..607c26eb563 --- /dev/null +++ b/libgcc/gthr.h @@ -0,0 +1,148 @@ +/* Threads compatibility routines for libgcc2. */ +/* Compile this one with gcc. */ +/* Copyright (C) 1997, 1998, 2004, 2008, 2009, 2011 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +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 +. */ + +#ifndef GCC_GTHR_H +#define GCC_GTHR_H + +#ifndef HIDE_EXPORTS +#pragma GCC visibility push(default) +#endif + +/* If this file is compiled with threads support, it must + #define __GTHREADS 1 + to indicate that threads support is present. Also it has define + function + int __gthread_active_p () + that returns 1 if thread system is active, 0 if not. + + The threads interface must define the following types: + __gthread_key_t + __gthread_once_t + __gthread_mutex_t + __gthread_recursive_mutex_t + + The threads interface must define the following macros: + + __GTHREAD_ONCE_INIT + to initialize __gthread_once_t + __GTHREAD_MUTEX_INIT + to initialize __gthread_mutex_t to get a fast + non-recursive mutex. + __GTHREAD_MUTEX_INIT_FUNCTION + some systems can't initialize a mutex without a + function call. On such systems, define this to a + function which looks like this: + void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *) + Don't define __GTHREAD_MUTEX_INIT in this case + __GTHREAD_RECURSIVE_MUTEX_INIT + __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION + as above, but for a recursive mutex. + + The threads interface must define the following static functions: + + int __gthread_once (__gthread_once_t *once, void (*func) ()) + + int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *)) + int __gthread_key_delete (__gthread_key_t key) + + void *__gthread_getspecific (__gthread_key_t key) + int __gthread_setspecific (__gthread_key_t key, const void *ptr) + + int __gthread_mutex_destroy (__gthread_mutex_t *mutex); + + int __gthread_mutex_lock (__gthread_mutex_t *mutex); + int __gthread_mutex_trylock (__gthread_mutex_t *mutex); + int __gthread_mutex_unlock (__gthread_mutex_t *mutex); + + int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex); + int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex); + int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex); + + The following are supported in POSIX threads only. They are required to + fix a deadlock in static initialization inside libsupc++. The header file + gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra + features are supported. + + Types: + __gthread_cond_t + + Macros: + __GTHREAD_COND_INIT + __GTHREAD_COND_INIT_FUNCTION + + Interface: + int __gthread_cond_broadcast (__gthread_cond_t *cond); + int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex); + int __gthread_cond_wait_recursive (__gthread_cond_t *cond, + __gthread_recursive_mutex_t *mutex); + + All functions returning int should return zero on success or the error + number. If the operation is not supported, -1 is returned. + + If the following are also defined, you should + #define __GTHREADS_CXX0X 1 + to enable the c++0x thread library. + + Types: + __gthread_t + __gthread_time_t + + Interface: + int __gthread_create (__gthread_t *thread, void *(*func) (void*), + void *args); + int __gthread_join (__gthread_t thread, void **value_ptr); + int __gthread_detach (__gthread_t thread); + int __gthread_equal (__gthread_t t1, __gthread_t t2); + __gthread_t __gthread_self (void); + int __gthread_yield (void); + + int __gthread_mutex_timedlock (__gthread_mutex_t *m, + const __gthread_time_t *abs_timeout); + int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m, + const __gthread_time_t *abs_time); + + int __gthread_cond_signal (__gthread_cond_t *cond); + int __gthread_cond_timedwait (__gthread_cond_t *cond, + __gthread_mutex_t *mutex, + const __gthread_time_t *abs_timeout); + int __gthread_cond_timedwait_recursive (__gthread_cond_t *cond, + __gthread_recursive_mutex_t *mutex, + const __gthread_time_t *abs_time) + +*/ + +#if SUPPORTS_WEAK +#ifndef GTHREAD_USE_WEAK +#define GTHREAD_USE_WEAK 1 +#endif +#endif +#include "gthr-default.h" + +#ifndef HIDE_EXPORTS +#pragma GCC visibility pop +#endif + +#endif /* ! GCC_GTHR_H */ diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index a022ee2ec63..264f196d9df 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,13 @@ +2011-11-02 Rainer Orth + + * Makefile.am (AM_CPPFLAGS): Add + -I$(srcdir)/$(MULTISRCTOP)../libgcc, -I$(MULTIBUILDTOP)../libgcc. + * Makefile.in: Regenerate. + * acinclude.m4 (LIBGFOR_CHECK_GTHR_DEFAULT): Remove. + * configure.ac (LIBGFOR_CHECK_GTHR_DEFAULT): Likewise. + * configure: Regenerate. + * config.h.in: Regenerate. + 2011-11-01 Janne Blomqvist * io/io.h (next_available_newunit): Remove prototype. diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am index ce0d7250328..350b7161059 100644 --- a/libgfortran/Makefile.am +++ b/libgfortran/Makefile.am @@ -56,7 +56,9 @@ libcaf_single_la_LINK = $(LINK) $(libcaf_single_la_LDFLAGS) ## use -iquote AM_CPPFLAGS = -iquote$(srcdir)/io -I$(srcdir)/$(MULTISRCTOP)../gcc \ -I$(srcdir)/$(MULTISRCTOP)../gcc/config $(LIBQUADINCLUDE) \ - -I$(MULTIBUILDTOP)../../$(host_subdir)/gcc + -I$(MULTIBUILDTOP)../../$(host_subdir)/gcc \ + -I$(srcdir)/$(MULTISRCTOP)../libgcc \ + -I$(MULTIBUILDTOP)../libgcc # Fortran rules for complex multiplication and division AM_CFLAGS += -fcx-fortran-rules diff --git a/libgfortran/Makefile.in b/libgfortran/Makefile.in index d41b7bb2b82..80a6c60968d 100644 --- a/libgfortran/Makefile.in +++ b/libgfortran/Makefile.in @@ -506,7 +506,9 @@ libcaf_single_la_DEPENDENCIES = caf/libcaf.h libcaf_single_la_LINK = $(LINK) $(libcaf_single_la_LDFLAGS) AM_CPPFLAGS = -iquote$(srcdir)/io -I$(srcdir)/$(MULTISRCTOP)../gcc \ -I$(srcdir)/$(MULTISRCTOP)../gcc/config $(LIBQUADINCLUDE) \ - -I$(MULTIBUILDTOP)../../$(host_subdir)/gcc + -I$(MULTIBUILDTOP)../../$(host_subdir)/gcc \ + -I$(srcdir)/$(MULTISRCTOP)../libgcc \ + -I$(MULTIBUILDTOP)../libgcc gfor_io_src = \ io/close.c \ diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4 index 92e027177b5..b6cb40430af 100644 --- a/libgfortran/acinclude.m4 +++ b/libgfortran/acinclude.m4 @@ -83,17 +83,6 @@ if (foovar > 10) return __sync_add_and_fetch (&foovar, -1);]])], [Define to 1 if the target supports __sync_fetch_and_add]) fi]) -dnl Check if threads are supported. -AC_DEFUN([LIBGFOR_CHECK_GTHR_DEFAULT], [ - AC_CACHE_CHECK([configured target thread model], - libgfor_cv_target_thread_file, [ -libgfor_cv_target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`]) - - if test $libgfor_cv_target_thread_file != single; then - AC_DEFINE(HAVE_GTHR_DEFAULT, 1, - [Define if the compiler has a thread header that is non single.]) - fi]) - dnl Check for pragma weak. AC_DEFUN([LIBGFOR_GTHREAD_WEAK], [ AC_CACHE_CHECK([whether pragma weak works], diff --git a/libgfortran/config.h.in b/libgfortran/config.h.in index 57f66b51ab9..708ec7cd02d 100644 --- a/libgfortran/config.h.in +++ b/libgfortran/config.h.in @@ -483,9 +483,6 @@ /* Define to 1 if you have the `gmtime_r' function. */ #undef HAVE_GMTIME_R -/* Define if the compiler has a thread header that is non single. */ -#undef HAVE_GTHR_DEFAULT - /* libm includes hypot */ #undef HAVE_HYPOT diff --git a/libgfortran/configure b/libgfortran/configure index a716ff37faf..3a1174a1237 100755 --- a/libgfortran/configure +++ b/libgfortran/configure @@ -25704,25 +25704,6 @@ $as_echo "#define HAVE_SYNC_FETCH_AND_ADD 1" >>confdefs.h fi -# Check out thread support. - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking configured target thread model" >&5 -$as_echo_n "checking configured target thread model... " >&6; } -if test "${libgfor_cv_target_thread_file+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - -libgfor_cv_target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'` -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgfor_cv_target_thread_file" >&5 -$as_echo "$libgfor_cv_target_thread_file" >&6; } - - if test $libgfor_cv_target_thread_file != single; then - -$as_echo "#define HAVE_GTHR_DEFAULT 1" >>confdefs.h - - fi - # Check out #pragma weak. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pragma weak works" >&5 diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac index 74cfe441a75..447ea9df998 100644 --- a/libgfortran/configure.ac +++ b/libgfortran/configure.ac @@ -550,9 +550,6 @@ LIBGFOR_CHECK_ATTRIBUTE_ALIAS # Check out sync builtins support. LIBGFOR_CHECK_SYNC_FETCH_AND_ADD -# Check out thread support. -LIBGFOR_CHECK_GTHR_DEFAULT - # Check out #pragma weak. LIBGFOR_GTHREAD_WEAK diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog index 86e8c139194..474849480e0 100644 --- a/libobjc/ChangeLog +++ b/libobjc/ChangeLog @@ -1,3 +1,10 @@ +2011-11-02 Rainer Orth + + * Makefile.in (INCLUDES): Add -I$(MULTIBUILDTOP)../libgcc. + * configure.ac (target_thread_file, HAVE_GTHR_DEFAULT): Remove. + * configure: Regenerate. + * config.h.in: Regenerate. + 2011-10-17 Paul Brook Matthias Klose diff --git a/libobjc/Makefile.in b/libobjc/Makefile.in index 0935ccd98d6..1427bac43b2 100644 --- a/libobjc/Makefile.in +++ b/libobjc/Makefile.in @@ -102,6 +102,7 @@ INCLUDES = -I$(srcdir)/$(MULTISRCTOP)../gcc \ -I$(srcdir)/$(MULTISRCTOP)../gcc/config \ -I$(MULTIBUILDTOP)../../$(host_subdir)/gcc \ -I$(srcdir)/$(MULTISRCTOP)../libgcc \ + -I$(MULTIBUILDTOP)../libgcc \ -I$(srcdir)/$(MULTISRCTOP)../include \ $(OBJC_BOEHM_GC_INCLUDES) diff --git a/libobjc/config.h.in b/libobjc/config.h.in index d9c8172d258..c055e7c1909 100644 --- a/libobjc/config.h.in +++ b/libobjc/config.h.in @@ -6,9 +6,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H -/* Define if the compiler has a thread header that is non single. */ -#undef HAVE_GTHR_DEFAULT - /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H diff --git a/libobjc/configure b/libobjc/configure index c68cde0f806..59e3d98a7a5 100755 --- a/libobjc/configure +++ b/libobjc/configure @@ -11248,18 +11248,6 @@ done # Miscellanea # ----------- -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for thread model used by GCC" >&5 -$as_echo_n "checking for thread model used by GCC... " >&6; } -target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'` -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $target_thread_file" >&5 -$as_echo "$target_thread_file" >&6; } - -if test $target_thread_file != single; then - -$as_echo "#define HAVE_GTHR_DEFAULT 1" >>confdefs.h - -fi - # Check if we have thread-local storage @@ -11483,7 +11471,7 @@ if test "${enable_sjlj_exceptions+set}" = set; then : enableval=$enable_sjlj_exceptions; : else cat > conftest.$ac_ext << EOF -#line 11486 "configure" +#line 11474 "configure" @interface Frob @end @implementation Frob diff --git a/libobjc/configure.ac b/libobjc/configure.ac index dd303fff065..52599e6019e 100644 --- a/libobjc/configure.ac +++ b/libobjc/configure.ac @@ -217,15 +217,6 @@ AC_CHECK_HEADERS(sched.h) # Miscellanea # ----------- -AC_MSG_CHECKING([for thread model used by GCC]) -target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'` -AC_MSG_RESULT([$target_thread_file]) - -if test $target_thread_file != single; then - AC_DEFINE(HAVE_GTHR_DEFAULT, 1, - [Define if the compiler has a thread header that is non single.]) -fi - # Check if we have thread-local storage GCC_CHECK_TLS diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 82a0b911412..7e00e2a382b 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -27,6 +27,26 @@ * testsuite/26_numerics/random/shuffle_order_engine/ operators/serialize.cc: Likewise. +2011-11-02 Rainer Orth + + * acinclude.m4 (GLIBCXX_CONFIGURE): Determine and substitute + toplevel_builddir. + (GLIBCXX_ENABLE_THREADS): Remove glibcxx_thread_h, + HAVE_GTHR_DEFAULT, enable_thread. + (GLIBCXX_CHECK_GTHREADS): Reflect gthr move to libgcc. + * include/Makefile.am (thread_host_headers): Remove + ${host_builddir}/gthr-tpf.h. + (${host_builddir}/gthr.h): Reflect gthr move to libgcc. + Use $<. + (${host_builddir}/gthr-single.h): Likewise. + (${host_builddir}/gthr-posix.h): Likewise. + (${host_builddir}/gthr-tpf.h): Remove. + (${host_builddir}/gthr-default.h): Likewise. + * configure, config.h.in: Regenerate. + * Makefile.in, doc/Makefile.in, include/Makefile.in, + libsupc++/Makefile.in, po/Makefile.in, python/Makefile.in, + src/Makefile.intestsuite/Makefile.in: Regenerate. + 2011-11-02 Benjamin Kosnik * include/bits/c++config: Add tr2 to versioned namespaces. diff --git a/libstdc++-v3/Makefile.in b/libstdc++-v3/Makefile.in index 272c4eeea40..2284126ab06 100644 --- a/libstdc++-v3/Makefile.in +++ b/libstdc++-v3/Makefile.in @@ -239,7 +239,6 @@ glibcxx_builddir = @glibcxx_builddir@ glibcxx_localedir = @glibcxx_localedir@ glibcxx_prefixdir = @glibcxx_prefixdir@ glibcxx_srcdir = @glibcxx_srcdir@ -glibcxx_thread_h = @glibcxx_thread_h@ glibcxx_toolexecdir = @glibcxx_toolexecdir@ glibcxx_toolexeclibdir = @glibcxx_toolexeclibdir@ gxx_include_dir = @gxx_include_dir@ @@ -279,6 +278,7 @@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +toplevel_builddir = @toplevel_builddir@ toplevel_srcdir = @toplevel_srcdir@ # May be used by various substitution variables. diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 9382250d057..684a2958ce8 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -35,6 +35,7 @@ dnl SUBDIRS dnl Substs: dnl glibcxx_builddir (absolute path) dnl glibcxx_srcdir (absolute path) +dnl toplevel_builddir (absolute path) dnl toplevel_srcdir (absolute path) dnl with_cross_host dnl with_newlib @@ -59,9 +60,11 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [ [\\/$]* | ?:[\\/]*) glibcxx_srcdir=${srcdir} ;; *) glibcxx_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;; esac + toplevel_builddir=${glibcxx_builddir}/.. toplevel_srcdir=${glibcxx_srcdir}/.. AC_SUBST(glibcxx_builddir) AC_SUBST(glibcxx_srcdir) + AC_SUBST(toplevel_builddir) AC_SUBST(toplevel_srcdir) # We use these options to decide which functions to include. They are @@ -3315,34 +3318,10 @@ dnl having to write complex code (the sed commands to clean the macro dnl namespace are complex and fragile enough as it is). We must also dnl add a relative path so that -I- is supported properly. dnl -dnl Substs: -dnl glibcxx_thread_h -dnl -dnl Defines: -dnl HAVE_GTHR_DEFAULT -dnl AC_DEFUN([GLIBCXX_ENABLE_THREADS], [ AC_MSG_CHECKING([for thread model used by GCC]) target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'` AC_MSG_RESULT([$target_thread_file]) - - if test $target_thread_file != single; then - AC_DEFINE(HAVE_GTHR_DEFAULT, 1, - [Define if gthr-default.h exists - (meaning that threading support is enabled).]) - fi - - glibcxx_thread_h=gthr-$target_thread_file.h - - dnl Check for __GTHREADS define. - gthread_file=${toplevel_srcdir}/gcc/${glibcxx_thread_h} - if grep __GTHREADS $gthread_file >/dev/null 2>&1 ; then - enable_thread=yes - else - enable_thread=no - fi - - AC_SUBST(glibcxx_thread_h) ]) @@ -3356,7 +3335,8 @@ AC_DEFUN([GLIBCXX_CHECK_GTHREADS], [ AC_LANG_CPLUSPLUS ac_save_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS -fno-exceptions -I${toplevel_srcdir}/gcc" + CXXFLAGS="$CXXFLAGS -fno-exceptions \ + -I${toplevel_srcdir}/libgcc -I${toplevel_builddir}/libgcc" target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'` case $target_thread_file in diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index df7effb6a6b..f82d91ad417 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -171,10 +171,6 @@ /* Define if _Unwind_GetIPInfo is available. */ #undef HAVE_GETIPINFO -/* Define if gthr-default.h exists (meaning that threading support is - enabled). */ -#undef HAVE_GTHR_DEFAULT - /* Define to 1 if you have the `hypot' function. */ #undef HAVE_HYPOT diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 77a4abfbadf..428cdc5bd80 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -707,7 +707,6 @@ BASIC_FILE_H CSTDIO_H SECTION_FLAGS WERROR -glibcxx_thread_h glibcxx_PCHFLAGS GLIBCXX_BUILD_PCH_FALSE GLIBCXX_BUILD_PCH_TRUE @@ -741,6 +740,7 @@ AR AS LN_S toplevel_srcdir +toplevel_builddir glibcxx_srcdir glibcxx_builddir ac_ct_CXX @@ -4870,11 +4870,13 @@ $as_echo "$ac_cv_path_EGREP" >&6; } \\/$* | ?:\\/*) glibcxx_srcdir=${srcdir} ;; *) glibcxx_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;; esac + toplevel_builddir=${glibcxx_builddir}/.. toplevel_srcdir=${glibcxx_srcdir}/.. + # We use these options to decide which functions to include. They are # set from the top level. @@ -11485,7 +11487,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11488 "configure" +#line 11490 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11591,7 +11593,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11594 "configure" +#line 11596 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -14949,7 +14951,7 @@ fi # # Fake what AC_TRY_COMPILE does. XXX Look at redoing this new-style. cat > conftest.$ac_ext << EOF -#line 14952 "configure" +#line 14954 "configure" struct S { ~S(); }; void bar(); void foo() @@ -15077,23 +15079,6 @@ $as_echo_n "checking for thread model used by GCC... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $target_thread_file" >&5 $as_echo "$target_thread_file" >&6; } - if test $target_thread_file != single; then - -$as_echo "#define HAVE_GTHR_DEFAULT 1" >>confdefs.h - - fi - - glibcxx_thread_h=gthr-$target_thread_file.h - - gthread_file=${toplevel_srcdir}/gcc/${glibcxx_thread_h} - if grep __GTHREADS $gthread_file >/dev/null 2>&1 ; then - enable_thread=yes - else - enable_thread=no - fi - - - ac_ext=cpp @@ -15317,7 +15302,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; } # Fake what AC_TRY_COMPILE does. cat > conftest.$ac_ext << EOF -#line 15320 "configure" +#line 15305 "configure" int main() { typedef bool atomic_type; @@ -15354,7 +15339,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 15357 "configure" +#line 15342 "configure" int main() { typedef short atomic_type; @@ -15391,7 +15376,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 15394 "configure" +#line 15379 "configure" int main() { // NB: _Atomic_word not necessarily int. @@ -15429,7 +15414,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 15432 "configure" +#line 15417 "configure" int main() { typedef long long atomic_type; @@ -15505,7 +15490,7 @@ $as_echo "$as_me: WARNING: Performance of certain classes will degrade as a resu # unnecessary for this test. cat > conftest.$ac_ext << EOF -#line 15508 "configure" +#line 15493 "configure" int main() { _Decimal32 d1; @@ -15547,7 +15532,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # unnecessary for this test. cat > conftest.$ac_ext << EOF -#line 15550 "configure" +#line 15535 "configure" template struct same { typedef T2 type; }; @@ -15581,7 +15566,7 @@ $as_echo "$enable_int128" >&6; } rm -f conftest* cat > conftest.$ac_ext << EOF -#line 15584 "configure" +#line 15569 "configure" template struct same { typedef T2 type; }; @@ -19821,7 +19806,8 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_save_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS -fno-exceptions -I${toplevel_srcdir}/gcc" + CXXFLAGS="$CXXFLAGS -fno-exceptions \ + -I${toplevel_srcdir}/libgcc -I${toplevel_builddir}/libgcc" target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'` case $target_thread_file in diff --git a/libstdc++-v3/doc/Makefile.in b/libstdc++-v3/doc/Makefile.in index 43045671ccd..8c38839bff7 100644 --- a/libstdc++-v3/doc/Makefile.in +++ b/libstdc++-v3/doc/Makefile.in @@ -215,7 +215,6 @@ glibcxx_builddir = @glibcxx_builddir@ glibcxx_localedir = @glibcxx_localedir@ glibcxx_prefixdir = @glibcxx_prefixdir@ glibcxx_srcdir = @glibcxx_srcdir@ -glibcxx_thread_h = @glibcxx_thread_h@ glibcxx_toolexecdir = @glibcxx_toolexecdir@ glibcxx_toolexeclibdir = @glibcxx_toolexeclibdir@ gxx_include_dir = @gxx_include_dir@ @@ -263,6 +262,7 @@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +toplevel_builddir = @toplevel_builddir@ toplevel_srcdir = @toplevel_srcdir@ # May be used by various substitution variables. diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 74acbf0c88a..c342528fe46 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -855,7 +855,6 @@ thread_host_headers = \ ${host_builddir}/gthr.h \ ${host_builddir}/gthr-single.h \ ${host_builddir}/gthr-posix.h \ - ${host_builddir}/gthr-tpf.h \ ${host_builddir}/gthr-default.h @@ -1122,43 +1121,35 @@ ${host_builddir}/c++config.h: ${CONFIG_HEADER} \ # Host includes for threads uppercase = [ABCDEFGHIJKLMNOPQRSTUVWXYZ_] -${host_builddir}/gthr.h: ${toplevel_srcdir}/gcc/gthr.h stamp-${host_alias} +${host_builddir}/gthr.h: ${toplevel_srcdir}/libgcc/gthr.h stamp-${host_alias} sed -e '/^#pragma/b' \ -e '/^#/s/\(${uppercase}${uppercase}*\)/_GLIBCXX_\1/g' \ -e 's/_GLIBCXX_SUPPORTS_WEAK/__GXX_WEAK__/g' \ -e 's,^#include "\(.*\)",#include ,g' \ - < ${toplevel_srcdir}/gcc/gthr.h > $@ + < $< > $@ -${host_builddir}/gthr-single.h: ${toplevel_srcdir}/gcc/gthr-single.h \ +${host_builddir}/gthr-single.h: ${toplevel_srcdir}/libgcc/gthr-single.h \ stamp-${host_alias} sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \ -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \ - < ${toplevel_srcdir}/gcc/gthr-single.h > $@ + < $< > $@ -${host_builddir}/gthr-posix.h: ${toplevel_srcdir}/gcc/gthr-posix.h \ +${host_builddir}/gthr-posix.h: ${toplevel_srcdir}/libgcc/config/gthr-posix.h \ stamp-${host_alias} sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \ -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \ -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \ -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \ - < ${toplevel_srcdir}/gcc/gthr-posix.h > $@ + < $< > $@ -${host_builddir}/gthr-tpf.h: ${toplevel_srcdir}/gcc/gthr-tpf.h \ - stamp-${host_alias} - sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \ - -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \ - -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \ - -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \ - < ${toplevel_srcdir}/gcc/gthr-tpf.h > $@ - -${host_builddir}/gthr-default.h: ${toplevel_srcdir}/gcc/${glibcxx_thread_h} \ +${host_builddir}/gthr-default.h: ${toplevel_builddir}/libgcc/gthr-default.h \ stamp-${host_alias} sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \ -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \ -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \ -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \ -e 's,^#include "\(.*\)",#include ,g' \ - < ${toplevel_srcdir}/gcc/${glibcxx_thread_h} > $@ + < $< > $@ # Build two precompiled C++ includes, stdc++.h.gch/*.gch ${pch1a_output}: ${allstamped} ${host_builddir}/c++config.h ${pch1_source} diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 8b805ba9acb..40dfb99c689 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -213,7 +213,6 @@ glibcxx_builddir = @glibcxx_builddir@ glibcxx_localedir = @glibcxx_localedir@ glibcxx_prefixdir = @glibcxx_prefixdir@ glibcxx_srcdir = @glibcxx_srcdir@ -glibcxx_thread_h = @glibcxx_thread_h@ glibcxx_toolexecdir = @glibcxx_toolexecdir@ glibcxx_toolexeclibdir = @glibcxx_toolexeclibdir@ gxx_include_dir = @gxx_include_dir@ @@ -253,6 +252,7 @@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +toplevel_builddir = @toplevel_builddir@ toplevel_srcdir = @toplevel_srcdir@ # May be used by various substitution variables. @@ -1099,7 +1099,6 @@ thread_host_headers = \ ${host_builddir}/gthr.h \ ${host_builddir}/gthr-single.h \ ${host_builddir}/gthr-posix.h \ - ${host_builddir}/gthr-tpf.h \ ${host_builddir}/gthr-default.h pch1_source = ${glibcxx_srcdir}/include/precompiled/stdc++.h @@ -1510,43 +1509,35 @@ ${host_builddir}/c++config.h: ${CONFIG_HEADER} \ echo "" >> $@ ;\ echo "#endif // _GLIBCXX_CXX_CONFIG_H" >> $@ -${host_builddir}/gthr.h: ${toplevel_srcdir}/gcc/gthr.h stamp-${host_alias} +${host_builddir}/gthr.h: ${toplevel_srcdir}/libgcc/gthr.h stamp-${host_alias} sed -e '/^#pragma/b' \ -e '/^#/s/\(${uppercase}${uppercase}*\)/_GLIBCXX_\1/g' \ -e 's/_GLIBCXX_SUPPORTS_WEAK/__GXX_WEAK__/g' \ -e 's,^#include "\(.*\)",#include ,g' \ - < ${toplevel_srcdir}/gcc/gthr.h > $@ + < $< > $@ -${host_builddir}/gthr-single.h: ${toplevel_srcdir}/gcc/gthr-single.h \ +${host_builddir}/gthr-single.h: ${toplevel_srcdir}/libgcc/gthr-single.h \ stamp-${host_alias} sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \ -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \ - < ${toplevel_srcdir}/gcc/gthr-single.h > $@ + < $< > $@ -${host_builddir}/gthr-posix.h: ${toplevel_srcdir}/gcc/gthr-posix.h \ +${host_builddir}/gthr-posix.h: ${toplevel_srcdir}/libgcc/config/gthr-posix.h \ stamp-${host_alias} sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \ -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \ -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \ -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \ - < ${toplevel_srcdir}/gcc/gthr-posix.h > $@ + < $< > $@ -${host_builddir}/gthr-tpf.h: ${toplevel_srcdir}/gcc/gthr-tpf.h \ - stamp-${host_alias} - sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \ - -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \ - -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \ - -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \ - < ${toplevel_srcdir}/gcc/gthr-tpf.h > $@ - -${host_builddir}/gthr-default.h: ${toplevel_srcdir}/gcc/${glibcxx_thread_h} \ +${host_builddir}/gthr-default.h: ${toplevel_builddir}/libgcc/gthr-default.h \ stamp-${host_alias} sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \ -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \ -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \ -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \ -e 's,^#include "\(.*\)",#include ,g' \ - < ${toplevel_srcdir}/gcc/${glibcxx_thread_h} > $@ + < $< > $@ # Build two precompiled C++ includes, stdc++.h.gch/*.gch ${pch1a_output}: ${allstamped} ${host_builddir}/c++config.h ${pch1_source} diff --git a/libstdc++-v3/libsupc++/Makefile.in b/libstdc++-v3/libsupc++/Makefile.in index 4c36c35e0bc..9ef5e683af8 100644 --- a/libstdc++-v3/libsupc++/Makefile.in +++ b/libstdc++-v3/libsupc++/Makefile.in @@ -272,7 +272,6 @@ glibcxx_builddir = @glibcxx_builddir@ glibcxx_localedir = @glibcxx_localedir@ glibcxx_prefixdir = @glibcxx_prefixdir@ glibcxx_srcdir = @glibcxx_srcdir@ -glibcxx_thread_h = @glibcxx_thread_h@ glibcxx_toolexecdir = @glibcxx_toolexecdir@ glibcxx_toolexeclibdir = @glibcxx_toolexeclibdir@ gxx_include_dir = @gxx_include_dir@ @@ -312,6 +311,7 @@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +toplevel_builddir = @toplevel_builddir@ toplevel_srcdir = @toplevel_srcdir@ # May be used by various substitution variables. diff --git a/libstdc++-v3/po/Makefile.in b/libstdc++-v3/po/Makefile.in index 09092677b04..0226b894a6e 100644 --- a/libstdc++-v3/po/Makefile.in +++ b/libstdc++-v3/po/Makefile.in @@ -213,7 +213,6 @@ glibcxx_builddir = @glibcxx_builddir@ glibcxx_localedir = @glibcxx_localedir@ glibcxx_prefixdir = @glibcxx_prefixdir@ glibcxx_srcdir = @glibcxx_srcdir@ -glibcxx_thread_h = @glibcxx_thread_h@ glibcxx_toolexecdir = @glibcxx_toolexecdir@ glibcxx_toolexeclibdir = @glibcxx_toolexeclibdir@ gxx_include_dir = @gxx_include_dir@ @@ -253,6 +252,7 @@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +toplevel_builddir = @toplevel_builddir@ toplevel_srcdir = @toplevel_srcdir@ # May be used by various substitution variables. diff --git a/libstdc++-v3/python/Makefile.in b/libstdc++-v3/python/Makefile.in index 01bcddbe1c6..ca046cf0a33 100644 --- a/libstdc++-v3/python/Makefile.in +++ b/libstdc++-v3/python/Makefile.in @@ -237,7 +237,6 @@ glibcxx_builddir = @glibcxx_builddir@ glibcxx_localedir = @glibcxx_localedir@ glibcxx_prefixdir = @glibcxx_prefixdir@ glibcxx_srcdir = @glibcxx_srcdir@ -glibcxx_thread_h = @glibcxx_thread_h@ glibcxx_toolexecdir = @glibcxx_toolexecdir@ glibcxx_toolexeclibdir = @glibcxx_toolexeclibdir@ gxx_include_dir = @gxx_include_dir@ @@ -277,6 +276,7 @@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +toplevel_builddir = @toplevel_builddir@ toplevel_srcdir = @toplevel_srcdir@ # May be used by various substitution variables. diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in index 5d31fb20c41..c52e5c4df61 100644 --- a/libstdc++-v3/src/Makefile.in +++ b/libstdc++-v3/src/Makefile.in @@ -277,7 +277,6 @@ glibcxx_builddir = @glibcxx_builddir@ glibcxx_localedir = @glibcxx_localedir@ glibcxx_prefixdir = @glibcxx_prefixdir@ glibcxx_srcdir = @glibcxx_srcdir@ -glibcxx_thread_h = @glibcxx_thread_h@ glibcxx_toolexecdir = @glibcxx_toolexecdir@ glibcxx_toolexeclibdir = @glibcxx_toolexeclibdir@ gxx_include_dir = @gxx_include_dir@ @@ -317,6 +316,7 @@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +toplevel_builddir = @toplevel_builddir@ toplevel_srcdir = @toplevel_srcdir@ # May be used by various substitution variables. diff --git a/libstdc++-v3/testsuite/Makefile.in b/libstdc++-v3/testsuite/Makefile.in index 37e8a3cf675..af161ea5d26 100644 --- a/libstdc++-v3/testsuite/Makefile.in +++ b/libstdc++-v3/testsuite/Makefile.in @@ -213,7 +213,6 @@ glibcxx_builddir = @glibcxx_builddir@ glibcxx_localedir = @glibcxx_localedir@ glibcxx_prefixdir = @glibcxx_prefixdir@ glibcxx_srcdir = @glibcxx_srcdir@ -glibcxx_thread_h = @glibcxx_thread_h@ glibcxx_toolexecdir = @glibcxx_toolexecdir@ glibcxx_toolexeclibdir = @glibcxx_toolexeclibdir@ gxx_include_dir = @gxx_include_dir@ @@ -253,6 +252,7 @@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +toplevel_builddir = @toplevel_builddir@ toplevel_srcdir = @toplevel_srcdir@ AUTOMAKE_OPTIONS = nostdinc RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir -- cgit v1.2.1