Commit Graph

28 Commits

Author SHA1 Message Date
Mike Barcroft
07842325eb Use useconds_t' instead of u_int' or `unsigned int' where appropriate. 2002-12-29 00:59:09 +00:00
David E. O'Brien
ea8d448a92 Fix SCM ID's. 2002-02-01 00:57:29 +00:00
Daniel Eischen
d201fe46e3 Remove _THREAD_SAFE and make libc thread-safe by default by
adding (weak definitions to) stubs for some of the pthread
functions.  If the threads library is linked in, the real
pthread functions will pulled in.

Use the following convention for system calls wrapped by the
threads library:
	__sys_foo - actual system call
	_foo - weak definition to __sys_foo
	foo - weak definition to __sys_foo

Change all libc uses of system calls wrapped by the threads
library from foo to _foo.  In order to define the prototypes
for _foo(), we introduce namespace.h and un-namespace.h
(suggested by bde).  All files that need to reference these
system calls, should include namespace.h before any standard
includes, then include un-namespace.h after the standard
includes and before any local includes.  <db.h> is an exception
and shouldn't be included in between namespace.h and
un-namespace.h  namespace.h will define foo to _foo, and
un-namespace.h will undefine foo.

Try to eliminate some of the recursive calls to MT-safe
functions in libc/stdio in preparation for adding a mutex
to FILE.  We have recursive mutexes, but would like to avoid
using them if possible.

Remove uneeded includes of <errno.h> from a few files.

Add $FreeBSD$ to a few files in order to pass commitprep.

Approved by:	-arch
2001-01-24 13:01:12 +00:00
Jason Evans
9233c4d942 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
Jason Evans
929273386f Add three-tier symbol naming in support of POSIX thread cancellation
points.  For library functions, the pattern is __sleep() <--
_libc_sleep() <-- sleep().  The arrows represent weak aliases.  For
system calls, the pattern is _read() <-- _libc_read() <-- read().
2000-01-12 09:23:48 +00:00
Peter Wemm
7f3dea244c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
Bruce Evans
362f4dce74 Don't check for the unlikely case of useconds == 0 here. The kernel
checks it.

Fixed a style bug.
1997-11-20 15:13:20 +00:00
Andrey A. Chernov
7a54ede12f Back out part of OpenGroup specs about limiting max arg since it may break
compatibility.
1997-10-22 12:04:49 +00:00
Andrey A. Chernov
9a9098177b Changes in spirit of OpenGroup Singe Unix specs:
1) Limit max allowed argument to 1000000
2) Change return type from void to int to indicate premature termination
(by signal)
1997-10-22 10:55:49 +00:00
Andrey A. Chernov
c717c2d74c Add $Id 1997-10-17 09:40:08 +00:00
Andrey A. Chernov
49620c896c Cleanup #includes 1997-10-16 13:35:25 +00:00
Peter Wemm
6173688707 Remove old SIGALRM absorbing back-compat code. It wasn't working at all
for the entire time that it was there, so obviously nothing needs it
anymore.

Note, unix98/single-unix spec v2 says that usleep() returns an int rather
than a void, to indicate whether the entire time period elapsed (0) or an
error (eg: signal handler) interrupted it (returns -1, errno = EINTR)
It is probably useful to make this change but I'll test it locally first
to see if this will break userland programs [much]...

Reviewed by: ache, bde
1997-10-15 14:11:08 +00:00
Andrey A. Chernov
a85a54896e Oops, fix logic for previous commit 1997-08-14 06:46:44 +00:00
Andrey A. Chernov
3b3d0d1b49 Break loop if error != EINTR occurse or it can take forever with
time_remaining unchanged
1997-08-14 06:23:48 +00:00
Andrey A. Chernov
71936d097e Handle syscalls error return slightly better 1997-08-13 18:22:41 +00:00
Andrey A. Chernov
8d7bf613b2 Back out my installation of SIGALRM handler even if it is blocked
and return to previous Peter's variant.
POSIX says that this place is implementation defined and old variant allows
application block SIGALRM and sleep and not be killed by external SIGALRMs.
BTW, GNU sleep f.e. sleeps forever in blocked SIGALRM :-)
1997-08-12 19:14:54 +00:00
Andrey A. Chernov
1ddf325cda 1) Make usleep() terminateable by alarm (or ualarm) as supposed
historically
2) Fix end of time loop condition: && -> ||
1997-08-12 17:17:53 +00:00
Peter Wemm
925d069aa8 Make sleep() and usleep() "eat" any stray SIGALRM signals during the
lifetime of the call, just like the old implementation did.  Previously,
we were only eating them if the application did not call sleep()/usleep()
with SIGALRM masked.

Submitted by:	ache
1997-07-18 09:48:37 +00:00
Peter Wemm
be159dcaf7 Re-activate the nanosleep style using code, but with the signal handling
semantics of the old sleep for compatability with a few decades of expected
side effects.  Apache breaks if we just use nanosleep() for some reason,
here we use a new signanosleep() syscall which is kinda like a hybrid of
sigsuspend and nanosleep..

Reviewed by:  ache (and tested on his apache that was failing when
                    sleep used plain nanosleep)
1997-06-02 16:30:22 +00:00
Peter Wemm
0913e7ce8b Update the sleep(3)/usleep(3) code to use signanosleep(2) if compiled with
-DUSE_NANOSLEEP.  Also, seperate the code for _THREAD_SAFE so that it uses
the simpler threaded nanosleep() call in libc_r..  We don't go to the same
extremes for emulating traditional sleep semantics (ie: eating any SIGALRM
that might happen) which things like apache seem to depend on.
1997-06-01 09:27:03 +00:00
Peter Wemm
304e0890fc Update the nanosleep versions to set a SIGALRM handler while sleeping.
This appears to appease Apache, although depending on having sleep(3)
changing the SIGALRM handler is a bit bogus.
1997-05-18 10:57:49 +00:00
Peter Wemm
1823941071 if nanosleep returns too early, loop. usleep() does not have a return
value, it appears as though the semantics of usleep are that it doesn't
return early.  (only in the nanosleep code - the setitimer code does this
already)
1997-05-17 15:42:58 +00:00
Peter Wemm
fa0f63238b Allow conditional use (add -DUSE_NANOSLEEP) to CFLAGS of nanosleep() for
the backend of sleep(3) and usleep(3).  It's off by default until the
problem is fixed.
1997-05-17 11:40:58 +00:00
Alexander Langer
97ea6d475a Fix typo from previous commit (tsvsec --> tv_sec). 1996-09-23 03:54:53 +00:00
Nate Williams
34eeb76411 ts_sec -> tv_sec
ts_nsec -> tv_nsec
1996-09-20 06:06:28 +00:00
Julian Elischer
f70177e76e Reviewed by: julian and (hsu?)
Submitted by:	 John Birrel(L?)

changes for threadsafe operations
1996-01-22 00:02:33 +00:00
Poul-Henning Kamp
8b10240709 Minor cleanup, mostly unused vars and missing #includes. 1995-10-22 14:37:11 +00:00
Rodney W. Grimes
58f0484fa2 BSD 4.4 Lite Lib Sources 1994-05-27 05:00:24 +00:00