re PR boehm-gc/34544 (pthread_default_stacksize_np failed.)
PR boehm-gc/34544 * gthr-posix.h (__gthread_active_init): Delete. (__gthread_active_p): Do activity check here. Don't include errno.h on hppa-hpux. Update comment. * gthr-posix95.h (__gthread_active_init): Delete. (__gthread_active_p): Do activity check here. Don't include errno.h on hppa-hpux. Update comment. * config.gcc (hppa[12]*-*-hpux11*): Define extra_parts. * config/pa/pa64-hpux.h (LIB_SPEC): When -static is specified, only add -lpthread when -mt or -pthread is specified. * config/pa/pa-hpux11.h (LIB_SPEC): likewise. (LINK_GCC_C_SEQUENCE_SPEC): Define. * config/pa/t-pa-hpux11 (LIBGCCSTUB_OBJS): Define. (stublib.c, pthread_default_stacksize_np-stub.o, pthread_mutex_lock-stub.o, pthread_mutex_unlock-stub.o, $(T)libgcc_stub.a): Add methods. * config/pa/t-pa64 (LIBGCCSTUB_OBJS): Add pthread stubs. (stublib.c, pthread_default_stacksize_np-stub.o, pthread_mutex_lock-stub.o, pthread_mutex_unlock-stub.o): Add methods. * config/pa/stublib.c (pthread_default_stacksize_np, pthread_mutex_lock, pthread_mutex_unlock): New stubs. From-SVN: r163461
This commit is contained in:
parent
11aa257739
commit
8c157f90f9
9 changed files with 144 additions and 71 deletions
|
@ -1,3 +1,27 @@
|
|||
2010-08-22 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
|
||||
|
||||
PR boehm-gc/34544
|
||||
* gthr-posix.h (__gthread_active_init): Delete.
|
||||
(__gthread_active_p): Do activity check here.
|
||||
Don't include errno.h on hppa-hpux. Update comment.
|
||||
* gthr-posix95.h (__gthread_active_init): Delete.
|
||||
(__gthread_active_p): Do activity check here.
|
||||
Don't include errno.h on hppa-hpux. Update comment.
|
||||
* config.gcc (hppa[12]*-*-hpux11*): Define extra_parts.
|
||||
* config/pa/pa64-hpux.h (LIB_SPEC): When -static is specified, only
|
||||
add -lpthread when -mt or -pthread is specified.
|
||||
* config/pa/pa-hpux11.h (LIB_SPEC): likewise.
|
||||
(LINK_GCC_C_SEQUENCE_SPEC): Define.
|
||||
* config/pa/t-pa-hpux11 (LIBGCCSTUB_OBJS): Define.
|
||||
(stublib.c, pthread_default_stacksize_np-stub.o,
|
||||
pthread_mutex_lock-stub.o, pthread_mutex_unlock-stub.o,
|
||||
$(T)libgcc_stub.a): Add methods.
|
||||
* config/pa/t-pa64 (LIBGCCSTUB_OBJS): Add pthread stubs.
|
||||
(stublib.c, pthread_default_stacksize_np-stub.o,
|
||||
pthread_mutex_lock-stub.o, pthread_mutex_unlock-stub.o): Add methods.
|
||||
* config/pa/stublib.c (pthread_default_stacksize_np, pthread_mutex_lock,
|
||||
pthread_mutex_unlock): New stubs.
|
||||
|
||||
2010-08-22 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
* Makefile.in (gccspec.o, cppspec.o): Update dependencies.
|
||||
|
|
|
@ -1106,6 +1106,7 @@ hppa[12]*-*-hpux11*)
|
|||
else
|
||||
tmake_file="$tmake_file pa/t-slibgcc-dwarf-ver"
|
||||
fi
|
||||
extra_parts="libgcc_stub.a"
|
||||
case x${enable_threads} in
|
||||
x | xyes | xposix )
|
||||
thread_file=posix
|
||||
|
|
|
@ -121,11 +121,16 @@ along with GCC; see the file COPYING3. If not see
|
|||
#undef LIB_SPEC
|
||||
#define LIB_SPEC \
|
||||
"%{!shared:\
|
||||
%{static|mt|pthread:%{fopenmp:%{static:-a archive_shared} -lrt\
|
||||
%{static:-a archive}} -lpthread} -lc\
|
||||
%{fopenmp:%{static:-a archive_shared} -lrt %{static:-a archive}}\
|
||||
%{mt|pthread:-lpthread} -lc\
|
||||
%{static:%{!nolibdld:-a archive_shared -ldld -a archive -lc}}}\
|
||||
%{shared:%{mt|pthread:-lpthread}}"
|
||||
|
||||
/* The libgcc_stub.a library needs to come last. */
|
||||
#undef LINK_GCC_C_SEQUENCE_SPEC
|
||||
#define LINK_GCC_C_SEQUENCE_SPEC \
|
||||
"%G %L %G %{!nostdlib:%{!nodefaultlibs:%{!shared:-lgcc_stub}}}"
|
||||
|
||||
#undef STARTFILE_SPEC
|
||||
#define STARTFILE_SPEC \
|
||||
"%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:crt0%O%s}} \
|
||||
|
|
|
@ -59,35 +59,35 @@ along with GCC; see the file COPYING3. If not see
|
|||
#if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GNU_LD)
|
||||
#define LIB_SPEC \
|
||||
"%{!shared:\
|
||||
%{!p:%{!pg:%{static|mt|pthread:%{fopenmp:%{static:-a shared} -lrt\
|
||||
%{static:-a archive}} -lpthread} -lc\
|
||||
%{!p:%{!pg:%{fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\
|
||||
%{mt|pthread:-lpthread} -lc\
|
||||
%{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
|
||||
%{p:%{!pg:%{static:%{!mhp-ld:-a shared}%{mhp-ld:-a archive_shared}}\
|
||||
-lprof %{static:-a archive}\
|
||||
%{static|mt|pthread:%{fopenmp:%{static:-a shared} -lrt\
|
||||
%{static:-a archive}} -lpthread} -lc\
|
||||
%{fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\
|
||||
%{mt|pthread:-lpthread} -lc\
|
||||
%{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
|
||||
%{pg:%{static:%{!mhp-ld:-a shared}%{mhp-ld:-a archive_shared}}\
|
||||
-lgprof %{static:-a archive}\
|
||||
%{static|mt|pthread:%{fopenmp:%{static:-a shared} -lrt\
|
||||
%{static:-a archive}} -lpthread} -lc\
|
||||
%{fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\
|
||||
%{mt|pthread:-lpthread} -lc\
|
||||
%{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
|
||||
%{shared:%{mt|pthread:-lpthread}}"
|
||||
#else
|
||||
#define LIB_SPEC \
|
||||
"%{!shared:\
|
||||
%{!p:%{!pg:%{static|mt|pthread:%{fopenmp:%{static:-a shared} -lrt\
|
||||
%{static:-a archive}} -lpthread} -lc\
|
||||
%{!p:%{!pg:%{fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\
|
||||
%{mt|pthread:-lpthread} -lc\
|
||||
%{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
|
||||
%{p:%{!pg:%{static:%{mgnu-ld:-a shared}%{!mgnu-ld:-a archive_shared}}\
|
||||
-lprof %{static:-a archive}\
|
||||
%{static|mt|pthread:%{fopenmp:%{static:-a shared} -lrt\
|
||||
%{static:-a archive}} -lpthread} -lc\
|
||||
%{fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\
|
||||
%{mt|pthread:-lpthread} -lc\
|
||||
%{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
|
||||
%{pg:%{static:%{mgnu-ld:-a shared}%{!mgnu-ld:-a archive_shared}}\
|
||||
-lgprof %{static:-a archive}\
|
||||
%{static|mt|pthread:%{fopenmp:%{static:-a shared} -lrt\
|
||||
%{static:-a archive}} -lpthread} -lc\
|
||||
%{fopenmp:%{static:-a shared} -lrt %{static:-a archive}}\
|
||||
%{mt|pthread:-lpthread} -lc\
|
||||
%{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
|
||||
%{shared:%{mt|pthread:-lpthread}}"
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Stub functions.
|
||||
Copyright (C) 2006, 2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
|
@ -56,3 +56,33 @@ _Jv_RegisterClasses (void *p)
|
|||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_pthread_default_stacksize_np
|
||||
int pthread_default_stacksize_np (unsigned long __attribute__((unused)),
|
||||
unsigned long *);
|
||||
int
|
||||
pthread_default_stacksize_np (unsigned long new, unsigned long *old)
|
||||
{
|
||||
if (old)
|
||||
*old = 0;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_pthread_mutex_lock
|
||||
int pthread_mutex_lock (void * __attribute__((unused)));
|
||||
int
|
||||
pthread_mutex_lock (void *p)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef L_pthread_mutex_unlock
|
||||
int pthread_mutex_unlock (void * __attribute__((unused)));
|
||||
int
|
||||
pthread_mutex_unlock (void *p)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,2 +1,26 @@
|
|||
TARGET_LIBGCC2_CFLAGS = -fPIC -frandom-seed=fixed-seed
|
||||
LIB2FUNCS_EXTRA=lib2funcs.asm quadlib.c
|
||||
LIBGCCSTUB_OBJS = pthread_default_stacksize_np-stub.o \
|
||||
pthread_mutex_lock-stub.o \
|
||||
pthread_mutex_unlock-stub.o
|
||||
|
||||
stublib.c: $(srcdir)/config/pa/stublib.c
|
||||
rm -f stublib.c
|
||||
cp $(srcdir)/config/pa/stublib.c .
|
||||
|
||||
pthread_default_stacksize_np-stub.o: stublib.c $(GCC_PASSES)
|
||||
$(GCC_FOR_TARGET) -c -O2 -DL_pthread_default_stacksize_np stublib.c \
|
||||
-o pthread_default_stacksize_np-stub.o
|
||||
|
||||
pthread_mutex_lock-stub.o: stublib.c $(GCC_PASSES)
|
||||
$(GCC_FOR_TARGET) -c -O2 -DL_pthread_mutex_lock stublib.c \
|
||||
-o pthread_mutex_lock-stub.o
|
||||
|
||||
pthread_mutex_unlock-stub.o: stublib.c $(GCC_PASSES)
|
||||
$(GCC_FOR_TARGET) -c -O2 -DL_pthread_mutex_unlock stublib.c \
|
||||
-o pthread_mutex_unlock-stub.o
|
||||
|
||||
$(T)libgcc_stub.a: $(LIBGCCSTUB_OBJS)
|
||||
-rm -rf $(T)libgcc_stub.a
|
||||
$(AR) rc $(T)libgcc_stub.a $(LIBGCCSTUB_OBJS)
|
||||
$(RANLIB) $(T)libgcc_stub.a
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (C) 2000, 2001, 2002, 2004, 2006,
|
||||
# 2007 Free Software Foundation, Inc.
|
||||
# 2007, 2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of GCC.
|
||||
#
|
||||
|
@ -19,7 +19,10 @@
|
|||
|
||||
TARGET_LIBGCC2_CFLAGS = -fPIC -Dpa64=1 -DELF=1 -mlong-calls
|
||||
LIB2FUNCS_EXTRA = quadlib.c
|
||||
LIBGCCSTUB_OBJS = rfi-stub.o dfi-stub.o jvrc-stub.o cxaf-stub.o
|
||||
LIBGCCSTUB_OBJS = rfi-stub.o dfi-stub.o jvrc-stub.o cxaf-stub.o \
|
||||
pthread_default_stacksize_np-stub.o \
|
||||
pthread_mutex_lock-stub.o \
|
||||
pthread_mutex_unlock-stub.o
|
||||
|
||||
stublib.c: $(srcdir)/config/pa/stublib.c
|
||||
rm -f stublib.c
|
||||
|
@ -41,6 +44,18 @@ jvrc-stub.o: stublib.c $(GCC_PASSES)
|
|||
$(GCC_FOR_TARGET) -c -O2 -DL_Jv_RegisterClasses stublib.c \
|
||||
-o jvrc-stub.o
|
||||
|
||||
pthread_default_stacksize_np-stub.o: stublib.c $(GCC_PASSES)
|
||||
$(GCC_FOR_TARGET) -c -O2 -DL_pthread_default_stacksize_np stublib.c \
|
||||
-o pthread_default_stacksize_np-stub.o
|
||||
|
||||
pthread_mutex_lock-stub.o: stublib.c $(GCC_PASSES)
|
||||
$(GCC_FOR_TARGET) -c -O2 -DL_pthread_mutex_lock stublib.c \
|
||||
-o pthread_mutex_lock-stub.o
|
||||
|
||||
pthread_mutex_unlock-stub.o: stublib.c $(GCC_PASSES)
|
||||
$(GCC_FOR_TARGET) -c -O2 -DL_pthread_mutex_unlock stublib.c \
|
||||
-o pthread_mutex_unlock-stub.o
|
||||
|
||||
$(T)libgcc_stub.a: $(LIBGCCSTUB_OBJS)
|
||||
-rm -rf $(T)libgcc_stub.a
|
||||
$(AR) rc $(T)libgcc_stub.a $(LIBGCCSTUB_OBJS)
|
||||
|
|
|
@ -260,47 +260,34 @@ __gthread_active_p (void)
|
|||
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 pthread
|
||||
provided for checking whether an application is linked to a shared pthread
|
||||
library or not. However, these interfaces aren't available in early
|
||||
libc versions. We also can't use pthread_once as some libc versions
|
||||
call the init function. So, we use pthread_create to check whether it
|
||||
is possible to create a thread or not. The stub implementation returns
|
||||
the error number ENOSYS. */
|
||||
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__)
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
static volatile int __gthread_active = -1;
|
||||
|
||||
static void __gthread_active_init (void) __attribute__((noinline));
|
||||
static void
|
||||
__gthread_active_init (void)
|
||||
{
|
||||
static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
size_t __s;
|
||||
|
||||
__gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
|
||||
if (__gthread_active < 0)
|
||||
{
|
||||
pthread_default_stacksize_np (0, &__s);
|
||||
__gthread_active = __s ? 1 : 0;
|
||||
}
|
||||
__gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
/* 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))
|
||||
{
|
||||
__gthread_active_init ();
|
||||
pthread_default_stacksize_np (0, &__s);
|
||||
__gthread_active = __s ? 1 : 0;
|
||||
__gthread_active_latest_value = __gthread_active;
|
||||
}
|
||||
|
||||
|
|
|
@ -184,47 +184,34 @@ __gthread_active_p (void)
|
|||
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 pthread
|
||||
provided for checking whether an application is linked to a shared pthread
|
||||
library or not. However, these interfaces aren't available in early
|
||||
libc versions. We also can't use pthread_once as some libc versions
|
||||
call the init function. So, we use pthread_create to check whether it
|
||||
is possible to create a thread or not. The stub implementation returns
|
||||
the error number ENOSYS. */
|
||||
pthread 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__)
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
static volatile int __gthread_active = -1;
|
||||
|
||||
static void __gthread_active_init (void) __attribute__((noinline));
|
||||
static void
|
||||
__gthread_active_init (void)
|
||||
{
|
||||
static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
size_t __s;
|
||||
|
||||
__gthrw_(pthread_mutex_lock) (&__gthread_active_mutex);
|
||||
if (__gthread_active < 0)
|
||||
{
|
||||
pthread_default_stacksize_np (0, &__s);
|
||||
__gthread_active = __s ? 1 : 0;
|
||||
}
|
||||
__gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
/* 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))
|
||||
{
|
||||
__gthread_active_init ();
|
||||
pthread_default_stacksize_np (0, &__s);
|
||||
__gthread_active = __s ? 1 : 0;
|
||||
__gthread_active_latest_value = __gthread_active;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue