00001
00038 #ifndef _MALOC_BASE_H_
00039 #define _MALOC_BASE_H_
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 #include <assert.h>
00065 #include <ctype.h>
00066 #include <errno.h>
00067 #include <float.h>
00068 #include <limits.h>
00069 #include <locale.h>
00070 #include <math.h>
00071 #include <signal.h>
00072 #include <stdarg.h>
00073 #include <stddef.h>
00074 #include <stdio.h>
00075 #include <stdlib.h>
00076 #include <string.h>
00077 #include <time.h>
00078
00082 #if !defined(CLOCKS_PER_SEC)
00083 # define CLOCKS_PER_SEC 60
00084 #endif
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 #define __FAVOR_BSD
00106 #define _BSD_SIGNALS
00108
00109 #include <setjmp.h>
00110
00111 #if defined(__cplusplus)
00112
00113 # define VCXX
00114
00115 # define VEXTERNC extern "C"
00116 #else
00117
00118 # define VCC
00119
00120 # define VEXTERNC extern
00121 #endif
00122
00123
00124
00125
00126
00127
00128
00129 #define VPRIVATE static
00130 #define VPUBLIC
00134 #define VWARN1(file, lineno) (fprintf(stderr,"VWARN: ASSERTION FAILURE! filename %s, line %u\n", (file), (lineno)), 0)
00135
00136 #define VASSERT1(file, lineno) (fprintf(stderr,"VASSERT: ASSERTION FAILURE! filename %s, line %u\n", (file), (lineno)), exit(1), 0)
00137
00138 #define VASSERT2(file, lineno) (fprintf(stderr,"VASSERT: ASSERTION FAILURE! filename %s, line %u\n", (file), (lineno)), abort(), 0)
00139
00140 #define VASSERT3(file, lineno, ex) (fprintf(stderr,"VASSERT: ASSERTION FAILURE! filename %s, line %u, (%s)\n", (file), (lineno), (#ex)), abort(), 0)
00141
00143 #define VWARN(ex) ((void) ((ex) ? 0 : VWARN1(__FILE__, __LINE__)))
00144
00145 #define VASSERT(ex) ((void) ((ex) ? 0 : VASSERT3(__FILE__, __LINE__, ex)))
00146
00147
00149 #define VJMPERR0(x) if (!(x)) goto VERROR0
00150
00151 #define VJMPERR1(x) if (!(x)) goto VERROR1
00152
00153 #define VJMPERR2(x) if (!(x)) goto VERROR2
00154
00155 #define VJMPERR3(x) if (!(x)) goto VERROR3
00156
00157 #define VJMPERR4(x) if (!(x)) goto VERROR4
00158
00159 #define VJMPERR5(x) if (!(x)) goto VERROR5
00160
00161 #define VJMPERR6(x) if (!(x)) goto VERROR6
00162
00163 #define VJMPERR7(x) if (!(x)) goto VERROR7
00164
00165 #define VJMPERR8(x) if (!(x)) goto VERROR8
00166
00167 #define VJMPERR9(x) if (!(x)) goto VERROR9
00168
00169
00170
00171
00172
00173
00174
00176 #define VPI 3.14159265358979323846
00177
00178 #define VLARGE 1.0e+9
00179
00180 #define VSMALL 1.0e-9
00181
00182 #define VVLARGE 1.0e+15
00183
00184 #define VVSMALL 1.0e-15
00185
00186 #define VPRTKEY 10000
00187
00189 #define VPTRSIZE 4
00190
00191 #define VMAX_ARGNUM 50
00192
00193 #define VMAX_ARGLEN 1024
00194
00195 #define VMAX_BUFSIZE 8192
00196
00197
00198
00199
00200
00201
00203 #define VMAX_OBJECTS 1073741824
00204
00205 #define VBLOCK_POWER 14
00206
00208 #define VNULL NULL
00209
00210 #define VINULL -1
00211
00212 #define VTRUE 1
00213
00214 #define VFALSE 0
00215
00216 #define VSTDMODE 0600
00217
00219 #define VNULL_STRING "\0"
00220
00221 #define VBLANK_STRING " "
00222
00223 #define VNEWLINE_STRING "\n"
00224
00226 #define VNULL_SYMBOL '\0'
00227
00228 #define VBLANK_SYMBOL ' '
00229
00230 #define VNEWLINE_SYMBOL '\n'
00231
00232 #define VRDIN_SYMBOL '<'
00233
00234 #define VRDOUT_SYMBOL '>'
00235
00236 #define VPIPE_SYMBOL '|'
00237
00238 #define VDELIM_SET " ><|&"
00239
00240
00242 #define VABS(x) ((x) >= 0 ? (x) : -(x))
00243
00244 #define VMIN2(x,y) ((x) <= (y) ? (x) : (y))
00245
00246 #define VMAX2(x,y) ((x) >= (y) ? (x) : (y))
00247
00248 #define VSIGN(x,y) ((y) >= 0 ? (VABS(x)) : (-VABS(x)))
00249
00251 #define VODD(x) ((x)&1)
00252
00253 #define VEVEN(x) (!((x)&1))
00254
00255 #define VZERO(x) ((x)==0)
00256
00257 #define VPOS(x) ((x)>0)
00258
00259 #define VNEG(x) ((x)<0)
00260
00261 #define VEVENP(x) (VEVEN(x) && VPOS(x))
00262
00263 #define VEVENN(x) (VEVEN(x) && VNEG(x))
00264
00266 #define VSQRT(x) (sqrt(x))
00267
00268 #define VSQR(x) ((x)*(x))
00269
00270 #define VSIN(x) (sin(x))
00271
00272 #define VCOS(x) (cos(x))
00273
00274 #define VTAN(x) (tan(x))
00275
00276 #define VASIN(x) (asin(x))
00277
00278 #define VACOS(x) (acos(x))
00279
00280 #define VATAN(x) (atan(x))
00281
00282 #define VSINH(x) (sinh(x))
00283
00284 #define VCOSH(x) (cosh(x))
00285
00286 #define VTANH(x) (tanh(x))
00287
00288 #define VEXP(x) (exp(x))
00289
00290 #define VLOG(x) (log(x))
00291
00292 #define VPOW(x,y) (pow(x,y))
00293
00294 #define VRINT(x) ((int)(floor((x)+0.5)))
00295
00297 #define VRAND (rand())
00298
00299 #define VRANDMAX (RAND_MAX)
00300
00304 #if 1
00305 # define VINLINE_MALOC
00306 #endif
00307
00308 #endif
00309