From 240b277abddd2bced7d0e6afa904904275aae0ab Mon Sep 17 00:00:00 2001 From: "Ron @ SWGY" <125934174+ron-at-swgy@users.noreply.github.com> Date: Wed, 5 Jun 2024 10:45:39 -0400 Subject: [PATCH] Use correct fp_env definition for OpenBSD (#4259) This commit includes OpenBSD in the list of definitions checked when adding exceptions to the control flags of the floating point environment on OpenBSD. Similar to FreeBSD, the flags are contained in an x87 struct within the fp_env structure. For reference, the [official CVSWeb repository](https://cvsweb.openbsd.org/src/sys/arch/amd64/include/fenv.h?rev=1.4&content-type=text/x-cvsweb-markup) shows a definition of: ```c /* * fenv_t represents the entire floating-point environment. */ typedef struct { struct { unsigned int __control; /* Control word register */ unsigned int __status; /* Status word register */ unsigned int __tag; /* Tag word register */ unsigned int __others[4]; /* EIP, Pointer Selector, etc */ } __x87; unsigned int __mxcsr; /* Control, status register */ } fenv_t; ``` --- ortools/util/fp_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ortools/util/fp_utils.h b/ortools/util/fp_utils.h index 2a943040d9..d0a3e20fc1 100644 --- a/ortools/util/fp_utils.h +++ b/ortools/util/fp_utils.h @@ -89,7 +89,7 @@ class ScopedFloatingPointEnv { excepts &= FE_ALL_EXCEPT; #if defined(__APPLE__) fenv_.__control &= ~excepts; -#elif defined(__FreeBSD__) +#elif (defined(__FreeBSD__) || defined(__OpenBSD__)) fenv_.__x87.__control &= ~excepts; #else // Linux fenv_.__control_word &= ~excepts;