svn commit: samba r12761 - in branches/SAMBA_4_0/source/lib: .
metze at samba.org
metze at samba.org
Sun Jan 8 00:09:50 GMT 2006
Author: metze
Date: 2006-01-08 00:09:49 +0000 (Sun, 08 Jan 2006)
New Revision: 12761
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=12761
Log:
get the TIME_T_MIN and TIME_T_MAX right again, merging from samba3 was a bad idea...
as in samba4 we use TIME_T_MIN = 0 (maybe we should do this in samba3 too) because
negativ values mean error.
but still restrict TIME_T_MAX to INT32_MAX, to not overflow gmtime() on 64 bit systems,
is this behavior documented somewhere?
metze
Modified:
branches/SAMBA_4_0/source/lib/time.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/time.c
===================================================================
--- branches/SAMBA_4_0/source/lib/time.c 2006-01-07 22:11:30 UTC (rev 12760)
+++ branches/SAMBA_4_0/source/lib/time.c 2006-01-08 00:09:49 UTC (rev 12761)
@@ -27,14 +27,26 @@
#define CHAR_BIT 8
#endif
+/* The extra casts work around common compiler bugs. */
+#define _TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
+ It is necessary at least when t == time_t. */
+#define _TYPE_MINIMUM(t) ((t) (_TYPE_SIGNED (t) \
+ ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
+#define _TYPE_MAXIMUM(t) ((t) (~ (t) 0 - _TYPE_MINIMUM (t)))
+
#ifndef TIME_T_MIN
-#define TIME_T_MIN ((time_t)0 < (time_t) -1 ? (time_t) 0 \
- : ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1))
+/* we use 0 here, because (time_t)-1 means error */
+#define TIME_T_MIN 0
#endif
#ifndef TIME_T_MAX
-#define TIME_T_MAX MIN(INT32_MAX,(~ (time_t) 0 - TIME_T_MIN))
+/*
+ * we use the INT32_MAX here as on 64 bit systems,
+ * gmtime() fails with INT64_MAX
+ */
+#define TIME_T_MAX MIN(INT32_MAX,_TYPE_MAXIMUM(time_t))
#endif
-
+
/*******************************************************************
External access to time_t_min and time_t_max.
********************************************************************/
More information about the samba-cvs
mailing list