ruby-changes:28440
From: akr <ko1@a...>
Date: Sat, 27 Apr 2013 12:31:01 +0900 (JST)
Subject: [ruby-changes:28440] akr:r40492 (trunk): * thread.c (TIMEVAL_SEC_MAX, TIMEVAL_SEC_MIN): Consider environments,
akr 2013-04-27 12:30:50 +0900 (Sat, 27 Apr 2013) New Revision: 40492 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40492 Log: * thread.c (TIMEVAL_SEC_MAX, TIMEVAL_SEC_MIN): Consider environments, sizeof(time_t) is smaller than sizeof(tv_sec), such as OpenBSD 5.2 (amd64). Modified files: trunk/ChangeLog trunk/thread.c Index: ChangeLog =================================================================== --- ChangeLog (revision 40491) +++ ChangeLog (revision 40492) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Apr 27 10:52:52 2013 Tanaka Akira <akr@f...> + + * thread.c (TIMEVAL_SEC_MAX, TIMEVAL_SEC_MIN): Consider environments, + sizeof(time_t) is smaller than sizeof(tv_sec), such as + OpenBSD 5.2 (amd64). + Fri Apr 26 23:34:59 2013 Kouhei Sutou <kou@c...> * lib/rexml/text.rb (REXML::Text.normalize): Fix a bug that all Index: thread.c =================================================================== --- thread.c (revision 40491) +++ thread.c (revision 40492) @@ -912,10 +912,20 @@ thread_value(VALUE self) https://github.com/ruby/ruby/blob/trunk/thread.c#L912 * Thread Scheduling */ +/* + * The type of tv_sec in struct timeval is time_t in POSIX. + * But several systems violates POSIX. + * + * OpenBSD 5.2 (amd64): + * time_t: int (signed 32bit integer) + * tv_sec: long (signed 64bit integer) + */ + #if SIGNEDNESS_OF_TIME_T < 0 /* signed */ -# define TIMEVAL_SEC_MAX_P1 (((unsigned_time_t)1) << (sizeof(TYPEOF_TIMEVAL_TV_SEC) * CHAR_BIT - 1)) -# define TIMEVAL_SEC_MAX ((TYPEOF_TIMEVAL_TV_SEC)(TIMEVAL_SEC_MAX_P1 - 1)) -# define TIMEVAL_SEC_MIN ((TYPEOF_TIMEVAL_TV_SEC)TIMEVAL_SEC_MAX_P1) +# define TIMEVAL_SEC_MAXBIT \ + (((TYPEOF_TIMEVAL_TV_SEC)1) << (sizeof(TYPEOF_TIMEVAL_TV_SEC) * CHAR_BIT - 2)) +# define TIMEVAL_SEC_MAX (TIMEVAL_SEC_MAXBIT | (TIMEVAL_SEC_MAXBIT-1)) +# define TIMEVAL_SEC_MIN (-TIMEVAL_SEC_MAX-1) #elif SIGNEDNESS_OF_TIME_T > 0 /* unsigned */ # define TIMEVAL_SEC_MAX ((TYPEOF_TIMEVAL_TV_SEC)(~(unsigned_time_t)0)) # define TIMEVAL_SEC_MIN ((TYPEOF_TIMEVAL_TV_SEC)0) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/