summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-07 08:24:22 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-07 15:39:34 +0200
commit4de8754bac676fc7f29082ccf8281b1c73ce629e (patch)
treea45eb9f1ddbd801106e447cc645a8d34fd26ca36
parentad45b86533a47ae33ec99cebc61aee96b57e17a5 (diff)
downloadcygnal-4de8754bac676fc7f29082ccf8281b1c73ce629e.tar.gz
cygnal-4de8754bac676fc7f29082ccf8281b1c73ce629e.tar.bz2
cygnal-4de8754bac676fc7f29082ccf8281b1c73ce629e.zip
Change time_t to 64-bit by default
In order to avoid the year 2038 problem, define time_t to a signed integer with at least 64-bits. The type for time_t can be forced to long with the --enable-newlib-long-time_t configure option or with the _USE_LONG_TIME_T system configuration define. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
-rw-r--r--newlib/README6
-rwxr-xr-xnewlib/configure26
-rw-r--r--newlib/configure.in15
-rw-r--r--newlib/libc/include/sys/_types.h6
-rw-r--r--newlib/libc/include/sys/config.h6
-rw-r--r--newlib/newlib.hin3
-rw-r--r--winsup/cygwin/include/cygwin/config.h1
7 files changed, 60 insertions, 3 deletions
diff --git a/newlib/README b/newlib/README
index 78f4de846..8c97e24aa 100644
--- a/newlib/README
+++ b/newlib/README
@@ -343,6 +343,12 @@ One feature can be enabled by specifying `--enable-FEATURE=yes' or
disables the optimization and saves size of text and stack.
Enabled by default.
+`--enable-newlib-long-time_t'
+ Define time_t to long. On platforms with a 32-bit long type, this gives
+ raise to the year 2038 problem. The default type for time_t is a signed
+ 64-bit integer on most systems.
+ Disabled by default.
+
`--enable-multilib'
Build many library versions.
Enabled by default.
diff --git a/newlib/configure b/newlib/configure
index b2f0b3340..eb4b3b275 100755
--- a/newlib/configure
+++ b/newlib/configure
@@ -804,6 +804,7 @@ enable_newlib_unbuf_stream_opt
enable_lite_exit
enable_newlib_nano_formatted_io
enable_newlib_retargetable_locking
+enable_newlib_long_time_t
enable_multilib
enable_target_optspace
enable_malloc_debugging
@@ -1477,6 +1478,7 @@ Optional Features:
--enable-lite-exit enable light weight exit
--enable-newlib-nano-formatted-io Use nano version formatted IO
--enable-newlib-retargetable-locking Allow locking routines to be retargeted at link time
+ --enable-newlib-long-time_t define time_t to long
--enable-multilib build many library versions (default)
--enable-target-optspace optimize for space
--enable-malloc-debugging indicate malloc debugging requested
@@ -2501,6 +2503,19 @@ else
fi
+# Check whether --enable-newlib-long-time_t was given.
+if test "${enable_newlib_long_time_t+set}" = set; then :
+ enableval=$enable_newlib_long_time_t; if test "${newlib_long_time_t+set}" != set; then
+ case "${enableval}" in
+ yes) newlib_long_time_t=yes ;;
+ no) newlib_long_time_t=no ;;
+ *) as_fn_error $? "bad value ${enableval} for newlib-long-time_t option" "$LINENO" 5 ;;
+ esac
+ fi
+else
+ newlib_nano_malloc=
+fi
+
# Make sure we can run config.sub.
$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
@@ -11807,7 +11822,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11810 "configure"
+#line 11825 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11913,7 +11928,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11916 "configure"
+#line 11931 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12496,6 +12511,13 @@ _ACEOF
fi
+if test "${newlib_long_time_t}" = "yes"; then
+cat >>confdefs.h <<_ACEOF
+#define _WANT_USE_LONG_TIME_T 1
+_ACEOF
+
+fi
+
if test "x${iconv_encodings}" != "x" \
|| test "x${iconv_to_encodings}" != "x" \
diff --git a/newlib/configure.in b/newlib/configure.in
index 5b86ee800..9d304817d 100644
--- a/newlib/configure.in
+++ b/newlib/configure.in
@@ -238,6 +238,17 @@ AC_ARG_ENABLE(newlib-retargetable-locking,
*) AC_MSG_ERROR(bad value ${enableval} for newlib-retargetable-locking) ;;
esac],[newlib_retargetable_locking=no])
+dnl Support --enable-newlib-long-time_t
+AC_ARG_ENABLE(newlib-long-time_t,
+[ --enable-newlib-long-time_t define time_t to long],
+[if test "${newlib_long_time_t+set}" != set; then
+ case "${enableval}" in
+ yes) newlib_long_time_t=yes ;;
+ no) newlib_long_time_t=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for newlib-long-time_t option) ;;
+ esac
+ fi], [newlib_nano_malloc=])dnl
+
NEWLIB_CONFIGURE(.)
dnl We have to enable libtool after NEWLIB_CONFIGURE because if we try and
@@ -486,6 +497,10 @@ if test "${newlib_retargetable_locking}" = "yes"; then
AC_DEFINE_UNQUOTED(_RETARGETABLE_LOCKING)
fi
+if test "${newlib_long_time_t}" = "yes"; then
+AC_DEFINE_UNQUOTED(_WANT_USE_LONG_TIME_T)
+fi
+
dnl
dnl Parse --enable-newlib-iconv-encodings option argument
dnl
diff --git a/newlib/libc/include/sys/_types.h b/newlib/libc/include/sys/_types.h
index d27979c9d..72e1dc17a 100644
--- a/newlib/libc/include/sys/_types.h
+++ b/newlib/libc/include/sys/_types.h
@@ -186,7 +186,11 @@ typedef void *_iconv_t;
typedef _CLOCK_T_ __clock_t;
-#define _TIME_T_ long /* time() */
+#if defined(_USE_LONG_TIME_T) || __LONG_MAX__ > 0x7fffffffL
+#define _TIME_T_ long
+#else
+#define _TIME_T_ __int_least64_t
+#endif
typedef _TIME_T_ __time_t;
#define _CLOCKID_T_ unsigned long
diff --git a/newlib/libc/include/sys/config.h b/newlib/libc/include/sys/config.h
index 8dc0c5e9d..2082dfdb1 100644
--- a/newlib/libc/include/sys/config.h
+++ b/newlib/libc/include/sys/config.h
@@ -283,6 +283,12 @@
#endif
#endif
+#ifdef _WANT_USE_LONG_TIME_T
+#ifndef _USE_LONG_TIME_T
+#define _USE_LONG_TIME_T
+#endif
+#endif
+
/* If _MB_EXTENDED_CHARSETS_ALL is set, we want all of the extended
charsets. The extended charsets add a few functions and a couple
of tables of a few K each. */
diff --git a/newlib/newlib.hin b/newlib/newlib.hin
index 45c683187..18306f293 100644
--- a/newlib/newlib.hin
+++ b/newlib/newlib.hin
@@ -90,6 +90,9 @@
/* Define if using retargetable functions for default lock routines. */
#undef _RETARGETABLE_LOCKING
+/* Define to use type long for time_t. */
+#undef _WANT_USE_LONG_TIME_T
+
/*
* Iconv encodings enabled ("to" direction)
*/
diff --git a/winsup/cygwin/include/cygwin/config.h b/winsup/cygwin/include/cygwin/config.h
index aede45f77..282637b67 100644
--- a/winsup/cygwin/include/cygwin/config.h
+++ b/winsup/cygwin/include/cygwin/config.h
@@ -79,6 +79,7 @@ extern inline struct _reent *__getreent (void)
#define _STDIO_BSD_SEMANTICS 1
#define __TM_GMTOFF tm_gmtoff
#define __TM_ZONE tm_zone
+#define _USE_LONG_TIME_T 1
#if defined(__INSIDE_CYGWIN__) || defined(_COMPILING_NEWLIB)
#define __EXPORT __declspec(dllexport)