public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Sebastian Huber <sh@sourceware.org>
To: cygwin-cvs@sourceware.org, newlib-cvs@sourceware.org
Subject: [newlib-cygwin] Change time_t to 64-bit by default
Date: Thu, 07 Sep 2017 13:40:00 -0000	[thread overview]
Message-ID: <20170907134046.128755.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=4de8754bac676fc7f29082ccf8281b1c73ce629e

commit 4de8754bac676fc7f29082ccf8281b1c73ce629e
Author: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date:   Thu Sep 7 08:24:22 2017 +0200

    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>

Diff:
---
 newlib/README                         |  6 ++++++
 newlib/configure                      | 26 ++++++++++++++++++++++++--
 newlib/configure.in                   | 15 +++++++++++++++
 newlib/libc/include/sys/_types.h      |  6 +++++-
 newlib/libc/include/sys/config.h      |  6 ++++++
 newlib/newlib.hin                     |  3 +++
 winsup/cygwin/include/cygwin/config.h |  1 +
 7 files changed, 60 insertions(+), 3 deletions(-)

diff --git a/newlib/README b/newlib/README
index 78f4de8..8c97e24 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 b2f0b33..eb4b3b2 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 5b86ee8..9d30481 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 d27979c..72e1dc1 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 8dc0c5e..2082dfd 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 45c6831..18306f2 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 aede45f..282637b 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)


                 reply	other threads:[~2017-09-07 13:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170907134046.128755.qmail@sourceware.org \
    --to=sh@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    --cc=newlib-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).