-
Notifications
You must be signed in to change notification settings - Fork 1
/
glibc-compat.h
106 lines (84 loc) · 2.42 KB
/
glibc-compat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef __GLIBC_COMPAT_SYMBOL_H__
#define __GLIBC_COMPAT_SYMBOL_H__ 1
/**
* This file provides compatibility to GLIBC 2.12.
* included it on all C / C++ source code with -include glibc-compat.h
*
*/
#define GLIBC_COMPAT_SYMBOL(FFF, GGG, VER) \
__asm__(".symver " #FFF "," #GGG "@GLIBC_" # VER);
/**
* Pin down the version of libc functions
* */
GLIBC_COMPAT_SYMBOL(memcpy, memcpy, 2.2.5)
/**
*
* Pin down the version of math functions.
*
* */
#ifdef __cplusplus
#include <cmath>
#else
#include <math.h>
#endif
#ifdef __cplusplus
#define CREATE_COMPAT_FUNC1(name, oldname, version) \
extern "C" { \
extern double oldname ## _compat (double); \
GLIBC_COMPAT_SYMBOL(oldname ## _compat, oldname, version) \
static inline double name(double a) { return oldname ## _compat (a); } \
} \
namespace std { \
static inline double name(double a) { return oldname ## _compat (a); } \
}
#else
#define CREATE_COMPAT_FUNC1(name, oldname, version) \
extern double oldname ## _compat (double); \
GLIBC_COMPAT_SYMBOL(oldname ## _compat, oldname, version) \
static inline double name(double a) { return oldname ## _compat (a); }
#endif
#ifdef __cplusplus
extern "C" {
#endif
static int signgam_;
extern double lgamma_r_compat(double, int *);
GLIBC_COMPAT_SYMBOL(lgamma_r_compat, lgamma_r, 2.2.5)
static inline double lgamma_(double a) { return lgamma_r_compat(a, &signgam_); }
#ifdef __cplusplus
namespace std {
static inline double lgamma_(double a) { return lgamma_r_compat(a, &signgam_); }
}
}
#endif
#define lgamma lgamma_
#define signgam signgam_
#ifdef __cplusplus
extern "C" {
#endif
extern double pow_compat(double, double);
GLIBC_COMPAT_SYMBOL(pow_compat, pow, 2.2.5)
static inline double pow_(double a, double b) { return pow_compat(a, b); }
#ifdef __cplusplus
namespace std {
static inline double pow_(double a, double b) { return pow_compat(a, b); }
}
}
#endif
#define pow pow_
CREATE_COMPAT_FUNC1(acosh_, acosh, 2.2.5)
#define acosh acosh_
CREATE_COMPAT_FUNC1(asin_, asin, 2.2.5)
#define asin asin_
CREATE_COMPAT_FUNC1(sinh_, sinh, 2.2.5)
#define sinh sinh_
CREATE_COMPAT_FUNC1(log10_, log10, 2.2.5)
#define log10 log10_
CREATE_COMPAT_FUNC1(cosh_, cosh, 2.2.5)
#define cosh cosh_
CREATE_COMPAT_FUNC1(log_, log, 2.2.5)
#define log log_
CREATE_COMPAT_FUNC1(exp_, exp, 2.2.5)
#define exp exp_
CREATE_COMPAT_FUNC1(atanh_, atanh, 2.2.5)
#define atanh atanh_
#endif /*__GLIBC_COMPAT_SYMBOL_H__*/