summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-12-22 11:13:05 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:38 -0500
commitd04ef04c7abea3692b1dc507e1f958f6a2777071 (patch)
tree638265773a508e9d4b6defa26cc9fb84ec7b1b3e /source4
parent7448b93a2e7a21fe2233706fc7b7ced1e98a41d3 (diff)
downloadsamba-d04ef04c7abea3692b1dc507e1f958f6a2777071.tar.gz
samba-d04ef04c7abea3692b1dc507e1f958f6a2777071.tar.bz2
samba-d04ef04c7abea3692b1dc507e1f958f6a2777071.zip
r12431: - the TIME_T_MAX needs to be a singed max value
- fix the calculation of TIME_T_MAX -> nttime -> TIME_T_MAX metze (This used to be commit 9caf4b9a42b02db85b3eb233c74316dcccb12537)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/time.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/source4/lib/time.c b/source4/lib/time.c
index c9cf0b9630..b8ef3d7724 100644
--- a/source4/lib/time.c
+++ b/source4/lib/time.c
@@ -23,13 +23,26 @@
#include "includes.h"
#include "system/time.h"
+#ifndef CHAR_BIT
+# 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 0
#endif
#ifndef TIME_T_MAX
-#define TIME_T_MAX (~(time_t)0)
+#define TIME_T_MAX _TYPE_MAXIMUM (time_t)
#endif
-
+
+
/*******************************************************************
External access to time_t_min and time_t_max.
********************************************************************/
@@ -69,7 +82,7 @@ time_t nt_time_to_unix(NTTIME nt)
nt /= 1000*1000*10;
nt -= TIME_FIXUP_CONSTANT;
- if (TIME_T_MIN >= nt || nt >= TIME_T_MAX) {
+ if (TIME_T_MIN > nt || nt > TIME_T_MAX) {
return 0;
}