summaryrefslogtreecommitdiffstats
path: root/source/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source/lib')
-rw-r--r--source/lib/replace/dlfcn.m413
-rw-r--r--source/lib/time.c43
2 files changed, 48 insertions, 8 deletions
diff --git a/source/lib/replace/dlfcn.m4 b/source/lib/replace/dlfcn.m4
index 2d5b2c5141a..d42409ac630 100644
--- a/source/lib/replace/dlfcn.m4
+++ b/source/lib/replace/dlfcn.m4
@@ -2,17 +2,18 @@ dnl dummies provided by dlfcn.c if not available
save_LIBS="$LIBS"
LIBS=""
+libreplace_cv_dlfcn=no
AC_SEARCH_LIBS(dlopen, dl)
-if test "$ac_cv_search_dlopen" != no; then
+if test x"${ac_cv_search_dlopen}" = x"no"; then
+ libreplace_cv_dlfcn=yes
+else
AC_CHECK_HEADERS(dlfcn.h)
-
- libreplace_cv_dlfcn=no
AC_CHECK_FUNCS([dlopen dlsym dlerror dlclose],[],[libreplace_cv_dlfcn=yes])
+fi
- if test x"${libreplace_cv_dlfcn}" = x"yes";then
- LIBREPLACEOBJ="${LIBREPLACEOBJ} dlfcn.o"
- fi
+if test x"${libreplace_cv_dlfcn}" = x"yes";then
+ LIBREPLACEOBJ="${LIBREPLACEOBJ} dlfcn.o"
fi
LIBDL="$LIBS"
diff --git a/source/lib/time.c b/source/lib/time.c
index e98f8232abc..ee44f5eb134 100644
--- a/source/lib/time.c
+++ b/source/lib/time.c
@@ -95,7 +95,13 @@ void unix_to_nt_time(NTTIME *nt, time_t t)
if (t == (time_t)-1) {
*nt = (NTTIME)-1LL;
return;
- }
+ }
+
+ if (t == TIME_T_MAX) {
+ *nt = 0x7fffffffffffffffLL;
+ return;
+ }
+
if (t == 0) {
*nt = 0;
return;
@@ -301,7 +307,9 @@ char *http_timestring(time_t t)
static fstring buf;
struct tm *tm = localtime(&t);
- if (!tm) {
+ if (t == TIME_T_MAX) {
+ slprintf(buf,sizeof(buf)-1,"never");
+ } else if (!tm) {
slprintf(buf,sizeof(buf)-1,"%ld seconds since the Epoch",(long)t);
} else {
#ifndef HAVE_STRFTIME
@@ -554,6 +562,37 @@ NTTIME timeval_to_nttime(const struct timeval *tv)
((TIME_FIXUP_CONSTANT_INT + (uint64_t)tv->tv_sec) * 1000000));
}
+/**************************************************************
+ Handle conversions between time_t and uint32, taking care to
+ preserve the "special" values.
+**************************************************************/
+
+uint32 convert_time_t_to_uint32(time_t t)
+{
+#if (defined(SIZEOF_TIME_T) && (SIZEOF_TIME_T == 8))
+ /* time_t is 64-bit. */
+ if (t == 0x8000000000000000LL) {
+ return 0x80000000;
+ } else if (t == 0x7FFFFFFFFFFFFFFFLL) {
+ return 0x7FFFFFFF;
+ }
+#endif
+ return (uint32)t;
+}
+
+time_t convert_uint32_to_time_t(uint32 u)
+{
+#if (defined(SIZEOF_TIME_T) && (SIZEOF_TIME_T == 8))
+ /* time_t is 64-bit. */
+ if (u == 0x80000000) {
+ return (time_t)0x8000000000000000LL;
+ } else if (u == 0x7FFFFFFF) {
+ return (time_t)0x7FFFFFFFFFFFFFFFLL;
+ }
+#endif
+ return (time_t)u;
+}
+
/*******************************************************************
Yield the difference between *A and *B, in seconds, ignoring leap seconds.
********************************************************************/