LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
fpControl.cc
Go to the documentation of this file.
2 
3 #if defined __i386__ || defined __x86_64__
4 #ifdef __linux__
5 #include <fpu_control.h>
6 #define fpControl_GETFPCW _FPU_GETCW
7 #define fpControl_SETFPCW _FPU_SETCW
8 #elif defined __APPLE__
9 #define fpControl_GETFPCW(cw) __asm__ __volatile__("fnstcw %0" : "=m"(*&cw))
10 #define fpControl_SETFPCW(cw) __asm__ __volatile__("fldcw %0" : : "m"(*&cw))
11 #else
12 #error OS not valid for FP control
13 #endif
14 #ifdef fpControl_HAVE_MXCSR
15 #define fpControl_GETMXCSR(cw) __asm__ __volatile__("stmxcsr %0" : "=m"(*&cw))
16 #define fpControl_SETMXCSR(cw) __asm__ __volatile__("ldmxcsr %0" : : "m"(*&cw))
17 #endif
18 #endif
19 
22 {
23  fpsw_t result{static_cast<fpsw_t>(fetestexcept(FE_ALL_EXCEPT))};
24  return result;
25 }
26 
29 {
30  fpcw_t result;
31  fpControl_GETFPCW(result);
32  return result;
33 }
34 
37 {
38  fpcw_t result = getFPCW();
39  fpControl_SETFPCW(fpcw);
40  return result;
41 }
42 
43 #ifdef fpControl_HAVE_MXCSR
44 art::fp_detail::mxcsr_t
45 art::fp_detail::getMXCSR()
46 {
47  mxcsr_t result;
48  fpControl_GETMXCSR(result);
49  return result;
50 }
51 
52 art::fp_detail::mxcsr_t
53 art::fp_detail::setMXCSR(mxcsr_t const mxcsr)
54 {
55  mxcsr_t result = getMXCSR();
56  fpControl_SETMXCSR(mxcsr);
57  return result;
58 }
59 
60 #endif
fpcw_t setFPCW(fpcw_t fpcw)
Definition: fpControl.cc:36
fpsw_t getFPSW()
Definition: fpControl.cc:21
typedef fpsw_t
Definition: fpControl.h:91
fpcw_t getFPCW()
Definition: fpControl.cc:28
typedef fpcw_t
Definition: fpControl.h:99