diff options
Diffstat (limited to 'targets/agent_sys.c')
| -rw-r--r-- | targets/agent_sys.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/targets/agent_sys.c b/targets/agent_sys.c index 12a6ada..85b460a 100644 --- a/targets/agent_sys.c +++ b/targets/agent_sys.c @@ -7,6 +7,10 @@ #include <string.h> #include <sys/wait.h> #include <unistd.h> +#include <xmmintrin.h> + +// MXCSR's flush-to-zero and denormals-are-zero: what -ffast-math turns on. +enum { flush_to_zero = 0x8040 }; static int fd; @@ -19,8 +23,9 @@ static void on_signal(int signo) { say("signal\n"); } +// A thread starts with the floating-point modes of the thread that made it. static void *thread(void *arg) { - say(arg); + say((_mm_getcsr() & flush_to_zero) == flush_to_zero ? arg : "thread without its maker's modes\n"); return NULL; } @@ -41,6 +46,7 @@ int main(void) { raise(SIGUSR1); pthread_t t; + _mm_setcsr(_mm_getcsr() | flush_to_zero); pthread_create(&t, NULL, thread, "thread\n"); pthread_join(t, NULL); |
