Skip to content

Commit 37e3ad3

Browse files
Fix boolean logic
1 parent 2aa941b commit 37e3ad3

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/fiat/drhook/drhook.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static unsigned int fpcr_to_fenv(unsigned long long fpcr_flags) {
259259
}
260260
unsigned long long all_fpcr_flags = __fpcr_trap_inexact | __fpcr_trap_underflow |
261261
__fpcr_trap_overflow | __fpcr_trap_divbyzero | __fpcr_trap_invalid | __fpcr_flush_to_zero;
262-
if (fenv_flag == all_fpcr_flags ) {
262+
if (fpcr_flags == all_fpcr_flags ) {
263263
return FE_ALL_EXCEPT;
264264
}
265265
return fenv_flag;
@@ -2621,7 +2621,7 @@ process_options()
26212621
// Not all platforms, e.g. Nvidia's Grace, support trapping FPEs,
26222622
// so we have to check if trapping is enabled
26232623
int prev_enabled_exceptions = fegetexcept();
2624-
int drhook_trapfpe_hw_support = feenableexcept(FE_INVALID & FE_DIVBYZERO & FE_OVERFLOW) != -1;
2624+
int drhook_trapfpe_hw_support = feenableexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW) != -1;
26252625
// Even if we failed above, we should still try to restore the flags
26262626
#if defined(__APPLE__) && defined(__arm64__)
26272627
// This seems to be enabled by default, but causes DrHook to raise a SIGILL in the OPTPRINTs below

tests/drhook/drhook_core/drhook_no_hw_fpe/drhook_check_hw_fpe_support.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static unsigned int fpcr_to_fenv(unsigned long long fpcr_flags) {
6666
}
6767
unsigned long long all_fpcr_flags = __fpcr_trap_inexact & __fpcr_trap_underflow &
6868
__fpcr_trap_overflow & __fpcr_trap_divbyzero & __fpcr_trap_invalid & __fpcr_flush_to_zero;
69-
if (fenv_flag == all_fpcr_flags ) {
69+
if (fpcr_flags == all_fpcr_flags ) {
7070
return FE_ALL_EXCEPT;
7171
}
7272
return fenv_flag;
@@ -95,5 +95,5 @@ int feenableexcept(int mask) {
9595
#endif
9696

9797
int main() {
98-
return feenableexcept(FE_INVALID & FE_DIVBYZERO & FE_OVERFLOW) == -1;
98+
return feenableexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW) == -1;
9999
}

0 commit comments

Comments
 (0)