Skip to content

Commit 7bd4805

Browse files
QuzarDCQuzarDC
authored andcommitted
pvrtex: Provide compatibility for systems without sincosf
1 parent 20819a1 commit 7bd4805

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

utils/pvrtex/nvmath.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ typedef union {
112112
#define NVMATH_TYPE_LIBRARY (1)
113113
#define NVMATH_TYPE_SH4_ASM (2)
114114

115-
#define NVMATH_METHOD NVMATH_TYPE_BUILTIN
115+
#define NVMATH_METHOD NVMATH_TYPE_LIBRARY
116116

117117

118118
#define NVMATH_MIN(a, b) ((a) < (b) ? (a) : (b))
@@ -125,7 +125,12 @@ typedef union {
125125
#define NVMATH_RSQRT(a) (1.0f/sqrt(a))
126126
#define NVMATH_SIN(rad) sinf(rad)
127127
#define NVMATH_COS(rad) cosf(rad)
128-
#define NVMATH_SINCOS(rad, s, c) sincosf(rad, s, c)
128+
/* Compat for systems without the nonstandard sincosf*/
129+
#ifndef sincosf
130+
#define NVMATH_SINCOS(rad, s, c) do{*s = sinf(rad); *c = cosf(rad);}while(0)
131+
#else
132+
#define NVMATH_SINCOS(rad, s, c) sincosf(rad, s, c)
133+
#endif
129134
#define NVMATH_ACOS(rad) acosf(rad)
130135
#define NVMATH_ABS(v) fabsf(v)
131136
#define NVMATH_ABSI(v) abs(v)
@@ -134,7 +139,12 @@ typedef union {
134139
#define NVMATH_RSQRT(a) (1.0f/__builtin_sqrt(a))
135140
#define NVMATH_SIN(rad) __builtin_sinf(rad)
136141
#define NVMATH_COS(rad) __builtin_cosf(rad)
137-
#define NVMATH_SINCOS(rad, s, c) __builtin_sincosf(rad, s, c)
142+
/* Compat for systems without the nonstandard sincosf*/
143+
#ifndef __builtin_sincosf
144+
#define NVMATH_SINCOS(rad, s, c) do{*s = __builtin_sinf(rad); *c = __builtin_cosf(rad);}while(0)
145+
#else
146+
#define NVMATH_SINCOS(rad, s, c) __builtin_sincosf(rad, s, c)
147+
#endif
138148
#define NVMATH_ACOS(rad) __builtin_acosf(rad)
139149
#define NVMATH_ABS(v) __builtin_fabsf(v)
140150
#define NVMATH_ABSI(v) __builtin_abs(v)

0 commit comments

Comments
 (0)