Commit Graph

37 Commits

Author SHA1 Message Date
Jacques Vidrine
e0554a531f Eliminate 61 warnings emitted at WARNS=2 (leaving 53 to go).
Only warnings that could be fixed without changing the generated object
code and without restructuring the source code have been handled.

Reviewed by:	/sbin/md5
2003-02-16 17:29:11 +00:00
Peter Wemm
878c9687ec Do not guarantee an overflow of tm_year when doing the binary search in
localtime/mktime/tmcomp and friends on ia64.

Approved by:	re
2002-12-05 19:54:47 +00:00
Peter Wemm
a5bf4e71ef Replace rev 1.33 with a real fix. The problem was integer overflows
when trying to store the year in a signed int.  The maximum time_t on ia64
is around 292 billion years in the future, but 'int' and struct tm.tm_year
can only represent then ext 2.1 billion years or so.

This solves the problem of mktime/localtime looping on ia64.  Unfortunately,
the standards say that tm_year is an 'int', so we are still stuck with a
y2147483647 bug.  bash2's configure script looks for bugs in mktime() and
fails on ia64 because of this.  However, mktime() on FreeBSD fails the test
normally anyway so this is no big loss.

This change does not affect any other platforms besides ia64.

Approved by:	re
2002-12-02 01:05:08 +00:00
Peter Wemm
b331ec93c0 Fix a nasty bug exposed by mktime() when time_t is significantly bigger
than 32 bits.  It was trying to figure out things like the day of week
of when time_t is roughly 2^62 etc.  Make a better guess for the starting
point for the binary search that works on both 32 and 64 bit types.  I have
been using this for a while now.
2002-09-03 04:34:10 +00:00
Alfred Perlstein
1d145de849 Remove use of __P() (actually P()) from code now that it's no longer
available.
2002-05-28 20:12:42 +00:00
Garrett Wollman
0d84b47e9c Fix fd leak. Threads people: does the call above to `access' need to be
underscored as well?

PR:		37717
Submitted by:	fred@clift.org (slightly modified by me)
2002-05-03 17:28:28 +00:00
David E. O'Brien
333fc21e3c Fix the style of the SCM ID's.
I believe have made all of libc .c's as consistent as possible.
2002-03-22 21:53:29 +00:00
David E. O'Brien
8fb3f3f682 Remove 'register' keyword. 2002-03-21 18:49:23 +00:00
Garrett Wollman
80d444c883 Don't mung the user's tm_sec field if we don't need to. (Belt-and-suspenders
version.)

PR:		bin/27630
Submitted by:	Arthur David Olson <ado@nci.nih.gov>
Obtained from:	Timezone mailing-list <tz@elsie.nci.nih.gov>
MFC after:	1 month
2001-06-05 20:13:28 +00:00
Tor Egge
9f52fa8615 Don't depend on lcl_mutex being a recursive mutex.
Reviewed by:	deischen
2001-02-15 22:17:04 +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
Martin Cracauer
6686e4fafb Temporary cosmetic change to prevent gcc-2.95.2 from doing an
optimization that generates code our current as doesn't understand.

The result is bad code that damages dynamic symbol locations at
runtime. Ouch. See PR bin/16862 and discussion in -current.

This change will be backed out when gcc and gas are back in sync.

PR:		Fixes bin/16862, but not the underlying problem.
Submitted by:	bde
Approved by:	jdk
2000-03-08 12:46:25 +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
Garrett Wollman
6efae010ca Merge from vendor branch: timezone file structure changes and doco.
Fix localtime.c to deal with new magic number field.

Obtained from: ftp://elsie.nci.nih.gov/pub/tzcode1999a.tar.gz
1999-01-21 17:22:59 +00:00
Dmitrij Tejblum
de16000123 Make ctime_r, asctime_r, gmtime_r, and localtime_r available in libc. 1999-01-04 20:45:20 +00:00
Warner Losh
e8420087b0 Replace memory leaking instances of realloc with non-leaking reallocf.
In some cases replace if (a == null) a = malloc(x); else a =
realloc(a, x); with simple reallocf(a, x).  Per ANSI-C, this is
guaranteed to be the same thing.

I've been running these on my system here w/o ill effects for some
time.  However, the CTM-express is at part 6 of 34 for the CAM
changes, so I've not been able to do a build world with the CAM in the
tree with these changes.  Shouldn't impact anything, but...
1998-09-16 04:17:47 +00:00
Poul-Henning Kamp
4f6eb9ceed Add a #ifdef _THREAD_SAFE around ctime_r 1998-04-20 10:09:37 +00:00
Poul-Henning Kamp
3f643d87bb ctime_r and asctime_r are not implemented.
prototypes in time.h do not match POSIX.

PR:		6345
Reviewed by:	phk
Submitted by:	Dmitry Khrustalev <dima@xyzzy.machaon.ru>
1998-04-19 06:47:25 +00:00
John Birrell
5a2f1fed77 Change in name of the static initializer define. 1998-04-04 11:03:07 +00:00
Julian Elischer
39a9295edc Submitted by: Jeremy Allison (jallison@whistle.com)
fix a slight confusion about which draft of threads we are supporting.
this allows something as big and ugly as samba to be compiled with libc_r
and still work!  our user-level pthreads seems amazingly robust!
1998-02-18 01:20:33 +00:00
Warner Losh
99a0772b8d Back out 1.14 until I reproduce trouble reports 1997-03-25 05:34:31 +00:00
Warner Losh
418d4a9817 Don't open the tz file if we're running setuid or setgid to prevent infomration
leakage.

Submitted by:	Julian Assange
1997-03-24 06:09:50 +00:00
Julian Elischer
c840cec7c5 Submitted by: John Birrell
uthreads update from the author.
1997-02-05 23:26:09 +00:00
Garrett Wollman
525a12e989 When attempting to load a `lastditch' timezone (e.g., because the load
of the user's timezone failed), don't bail if the specified timezone
doesn't have an offset; in this case it isn't going to.  (Perhaps it would
be better to change the caller to always supply one, but this is quick
and clean and fixes the bug in the easiest possible way.)

