Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: fusl/src/math/ilogbl.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include <limits.h> 1 #include <limits.h>
2 #include "libm.h" 2 #include "libm.h"
3 3
4 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 4 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
5 int ilogbl(long double x) 5 int ilogbl(long double x) {
6 { 6 return ilogb(x);
7 » return ilogb(x);
8 } 7 }
9 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 8 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
10 int ilogbl(long double x) 9 int ilogbl(long double x) {
11 { 10 PRAGMA_STDC_FENV_ACCESS_ON
12 » PRAGMA_STDC_FENV_ACCESS_ON 11 union ldshape u = {x};
13 » union ldshape u = {x}; 12 uint64_t m = u.i.m;
14 » uint64_t m = u.i.m; 13 int e = u.i.se & 0x7fff;
15 » int e = u.i.se & 0x7fff;
16 14
17 » if (!e) { 15 if (!e) {
18 » » if (m == 0) { 16 if (m == 0) {
19 » » » FORCE_EVAL(0/0.0f); 17 FORCE_EVAL(0 / 0.0f);
20 » » » return FP_ILOGB0; 18 return FP_ILOGB0;
21 » » } 19 }
22 » » /* subnormal x */ 20 /* subnormal x */
23 » » for (e = -0x3fff+1; m>>63 == 0; e--, m<<=1); 21 for (e = -0x3fff + 1; m >> 63 == 0; e--, m <<= 1)
24 » » return e; 22 ;
25 » } 23 return e;
26 » if (e == 0x7fff) { 24 }
27 » » FORCE_EVAL(0/0.0f); 25 if (e == 0x7fff) {
28 » » return m<<1 ? FP_ILOGBNAN : INT_MAX; 26 FORCE_EVAL(0 / 0.0f);
29 » } 27 return m << 1 ? FP_ILOGBNAN : INT_MAX;
30 » return e - 0x3fff; 28 }
29 return e - 0x3fff;
31 } 30 }
32 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 31 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
33 int ilogbl(long double x) 32 int ilogbl(long double x) {
34 { 33 #pragma STDC FENV_ACCESS ON
35 » #pragma STDC FENV_ACCESS ON 34 union ldshape u = {x};
36 » union ldshape u = {x}; 35 int e = u.i.se & 0x7fff;
37 » int e = u.i.se & 0x7fff;
38 36
39 » if (!e) { 37 if (!e) {
40 » » if (x == 0) { 38 if (x == 0) {
41 » » » FORCE_EVAL(0/0.0f); 39 FORCE_EVAL(0 / 0.0f);
42 » » » return FP_ILOGB0; 40 return FP_ILOGB0;
43 » » } 41 }
44 » » /* subnormal x */ 42 /* subnormal x */
45 » » x *= 0x1p120; 43 x *= 0x1p120;
46 » » return ilogbl(x) - 120; 44 return ilogbl(x) - 120;
47 » } 45 }
48 » if (e == 0x7fff) { 46 if (e == 0x7fff) {
49 » » FORCE_EVAL(0/0.0f); 47 FORCE_EVAL(0 / 0.0f);
50 » » u.i.se = 0; 48 u.i.se = 0;
51 » » return u.f ? FP_ILOGBNAN : INT_MAX; 49 return u.f ? FP_ILOGBNAN : INT_MAX;
52 » } 50 }
53 » return e - 0x3fff; 51 return e - 0x3fff;
54 } 52 }
55 #endif 53 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698