[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Fix logic to set TIME_T_MAX; apparently, everybody had thou...
Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv14595/src/common
Modified Files:
torint.h
Log Message:
Fix logic to set TIME_T_MAX; apparently, everybody had thought of the prospect of a signed time_t but me.
Index: torint.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/torint.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- torint.h 9 Jun 2005 19:03:31 -0000 1.21
+++ torint.h 25 Jul 2005 18:10:08 -0000 1.22
@@ -224,6 +224,16 @@
#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 @@
#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))