Commit Graph

255 Commits

Author SHA1 Message Date
sobomax
7db199851c Add thread-safe wrapper for fpathconf(2) syscall.
Reviewed by:	jlemon
2000-09-19 18:01:03 +00:00
jasone
8f49d9a949 The second call to _thread_kern_sig_defer() in sem_post() should be a call
to _thread_kern_sig_undefer().
2000-08-23 07:59:50 +00:00
alfred
c90f528c48 Fix an off-by-one error in the recursive mutex handling that made it
prematurely release recursive mutexes.

Test case provided by: Bradley T. Hughes <bhughes@trolltech.com>
Reviewed by: deischen
2000-08-13 01:30:36 +00:00
jasone
fc5a57416d kevent() is not a POSIX cancellation point, so _kevent() need not be
defined.

Remove some unnecessary header file inclusions.
2000-08-08 00:12:35 +00:00
jlemon
4cc352512a Add wrapper for kevent() syscall
Noted as missing by: nicolas.leonard@animaths.com
2000-08-07 16:51:56 +00:00
jasone
a8691b8420 Make sem_post() safe to call from within a signal handler, as required by
POSIX/SUSv2.
2000-08-01 21:19:09 +00:00
dfr
a8bebf2b2d Call _thread_init() from pthread_once() if it has not already been called.
This fixes a segfault in some C++ programs which use exceptions before
main() has been called (i.e. from global constructors).

Reviewed by: deischen
2000-07-21 09:31:13 +00:00
jasone
531e62c825 pthread_once --> pthread_once_t. 2000-07-19 16:38:07 +00:00
jasone
3006cee4d8 Change my email address in the copyright notices for the sake of consistency
(jasone@canonware.com --> jasone@freebsd.org).
2000-07-18 01:38:19 +00:00
jasone
fa7c7acbf9 Deal correctly with statically initialized condition variables in
pthread_cond_signal(), pthread_cond_broadcast(), and pthread_cond_timedwait().

Do not dump core in pthread_cond_timedwait() (due to a NULL pointer
dereference) if attempting to wait on an uninitialized condition variable.

PR:	bin/18099
2000-07-17 22:55:05 +00:00
jasone
210624f121 Reshuffle the SEE ALSO section.
Prompted by:	sheldonh
2000-07-17 22:33:32 +00:00
jasone
a5e8ea1009 Remove DEBUG_FLAGS=-g3, which never should have been committed. 2000-07-05 16:21:42 +00:00
jasone
07f1aa63b8 Fix typo in SEE ALSO section. 2000-06-28 03:15:21 +00:00
jasone
685b55093c If multiple threads are blocked in sigwait() for the same signal that does
not have a user-supplied signal handler, when a signal is delivered, one
thread will receive the signal, and then the code reverts to having no
signal handler for the signal.  This can leave the other sigwait()ing
threads stranded permanently if the signal is later ignored, or can result
in process termination when the process should have delivered the signal to
one of the threads in sigwait().

To fix this problem, maintain a count of sigwait()ers for each signal that
has no default signal handler.  Use the count to correctly install/uninstall
dummy signal handlers.

Reviewed by:	deischen
2000-06-27 21:30:16 +00:00
jasone
9f479e9f39 pthread_mutex_lock(), pthread_cond_trywait(), and pthread_cond_wait() are
not allowed to return EINTR, but use of pthread_suspend_np() could cause
EINTR to be returned.  To fix this, restructure pthread_suspend_np() so that
it does not interrupt a thread that is waiting on a mutex or condition, and
keep enough state around that pthread_resume_np() can fix things up
afterwards.

Reviewed by:	deischen
2000-06-14 17:17:41 +00:00
chris
ef06afc4d3 Fix a misspelling: undefied -> undefined 2000-05-27 22:02:32 +00:00
jake
961b97d434 Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by:		msmith and others
2000-05-26 02:09:24 +00:00
jake
d93fbc9916 Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by:	phk
Reviewed by:	phk
Approved by:	mdodd
2000-05-23 20:41:01 +00:00
jasone
28fde4831e Fix a memory leak. pthread_set_name_np() allocates space for a name, but
was not deallocating space for the previous name, if any.

