MathEngine
Home Page       Structures       File List       Functions and Macros      

MeMemory.h File Reference

The memory manager API. More...

#include <stddef.h>

Go to the source code of this file.

Compounds

struct  MeMemoryAPI
struct  MeMemoryOptions
struct  MeMemoryStats

Defines

#define MeMemoryALLOCA(n)    ((*MeMemoryAPI.create)(n))
 Stack allocation. More...

#define MeMemoryFREEA(b)    ((*MeMemoryAPI.destroy)(b))
 Stack deallocation. More...

#define MeMemoryAVAILABLE   1
 This flag allows testing whether the API is being used.


Enumerations

enum  MeMemoryAllocation {
  MeMemoryAny = 0,
  MeMemorySegment,
  MeMemoryBIBOP,
  MeMemoryBTag,
  MeMemoryBitmap,
  MeMemoryBuddy,
  MeMemoryArrays,
  MeMemoryPools
}
 Type of memory allocation implementation. More...

enum  MeMemoryReclamation {
  MeMemoryManual = 0,
  MeMemoryNone,
  MeMemoryStack,
  MeMemoryRefCount,
  MeMemoryGC,
  MeMemoryGCCompacting,
  MeMemoryGCCopying,
  MeMemoryGCAged
}
 Type of memory reclamation policy. More...


Functions

void MeMemoryPrintOptions (const struct MeMemoryOptions *const options)
 Print an MeMemory option record. More...

void MeMemoryPrintStats (const struct MeMemoryStats *const stats)
 Print an MeMemory statistics record. More...

void MeMemorySetDefaults (struct MeMemoryOptions *const opts)
 Set the options passed to some sort of default, vanilla, values.


Variables

struct MeMemoryAPI MeMemoryAPI
 The table of memory manager entry points. More...

unsigned MeMemoryDoTrace = 0
 If nonzero, trace API calls if tracing is enabled.

unsigned MeMemoryDoStats = 1
 If nonzero, keep statistics if statistics have been enabled.


Detailed Description

The memory manager API.

This API allows a library to use an external memory manager, via a a set of function pointers with predefined semantics.

It also allows a library to give hints as to what kind of memory management it prefers; the memory manager may or may not heed such advice.

It is expected that the debug version of the memory managers will perform extensive checks, like verifying redzones around each block.


Define Documentation

#define MeMemoryALLOCA( n )   ((*MeMemoryAPI.create)(n))

Stack allocation.

If the compiler supports stack allocation (GNU C or MS C) then the relevant compiler intrinsics are used. Otherwise it uses heap allocation, which is why a FREEA function is needed too, and you must use it.

#define MeMemoryFREEA( b )   ((*MeMemoryAPI.destroy)(b))

Stack deallocation.

If the compiler supports stack allocation (GNU C or MS C) then this does nothing. Otherwise heap allocation has been used and this just destroys the heap allocated block.

#define MeMemoryQUADALIGN( a )

Initializer:

\
    ((void *) ((((long unsigned) (void *) (a)) + 15) &~ 15))

#define MeMemoryQUADALIGNEDALLOCA( name, type, n )

Initializer:

\
        void *name##Addr = \
            MeMemoryALLOCA(((n) * sizeof (type)) + 16); \
        type *name = (type *) MeMemoryQUADALIGN(name##Addr);

#define MeMemoryQUADALIGNEDFREEA( name )

Initializer:

\
        MeMemoryFREEA(name##Addr)

Enumeration Type Documentation

enum MeMemoryAllocation

Type of memory allocation implementation.

Enumeration values:
MeMemoryAny   Choose any.

(default, must be 0)

MeMemorySegment   Growing area, like UNIX data segment.
MeMemoryBIBOP   Big bag of pages.
MeMemoryBTag   Boundary tag.
MeMemoryBitmap   Flat bitmap.
MeMemoryBuddy   Buddy system.
MeMemoryArrays   Contiguous fixed size arrays.
MeMemoryPools   Contiguous flexible size arrays.

enum MeMemoryReclamation

Type of memory reclamation policy.

Enumeration values:
MeMemoryManual   Manual/explicit.

(default, must be 0)

MeMemoryNone   No memory reclamation.
MeMemoryStack   Like Pascal Mark/Release.
MeMemoryRefCount   Reference counting.
MeMemoryGC   Vanilla conservative GC.
MeMemoryGCCompacting   Compacting GC.
MeMemoryGCCopying   Baker style copying GC.
MeMemoryGCAged   Hewitt style generational GC.

Function Documentation

void MeMemoryPrintOptions ( const struct MeMemoryOptions * const options )

Print an MeMemory option record.

This function prints, using the MeInfo entry point of the MeMessage library, the contents of a MeMemoryOptions record.

Parameters:
options   A pointer to a MeMemory options record.
See also:
MeMemoryAPI::getOptions

void MeMemoryPrintStats ( const struct MeMemoryStats * const stats )

Print an MeMemory statistics record.

This function prints, using the MeInfo entry point of the MeMessage library, the contents of a MeMemoryStats record.

Parameters:
options   A pointer to a MeMemory statistics record.
See also:
MeMemoryAPI::getStats

Variable Documentation

struct MeMemoryAPI MeMemoryAPI

The table of memory manager entry points.

This table is usually initialised using one of the memory manager specific function tables, for example MeMemoryAPIArrays or MeMemoryAPIMalloc.


MathEngine Utilities: Memory Manager API - Version 0.0.5 Alpha - Reference Manual generated using doxygen at Wed Oct 11 00:34:57 2000

Copyright MathEngine PLC 2000, all rights reserved.