compat: wrap clock_gettime

wraps librt clock_gettime for backward compatibility with glibc
versions < 2.17.
This commit is contained in:
Patrick Lodder 2023-01-18 01:14:43 +01:00
parent 87b1dc9300
commit 99cbe5129a
No known key found for this signature in database
GPG Key ID: 2D3A345B98D0DC1F
2 changed files with 16 additions and 0 deletions

View File

@ -503,6 +503,7 @@ if test x$use_glibc_compat != xno; then
[ fdelt_type="long int"])
AC_MSG_RESULT($fdelt_type)
AC_DEFINE_UNQUOTED(FDELT_TYPE, $fdelt_type,[parameter and return value type for __fdelt_chk])
AX_CHECK_LINK_FLAG([[-Wl,--wrap=clock_gettime]], [COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=clock_gettime"])
AX_CHECK_LINK_FLAG([[-Wl,--wrap=__divmoddi4]], [COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=__divmoddi4"])
AX_CHECK_LINK_FLAG([[-Wl,--wrap=exp]], [COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=exp"])
AX_CHECK_LINK_FLAG([[-Wl,--wrap=log]], [COMPAT_LDFLAGS="$COMPAT_LDFLAGS -Wl,--wrap=log"])

View File

@ -9,6 +9,7 @@
#include <cstddef>
#include <cstdint>
#include <time.h>
#if defined(HAVE_SYS_SELECT_H)
#include <sys/select.h>
@ -115,3 +116,17 @@ __asm(".symver pow_old,pow@GLIBC_2.17");
extern "C" double __wrap_pow(double x, double y) {
return pow_old(x,y);
}
extern "C" int clock_gettime_old(clockid_t a, struct timespec *b);
#ifdef __i386__
__asm(".symver clock_gettime_old,clock_gettime@GLIBC_2.2");
#elif defined(__amd64__)
__asm(".symver clock_gettime_old,clock_gettime@GLIBC_2.2.5");
#elif defined(__arm__)
__asm(".symver clock_gettime_old,clock_gettime@GLIBC_2.4");
#elif defined(__aarch64__)
__asm(".symver clock_gettime_old,clock_gettime@GLIBC_2.17");
#endif
extern "C" int __wrap_clock_gettime(clockid_t a, struct timespec *b) {
return clock_gettime_old(a, b);
}