maloc_base.h File Reference

The base (or foundation) header for MALOC. More...

#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>
#include <setjmp.h>

Include dependency graph for maloc_base.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define CLOCKS_PER_SEC   60
 Fix to broken <time.h> on old SunOS.
#define __FAVOR_BSD
 Linux: uses sigsetjmp as the setjmp function.
#define _BSD_SIGNALS
 IRIX: uses sigsetjmp as the setjmp function.
#define VCC
 Setup so this include file (and subsequent) will work for both C and C++.
#define extern
 Setup so this include file (and subsequent) will work for both C and C++.
#define VPRIVATE   static
 Mimic C++ "Private" type modifier.
#define VPUBLIC   /*empty*/
 Mimic C++ "Public" type modifier.
#define VWARN1(file, lineno)   (fprintf(stderr,"VWARN: ASSERTION FAILURE! filename %s, line %u\n", (file), (lineno)), 0)
 Slick assertion macro.
#define VASSERT1(file, lineno)   (fprintf(stderr,"VASSERT: ASSERTION FAILURE! filename %s, line %u\n", (file), (lineno)), exit(1), 0)
 Slick assertion macro.
#define VASSERT2(file, lineno)   (fprintf(stderr,"VASSERT: ASSERTION FAILURE! filename %s, line %u\n", (file), (lineno)), abort(), 0)
 Slick assertion macro.
#define VASSERT3(file, lineno, ex)   (fprintf(stderr,"VASSERT: ASSERTION FAILURE! filename %s, line %u, (%s)\n", (file), (lineno), (#ex)), abort(), 0)
 Slick assertion macro.
#define VWARN(ex)   ((void) ((ex) ? 0 : VWARN1(__FILE__, __LINE__)))
 Slick assertion macro.
#define VASSERT(ex)   ((void) ((ex) ? 0 : VASSERT3(__FILE__, __LINE__, ex)))
 Slick assertion macro.
#define VJMPERR0(x)   if (!(x)) goto VERROR0
 A userful error handling macro.
#define VJMPERR1(x)   if (!(x)) goto VERROR1
 A userful error handling macro.
#define VJMPERR2(x)   if (!(x)) goto VERROR2
 A userful error handling macro.
#define VJMPERR3(x)   if (!(x)) goto VERROR3
 A userful error handling macro.
#define VJMPERR4(x)   if (!(x)) goto VERROR4
 A userful error handling macro.
#define VJMPERR5(x)   if (!(x)) goto VERROR5
 A userful error handling macro.
#define VJMPERR6(x)   if (!(x)) goto VERROR6
 A userful error handling macro.
#define VJMPERR7(x)   if (!(x)) goto VERROR7
 A userful error handling macro.
#define VJMPERR8(x)   if (!(x)) goto VERROR8
 A userful error handling macro.
#define VJMPERR9(x)   if (!(x)) goto VERROR9
 A userful error handling macro.
#define VPI   3.14159265358979323846
 Global constant.
#define VLARGE   1.0e+9
 Global constant. 1e9 just fits into 32-bit signed int.
#define VSMALL   1.0e-9
 Global constant.
#define VVLARGE   1.0e+15
 Global constant.
#define VVSMALL   1.0e-15
 Global constant.
#define VPRTKEY   10000
 Global constant.
#define VPTRSIZE   4
 Global constant.
#define VMAX_ARGNUM   50
 Global constant.
#define VMAX_ARGLEN   1024
 Global constant.
#define VMAX_BUFSIZE   8192
 Global constant.
#define VMAX_OBJECTS   1073741824
 Global constant.
#define VBLOCK_POWER   14
 Global constant.
#define VNULL   NULL
 Global constant.
#define VINULL   -1
 Global constant.
#define VTRUE   1
 Global constant.
#define VFALSE   0
 Global constant.
#define VSTDMODE   0600
 Global constant.
#define VNULL_STRING   "\0"
 Global constant.
#define VBLANK_STRING   " "
 Global constant.
#define VNEWLINE_STRING   "\n"
 Global constant.
#define VNULL_SYMBOL   '\0'
 Global constant.
#define VBLANK_SYMBOL   ' '
 Global constant.
#define VNEWLINE_SYMBOL   '\n'
 Global constant.
#define VRDIN_SYMBOL   '<'
 Global constant.
#define VRDOUT_SYMBOL   '>'
 Global constant.
#define VPIPE_SYMBOL   '|'
 Global constant.
#define VDELIM_SET   " ><|&"
 Global constant.
#define VABS(x)   ((x) >= 0 ? (x) : -(x))
 Mathematical macro.
#define VMIN2(x, y)   ((x) <= (y) ? (x) : (y))
 Mathematical macro.
#define VMAX2(x, y)   ((x) >= (y) ? (x) : (y))
 Mathematical macro.
#define VSIGN(x, y)   ((y) >= 0 ? (VABS(x)) : (-VABS(x)))
 Mathematical macro.
#define VODD(x)   ((x)&1)
 Mathematical macro.
#define VEVEN(x)   (!((x)&1))
 Mathematical macro.
#define VZERO(x)   ((x)==0)
 Mathematical macro.
#define VPOS(x)   ((x)>0)
 Mathematical macro.
#define VNEG(x)   ((x)<0)
 Mathematical macro.
#define VEVENP(x)   (VEVEN(x) && VPOS(x))
 Mathematical macro.
#define VEVENN(x)   (VEVEN(x) && VNEG(x))
 Mathematical macro.
#define VSQRT(x)   (sqrt(x))
 Mathematical macro.
#define VSQR(x)   ((x)*(x))
 Mathematical macro.
#define VSIN(x)   (sin(x))
 Mathematical macro.
#define VCOS(x)   (cos(x))
 Mathematical macro.
#define VTAN(x)   (tan(x))
 Mathematical macro.
#define VASIN(x)   (asin(x))
 Mathematical macro.
#define VACOS(x)   (acos(x))
 Mathematical macro.
#define VATAN(x)   (atan(x))
 Mathematical macro.
#define VSINH(x)   (sinh(x))
 Mathematical macro.
#define VCOSH(x)   (cosh(x))
 Mathematical macro.
#define VTANH(x)   (tanh(x))
 Mathematical macro.
#define VEXP(x)   (exp(x))
 Mathematical macro.
#define VLOG(x)   (log(x))
 Mathematical macro.
#define VPOW(x, y)   (pow(x,y))
 Mathematical macro.
#define VRINT(x)   ((int)(floor((x)+0.5)))
 Mathematical macro.
#define VRAND   (rand())
 Mathematical macro.
#define VRANDMAX   (RAND_MAX)
 Mathematical macro.
#define VINLINE_MALOC
 Inlining via macros for speed.


Detailed Description

The base (or foundation) header for MALOC.

Author:
Michael Holst
Note:
This header sets things up correctly for using ISO/ANSI-C. The following macros affect the behavior of the header:
     Inlining for speed:  (Normal C functions if VINLINE_XXX not defined.)    
     ------------------
     -DVINLINE_VNM : Enables macro replacement of time-critical funcs in VNM.
    
Version:
Id
maloc_base.h,v 1.32 2008/05/09 18:24:00 fetk Exp

Attention:
 *
 * MALOC = < Minimal Abstraction Layer for Object-oriented C >
 * Copyright (C) 1994--2008 Michael Holst
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 * 
 *  

Define Documentation

#define __FAVOR_BSD

Linux: uses sigsetjmp as the setjmp function.

