1 /**
2 * \file
3 * \brief \todo brief description
4 *
5 * Authors:
6 * ? <?@?.?>
7 *
8 * Copyright ?-? authors
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it either under the terms of the GNU Lesser General Public
12 * License version 2.1 as published by the Free Software Foundation
13 * (the "LGPL") or, at your option, under the terms of the Mozilla
14 * Public License Version 1.1 (the "MPL"). If you do not alter this
15 * notice, a recipient may use your version of this file under either
16 * the MPL or the LGPL.
17 *
18 * You should have received a copy of the LGPL along with this library
19 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * You should have received a copy of the MPL along with this library
22 * in the file COPYING-MPL-1.1
23 *
24 * The contents of this file are subject to the Mozilla Public License
25 * Version 1.1 (the "License"); you may not use this file except in
26 * compliance with the License. You may obtain a copy of the License at
27 * http://www.mozilla.org/MPL/
28 *
29 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
30 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
31 * the specific language governing rights and limitations.
32 *
33 */
35 #ifndef _2GEOM_ISNAN_H__
36 #define _2GEOM_ISNAN_H__
38 /*
39 * Temporary fix for various misdefinitions of isnan().
40 * isnan() is becoming undef'd in some .h files.
41 * #include this last in your .cpp file to get it right.
42 *
43 * The problem is that isnan and isfinite are part of C99 but aren't part of
44 * the C++ standard (which predates C99).
45 *
46 * Authors:
47 * Inkscape groupies and obsessive-compulsives
48 *
49 * Copyright (C) 2004 authors
50 *
51 * Released under GNU GPL, read the file 'COPYING' for more information
52 *
53 * 2005 modification hereby placed in public domain. Probably supercedes
54 * the 2004 copyright for the code itself.
55 */
57 #include <math.h>
58 /* You might try changing the above to <cmath> if you have problems.
59 * Whether you use math.h or cmath, you may need to edit the .cpp file
60 * and/or other .h files to use the same header file.
61 */
63 #if defined(__isnan)
64 # define IS_NAN(_a) (__isnan(_a))
65 #elif defined(__APPLE__) && __GNUC__ == 3
66 # define IS_NAN(_a) (__isnan(_a)) /* MacOSX/Darwin definition < 10.4 */
67 #elif defined(WIN32) || defined(_isnan)
68 # define IS_NAN(_a) (_isnan(_a)) /* Win32 definition */
69 #elif defined(isnan) || defined(__FreeBSD__) || defined(__osf__)
70 # define IS_NAN(_a) (isnan(_a)) /* GNU definition */
71 #elif defined (SOLARIS_2_8) && __GNUC__ == 3 && __GNUC_MINOR__ == 2
72 # define IS_NAN(_a) (isnan(_a)) /* GNU definition */
73 #else
74 # define IS_NAN(_a) (std::isnan(_a))
75 #endif
76 /* If the above doesn't work, then try (a != a).
77 * Also, please report a bug as per http://www.inkscape.org/report_bugs.php,
78 * giving information about what platform and compiler version you're using.
79 */
82 #if defined(__isfinite)
83 # define IS_FINITE(_a) (__isfinite(_a))
84 #elif defined(__APPLE__) && __GNUC__ == 3
85 # define IS_FINITE(_a) (__isfinite(_a)) /* MacOSX/Darwin definition < 10.4 */
86 #elif defined(__sgi)
87 # define IS_FINITE(_a) (_isfinite(_a))
88 #elif defined(isfinite)
89 # define IS_FINITE(_a) (isfinite(_a))
90 #elif defined(__osf__)
91 # define IS_FINITE(_a) (finite(_a) && !IS_NAN(_a))
92 #elif defined (SOLARIS_2_8) && __GNUC__ == 3 && __GNUC_MINOR__ == 2
93 #include <ieeefp.h>
94 #define IS_FINITE(_a) (finite(_a) && !IS_NAN(_a))
95 #else
96 # define IS_FINITE(_a) (std::isfinite(_a))
97 #endif
98 /* If the above doesn't work, then try (finite(_a) && !IS_NAN(_a)) or
99 * (!IS_NAN((_a) - (_a))).
100 * Also, please report a bug as per http://www.inkscape.org/report_bugs.php,
101 * giving information about what platform and compiler version you're using.
102 */
105 #endif /* _2GEOM_ISNAN_H__ */
107 /*
108 Local Variables:
109 mode:c++
110 c-file-style:"stroustrup"
111 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
112 indent-tabs-mode:nil
113 fill-column:99
114 End:
115 */
116 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :