History log of /freebsd-9.3-release/lib/libc/gen/sleep.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 267654 19-Jun-2014 gjb

Copy stable/9 to releng/9.3 as part of the 9.3-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 225736 22-Sep-2011 kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by: re (implicit)


# 200150 05-Dec-2009 ed

Fix many "function declaration isn't a prototype" warnings in libc.

I've only fixed code that seems to be written by `us'. There are still
many warnings like this present in resolv/, rpc/, stdtime/ and yp/.


# 165903 08-Jan-2007 imp

Per Regents of the University of Calfornia letter, remove advertising
clause.

# If I've done so improperly on a file, please let me know.


# 90039 31-Jan-2002 obrien

Fix SCM ID's.


# 71579 24-Jan-2001 deischen

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


# 58126 16-Mar-2000 jasone

Take care to avoid having "strong" and "weak" symbols of the same name in
libc_r.


# 56698 27-Jan-2000 jasone

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


# 55837 12-Jan-2000 jasone

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().


# 50476 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 38938 08-Sep-1998 ache

restore rev 1.23 to give clear SIGALRM handling example, 68 years
are too long to affect real code


# 38878 06-Sep-1998 dillon

Reviewed by: Andrey A. Chernov <ache@nagual.pp.ru>, Doug Rabson <dfr@nlsystems.com>

Rewrote sleep() to remove int/long typing assumptions between the argument
to the function and the timespec structure.


# 38847 05-Sep-1998 jb

Use INT_MAX instead of LONG_MAX since the variable being compared
is an int, not a long.


# 30510 17-Oct-1997 ache

Fix LONG_MAX overflowing
Return seconds if errno other than EINTR
Add $Id
Submitted by: bde with minor optimization by me


# 30493 16-Oct-1997 ache

Copy time_to_sleep to time_remaining since it can be left
uninitialized if nanosleep returns early with agr error


# 30479 16-Oct-1997 ache

Cleanup #includes


# 30442 15-Oct-1997 peter

Give up on the "try and compensate for broken programs" cruft and revert
back to the original single nanosleep() implementation. This is POSIX and
Unix98 (aka single-unix spec v2) compliant behavior. If a program sets
alarm(2) or an interval timer (setitimer(2)) without a SIGALRM handler
being active, sleep(3) will no longer absorb it, and the program will get
what it asked for..... :-]

The original reason for this in the first place (apache) doesn't seem to
need it anymore, according to Andrey.

Reviewed by: ache, bde


# 28172 13-Aug-1997 ache

Back out itimerfix hack since nanosleep1 fixed now
Handle syscalls error return slightly better


# 28128 12-Aug-1997 ache

Rearrange itimerfix loop doing it inside SIGALRM handling section


# 28127 12-Aug-1997 ache

Solve itimerfix() problem completely by using loop in 100000000 secs chunks


# 28125 12-Aug-1997 ache

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 :-)


# 28107 12-Aug-1997 ache

Make itimerfix hack better: return the time we can't sleep at once


# 28033 10-Aug-1997 joerg

Hack^H^H^H^Hworkaround for itimerfix(9) gratuitously limiting the
acceptable range for tv_sec to the magic number 100000000 (which at
least ought to be declared in a header file, and explained in the
non-existing man page, as well as in the existing man pages for
nanosleep(2) & Co.).

PR: bin/4259


# 27502 18-Jul-1997 peter

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


# 26385 02-Jun-1997 peter

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)


# 26338 01-Jun-1997 peter

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.


# 25890 18-May-1997 peter

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.


# 25870 17-May-1997 peter

round-up non-zero nanoseconds in #ifdef'ed code.


# 25862 17-May-1997 peter

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.


# 25861 17-May-1997 ache

Temporarily restore old (itimer) sleep variant because new one
(nanosleep) breaks Apache httpd badly: his childs died quickly after
number of requests (SIGPIPE). To reproduce this bug start
gdb /usr/local/sbin/httpd
run -X

and make some bunch of concurent requests (load the server pages
from 3 different places f.e.)
After short time httpd dies via SIGPIPE. It never dies with old sleep.c

In real life it looks like lots of broken images on the pages or missing
pages. Lynx says about Network read error, etc.
It seems something wrong in nanosleep signal handling.


# 25739 12-May-1997 peter

Use nanosleep() in all cases, not just in the reentrant libc (_THREAD_SAFE)
version.


# 18414 20-Sep-1996 nate

ts_sec -> tv_sec
ts_nsec -> tv_nsec


# 13545 21-Jan-1996 julian

Reviewed by: julian and (hsu?)
Submitted by: John Birrel(L?)

changes for threadsafe operations


# 11659 22-Oct-1995 phk

Minor cleanup, mostly unused vars and missing #includes.


# 1574 27-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1573,
which included commits to RCS files with non-trunk default branches.


# 1573 27-May-1994 rgrimes

BSD 4.4 Lite Lib Sources