Change license from GPLv2+ to GPLv3+.
[pspp-builds.git] / src / libpspp / magic.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program 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
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
17 #if !magic_h
18 #define magic_h 1
19
20 /* Magic numbers. */
21
22 #include <float.h>
23 #include <limits.h>
24
25 /* Check that the floating-point representation is one that we
26    understand. */
27 #ifndef FPREP_IEEE754
28 #error Only IEEE-754 floating point currently supported.
29 #endif
30
31 /* Allows us to specify individual bytes of a double. */
32 union cvt_dbl {
33   unsigned char cvt_dbl_i[8];
34   double cvt_dbl_d;
35 };
36
37
38 /* "Second-lowest value" bytes for an IEEE-754 double. */
39 #if WORDS_BIGENDIAN
40 #define SECOND_LOWEST_BYTES {0xff,0xef,0xff,0xff, 0xff,0xff,0xff,0xfe}
41 #else
42 #define SECOND_LOWEST_BYTES {0xfe,0xff,0xff,0xff, 0xff,0xff,0xef,0xff}
43 #endif
44
45 /* "Second-lowest value" for a double. */
46 #if __GNUC__
47 #define second_lowest_value                                               \
48         (__extension__ ((union cvt_dbl) {SECOND_LOWEST_BYTES}).cvt_dbl_d)
49 #else /* not GNU C */
50 extern union cvt_dbl second_lowest_value_union;
51 #define second_lowest_value (second_lowest_value_union.cvt_dbl_d)
52 #endif
53
54 /* Used when we want a "missing value". */
55 #define NOT_DOUBLE (-DBL_MAX)
56 #define NOT_LONG LONG_MIN
57 #define NOT_INT INT_MIN
58
59 #endif /* magic.h */