@zigc/lib 0.16.0-test.1 → 0.17.0-dev.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/LICENSE +19 -0
  2. package/c/math.zig +148 -35
  3. package/c/stropts.zig +17 -0
  4. package/c.zig +1 -0
  5. package/compiler/aro/aro/Attribute/names.zig +604 -589
  6. package/compiler/aro/aro/Attribute.zig +202 -116
  7. package/compiler/aro/aro/Builtins/common.zig +874 -863
  8. package/compiler/aro/aro/Builtins/eval.zig +15 -7
  9. package/compiler/aro/aro/Builtins.zig +0 -1
  10. package/compiler/aro/aro/CodeGen.zig +3 -1
  11. package/compiler/aro/aro/Compilation.zig +120 -97
  12. package/compiler/aro/aro/Diagnostics.zig +21 -17
  13. package/compiler/aro/aro/Driver/GCCDetector.zig +635 -0
  14. package/compiler/aro/aro/Driver.zig +124 -50
  15. package/compiler/aro/aro/LangOpts.zig +12 -2
  16. package/compiler/aro/aro/Parser/Diagnostic.zig +79 -19
  17. package/compiler/aro/aro/Parser.zig +336 -142
  18. package/compiler/aro/aro/Preprocessor/Diagnostic.zig +21 -0
  19. package/compiler/aro/aro/Preprocessor.zig +127 -56
  20. package/compiler/aro/aro/Target.zig +17 -12
  21. package/compiler/aro/aro/Tokenizer.zig +31 -14
  22. package/compiler/aro/aro/Toolchain.zig +4 -7
  23. package/compiler/aro/aro/Tree.zig +178 -148
  24. package/compiler/aro/aro/TypeStore.zig +82 -24
  25. package/compiler/aro/aro/Value.zig +13 -17
  26. package/compiler/aro/aro/features.zig +1 -0
  27. package/compiler/aro/aro/pragmas/once.zig +0 -1
  28. package/compiler/aro/aro/record_layout.zig +3 -3
  29. package/compiler/aro/assembly_backend/x86_64.zig +3 -4
  30. package/compiler/aro/backend/Assembly.zig +1 -2
  31. package/compiler/aro/backend/Interner.zig +2 -2
  32. package/compiler/aro/backend/Ir.zig +100 -92
  33. package/compiler/aro/include/ptrcheck.h +49 -0
  34. package/compiler/aro/main.zig +26 -10
  35. package/compiler/build_runner.zig +1 -0
  36. package/compiler/objdump.zig +93 -0
  37. package/compiler/reduce.zig +5 -1
  38. package/compiler/resinator/compile.zig +2 -2
  39. package/compiler/resinator/main.zig +7 -1
  40. package/compiler/resinator/preprocess.zig +1 -3
  41. package/compiler/std-docs.zig +8 -1
  42. package/compiler/test_runner.zig +194 -62
  43. package/compiler/translate-c/MacroTranslator.zig +80 -11
  44. package/compiler/translate-c/PatternList.zig +1 -9
  45. package/compiler/translate-c/Scope.zig +43 -6
  46. package/compiler/translate-c/Translator.zig +364 -126
  47. package/compiler/translate-c/ast.zig +19 -11
  48. package/compiler/translate-c/main.zig +75 -16
  49. package/compiler_rt/cos.zig +141 -52
  50. package/compiler_rt/divmodei4.zig +40 -17
  51. package/compiler_rt/exp.zig +1 -4
  52. package/compiler_rt/exp2.zig +1 -4
  53. package/compiler_rt/exp_f128.zig +377 -0
  54. package/compiler_rt/limb64.zig +1126 -0
  55. package/compiler_rt/long_double.zig +37 -0
  56. package/compiler_rt/mulXi3.zig +1 -1
  57. package/compiler_rt/mulo.zig +6 -1
  58. package/compiler_rt/rem_pio2l.zig +173 -0
  59. package/compiler_rt/sin.zig +140 -55
  60. package/compiler_rt/sincos.zig +279 -72
  61. package/compiler_rt/ssp.zig +1 -1
  62. package/compiler_rt/tan.zig +118 -47
  63. package/compiler_rt/trig.zig +256 -6
  64. package/compiler_rt/udivmodei4.zig +28 -0
  65. package/compiler_rt.zig +2 -0
  66. package/fuzzer.zig +855 -307
  67. package/libc/musl/src/math/pow.c +343 -0
  68. package/package.json +1 -1
  69. package/std/Build/Fuzz.zig +6 -19
  70. package/std/Build/Module.zig +1 -1
  71. package/std/Build/Step/CheckObject.zig +3 -3
  72. package/std/Build/Step/Compile.zig +18 -0
  73. package/std/Build/Step/ConfigHeader.zig +49 -33
  74. package/std/Build/Step/InstallArtifact.zig +18 -0
  75. package/std/Build/Step/Run.zig +536 -87
  76. package/std/Build/Step/TranslateC.zig +0 -6
  77. package/std/Build/Step.zig +8 -15
  78. package/std/Build/WebServer.zig +29 -17
  79. package/std/Build/abi.zig +47 -11
  80. package/std/Build.zig +17 -14
  81. package/std/Io/Dispatch.zig +2 -0
  82. package/std/Io/File/Reader.zig +3 -1
  83. package/std/Io/File.zig +1 -0
  84. package/std/Io/Kqueue.zig +2 -2
  85. package/std/Io/Threaded.zig +181 -143
  86. package/std/Io/Uring.zig +2 -1
  87. package/std/Io/Writer.zig +41 -41
  88. package/std/Io.zig +970 -2
  89. package/std/Target.zig +3 -2
  90. package/std/Thread.zig +8 -3
  91. package/std/array_hash_map.zig +96 -555
  92. package/std/array_list.zig +22 -31
  93. package/std/bit_set.zig +22 -6
  94. package/std/builtin/assembly.zig +68 -0
  95. package/std/c.zig +17 -17
  96. package/std/compress/flate/Compress.zig +3 -3
  97. package/std/crypto/Certificate/Bundle.zig +15 -1
  98. package/std/crypto/codecs/asn1.zig +33 -18
  99. package/std/crypto/codecs/base64_hex_ct.zig +14 -4
  100. package/std/debug/Dwarf.zig +29 -9
  101. package/std/debug/Info.zig +4 -0
  102. package/std/debug/MachOFile.zig +46 -8
  103. package/std/debug/Pdb.zig +539 -36
  104. package/std/debug/SelfInfo/Elf.zig +19 -18
  105. package/std/debug/SelfInfo/MachO.zig +18 -7
  106. package/std/debug/SelfInfo/Windows.zig +138 -36
  107. package/std/debug.zig +179 -65
  108. package/std/enums.zig +25 -19
  109. package/std/heap/ArenaAllocator.zig +145 -154
  110. package/std/heap/debug_allocator.zig +7 -7
  111. package/std/http/Client.zig +10 -6
  112. package/std/http.zig +11 -9
  113. package/std/json/Stringify.zig +3 -3
  114. package/std/json/dynamic.zig +4 -4
  115. package/std/math/big/int.zig +16 -17
  116. package/std/mem/Allocator.zig +4 -5
  117. package/std/mem.zig +48 -0
  118. package/std/os/emscripten.zig +2 -18
  119. package/std/os/linux/arc.zig +144 -0
  120. package/std/os/linux.zig +21 -4
  121. package/std/os/windows.zig +2 -2
  122. package/std/pdb.zig +143 -4
  123. package/std/posix.zig +6 -12
  124. package/std/priority_dequeue.zig +13 -12
  125. package/std/priority_queue.zig +5 -4
  126. package/std/process/Child.zig +1 -1
  127. package/std/process/Environ.zig +1 -1
  128. package/std/start.zig +17 -4
  129. package/std/std.zig +19 -6
  130. package/std/testing/FailingAllocator.zig +4 -4
  131. package/std/testing/Smith.zig +37 -2
  132. package/std/zig/Ast/Render.zig +186 -458
  133. package/std/zig/Ast.zig +0 -4
  134. package/std/zig/AstGen.zig +44 -7
  135. package/std/zig/AstSmith.zig +2602 -0
  136. package/std/zig/Client.zig +8 -3
  137. package/std/zig/Parse.zig +83 -74
  138. package/std/zig/Server.zig +26 -0
  139. package/std/zig/Zir.zig +17 -0
  140. package/std/zig/c_translation/helpers.zig +14 -9
  141. package/std/zig/llvm/Builder.zig +107 -48
  142. package/std/zig/system.zig +20 -4
  143. package/std/zig/tokenizer.zig +2 -1
  144. package/std/zig.zig +6 -0
  145. package/compiler/aro/aro/Driver/Filesystem.zig +0 -241
  146. package/libc/mingw/complex/cabs.c +0 -48
  147. package/libc/mingw/complex/cabsf.c +0 -48
  148. package/libc/mingw/complex/cacos.c +0 -50
  149. package/libc/mingw/complex/cacosf.c +0 -50
  150. package/libc/mingw/complex/carg.c +0 -48
  151. package/libc/mingw/complex/cargf.c +0 -48
  152. package/libc/mingw/complex/casin.c +0 -50
  153. package/libc/mingw/complex/casinf.c +0 -50
  154. package/libc/mingw/complex/catan.c +0 -50
  155. package/libc/mingw/complex/catanf.c +0 -50
  156. package/libc/mingw/complex/ccos.c +0 -50
  157. package/libc/mingw/complex/ccosf.c +0 -50
  158. package/libc/mingw/complex/cexp.c +0 -48
  159. package/libc/mingw/complex/cexpf.c +0 -48
  160. package/libc/mingw/complex/cimag.c +0 -48
  161. package/libc/mingw/complex/cimagf.c +0 -48
  162. package/libc/mingw/complex/clog.c +0 -48
  163. package/libc/mingw/complex/clog10.c +0 -49
  164. package/libc/mingw/complex/clog10f.c +0 -49
  165. package/libc/mingw/complex/clogf.c +0 -48
  166. package/libc/mingw/complex/conj.c +0 -48
  167. package/libc/mingw/complex/conjf.c +0 -48
  168. package/libc/mingw/complex/cpow.c +0 -48
  169. package/libc/mingw/complex/cpowf.c +0 -48
  170. package/libc/mingw/complex/cproj.c +0 -48
  171. package/libc/mingw/complex/cprojf.c +0 -48
  172. package/libc/mingw/complex/creal.c +0 -48
  173. package/libc/mingw/complex/crealf.c +0 -48
  174. package/libc/mingw/complex/csin.c +0 -50
  175. package/libc/mingw/complex/csinf.c +0 -50
  176. package/libc/mingw/complex/csqrt.c +0 -48
  177. package/libc/mingw/complex/csqrtf.c +0 -48
  178. package/libc/mingw/complex/ctan.c +0 -50
  179. package/libc/mingw/complex/ctanf.c +0 -50
  180. package/libc/mingw/math/arm/s_rint.c +0 -86
  181. package/libc/mingw/math/arm/s_rintf.c +0 -51
  182. package/libc/mingw/math/arm/sincos.S +0 -30
  183. package/libc/mingw/math/arm-common/sincosl.c +0 -13
  184. package/libc/mingw/math/arm64/rint.c +0 -12
  185. package/libc/mingw/math/arm64/rintf.c +0 -12
  186. package/libc/mingw/math/arm64/sincos.S +0 -32
  187. package/libc/mingw/math/bsd_private_base.h +0 -148
  188. package/libc/mingw/math/fdiml.c +0 -24
  189. package/libc/mingw/math/frexpf.c +0 -13
  190. package/libc/mingw/math/frexpl.c +0 -71
  191. package/libc/mingw/math/x86/acosf.c +0 -29
  192. package/libc/mingw/math/x86/atanf.c +0 -23
  193. package/libc/mingw/math/x86/atanl.c +0 -18
  194. package/libc/mingw/math/x86/cos.def.h +0 -65
  195. package/libc/mingw/math/x86/cosl.c +0 -46
  196. package/libc/mingw/math/x86/cosl_internal.S +0 -55
  197. package/libc/mingw/math/x86/ldexp.c +0 -23
  198. package/libc/mingw/math/x86/scalbn.S +0 -41
  199. package/libc/mingw/math/x86/scalbnf.S +0 -40
  200. package/libc/mingw/math/x86/sin.def.h +0 -65
  201. package/libc/mingw/math/x86/sinl.c +0 -46
  202. package/libc/mingw/math/x86/sinl_internal.S +0 -58
  203. package/libc/mingw/math/x86/tanl.S +0 -62
  204. package/libc/mingw/misc/btowc.c +0 -28
  205. package/libc/mingw/misc/wcstof.c +0 -66
  206. package/libc/mingw/misc/wcstoimax.c +0 -132
  207. package/libc/mingw/misc/wcstoumax.c +0 -126
  208. package/libc/mingw/misc/wctob.c +0 -29
  209. package/libc/mingw/misc/winbs_uint64.c +0 -6
  210. package/libc/mingw/misc/winbs_ulong.c +0 -6
  211. package/libc/mingw/misc/winbs_ushort.c +0 -6
  212. package/libc/mingw/stdio/_Exit.c +0 -10
  213. package/libc/mingw/stdio/_findfirst64i32.c +0 -21
  214. package/libc/mingw/stdio/_findnext64i32.c +0 -21
  215. package/libc/mingw/stdio/_fstat64i32.c +0 -37
  216. package/libc/mingw/stdio/_stat64i32.c +0 -37
  217. package/libc/mingw/stdio/_wfindfirst64i32.c +0 -21
  218. package/libc/mingw/stdio/_wfindnext64i32.c +0 -21
  219. package/libc/mingw/stdio/_wstat64i32.c +0 -37
  220. package/libc/musl/src/legacy/isastream.c +0 -7
  221. package/libc/musl/src/legacy/valloc.c +0 -8
  222. package/libc/musl/src/math/__cosl.c +0 -96
  223. package/libc/musl/src/math/__sinl.c +0 -78
  224. package/libc/musl/src/math/__tanl.c +0 -143
  225. package/libc/musl/src/math/aarch64/lrint.c +0 -10
  226. package/libc/musl/src/math/aarch64/lrintf.c +0 -10
  227. package/libc/musl/src/math/aarch64/rintf.c +0 -7
  228. package/libc/musl/src/math/cosl.c +0 -39
  229. package/libc/musl/src/math/fdim.c +0 -10
  230. package/libc/musl/src/math/fdimf.c +0 -10
  231. package/libc/musl/src/math/fdiml.c +0 -18
  232. package/libc/musl/src/math/finite.c +0 -7
  233. package/libc/musl/src/math/finitef.c +0 -7
  234. package/libc/musl/src/math/frexp.c +0 -23
  235. package/libc/musl/src/math/frexpf.c +0 -23
  236. package/libc/musl/src/math/frexpl.c +0 -29
  237. package/libc/musl/src/math/i386/lrint.c +0 -8
  238. package/libc/musl/src/math/i386/lrintf.c +0 -8
  239. package/libc/musl/src/math/i386/rintf.c +0 -7
  240. package/libc/musl/src/math/lrint.c +0 -72
  241. package/libc/musl/src/math/lrintf.c +0 -8
  242. package/libc/musl/src/math/powerpc64/lrint.c +0 -16
  243. package/libc/musl/src/math/powerpc64/lrintf.c +0 -16
  244. package/libc/musl/src/math/rintf.c +0 -30
  245. package/libc/musl/src/math/s390x/rintf.c +0 -15
  246. package/libc/musl/src/math/sincosl.c +0 -60
  247. package/libc/musl/src/math/sinl.c +0 -41
  248. package/libc/musl/src/math/tanl.c +0 -29
  249. package/libc/musl/src/math/x32/lrint.s +0 -5
  250. package/libc/musl/src/math/x32/lrintf.s +0 -5
  251. package/libc/musl/src/math/x86_64/lrint.c +0 -8
  252. package/libc/musl/src/math/x86_64/lrintf.c +0 -8
  253. package/libc/wasi/libc-bottom-half/sources/reallocarray.c +0 -14
