1 /* Internal libc stuff for floating point environment routines.
2    Copyright (C) 2004 Free Software Foundation, Inc.
3    Contributed by Aldy Hernandez <aldyh@redhat.com>, 2004
4    This file is part of the GNU C Library.
5 
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10 
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15 
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, see
18    <http://www.gnu.org/licenses/>.  */
19 
20 #ifndef _FENV_LIBC_H
21 #define _FENV_LIBC_H	1
22 
23 #include <fenv.h>
24 
25 extern int __feraiseexcept_internal (int __excepts);
26 
27 /* Equivalent to fegetenv, but returns a fenv_t instead of taking a
28    pointer.  */
29 #define fegetenv_register() \
30         ({ unsigned fscr; __asm__ __volatile__ ("mfspefscr %0" : "=r" (fscr)); fscr; })
31 
32 /* Equivalent to fesetenv, but takes a fenv_t instead of a pointer.  */
33 #define fesetenv_register(fscr) \
34 	({ __asm__ __volatile__ ("mtspefscr %0" : : "r" (fscr)); })
35 
36 typedef union
37 {
38   fenv_t fenv;
39   unsigned int l[2];
40 } fenv_union_t;
41 
42 /* Definitions of all the SPEFSCR bit numbers.  */
43 enum {
44   SPEFSCR_SOVH          = 0x80000000,
45   SPEFSCR_OVH           = 0x40000000,
46   SPEFSCR_FGH           = 0x20000000,
47   SPEFSCR_FXH           = 0x10000000,
48   SPEFSCR_FINVH         = 0x08000000,
49   SPEFSCR_FDBZH         = 0x04000000,
50   SPEFSCR_FUNFH         = 0x02000000,
51   SPEFSCR_FOVFH         = 0x01000000,
52   /* 2 unused bits.  */
53   SPEFSCR_FINXS         = 0x00200000,
54   SPEFSCR_FINVS         = 0x00100000,
55   SPEFSCR_FDBZS         = 0x00080000,
56   SPEFSCR_FUNFS         = 0x00040000,
57   SPEFSCR_FOVFS         = 0x00020000,
58   SPEFSCR_MODE          = 0x00010000,
59   SPEFSCR_SOV           = 0x00008000,
60   SPEFSCR_OV            = 0x00004000,
61   SPEFSCR_FG            = 0x00002000,
62   SPEFSCR_FX            = 0x00001000,
63   SPEFSCR_FINV          = 0x00000800,
64   SPEFSCR_FDBZ          = 0x00000400,
65   SPEFSCR_FUNF          = 0x00000200,
66   SPEFSCR_FOVF          = 0x00000100,
67   /* 1 unused bit.  */
68   SPEFSCR_FINXE         = 0x00000040,
69   SPEFSCR_FINVE         = 0x00000020,
70   SPEFSCR_FDBZE         = 0x00000010,
71   SPEFSCR_FUNFE         = 0x00000008,
72   SPEFSCR_FOVFE         = 0x00000004,
73   SPEFSCR_FRMC          = 0x00000003
74 };
75 
76 #endif /* fenv_libc.h */
77