OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 #include "wtf/CPU.h" | 29 #include "wtf/CPU.h" |
30 #include "wtf/StdLibExtras.h" | 30 #include "wtf/StdLibExtras.h" |
31 #include <algorithm> | 31 #include <algorithm> |
32 #include <cmath> | 32 #include <cmath> |
33 #include <float.h> | 33 #include <float.h> |
34 #include <limits> | 34 #include <limits> |
35 #include <stdint.h> | 35 #include <stdint.h> |
36 #include <stdlib.h> | 36 #include <stdlib.h> |
37 | 37 |
38 #if OS(SOLARIS) | |
39 #include <ieeefp.h> | |
40 #endif | |
41 | |
42 #if OS(OPENBSD) | 38 #if OS(OPENBSD) |
43 #include <sys/types.h> | 39 #include <sys/types.h> |
44 #include <machine/ieee.h> | 40 #include <machine/ieee.h> |
45 #endif | 41 #endif |
46 | 42 |
47 #ifndef M_PI | 43 #ifndef M_PI |
48 const double piDouble = 3.14159265358979323846; | 44 const double piDouble = 3.14159265358979323846; |
49 const float piFloat = 3.14159265358979323846f; | 45 const float piFloat = 3.14159265358979323846f; |
50 #else | 46 #else |
51 const double piDouble = M_PI; | 47 const double piDouble = M_PI; |
(...skipping 18 matching lines...) Expand all Loading... |
70 | 66 |
71 #if OS(DARWIN) | 67 #if OS(DARWIN) |
72 | 68 |
73 // Work around a bug in the Mac OS X libc where ceil(-0.1) return +0. | 69 // Work around a bug in the Mac OS X libc where ceil(-0.1) return +0. |
74 inline double wtf_ceil(double x) { return copysign(ceil(x), x); } | 70 inline double wtf_ceil(double x) { return copysign(ceil(x), x); } |
75 | 71 |
76 #define ceil(x) wtf_ceil(x) | 72 #define ceil(x) wtf_ceil(x) |
77 | 73 |
78 #endif | 74 #endif |
79 | 75 |
80 #if OS(SOLARIS) | |
81 | |
82 namespace std { | |
83 | |
84 #ifndef isfinite | |
85 inline bool isfinite(double x) { return finite(x) && !isnand(x); } | |
86 #endif | |
87 #ifndef signbit | |
88 inline bool signbit(double x) { return copysign(1.0, x) < 0; } | |
89 #endif | |
90 #ifndef isinf | |
91 inline bool isinf(double x) { return !finite(x) && !isnand(x); } | |
92 #endif | |
93 | |
94 } // namespace std | |
95 | |
96 #endif | |
97 | |
98 #if OS(OPENBSD) | 76 #if OS(OPENBSD) |
99 | 77 |
100 namespace std { | 78 namespace std { |
101 | 79 |
102 #ifndef isfinite | 80 #ifndef isfinite |
103 inline bool isfinite(double x) { return finite(x); } | 81 inline bool isfinite(double x) { return finite(x); } |
104 #endif | 82 #endif |
105 #ifndef signbit | 83 #ifndef signbit |
106 inline bool signbit(double x) { struct ieee_double *p = (struct ieee_double *)&x
; return p->dbl_sign; } | 84 inline bool signbit(double x) { struct ieee_double *p = (struct ieee_double *)&x
; return p->dbl_sign; } |
107 #endif | 85 #endif |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 if (i >> 2) | 316 if (i >> 2) |
339 log2 += 2, i >>= 2; | 317 log2 += 2, i >>= 2; |
340 if (i >> 1) | 318 if (i >> 1) |
341 log2 += 1; | 319 log2 += 1; |
342 return log2; | 320 return log2; |
343 } | 321 } |
344 | 322 |
345 } // namespace WTF | 323 } // namespace WTF |
346 | 324 |
347 #endif // #ifndef WTF_MathExtras_h | 325 #endif // #ifndef WTF_MathExtras_h |
OLD | NEW |