Last active
August 13, 2023 22:12
-
-
Save comex/061c2f7316e5bfbded0fed50bf15b424 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma STDC FENV_ACCESS ON | |
#include <signal.h> | |
#include <assert.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <fenv.h> | |
static void check(const char *where) { | |
printf("%-40s: fegetround() => %#x\n", where, fegetround()); | |
} | |
static void handler(int _) { | |
check("in signal handler before fesetround"); | |
assert(!fesetround(FE_DOWNWARD)); | |
check("in signal handler after fesetround"); | |
} | |
int main() { | |
int round = FE_UPWARD; | |
printf("fesetround(%#x)\n", round); | |
assert(!fesetround(round)); | |
check("before signal handler"); | |
assert(SIG_ERR != signal(SIGINT, handler)); | |
assert(!raise(SIGINT)); | |
check("after signal handler"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment