Commit Graph

602 Commits

Author SHA1 Message Date
David Xu
6f54e82927 If a thread was detached, return EINVAL instead, the error code
is also returned by pthread_detach() if a thread was already
detached, the error code was already documented:

>    [EINVAL]	The implementation has detected that the value speci-
>		fied by thread does not refer to a joinable thread.
2006-11-28 11:05:31 +00:00
Marcel Moolenaar
4d630a8f11 Stylize:
o  avoid using a global register variable.
o  redefine struct ia64_tp as a union. We don't have to get to the
   fields themselves. We just need it to be of the right size with
   the right alignment.
2006-09-01 21:25:22 +00:00
Marcel Moolenaar
4c91d168a7 The ucontext is 16-byte aligned, which means that struct tcb is
16-byte aligned. Consequently, struct tcb is a multiple of 16
bytes in size. We need to make sure there's no padding after
struct ppc32_tp. We do this by explicitly adding the necessary
padding in front of it.
2006-09-01 19:13:36 +00:00
Marcel Moolenaar
5df93cb787 Stylize. Introduce ppc_{get|set}_tp() and ppc_{get|set}_tcb() to
abstract the magic that happens when deriving one or the other.
2006-09-01 17:52:13 +00:00
Marcel Moolenaar
20b18e870b Implement TLS. 2006-09-01 06:17:16 +00:00
Ruslan Ermilov
2b46c64c9c Remove alpha left-overs. 2006-08-22 08:03:01 +00:00
Maxim Konovalov
0295184c7e o Remove a cruft prevented libpthread sigaction(2) wrapper to
do its work for SIGINFO.  Always install libpthread signal handler
wrapper for SIGINFO even if user SIG_IGN's or SIG_DFL's it.

SIGINFO has a special meaning for libpthread: when LIBPTHREAD_DEBUG
enviroment variable defined it is used for dumping an information
about threads to /tmp/.

Reported by:	mi
Reviewed by:	deischen
MFC after:	2 weeks
2006-06-09 14:23:40 +00:00
David Xu
0eb14dbdd6 Export offsets of thread signal pending set and signal mask for debugger. 2006-05-17 04:59:59 +00:00
David Xu
7649f45c3e In order to let new binutils can compile it, replace movl with
movw for segment saving and restoring.

Submitted by: Diego 'Flameeyes' Petteno flameeyes at gentoo dot org
2006-05-07 08:19:04 +00:00
Xin LI
34562de4d5 Unexpand TAILQ_FIRST(foo) == NULL to TAILQ_EMPTY.
Ok'ed by:	davidxu
2006-04-13 03:09:34 +00:00
Ruslan Ermilov
84e709f1f1 Install shared libpthread library into /lib; needed by some
/sbin programs.
2006-04-12 19:42:20 +00:00
Dag-Erling Smørgrav
1e5e6f25c5 Bring libpthread up to WARNS level 2.
Reviewed by:	deischen
2006-03-29 05:38:19 +00:00
Dag-Erling Smørgrav
adb19548bd Fix prototype mismatch and use of un-namespaced pthread functions. 2006-03-28 21:50:12 +00:00
Daniel Eischen
2445cd7c11 Use the correct type for and argument. Recent changes to namespace.h
exposed this bug.

Reported by:	kris
2006-03-28 21:07:59 +00:00
Daniel Eischen
3618d8fe53 Suuply the name of the version map and let bsd.lib.mk supply
the link arguments.
2006-03-16 15:17:47 +00:00
Daniel Eischen
e62165c8b0 Add compatibility symbol maps. libpthread (.so.1 and .so.2)
used LIBTHREAD_1_0 as its version definition, but now needs
to define its symbols in the same namespace used by libc.
The compatibility hooks allows you to use libraries and
binaries built and linked to libpthread before libc was
built with symbol versioning.  The shims can be removed if
libpthread is given a version bump.

Reviewed by:	davidxu
2006-03-13 00:59:51 +00:00
Daniel Eischen
4f0d668324 Only catch SIGINFO (for dumping thread states) when LIBPTHREAD_DEBUG
is defined in the environment.

