Changeset View
Changeset View
Standalone View
Standalone View
src/compat/glibc_compat.cpp
// Copyright (c) 2009-2014 The Bitcoin Core developers | // Copyright (c) 2009-2014 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#if defined(HAVE_CONFIG_H) | #if defined(HAVE_CONFIG_H) | ||||
#include <config/bitcoin-config.h> | #include <config/bitcoin-config.h> | ||||
#endif | #endif | ||||
#include <cstdarg> | |||||
#include <cstddef> | #include <cstddef> | ||||
#include <cstdint> | #include <cstdint> | ||||
#if defined(HAVE_SYS_SELECT_H) | #if defined(HAVE_SYS_SELECT_H) | ||||
#include <sys/select.h> | #include <sys/select.h> | ||||
#endif | #endif | ||||
// Prior to GLIBC_2.14, memcpy was aliased to memmove. | // Prior to GLIBC_2.14, memcpy was aliased to memmove. | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
#elif defined(__arm__) | #elif defined(__arm__) | ||||
__asm(".symver log2f_old,log2f@GLIBC_2.4"); | __asm(".symver log2f_old,log2f@GLIBC_2.4"); | ||||
#elif defined(__aarch64__) | #elif defined(__aarch64__) | ||||
__asm(".symver log2f_old,log2f@GLIBC_2.17"); | __asm(".symver log2f_old,log2f@GLIBC_2.17"); | ||||
#endif | #endif | ||||
extern "C" float __wrap_log2f(float x) { | extern "C" float __wrap_log2f(float x) { | ||||
return log2f_old(x); | return log2f_old(x); | ||||
} | } | ||||
/* | |||||
* Starting with GLIBC_2.28, the `fcntl()` function has a new variant | |||||
* `fcntl64()`: | |||||
* https://gitlab.com/freedesktop-sdk/mirrors/glibc/commit/06ab719d30b01da401150068054d3b8ea93dd12f | |||||
* (link to a mirror, glibc has no online source browser). | |||||
* | |||||
* See also the release notes for the 2.28 version: | |||||
* https://www.sourceware.org/ml/libc-alpha/2018-08/msg00003.html | |||||
* | |||||
* This is intended to fix a bug related to large file support on architectures | |||||
* where off_t and off64_t are not the same underlying type. | |||||
* To remain compatible with the previous versions, the GLIBC offers a | |||||
* compatibility symbol for these architectures. We can link the new `fcntl()` | |||||
* and `fcntl64()` against this symbol with the help of a wrapper. | |||||
*/ | |||||
#if defined(HAVE_CONFIG_H) && !defined(OFF_T_EQUALS_OFF64_T) | |||||
extern "C" int fcntl_old(int fd, int cmd, ...); | |||||
#ifdef __i386__ | |||||
__asm(".symver fcntl_old,fcntl@GLIBC_2.0"); | |||||
#elif defined(__amd64__) | |||||
__asm(".symver fcntl_old,fcntl@GLIBC_2.2.5"); | |||||
#elif defined(__arm__) | |||||
__asm(".symver fcntl_old,fcntl@GLIBC_2.4"); | |||||
#elif defined(__aarch64__) | |||||
__asm(".symver fcntl_old,fcntl@GLIBC_2.17"); | |||||
#endif | |||||
extern "C" int __wrap_fcntl(int fd, int cmd, ...) { | |||||
int ret; | |||||
va_list vargs; | |||||
va_start(vargs, cmd); | |||||
ret = fcntl_old(fd, cmd, va_arg(vargs, void *)); | |||||
va_end(vargs); | |||||
return ret; | |||||
} | |||||
extern "C" int __wrap_fcntl64(int fd, int cmd, ...) { | |||||
int ret; | |||||
va_list vargs; | |||||
va_start(vargs, cmd); | |||||
ret = fcntl_old(fd, cmd, va_arg(vargs, void *)); | |||||
va_end(vargs); | |||||
return ret; | |||||
} | |||||
#endif |