summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-05 13:09:42 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-05 13:09:42 +0000
commit66fc78d20737cc78c244809395b1f185748763ef (patch)
tree7819557eb374a639300ff2db49f7d7e7197b4c90 /ext
parent6410a4ae27a8832d1aee4c370bbf036608a7e577 (diff)
* ext/date/date_core.c (DAY_IN_NANOSECONDS): long long int is not
available on all platforms. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/date/date_core.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index 040bfa3a153..84338c4eff8 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -42,7 +42,13 @@
#define DAY_IN_SECONDS 86400
#define SECOND_IN_NANOSECONDS 1000000000
-#define DAY_IN_NANOSECONDS 86400000000000LL
+#if (ULONG_MAX / DAY_IN_SECONDS) > SECOND_IN_NANOSECONDS
+#define DAY_IN_NANOSECONDS LONG2NUM(DAY_IN_SECONDS * SECOND_IN_NANOSECONDS)
+#elif defined HAVE_LONG_LONG
+#define DAY_IN_NANOSECONDS LL2NUM((LONG_LONG)DAY_IN_SECONDS * SECOND_IN_NANOSECONDS)
+#else
+#define DAY_IN_NANOSECONDS f_mul(INT2FIX(DAY_IN_SECONDS), INT2FIX(SECOND_IN_NANOSECONDS))
+#endif
/* copied from time.c */
#define NDIV(x,y) (-(-((x)+1)/(y))-1)
@@ -4584,7 +4590,7 @@ Init_date_core(void)
rzero = rb_rational_new1(INT2FIX(0));
rhalf = rb_rational_new2(INT2FIX(1), INT2FIX(2));
- day_in_nanoseconds = rb_ll2inum(DAY_IN_NANOSECONDS);
+ day_in_nanoseconds = DAY_IN_NANOSECONDS;
rb_gc_register_mark_object(rzero);
rb_gc_register_mark_object(rhalf);