summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--ext/date/date_core.c10
2 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f531fae700b..40b13faeeb3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu May 5 22:09:39 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/date/date_core.c (DAY_IN_NANOSECONDS): long long int is not
+ available on all platforms.
+
Thu May 5 17:36:31 2011 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
* eval.c (frame_func_id): store result of method_entry_of_iseq() to
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);