summaryrefslogtreecommitdiff
path: root/lib/libc/stdtime/localtime.c
Commit message (Collapse)AuthorAgeFilesLines
* struct tm.tm_year is listed as 'years since 1900', and is signed. OnPeter Wemm2004-08-241-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | 64 bit systems, years roughly -2^31 through 2^31 can be represented in time_t without any trouble. 32 bit time_t systems only range from roughly 1902 through 2038. As a consequence, none of the date munging code for all the various calendar tweaks before then is present. There are other problems including the fact that there was no 'year zero' and so on. So rather than get excited about trying to figure out when the calendar jumped by two weeks etc, simply disallow negative (ie: prior to 1900) years. This happens to have an important side effect. If you bzero a 'struct tm', it corresponds to 'Jan 0, 1900, 00:00 GMT'. This happens to be representable (after canonification) in 64 bit time_t space. Zero tm structs are generally an error and mktime normally returns -1 for them. Interestingly, it tries to canonify the 'jan 0' to 'dec 31, 1899', ie: year -1. This conveniently trips the negative year test above, which means we can trivially detect the null 'tm' struct. This actually tripped up code at work. :-/ (Don't ask) Notes: svn path=/head/; revision=134231
* Merge changes from the tzcode2004a import. Wherever possible I tried to bringStefan Farfeleder2004-06-141-52/+116
| | | | | | | | | us closer to the vendor branch. Requested by: wollman Notes: svn path=/head/; revision=130461
* Change defualt time zone from GMT to UTC. This will not be MFC-ed, andKen Smith2004-06-111-1/+6
| | | | | | | was done before 5-STABLE on purpose... Notes: svn path=/head/; revision=130332
* Remove a couple of casts added for an ancient Sun compiler.Stefan Farfeleder2004-06-081-11/+2
| | | | | | | Approved by: das (mentor) Notes: svn path=/head/; revision=130244
* Eliminate 61 warnings emitted at WARNS=2 (leaving 53 to go).Jacques Vidrine2003-02-161-2/+2
| | | | | | | | | | 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 Notes: svn path=/head/; revision=111010
* Do not guarantee an overflow of tm_year when doing the binary search inPeter Wemm2002-12-051-0/+6
| | | | | | | | | localtime/mktime/tmcomp and friends on ia64. Approved by: re Notes: svn path=/head/; revision=107648
* Replace rev 1.33 with a real fix. The problem was integer overflowsPeter Wemm2002-12-021-8/+2
| | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=107480
* Fix a nasty bug exposed by mktime() when time_t is significantly biggerPeter Wemm2002-09-031-0/+6
| | | | | | | | | | 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. Notes: svn path=/head/; revision=102885
* Remove use of __P() (actually P()) from code now that it's no longerAlfred Perlstein2002-05-281-38/+38
| | | | | | | available. Notes: svn path=/head/; revision=97423
* Fix fd leak. Threads people: does the call above to `access' need to beGarrett Wollman2002-05-031-1/+3
| | | | | | | | | | underscored as well? PR: 37717 Submitted by: fred@clift.org (slightly modified by me) Notes: svn path=/head/; revision=95989
* Fix the style of the SCM ID's.David E. O'Brien2002-03-221-2/+2
| | | | | | | I believe have made all of libc .c's as consistent as possible. Notes: svn path=/head/; revision=92986
* Remove 'register' keyword.David E. O'Brien2002-03-211-73/+73
| | | | Notes: svn path=/head/; revision=92889
* Don't mung the user's tm_sec field if we don't need to. (Belt-and-suspendersGarrett Wollman2001-06-051-1/+3
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=77785
* Don't depend on lcl_mutex being a recursive mutex.Tor Egge2001-02-151-5/+5
| | | | | | | Reviewed by: deischen Notes: svn path=/head/; revision=72524
* Remove _THREAD_SAFE and make libc thread-safe by default byDaniel Eischen2001-01-241-108/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=71579
* Temporary cosmetic change to prevent gcc-2.95.2 from doing anMartin Cracauer2000-03-081-1/+1
| | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=57822
* Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(),Jason Evans2000-01-271-3/+3
| | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=56698
* Add three-tier symbol naming in support of POSIX thread cancellationJason Evans2000-01-121-3/+5
| | | | | | | | | 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(). Notes: svn path=/head/; revision=55837
* Merge from vendor branch: timezone file structure changes and doco.Garrett Wollman1999-01-211-1/+1
| | | | | | | | | Fix localtime.c to deal with new magic number field. Obtained from: ftp://elsie.nci.nih.gov/pub/tzcode1999a.tar.gz Notes: svn path=/head/; revision=42989
* Make ctime_r, asctime_r, gmtime_r, and localtime_r available in libc.Dmitrij Tejblum1999-01-041-6/+4
| | | | Notes: svn path=/head/; revision=42293
* Replace memory leaking instances of realloc with non-leaking reallocf.Warner Losh1998-09-161-2/+7
| | | | | | | | | | | | | | 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... Notes: svn path=/head/; revision=39327
* Add a #ifdef _THREAD_SAFE around ctime_rPoul-Henning Kamp1998-04-201-0/+2
| | | | Notes: svn path=/head/; revision=35331
* ctime_r and asctime_r are not implemented.Poul-Henning Kamp1998-04-191-0/+9
| | | | | | | | | | | prototypes in time.h do not match POSIX. PR: 6345 Reviewed by: phk Submitted by: Dmitry Khrustalev <dima@xyzzy.machaon.ru> Notes: svn path=/head/; revision=35285
* Change in name of the static initializer define.John Birrell1998-04-041-4/+4
| | | | Notes: svn path=/head/; revision=35026
* Submitted by: Jeremy Allison (jallison@whistle.com)Julian Elischer1998-02-181-3/+5
| | | | | | | | | 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! Notes: svn path=/head/; revision=33527
* Back out 1.14 until I reproduce trouble reportsWarner Losh1997-03-251-4/+2
| | | | Notes: svn path=/head/; revision=24253
* Don't open the tz file if we're running setuid or setgid to prevent infomrationWarner Losh1997-03-241-2/+4
| | | | | | | | | leakage. Submitted by: Julian Assange Notes: svn path=/head/; revision=24195
* Submitted by: John BirrellJulian Elischer1997-02-051-5/+3
| | | | | | | uthreads update from the author. Notes: svn path=/head/; revision=22315
* When attempting to load a `lastditch' timezone (e.g., because the loadGarrett Wollman1997-01-131-7/+8
| | | | | | | | | | | | 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. Notes: svn path=/head/; revision=21659
* Parameters for localtime_r() and gmtime_r() definitions changed.Jeffrey Hsu1996-11-111-8/+8
| | | | | | | | Parameters for pthread_getspecific() call changed. pthread_keycreate() renamed to pthread_key_create(). Notes: svn path=/head/; revision=19636
* Require that a timezone specified via the TZ envariable be a regularGarrett Wollman1996-10-091-1/+7
| | | | | | | | file (and not a directory or a device which might also be readable). Closes PR#1740. Notes: svn path=/head/; revision=18834
* Submitted by: John Birrell <cimaxp1!jb@werple.net.au>Julian Elischer1996-08-201-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=17706
* Merge the recently-imported tzcode96h distribution (libc portion). TheGarrett Wollman1996-07-181-56/+59
| | | | | | | | | 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). Notes: svn path=/head/; revision=17209
* Removed false copyrights...Marc G. Fournier1996-05-271-34/+0
| | | | Notes: svn path=/head/; revision=15927
* Added in appropriate Berkeley copyright and RCS Id: stringMarc G. Fournier1996-05-271-0/+36
| | | | | | | Closes PR#doc/536 Notes: svn path=/head/; revision=15923
* Reviewed by: julian and (hsu?)Julian Elischer1996-01-221-1/+129
| | | | | | | | | Submitted by: John Birrel(L?) changes for threadsafe operations Notes: svn path=/head/; revision=13545
* The European Commission went out and invented a new sort of summer-timeGarrett Wollman1995-08-051-129/+211
| | | | | | | | | 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). Notes: svn path=/head/; revision=9936
* Remove trailing whitespace.Rodney W. Grimes1995-05-301-1/+1
| | | | Notes: svn path=/head/; revision=8870
* Port to FreeBSD. Not ready for inclusion in libc just yet, but hereGarrett Wollman1994-09-131-1/+1
| | | | | | | so we can compile zic. Notes: svn path=/head/; revision=2713
* One more try, and if it doesn't work this time I'm giving up.Garrett Wollman1994-09-131-1/+1
| | | | | | | (Check in original localtime.c.) Notes: svn path=/vendor/tzcode/dist/; revision=2710
* The rest of tzcode94g from Arthur David Olson.Garrett Wollman1994-09-131-0/+1530
Obtained From: Arthur David Olson, ftp://elsie.nci.nih.gov/pub/tzcode94g.tar.gz Notes: svn path=/vendor/tzcode/dist/; revision=2708