Last active
August 13, 2023 22:12
-
-
Save comex/061c2f7316e5bfbded0fed50bf15b424 to your computer and use it in GitHub Desktop.
Revisions
-
comex revised this gist
Aug 13, 2023 . 1 changed file with 0 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,10 +5,6 @@ #include <stdlib.h> #include <fenv.h> static void check(const char *where) { printf("%-40s: fegetround() => %#x\n", where, fegetround()); } -
comex revised this gist
Aug 13, 2023 . 1 changed file with 7 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -10,28 +10,22 @@ #endif 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"); } -
comex revised this gist
Aug 13, 2023 . 1 changed file with 22 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,27 +4,34 @@ #include <stdio.h> #include <stdlib.h> #include <fenv.h> #ifdef _WIN32 #include <intrin.h> #endif static void check(const char *where) { printf("%21s: fegetround() => %#x\n", where, fegetround()); } static void handler(int _) { check("in signal handler"); } int main() { int round = FE_UPWARD; printf("fesetround(%#x)\n", round); assert(!fesetround(round)); check("before signal handler"); assert(SIG_ERR != signal(SIGTRAP, handler)); #ifdef _WIN32 __debugbreak(); #elif defined(__x86_64__) asm("int3"); #else asm("bkpt"); #endif check("after signal handler"); } -
comex created this gist
Aug 13, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #pragma STDC FENV_ACCESS ON #include <signal.h> #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <fenv.h> #include <xmmintrin.h> static void handler(int _) { printf("fegetround() in signal handler => %#x\n", fegetround()); #if defined(_M_X64) || defined(__x86_64__) printf("mxcsr: %x\n", _mm_getcsr()); #endif _Exit(0); } int main() { int round = FE_UPWARD; printf("fesetround(%#x)\n", round); assert(!fesetround(round)); printf("fegetround() before signal handler => %#x\n", fegetround()); #if defined(_M_X64) || defined(__x86_64__) printf("mxcsr: %x\n", _mm_getcsr()); #endif assert(SIG_ERR != signal(SIGSEGV, handler)); #ifndef _WIN32 assert(SIG_ERR != signal(SIGBUS, handler)); #endif *(volatile int *)0xdeadbeefdeadbeef = 2; }