PR:	misc/18504
2000-05-16 22:08:14 +00:00
jasone
e3cda7421d Fix a memory leak. pthread_set_name_np() allocates space for a name, but
_thread_gc() was not deallocating it.

PR:	misc/18504
2000-05-16 21:57:12 +00:00
phantom
8c193b4282 add MLINKS: pthread_testcancel(3) -> pthread_setcanceltype(3) 2000-05-12 09:59:44 +00:00
bde
eae1aa7098 "Fixed" missing include in synopsis. POSIX.1-1996 only specifies
including <signal.h>, but that must be a bug in POSIX.1, because it
also specifies that the relevant prototype is [only] in <pthread.h>.
2000-05-11 16:13:18 +00:00
bde
5e51fa49c7 Fixed misspelling of a struct tag in a function parameter type. 2000-05-11 16:03:38 +00:00
bde
8e84288c32 Fixed missing consts for function parameters, so that the code matches
the man page and POSIX.1.  Fixed nearby misformatting.  Fixed a missing
prototype.
2000-05-11 15:57:17 +00:00
sheldonh
14e9cd73ea Fix miscellaneous mdoc macro argument limit infringements.
PR:		18465
Reported by:	Kazu TAKAMUNE <takamune@avrl.mei.co.jp>
2000-05-09 14:02:06 +00:00
phantom
a477158490 mdoc(7) cleanup:
. use real function names as `.Nm' macro argument in NAME section. It allows
them to appear in apropos(1) or whatis(1) output.

. replace empty lines with `.Pp' macro.

