[core] Y2038: use _TIME_BITS=64 on 32-bit glibc

Y2038: use _TIME_BITS=64 on 32-bit glibc platforms

reference:
https://www.phoronix.com/scan.php?page=news_item&px=Glibc-More-Y2038-Work
This commit is contained in:
Glenn Strauss 2021-07-12 22:35:19 -04:00
parent 1ccc1d4ff5
commit 92576a2f4b
5 changed files with 17 additions and 2 deletions

View File

@ -294,6 +294,7 @@ if env['CC'] == 'gcc':
env.Append(CCFLAGS = Split('-pipe -Wall -O2 -g -W -pedantic -Wunused -Wshadow -std=gnu99'))
env.Append(CPPFLAGS = [
'-D_TIME_BITS=64',
'-D_FILE_OFFSET_BITS=64',
'-D_LARGEFILE_SOURCE',
'-D_LARGE_FILES',

View File

@ -1553,7 +1553,7 @@ AC_ARG_ENABLE([lfs],
)
AC_MSG_RESULT([$ENABLE_LFS])
if test "$ENABLE_LFS" = yes; then
CPPFLAGS="${CPPFLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES"
CPPFLAGS="${CPPFLAGS} -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES"
AC_SYS_LARGEFILE
fi

View File

@ -11,7 +11,7 @@ include(FindPkgConfig)
include(LighttpdMacros)
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -D_DEFAULT_SOURCE)
add_definitions(-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -D_DEFAULT_SOURCE)
# default to ON
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Default value for ``POSITION_INDEPENDENT_CODE`` of targets.")

View File

@ -21,6 +21,16 @@
#define _Float32 float
#endif
/* enable glibc Y2038 64-bit time_t (where available on 32-bit systems) */
#ifdef _ILP32
#ifndef _TIME_BITS
#define _TIME_BITS 64
#endif
#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
#endif
#endif
#include <sys/types.h>
#include <stddef.h>
@ -60,6 +70,8 @@
#elif defined(__TIMESIZE)
#if __TIMESIZE == 64
#define HAS_TIME_BITS64 1
#elif defined(__USE_TIME_BITS64)
#define HAS_TIME_BITS64 1
#else
#define HAS_TIME_BITS64 0
#endif
@ -70,6 +82,7 @@
#define HAS_TIME_BITS64 0
#endif
#elif defined(_ILP32) \
&& !defined(__USE_TIME_BITS64) \
&& !defined(__NetBSD__) && !defined(__OpenBSD__) \
&& (!defined(__FreeBSD__) || !defined(__i386__)) \
&& !(defined(__APPLE__) && defined(__MACH__))

View File

@ -8,6 +8,7 @@ include_base_paths = [
]
defs = [
'-D_TIME_BITS=64',
'-D_FILE_OFFSET_BITS=64',
'-D_LARGEFILE_SOURCE',
'-D_LARGE_FILES',