maloc_base.h
Go to the documentation of this file.
#ifndef _MALOC_BASE_H_
#define _MALOC_BASE_H_
/*
* ***************************************************************************
* Proper ISO-C header setup (with a slight "signals" tweek for setjmp)
* ***************************************************************************
*/
/* Get the fifteen ISO-C headers (CAREFUL: POSIX/BSD flags delicate...) */
/* Some compilers don't set this for you; GCC does with -ansi */
/*
* if !defined(__STDC__)
* define __STDC__ 1
* endif
*/
/* Old Sparc compilers need this to give you prototypes */
/*
* if !defined(__USE_FIXED_PROTOTYPES__)
* define __USE_FIXED_PROTOTYPES__
* endif
*/
/* Include 14 of the 15 ISO-C headers (postponing setjmp.h) */
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#if !defined(CLOCKS_PER_SEC)
# define CLOCKS_PER_SEC 60
#endif
#define __FAVOR_BSD
#define _BSD_SIGNALS
/* Now finally include the 15th header, setjmp.h */
#include <setjmp.h>
#if defined(__cplusplus)
# define VCXX
# define extern "C"
#else
# define VCC
# define extern
#endif
/*
* ***************************************************************************
* Private and Public type modifier simulation
* ***************************************************************************
*/
#define VPRIVATE static
#define VPUBLIC /*empty*/
#define VWARN1(file, lineno) (fprintf(stderr,"VWARN: ASSERTION FAILURE! filename %s, line %u\n", (file), (lineno)), 0)
#define VASSERT1(file, lineno) (fprintf(stderr,"VASSERT: ASSERTION FAILURE! filename %s, line %u\n", (file), (lineno)), exit(1), 0)
#define VASSERT2(file, lineno) (fprintf(stderr,"VASSERT: ASSERTION FAILURE! filename %s, line %u\n", (file), (lineno)), abort(), 0)
#define VASSERT3(file, lineno, ex) (fprintf(stderr,"VASSERT: ASSERTION FAILURE! filename %s, line %u, (%s)\n", (file), (lineno), (#ex)), abort(), 0)
#define VWARN(ex) ((void) ((ex) ? 0 : VWARN1(__FILE__, __LINE__)))
#define VASSERT(ex) ((void) ((ex) ? 0 : VASSERT3(__FILE__, __LINE__, ex)))
#define VJMPERR0(x) if (!(x)) goto VERROR0
#define VJMPERR1(x) if (!(x)) goto VERROR1
#define VJMPERR2(x) if (!(x)) goto VERROR2
#define VJMPERR3(x) if (!(x)) goto VERROR3
#define VJMPERR4(x) if (!(x)) goto VERROR4
#define VJMPERR5(x) if (!(x)) goto VERROR5
#define VJMPERR6(x) if (!(x)) goto VERROR6
#define VJMPERR7(x) if (!(x)) goto VERROR7
#define VJMPERR8(x) if (!(x)) goto VERROR8
#define VJMPERR9(x) if (!(x)) goto VERROR9
/*
* ***************************************************************************
* Global constants
* ***************************************************************************
*/
#define VPI 3.14159265358979323846
#define VLARGE 1.0e+9
#define VSMALL 1.0e-9
#define VVLARGE 1.0e+15
#define VVSMALL 1.0e-15
#define VPRTKEY 10000
#define VPTRSIZE 4
#define VMAX_ARGNUM 50
#define VMAX_ARGLEN 1024
#define VMAX_BUFSIZE 8192
/*
* #define VMAX_OBJECTS 16777216 //(1<<24) = 2^24
* #define VBLOCK_POWER 12
*/
#define VMAX_OBJECTS 1073741824 /* (1<<31) = 2^31 */
#define VBLOCK_POWER 14
#define VNULL NULL
#define VINULL -1
#define VTRUE 1
#define VFALSE 0
#define VSTDMODE 0600
#define VNULL_STRING "\0"
#define VBLANK_STRING " "
#define VNEWLINE_STRING "\n"
#define VNULL_SYMBOL '\0'
#define VBLANK_SYMBOL ' '
#define VNEWLINE_SYMBOL '\n'
#define VRDIN_SYMBOL '<'
#define VRDOUT_SYMBOL '>'
#define VPIPE_SYMBOL '|'
#define VDELIM_SET " ><|&"
#define VABS(x) ((x) >= 0 ? (x) : -(x))
#define VMIN2(x,y) ((x) <= (y) ? (x) : (y))
#define VMAX2(x,y) ((x) >= (y) ? (x) : (y))
#define VSIGN(x,y) ((y) >= 0 ? (VABS(x)) : (-VABS(x)))
#define VODD(x) ((x)&1)
#define VEVEN(x) (!((x)&1))
#define VZERO(x) ((x)==0)
#define VPOS(x) ((x)>0)
#define VNEG(x) ((x)<0)
#define VEVENP(x) (VEVEN(x) && VPOS(x))
#define VEVENN(x) (VEVEN(x) && VNEG(x))
#define VSQRT(x) (sqrt(x))
#define VSQR(x) ((x)*(x))
#define VSIN(x) (sin(x))
#define VCOS(x) (cos(x))
#define VTAN(x) (tan(x))
#define VASIN(x) (asin(x))
#define VACOS(x) (acos(x))
#define VATAN(x) (atan(x))
#define VSINH(x) (sinh(x))
#define VCOSH(x) (cosh(x))
#define VTANH(x) (tanh(x))
#define VEXP(x) (exp(x))
#define VLOG(x) (log(x))
#define VPOW(x,y) (pow(x,y))
#define VRINT(x) ((int)(floor((x)+0.5)))
#define VRAND (rand())
#define VRANDMAX (RAND_MAX)
#if 1
# define VINLINE_MALOC
#endif
#endif /* _MALOC_BASE_H_ */