. replace hardcoded standard names with their `.St' macro equivalents.

. sort cross references in SEE ALSO section
2000-05-04 08:05:45 +00:00
jasone
2ba660079d Add missing .El macro. 2000-05-03 08:50:43 +00:00
jasone
03d029f134 Add missing man pages. Fix various compliance bugs, mostly having to do with
error return values.  Implement pthread_mutexattr_gettype().

PR:		docs/16537, docs/17538
2000-05-02 06:51:40 +00:00
jasone
f89de11e93 Add a wrapper for the sendfile() system call.
PR:		bin/17366
2000-04-27 00:59:44 +00:00
jasone
83086c2885 Add test to detect propagation of cancellation points within libc_r. 2000-04-26 23:25:58 +00:00
jasone
b1932c6651 Automated regression test harness for libc_r. Existing tests are integrated,
a new test for POSIX semaphores was added, and examples of harness usage are
included.
2000-04-24 21:07:45 +00:00
phantom
c8cd1c858c Introduce .Lb macro to libc_r manpages. 2000-04-22 15:50:29 +00:00
jasone
c35fe5e157 Explicitly include sys/cdefs.h to get the definition of __strong_reference(),
rather than getting lucky due to header dependencies.
2000-03-18 22:36:46 +00:00
deischen
228266df11 Fix pthread_suspend_np/pthread_resume_np. For the record, suspending a
thread waiting on an event (I/O, condvar, etc) will, when resumed using
pthread_resume_np, return with EINTR.  For example, suspending and resuming
a thread blocked on read() will not requeue the thread for the read, but
will return -1 with errno = EINTR.  If the suspended thread is in a critical
region, the thread is suspended as soon as it leaves the critical region.

Fix a bogon in pthread_kill() where a signal was being delivered twice
to threads waiting in sigwait().

Reported by (suspend/resume bug):	jdp
Reviewed by:	jasone
2000-03-15 13:59:27 +00:00
sheldonh
329223e6f2 Remove single-space hard sentence breaks. These degrade the quality
of the typeset output, tend to make diffs harder to read and provide
bad examples for new-comers to mdoc.
2000-03-02 09:14:21 +00:00
ru
f7be466376 Fix the installworld breakage from rev 1.9.
Submitted by:	reg
Reviewed by:	ru
Approved by:	jasone (rev 1.9)
Pointy hat to:	unfurl
2000-02-18 13:21:16 +00:00
unfurl
3e33e82f1d fixed missing trailing \
Submitted by:	Thimble Smith <tim@mysql.com>
2000-02-18 05:31:26 +00:00
unfurl
cbb193fe52 Adds missing symlinks for pthread related manpages.
PR:		16537
Submitted by:	AnarCat <beaupran@iro.umontreal.ca>
Approved by:	jasone
2000-02-18 02:26:27 +00:00
jasone
f2f7c466a9 For errors, return -1 and set errno to indicate the error type, rather than
returning the error directly.

For sem_post(), make sure that the correct thread is woken up.  This has
unfortunate performance implications, but is necessary for POSIX compliance.

Approved by:	jkh
2000-02-16 19:34:53 +00:00
jasone
940003aae4 Add man pages for the sem_*() functions.
Approved by:	jkh
2000-02-16 19:31:53 +00:00
jasone
c339e807cc Use __strong_reference() instead of __weak_reference() to assure that the
weak symbols of the same name are not used.
2000-01-29 22:53:55 +00:00
jasone
13ebb10b60 Use _fcntl() (not fcntl()) inside of fcntl().
Reported by:	green
2000-01-28 22:10:27 +00:00
jasone
8abe2a2d86 Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(),
just use _foo() <-- foo().  In the case of a libpthread that doesn't do
call conversion (such as linuxthreads and our upcoming libpthread), this
is adequate.  In the case of libc_r, we still need three names, which are
now _thread_sys_foo() <-- _foo() <-- foo().

Convert all internal libc usage of: aio_suspend(), close(), fsync(), msync(),
nanosleep(), open(), fcntl(), read(), and write() to _foo() instead of foo().

Remove all internal libc usage of: creat(), pause(), sleep(), system(),
tcdrain(), wait(), and waitpid().

Make thread cancellation fully POSIX-compliant.

Suggested by:	deischen
2000-01-27 23:07:25 +00:00
jasone
662c778ddd Fix millisecond to nanosecond conversion.
PR:		misc/16245
2000-01-22 09:15:15 +00:00
jasone
d28faf45be Minor *jmp() cleanups. 2000-01-20 21:53:59 +00:00
jasone
3daa9aa719 Add sem_*() functions. Named semaphores and process-shared semaphores
are not supported by this implementation, and the error return values
from sem_init(), sem_open(), sem_close(), and sem_unlink() reflect this.

Approved by:	jkh
2000-01-20 07:54:49 +00:00
jasone
3d70640506 Do signal deferral for pthread_kill() as it was done in the old days.
Submitted by:	deischen
2000-01-20 04:46:52 +00:00
jasone
0b9957ff21 Implement continuations to correctly handle [sig|_]longjmp() inside of a
signal handler.  Explicitly check for jumps to anywhere other than the
current stack, since such jumps are undefined according to POSIX.

While we're at it, convert thread cancellation to use continuations, since
it's cleaner than the original cancellation code.

Avoid delivering a signal to a thread twice.  This was a pre-existing bug,
but was likely unexposed until these other changes were made.

Defer signals generated by pthread_kill() so that they can be delivered on
the appropriate stack.  deischen claims that this is unnecessary, which is
likely true, but without this change, pthread_kill() can cause undefined
priority queue states and/or PANICs in [sig|_]longjmp(), so I'm leaving
this in for now.  To compile this code out and exercise the bug, define
the _NO_UNDISPATCH cpp macro.  Defining _PTHREADS_INVARIANTS as well will
cause earlier crashes.

PR:			kern/14685
Collaboration with:	deischen
2000-01-19 07:04:50 +00:00
deischen
17c111ba77 Properly initialize the last active time of the initial thread. This fixes
the case that a CPU hungry main thread is prevented from being preempted
due to a negative calculation of its time slice.

Reported by:	Alexander Litvin <archer@lucky.net>
2000-01-18 11:35:25 +00:00
jasone
4b4a2e733a Track libc's three-tier symbol naming. libc_r must currently implement
the _libc_*() entry points and add *() weak aliases.  This will all
change for the better when libc_r becomes libpthread.
2000-01-12 09:28:58 +00:00