Note:
 * Problems using setjmp/longjmp for use in the MC-shell.
 *
 * Problem:  Some implementations of ISO-C "setjmp/longjmp"  do not return
 *           the interrupt mask to its pre-jump state after returning.
 *           The behavior this produces is for example you can capture a
 *           single CTRL-C, but that is it; the mask for CTRL-C is wiped
 *           after the first interrupt is handled.
 *
 * Solution: Use the "sigsetjmp/siglongjmp" extensions provided by most
 *           UNIX variants.  You just have to set an appropriate macro
 *           before including <setjmp.h> to get sigsetjmp rather than
 *           setjmp behavior.
 *
 * Notes:    You can run into trouble (e.g. some versions of Linux) if
 *           you set some of these special signal macros before some of
 *           the other ISO-C headers.  Therefore, we only set the macros
 *           just before including <setjmp.h> as the final ISO-C header.
 * 

#define _BSD_SIGNALS

IRIX: uses sigsetjmp as the setjmp function.

Note:
 * Problems using setjmp/longjmp for use in the MC-shell.
 *
 * Problem:  Some implementations of ISO-C "setjmp/longjmp"  do not return
 *           the interrupt mask to its pre-jump state after returning.
 *           The behavior this produces is for example you can capture a
 *           single CTRL-C, but that is it; the mask for CTRL-C is wiped
 *           after the first interrupt is handled.
 *
 * Solution: Use the "sigsetjmp/siglongjmp" extensions provided by most
 *           UNIX variants.  You just have to set an appropriate macro
 *           before including <setjmp.h> to get sigsetjmp rather than
 *           setjmp behavior.
 *
 * Notes:    You can run into trouble (e.g. some versions of Linux) if
 *           you set some of these special signal macros before some of
 *           the other ISO-C headers.  Therefore, we only set the macros
 *           just before including <setjmp.h> as the final ISO-C header.
 * 

#define CLOCKS_PER_SEC   60

Fix to broken <time.h> on old SunOS.

#define extern

Setup so this include file (and subsequent) will work for both C and C++.

#define VABS (  )     ((x) >= 0 ? (x) : -(x))

Mathematical macro.

#define VACOS (  )     (acos(x))

Mathematical macro.

#define VASIN (  )     (asin(x))

Mathematical macro.

#define VASSERT ( ex   )     ((void) ((ex) ? 0 : VASSERT3(__FILE__, __LINE__, ex)))

Slick assertion macro.

#define VASSERT1 ( file,
lineno   )     (fprintf(stderr,"VASSERT: ASSERTION FAILURE! filename %s, line %u\n", (file), (lineno)), exit(1), 0)

Slick assertion macro.

#define VASSERT2 ( file,
lineno   )     (fprintf(stderr,"VASSERT: ASSERTION FAILURE! filename %s, line %u\n", (file), (lineno)), abort(), 0)

Slick assertion macro.

