|
66 | 66 | MSVC via compile time define.
|
67 | 67 | */
|
68 | 68 |
|
69 |
| -// MSVC detection (MSVC people usually don't use autoconf) |
| 69 | +/* MSVC detection (MSVC people usually don't use autoconf) */ |
70 | 70 | #ifdef _MSC_VER
|
71 | 71 | # if _MSC_VER >= 1500
|
72 |
| - // Visual C++ 2008 or higher, supports _controlfp_s |
| 72 | + /* Visual C++ 2008 or higher, supports _controlfp_s */ |
73 | 73 | # define HAVE__CONTROLFP_S
|
74 | 74 | # else
|
75 |
| - // Visual C++ (up to 2005), supports _controlfp |
| 75 | + /* Visual C++ (up to 2005), supports _controlfp */ |
76 | 76 | # define HAVE__CONTROLFP
|
77 |
| -# endif // MSC_VER >= 1500 |
78 |
| - // Tell MSVC optimizer that we access FP environment |
| 77 | +# endif /* MSC_VER >= 1500 */ |
| 78 | + /* Tell MSVC optimizer that we access FP environment */ |
79 | 79 | # pragma fenv_access (on)
|
80 |
| -#endif // _MSC_VER |
| 80 | +#endif /* _MSC_VER */ |
81 | 81 |
|
82 | 82 | #ifdef HAVE__CONTROLFP_S
|
83 | 83 |
|
84 |
| -// float.h defines _controlfp_s |
| 84 | +/* float.h defines _controlfp_s */ |
85 | 85 | # include <float.h>
|
86 | 86 |
|
87 | 87 | # define XPFPA_DECLARE \
|
|
97 | 97 | _xpfpa_fpu_oldcw = _xpfpa_fpu_cw; \
|
98 | 98 | _controlfp_s(&_xpfpa_fpu_cw, _PC_24, _MCW_PC); \
|
99 | 99 | } while (0)
|
100 |
| -// NOTE: This only sets internal precision. MSVC does NOT support double- |
101 |
| -// extended precision! |
| 100 | +/* NOTE: This only sets internal precision. MSVC does NOT support double- |
| 101 | + extended precision! */ |
102 | 102 | # define XPFPA_SWITCH_DOUBLE_EXTENDED() do { \
|
103 | 103 | _controlfp_s(&_xpfpa_fpu_cw, 0, 0); \
|
104 | 104 | _xpfpa_fpu_oldcw = _xpfpa_fpu_cw; \
|
105 | 105 | _controlfp_s(&_xpfpa_fpu_cw, _PC_64, _MCW_PC); \
|
106 | 106 | } while (0)
|
107 | 107 | # define XPFPA_RESTORE() \
|
108 | 108 | _controlfp_s(&_xpfpa_fpu_cw, _xpfpa_fpu_oldcw, _MCW_PC)
|
109 |
| -// We do NOT use the volatile return trick since _controlfp_s is a function |
110 |
| -// call and thus FP registers are saved in memory anyway. However, we do use |
111 |
| -// a variable to ensure that the expression passed into val will be evaluated |
112 |
| -// *before* switching back contexts. |
| 109 | +/* We do NOT use the volatile return trick since _controlfp_s is a function |
| 110 | + call and thus FP registers are saved in memory anyway. However, we do use |
| 111 | + a variable to ensure that the expression passed into val will be evaluated |
| 112 | + *before* switching back contexts. */ |
113 | 113 | # define XPFPA_RETURN_DOUBLE(val) \
|
114 | 114 | do { \
|
115 | 115 | double _xpfpa_result = (val); \
|
|
122 | 122 | XPFPA_RESTORE(); \
|
123 | 123 | return _xpfpa_result; \
|
124 | 124 | } while (0)
|
125 |
| -// This won't work, but we add a macro for it anyway. |
| 125 | +/* This won't work, but we add a macro for it anyway. */ |
126 | 126 | # define XPFPA_RETURN_DOUBLE_EXTENDED(val) \
|
127 | 127 | do { \
|
128 | 128 | long double _xpfpa_result = (val); \
|
|
132 | 132 |
|
133 | 133 | #elif defined(HAVE__CONTROLFP)
|
134 | 134 |
|
135 |
| -// float.h defines _controlfp |
| 135 | +/* float.h defines _controlfp */ |
136 | 136 | # include <float.h>
|
137 | 137 |
|
138 | 138 | # define XPFPA_DECLARE \
|
|
146 | 146 | _xpfpa_fpu_oldcw = _controlfp(0, 0); \
|
147 | 147 | _controlfp(_PC_24, _MCW_PC); \
|
148 | 148 | } while (0)
|
149 |
| -// NOTE: This will only work as expected on MinGW. |
| 149 | +/* NOTE: This will only work as expected on MinGW. */ |
150 | 150 | # define XPFPA_SWITCH_DOUBLE_EXTENDED() do { \
|
151 | 151 | _xpfpa_fpu_oldcw = _controlfp(0, 0); \
|
152 | 152 | _controlfp(_PC_64, _MCW_PC); \
|
153 | 153 | } while (0)
|
154 | 154 | # define XPFPA_RESTORE() \
|
155 | 155 | _controlfp(_xpfpa_fpu_oldcw, _MCW_PC)
|
156 |
| -// We do NOT use the volatile return trick since _controlfp is a function |
157 |
| -// call and thus FP registers are saved in memory anyway. However, we do use |
158 |
| -// a variable to ensure that the expression passed into val will be evaluated |
159 |
| -// *before* switching back contexts. |
| 156 | +/* We do NOT use the volatile return trick since _controlfp is a function |
| 157 | + call and thus FP registers are saved in memory anyway. However, we do use |
| 158 | + a variable to ensure that the expression passed into val will be evaluated |
| 159 | + *before* switching back contexts. */ |
160 | 160 | # define XPFPA_RETURN_DOUBLE(val) \
|
161 | 161 | do { \
|
162 | 162 | double _xpfpa_result = (val); \
|
|
169 | 169 | XPFPA_RESTORE(); \
|
170 | 170 | return _xpfpa_result; \
|
171 | 171 | } while (0)
|
172 |
| -// This will only work on MinGW |
| 172 | +/* This will only work on MinGW */ |
173 | 173 | # define XPFPA_RETURN_DOUBLE_EXTENDED(val) \
|
174 | 174 | do { \
|
175 | 175 | long double _xpfpa_result = (val); \
|
176 | 176 | XPFPA_RESTORE(); \
|
177 | 177 | return _xpfpa_result; \
|
178 | 178 | } while (0)
|
179 | 179 |
|
180 |
| -#elif defined(HAVE__FPU_SETCW) // glibc systems |
| 180 | +#elif defined(HAVE__FPU_SETCW) /* glibc systems */ |
181 | 181 |
|
182 |
| -// fpu_control.h defines _FPU_[GS]ETCW |
| 182 | +/* fpu_control.h defines _FPU_[GS]ETCW */ |
183 | 183 | # include <fpu_control.h>
|
184 | 184 |
|
185 | 185 | # define XPFPA_DECLARE \
|
|
202 | 202 | } while (0)
|
203 | 203 | # define XPFPA_RESTORE() \
|
204 | 204 | _FPU_SETCW(_xpfpa_fpu_oldcw)
|
205 |
| -// We use a temporary volatile variable (in a new block) in order to ensure |
206 |
| -// that the optimizer does not mis-optimize the instructions. Also, a volatile |
207 |
| -// variable ensures truncation to correct precision. |
| 205 | +/* We use a temporary volatile variable (in a new block) in order to ensure |
| 206 | + that the optimizer does not mis-optimize the instructions. Also, a volatile |
| 207 | + variable ensures truncation to correct precision. */ |
208 | 208 | # define XPFPA_RETURN_DOUBLE(val) \
|
209 | 209 | do { \
|
210 | 210 | volatile double _xpfpa_result = (val); \
|
|
224 | 224 | return _xpfpa_result; \
|
225 | 225 | } while (0)
|
226 | 226 |
|
227 |
| -#elif defined(HAVE_FPSETPREC) // FreeBSD |
| 227 | +#elif defined(HAVE_FPSETPREC) /* FreeBSD */ |
228 | 228 |
|
229 |
| -// fpu_control.h defines _FPU_[GS]ETCW |
| 229 | +/* fpu_control.h defines _FPU_[GS]ETCW */ |
230 | 230 | # include <machine/ieeefp.h>
|
231 | 231 |
|
232 | 232 | # define XPFPA_DECLARE \
|
|
246 | 246 | } while (0)
|
247 | 247 | # define XPFPA_RESTORE() \
|
248 | 248 | fpsetprec(_xpfpa_fpu_oldprec)
|
249 |
| -// We use a temporary volatile variable (in a new block) in order to ensure |
250 |
| -// that the optimizer does not mis-optimize the instructions. Also, a volatile |
251 |
| -// variable ensures truncation to correct precision. |
| 249 | +/* We use a temporary volatile variable (in a new block) in order to ensure |
| 250 | + that the optimizer does not mis-optimize the instructions. Also, a volatile |
| 251 | + variable ensures truncation to correct precision. */ |
252 | 252 | # define XPFPA_RETURN_DOUBLE(val) \
|
253 | 253 | do { \
|
254 | 254 | volatile double _xpfpa_result = (val); \
|
|
312 | 312 | } while (0)
|
313 | 313 | # define XPFPA_RESTORE() \
|
314 | 314 | __asm__ __volatile__ ("fldcw %0" : : "m" (*&_xpfpa_fpu_oldcw))
|
315 |
| -// We use a temporary volatile variable (in a new block) in order to ensure |
316 |
| -// that the optimizer does not mis-optimize the instructions. Also, a volatile |
317 |
| -// variable ensures truncation to correct precision. |
| 315 | +/* We use a temporary volatile variable (in a new block) in order to ensure |
| 316 | + that the optimizer does not mis-optimize the instructions. Also, a volatile |
| 317 | + variable ensures truncation to correct precision. */ |
318 | 318 | # define XPFPA_RETURN_DOUBLE(val) \
|
319 | 319 | do { \
|
320 | 320 | volatile double _xpfpa_result = (val); \
|
|
334 | 334 | return _xpfpa_result; \
|
335 | 335 | } while (0)
|
336 | 336 |
|
337 |
| -#else // FPU CONTROL |
| 337 | +#else /* FPU CONTROL */ |
338 | 338 |
|
339 | 339 | /*
|
340 | 340 | This is either not an x87 FPU or the inline assembly syntax was not
|
|
350 | 350 | # define XPFPA_RETURN_SINGLE(val) return (val)
|
351 | 351 | # define XPFPA_RETURN_DOUBLE_EXTENDED(val) return (val)
|
352 | 352 |
|
353 |
| -#endif // FPU CONTROL |
| 353 | +#endif /* FPU CONTROL */ |
354 | 354 |
|
355 | 355 | #endif
|
0 commit comments