mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* internal.h (SIGNED_INTEGER_TYPE_P): New macro.
(SIGNED_INTEGER_MAX): Ditto. (SIGNED_INTEGER_MIN): Ditto. (UNSIGNED_INTEGER_MAX): Ditto. (TIMET_MAX): Use SIGNED_INTEGER_MAX and UNSIGNED_INTEGER_MAX. (TIMET_MIN): Use SIGNED_INTEGER_MIN. * thread.c (TIMEVAL_SEC_MAX): Use SIGNED_INTEGER_MAX. (TIMEVAL_SEC_MIN): Use SIGNED_INTEGER_MIN. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e88a692a88
commit
d907adecd9
3 changed files with 25 additions and 8 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
Sat Apr 27 15:50:40 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* internal.h (SIGNED_INTEGER_TYPE_P): New macro.
|
||||
(SIGNED_INTEGER_MAX): Ditto.
|
||||
(SIGNED_INTEGER_MIN): Ditto.
|
||||
(UNSIGNED_INTEGER_MAX): Ditto.
|
||||
(TIMET_MAX): Use SIGNED_INTEGER_MAX and UNSIGNED_INTEGER_MAX.
|
||||
(TIMET_MIN): Use SIGNED_INTEGER_MIN.
|
||||
|
||||
* thread.c (TIMEVAL_SEC_MAX): Use SIGNED_INTEGER_MAX.
|
||||
(TIMEVAL_SEC_MIN): Use SIGNED_INTEGER_MIN.
|
||||
|
||||
Sat Apr 27 10:52:52 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* thread.c (TIMEVAL_SEC_MAX, TIMEVAL_SEC_MIN): Consider environments,
|
||||
|
|
15
internal.h
15
internal.h
|
@ -25,12 +25,19 @@ extern "C" {
|
|||
(__GNUC__ == (major) && __GNUC_MINOR__ > (minor)) || \
|
||||
(__GNUC__ == (major) && __GNUC_MINOR__ == (minor) && __GNUC_PATCHLEVEL__ >= (patchlevel))))
|
||||
|
||||
#define SIGNED_INTEGER_TYPE_P(int_type) (0 > ((int_type)0)-1)
|
||||
#define SIGNED_INTEGER_MAX(sint_type) \
|
||||
((((sint_type)1) << (sizeof(sint_type) * CHAR_BIT - 2)) | \
|
||||
((((sint_type)1) << (sizeof(sint_type) * CHAR_BIT - 2)) - 1))
|
||||
#define SIGNED_INTEGER_MIN(sint_type) (-SIGNED_INTEGER_MAX(sint_type)-1)
|
||||
#define UNSIGNED_INTEGER_MAX(uint_type) (~(uint_type)0)
|
||||
|
||||
#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 SIGNED_INTEGER_MAX(time_t)
|
||||
# define TIMET_MIN SIGNED_INTEGER_MIN(time_t)
|
||||
#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 UNSIGNED_INTEGER_MAX(time_t)
|
||||
# define TIMET_MIN ((time_t)0)
|
||||
#endif
|
||||
#define TIMET_MAX_PLUS_ONE (2*(double)(TIMET_MAX/2+1))
|
||||
|
||||
|
|
6
thread.c
6
thread.c
|
@ -922,10 +922,8 @@ thread_value(VALUE self)
|
|||
*/
|
||||
|
||||
#if SIGNEDNESS_OF_TIME_T < 0 /* signed */
|
||||
# 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)
|
||||
# define TIMEVAL_SEC_MAX SIGNED_INTEGER_MAX(TYPEOF_TIMEVAL_TV_SEC)
|
||||
# define TIMEVAL_SEC_MIN SIGNED_INTEGER_MIN(TYPEOF_TIMEVAL_TV_SEC)
|
||||
#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)
|
||||
|
|
Loading…
Reference in a new issue