Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

internal.h: use SIGNEDNESS_OF_TIME_T

* configure.in (RUBY_REPLACE_TYPE): define SIGNEDNESS_OF_type same as
  check_signedness of mkmf.rb.
* internal.h (TIMET_MAX, TIMET_MIN, TIMET_MAX_PLUS_ONE): use
  SIGNEDNESS_OF_TIME_T.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
commit 7b2c7b620c9d124d5d676a09acf6799f57627b0d 1 parent 5426842
@nobu nobu authored
Showing with 21 additions and 6 deletions.
  1. +8 −0 ChangeLog
  2. +2 −0  configure.in
  3. +11 −6 internal.h
View
8 ChangeLog
@@ -1,3 +1,11 @@
+Wed Mar 27 05:15:37 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * configure.in (RUBY_REPLACE_TYPE): define SIGNEDNESS_OF_type same as
+ check_signedness of mkmf.rb.
+
+ * internal.h (TIMET_MAX, TIMET_MIN, TIMET_MAX_PLUS_ONE): use
+ SIGNEDNESS_OF_TIME_T.
+
Wed Mar 27 00:28:45 2013 Tanaka Akira <akr@fsij.org>
* internal.h (TIMET_MAX_PLUS_ONE): Defined.
View
2  configure.in
@@ -1171,7 +1171,9 @@ AC_DEFUN([RUBY_REPLACE_TYPE], [dnl
t=INT])
rb_cv_[$1]_convertible=${u}${t}])
test "${AS_TR_SH(ac_cv_type_[$1])}" = "yes" && n="$1"
+ AS_CASE("${rb_cv_[$1]_convertible}", [U*], [u=+1], [u=-1])
AC_DEFINE_UNQUOTED(rb_[$1], $n)
+ AC_DEFINE_UNQUOTED([SIGNEDNESS_OF_]AS_TR_CPP($1), $u)
AC_DEFINE_UNQUOTED([$3]2NUM[(v)], [${rb_cv_[$1]_convertible}2NUM(v)])
AC_DEFINE_UNQUOTED(NUM2[$3][(v)], [NUM2${rb_cv_[$1]_convertible}(v)])
AC_DEFINE_UNQUOTED(PRI_[$3]_PREFIX,
View
17 internal.h
@@ -19,12 +19,17 @@ extern "C" {
#endif
#endif
-#define TIMET_MAX (~(time_t)0 <= 0 ? (time_t)((~(unsigned_time_t)0) >> 1) : (time_t)(~(unsigned_time_t)0))
-#define TIMET_MIN (~(time_t)0 <= 0 ? (time_t)(((unsigned_time_t)1) << (sizeof(time_t) * CHAR_BIT - 1)) : (time_t)0)
-
-#define TIMET_MAX_PLUS_ONE (~(time_t)0 <= 0 ? \
- ((time_t)1 << (sizeof(time_t) * CHAR_BIT / 2)) * (double)((time_t)1 << (sizeof(time_t) * CHAR_BIT / 2 - 1)) : \
- ((time_t)1 << (sizeof(time_t) * CHAR_BIT / 2)) * (double)((time_t)1 << (sizeof(time_t) * CHAR_BIT / 2)))
+#if SIGNEDNESS_OF_TIME_T < 0 /* signed */
+# define TIMET_MAX (time_t)((~(unsigned_time_t)0) >> 1)
+# define TIMET_MIN (time_t)(((unsigned_time_t)1) << (sizeof(time_t) * CHAR_BIT - 1))
+# define TIMET_MAX_PLUS_ONE \
+ (((time_t)1 << (sizeof(time_t) * CHAR_BIT / 2)) * (double)((time_t)1 << (sizeof(time_t) * CHAR_BIT / 2 - 1)))
+#elif SIGNEDNESS_OF_TIME_T > 0 /* unsigned */
+# define TIMET_MAX (time_t)(~(unsigned_time_t)0)
+# define TIMET_MIN (time_t)0
+# define TIMET_MAX_PLUS_ONE \
+ (((time_t)1 << (sizeof(time_t) * CHAR_BIT / 2)) * (double)((time_t)1 << (sizeof(time_t) * CHAR_BIT / 2))))
+#endif
struct rb_deprecated_classext_struct {
char conflict[sizeof(VALUE) * 3];
Please sign in to comment.
Something went wrong with that request. Please try again.