|
| 1 | +#ifdef __linux__ |
| 2 | + |
| 3 | +#include "config.h" |
| 4 | + |
| 5 | +#include <string.h> |
| 6 | +#include <stdarg.h> |
| 7 | +#include <stdlib.h> |
| 8 | +#include <stdio.h> |
| 9 | + |
| 10 | +#ifdef NDEBUG |
| 11 | + |
| 12 | +extern "C" { |
| 13 | + |
| 14 | +// GLIBC_2.14 |
| 15 | +#ifdef GLIB_C_MEMCPY |
| 16 | +__asm__(".symver _memcpy,memcpy@GLIBC_" GLIB_C_MEMCPY); |
| 17 | +void* _memcpy(void* dest, const void* src, size_t n); |
| 18 | +void* memcpy(void* dest, const void* src, size_t n) |
| 19 | +{ |
| 20 | + return _memcpy(dest, src, n); |
| 21 | +} |
| 22 | +#endif |
| 23 | + |
| 24 | +// GLIBC_2.17 |
| 25 | +#ifdef GLIB_C_TIME |
| 26 | +__asm__(".symver _clock_gettime,clock_gettime@GLIBC_" GLIB_C_TIME); |
| 27 | +int _clock_gettime(clockid_t clk_id, struct timespec* tp); |
| 28 | +int clock_gettime(clockid_t clk_id, struct timespec* tp) |
| 29 | +{ |
| 30 | + return _clock_gettime(clk_id, tp); |
| 31 | +} |
| 32 | + |
| 33 | +__asm__(".symver _clock_getres,clock_getres@GLIBC_" GLIB_C_TIME); |
| 34 | +int _clock_getres(clockid_t clk_id, struct timespec* tp); |
| 35 | +int clock_getres(clockid_t clk_id, struct timespec* tp) |
| 36 | +{ |
| 37 | + return _clock_getres(clk_id, tp); |
| 38 | +} |
| 39 | +#endif |
| 40 | + |
| 41 | +// GLIBC_2.28 |
| 42 | +#ifdef GLIB_C_FCNTL |
| 43 | +__asm__(".symver _fcntl,fcntl@GLIBC_" GLIB_C_FCNTL); |
| 44 | +int _fcntl(int fd, int cmd, ...); |
| 45 | +int fcntl64(int fd, int cmd, ...) |
| 46 | +{ |
| 47 | + int result; |
| 48 | + va_list va; |
| 49 | + |
| 50 | + va_start(va, cmd); |
| 51 | + result = _fcntl(fd, cmd, va_arg(va, void*)); |
| 52 | + va_end(va); |
| 53 | + |
| 54 | + return result; |
| 55 | +} |
| 56 | + |
| 57 | +int fcntl(int fd, int cmd, ...) |
| 58 | +{ |
| 59 | + int result; |
| 60 | + va_list va; |
| 61 | + |
| 62 | + va_start(va, cmd); |
| 63 | + result = _fcntl(fd, cmd, va_arg(va, void*)); |
| 64 | + va_end(va); |
| 65 | + |
| 66 | + return result; |
| 67 | +} |
| 68 | +#endif |
| 69 | + |
| 70 | +// GLIBC_2.29 |
| 71 | +#ifdef GLIB_C_MATH |
| 72 | +__asm__(".symver _exp,exp@GLIBC_" GLIB_C_MATH); |
| 73 | +double _exp(double x); |
| 74 | +double exp(double x) |
| 75 | +{ |
| 76 | + return _exp(x); |
| 77 | +} |
| 78 | + |
| 79 | +__asm__(".symver _expf,expf@GLIBC_" GLIB_C_MATH); |
| 80 | +float _expf(float x); |
| 81 | +float expf(float x) |
| 82 | +{ |
| 83 | + return _expf(x); |
| 84 | +} |
| 85 | + |
| 86 | +__asm__(".symver _log,log@GLIBC_" GLIB_C_MATH); |
| 87 | +double _log(double x); |
| 88 | +double log(double x) |
| 89 | +{ |
| 90 | + return _log(x); |
| 91 | +} |
| 92 | + |
| 93 | +__asm__(".symver _logf,logf@GLIBC_" GLIB_C_MATH); |
| 94 | +float _logf(float x); |
| 95 | +float logf(float x) |
| 96 | +{ |
| 97 | + return _logf(x); |
| 98 | +} |
| 99 | + |
| 100 | +__asm__(".symver _pow,pow@GLIBC_" GLIB_C_MATH); |
| 101 | +double _pow(double x, double y); |
| 102 | +double pow(double x, double y) |
| 103 | +{ |
| 104 | + return _pow(x, y); |
| 105 | +} |
| 106 | + |
| 107 | +__asm__(".symver _powf,powf@GLIBC_" GLIB_C_MATH); |
| 108 | +float _powf(float x, float y); |
| 109 | +float powf(float x, float y) |
| 110 | +{ |
| 111 | + return _powf(x, y); |
| 112 | +} |
| 113 | +#endif |
| 114 | + |
| 115 | +#ifdef GLIB_C_MATH2 |
| 116 | +__asm__(".symver _log2,log2@GLIBC_" GLIB_C_MATH); |
| 117 | +double _log2(double x); |
| 118 | +double log2(double x) |
| 119 | +{ |
| 120 | + return _log2(x); |
| 121 | +} |
| 122 | +#endif |
| 123 | +} |
| 124 | + |
| 125 | +#endif |
| 126 | + |
| 127 | +#endif |
0 commit comments