#define VASSERT3 ( file,
lineno,
ex   )     (fprintf(stderr,"VASSERT: ASSERTION FAILURE! filename %s, line %u, (%s)\n", (file), (lineno), (#ex)), abort(), 0)

Slick assertion macro.

#define VATAN (  )     (atan(x))

Mathematical macro.

#define VBLANK_STRING   " "

Global constant.

#define VBLANK_SYMBOL   ' '

Global constant.

#define VBLOCK_POWER   14

Global constant.

#define VCC

Setup so this include file (and subsequent) will work for both C and C++.

#define VCOS (  )     (cos(x))

Mathematical macro.

#define VCOSH (  )     (cosh(x))

Mathematical macro.

#define VDELIM_SET   " ><|&"

Global constant.

#define VEVEN (  )     (!((x)&1))

Mathematical macro.

#define VEVENN (  )     (VEVEN(x) && VNEG(x))

Mathematical macro.

#define VEVENP (  )     (VEVEN(x) && VPOS(x))

Mathematical macro.

#define VEXP (  )     (exp(x))

Mathematical macro.

#define VFALSE   0

Global constant.

#define VINLINE_MALOC

Inlining via macros for speed.

#define VINULL   -1

Global constant.

#define VJMPERR0 (  )     if (!(x)) goto VERROR0

A userful error handling macro.

#define VJMPERR1 (  )     if (!(x)) goto VERROR1

A userful error handling macro.

#define VJMPERR2 (  )     if (!(x)) goto VERROR2

A userful error handling macro.

#define VJMPERR3 (  )     if (!(x)) goto VERROR3

A userful error handling macro.

#define VJMPERR4 (  )     if (!(x)) goto VERROR4

A userful error handling macro.

#define VJMPERR5 (  )     if (!(x)) goto VERROR5

A userful error handling macro.

#define VJMPERR6 (  )     if (!(x)) goto VERROR6

A userful error handling macro.

#define VJMPERR7 (  )     if (!(x)) goto VERROR7

A userful error handling macro.

#define VJMPERR8 (  )     if (!(x)) goto VERROR8

A userful error handling macro.

#define VJMPERR9 (  )     if (!(x)) goto VERROR9

A userful error handling macro.

#define VLARGE   1.0e+9

Global constant. 1e9 just fits into 32-bit signed int.

#define VLOG (  )     (log(x))

Mathematical macro.

#define VMAX2 ( x,
 )     ((x) >= (y) ? (x) : (y))

Mathematical macro.

#define VMAX_ARGLEN   1024

Global constant.

#define VMAX_ARGNUM   50

Global constant.

#define VMAX_BUFSIZE   8192

Global constant.

#define VMAX_OBJECTS   1073741824

Global constant.

#define VMIN2 ( x,
 )     ((x) <= (y) ? (x) : (y))

Mathematical macro.

#define VNEG (  )     ((x)<0)

Mathematical macro.

#define VNEWLINE_STRING   "\n"

Global constant.

#define VNEWLINE_SYMBOL   '\n'

Global constant.

#define VNULL   NULL

Global constant.

#define VNULL_STRING   "\0"

Global constant.

#define VNULL_SYMBOL   '\0'

Global constant.

#define VODD (  )     ((x)&1)

Mathematical macro.

#define VPI   3.14159265358979323846

Global constant.

#define VPIPE_SYMBOL   '|'

Global constant.

#define VPOS (  )     ((x)>0)

Mathematical macro.

#define VPOW ( x,
 )     (pow(x,y))

Mathematical macro.

#define VPRIVATE   static

Mimic C++ "Private" type modifier.

#define VPRTKEY   10000

Global constant.

#define VPTRSIZE   4

Global constant.

#define VPUBLIC   /*empty*/

Mimic C++ "Public" type modifier.

#define VRAND   (rand())

Mathematical macro.

#define VRANDMAX   (RAND_MAX)

Mathematical macro.

#define VRDIN_SYMBOL   '<'

Global constant.

#define VRDOUT_SYMBOL   '>'

Global constant.

#define VRINT (  )     ((int)(floor((x)+0.5)))

Mathematical macro.

#define VSIGN ( x,
 )     ((y) >= 0 ? (VABS(x)) : (-VABS(x)))

Mathematical macro.

#define VSIN (  )     (sin(x))

Mathematical macro.

#define VSINH (  )     (sinh(x))

Mathematical macro.

#define VSMALL   1.0e-9

Global constant.

#define VSQR (  )     ((x)*(x))

Mathematical macro.

#define VSQRT (  )     (sqrt(x))

Mathematical macro.

#define VSTDMODE   0600

Global constant.

#define VTAN (  )     (tan(x))

Mathematical macro.

#define VTANH (  )     (tanh(x))

Mathematical macro.

#define VTRUE   1

Global constant.

#define VVLARGE   1.0e+15

Global constant.

#define VVSMALL   1.0e-15

Global constant.

#define VWARN ( ex   )     ((void) ((ex) ? 0 : VWARN1(__FILE__, __LINE__)))

Slick assertion macro.

#define VWARN1 ( file,
lineno   )     (fprintf(stderr,"VWARN: ASSERTION FAILURE! filename %s, line %u\n", (file), (lineno)), 0)

Slick assertion macro.

#define VZERO (  )     ((x)==0)

Mathematical macro.


Generated on Mon Aug 9 11:08:00 2010 for MALOC by  doxygen 1.5.6