Home | History | Annotate | Download | only in include
      1 /*-
      2  * Copyright (c) 2004-2005 David Schultz <das (at) FreeBSD.ORG>
      3  * All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  * 1. Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  * 2. Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in the
     12  *    documentation and/or other materials provided with the distribution.
     13  *
     14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     24  * SUCH DAMAGE.
     25  *
     26  * $FreeBSD: src/lib/msun/arm/fenv.h,v 1.5 2005/03/16 19:03:45 das Exp $
     27  */
     28 
     29 /*
     30  * Rewritten for Android.
     31  *
     32  * The ARM FPSCR is described here:
     33  * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0344b/Chdfafia.html
     34  */
     35 
     36 #ifndef _FENV_H_
     37 #define _FENV_H_
     38 
     39 #include <sys/types.h>
     40 
     41 __BEGIN_DECLS
     42 
     43 /*
     44  * arm/mips definition
     45  */
     46 typedef __uint32_t fenv_t;
     47 typedef __uint32_t fexcept_t;
     48 
     49 /*
     50  * x86 definition
     51  */
     52 /*
     53 typedef struct {
     54         __uint16_t      __control;
     55         __uint16_t      __mxcsr_hi;
     56         __uint16_t      __status;
     57         __uint16_t      __mxcsr_lo;
     58         __uint32_t      __tag;
     59         char            __other[16];
     60 } fenv_t;
     61 */
     62 
     63 
     64 /* Exception flags. */
     65 #define FE_INVALID    0x01
     66 #define FE_DIVBYZERO  0x02
     67 #define FE_OVERFLOW   0x04
     68 #define FE_UNDERFLOW  0x08
     69 #define FE_INEXACT    0x10
     70 #define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
     71 
     72 /* Rounding modes. */
     73 #define FE_TONEAREST  0x0
     74 #define FE_UPWARD     0x1
     75 #define FE_DOWNWARD   0x2
     76 #define FE_TOWARDZERO 0x3
     77 
     78 /* Default floating-point environment. */
     79 extern const fenv_t __fe_dfl_env;
     80 #define FE_DFL_ENV (&__fe_dfl_env)
     81 
     82 /*
     83  * Need implementations in libportable to enable following functions
     84  *
     85  * int fegetenv(fenv_t* __envp);
     86  * int fesetenv(const fenv_t* __envp);
     87  * int feholdexcept(fenv_t* __envp);
     88  * int feupdateenv(const fenv_t* __envp);
     89  */
     90 
     91 int feclearexcept(int __excepts);
     92 int fegetexceptflag(fexcept_t* __flagp, int __excepts);
     93 int fesetexceptflag(const fexcept_t* __flagp, int __excepts);
     94 int feraiseexcept(int __excepts);
     95 int fetestexcept(int __excepts);
     96 int fegetround(void);
     97 int fesetround(int __round);
     98 
     99 __END_DECLS
    100 
    101 #endif /* !_FENV_H_ */
    102