changed: gcc8 base update
[opensg.git] / Source / System / NodeCores / Drawables / Nurbs / Internal / OSGrounding.h
blobb711c004e451f3cf115f9412e88a5b224eea0985
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.
19 #ifdef __sgi
20 #pragma once
21 #endif
23 #include "OSGSystemDef.h"
24 #include "OSGConfig.h"
26 OSG_BEGIN_NAMESPACE
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)
33 #ifndef WIN32
34 #define OSG_HAVE_FPU_CONTROL_H 1
35 #endif /* WIN32 */
37 #ifdef OSG_HAVE_FPU_CONTROL_H
38 # include <fpu_control.h>
39 # ifdef _FPU_EXTENDED
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)
57 # ifdef _MSC_VER
58 # include <float.h>
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
70 # else
71 # error "Unknown CPU: assuming default double precision rounding"
72 # define OSG_FPU_ROUND_DOUBLE
73 # define OSG_FPU_RESTORE
74 # endif
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
83 #endif
85 OSG_END_NAMESPACE