Merge branch 'time64' into 'master'

On 32-bit glibc, define _TIME_BITS to 64 if not already defined

Closes #465

See merge request dbus/dbus!416
This commit is contained in:
Simon McVittie 2023-08-14 14:45:53 +00:00
commit 9a47cca662
4 changed files with 54 additions and 0 deletions

View file

@ -72,6 +72,22 @@ check_symbol_exists(socketpair "sys/socket.h" HAVE_SOCKETPAIR) #
check_symbol_exists(unsetenv "stdlib.h" HAVE_UNSETENV) # dbus-sysdeps.c
check_symbol_exists(writev "sys/uio.h" HAVE_WRITEV) # dbus-sysdeps.c, dbus-sysdeps-win.c
# It doesn't really matter which specific header we use for these, as long as
# we include at least one glibc-provided header. time.h is suitable.
check_symbol_exists(__GLIBC__ "time.h" HAVE___GLIBC__)
check_symbol_exists(_FILE_OFFSET_BITS "time.h" HAVE__FILE_OFFSET_BITS)
check_symbol_exists(_TIME_BITS "time.h" HAVE__TIME_BITS)
# Opt-in to large inode number and timestamp support, which we know doesn't
# break libdbus ABI: https://gitlab.freedesktop.org/dbus/dbus/-/issues/465
if(HAVE___GLIBC__ AND CMAKE_SIZEOF_VOID_P EQUAL 4 AND NOT HAVE__FILE_OFFSET_BITS)
set(_FILE_OFFSET_BITS 64)
endif()
if(HAVE___GLIBC__ AND CMAKE_SIZEOF_VOID_P EQUAL 4 AND NOT HAVE__TIME_BITS)
set(_TIME_BITS 64)
endif()
check_struct_member(cmsgcred cmcred_pid "sys/types.h;sys/socket.h" HAVE_CMSGCRED) # dbus-sysdeps.c
CHECK_C_SOURCE_COMPILES("

View file

@ -13,6 +13,8 @@
# define __USE_MINGW_ANSI_STDIO 0
#endif
#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
#cmakedefine _TIME_BITS @_TIME_BITS@
#cmakedefine WORDS_BIGENDIAN
/* Opt-in to modern APIs and thread-safety for Solaris. In the Autotools

View file

@ -546,6 +546,31 @@ fi
AC_SUBST(DBUS_INT16_TYPE)
# Opt-in to large timestamp support, which we know doesn't break libdbus ABI:
# https://gitlab.freedesktop.org/dbus/dbus/-/issues/465
# Currently we only know how to do this for GNU libc.
AC_CHECK_DECL(
[__GLIBC__], [
AC_CHECK_DECL(
[_TIME_BITS],
[time_bits_defined=yes],
[time_bits_defined=no],
[[#include <time.h>]]
)
],
[],
[[#include <time.h>]]
)
AS_IF(
[test "$time_bits_defined" = no && test "$DBUS_SIZEOF_VOID_P" = 4],
[
AC_DEFINE(
[_TIME_BITS], [64],
[Define to 64 if using 32-bit glibc and not already defined]
)
]
)
## byte order
case $host_os in
darwin*)

View file

@ -627,6 +627,17 @@ endif
config.set('DBUS_BUILD_X11', use_x11_autolaunch)
config.set('DBUS_ENABLE_X11_AUTOLAUNCH', use_x11_autolaunch)
# Opt-in to large timestamp support, which we know doesn't break libdbus ABI:
# https://gitlab.freedesktop.org/dbus/dbus/-/issues/465
# Meson does the equivalent for large offsets and inode numbers automatically.
if (
cc.has_header_symbol('time.h', '__GLIBC__', args: compile_args_c)
and not cc.has_header_symbol('time.h', '_TIME_BITS', args: compile_args_c)
and cc.sizeof('void *') == 4
)
config.set('_TIME_BITS', '64')
endif
# keep CMakeLists.txt in sync
check_functions = [
'accept4',