pcb 4.1.1
An interactive printed circuit board layout editor.

rounding.h

Go to the documentation of this file.
00001 /* GTS - Library for the manipulation of triangulated surfaces
00002  * Copyright (C) 1999 Stéphane Popinet
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  * Boston, MA 02111-1307, USA.
00018  */
00019 
00020 #include "config.h"
00021 
00022 #ifdef HAVE_FPU_CONTROL_H
00023 #  include <fpu_control.h>
00024 #  ifdef _FPU_EXTENDED
00025 #   if !defined(__alpha__) || !defined(__GLIBC__)
00026 #    if defined(__arm__)
00027      static fpu_control_t fpu_round_double = _FPU_DEFAULT;
00028 #    else
00029      static fpu_control_t fpu_round_double =
00030        (_FPU_DEFAULT & ~ _FPU_EXTENDED)|_FPU_DOUBLE;
00031 #    endif
00032      static fpu_control_t fpu_init;
00033 #    define FPU_ROUND_DOUBLE  { _FPU_GETCW(fpu_init);\
00034                                 _FPU_SETCW(fpu_round_double); }
00035 #    define FPU_RESTORE       {_FPU_SETCW(fpu_init);}
00036 #   else /* __alpha__ && __GLIBC__ */
00037 #    define FPU_ROUND_DOUBLE
00038 #    define FPU_RESTORE
00039 #   endif /* __alpha__ && __GLIBC__ */
00040 #  else /* not FPU_EXTENDED */
00041 #    define FPU_ROUND_DOUBLE
00042 #    define FPU_RESTORE
00043 #  endif /* not FPU_EXTENDED */
00044 #else /* not HAVE_FPU_CONTROL_H */
00045 #  ifdef __FreeBSD__
00046 #    include <floatingpoint.h>
00047 #    define FPU_ROUND_DOUBLE  (fpsetprec(FP_PD))
00048 #    define FPU_RESTORE       (fpsetprec(FP_PE))
00049 #  else /* not __FreeBSD__ */
00050 #    ifdef WIN32
00051 #      ifdef _MSC_VER
00052 #        include <float.h>
00053          static unsigned int fpu_init;
00054 #        define FPU_ROUND_DOUBLE (fpu_init = _controlfp (0, 0),\
00055                                  _controlfp (_PC_53, MCW_PC))
00056 #        define FPU_RESTORE      (_controlfp (fpu_init, 0xfffff))
00057 #      elif __MINGW32__
00058 #        include <float.h>
00059          static unsigned int fpu_init;
00060 #        define FPU_ROUND_DOUBLE (fpu_init = _controlfp (0, 0),\
00061                                   _controlfp (_PC_53, _MCW_PC))
00062 #        define FPU_RESTORE      (_controlfp (fpu_init, 0xfffff))
00063 #      else /* not _MSC_VER or __MINGW32__ */
00064 #        error "You need MSVC or MinGW for the Win32 version"
00065 #      endif /*  not _MSC_VER or __MINGW32__ */
00066 #    else /* not WIN32 */
00067 #      ifdef __CYGWIN__
00068          typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
00069          static fpu_control_t fpu_round_double = 0x027f;
00070          static fpu_control_t fpu_init;
00071 #        define _FPU_GETCW(cw) __asm__ ("fnstcw %0" : "=m" (*&cw))
00072 #        define _FPU_SETCW(cw) __asm__ ("fldcw %0" : : "m" (*&cw))
00073 #        define FPU_ROUND_DOUBLE  { _FPU_GETCW(fpu_init);\
00074                                     _FPU_SETCW(fpu_round_double); }
00075 #        define FPU_RESTORE       { _FPU_SETCW(fpu_init);}
00076 #      else /* not __CYGWIN__ */
00077 #        ifdef CPP_HAS_WARNING
00078 #          warning "Unknown CPU: assuming default double precision rounding"
00079 #        endif /* CPP_HAS_WARNING */
00080 #        define FPU_ROUND_DOUBLE
00081 #        define FPU_RESTORE
00082 #      endif /* not __CYGWIN__ */
00083 #    endif /* not WIN32 */
00084 #  endif /* not __FreeBSD__ */
00085 #endif /* not HAVE_FPU_CONTROL_H */