Commit Graph

596 Commits

Author SHA1 Message Date
maxim
7b9c5e1df6 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
davidxu
28aa53a45c Export offsets of thread signal pending set and signal mask for debugger. 2006-05-17 04:59:59 +00:00
davidxu
bbcf536040 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
delphij
cf4eda6001 Unexpand TAILQ_FIRST(foo) == NULL to TAILQ_EMPTY.
Ok'ed by:	davidxu
2006-04-13 03:09:34 +00:00
ru
450f399135 Install shared libpthread library into /lib; needed by some
/sbin programs.
2006-04-12 19:42:20 +00:00
des
590f74742c Bring libpthread up to WARNS level 2.
Reviewed by:	deischen
2006-03-29 05:38:19 +00:00
des
91d320d3aa Fix prototype mismatch and use of un-namespaced pthread functions. 2006-03-28 21:50:12 +00:00
deischen
776daae39d 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
deischen
1b17c00bde Suuply the name of the version map and let bsd.lib.mk supply
the link arguments.
2006-03-16 15:17:47 +00:00
deischen
cc69a08fbf 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
deischen
6401ef60bd 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
deischen
e586a0042e 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
deischen
2c3357a0a6 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
deischen
4dd473489e Eliminate a race condition in timed waits (cv, mutex, and sleeps).
MFC Candidate.

PR:	93592
2006-02-23 21:34:08 +00:00
deischen
63bc390672 Don't forget to initialize a tailq before using it.
MFC candidate
Noticed by:	luoqi
2006-02-16 01:33:36 +00:00
jasone
e30d92806f 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
jasone
3668a2e494 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
9105db3d27 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
d7ead39c65 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
3886f95485 o Include <string.h>
o  Make this ILP32/LP64 clean: cast pointers to long.
2005-11-19 04:45:15 +00:00
marcel
bfb066610e Fix typo: s/_LIBC_R/_LIBC_R_/ 2005-11-19 04:43:29 +00:00
davidxu
a9cb4a5684 Include files thr_condattr_pshared.c and thr_mattr_pshare.c. 2005-10-24 05:48:32 +00:00
davidxu
ea2d656f5a Add functions pthread_mutexattr_setpshared and pthread_mutexattr_getpshared. 2005-10-24 05:35:40 +00:00
davidxu
89731ba9fc Add function pthread_condattr_setpshared and pthread_condattr_getpshared. 2005-10-24 05:35:14 +00:00
brian
07adfc3d98 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
stefanf
be47cc4f82 Include needed headers that were obtained through <pthread.h>. Sort headers
while here.
2005-09-01 15:21:23 +00:00
deischen
91ca27dcf8 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
deischen
64b6610e61 Handle failure to malloc() part of the thread structure.
PR:	83457
2005-08-29 13:49:18 +00:00
deischen
edebe2a2bd 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
stefanf
cb1c3eea78 - 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
deischen
c0c21f6ca7 Add a cancellation point for usleep(). 2005-08-03 00:48:13 +00:00
deischen
f0435773fa Remove an unused variable. 2005-07-29 21:49:47 +00:00
deischen
46ccea61c3 Catch up with the atomic_FOO_ptr() changes and silence a few warnings. 2005-07-29 21:06:09 +00:00
kensmith
f97f77429f 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
db8830bc2d 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
davidxu
fab6f17360 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
408a98eda0 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
03d84df307 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
cognet
c7b04f713a Use the new atomic_cmpset_32(). 2005-04-07 22:06:05 +00:00
davidxu
17f1ca4d9b Eliminate plt relocation for kse_switchin. 2005-03-21 23:10:35 +00:00
delphij
55c4c85b99 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
cognet
23a2642656 Bring in a more healthy version of the libpthread for arm, which uses
ARM_TP_ADDRESS.
2005-02-26 19:06:49 +00:00
deischen
d249e2f25d 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
deischen
80b24bb8d5 Set the default guardsize and stacksize in the default thread
attribute when the library is initialized.
2005-02-15 15:02:11 +00:00
deischen
b082404539 Increase the default stacksizes:
32-bit		64-bit
main thread	  2MB		  4MB
other threads	  1MB		  2MB
2005-02-13 18:38:06 +00:00
deischen
8fe8e68e76 Don't panic when sigsuspend is interrupted by a cancellation.
PR:	75273
2004-12-19 23:23:43 +00:00
deischen
a5b13ff571 Use a generic way to back threads out of wait queues when handling
signals instead of having more intricate knowledge of thread state
within signal handling.

Simplify signal code because of above (by David Xu).

Use macros for libpthread usage of pthread_cleanup_push() and
pthread_cleanup_pop().  This removes some instances of malloc()
and free() from the semaphore and pthread_once() implementations.

When single threaded and forking(), make sure that the current
thread's signal mask is inherited by the forked thread.

Use private mutexes for libc and libpthread.  Signals are
deferred while threads hold private mutexes.  This fix also
breaks www/linuxpluginwrapper; a patch that fixes it is at
http://people.freebsd.org/~deischen/kse/linuxpluginwrapper.diff

Fix race condition in condition variables where handling a
signal (pthread_kill() or kill()) may not see a wakeup
(pthread_cond_signal() or pthread_cond_broadcast()).

In collaboration with:	davidxu
2004-12-18 18:07:37 +00:00
peter
09f7cb0cec i386_set_ldt() is not available when running 32 bit binaries on amd64
kernels.  Use the recently exposed direct-set routines instead.  This is
only activated for when we compile i386 support libraries on amd64.
2004-11-06 03:35:51 +00:00
peter
1028f02dbd Cosmetic tweaks to reduce diffs to the i386 counterpart. 2004-11-06 03:33:19 +00:00
cognet
2310011fe2 Partial support of KSE for arm. 2004-11-05 23:49:21 +00:00