File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -183,12 +183,19 @@ Those can be useful for precise floating point comparison.
183183 * NPY_FPE_UNDERFLOW
184184 * NPY_FPE_INVALID
185185
186+ Note that :c:func:`npy_get_floatstatus_barrier` is preferable as it prevents
187+ agressive compiler optimizations reordering the call relative to
188+ the code setting the status, which could lead to incorrect results.
189+
186190 .. versionadded:: 1.9.0
187191
188192.. c:function:: int npy_get_floatstatus_barrier(char*)
189193
190194 Get floating point status. A pointer to a local variable is passed in to
191- prevent aggresive compiler optimizations from reodering this function call.
195+ prevent aggresive compiler optimizations from reodering this function call
196+ relative to the code setting the status, which could lead to incorrect
197+ results.
198+
192199 Returns a bitmask with following possible flags:
193200
194201 * NPY_FPE_DIVIDEBYZERO
@@ -202,9 +209,13 @@ Those can be useful for precise floating point comparison.
202209
203210 Clears the floating point status. Returns the previous status mask.
204211
212+ Note that :c:func:`npy_clear_floatstatus_barrier` is preferable as it
213+ prevents agressive compiler optimizations reordering the call relative to
214+ the code setting the status, which could lead to incorrect results.
215+
205216 .. versionadded:: 1.9.0
206217
207- .. c:function:: int npy_clear_floatstatus (char*)
218+ .. c:function:: int npy_clear_floatstatus_barrier (char*)
208219
209220 Clears the floating point status. A pointer to a local variable is passed in to
210221 prevent aggresive compiler optimizations from reodering this function call.
Original file line number Diff line number Diff line change @@ -528,10 +528,13 @@ int npy_clear_floatstatus_barrier(char*);
528528int npy_get_floatstatus_barrier (char * );
529529/*
530530 * use caution with these - clang and gcc8.1 are known to reorder calls
531- * to this form of the function which can defeat the check
531+ * to this form of the function which can defeat the check. The _barrier
532+ * form of the call is preferable, where the argument is
533+ * (char*)&local_variable
532534 */
533535int npy_clear_floatstatus (void );
534536int npy_get_floatstatus (void );
537+
535538void npy_set_floatstatus_divbyzero (void );
536539void npy_set_floatstatus_overflow (void );
537540void npy_set_floatstatus_underflow (void );
You can’t perform that action at this time.
0 commit comments