diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-27 03:30:50 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-27 03:30:50 +0000 |
commit | e88a692a884a2c9d5349e1e94da3b0d77247adc2 (patch) | |
tree | fbbd153c6e378dea96eac9699c3bff4704f45c05 /thread.c | |
parent | 825a892330a0a9829011c59eabb212da31761711 (diff) | |
download | ruby-e88a692a884a2c9d5349e1e94da3b0d77247adc2.tar.gz |
* 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
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -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) |