• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * ieee_status.c
3  *
4  * Copyright (c) 2015-2018, Arm Limited.
5  * SPDX-License-Identifier: MIT
6  */
7 
8 #include "math_private.h"
9 
__ieee_status(unsigned bicmask,unsigned xormask)10 __inline unsigned __ieee_status(unsigned bicmask, unsigned xormask)
11 {
12 #if defined __aarch64__ && defined __FP_FENV_EXCEPTIONS
13   unsigned status_word;
14   unsigned ret;
15 
16 #ifdef __FP_FENV_ROUNDING
17 # define MASK (1<<27)|FE_IEEE_FLUSHZERO|FE_IEEE_MASK_ALL_EXCEPT|FE_IEEE_ALL_EXCEPT|FE_IEEE_ROUND_MASK
18 #else
19 # define MASK (1<<27)|FE_IEEE_FLUSHZERO|FE_IEEE_MASK_ALL_EXCEPT|FE_IEEE_ALL_EXCEPT
20 #endif
21 
22   /* mask out read-only bits */
23   bicmask &= MASK;
24   xormask &= MASK;
25 
26   /* modify the status word */
27   __asm__ __volatile__ ("mrs %0, fpsr" : "=r" (status_word));
28   ret = status_word;
29   status_word &= ~bicmask;
30   status_word ^= xormask;
31   __asm__ __volatile__ ("msr fpsr, %0" : : "r" (status_word));
32 
33   /* and return what it used to be */
34   return ret;
35 #else
36   return 0;
37 #endif
38 }
39