1 /* GTS - Library for the manipulation of triangulated surfaces
2 * Copyright (C) 1999 Stéphane Popinet
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
23 #include "OSGSystemDef.h"
24 #include "OSGConfig.h"
28 // This is only necessary for Intel CPUs, to make sure they
29 // don't use a higher precision internally
31 #if defined(WIN32) || defined(__linux)
34 #define OSG_HAVE_FPU_CONTROL_H 1
37 #ifdef OSG_HAVE_FPU_CONTROL_H
38 # include <fpu_control.h>
40 static fpu_control_t fpu_round_double
=
41 (_FPU_DEFAULT
& ~_FPU_EXTENDED
) | _FPU_DOUBLE
;
42 static fpu_control_t fpu_init
;
43 # define OSG_FPU_ROUND_DOUBLE { _FPU_GETCW(fpu_init); \
44 _FPU_SETCW(fpu_round_double); }
45 # define OSG_FPU_RESTORE {_FPU_SETCW(fpu_init);}
46 # else /* not FPU_EXTENDED */
47 # define OSG_FPU_ROUND_DOUBLE
48 # define OSG_FPU_RESTORE
49 # endif /* not FPU_EXTENDED */
50 #else /* not OSG_HAVE_FPU_CONTROL_H */
51 # ifdef OSG_HAVE_FLOATINGPOINT_H
52 # include <floatingpoint.h>
53 # define OSG_FPU_ROUND_DOUBLE (fpsetprec(FP_PD))
54 # define OSG_FPU_RESTORE (fpsetprec(FP_PE))
55 # else /* not OSG_HAVE_FLOATINGPOINT_H */
56 # if defined(WIN32) && !defined(_WIN64)
59 static unsigned int fpu_init
;
60 # define OSG_FPU_ROUND_DOUBLE (fpu_init = _controlfp(0, 0), \
61 _controlfp(_PC_53, _MCW_PC))
62 # define OSG_FPU_RESTORE (_controlfp(fpu_init, 0xfffff))
63 # else /* not _MSC_VER */
64 # error "You need the Microsoft C compiler for the Win32 version"
65 # endif /* not _MSC_VER */
66 # elif defined(_WIN64)
67 # pragma message("Windows x64 environment does not support rounding mode control")
68 # define OSG_FPU_ROUND_DOUBLE
69 # define OSG_FPU_RESTORE
71 # error "Unknown CPU: assuming default double precision rounding"
72 # define OSG_FPU_ROUND_DOUBLE
73 # define OSG_FPU_RESTORE
75 # endif /* not OSG_HAVE_FLOATINGPOINT_H */
76 #endif /* not OSG_HAVE_FPU_CONTROL_H */
78 #else // Other systems: not needed, define empty
80 #define OSG_FPU_ROUND_DOUBLE
81 #define OSG_FPU_RESTORE