Requested by:	jmg & a few others
2006-03-06 05:02:28 +00:00
Daniel Eischen
f4cd2a5b5c Add some more pthread stubs so that librt can use them.
The thread jump table has been resorted, so you need to
keep libc, libpthread, and libthr in sync.

Submitted by:	xu
2006-03-05 18:10:28 +00:00
Daniel Eischen
c0addafac3 Fix a race condition introduced when redzones were added. Use an
atomic operation to return and adjust the stack.

Submitted by:	luoqi
2006-02-24 22:03:10 +00:00
Daniel Eischen
aa8eff60a3 Eliminate a race condition in timed waits (cv, mutex, and sleeps).
MFC Candidate.

PR:	93592
2006-02-23 21:34:08 +00:00
Daniel Eischen
9fcaf8a4ab Don't forget to initialize a tailq before using it.
MFC candidate
Noticed by:	luoqi
2006-02-16 01:33:36 +00:00
Jason Evans
90dc795234 Increase the number of spinlocks, since libc's malloc implementation is
about to significantly increase the number of spinlocks used.

Approved by:	markm (mentor)
2006-01-13 06:14:04 +00:00
Jason Evans
52828c0e9c In preparation for a new malloc implementation:
* Add posix_memalign().

  * Move calloc() from calloc.c to malloc.c.  Add a calloc() implementation in
    rtld-elf in order to make the loader happy (even though calloc() isn't
    used in rtld-elf).

  * Add _malloc_prefork() and _malloc_postfork(), and use them instead of
    directly manipulating __malloc_lock.

Approved by:	phk, markm (mentor)
2006-01-12 07:28:21 +00:00
Brian Somers
6632abc8dc For the ``#ifdef NOTYET'' code that allows calling non-async-safe
functions in the child after a fork() from a threaded process,
use __sys_setprocmask() rather than setprocmask() to keep our
signal handling sane.  Without this fix, signals are essentially
ignored in said child and things such as protection violations
result in an endless busy loop.

Reviewed by:	deischen
2006-01-03 15:34:27 +00:00
Marcel Moolenaar
49fa07a087 o Include <sys/time.h>
o  Make this ILP32/LP64 clean: cast pointers to long
o  Code conditional upon DEBUG must also be conditional
   upon _LIBC_R_
2005-11-19 04:47:06 +00:00
Marcel Moolenaar
dc2e8ca41b o Include <string.h>
o  Make this ILP32/LP64 clean: cast pointers to long.
2005-11-19 04:45:15 +00:00
Marcel Moolenaar
40edb45e59 Fix typo: s/_LIBC_R/_LIBC_R_/ 2005-11-19 04:43:29 +00:00
David Xu
710eb02de0 Include files thr_condattr_pshared.c and thr_mattr_pshare.c. 2005-10-24 05:48:32 +00:00
David Xu
3c86291f25 Add functions pthread_mutexattr_setpshared and pthread_mutexattr_getpshared. 2005-10-24 05:35:40 +00:00
David Xu
b21a55e2d6 Add function pthread_condattr_setpshared and pthread_condattr_getpshared. 2005-10-24 05:35:14 +00:00
Brian Somers
225721f00b Modify the code path of the ifdef NOTYET part of _kse_single_thread():
o  Don't reinitialise the atfork() handler list in the child.  We
   are meant to call the child handler, and on subsequent fork()s
   should call all three functions as normal.
o  Don't reinitialise the thread specific keyed data in the
   child after a fork.  Applications may require this for context.
o  Reinitialise curthread->tlflags after removing ourselves from
   (and reinitialising) the various internal thread lists.
o  Reinitialise __malloc_lock in the child after fork() (to balance
   our explicitly taking the lock prior to the fork()).

With these changes, it is possible to enable the NOTYET code in
thr_kern.c to allow the use of non-async-safe functions after
fork()ing from a threaded program.

