MALOC 0.1
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.

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)
 Slick assertion macro.
#define VASSERT1(file, lineno)
 Slick assertion macro.
#define VASSERT2(file, lineno)
 Slick assertion macro.
#define VASSERT3(file, lineno, ex)
 Slick assertion macro.
#define VWARN(ex)
 Slick assertion macro.
#define VASSERT(ex)
 Slick assertion macro.
#define VJMPERR0(x)
 A userful error handling macro.
#define VJMPERR1(x)
 A userful error handling macro.
#define VJMPERR2(x)
 A userful error handling macro.
#define VJMPERR3(x)
 A userful error handling macro.
#define VJMPERR4(x)
 A userful error handling macro.
#define VJMPERR5(x)
 A userful error handling macro.
#define VJMPERR6(x)
 A userful error handling macro.
#define VJMPERR7(x)
 A userful error handling macro.
#define VJMPERR8(x)
 A userful error handling macro.
#define VJMPERR9(x)
 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)
 Mathematical macro.
#define VMIN2(x, y)
 Mathematical macro.
#define VMAX2(x, y)
 Mathematical macro.
#define VSIGN(x, y)
 Mathematical macro.
#define VODD(x)
 Mathematical macro.
#define VEVEN(x)
 Mathematical macro.
#define VZERO(x)
 Mathematical macro.
#define VPOS(x)
 Mathematical macro.
#define VNEG(x)
 Mathematical macro.
#define VEVENP(x)
 Mathematical macro.
#define VEVENN(x)
 Mathematical macro.
#define VSQRT(x)
 Mathematical macro.
#define VSQR(x)
 Mathematical macro.
#define VSIN(x)
 Mathematical macro.
#define VCOS(x)
 Mathematical macro.
#define VTAN(x)
 Mathematical macro.
#define VASIN(x)
 Mathematical macro.
#define VACOS(x)
 Mathematical macro.
#define VATAN(x)
 Mathematical macro.
#define VSINH(x)
 Mathematical macro.
#define VCOSH(x)
 Mathematical macro.
#define VTANH(x)
 Mathematical macro.
#define VEXP(x)
 Mathematical macro.
#define VLOG(x)
 Mathematical macro.
#define VPOW(x, y)
 Mathematical macro.
#define VRINT(x)
 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)
Value:
((x) >= 0 ? (x) : -(x))

Mathematical macro.

◆ VACOS

#define VACOS ( x)
Value:
(acos(x))

Mathematical macro.

◆ VASIN

#define VASIN ( x)
Value:
(asin(x))

Mathematical macro.

◆ VASSERT

#define VASSERT ( ex)
Value:
((void) ((ex) ? 0 : VASSERT3(__FILE__, __LINE__, ex)))
#define VASSERT3(file, lineno, ex)
Slick assertion macro.
Definition maloc_base.h:174

Slick assertion macro.

◆ VASSERT1

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

Slick assertion macro.

◆ VASSERT2

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

Slick assertion macro.

◆ VASSERT3

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

Slick assertion macro.

◆ VATAN

#define VATAN ( x)
Value:
(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)
Value:
(cos(x))

Mathematical macro.

◆ VCOSH

#define VCOSH ( x)
Value:
(cosh(x))

Mathematical macro.

◆ VDELIM_SET

#define VDELIM_SET   " ><|&"

Global constant.

◆ VEVEN

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

Mathematical macro.

◆ VEVENN

#define VEVENN ( x)
Value:
(VEVEN(x) && VNEG(x))
#define VEVEN(x)
Mathematical macro.
Definition maloc_base.h:287
#define VNEG(x)
Mathematical macro.
Definition maloc_base.h:293

Mathematical macro.

◆ VEVENP

#define VEVENP ( x)
Value:
(VEVEN(x) && VPOS(x))
#define VPOS(x)
Mathematical macro.
Definition maloc_base.h:291

Mathematical macro.

◆ VEXP

#define VEXP ( x)
Value:
(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)
Value:
if (!(x)) goto VERROR0

A userful error handling macro.

◆ VJMPERR1

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

A userful error handling macro.

◆ VJMPERR2

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

A userful error handling macro.

◆ VJMPERR3

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

A userful error handling macro.

◆ VJMPERR4

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

A userful error handling macro.

◆ VJMPERR5

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

A userful error handling macro.

◆ VJMPERR6

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

A userful error handling macro.

◆ VJMPERR7

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

A userful error handling macro.

◆ VJMPERR8

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

A userful error handling macro.

◆ VJMPERR9

#define VJMPERR9 ( x)
Value:
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)
Value:
(log(x))

Mathematical macro.

◆ VMAX2

#define VMAX2 ( x,
y )
Value:
((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 )
Value:
((x) <= (y) ? (x) : (y))

Mathematical macro.

◆ VNEG

#define VNEG ( x)
Value:
((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)
Value:
((x)&1)

Mathematical macro.

◆ VPI

#define VPI   3.14159265358979323846

Global constant.

◆ VPIPE_SYMBOL

#define VPIPE_SYMBOL   '|'

Global constant.

◆ VPOS

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

Mathematical macro.

◆ VPOW

#define VPOW ( x,
y )
Value:
(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)
Value:
((int)(floor((x)+0.5)))

Mathematical macro.

◆ VSIGN

#define VSIGN ( x,
y )
Value:
((y) >= 0 ? (VABS(x)) : (-VABS(x)))
#define VABS(x)
Mathematical macro.
Definition maloc_base.h:276

Mathematical macro.

◆ VSIN

#define VSIN ( x)
Value:
(sin(x))

Mathematical macro.

◆ VSINH

#define VSINH ( x)
Value:
(sinh(x))

Mathematical macro.

◆ VSMALL

#define VSMALL   1.0e-9

Global constant.

◆ VSQR

#define VSQR ( x)
Value:
((x)*(x))

Mathematical macro.

◆ VSQRT

#define VSQRT ( x)
Value:
(sqrt(x))

Mathematical macro.

◆ VSTDMODE

#define VSTDMODE   0600

Global constant.

◆ VTAN

#define VTAN ( x)
Value:
(tan(x))

Mathematical macro.

◆ VTANH

#define VTANH ( x)
Value:
(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)
Value:
((void) ((ex) ? 0 : VWARN1(__FILE__, __LINE__)))
#define VWARN1(file, lineno)
Slick assertion macro.
Definition maloc_base.h:168

Slick assertion macro.

◆ VWARN1

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

Slick assertion macro.

◆ VZERO

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

Mathematical macro.