[前][次][番号順一覧][スレッド一覧]

ruby-changes:27904

From: nobu <ko1@a...>
Date: Wed, 27 Mar 2013 05:15:56 +0900 (JST)
Subject: [ruby-changes:27904] nobu:r39956 (trunk): internal.h: use SIGNEDNESS_OF_TIME_T

nobu	2013-03-27 05:15:44 +0900 (Wed, 27 Mar 2013)

  New Revision: 39956

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39956

  Log:
    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.

  Modified files:
    trunk/ChangeLog
    trunk/configure.in
    trunk/internal.h

Index: configure.in
===================================================================
--- configure.in	(revision 39955)
+++ configure.in	(revision 39956)
@@ -1171,7 +1171,9 @@ AC_DEFUN([RUBY_REPLACE_TYPE], [dnl https://github.com/ruby/ruby/blob/trunk/configure.in#L1171
 	    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,
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39955)
+++ ChangeLog	(revision 39956)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Mar 27 05:15:37 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@f...>
 
 	* internal.h (TIMET_MAX_PLUS_ONE): Defined.
Index: internal.h
===================================================================
--- internal.h	(revision 39955)
+++ internal.h	(revision 39956)
@@ -19,12 +19,17 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/internal.h#L19
 #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];

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]