@@ -19,15 +19,15 @@ namespace common_constants_internal {
1919// log(2) generated by Sollya with:
2020// > a = 2^-43 * nearestint(2^43*log(2));
2121// LSB = 2^-43 is chosen so that e_x * LOG_2_HI is exact for -1075 < e_x < 1024.
22- static constexpr double LOG_2_HI = 0x1 .62e42fefa38p-1 ; // LSB = 2^-43
22+ LIBC_INLINE_VAR constexpr double LOG_2_HI = 0x1 .62e42fefa38p-1 ; // LSB = 2^-43
2323// > b = round(log10(2) - a, D, RN);
24- static constexpr double LOG_2_LO = 0x1 .ef35793c7673p-45 ; // LSB = 2^-97
24+ LIBC_INLINE_VAR constexpr double LOG_2_LO = 0x1 .ef35793c7673p-45 ; // LSB = 2^-97
2525
2626// Minimax polynomial for (log(1 + x) - x)/x^2, generated by sollya with:
2727// > P = fpminimax((log(1 + x) - x)/x^2, 5, [|D...|], [-2^-8, 2^-7]);
28- constexpr double LOG_COEFFS[6 ] = {- 0x1 . fffffffffffffp - 2 , 0x1 .5555555554a9bp- 2 ,
29- -0x1 .0000000094567p -2 , 0x1 .99999dcc9823cp- 3 ,
30- -0x1 .55550ac2e537ap-3 , 0x1 .21a02c4e624d7p-3 };
28+ LIBC_INLINE_VAR constexpr double LOG_COEFFS[6 ] = {
29+ -0x1 .fffffffffffffp -2 , 0x1 .5555555554a9bp- 2 , - 0x1 .0000000094567p- 2 ,
30+ 0x1 .99999dcc9823cp- 3 , -0x1 .55550ac2e537ap-3 , 0x1 .21a02c4e624d7p-3 };
3131
3232// Range reduction constants for logarithms.
3333// r(0) = 1, r(127) = 0.5
@@ -36,7 +36,7 @@ constexpr double LOG_COEFFS[6] = {-0x1.fffffffffffffp-2, 0x1.5555555554a9bp-2,
3636// precision, and -2^-8 <= v < 2^-7.
3737// TODO(lntue): Add reference to how the constants are derived after the
3838// resulting paper is ready.
39- alignas (8 ) static constexpr float R[128 ] = {
39+ alignas (8 ) LIBC_INLINE_VAR constexpr float R[128 ] = {
4040 0x1p0, 0x1 .fcp -1 , 0x1 .f8p -1 , 0x1 .f4p -1 , 0x1 .fp -1 , 0x1 .ecp -1 , 0x1 .e8p -1 ,
4141 0x1 .e4p -1 , 0x1 .ep -1 , 0x1 .dep -1 , 0x1 .dap -1 , 0x1 .d6p -1 , 0x1 .d4p -1 , 0x1 .dp -1 ,
4242 0x1 .ccp -1 , 0x1 .cap -1 , 0x1 .c6p -1 , 0x1 .c4p -1 , 0x1 .cp -1 , 0x1 .bep -1 , 0x1 .bap -1 ,
@@ -57,7 +57,7 @@ alignas(8) static constexpr float R[128] = {
5757 0x1 .0ap-1 , 0x1 .08p-1 , 0x1 .08p-1 , 0x1 .06p-1 , 0x1 .06p-1 , 0x1 .04p-1 , 0x1 .04p-1 ,
5858 0x1 .02p-1 , 0x1 .0p-1 };
5959
60- static constexpr double RD[128 ] = {
60+ LIBC_INLINE_VAR constexpr double RD[128 ] = {
6161 0x1p0, 0x1 .fcp -1 , 0x1 .f8p -1 , 0x1 .f4p -1 , 0x1 .fp -1 , 0x1 .ecp -1 , 0x1 .e8p -1 ,
6262 0x1 .e4p -1 , 0x1 .ep -1 , 0x1 .dep -1 , 0x1 .dap -1 , 0x1 .d6p -1 , 0x1 .d4p -1 , 0x1 .dp -1 ,
6363 0x1 .ccp -1 , 0x1 .cap -1 , 0x1 .c6p -1 , 0x1 .c4p -1 , 0x1 .cp -1 , 0x1 .bep -1 , 0x1 .bap -1 ,
@@ -82,7 +82,7 @@ static constexpr double RD[128] = {
8282// available.
8383// Generated by Sollya with the formula: CD[i] = RD[i]*(1 + i*2^-7) - 1
8484// for RD[i] defined on the table above.
85- static constexpr double CD[128 ] = {
85+ LIBC_INLINE_VAR constexpr double CD[128 ] = {
8686 0.0 , -0x1p-14 , -0x1p-12 , -0x1 .2p-11 , -0x1p-10 , -0x1 .9p-10 ,
8787 -0x1 .2p-9 , -0x1 .88p-9 , -0x1p-8 , -0x1 .9p-11 , -0x1 .fp -10 , -0x1 .9cp-9 ,
8888 -0x1p-12 , -0x1 .cp -10 , -0x1 .bp -9 , -0x1 .5p-11 , -0x1 .4p-9 , 0x1p-14 ,
@@ -107,7 +107,7 @@ static constexpr double CD[128] = {
107107 -0x1p-14 , -0x1p-8 ,
108108};
109109
110- static constexpr double LOG_R[128 ] = {
110+ LIBC_INLINE_VAR constexpr double LOG_R[128 ] = {
111111 0x0 .0000000000000p0, 0x1 .010157588de71p-7 , 0x1 .0205658935847p-6 ,
112112 0x1 .8492528c8cabfp-6 , 0x1 .0415d89e74444p-5 , 0x1 .466aed42de3eap-5 ,
113113 0x1 .894aa149fb343p-5 , 0x1 .ccb73cdddb2ccp -5 , 0x1 .08598b59e3a07p-4 ,
@@ -152,7 +152,7 @@ static constexpr double LOG_R[128] = {
152152 0x1 .5707a26bb8c66p-1 , 0x1 .5af405c3649ep-1 , 0x1 .5af405c3649ep-1 ,
153153 0x1 .5ee82aa24192p-1 , 0x0 .000000000000p0};
154154
155- static constexpr double LOG2_R[128 ] = {
155+ LIBC_INLINE_VAR constexpr double LOG2_R[128 ] = {
156156 0x0 .0000000000000p+0 , 0x1 .72c7ba20f7327p-7 , 0x1 .743ee861f3556p-6 ,
157157 0x1 .184b8e4c56af8p-5 , 0x1 .77394c9d958d5p-5 , 0x1 .d6ebd1f1febfep -5 ,
158158 0x1 .1bb32a600549dp-4 , 0x1 .4c560fe68af88p-4 , 0x1 .7d60496cfbb4cp-4 ,
@@ -205,7 +205,7 @@ static constexpr double LOG2_R[128] = {
205205// print("{", -c, ",", -b, "},");
206206// };
207207// We replace LOG_R[0] with log10(1.0) == 0.0
208- alignas (16 ) static constexpr NumberPair<double > LOG_R_DD[128 ] = {
208+ alignas (16 ) LIBC_INLINE_VAR constexpr NumberPair<double > LOG_R_DD[128 ] = {
209209 {0.0 , 0.0 },
210210 {-0x1 .0c76b999d2be8p-46 , 0x1 .010157589p-7 },
211211 {-0x1 .3dc5b06e2f7d2p-45 , 0x1 .0205658938p-6 },
@@ -341,7 +341,7 @@ alignas(16) static constexpr NumberPair<double> LOG_R_DD[128] = {
341341// Output range:
342342// [-0x1.3ffcp-15, 0x1.3e3dp-15]
343343// We store S2[i] = 2^16 (r(i - 2^6) - 1).
344- alignas (8 ) static constexpr int S2[193 ] = {
344+ alignas (8 ) LIBC_INLINE_VAR constexpr int S2[193 ] = {
345345 0x101 , 0xfd , 0xf9 , 0xf5 , 0xf1 , 0xed , 0xe9 , 0xe5 , 0xe1 ,
346346 0xdd , 0xd9 , 0xd5 , 0xd1 , 0xcd , 0xc9 , 0xc5 , 0xc1 , 0xbd ,
347347 0xb9 , 0xb4 , 0xb0 , 0xac , 0xa8 , 0xa4 , 0xa0 , 0x9c , 0x98 ,
@@ -365,7 +365,7 @@ alignas(8) static constexpr int S2[193] = {
365365 -0x1cd , -0x1d1 , -0x1d5 , -0x1d9 , -0x1dd , -0x1e0 , -0x1e4 , -0x1e8 , -0x1ec ,
366366 -0x1f0 , -0x1f4 , -0x1f8 , -0x1fc };
367367
368- static constexpr double R2[193 ] = {
368+ LIBC_INLINE_VAR constexpr double R2[193 ] = {
369369 0x1 .0101p0, 0x1 .00fdp0, 0x1 .00f9p0, 0x1 .00f5p0, 0x1 .00f1p0,
370370 0x1 .00edp0, 0x1 .00e9p0, 0x1 .00e5p0, 0x1 .00e1p0, 0x1 .00ddp0,
371371 0x1 .00d9p0, 0x1 .00d5p0, 0x1 .00d1p0, 0x1 .00cdp0, 0x1 .00c9p0,
@@ -412,7 +412,7 @@ static constexpr double R2[193] = {
412412// Output range:
413413// [-0x1.01928p-22 , 0x1p-22]
414414// We store S[i] = 2^21 (r(i - 80) - 1).
415- alignas (8 ) static constexpr int S3[161 ] = {
415+ alignas (8 ) LIBC_INLINE_VAR constexpr int S3[161 ] = {
416416 0x50 , 0x4f , 0x4e , 0x4d , 0x4c , 0x4b , 0x4a , 0x49 , 0x48 , 0x47 , 0x46 ,
417417 0x45 , 0x44 , 0x43 , 0x42 , 0x41 , 0x40 , 0x3f , 0x3e , 0x3d , 0x3c , 0x3b ,
418418 0x3a , 0x39 , 0x38 , 0x37 , 0x36 , 0x35 , 0x34 , 0x33 , 0x32 , 0x31 , 0x30 ,
@@ -435,7 +435,7 @@ alignas(8) static constexpr int S3[161] = {
435435// Output range:
436436// [-0x1.0002143p-29 , 0x1p-29]
437437// We store S[i] = 2^28 (r(i - 65) - 1).
438- alignas (8 ) static constexpr int S4[130 ] = {
438+ alignas (8 ) LIBC_INLINE_VAR constexpr int S4[130 ] = {
439439 0x41 , 0x40 , 0x3f , 0x3e , 0x3d , 0x3c , 0x3b , 0x3a , 0x39 , 0x38 , 0x37 ,
440440 0x36 , 0x35 , 0x34 , 0x33 , 0x32 , 0x31 , 0x30 , 0x2f , 0x2e , 0x2d , 0x2c ,
441441 0x2b , 0x2a , 0x29 , 0x28 , 0x27 , 0x26 , 0x25 , 0x24 , 0x23 , 0x22 , 0x21 ,
@@ -456,7 +456,7 @@ alignas(8) static constexpr int S4[130] = {
456456// Table is generated with Sollya as follow:
457457// > display = hexadecimal;
458458// > for i from -104 to 89 do { D(exp(i)); };
459- static constexpr double EXP_M1[195 ] = {
459+ LIBC_INLINE_VAR constexpr double EXP_M1[195 ] = {
460460 0x1 .f1e6b68529e33p -151 , 0x1 .525be4e4e601dp-149 , 0x1 .cbe0a45f75eb1p -148 ,
461461 0x1 .3884e838aea68p-146 , 0x1 .a8c1f14e2af5dp -145 , 0x1 .20a717e64a9bdp-143 ,
462462 0x1 .8851d84118908p-142 , 0x1 .0a9bdfb02d240p-140 , 0x1 .6a5bea046b42ep-139 ,
@@ -528,7 +528,7 @@ static constexpr double EXP_M1[195] = {
528528// Table is generated with Sollya as follow:
529529// > display = hexadecimal;
530530// > for i from 0 to 127 do { D(exp(i / 128)); };
531- static constexpr double EXP_M2[128 ] = {
531+ LIBC_INLINE_VAR constexpr double EXP_M2[128 ] = {
532532 0x1 .0000000000000p0, 0x1 .0202015600446p0, 0x1 .04080ab55de39p0,
533533 0x1 .06122436410ddp0, 0x1 .08205601127edp0, 0x1 .0a32a84e9c1f6p0,
534534 0x1 .0c49236829e8cp0, 0x1 .0e63cfa7ab09dp0, 0x1 .1082b577d34edp0,
0 commit comments