-
Notifications
You must be signed in to change notification settings - Fork 0
/
musl.patch
217 lines (194 loc) · 5.09 KB
/
musl.patch
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
diff --git a/include/math.h b/include/math.h
index 14f28ec8..bcb19851 100644
--- a/include/math.h
+++ b/include/math.h
@@ -65,39 +65,18 @@ static __inline unsigned long long __DOUBLE_BITS(double __f)
return __u.__i;
}
-#define fpclassify(x) ( \
- sizeof(x) == sizeof(float) ? __fpclassifyf(x) : \
- sizeof(x) == sizeof(double) ? __fpclassify(x) : \
- __fpclassifyl(x) )
-
-#define isinf(x) ( \
- sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) == 0x7f800000 : \
- sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) == 0x7ffULL<<52 : \
- __fpclassifyl(x) == FP_INFINITE)
-
-#define isnan(x) ( \
- sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000 : \
- sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) > 0x7ffULL<<52 : \
- __fpclassifyl(x) == FP_NAN)
-
-#define isnormal(x) ( \
- sizeof(x) == sizeof(float) ? ((__FLOAT_BITS(x)+0x00800000) & 0x7fffffff) >= 0x01000000 : \
- sizeof(x) == sizeof(double) ? ((__DOUBLE_BITS(x)+(1ULL<<52)) & -1ULL>>1) >= 1ULL<<53 : \
- __fpclassifyl(x) == FP_NORMAL)
-
-#define isfinite(x) ( \
- sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) < 0x7f800000 : \
- sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) < 0x7ffULL<<52 : \
- __fpclassifyl(x) > FP_INFINITE)
+int fpclassify(double);
+
+int isfinite(double x);
+int isinf(double x);
+int isnan(double x);
+int isnormal(double x);
int __signbit(double);
int __signbitf(float);
int __signbitl(long double);
-#define signbit(x) ( \
- sizeof(x) == sizeof(float) ? (int)(__FLOAT_BITS(x)>>31) : \
- sizeof(x) == sizeof(double) ? (int)(__DOUBLE_BITS(x)>>63) : \
- __signbitl(x) )
+int signbit(double);
#define isunordered(x,y) (isnan((x)) ? ((void)(y),1) : isnan((y)))
@@ -200,6 +179,7 @@ double expm1(double);
float expm1f(float);
long double expm1l(long double);
+int abs(int);
double fabs(double);
float fabsf(float);
long double fabsl(long double);
diff --git a/include/stdio.h b/include/stdio.h
index 3604198c..ba195062 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -25,11 +25,13 @@ extern "C" {
#include <bits/alltypes.h>
+#ifndef NULL
#ifdef __cplusplus
#define NULL 0L
#else
#define NULL ((void*)0)
#endif
+#endif
#undef EOF
#define EOF (-1)
diff --git a/include/stdlib.h b/include/stdlib.h
index b54a051f..efb3b0a1 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -7,11 +7,13 @@ extern "C" {
#include <features.h>
+#ifndef NULL
#ifdef __cplusplus
#define NULL 0L
#else
#define NULL ((void*)0)
#endif
+#endif
#define __NEED_size_t
#define __NEED_wchar_t
diff --git a/include/string.h b/include/string.h
index 795a2abc..df0b98b9 100644
--- a/include/string.h
+++ b/include/string.h
@@ -7,11 +7,13 @@ extern "C" {
#include <features.h>
+#ifndef NULL
#ifdef __cplusplus
#define NULL 0L
#else
#define NULL ((void*)0)
#endif
+#endif
#define __NEED_size_t
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
diff --git a/include/time.h b/include/time.h
index 5494df18..1b180245 100644
--- a/include/time.h
+++ b/include/time.h
@@ -7,11 +7,13 @@ extern "C" {
#include <features.h>
+#ifndef NULL
#ifdef __cplusplus
#define NULL 0L
#else
#define NULL ((void*)0)
#endif
+#endif
#define __NEED_size_t
diff --git a/include/wchar.h b/include/wchar.h
index 88eb55b1..9d03ca25 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -38,11 +38,13 @@ extern "C" {
#define WCHAR_MIN (-1-0x7fffffff+L'\0')
#endif
+#ifndef NULL
#ifdef __cplusplus
#define NULL 0L
#else
#define NULL ((void*)0)
#endif
+#endif
#undef WEOF
#define WEOF 0xffffffffU
diff --git a/src/errno/__errno_location.c b/src/errno/__errno_location.c
index 7f9d6027..f89b37a0 100644
--- a/src/errno/__errno_location.c
+++ b/src/errno/__errno_location.c
@@ -1,9 +1,15 @@
#include <errno.h>
#include "pthread_impl.h"
+int errno;
+
int *__errno_location(void)
{
- return &__pthread_self()->errno_val;
+ return &errno;
+ // return &__pthread_self()->errno_val;
}
-weak_alias(__errno_location, ___errno_location);
+int *___errno_location(void) {
+ return &errno;
+ // return &__pthread_self()->errno_val;
+}
diff --git a/src/math/__fpclassify.c b/src/math/__fpclassify.c
index f7c0e2df..a672f2db 100644
--- a/src/math/__fpclassify.c
+++ b/src/math/__fpclassify.c
@@ -9,3 +9,27 @@ int __fpclassify(double x)
if (e==0x7ff) return u.i<<12 ? FP_NAN : FP_INFINITE;
return FP_NORMAL;
}
+
+int fpclassify(double x) {
+ return __fpclassify(x);
+}
+
+int signbit(double x) {
+ return __signbit(x);
+}
+
+int isfinite(double x) {
+ return (__DOUBLE_BITS(x) & -1ULL>>1) < 0x7ffULL<<52;
+}
+
+int isinf(double x) {
+ return (__DOUBLE_BITS(x) & -1ULL>>1) == 0x7ffULL<<52;
+}
+
+int isnan(double x) {
+ return (__DOUBLE_BITS(x) & -1ULL>>1) > 0x7ffULL<<52;
+}
+
+int isnormal(double x) {
+ return ((__DOUBLE_BITS(x)+(1ULL<<52)) & -1ULL>>1) >= 1ULL<<53;
+}
diff --git a/src/string/x86_64/memcpy.s b/src/string/x86_64/memcpy.s
index 3d960efa..aa495768 100644
--- a/src/string/x86_64/memcpy.s
+++ b/src/string/x86_64/memcpy.s
@@ -1,3 +1,4 @@
+//*
.global memcpy
.global __memcpy_fwd
.hidden __memcpy_fwd
@@ -23,3 +24,4 @@ __memcpy_fwd:
dec %edx
jnz 2b
1: ret
+//*/