diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-07-25 18:10:08 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-07-25 18:10:08 +0000 |
commit | 48787c839e394d3c543d847e0173b988ca319cba (patch) | |
tree | 1982c14ed079cc8204e4b9a839a8b664a6aec566 /src/common/torint.h | |
parent | a32f93634697895633de860841d8858e27d79cf9 (diff) | |
download | tor-48787c839e394d3c543d847e0173b988ca319cba.tar.gz tor-48787c839e394d3c543d847e0173b988ca319cba.zip |
Fix logic to set TIME_T_MAX; apparently, everybody had thought of the prospect of a signed time_t but me.
svn:r4675
Diffstat (limited to 'src/common/torint.h')
-rw-r--r-- | src/common/torint.h | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/common/torint.h b/src/common/torint.h index 96464a29ad..baaca80b70 100644 --- a/src/common/torint.h +++ b/src/common/torint.h @@ -224,6 +224,16 @@ typedef uint32_t uintptr_t; #endif #endif +#ifndef INT_MAX +#if (SIZEOF_INT == 4) +#define INT_MAX 0x7fffffffL +#elif (SIZEOF_INT == 8) +#define INT_MAX 0x7fffffffffffffffL +#else +#error "Can't define INT_MAX" +#endif +#endif + #ifndef UINT_MAX #if (SIZEOF_INT == 2) #define UINT_MAX 0xffffu @@ -237,14 +247,28 @@ typedef uint32_t uintptr_t; #endif #ifndef TIME_MAX + +#ifdef TIME_T_IS_SIGNED + +#if (SIZEOF_TIME_T == SIZEOF_INT) +#define TIME_MAX ((time_t)INT_MAX) +#elif (SIZEOF_TIME_T == SIZEOF_LONG) +#define TIME_MAX ((time_t)LONG_MAX) +#else +#error "Can't define (signed) TIME_MAX" +#endif + +#else +/* Unsigned case */ #if (SIZEOF_TIME_T == 4) #define TIME_MAX ((time_t)UINT32_MAX) #elif (SIZEOF_TIME_T == 8) #define TIME_MAX ((time_t)UINT64_MAX) #else -#error "Can't define TIME_MAX" -#endif +#error "Can't define (unsigned) TIME_MAX" #endif +#endif /* time_t_is_signed */ +#endif /* ifndef(TIME_MAX) */ /* Any size_t larger than this amount is likely to be an underflow. */ #define SIZE_T_CEILING (sizeof(char)<<(sizeof(size_t)*8 - 1)) |