Bitcoin ABC  0.28.12
P2P Digital Currency
glibc_compat.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2014 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 #include <cstdarg>
5 
6 /*
7  * Starting with GLIBC_2.28, the `fcntl()` function has a new variant
8  * `fcntl64()`:
9  * https://gitlab.com/freedesktop-sdk/mirrors/glibc/commit/06ab719d30b01da401150068054d3b8ea93dd12f
10  * (link to a mirror, glibc has no online source browser).
11  *
12  * See also the release notes for the 2.28 version:
13  * https://www.sourceware.org/ml/libc-alpha/2018-08/msg00003.html
14  *
15  * This is intended to fix a bug related to large file support on architectures
16  * where off_t and off64_t are not the same underlying type.
17  * To remain compatible with the previous versions, the GLIBC offers a
18  * compatibility symbol for these architectures. We can link the new `fcntl()`
19  * and `fcntl64()` against this symbol with the help of a wrapper.
20  */
21 #if defined(HAVE_CONFIG_H) && !defined(HAVE_LARGE_FILE_SUPPORT)
22 extern "C" int fcntl_old(int fd, int cmd, ...);
23 #ifdef __i386__
24 __asm(".symver fcntl_old,fcntl@GLIBC_2.0");
25 #elif defined(__amd64__)
26 __asm(".symver fcntl_old,fcntl@GLIBC_2.2.5");
27 #elif defined(__arm__)
28 __asm(".symver fcntl_old,fcntl@GLIBC_2.4");
29 #elif defined(__aarch64__)
30 __asm(".symver fcntl_old,fcntl@GLIBC_2.17");
31 #endif
32 
33 extern "C" int __wrap_fcntl(int fd, int cmd, ...) {
34  int ret;
35  va_list vargs;
36  va_start(vargs, cmd);
37  ret = fcntl_old(fd, cmd, va_arg(vargs, void *));
38  va_end(vargs);
39  return ret;
40 }
41 extern "C" int __wrap_fcntl64(int fd, int cmd, ...) {
42  int ret;
43  va_list vargs;
44  va_start(vargs, cmd);
45  ret = fcntl_old(fd, cmd, va_arg(vargs, void *));
46  va_end(vargs);
47  return ret;
48 }
49 #endif
50 
55 extern "C" float exp_old(float x);
56 #ifdef __i386__
57 __asm(".symver exp_old,exp@GLIBC_2.1");
58 #elif defined(__amd64__)
59 __asm(".symver exp_old,exp@GLIBC_2.2.5");
60 #elif defined(__arm__)
61 __asm(".symver exp_old,exp@GLIBC_2.4");
62 #elif defined(__aarch64__)
63 __asm(".symver exp_old,exp@GLIBC_2.17");
64 #endif
65 extern "C" float __wrap_exp(float x) {
66  return exp_old(x);
67 }
68 
69 extern "C" float log_old(float x);
70 #ifdef __i386__
71 __asm(".symver log_old,log@GLIBC_2.1");
72 #elif defined(__amd64__)
73 __asm(".symver log_old,log@GLIBC_2.2.5");
74 #elif defined(__arm__)
75 __asm(".symver log_old,log@GLIBC_2.4");
76 #elif defined(__aarch64__)
77 __asm(".symver log_old,log@GLIBC_2.17");
78 #endif
79 extern "C" float __wrap_log(float x) {
80  return log_old(x);
81 }
82 
83 extern "C" float log2_old(float x);
84 #ifdef __i386__
85 __asm(".symver log2_old,log2@GLIBC_2.1");
86 #elif defined(__amd64__)
87 __asm(".symver log2_old,log2@GLIBC_2.2.5");
88 #elif defined(__arm__)
89 __asm(".symver log2_old,log2@GLIBC_2.4");
90 #elif defined(__aarch64__)
91 __asm(".symver log2_old,log2@GLIBC_2.17");
92 #endif
93 extern "C" float __wrap_log2(float x) {
94  return log2_old(x);
95 }
96 
97 extern "C" float pow_old(float x);
98 #ifdef __i386__
99 __asm(".symver pow_old,pow@GLIBC_2.1");
100 #elif defined(__amd64__)
101 __asm(".symver pow_old,pow@GLIBC_2.2.5");
102 #elif defined(__arm__)
103 __asm(".symver pow_old,pow@GLIBC_2.4");
104 #elif defined(__aarch64__)
105 __asm(".symver pow_old,pow@GLIBC_2.17");
106 #endif
107 extern "C" float __wrap_pow(float x) {
108  return pow_old(x);
109 }
float __wrap_exp(float x)
float __wrap_log2(float x)
float log2_old(float x)
float __wrap_log(float x)
float pow_old(float x)
float log_old(float x)
float __wrap_pow(float x)
float exp_old(float x)
Starting with GLIBC_2.29 there is an optimized version of the math functions.