1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-22 04:21:24 -08:00

Review.impl.h.mpmtypes.4

Copied from Perforce
 Change: 16223
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Richard Brooksby 1996-10-31 16:09:30 +00:00
parent 10b354f871
commit e5eee25c09
3 changed files with 41 additions and 59 deletions

View file

@ -1,6 +1,6 @@
/* impl.h.misc: MISCELLANEOUS DEFINITIONS
*
* $HopeName: MMsrc!misc.h(trunk.5) $
* $HopeName: MMsrc!misc.h(trunk.6) $
* Copyright (C) 1994,1995,1996 Harlequin Group, all rights reserved
*
* Small general things which are useful for C but aren't part of the
@ -52,22 +52,6 @@ typedef const struct SrcIdStruct {
#define END } while(0)
/* Bool -- boolean type
*
* Using a boolean type in C is a tricky thing. Non-zero values are
* "true" but are not all equal to TRUE. The Bool type is therefore
* mostly defined so that the intention of the code is clearer.
* Use with care.
*/
typedef int Bool; /* boolean type */
enum
{
FALSE = 0,
TRUE = 1
};
#define BoolCheck(b) ((b) == TRUE || (b) == FALSE)
/* NOOP -- null statement
*
* Do not be tempted to use NULL, or just semicolon as the null
@ -104,41 +88,4 @@ enum
((type *)((char *)(p) - offsetof(type, field)))
/* Object Signatures
*
* .sig: Signatures are magic numbers which are written into structures
* when they are created and invalidated (by overwriting with
* SigInvalid) when they are destroyed. They provide a limited form
* of run-time type checking and dynamic scope checking.
*
* .sig.form: The first three hex digits of signatures should be 519
* (which resembles "SIG"), and should be chosen to be mnemonic when
* viewed in hex, so that structures can be recognized visually when
* debugging and dumping memory.
*/
typedef unsigned long Sig;
#define SigInvalid ((Sig)0x51915BAD)
/* Res -- Result Code
*
* .res: See also impl.h.mps.res, impl.c.mpsi.check.res.
*/
typedef int Res; /* result code type */
enum {
ResOK = 0, /* success */
ResFAIL, /* unspecified failure */
ResRESOURCE, /* unable to obtain resources */
ResMEMORY, /* unable to obtain memory */
ResLIMIT, /* internal limitation reached */
ResUNIMPL, /* unimplemented facility */
ResIO /* system I/O error */
};
/* Functions - no type */
#define FunctionCheck(fun) ((fun) != NULL) /* Could do more ? */
#endif /* misc_h */

View file

@ -1,6 +1,6 @@
/* impl.c.mpm: GENERAL MPM SUPPORT
*
* $HopeName: MMsrc!mpm.c(trunk.5) $
* $HopeName: MMsrc!mpm.c(trunk.6) $
* Copyright (C) 1996 Harlequin Group, all rights reserved.
*
* .readership: MM developers.
@ -13,7 +13,7 @@
#include "mpm.h"
SRCID(mpm, "$HopeName: MMsrc!mpm.c(trunk.5) $");
SRCID(mpm, "$HopeName: MMsrc!mpm.c(trunk.6) $");
/* MPMCheck -- test MPM assumptions */
@ -51,6 +51,35 @@ Bool MPMCheck(void)
}
/* BoolCheck -- check that a boolean is valid */
Bool BoolCheck(Bool b)
{
AVER(b == TRUE || b == FALSE);
return TRUE;
}
/* FunCheck -- check that a function pointer is valid */
Bool FunCheck(Fun f)
{
AVER(f != NULL);
/* Could assert various platform-specific things here. */
return TRUE;
}
/* AttrCheck -- check that a set of pool attributes are valid */
Bool AttrCheck(Attr attr)
{
AVER(((attr) & ~AttrMASK) == 0);
/* Could check for legal combinations of attributes. */
return TRUE;
}
/* AlignCheck -- check that an alignment is valid */
Bool AlignCheck(Align align)

View file

@ -1,6 +1,6 @@
/* impl.h.mpm: MEMORY POOL MANAGER DEFINITIONS
*
* $HopeName: MMsrc!mpm.h(trunk.10) $
* $HopeName: MMsrc!mpm.h(trunk.11) $
* Copyright (C) 1996 Harlequin Group, all rights reserved.
*/
@ -39,6 +39,14 @@
extern Bool MPMCheck(void);
/* Miscellaneous Checks -- see impl.c.mpm */
extern Bool BoolCheck(Bool b);
extern Bool FunCheck(Fun f);
extern Bool AttrCheck(Attr attr);
#define FUNCHECK(f) (FunCheck((Fun)f))
/* Address/Size Interface -- see impl.c.mpm */
extern Bool (WordIsAligned)(Word word, Align align);
@ -431,6 +439,4 @@ extern void VMUnmap(Space space, Addr base, Addr limit);
extern Size VMReserved(Space space);
extern Size VMMapped(Space space);
#define AttrCheck(attr) (((attr) & ~AttrMask) == 0)
#endif /* mpm_h */