]> Pileus Git - ~andy/fetchmail/blob - trio/trionan.h
Minor bug fixes for socket.c
[~andy/fetchmail] / trio / trionan.h
1 /*************************************************************************
2  *
3  * $Id: trionan.h,v 1.9 2005/03/27 18:52:45 breese Exp $
4  *
5  * Copyright (C) 2001 Bjorn Reese <breese@users.sourceforge.net>
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
12  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
13  * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
14  * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
15  *
16  ************************************************************************/
17
18 #ifndef TRIO_TRIONAN_H
19 #define TRIO_TRIONAN_H
20
21 #include "triodef.h"
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #if !defined(TRIO_PUBLIC_NAN)
28 # if !defined(TRIO_PUBLIC)
29 #  define TRIO_PUBLIC
30 # endif
31 # define TRIO_PUBLIC_NAN TRIO_PUBLIC
32 #endif
33   
34 enum {
35   TRIO_FP_INFINITE,
36   TRIO_FP_NAN,
37   TRIO_FP_NORMAL,
38   TRIO_FP_SUBNORMAL,
39   TRIO_FP_ZERO
40 };
41
42 /*************************************************************************
43  * Dependencies
44  */
45
46 #if defined(TRIO_EMBED_NAN)
47
48 /*
49  * The application that trionan is embedded in must define which functions
50  * it uses.
51  *
52  * The following resolves internal dependencies.
53  */
54   
55 # if defined(TRIO_FUNC_ISNAN) \
56   || defined(TRIO_FUNC_ISINF)
57 #  if !defined(TRIO_FUNC_FPCLASSIFY_AND_SIGNBIT)
58 #   define TRIO_FUNC_FPCLASSIFY_AND_SIGNBIT
59 #  endif
60 # endif
61
62 # if defined(TRIO_FUNC_NAN)
63 #  if !defined(TRIO_FUNC_PINF)
64 #   define TRIO_FUNC_PINF
65 #  endif
66 # endif
67   
68 # if defined(TRIO_FUNC_NINF)
69 #  if !defined(TRIO_FUNC_PINF)
70 #   define TRIO_FUNC_PINF
71 #  endif
72 # endif
73
74 #else
75
76 /*
77  * When trionan is not embedded all all functions are defined.
78  */
79   
80 # define TRIO_FUNC_NAN
81 # define TRIO_FUNC_PINF
82 # define TRIO_FUNC_NINF
83 # define TRIO_FUNC_NZERO
84 # define TRIO_FUNC_ISNAN
85 # define TRIO_FUNC_ISINF
86 # define TRIO_FUNC_ISFINITE
87 # define TRIO_FUNC_SIGNBIT
88 # define TRIO_FUNC_FPCLASSIFY
89 # define TRIO_FUNC_FPCLASSIFY_AND_SIGNBIT
90   
91 #endif
92
93 /*************************************************************************
94  * Functions
95  */
96
97 /*
98  * Return NaN (Not-a-Number).
99  */
100 #if defined(TRIO_FUNC_NAN)
101 TRIO_PUBLIC_NAN double
102 trio_nan
103 TRIO_PROTO((void));
104 #endif
105
106 /*
107  * Return positive infinity.
108  */
109 #if defined(TRIO_FUNC_PINF)
110 TRIO_PUBLIC_NAN double
111 trio_pinf
112 TRIO_PROTO((void));
113 #endif
114
115 /*
116  * Return negative infinity.
117  */
118 #if defined(TRIO_FUNC_NINF)
119 TRIO_PUBLIC_NAN double
120 trio_ninf
121 TRIO_PROTO((void));
122 #endif
123
124 /*
125  * Return negative zero.
126  */
127 #if defined(TRIO_FUNC_NZERO)
128 TRIO_PUBLIC_NAN double
129 trio_nzero
130 TRIO_PROTO((TRIO_NOARGS));
131 #endif
132
133 /*
134  * If number is a NaN return non-zero, otherwise return zero.
135  */
136 #if defined(TRIO_FUNC_ISNAN)
137 TRIO_PUBLIC_NAN int
138 trio_isnan
139 TRIO_PROTO((double number));
140 #endif
141
142 /*
143  * If number is positive infinity return 1, if number is negative
144  * infinity return -1, otherwise return 0.
145  */
146 #if defined(TRIO_FUNC_ISINF)
147 TRIO_PUBLIC_NAN int
148 trio_isinf
149 TRIO_PROTO((double number));
150 #endif
151
152 /*
153  * If number is finite return non-zero, otherwise return zero.
154  */
155 #if defined(TRIO_FUNC_ISFINITE)
156 TRIO_PUBLIC_NAN int
157 trio_isfinite
158 TRIO_PROTO((double number));
159 #endif
160
161 #if defined(TRIO_FUNC_SIGNBIT)
162 TRIO_PUBLIC_NAN int
163 trio_signbit
164 TRIO_PROTO((double number));
165 #endif
166
167 #if defined(TRIO_FUNC_FPCLASSIFY)
168 TRIO_PUBLIC_NAN int
169 trio_fpclassify
170 TRIO_PROTO((double number));
171 #endif
172
173 #if defined(TRIO_FUNC_FPCLASSIFY_AND_SIGNBIT)
174 TRIO_PUBLIC_NAN int
175 trio_fpclassify_and_signbit
176 TRIO_PROTO((double number, int *is_negative));
177 #endif
178
179 #ifdef __cplusplus
180 }
181 #endif
182
183 #endif /* TRIO_TRIONAN_H */