@@ -0,0 +1,343 @@
1
+ /*
2
+ * Double-precision x^y function.
3
+ *
4
+ * Copyright (c) 2018, Arm Limited.
5
+ * SPDX-License-Identifier: MIT
6
+ */
7
+
8
+ #include <math.h>
9
+ #include <stdint.h>
10
+ #include "libm.h"
11
+ #include "exp_data.h"
12
+ #include "pow_data.h"
13
+
14
+ /*
15
+ Worst-case error: 0.54 ULP (~= ulperr_exp + 1024*Ln2*relerr_log*2^53)
16
+ relerr_log: 1.3 * 2^-68 (Relative error of log, 1.5 * 2^-68 without fma)
17
+ ulperr_exp: 0.509 ULP (ULP error of exp, 0.511 ULP without fma)
18
+ */
19
+
20
+ #define T __pow_log_data.tab
21
+ #define A __pow_log_data.poly
22
+ #define Ln2hi __pow_log_data.ln2hi
23
+ #define Ln2lo __pow_log_data.ln2lo
24
+ #define N (1 << POW_LOG_TABLE_BITS)
25
+ #define OFF 0x3fe6955500000000
26
+
27
+ /* Top 12 bits of a double (sign and exponent bits). */
28
+ static inline uint32_t top12(double x)
29
+ {
30
+ return asuint64(x) >> 52;
31
+ }
32
+
33
+ /* Compute y+TAIL = log(x) where the rounded result is y and TAIL has about
34
+ additional 15 bits precision. IX is the bit representation of x, but
35
+ normalized in the subnormal range using the sign bit for the exponent. */
36
+ static inline double_t log_inline(uint64_t ix, double_t *tail)
37
+ {
38
+ /* double_t for better performance on targets with FLT_EVAL_METHOD==2. */
39
+ double_t z, r, y, invc, logc, logctail, kd, hi, t1, t2, lo, lo1, lo2, p;
40
+ uint64_t iz, tmp;
41
+ int k, i;
42
+
43
+ /* x = 2^k z; where z is in range [OFF,2*OFF) and exact.
44
+ The range is split into N subintervals.
45
+ The ith subinterval contains z and c is near its center. */
46
+ tmp = ix - OFF;
47
+ i = (tmp >> (52 - POW_LOG_TABLE_BITS)) % N;
48
+ k = (int64_t)tmp >> 52; /* arithmetic shift */
49
+ iz = ix - (tmp & 0xfffULL << 52);
50
+ z = asdouble(iz);
51
+ kd = (double_t)k;
52
+
53
+ /* log(x) = k*Ln2 + log(c) + log1p(z/c-1). */
54
+ invc = T[i].invc;
55
+ logc = T[i].logc;
56
+ logctail = T[i].logctail;
57
+
58
+ /* Note: 1/c is j/N or j/N/2 where j is an integer in [N,2N) and
59
+ |z/c - 1| < 1/N, so r = z/c - 1 is exactly representible. */
60
+ #if __FP_FAST_FMA
61
+ r = __builtin_fma(z, invc, -1.0);
62
+ #else
63
+ /* Split z such that rhi, rlo and rhi*rhi are exact and |rlo| <= |r|. */
64
+ double_t zhi = asdouble((iz + (1ULL << 31)) & (-1ULL << 32));
65
+ double_t zlo = z - zhi;
66
+ double_t rhi = zhi * invc - 1.0;
67
+ double_t rlo = zlo * invc;
68
+ r = rhi + rlo;
69
+ #endif
70
+
71
+ /* k*Ln2 + log(c) + r. */
72
+ t1 = kd * Ln2hi + logc;
73
+ t2 = t1 + r;
74
+ lo1 = kd * Ln2lo + logctail;
75
+ lo2 = t1 - t2 + r;
76
+
77
+ /* Evaluation is optimized assuming superscalar pipelined execution. */
78
+ double_t ar, ar2, ar3, lo3, lo4;
79
+ ar = A[0] * r; /* A[0] = -0.5. */
80
+ ar2 = r * ar;
81
+ ar3 = r * ar2;
82
+ /* k*Ln2 + log(c) + r + A[0]*r*r. */
83
+ #if __FP_FAST_FMA
84
+ hi = t2 + ar2;
85
+ lo3 = __builtin_fma(ar, r, -ar2);
86
+ lo4 = t2 - hi + ar2;
87
+ #else
88
+ double_t arhi = A[0] * rhi;
89
+ double_t arhi2 = rhi * arhi;
90
+ hi = t2 + arhi2;
91
+ lo3 = rlo * (ar + arhi);
92
+ lo4 = t2 - hi + arhi2;
93
+ #endif
94
+ /* p = log1p(r) - r - A[0]*r*r. */
95
+ p = (ar3 * (A[1] + r * A[2] +
96
+ ar2 * (A[3] + r * A[4] + ar2 * (A[5] + r * A[6]))));
97
+ lo = lo1 + lo2 + lo3 + lo4 + p;
98
+ y = hi + lo;
99
+ *tail = hi - y + lo;
100
+ return y;
101
+ }
102
+
103
+ #undef N
104
+ #undef T
105
+ #define N (1 << EXP_TABLE_BITS)
106
+ #define InvLn2N __exp_data.invln2N
107
+ #define NegLn2hiN __exp_data.negln2hiN
108
+ #define NegLn2loN __exp_data.negln2loN
109
+ #define Shift __exp_data.shift
110
+ #define T __exp_data.tab
111
+ #define C2 __exp_data.poly[5 - EXP_POLY_ORDER]
112
+ #define C3 __exp_data.poly[6 - EXP_POLY_ORDER]
113
+ #define C4 __exp_data.poly[7 - EXP_POLY_ORDER]
114
+ #define C5 __exp_data.poly[8 - EXP_POLY_ORDER]
115
+ #define C6 __exp_data.poly[9 - EXP_POLY_ORDER]
116
+
117
+ /* Handle cases that may overflow or underflow when computing the result that
118
+ is scale*(1+TMP) without intermediate rounding. The bit representation of
119
+ scale is in SBITS, however it has a computed exponent that may have
120
+ overflown into the sign bit so that needs to be adjusted before using it as
121
+ a double. (int32_t)KI is the k used in the argument reduction and exponent
122
+ adjustment of scale, positive k here means the result may overflow and
123
+ negative k means the result may underflow. */
124
+ static inline double specialcase(double_t tmp, uint64_t sbits, uint64_t ki)
125
+ {
126
+ double_t scale, y;
127
+
128
+ if ((ki & 0x80000000) == 0) {
129
+ /* k > 0, the exponent of scale might have overflowed by <= 460. */
130
+ sbits -= 1009ull << 52;
131
+ scale = asdouble(sbits);
132
+ y = 0x1p1009 * (scale + scale * tmp);
133
+ return eval_as_double(y);
134
+ }
135
+ /* k < 0, need special care in the subnormal range. */
136
+ sbits += 1022ull << 52;
137
+ /* Note: sbits is signed scale. */
138
+ scale = asdouble(sbits);
139
+ y = scale + scale * tmp;
140
+ if (fabs(y) < 1.0) {
141
+ /* Round y to the right precision before scaling it into the subnormal
142
+ range to avoid double rounding that can cause 0.5+E/2 ulp error where
143
+ E is the worst-case ulp error outside the subnormal range. So this
144
+ is only useful if the goal is better than 1 ulp worst-case error. */
145
+ double_t hi, lo, one = 1.0;
146
+ if (y < 0.0)
147
+ one = -1.0;
148
+ lo = scale - y + scale * tmp;
149
+ hi = one + y;
150
+ lo = one - hi + y + lo;
151
+ y = eval_as_double(hi + lo) - one;
152
+ /* Fix the sign of 0. */
153
+ if (y == 0.0)
154
+ y = asdouble(sbits & 0x8000000000000000);
155
+ /* The underflow exception needs to be signaled explicitly. */
156
+ fp_force_eval(fp_barrier(0x1p-1022) * 0x1p-1022);
157
+ }
158
+ y = 0x1p-1022 * y;
159
+ return eval_as_double(y);
160
+ }
161
+
162
+ #define SIGN_BIAS (0x800 << EXP_TABLE_BITS)
163
+
164
+ /* Computes sign*exp(x+xtail) where |xtail| < 2^-8/N and |xtail| <= |x|.
165
+ The sign_bias argument is SIGN_BIAS or 0 and sets the sign to -1 or 1. */
166
+ static inline double exp_inline(double_t x, double_t xtail, uint32_t sign_bias)
167
+ {
168
+ uint32_t abstop;
169
+ uint64_t ki, idx, top, sbits;
170
+ /* double_t for better performance on targets with FLT_EVAL_METHOD==2. */
171
+ double_t kd, z, r, r2, scale, tail, tmp;
172
+
173
+ abstop = top12(x) & 0x7ff;
174
+ if (predict_false(abstop - top12(0x1p-54) >=
175
+ top12(512.0) - top12(0x1p-54))) {
176
+ if (abstop - top12(0x1p-54) >= 0x80000000) {
177
+ /* Avoid spurious underflow for tiny x. */
178
+ /* Note: 0 is common input. */
179
+ double_t one = WANT_ROUNDING ? 1.0 + x : 1.0;
180
+ return sign_bias ? -one : one;
181
+ }
182
+ if (abstop >= top12(1024.0)) {
183
+ /* Note: inf and nan are already handled. */
184
+ if (asuint64(x) >> 63)
185
+ return __math_uflow(sign_bias);
186
+ else
187
+ return __math_oflow(sign_bias);
188
+ }
189
+ /* Large x is special cased below. */
190
+ abstop = 0;
191
+ }
192
+
193
+ /* exp(x) = 2^(k/N) * exp(r), with exp(r) in [2^(-1/2N),2^(1/2N)]. */
194
+ /* x = ln2/N*k + r, with int k and r in [-ln2/2N, ln2/2N]. */
195
+ z = InvLn2N * x;
196
+ #if TOINT_INTRINSICS
197
+ kd = roundtoint(z);
198
+ ki = converttoint(z);
199
+ #elif EXP_USE_TOINT_NARROW
200
+ /* z - kd is in [-0.5-2^-16, 0.5] in all rounding modes. */
201
+ kd = eval_as_double(z + Shift);
202
+ ki = asuint64(kd) >> 16;
203
+ kd = (double_t)(int32_t)ki;
204
+ #else
205
+ /* z - kd is in [-1, 1] in non-nearest rounding modes. */
206
+ kd = eval_as_double(z + Shift);
207
+ ki = asuint64(kd);
208
+ kd -= Shift;
209
+ #endif
210
+ r = x + kd * NegLn2hiN + kd * NegLn2loN;
211
+ /* The code assumes 2^-200 < |xtail| < 2^-8/N. */
212
+ r += xtail;
213
+ /* 2^(k/N) ~= scale * (1 + tail). */
214
+ idx = 2 * (ki % N);
215
+ top = (ki + sign_bias) << (52 - EXP_TABLE_BITS);
216
+ tail = asdouble(T[idx]);
217
+ /* This is only a valid scale when -1023*N < k < 1024*N. */
218
+ sbits = T[idx + 1] + top;
219
+ /* exp(x) = 2^(k/N) * exp(r) ~= scale + scale * (tail + exp(r) - 1). */
220
+ /* Evaluation is optimized assuming superscalar pipelined execution. */
221
+ r2 = r * r;
222
+ /* Without fma the worst case error is 0.25/N ulp larger. */
223
+ /* Worst case error is less than 0.5+1.11/N+(abs poly error * 2^53) ulp. */
224
+ tmp = tail + r + r2 * (C2 + r * C3) + r2 * r2 * (C4 + r * C5);
225
+ if (predict_false(abstop == 0))
226
+ return specialcase(tmp, sbits, ki);
227
+ scale = asdouble(sbits);
228
+ /* Note: tmp == 0 or |tmp| > 2^-200 and scale > 2^-739, so there
229
+ is no spurious underflow here even without fma. */
230
+ return eval_as_double(scale + scale * tmp);
231
+ }
232
+
233
+ /* Returns 0 if not int, 1 if odd int, 2 if even int. The argument is
234
+ the bit representation of a non-zero finite floating-point value. */
235
+ static inline int checkint(uint64_t iy)
236
+ {
237
+ int e = iy >> 52 & 0x7ff;
238
+ if (e < 0x3ff)
239
+ return 0;
240
+ if (e > 0x3ff + 52)
241
+ return 2;
242
+ if (iy & ((1ULL << (0x3ff + 52 - e)) - 1))
243
+ return 0;
244
+ if (iy & (1ULL << (0x3ff + 52 - e)))
245
+ return 1;
246
+ return 2;
247
+ }
248
+
249
+ /* Returns 1 if input is the bit representation of 0, infinity or nan. */
250
+ static inline int zeroinfnan(uint64_t i)
251
+ {
252
+ return 2 * i - 1 >= 2 * asuint64(INFINITY) - 1;
253
+ }
254
+
255
+ double pow(double x, double y)
256
+ {
257
+ uint32_t sign_bias = 0;
258
+ uint64_t ix, iy;
259
+ uint32_t topx, topy;
260
+
261
+ ix = asuint64(x);
262
+ iy = asuint64(y);
263
+ topx = top12(x);
264
+ topy = top12(y);
265
+ if (predict_false(topx - 0x001 >= 0x7ff - 0x001 ||
266
+ (topy & 0x7ff) - 0x3be >= 0x43e - 0x3be)) {
267
+ /* Note: if |y| > 1075 * ln2 * 2^53 ~= 0x1.749p62 then pow(x,y) = inf/0
268
+ and if |y| < 2^-54 / 1075 ~= 0x1.e7b6p-65 then pow(x,y) = +-1. */
269
+ /* Special cases: (x < 0x1p-126 or inf or nan) or
270
+ (|y| < 0x1p-65 or |y| >= 0x1p63 or nan). */
271
+ if (predict_false(zeroinfnan(iy))) {
272
+ if (2 * iy == 0)
273
+ return issignaling_inline(x) ? x + y : 1.0;
274
+ if (ix == asuint64(1.0))
275
+ return issignaling_inline(y) ? x + y : 1.0;
276
+ if (2 * ix > 2 * asuint64(INFINITY) ||
277
+ 2 * iy > 2 * asuint64(INFINITY))
278
+ return x + y;
279
+ if (2 * ix == 2 * asuint64(1.0))
280
+ return 1.0;
281
+ if ((2 * ix < 2 * asuint64(1.0)) == !(iy >> 63))
282
+ return 0.0; /* |x|<1 && y==inf or |x|>1 && y==-inf. */
283
+ return y * y;
284
+ }
285
+ if (predict_false(zeroinfnan(ix))) {
286
+ double_t x2 = x * x;
287
+ if (ix >> 63 && checkint(iy) == 1)
288
+ x2 = -x2;
289
+ /* Without the barrier some versions of clang hoist the 1/x2 and
290
+ thus division by zero exception can be signaled spuriously. */
291
+ return iy >> 63 ? fp_barrier(1 / x2) : x2;
292
+ }
293
+ /* Here x and y are non-zero finite. */
294
+ if (ix >> 63) {
295
+ /* Finite x < 0. */
296
+ int yint = checkint(iy);
297
+ if (yint == 0)
298
+ return __math_invalid(x);
299
+ if (yint == 1)
300
+ sign_bias = SIGN_BIAS;
301
+ ix &= 0x7fffffffffffffff;
302
+ topx &= 0x7ff;
303
+ }
304
+ if ((topy & 0x7ff) - 0x3be >= 0x43e - 0x3be) {
305
+ /* Note: sign_bias == 0 here because y is not odd. */
306
+ if (ix == asuint64(1.0))
307
+ return 1.0;
308
+ if ((topy & 0x7ff) < 0x3be) {
309
+ /* |y| < 2^-65, x^y ~= 1 + y*log(x). */
310
+ if (WANT_ROUNDING)
311
+ return ix > asuint64(1.0) ? 1.0 + y :
312
+ 1.0 - y;
313
+ else
314
+ return 1.0;
315
+ }
316
+ return (ix > asuint64(1.0)) == (topy < 0x800) ?
317
+ __math_oflow(0) :
318
+ __math_uflow(0);
319
+ }
320
+ if (topx == 0) {
321
+ /* Normalize subnormal x so exponent becomes negative. */
322
+ ix = asuint64(x * 0x1p52);
323
+ ix &= 0x7fffffffffffffff;
324
+ ix -= 52ULL << 52;
325
+ }
326
+ }
327
+
328
+ double_t lo;
329
+ double_t hi = log_inline(ix, &lo);
330
+ double_t ehi, elo;
331
+ #if __FP_FAST_FMA
332
+ ehi = y * hi;
333
+ elo = y * lo + __builtin_fma(y, hi, -ehi);
334
+ #else
335
+ double_t yhi = asdouble(iy & -1ULL << 27);
336
+ double_t ylo = y - yhi;
337
+ double_t lhi = asdouble(asuint64(hi) & -1ULL << 27);
338
+ double_t llo = hi - lhi + lo;
339
+ ehi = yhi * lhi;
340
+ elo = ylo * lhi + y * llo; /* |elo| < |ehi| * 2^-25. */
341
+ #endif
342
+ return exp_inline(ehi, elo, sign_bias);
343
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zigc/lib",
3
- "version": "0.16.0-test.1",
3
+ "version": "0.17.0-dev.27",
4
4
  "description": "Zig standard library and libc headers (shared across all platforms)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -128,7 +128,7 @@ pub fn init(
128
128
 
129
129
  pub fn start(fuzz: *Fuzz) void {
130
130
  const io = fuzz.io;
131
- fuzz.prog_node = fuzz.root_prog_node.start("Fuzzing", fuzz.run_steps.len);
131
+ fuzz.prog_node = fuzz.root_prog_node.start("Fuzzing", 0);
132
132
 
133
133
  if (fuzz.mode == .forever) {
134
134
  // For polling messages and sending updates to subscribers.
@@ -137,18 +137,8 @@ pub fn start(fuzz: *Fuzz) void {
137
137
  }
138
138
 
139
139
  for (fuzz.run_steps) |run| {
140
- if (run.fuzz_tests.items.len > 1) {
141
- // Multiple fuzzWorkerRuns currently cause race-conditions
142
- // since they use the same Run step. See #30969
143
- fatal("--fuzz not yet implemented for multiple tests", .{});
144
- }
145
- }
146
-
147
- for (fuzz.run_steps) |run| {
148
- for (run.fuzz_tests.items) |unit_test_name| {
149
- assert(run.rebuilt_executable != null);
150
- fuzz.group.async(io, fuzzWorkerRun, .{ fuzz, run, unit_test_name });
151
- }
140
+ assert(run.rebuilt_executable != null);
141
+ fuzz.group.async(io, fuzzWorkerRun, .{ fuzz, run });
152
142
  }
153
143
  }
154
144
 
@@ -193,16 +183,13 @@ fn rebuildTestsWorkerRunFallible(run: *Step.Run, gpa: Allocator, parent_prog_nod
193
183
  run.rebuilt_executable = try rebuilt_bin_path.join(gpa, compile.out_filename);
194
184
  }
195
185
 
196
- fn fuzzWorkerRun(fuzz: *Fuzz, run: *Step.Run, unit_test_name: []const u8) void {
186
+ fn fuzzWorkerRun(fuzz: *Fuzz, run: *Step.Run) void {
197
187
  const owner = run.step.owner;
198
188
  const gpa = owner.allocator;
199
189
  const graph = owner.graph;
200
190
  const io = graph.io;
201
191
 
202
- const prog_node = fuzz.prog_node.start(unit_test_name, 0);
203
- defer prog_node.end();
204
-
205
- run.rerunInFuzzMode(fuzz, unit_test_name, prog_node) catch |err| switch (err) {
192
+ run.rerunInFuzzMode(fuzz, fuzz.prog_node) catch |err| switch (err) {
206
193
  error.MakeFailed => {
207
194
  var buf: [256]u8 = undefined;
208
195
  const stderr = io.lockStderr(&buf, graph.stderr_mode) catch |e| switch (e) {
@@ -213,7 +200,7 @@ fn fuzzWorkerRun(fuzz: *Fuzz, run: *Step.Run, unit_test_name: []const u8) void {
213
200
  return;
214
201
  },
215
202
  else => {
216
- log.err("step '{s}': failed to rerun '{s}' in fuzz mode: {t}", .{ run.step.name, unit_test_name, err });
203
+ log.err("step '{s}': failed to rerun in fuzz mode: {t}", .{ run.step.name, err });
217
204
  return;
218
205
  },
219
206
  };
@@ -596,7 +596,7 @@ pub fn appendZigProcessFlags(
596
596
  "-target", try target.query.zigTriple(b.allocator),
597
597
  "-mcpu", try target.query.serializeCpuAlloc(b.allocator),
598
598
  });
599
- if (target.query.dynamic_linker) |dynamic_linker| {
599
+ if (target.query.dynamic_linker) |*dynamic_linker| {
600
600
  if (dynamic_linker.get()) |dynamic_linker_path| {
601
601
  try zig_args.append("--dynamic-linker");
602
602
  try zig_args.append(dynamic_linker_path);
@@ -1814,16 +1814,16 @@ const ElfDumper = struct {
1814
1814
  files.putAssumeCapacityNoClobber(object.off - @sizeOf(elf.ar_hdr), object.name);
1815
1815
  }
1816
1816
 
1817
- var symbols = std.AutoArrayHashMap(usize, std.array_list.Managed([]const u8)).init(ctx.gpa);
1817
+ var symbols: std.array_hash_map.Auto(usize, std.array_list.Managed([]const u8)) = .empty;
1818
1818
  defer {
1819
1819
  for (symbols.values()) |*value| {
1820
1820
  value.deinit();
1821
1821
  }
1822
- symbols.deinit();
1822
+ symbols.deinit(ctx.gpa);
1823
1823
  }
1824
1824
 
1825
1825
  for (ctx.symtab.items) |entry| {
1826
- const gop = try symbols.getOrPut(@intCast(entry.off));
1826
+ const gop = try symbols.getOrPut(ctx.gpa, @intCast(entry.off));
1827
1827
  if (!gop.found_existing) {
1828
1828
  gop.value_ptr.* = std.array_list.Managed([]const u8).init(ctx.gpa);
1829
1829
  }
@@ -219,6 +219,8 @@ generated_docs: ?*GeneratedFile,
219
219
  generated_asm: ?*GeneratedFile,
220
220
  generated_bin: ?*GeneratedFile,
221
221
  generated_pdb: ?*GeneratedFile,
222
+ // hack for stage2_x86_64 + coff
223
+ generated_compiler_rt_dyn_lib: ?*GeneratedFile,
222
224
  generated_implib: ?*GeneratedFile,
223
225
  generated_llvm_bc: ?*GeneratedFile,
224
226
  generated_llvm_ir: ?*GeneratedFile,
@@ -441,6 +443,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
441
443
  .generated_asm = null,
442
444
  .generated_bin = null,
443
445
  .generated_pdb = null,
446
+ .generated_compiler_rt_dyn_lib = null,
444
447
  .generated_implib = null,
445
448
  .generated_llvm_bc = null,
446
449
  .generated_llvm_ir = null,
@@ -691,6 +694,13 @@ pub fn producesPdbFile(compile: *Compile) bool {
691
694
  return compile.isDynamicLibrary() or compile.kind == .exe or compile.kind == .@"test";
692
695
  }
693
696
 
697
+ pub fn producesCompilerRtDynLib(compile: *Compile) bool {
698
+ if (compile.rootModuleTarget().ofmt != .coff) return false;
699
+ if (compile.bundle_compiler_rt orelse (compile.kind == .exe or compile.isDynamicLibrary()))
700
+ return compile.use_llvm == false;
701
+ return false;
702
+ }
703
+
694
704
  pub fn producesImplib(compile: *Compile) bool {
695
705
  return compile.isDll();
696
706
  }
@@ -869,6 +879,12 @@ pub fn getEmittedPdb(compile: *Compile) LazyPath {
869
879
  return compile.getEmittedFileGeneric(&compile.generated_pdb);
870
880
  }
871
881
 
882
+ /// Returns the generated compiler_rt dynamic library.
883
+ /// This is a hack for stage2_x86_64 + coff.
884
+ pub fn getEmittedCompilerRtDynLib(compile: *Compile) ?LazyPath {
885
+ return compile.getEmittedFileGeneric(&compile.generated_compiler_rt_dyn_lib);
886
+ }
887
+
872
888
  /// Returns the path to the generated documentation directory.
873
889
  pub fn getEmittedDocs(compile: *Compile) LazyPath {
874
890
  return compile.getEmittedFileGeneric(&compile.generated_docs);
@@ -1794,6 +1810,8 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
1794
1810
  // zig fmt: off
1795
1811
  if (compile.generated_bin) |lp| lp.path = compile.outputPath(output_dir, .bin);
1796
1812
  if (compile.generated_pdb) |lp| lp.path = compile.outputPath(output_dir, .pdb);
1813
+ // hack for stage2_x86_64 + coff
1814
+ if (compile.generated_compiler_rt_dyn_lib) |lp| lp.path = compile.outputPath(output_dir, .compiler_rt_dyn_lib);
1797
1815
  if (compile.generated_implib) |lp| lp.path = compile.outputPath(output_dir, .implib);
1798
1816
  if (compile.generated_h) |lp| lp.path = compile.outputPath(output_dir, .h);
1799
1817
  if (compile.generated_docs) |lp| lp.path = compile.outputPath(output_dir, .docs);