summaryrefslogtreecommitdiff
path: root/time64.c
Commit message (Collapse)AuthorAgeFilesLines
* time64.c: Remove no longer needed codeKarl Williamson2022-09-291-34/+0
| | | | This code defined some macros; those are now defined by perl.h
* Change ENV/LOCALE locking read macro namesKarl Williamson2022-09-291-4/+4
| | | | The old name was confusing.
* Remove ENV_LOCALE_LOCK/UNLOCK macrosKarl Williamson2022-09-291-4/+4
| | | | | These are subsumed by gwENVr_LOCALEr_LOCK created in the previous commit.
* Fix typos in tim64.c commentsKarl Williamson2022-06-081-2/+3
|
* Add Hobbit quote to time64.cLeon Timmermans2022-06-081-0/+26
|
* time64.c: avoid 'uninit' compiler warningDavid Mitchell2020-12-031-1/+1
| | | | | | | | | | clang isn't smart enough to recognise the pattern: if (foo) { ...} { else orig_year = ... } ... if (!foo) { ... use orig_year .. } So just unconditionally initialise orig_year.
* time64: declare `tm_zone` as `const char*` unconditionallyDagfinn Ilmari Mannsåker2020-07-181-1/+1
| | | | | | We only ever assign from `struct tm` to `struct TM`, not the other way around, so making this const regardless of what `struct tm` has should be safe.
* time64.c: Add a branch prediction for unlikely eventKarl Williamson2020-03-181-1/+1
|
* time64.c: Add mutex protectionKarl Williamson2020-03-181-3/+46
| | | | | | | | | The gmtime_r() and localtime_r() functions are not thread safe with regards to changes in the environment and locale while executing. This protects them with a mutex, but only from other functions that also participate in using that mutex. Future commits will change everything in the perl core to do that, but there is still a hole if some XS writer, or alien library doesn't use the mutex.
* time64.[ch]: Inline only use of another macroKarl Williamson2020-03-181-24/+21
| | | | | | | | | | This macro is now only used once. It is accessible outside perl because it is in time64.h, but isn't used in cpan. Remove it and place its expansion in time64.c. Part of the expansion called another function. That function can be removed and the expansion simplified, since gmtime() is now automatically converted into gmtime_r() if available and needed.
* time64.[ch]: Inline only use of a macro and fcnKarl Williamson2020-03-181-24/+24
| | | | | | | | | This macro is now only used once, and was the only caller of a helper function. Thus both can be removed and inlined, simplifying things. Further, most of the function's functionality can be removed, since it was an attempt to simulate localtime_r(), which is now automatically furnished by reentrant.[ch] if needed.
* time64.c: White-space onlyKarl Williamson2020-03-181-42/+42
| | | | | Indent code blocks created by the previous commit; a few more white-space adjustments.
* time64.c: Refactor Perl_localtime64_r()Karl Williamson2020-03-181-8/+7
| | | | | | | | | | | | | | | | | | | There are two main cases in Perl_localtime64_r(), call them A and B. Prior to this commit, it was structured if (A) { codeA return; } codeB return; The problem this commit solves is that there is common stuff in codeA and codeB that will now only be specified once. Currently that common stuff is minimal, and so acceptable, but the next few commits will make the common stuff more complex, so making it be only once is helpful.
* time64.c: Store fcn return in a variableKarl Williamson2020-03-181-1/+2
| | | | This is in preparation for it being used in more than one place
* A few small tweaks in time64.cAndy Lester2016-11-291-10/+10
| | | | | | | | | | * The struct TM * pointers to S_check_tm and S_timegm64 functions is not modified, so make it be a const and let the compiler know it won't get modified. * Localize variables to their innermost scopes * Consting various local variables
* Drop useful-looking but unused lookup table.Jarkko Hietaniemi2015-07-221-10/+0
|
* Add time64 as its own build target.Jarkko Hietaniemi2015-07-221-5/+8
|
* Use the Perl_ math in time64.c, too.Jarkko Hietaniemi2014-09-101-9/+9
|
* Some <termios.h> #define WRAP, undef it.Jarkko Hietaniemi2014-09-041-0/+1
|
* Time functions in time64.c need thread context on VMS.Craig A. Berry2014-06-271-2/+5
| | | | | | | | In order to support the C<vmsish 'time'> pragma, the wrappers for gmtime and localtime need thread context, which in the case of localtime was removed in 23491f1decae17401c5. Add it back but make it VMS-specific and turn the comment indicating why it's there into a more direct statement.
* Unused contexts found under PERL_GLOBAL_STRUCT.Jarkko Hietaniemi2014-06-241-1/+0
|
* reduce size of const static tables in time64.cDaniel Dragan2014-01-131-5/+5
| | | | | The data in the const static arrays can be expressed with smaller datatypes. This reduces binary size slightly.
* Added asserts() to check the arguments to S_copy_little_tm_to_big_TM.Andy Dougherty2013-01-171-0/+2
| | | | | | The original version just zeroed dest if src == NULL, but that code path was never used. (gcc -Os inlined the function and optimized the test away anyway.)
* remove an useless null check in S_copy_little_tm_to_big_TMDaniel Dragan2013-01-171-28/+23
| | | | | | | | | All callers of S_copy_little_tm_to_big_TM pass a true variable src. Checking for null is pointless. On Win32 32 bit VC 2003 -O1 -GL, perl517.dll's .text section went from 0xCO13F to 0xC012F bytes long. It can be argued that the compiler should have figured this out on its own, but VC for whatever reason didn't. Also pretty the indenting and align the assignments. The null check blames to commit 806a119aef .
* remove various redundant dTHXesDaniel Dragan2012-11-081-0/+2
| | | | | Remove either unused dTHXes, or remove dTHXes where a nocontext func can be used instead. Smaller/faster machine code is the result.
* Fix typos (spelling errors) in Perl sources.Peter J. Acklam) (via RT2011-01-071-1/+1
| | | | | | | | | # New Ticket Created by (Peter J. Acklam) # Please include the string: [perl #81904] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=81904 > Signed-off-by: Abigail <abigail@abigail.be>
* Silence a warning in time64.c. Need to downgrade a const char *Steve Peters2010-08-191-1/+1
| | | | to a char *.
* gmtime/localtime are busted around 2**48Michael G Schwern2010-01-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Michael G Schwern wrote: > Anyhow, I'm willing to let that drop, but I want figure out A) why its > failing so early because it might be masking a bug, this is not > predicted behavior, and most importantly B) to get it to error, or at > least warn. > > I know B is possible, I did it for Time::y2038. I'll figure that part > out and try to dig into A. I would like to call B a blocker for 5.12. Found the bug, patch attached. v_tm_tday is an NV, so casting time to an integer will cause an overflow 2**31 days after 1970 or somewhere between 2**47 and 2**48. Not sure why the compiler didn't warn about that. This makes it work until the year overflows. As for putting in a warning, there's two options: 1) A few days before the 32 bit year overflows. 2) At some reasonable point before there's too much floating point inaccuracy. The possibility of long doubles will make #2 difficult to nail down, but I'll be happy with +/- 2**53. -- 24. Must not tell any officer that I am smarter than they are, especially if it's true. -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army http://skippyslist.com/list/ From 9e940e610ac5b2fbb09a554f505963094a4a0745 Mon Sep 17 00:00:00 2001 From: Michael G. Schwern <schwern@pobox.com> Date: Sun, 31 Jan 2010 02:24:50 -0800 Subject: [PATCH] Type conversion bug in gmtime64 that was causing it to crap out around 2**48 Signed-off-by: H.Merijn Brand <h.m.brand@xs4all.nl>
* pp.c and time64.c don't need to be executableVincent Pit2009-05-141-0/+0
|
* Make time64 use NV for time_t, I32 for year, not Quad_t.Craig A. Berry2009-04-251-10/+10
| | | | | | | This means it should run on anything that does not have a 64-bit integer type available but does have a double. Presumably this includes platforms that define PERL_MICRO, so we now use the same extended time implementation for everything that runs Perl.
* Forgot one "static" in 7430375d1909c2b62c1fb3f9c6ed4b9d24dfcf32.Craig A. Berry2009-03-271-1/+1
|
* Remove unused function S_copy_big_TM_to_little_tm from time64.c.Craig A. Berry2009-03-261-32/+0
|
* Namespace clean-up for time64.Craig A. Berry2009-03-261-44/+46
| | | | | | | | | | | | | | | | | | | | All of the time64 functions are only visible within pp_sys.c and are not part of the public API, so make them all static and give them the S_ prefix. A side effect of this is that we now unambiguously use S_localtime64_r and S_gmtime64_r and should no longer collide with system-supplied versions, if any. One possible future direction is that if and when Configure detects any system-supplied *time64_r functions, their prototypes, and their valid time ranges, we could optionally select those instead of the home-grown ones. Another possible future direction is that we could s/S_/Perl_/ and make the *time64_r functions part of the public API in some post-5.10.x release. Currently they are only exposed to the outside world via Perl_pp_gmtime. Also gave some TRACE macros more specific names.
* Silence time64.c build warningJerry D. Hedden2009-01-131-0/+2
| | | | | | | Silence the following build warning: time64.c:169: warning: 'check_tm' defined but not used Message-ID: <1ff86f510901081219q4f5f25a3od89c4e5ac03e8664@mail.gmail.com>
* Silence Win32 compiler warnings.Steve Hay2009-01-131-3/+3
|
* fake_localtime_r and fake_gmtime_r may need thread context.Craig A. Berry2009-01-091-0/+2
| | | | They definitely need it on VMS.
* Make time64.c's internal copy function names more readable and VMS-friendly.Craig A. Berry2009-01-041-5/+5
|
* Update from y2038Michael G. Schwern2009-01-031-12/+17
| | | | | | Fix trailing #endif. Remove C99 macro.
* Update from y2038.Michael G. Schwern2009-01-031-14/+27
| | | | | | | | | | | Add trace code. Fix implied negative time in localtie64_r(). This fixes Windows. Put in some more tests around small negative and positive times to try and catch the above. Explain the loss of accuracy due to use of doubles in perlport.
* Update from y2038Michael G. Schwern2009-01-031-17/+28
| | | | | | | | | | | | Configuration information split out into its own header. Added files to MANIFEST Turn off USE_SYSTEM_GMTIME, ours is more reliable and possibly faster. Fix type warnings found on Windows. Remove unnecessary use of floor() and ceil().
* Remove the AIX work around code. Instead it should just set it's ↵Michael G. Schwern2009-01-031-36/+107
| | | | | | | | | | | | | | | | | LOCALTIME_MAX to 0x7fff573e. Update from y2038. Use the new TM64 struct so years can go out past y2**31 Defines a Year type to avoid converting years to ints. Remove the TIMGM work around code, using timegm64() is fine and it saves us from having to convert from TM to tm. Make functions private with static rather than the _foo convention. Even faster for distant dates.
* Rename localtime64.[ch] to time64.[ch] to mirror change in y2038, and the ↵Michael G. Schwern2009-01-031-0/+481
file isn't about just localtime() anymore.