diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-06 13:03:43 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-06 13:03:43 +0000 |
commit | 2bbeb4c0ad49847b1f73ba6281827bf513d05884 (patch) | |
tree | 0d2d7e914ea457f1940519b895053459f0a3689e /configure.in | |
parent | 727371f88ac06fcb1e5417492f5ab17f5d58d886 (diff) |
* configure.in: test localtime(3) overflow. [ruby-dev:40910]
* time.c (rb_gmtime_r): renamed from rb_gmtime.
(rb_localtime_r): renamed from rb_localtime.
(rb_localtime_r2): call rb_localtime_r and validate the result if
there is overflow problem.
(rb_gmtime_r2): call rb_gmtime_r and validate the result if there
is overflow problem.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'configure.in')
-rw-r--r-- | configure.in | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/configure.in b/configure.in index 5047e9e054..27fbe56d98 100644 --- a/configure.in +++ b/configure.in @@ -1290,6 +1290,48 @@ if test "$rb_cv_negative_time_t" = yes; then AC_DEFINE(NEGATIVE_TIME_T) fi +# [ruby-dev:40910] overflow of time on FreeBSD +# http://www.freebsd.org/cgi/query-pr.cgi?pr=145341 +AC_CACHE_CHECK(for localtime(3) overflow correctly, rb_cv_localtime_overflow, + [AC_TRY_RUN([ +#include <time.h> + +void +check(time_t t1) +{ + struct tm *tm; + time_t t2; + tm = localtime(&t1); + if (!tm) + return; /* overflow detected. ok. */ + t2 = mktime(tm); + if (t1 == t2) + return; /* round-trip. ok. */ + exit(1); +} + +int +main() +{ + time_t t; + if (~(time_t)0 <= 0) { + t = (((time_t)1) << (sizeof(time_t) * 8 - 2)); + t |= t - 1; + } + else { + t = ~(time_t)0; + } + check(t); + return 0; +} +], + rb_cv_localtime_overflow=yes, + rb_cv_localtime_overflow=no, + rb_cv_localtime_overflow=yes)]) +if test "$rb_cv_localtime_overflow" = no; then + AC_DEFINE(LOCALTIME_OVERFLOW_PROBLEM) +fi + if test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = yes; then AC_DEFINE(POSIX_SIGNAL) else |