diff options
author | Frank Ch. Eigler <fche@elastic.org> | 2008-05-21 13:37:07 -0400 |
---|---|---|
committer | Frank Ch. Eigler <fche@elastic.org> | 2008-05-21 13:37:07 -0400 |
commit | e3339150b3c04f50b0abdc4a6d132a6b75b22cb6 (patch) | |
tree | c80892afd79625f95ff0a2543728804464c2961a /tapset/ctime.stp | |
parent | 332ddc9f7354fe51c32c504087575b3ea2b70990 (diff) | |
parent | aa8a3b1797da54a14d04cd57758a65064056376e (diff) | |
download | systemtap-steved-e3339150b3c04f50b0abdc4a6d132a6b75b22cb6.tar.gz systemtap-steved-e3339150b3c04f50b0abdc4a6d132a6b75b22cb6.tar.xz systemtap-steved-e3339150b3c04f50b0abdc4a6d132a6b75b22cb6.zip |
Merge commit 'origin/master' into pr6429-comp-unwindsyms
* commit 'origin/master':
Fix assignment optimization expected results.
PR6538: more testsuite tweaks for read-only warnings
PR6538: more tapset fixes
PR6538: explain why absentstats.stp logs will contain warnings
PR6538: fix treatment of initialized globals
Use pointer_arg to fetch arguments for syscall.utime and compat_utime.
Optimize compound and binary expression assignments.
Check new (sub) functions of _struct_utimbuf_* and _struct_compat_utimbuf_*.
PR6538: tapset changes
PR6538: testsuite changes
PR5001: fix test suite collateral damage
PR6538: warn about read-only variables
Add some scripts and descriptions to the systemtap.examples.
PR5001: Remove _stp_ctime and always use ctime.
Use tr1/unordered_map instead of the deprecated ext/hash_map.
PR6524: ctime() on bad values hangs system.
Optimize away assignments in other contexts.
Optimize away assignments in other contexts.
dummy commit for testing systemtap-cvs notification
Remove sa_restorer initialization.
Diffstat (limited to 'tapset/ctime.stp')
-rw-r--r-- | tapset/ctime.stp | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/tapset/ctime.stp b/tapset/ctime.stp index cd8e5026..96af4d47 100644 --- a/tapset/ctime.stp +++ b/tapset/ctime.stp @@ -4,7 +4,23 @@ * Takes an argument of seconds since the epoch as returned by * gettimeofday_s(). Returns a string of the form * - * "Wed Jun 30 21:49:008 1993" + * "Wed Jun 30 21:49:08 1993" + * + * The string will always be exactly 24 characters. If the time would + * be unreasonable far in the past (before what can be represented + * with a 32 bit offset in seconds from the epoch) the returned string + * will be "a long, long time ago...". If the time would be + * unreasonable far in the future the returned string will be "far far + * in the future..." (both these strings are also 24 characters wide). + * + * Note that the epoch (zero) corresponds to + * + * "Thu Jan 1 00:00:00 1970" + * + * The earliest full date given by ctime, corresponding to epochsecs + * -2147483648 is "Fri Dec 13 20:45:52 1901". The latest full date + * given by ctime, corresponding to epachsecs 2147483647 is + * "Tue Jan 19 03:14:07 2038". * * The abbreviations for the days of the week are ‘Sun’, ‘Mon’, ‘Tue’, * ‘Wed’, ‘Thu’, ‘Fri’, and ‘Sat’. The abbreviations for the months @@ -21,7 +37,7 @@ * tzcode maintained by Arthur David Olson. In newlib, asctime_r.c * doesn't have any author/copyright information. * - * Changes copyright (C) 2006 Red Hat Inc. + * Changes copyright (C) 2006, 2008 Red Hat Inc. */ function ctime:string(epochsecs:long) @@ -70,6 +86,25 @@ function ctime:string(epochsecs:long) int tm_year; /* year */ int tm_wday; /* day of the week */ + // Check that the numer of seconds is "reasonable". + // Otherwise (especially on 64bit machines) we will be spending + // way too much time calculating the correct year, month and + // day. Also we would like the returned string to always be 24 chars. + // So cap to what can be represented normally on a 32bit machine. + int64_t MAX_POS_SECS = 2147483647LL; + int64_t MIN_NEG_SECS = -2147483648LL; + + if (THIS->epochsecs > MAX_POS_SECS) + { + strlcpy(THIS->__retvalue, "far far in the future...", MAXSTRINGLEN); + return; + } + if (THIS->epochsecs < MIN_NEG_SECS) + { + strlcpy(THIS->__retvalue, "a long, long time ago...", MAXSTRINGLEN); + return; + } + lcltime = THIS->epochsecs; days = ((long)lcltime) / SECSPERDAY; |