Browse Source

[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
master
Glenn Strauss 5 months ago
parent
commit
92576a2f4b
  1. 1
      SConstruct
  2. 2
      configure.ac
  3. 2
      src/CMakeLists.txt
  4. 13
      src/first.h
  5. 1
      src/meson.build

1
SConstruct

@ -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',

2
configure.ac

@ -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

2
src/CMakeLists.txt

@ -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.")

13
src/first.h

@ -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__))

1
src/meson.build

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

Loading…
Cancel
Save