* 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).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-04-27 03:30:50 +00:00
Родитель 825a892330
Коммит e88a692a88
2 изменённых файлов: 19 добавлений и 3 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Sat Apr 27 10:52:52 2013 Tanaka Akira <akr@fsij.org>
* 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@cozmixng.org>
* lib/rexml/text.rb (REXML::Text.normalize): Fix a bug that all

Просмотреть файл

@ -912,10 +912,20 @@ thread_value(VALUE self)
* 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)