Bitcoin Core  0.18.99
P2P Digital Currency
glibc_compat.cpp
Go to the documentation of this file.
1 // Copyright (c) 2009-2018 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 
5 #if defined(HAVE_CONFIG_H)
7 #endif
8 
9 #include <cstddef>
10 #include <cstdint>
11 
12 #if defined(HAVE_SYS_SELECT_H)
13 #include <sys/select.h>
14 #endif
15 
16 // Prior to GLIBC_2.14, memcpy was aliased to memmove.
17 extern "C" void* memmove(void* a, const void* b, size_t c);
18 extern "C" void* memcpy(void* a, const void* b, size_t c)
19 {
20  return memmove(a, b, c);
21 }
22 
23 extern "C" void __chk_fail(void) __attribute__((__noreturn__));
24 extern "C" FDELT_TYPE __fdelt_warn(FDELT_TYPE a)
25 {
26  if (a >= FD_SETSIZE)
27  __chk_fail();
28  return a / __NFDBITS;
29 }
30 extern "C" FDELT_TYPE __fdelt_chk(FDELT_TYPE) __attribute__((weak, alias("__fdelt_warn")));
31 
32 #if defined(__i386__) || defined(__arm__)
33 
34 extern "C" int64_t __udivmoddi4(uint64_t u, uint64_t v, uint64_t* rp);
35 
36 extern "C" int64_t __wrap___divmoddi4(int64_t u, int64_t v, int64_t* rp)
37 {
38  int32_t c1 = 0, c2 = 0;
39  int64_t uu = u, vv = v;
40  int64_t w;
41  int64_t r;
42 
43  if (uu < 0) {
44  c1 = ~c1, c2 = ~c2, uu = -uu;
45  }
46  if (vv < 0) {
47  c1 = ~c1, vv = -vv;
48  }
49 
50  w = __udivmoddi4(uu, vv, (uint64_t*)&r);
51  if (c1)
52  w = -w;
53  if (c2)
54  r = -r;
55 
56  *rp = r;
57  return w;
58 }
59 #endif
60 
61 extern "C" float log2f_old(float x);
62 #ifdef __i386__
63 __asm(".symver log2f_old,log2f@GLIBC_2.1");
64 #elif defined(__amd64__)
65 __asm(".symver log2f_old,log2f@GLIBC_2.2.5");
66 #elif defined(__arm__)
67 __asm(".symver log2f_old,log2f@GLIBC_2.4");
68 #elif defined(__aarch64__)
69 __asm(".symver log2f_old,log2f@GLIBC_2.17");
70 #elif defined(__riscv)
71 __asm(".symver log2f_old,log2f@GLIBC_2.27");
72 #endif
73 extern "C" float __wrap_log2f(float x)
74 {
75  return log2f_old(x);
76 }
FDELT_TYPE __fdelt_warn(FDELT_TYPE a)
void __chk_fail(void) __attribute__((__noreturn__))
float __wrap_log2f(float x)
float log2f_old(float x)
FDELT_TYPE __fdelt_chk(FDELT_TYPE) __attribute__((weak
void * memcpy(void *a, const void *b, size_t c)
void * memmove(void *a, const void *b, size_t c)
FDELT_TYPE alias("__fdelt_warn")))