Reviewed by:	Daniel Eischen <deischen@freebsd.org>
[_malloc_lock reinitialisation has since been moved to avoid polluting the
!NOTYET code]
2005-09-24 01:19:53 +00:00
Stefan Farfeleder
7e4cbc3a50 Include needed headers that were obtained through <pthread.h>. Sort headers
while here.
2005-09-01 15:21:23 +00:00
Daniel Eischen
f98418eb29 Allocate a thread's tcb last so it is easier to handle failures to
malloc() siginfo.

PR:	85468
2005-08-30 12:42:00 +00:00
Daniel Eischen
f12a8f9703 Handle failure to malloc() part of the thread structure.
PR:	83457
2005-08-29 13:49:18 +00:00
Daniel Eischen
c7c5df6fdb Don't attempt to initialize the rtld lock if it can't be malloc()'d.
PR:	83452
2005-08-29 13:47:42 +00:00
Stefan Farfeleder
ad7c49168f - Prefix MUTEX_TYPE_MAX with PTHREAD_ to avoid namespace pollution.
- Remove the macros MUTEX_TYPE_FAST and MUTEX_TYPE_COUNTING_FAST.

OK'ed by:	deischen
2005-08-19 21:31:42 +00:00
Daniel Eischen
7f2461f315 Add a cancellation point for usleep(). 2005-08-03 00:48:13 +00:00
Daniel Eischen
e059b9ce6c Remove an unused variable. 2005-07-29 21:49:47 +00:00
Daniel Eischen
ca7d07fa00 Catch up with the atomic_FOO_ptr() changes and silence a few warnings. 2005-07-29 21:06:09 +00:00
Ken Smith
a84020c2b9 Bump the shared library version number of all libraries that have not
been bumped since RELENG_5.

Reviewed by:	ru
Approved by:	re (not needed for commit check but in principle...)
2005-07-22 17:19:05 +00:00
Peter Wemm
3b4399f6a7 Clean out the leftovers from the i386_set_gsbase() TLS conversion.
Like on libthr, there is an i386_set_gsbase() stub implementation here
to avoid libc.so.5 issues.  This should likely be a weak symbol and I
expect this will be fixed soon.

Approved by:	re
2005-06-29 23:15:36 +00:00
David Xu
86a07ac068 Fix off-by-one nanosecond in macro TIMESPEC_ADD.
Reviewed by: deischen
Approved by: re (dwhite)
MFC after  : 4 days
2005-06-22 22:35:49 +00:00
Peter Wemm
1ec622fdd6 Remove the special _amd64_set_gsbase() code for #ifdef COMPAT_32BIT, now
that the amd64 kernel implements i386_get/set_gsbase().  All the rest of
the ldt backwards compat code should go away soon.
2005-04-26 20:41:48 +00:00
Peter Wemm
72a79166ea Use the i386_set_gsbase() syscall if it is implemented in the kernel.
This is a little hairy here because the allocation and usage of this
functionality is split into two places in libpthread.
2005-04-14 00:13:20 +00:00
Olivier Houchard
e0d6cac076 Use the new atomic_cmpset_32(). 2005-04-07 22:06:05 +00:00
David Xu
ab7f22e264 Eliminate plt relocation for kse_switchin. 2005-03-21 23:10:35 +00:00
Xin LI
12927a8513 Change the spin lock logic to a reasonable one. We should spin when
the lock is held by other thread, but not when nobody owns it.  According
to deischen@, this part of code will never be hit in our threads
library, since it does not use locks without wait/wakeup functions.

Spotted by:	mingyanguo via ChinaUnix.net forum
Reviewed by:	deischen
2005-02-27 17:45:55 +00:00
Olivier Houchard
788d6eeca0 Bring in a more healthy version of the libpthread for arm, which uses
ARM_TP_ADDRESS.
2005-02-26 19:06:49 +00:00
Daniel Eischen
0e963ec574 Somewhere along the line, tick accumulation for SA threads was
changed to use the statclock.  Make sure we calculate the value
of a tick correctly in userland.

Noticed by:	Kazuaki Oda <kaakun at highway dot ne dot jp>
2005-02-18 16:07:05 +00:00
Daniel Eischen
888ab0185e Set the default guardsize and stacksize in the default thread
attribute when the library is initialized.
2005-02-15 15:02:11 +00:00