00001 #include "config.h"
00002
00003 #ifdef HAVE_LIBPLOTTER
00004
00005
00006
00007
00008
00009 #ifdef HAVE_VOID
00010 #define voidptr_t void *
00011 #else
00012 #define NO_VOID_SUPPORT
00013 #define voidptr_t char *
00014 #define void int
00015 #endif
00016
00017 #ifdef const
00018 #define NO_CONST_SUPPORT
00019 #endif
00020
00021
00022
00023
00024 #ifdef ____P
00025 #undef ____P
00026 #endif
00027 #ifdef _HAVE_PROTOS
00028 #undef _HAVE_PROTOS
00029 #endif
00030 #if defined (__STDC__) || defined (_AIX) \
00031 || (defined (__mips) && defined (_SYSTYPE_SVR4)) \
00032 || defined(WIN32) || defined(__cplusplus)
00033 #ifdef _SUPPRESS_PROTOS
00034 #define ____P(protos) ()
00035 #else
00036 #define ____P(protos) protos
00037 #define _HAVE_PROTOS 1
00038 #endif
00039 #else
00040 #define ____P(protos) ()
00041 #endif
00042
00043
00044
00045
00046
00047
00048
00049 #ifdef __cplusplus
00050 # define __C_LINKAGE "C"
00051 #else
00052 # define __C_LINKAGE
00053 #endif
00054
00055
00056
00057 #ifdef __cplusplus
00058 #ifdef RETSIGTYPE
00059 #undef RETSIGTYPE
00060 #endif
00061 #define RETSIGTYPE void
00062 #endif
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 #ifdef LIBPLOT
00078 #ifdef PTHREAD_SUPPORT
00079 #ifdef HAVE_PTHREAD_H
00080 #define _REENTRANT
00081 #include <pthread.h>
00082 #endif
00083 #endif
00084 #endif
00085
00086
00087
00088
00089
00090 #include <stdio.h>
00091 #include <ctype.h>
00092
00093 #include <errno.h>
00094 #ifndef HAVE_STRERROR
00095 extern __C_LINKAGE char *strerror ____P((int errnum));
00096 #endif
00097
00098
00099
00100
00101
00102 #ifdef __DJGPP__
00103
00104
00105 #define _USE_LIBM_MATH_H
00106 #endif
00107
00108
00109
00110 #include <math.h>
00111
00112 #ifdef HAVE_FLOAT_H
00113 #include <float.h>
00114 #endif
00115 #ifdef HAVE_LIMITS_H
00116 #include <limits.h>
00117 #endif
00118 #ifdef HAVE_VALUES_H
00119 #include <values.h>
00120 #endif
00121
00122
00123
00124 #ifndef UINT_MAX
00125 #ifdef __STDC__
00126 #define UINT_MAX ((unsigned int)(~(0U)))
00127 #else
00128 #define UINT_MAX ((unsigned int)(~((unsigned int)0)))
00129 #endif
00130 #endif
00131
00132 #ifndef INT_MAX
00133 #ifdef MAXINT
00134 #define INT_MAX MAXINT
00135 #else
00136 #define INT_MAX ((int)(~(1U << (8 * (int)sizeof(int) - 1))))
00137 #endif
00138 #endif
00139
00140
00141
00142 #ifdef _AIX
00143 #ifdef __GNUC__
00144 #undef INT_MAX
00145 #define INT_MAX ((int)(~(1U << (8 * (int)sizeof(int) - 1))))
00146 #endif
00147 #endif
00148
00149
00150
00151 #ifndef DBL_MAX
00152 #ifdef MAXDOUBLE
00153 #define DBL_MAX MAXDOUBLE
00154 #else
00155
00156 #define DBL_MAX (1.701411834604692293e+38)
00157 #endif
00158 #endif
00159
00160 #ifndef FLT_MAX
00161 #ifdef MAXFLOAT
00162 #define FLT_MAX MAXFLOAT
00163 #else
00164
00165 #define FLT_MAX (1.7014117331926443e+38)
00166 #endif
00167 #endif
00168
00169
00170
00171
00172
00173
00174 #ifdef STDC_HEADERS
00175 #include <stdlib.h>
00176 #include <string.h>
00177
00178 #else
00179
00180 #ifdef HAVE_SYS_STDTYPES_H
00181 #include <sys/stdtypes.h>
00182 #endif
00183
00184
00185 extern __C_LINKAGE char *getenv ____P((const char *name));
00186 extern __C_LINKAGE int atoi ____P((const char *nptr));
00187 extern __C_LINKAGE double atof ____P((const char *nptr));
00188
00189
00190 #define EXIT_FAILURE 1
00191 #define EXIT_SUCCESS 0
00192
00193
00194 #ifdef HAVE_STRCHR
00195 #ifdef HAVE_STRING_H
00196 #include <string.h>
00197 #else
00198 #ifdef HAVE_STRINGS_H
00199 #include <strings.h>
00200 #endif
00201 #endif
00202 #else
00203 #ifdef HAVE_STRINGS_H
00204 #include <strings.h>
00205 #else
00206 #ifdef HAVE_STRING_H
00207 #include <string.h>
00208 #endif
00209 #endif
00210 #define strchr index
00211 #define strrchr rindex
00212 #endif
00213
00214 #ifndef HAVE_MEMCPY
00215 #define memcpy(d, s, n) bcopy ((s), (d), (n))
00216 #endif
00217 #ifndef HAVE_MEMMOVE
00218 #define memmove(d, s, n) bcopy ((s), (d), (n))
00219 #endif
00220
00221 #ifndef HAVE_STRCASECMP
00222 extern __C_LINKAGE int strcasecmp ____P((const char *s1, const char *s2));
00223 #endif
00224
00225
00226 #ifdef HAVE_MALLOC_H
00227 #include <malloc.h>
00228 #else
00229 extern __C_LINKAGE voidptr_t malloc ____P((size_t size));
00230 extern __C_LINKAGE voidptr_t realloc ____P((voidptr_t ptr, size_t size));
00231 extern __C_LINKAGE voidptr_t calloc ____P((size_t nmemb, size_t size));
00232 extern __C_LINKAGE void free ____P((voidptr_t ptr));
00233 #endif
00234
00235 #endif
00236
00237
00238
00239
00240
00241 #ifndef NULL
00242 #define NULL 0
00243 #endif
00244
00245
00246
00247
00248
00249
00250 #ifdef __cplusplus
00251 #ifndef HAVE_BOOL
00252 typedef enum { false = 0, true = 1 } bool;
00253 #endif
00254 #else
00255 #ifdef __STDC__
00256 typedef enum { false = 0, true = 1 } bool;
00257 #else
00258 typedef int bool;
00259 #define false 0
00260 #define true 1
00261 #endif
00262 #endif
00263
00264
00265
00266
00267
00268 #ifndef M_PI
00269 #define M_PI 3.14159265358979323846264
00270 #endif
00271 #ifndef M_PI_2
00272 #define M_PI_2 1.57079632679489661923
00273 #endif
00274 #ifndef M_SQRT2
00275 #define M_SQRT2 1.41421356237309504880
00276 #endif
00277 #ifndef M_SQRT3
00278 #define M_SQRT3 1.73205080756887719
00279 #endif
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294 #ifdef _AIX
00295 #define NO_SYSTEM_GAMMA
00296 #endif
00297 #ifdef NO_SYSTEM_GAMMA
00298 #define F_LGAMMA f_lgamma
00299 #else
00300 #ifdef HAVE_LGAMMA
00301 #define F_LGAMMA lgamma
00302 #else
00303 #ifdef HAVE_GAMMA
00304 #define F_LGAMMA gamma
00305 #else
00306 #define F_LGAMMA f_lgamma
00307 #define NO_SYSTEM_GAMMA
00308 #endif
00309 #endif
00310 #endif
00311
00312
00313
00314
00315
00316 #ifdef __GNUC__
00317 #define DMAX(a,b) ({double _a = (a), _b = (b); _a > _b ? _a : _b; })
00318 #define DMIN(a,b) ({double _a = (a), _b = (b); _a < _b ? _a : _b; })
00319 #define IMAX(a,b) ({int _a = (a), _b = (b); _a > _b ? _a : _b; })
00320 #define IMIN(a,b) ({int _a = (a), _b = (b); _a < _b ? _a : _b; })
00321 #define UMAX(a,b) ({unsigned int _a = (a), _b = (b); _a > _b ? _a : _b; })
00322 #define UMIN(a,b) ({unsigned int _a = (a), _b = (b); _a < _b ? _a : _b; })
00323 #define IROUND(x) ({double _x = (x); int _i; \
00324 if (_x >= INT_MAX) _i = INT_MAX; \
00325 else if (_x <= -(INT_MAX)) _i = -(INT_MAX); \
00326 else _i = (_x > 0.0 ? (int)(_x + 0.5) : (int)(_x - 0.5)); \
00327 _i;})
00328 #define FROUND(x) ({double _x = (x); float _f; \
00329 if (_x >= FLT_MAX) _f = FLT_MAX; \
00330 else if (_x <= -(FLT_MAX)) _f = -(FLT_MAX); \
00331 else _f = _x; \
00332 _f;})
00333 #define FABS(x) ((x) >= 0.0 ? (x) : -(x))
00334 #define ICEIL(x) ({double _x = (x); int _i = (int)_x; \
00335 ((_x == _i) || (_x < 0.0)) ? _i : _i + 1;})
00336 #define IFLOOR(x) ({double _x = (x); int _i = (int)_x; \
00337 ((_x == _i) || (_x > 0.0)) ? _i : _i - 1;})
00338 #else
00339 #define DMAX(a,b) ((a) > (b) ? (a) : (b))
00340 #define DMIN(a,b) ((a) < (b) ? (a) : (b))
00341 #define IMAX(a,b) ((a) > (b) ? (a) : (b))
00342 #define IMIN(a,b) ((a) < (b) ? (a) : (b))
00343 #define UMAX(a,b) ((a) > (b) ? (a) : (b))
00344 #define UMIN(a,b) ((a) < (b) ? (a) : (b))
00345 #define IROUND(x) ((int) ((x) > 0 ? (x) + 0.5 : (x) - 0.5))
00346 #define FROUND(x) ((float)(x))
00347 #define FABS(x) ((x) >= 0.0 ? (x) : -(x))
00348 #define ICEIL(x) ((int)ceil(x))
00349 #define IFLOOR(x) ((int)floor(x))
00350 #endif
00351
00352 #endif