HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SYS_NTMath.h
Go to the documentation of this file.
1 #ifndef _SYS_NTMath_h_
2 #define _SYS_NTMath_h_
3 
4 #include "SYS_API.h"
5 #include "SYS_Types.h"
6 
7 // Include these system libraries first so that our tests for math defines
8 // won't try to refine them.
9 #include <stdlib.h>
10 #include <math.h>
11 
12 #if defined(CELLRSX)
13  #include <ppu_intrinsics.h>
14 #endif
15 
16 #ifdef WIN32
17 
18  #define SYS_HAS_NO_DRAND
19  #define SYS_HAS_NO_RANDOM
20 
21  static inline int finite(double x) { return ::_finite(x); }
22  static inline int finitef(double x) { return ::_finite(x); }
23  static inline int isfinite(double x) { return ::_finite(x); }
24 
25  #ifdef __cplusplus
26  #include <ieeefp.h>
27 
28  // trunc() and truncf() don't exist, so create them.
29  static inline fpreal32 truncf(fpreal32 value)
30  {
31  return (value < 0.0f) ? ceilf(value) : floorf(value);
32  }
33 
34  static inline fpreal64 trunc(fpreal64 value)
35  {
36  return (value < 0.0) ? ceil(value) : floor(value);
37  }
38  #endif /* __cplusplus */
39 #endif /* WIN32 */
40 
41 #if defined(GAMEOS)
42  #define SYS_HAS_NO_DRAND
43  #define SYS_HAS_NO_RANDOM
44  #define SYS_HAS_NO_PI
45  static inline int finite(double) { return 1; }
46 #endif
47 
48 #if defined(SYS_HAS_NO_DRAND) && defined(__cplusplus)
49 // We carefully do *not* specify srand48 and drand48 in these
50 // cases! Use SYSsrand48 and SYSdrand48 instead!
51 #endif
52 
53 #if defined(SYS_HAS_NO_RANDOM) && defined(__cplusplus)
54  // Likewise, random() and srandom() are considered harmful.
55 #endif
56 
57 #if defined(SYS_HAS_NO_PI)
58  #undef M_PI
59  #undef M_PI_2
60  #undef M_PI_4
61  #define M_PI 3.14159265358979323846
62  #define M_PI_2 1.57079632679489661923
63  #define M_PI_4 0.78539816339744830962
64 #endif
65 
66 #if !defined(M_SQRT2)
67  #define M_SQRT2 1.41421356237309504880
68 #endif
69 
70 #endif /* _SYS_NTMath_h_ */
int trunc(T x)
Definition: ImathFun.h:165
bool finitef(float f)
Definition: ImathFun.h:249
SYS_API float truncf(float x)
GLfloat f
Definition: glcorearb.h:1925
double fpreal64
Definition: SYS_Types.h:191
int floor(T x)
Definition: ImathFun.h:150
GLsizei const GLfloat * value
Definition: glcorearb.h:823
GLint GLenum GLint x
Definition: glcorearb.h:408
int ceil(T x)
Definition: ImathFun.h:158
float fpreal32
Definition: SYS_Types.h:190