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.
#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 /* (1<<31) = 2^31 */
| 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.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.