From: H.Merijn Brand Date: Mon, 7 Jul 2008 19:59:08 +0000 (+0000) Subject: y2038 preparation for Schwern X-Git-Tag: 5.26.1~294 X-Git-Url: https://perl5.git.perl.org/metaconfig.git/commitdiff_plain/1879bbb77bc6dd7c5e6b89874ffd7bf4f1845a37?ds=inline y2038 preparation for Schwern p4raw-id: //depot/metaconfig@34104 --- diff --git a/U/perl/time_size.U b/U/perl/time_size.U new file mode 100644 index 0000000..0208145 --- /dev/null +++ b/U/perl/time_size.U @@ -0,0 +1,102 @@ +?RCS: $Id$ +?RCS: +?RCS: Copyright (c) 2008 H.Merijn Brand +?RCS: +?RCS: You may distribute under the terms of either the GNU General Public +?RCS: License or the Artistic License, as specified in the README file. +?RCS: +?MAKE:sGMTIME_max sGMTIME_min: cat rm_try Setvar Compile run +?MAKE: -pick add $@ %< +?S:sGMTIME_max: +?S: This variable defines the maximum value of the time_t offset that +?S: the system function gmtime () accepts +?S:. +?S:sGMTIME_min: +?S: This variable defines the minimum value of the time_t offset that +?S: the system function gmtime () accepts +?S:. +?C:GMTIME_MAX: +?C: This symbol contains the maximum value for the time_t offset that +?C: the system function gmtime () accepts, and defaults to 0 +?C:. +?C:GMTIME_MIN: +?C: This symbol contains the minimum value for the time_t offset that +?C: the system function gmtime () accepts, and defaults to 0 +?C:. +?H:#define GMTIME_MAX $sGMTIME_max /**/ +?H:#define GMTIME_MIN $sGMTIME_min /**/ +?H:. +?D:sGMTIME_max=0 +?D:sGMTIME_min=0 +?F:!try +: Check the max offset that gmtime accepts +echo "Checking max offset that gmtime () accepts" + +$cat >try.c <<'EOCP' +#include +#include +#include +int main () { + struct tm *tmp; + int i, y = 0; + time_t pt = 0; + + for (i = 0; i < 78; i++) { + time_t t = (1 << i) - 1; + tmp = gmtime (&t); + if (tmp == NULL || tmp->tm_year < y) { + i--; + printf ("%d\n", pt); + return (i); + } + + y = tmp->tm_year; + pt = t; + } + printf ("%d\n", pt); + return (0); + } +EOCP +set try +if eval $compile; then + sGMTIME_max=`$run ./try` +else + echo "Cannot determine sGMTIME_max" + fi +$rm_try + +echo "Checking min offset that gmtime () accepts" + +$cat >try.c <<'EOCP' +#include +#include +#include +int main () { + struct tm *tmp; + int i, y = 70; + time_t pt = 0; + + for (i = 0; i < 78; i++) { + time_t t = - (1 << i); + tmp = gmtime (&t); + if (tmp == NULL || tmp->tm_year > y) { + i--; + printf ("%d\n", pt); + return (i); + } + + y = tmp->tm_year; + pt = t; + } + printf ("%d\n", pt); + return (0); + } +EOCP +set try +if eval $compile; then + sGMTIME_min=`$run ./try` +else + echo "Cannot determine sGMTIME_min" + fi +$rm_try +