Upload Tizen:Base source
[external/eglibc.git] / ports / sysdeps / powerpc / powerpc32 / e500 / fpu / fenv_libc.h
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, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
20
21 #ifndef _FENV_LIBC_H
22 #define _FENV_LIBC_H    1
23
24 #include <fenv.h>
25
26 extern int __feraiseexcept_internal (int __excepts);
27
28 /* Equivalent to fegetenv, but returns a fenv_t instead of taking a
29    pointer.  */
30 #define fegetenv_register() \
31         ({ unsigned fscr; asm volatile ("mfspefscr %0" : "=r" (fscr)); fscr; })
32
33 /* Equivalent to fesetenv, but takes a fenv_t instead of a pointer.  */
34 #define fesetenv_register(fscr) \
35         ({ asm volatile ("mtspefscr %0" : : "r" (fscr)); })
36
37 typedef union
38 {
39   fenv_t fenv;
40   unsigned int l[2];
41 } fenv_union_t;
42
43 /* Definitions of all the SPEFSCR bit numbers.  */
44 enum {
45   SPEFSCR_SOVH          = 0x80000000,
46   SPEFSCR_OVH           = 0x40000000,
47   SPEFSCR_FGH           = 0x20000000,
48   SPEFSCR_FXH           = 0x10000000,
49   SPEFSCR_FINVH         = 0x08000000,
50   SPEFSCR_FDBZH         = 0x04000000,
51   SPEFSCR_FUNFH         = 0x02000000,
52   SPEFSCR_FOVFH         = 0x01000000,
53   /* 2 unused bits.  */
54   SPEFSCR_FINXS         = 0x00200000,
55   SPEFSCR_FINVS         = 0x00100000,
56   SPEFSCR_FDBZS         = 0x00080000,
57   SPEFSCR_FUNFS         = 0x00040000,
58   SPEFSCR_FOVFS         = 0x00020000,
59   SPEFSCR_MODE          = 0x00010000,
60   SPEFSCR_SOV           = 0x00008000,
61   SPEFSCR_OV            = 0x00004000,
62   SPEFSCR_FG            = 0x00002000,
63   SPEFSCR_FX            = 0x00001000,
64   SPEFSCR_FINV          = 0x00000800,
65   SPEFSCR_FDBZ          = 0x00000400,
66   SPEFSCR_FUNF          = 0x00000200,
67   SPEFSCR_FOVF          = 0x00000100,
68   /* 1 unused bit.  */
69   SPEFSCR_FINXE         = 0x00000040,
70   SPEFSCR_FINVE         = 0x00000020,
71   SPEFSCR_FDBZE         = 0x00000010,
72   SPEFSCR_FUNFE         = 0x00000008,
73   SPEFSCR_FOVFE         = 0x00000004,
74   SPEFSCR_FRMC          = 0x00000003
75 };
76
77 #endif /* fenv_libc.h */