maloc_base.h File Reference
global_maloc class

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.

## Macros

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

## 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.33 2010/08/12 05:40:16 fetk Exp

Attention

      *
      * MALOC = < Minimal Abstraction Layer for Object-oriented C >
      * Copyright (C) 1994-- 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
      *
      *

## Macro Definition Documentation

## __FAVOR_BSD

#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.
      *

## _BSD_SIGNALS

#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.
      *

## CLOCKS_PER_SEC

#define CLOCKS_PER_SEC 60

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

## extern

#define extern

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

## VABS

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

Mathematical macro.

## VACOS

#define VACOS | ( |  | x | ) | (acos(x))

Mathematical macro.

## VASIN

#define VASIN | ( |  | x | ) | (asin(x))

Mathematical macro.

## VASSERT

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

Slick assertion macro.

## VASSERT1

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

Slick assertion macro.

## VASSERT2

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

Slick assertion macro.

## VASSERT3

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

Slick assertion macro.

## VATAN

#define VATAN | ( |  | x | ) | (atan(x))

Mathematical macro.

## VBLANK_STRING

#define VBLANK_STRING " "

Global constant.

## VBLANK_SYMBOL

#define VBLANK_SYMBOL ' '

Global constant.

## VBLOCK_POWER

#define VBLOCK_POWER 14

Global constant.

## VCC

#define VCC

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

## VCOS

#define VCOS | ( |  | x | ) | (cos(x))

Mathematical macro.

## VCOSH

#define VCOSH | ( |  | x | ) | (cosh(x))

Mathematical macro.

## VDELIM_SET

#define VDELIM_SET " ><|&"

Global constant.

## VEVEN

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

Mathematical macro.

## VEVENN

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

Mathematical macro.

## VEVENP

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

Mathematical macro.

## VEXP

#define VEXP | ( |  | x | ) | (exp(x))

Mathematical macro.

## VFALSE

#define VFALSE 0

Global constant.

## VINLINE_MALOC

#define VINLINE_MALOC

Inlining via macros for speed.

## VINULL

#define VINULL -1

Global constant.

## VJMPERR0

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

A userful error handling macro.

## VJMPERR1

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

A userful error handling macro.

## VJMPERR2

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

A userful error handling macro.

## VJMPERR3

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

A userful error handling macro.

## VJMPERR4

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

A userful error handling macro.

## VJMPERR5

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

A userful error handling macro.

## VJMPERR6

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

A userful error handling macro.

## VJMPERR7

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

A userful error handling macro.

## VJMPERR8

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

A userful error handling macro.

## VJMPERR9

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

A userful error handling macro.

## VLARGE

#define VLARGE 1.0e+9

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

## VLOG

#define VLOG | ( |  | x | ) | (log(x))

Mathematical macro.

## VMAX2

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

Mathematical macro.

## VMAX_ARGLEN

#define VMAX_ARGLEN 1024

Global constant.

## VMAX_ARGNUM

#define VMAX_ARGNUM 50

Global constant.

## VMAX_BUFSIZE

#define VMAX_BUFSIZE 8192

Global constant.

## VMAX_OBJECTS

#define VMAX_OBJECTS 1073741824 /* (1<<31) = 2^31 */

Global constant.

## VMIN2

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

Mathematical macro.

## VNEG

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

Mathematical macro.

## VNEWLINE_STRING

#define VNEWLINE_STRING "\n"

Global constant.

## VNEWLINE_SYMBOL

#define VNEWLINE_SYMBOL '\n'

Global constant.

## VNULL

#define VNULL NULL

Global constant.

## VNULL_STRING

#define VNULL_STRING "\0"

Global constant.

## VNULL_SYMBOL

#define VNULL_SYMBOL '\0'

Global constant.

## VODD

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

Mathematical macro.

## VPI

#define VPI 3.14159265358979323846

Global constant.

## VPIPE_SYMBOL

#define VPIPE_SYMBOL '|'

Global constant.

## VPOS

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

Mathematical macro.

## VPOW

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

Mathematical macro.

## VPRIVATE

#define VPRIVATE static

Mimic C++ "Private" type modifier.

## VPRTKEY

#define VPRTKEY 10000

Global constant.

## VPTRSIZE

#define VPTRSIZE 4

Global constant.

## VPUBLIC

#define VPUBLIC /*empty*/

Mimic C++ "Public" type modifier

## VRAND

#define VRAND (rand())

Mathematical macro.

## VRANDMAX

#define VRANDMAX (RAND_MAX)

Mathematical macro.

## VRDIN_SYMBOL

#define VRDIN_SYMBOL '<'

Global constant.

## VRDOUT_SYMBOL

#define VRDOUT_SYMBOL '>'

Global constant.

## VRINT

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

Mathematical macro.

## VSIGN

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

Mathematical macro.

## VSIN

#define VSIN | ( |  | x | ) | (sin(x))

Mathematical macro.

## VSINH

#define VSINH | ( |  | x | ) | (sinh(x))

Mathematical macro.

## VSMALL

#define VSMALL 1.0e-9

Global constant.

## VSQR

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

Mathematical macro.

## VSQRT

#define VSQRT | ( |  | x | ) | (sqrt(x))

Mathematical macro.

## VSTDMODE

#define VSTDMODE 0600

Global constant.

## VTAN

#define VTAN | ( |  | x | ) | (tan(x))

Mathematical macro.

## VTANH

#define VTANH | ( |  | x | ) | (tanh(x))

Mathematical macro.

## VTRUE

#define VTRUE 1

Global constant.

## VVLARGE

#define VVLARGE 1.0e+15

Global constant.

## VVSMALL

#define VVSMALL 1.0e-15

Global constant.

## VWARN

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

Slick assertion macro.

## VWARN1

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

Slick assertion macro.

## VZERO

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

Mathematical macro.