|
26 | 26 | #include "jni.h"
|
27 | 27 | #include "runtime/interfaceSupport.inline.hpp"
|
28 | 28 | #include "runtime/sharedRuntime.hpp"
|
| 29 | +#include "sanitizers/ub.hpp" |
| 30 | + |
| 31 | +#include <limits> |
29 | 32 |
|
30 | 33 | // This file contains copies of the fdlibm routines used by
|
31 | 34 | // StrictMath. It turns out that it is almost always required to use
|
@@ -110,11 +113,14 @@ ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */
|
110 | 113 |
|
111 | 114 | static double zero = 0.0;
|
112 | 115 |
|
| 116 | +ATTRIBUTE_NO_UBSAN |
113 | 117 | static double __ieee754_log(double x) {
|
114 | 118 | double hfsq,f,s,z,R,w,t1,t2,dk;
|
115 | 119 | int k,hx,i,j;
|
116 | 120 | unsigned lx;
|
117 | 121 |
|
| 122 | + static_assert(std::numeric_limits<double>::is_iec559, "IEEE 754 required"); |
| 123 | + |
118 | 124 | hx = high(x); /* high word of x */
|
119 | 125 | lx = low(x); /* low word of x */
|
120 | 126 |
|
@@ -204,11 +210,14 @@ ivln10 = 4.34294481903251816668e-01, /* 0x3FDBCB7B, 0x1526E50E */
|
204 | 210 | log10_2hi = 3.01029995663611771306e-01, /* 0x3FD34413, 0x509F6000 */
|
205 | 211 | log10_2lo = 3.69423907715893078616e-13; /* 0x3D59FEF3, 0x11F12B36 */
|
206 | 212 |
|
| 213 | +ATTRIBUTE_NO_UBSAN |
207 | 214 | static double __ieee754_log10(double x) {
|
208 | 215 | double y,z;
|
209 | 216 | int i,k,hx;
|
210 | 217 | unsigned lx;
|
211 | 218 |
|
| 219 | + static_assert(std::numeric_limits<double>::is_iec559, "IEEE 754 required"); |
| 220 | + |
212 | 221 | hx = high(x); /* high word of x */
|
213 | 222 | lx = low(x); /* low word of x */
|
214 | 223 |
|
@@ -440,13 +449,16 @@ bp[] = {1.0, 1.5,},
|
440 | 449 | ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/
|
441 | 450 | ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
|
442 | 451 |
|
| 452 | +ATTRIBUTE_NO_UBSAN |
443 | 453 | static double __ieee754_pow(double x, double y) {
|
444 | 454 | double z,ax,z_h,z_l,p_h,p_l;
|
445 | 455 | double y1,t1,t2,r,s,t,u,v,w;
|
446 | 456 | int i0,i1,i,j,k,yisint,n;
|
447 | 457 | int hx,hy,ix,iy;
|
448 | 458 | unsigned lx,ly;
|
449 | 459 |
|
| 460 | + static_assert(std::numeric_limits<double>::is_iec559, "IEEE 754 required"); |
| 461 | + |
450 | 462 | i0 = ((*(int*)&one)>>29)^1; i1=1-i0;
|
451 | 463 | hx = high(x); lx = low(x);
|
452 | 464 | hy = high(y); ly = low(y);
|
|
0 commit comments