Should be in 2.2.  Fixes (properly) PR#1740.
1997-01-13 17:12:23 +00:00
Jeffrey Hsu
c1f20410c2 Parameters for localtime_r() and gmtime_r() definitions changed.
Parameters for pthread_getspecific() call changed.
pthread_keycreate() renamed to pthread_key_create().
1996-11-11 09:14:24 +00:00
Garrett Wollman
318a4f9fc3 Require that a timezone specified via the TZ envariable be a regular
file (and not a directory or a device which might also be readable).
Closes PR#1740.
1996-10-09 17:39:37 +00:00
Julian Elischer
0f7d684755 Submitted by: John Birrell <cimaxp1!jb@werple.net.au>
Here are the diffs for libc_r to get it one step closer to P1003.1c
These make most of the thread/mutex/condvar structures opaque to the
user. There are three functions which have been renamed with _np
suffixes because they are extensions to P1003.1c (I did them for JAVA,
which needs to suspend/resume threads and also start threads suspended).

I've created a new header (pthread_np.h) for the non-POSIX stuff.

The egrep tags stuff in /usr/src/lib/libc_r/Makefile that I uncommented
doesn't work. I think its best to delete it. I don't think libc_r needs
tags anyway, 'cause most of the source is in libc which does have tags.

also:

Here's the first batch of man pages for the thread functions.
The diff to /usr/src/lib/libc_r/Makefile removes some stuff that was
inherited from /usr/src/lib/libc/Makefile that should only be done with
libc.

also:

I should have sent this diff with the pthread(3) man page.
It allows people to type

make -DWANT_LIBC_R world

to get libc_r built with the rest of the world. I put this in the
pthread(3) man page.  The default is still not to build libc_r.


also:
The diff attached adds a pthread(3) man page to /usr/src/share/man/man3.
The idea is that without libc_r installed, this man page will give people
enough info to know that they have to build libc_r.
1996-08-20 08:22:01 +00:00
Garrett Wollman
1ecaa8a894 Merge the recently-imported tzcode96h distribution (libc portion). The
part that does zic(8)/zdump(8) is still yet to be imported (but the old
zic and zdump will work just fine with these header files and the
data format has not changed).
1996-07-18 18:53:15 +00:00
Marc G. Fournier
6859875c81 Removed false copyrights... 1996-05-27 06:54:03 +00:00
Marc G. Fournier
b0d57629f6 Added in appropriate Berkeley copyright and RCS Id: string
Closes PR#doc/536
1996-05-27 04:10: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
Garrett Wollman
35482326b2 The European Commission went out and invented a new sort of summer-time
changeover, so we have to extend the format of timezone files (in a backward-
compatible way, of course).  This probably means that libc needs a minor
version number bump before 2.2 is released (or maybe not).
1995-08-05 20:28:08 +00:00
Rodney W. Grimes
6c06b4e2aa Remove trailing whitespace. 1995-05-30 05:51:47 +00:00
Garrett Wollman
f47e280f0a Port to FreeBSD. Not ready for inclusion in libc just yet, but here
so we can compile zic.
1994-09-13 03:50:58 +00:00
Garrett Wollman
23c76c74b7 One more try, and if it doesn't work this time I'm giving up.
(Check in original localtime.c.)
1994-09-13 03:44:49 +00:00
Garrett Wollman
48d96b1761 The rest of tzcode94g from Arthur David Olson.
Obtained From: Arthur David Olson, ftp://elsie.nci.nih.gov/pub/tzcode94g.tar.gz
1994-09-13 03:39:01 +00:00