@@ -68,9 +68,9 @@ SLANG_FORCE_INLINE float F32_rsqrt(float f) { return 1.0f / F32_sqrt(f); }
68
68
SLANG_FORCE_INLINE float F32_sign (float f) { return ( f == 0 .0f ) ? f : (( f < 0 .0f ) ? -1 .0f : 1 .0f ); }
69
69
SLANG_FORCE_INLINE float F32_frac (float f) { return f - F32_floor (f); }
70
70
71
- SLANG_FORCE_INLINE bool F32_isnan (float f) { return isnan (f); }
72
- SLANG_FORCE_INLINE bool F32_isfinite (float f) { return isfinite (f); }
73
- SLANG_FORCE_INLINE bool F32_isinf (float f) { return isinf (f); }
71
+ SLANG_FORCE_INLINE bool F32_isnan (float f) { return SLANG_PRELUDE_STD isnan (f); }
72
+ SLANG_FORCE_INLINE bool F32_isfinite (float f) { return SLANG_PRELUDE_STD isfinite (f); }
73
+ SLANG_FORCE_INLINE bool F32_isinf (float f) { return SLANG_PRELUDE_STD isinf (f); }
74
74
75
75
// Binary
76
76
SLANG_FORCE_INLINE float F32_min (float a, float b) { return ::fminf (a, b); }
@@ -84,7 +84,7 @@ SLANG_FORCE_INLINE float F32_frexp(float x, float& e)
84
84
{
85
85
int ei;
86
86
float m = ::frexpf (x, &ei);
87
- e = ei ;
87
+ e = float (ei) ;
88
88
return m;
89
89
}
90
90
SLANG_FORCE_INLINE float F32_modf (float x, float & ip)
@@ -135,9 +135,9 @@ SLANG_FORCE_INLINE double F64_rsqrt(double f) { return 1.0 / F64_sqrt(f); }
135
135
SLANG_FORCE_INLINE double F64_sign (double f) { return (f == 0.0 ) ? f : ((f < 0.0 ) ? -1.0 : 1.0 ); }
136
136
SLANG_FORCE_INLINE double F64_frac (double f) { return f - F64_floor (f); }
137
137
138
- SLANG_FORCE_INLINE bool F64_isnan (double f) { return isnan (f); }
139
- SLANG_FORCE_INLINE bool F64_isfinite (double f) { return isfinite (f); }
140
- SLANG_FORCE_INLINE bool F64_isinf (double f) { return isinf (f); }
138
+ SLANG_FORCE_INLINE bool F64_isnan (double f) { return SLANG_PRELUDE_STD isnan (f); }
139
+ SLANG_FORCE_INLINE bool F64_isfinite (double f) { return SLANG_PRELUDE_STD isfinite (f); }
140
+ SLANG_FORCE_INLINE bool F64_isinf (double f) { return SLANG_PRELUDE_STD isinf (f); }
141
141
142
142
// Binary
143
143
SLANG_FORCE_INLINE double F64_min (double a, double b) { return ::fmin (a, b); }
@@ -151,9 +151,10 @@ SLANG_FORCE_INLINE double F64_frexp(double x, double& e)
151
151
{
152
152
int ei;
153
153
double m = ::frexp (x, &ei);
154
- e = ei ;
154
+ e = float (ei) ;
155
155
return m;
156
156
}
157
+
157
158
SLANG_FORCE_INLINE double F64_modf (double x, double & ip)
158
159
{
159
160
return ::modf (x, &ip);
@@ -236,14 +237,17 @@ SLANG_FORCE_INLINE uint64_t U64_abs(uint64_t f) { return f; }
236
237
SLANG_FORCE_INLINE uint64_t U64_min (uint64_t a, uint64_t b) { return a < b ? a : b; }
237
238
SLANG_FORCE_INLINE uint64_t U64_max (uint64_t a, uint64_t b) { return a > b ? a : b; }
238
239
240
+ // TODO(JS): We don't define countbits for 64bit in stdlib currently.
241
+ // It's not clear from documentation if it should return 32 or 64 bits, if it exists.
242
+ // 32 bits can always hold the result, and will be implicitly promoted.
239
243
SLANG_FORCE_INLINE uint32_t U64_countbits (uint64_t v)
240
244
{
241
245
#if SLANG_GCC_FAMILY
242
- return __builtin_popcountl (v);
246
+ return uint32_t ( __builtin_popcountl (v) );
243
247
#elif SLANG_PROCESSOR_X86_64 && SLANG_VC
244
- return __popcnt64 (v);
248
+ return uint32_t ( __popcnt64 (v) );
245
249
#else
246
- uint64_t c = 0 ;
250
+ uint32_t c = 0 ;
247
251
while (v)
248
252
{
249
253
c++;
0 commit comments