My Project
Loading...
Searching...
No Matches
omtTest.h
Go to the documentation of this file.
1#include <time.h>
2#include <string.h>
3#include <limits.h>
4
5#include "omConfig.h"
6
7#ifdef HAVE_OMALLOC
8
9#define TRACK_LEVEL 1
10#define CHECK_LEVEL 1
11// keep every ith address: define to 0 if no keeping
12#define KEEP_LEVEL 20
13// #define KEEP_LEVEL 0
14
15// #define MAX_CELLS 500000
16// #define MAX_CELLS 100000
17#define MAX_CELLS 100000
18#define KEEP_ADDR 100
19// #define KEEP_ADDR 0
20#define END_CHECK_LEVEL 5
21
22#include "omStructs.h"
23
25{
26 void* addr;
28 unsigned long spec;
30};
31
32typedef struct omMemCell_s omMemCell_t;
33typedef omMemCell_t* omMemCell;
34
35extern omMemCell_t cells[];
36void TestAlloc(omMemCell cell, unsigned long spec);
37void TestRealloc(omMemCell cell, unsigned long spec);
38void TestFree(omMemCell cell);
39
40#if CHECK_LEVEL > 2
41#define myprintf(format, args...) \
42 printf(format, ## args)
43#define myfflush(what) fflush(what)
44#else
45#define myprintf(format, args...) do {} while (0)
46#define myfflush(what) do {} while (0)
47#endif
48
49#define IS_STICKY_BIN(spec) (spec & 1)
50// #define IS_STICKY_BIN(spec) (0)
51#define GET_SIZE(spec) OM_ALIGN_SIZE((spec & ((((unsigned long) 1) << 14) -1)))
52#define SET_SIZE(spec, size) spec = ((spec & ~((((unsigned long) 1) << 14) -1)) | (size))
53#define IS_ALIGNED(spec) (spec & (((unsigned long) 1) << 15))
54#define IS_ZERO(spec) (spec & (((unsigned long) 1) << 16))
55#define IS_BIN(spec) (spec & (((unsigned long) 1) << 17))
56#define IS_SPEC_BIN(spec) (spec & (((unsigned long) 1) << 18))
57#define IS_INLINE(spec) (spec & (((unsigned long) 1) << 19))
58#define DO_FREE(spec) (!(spec & (((unsigned long) 1) << 20)) && !(spec & (((unsigned long) 1) << 21)))
59#define DO_REALLOC(spec) ((spec & (((unsigned long) 1) << 20)) && (spec & (((unsigned long) 1) << 21)))
60#define DO_DUP(spec) ((spec & (((unsigned long) 1) << 20)) && ! (spec & (((unsigned long) 1) << 21)))
61#if CHECK_LEVEL > 0
62//#define DO_CHECK(spec) 1
63#define DO_CHECK(spec) (spec & (((unsigned long) 1) << 22))
64#define DO_FREE_CHECK(spec) (spec & (((unsigned long) 1) << 23))
65#else
66#define DO_CHECK(spec) 0
67#define DO_FREE_CHECK(spec) 0
68#endif
69#if CHECK_LEVEL > 0 && TRACK_LEVEL > 0
70#define DO_TRACK(spec) (spec & (((unsigned long) 1) << 24))
71#define GET_TRACK(spec) (((spec & ((((unsigned long) 1) << 27) | (((unsigned long) 1) << 26) | (((unsigned long) 1) << 25))) >> 25) % 5) + TRACK_LEVEL
72// #define DO_TRACK(spec) TRACK_LEVEL
73// #define GET_TRACK(spec) TRACK_LEVEL
74#else
75#define DO_TRACK(spec) 0
76#define GET_TRACK(spec) 0
77#endif
78#if KEEP_LEVEL > 0
79#define DO_KEEP(spec) (DO_CHECK(spec) && (spec % KEEP_LEVEL == 0))
80#define DO_FREE_KEEP(spec) (DO_FREE_CHECK(spec) && (spec % KEEP_LEVEL == 0))
81#else
82#define DO_KEEP(spec) 0
83#define DO_FREE_KEEP(spec) 0
84#endif
85
86#define IS_FREE_SIZE(spec) (spec & (((unsigned long) 1) << 28))
87#define IS_FREE_BIN(spec) (spec & (((unsigned long) 1) << 29))
88#define IS_SLOPPY(spec) (spec & (((unsigned long) 1) << 30))
89#define IS_FREE_BINADDR(spec) (spec & (((unsigned long) 1) << 31))
90
91
92#define SPEC_MAX ULONG_MAX
93#define SIZE_MAX ((((unsigned long) 1) << 14) -1)
94#define RANGE_MIN (((unsigned long) 1) << 6)
95#define RANGE_MAX (((unsigned long) 1) << 14)
96
97#define PAGES_PER_REGION 128
98
99void omtTestAlloc(omMemCell cell, unsigned long spec);
100void omtTestRealloc(omMemCell cell, unsigned long spec);
101void omtTestDup(omMemCell cell, unsigned long spec);
102void omtTestFree(omMemCell cell);
103
104void omtTestAllocDebug(omMemCell cell, unsigned long spec);
105void omtTestReallocDebug(omMemCell cell, unsigned long spec);
106void omtTestDupDebug(omMemCell cell, unsigned long spec);
108
109void omtTestAllocKeep(omMemCell cell, unsigned long spec);
110void omtTestReallocKeep(omMemCell cell, unsigned long spec);
111void omtTestDupKeep(omMemCell cell, unsigned long spec);
113
115int omtTestErrors();
117
118#if CHECK_LEVEL > 0
119void omtTestDebug(omMemCell cell);
120void TestAddrContent(void* addr, unsigned long value, size_t size);
121void TestAddrContentEqual(void* s1, void* s2, size_t size);
122#else
123#define omtTestDebug(cell) do {} while (0)
124#define TestAddrContent(a,v,s) do {} while (0)
125#define TestAddrContentEqual(s1, s2, s) do {} while (0)
126#endif
127#endif
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
omBin_t * omBin
Definition: omStructs.h:12
void TestAlloc(omMemCell cell, unsigned long spec)
Definition: omtTest.c:182
void TestAddrContent(void *addr, unsigned long value, size_t size)
Definition: omtTest.c:106
void omtTestAlloc(omMemCell cell, unsigned long spec)
Definition: omtTestAlloc.c:33
omBin omtGetStickyBin(omBin bin)
Definition: omtTest.c:275
omBin orig_bin
Definition: omtTest.h:29
void omtTestReallocDebug(omMemCell cell, unsigned long spec)
void omtTestAllocKeep(omMemCell cell, unsigned long spec)
void omtTestDup(omMemCell cell, unsigned long spec)
Definition: omtTestAlloc.c:348
void omtTestReallocKeep(omMemCell cell, unsigned long spec)
void TestFree(omMemCell cell)
Definition: omtTest.c:252
void TestRealloc(omMemCell cell, unsigned long spec)
Definition: omtTest.c:205
omMemCell_t * omMemCell
Definition: omtTest.h:33
void omtTestAllocDebug(omMemCell cell, unsigned long spec)
void omtTestDebug(omMemCell cell)
Definition: omtTest.c:36
void omtTestFreeDebug(omMemCell cell)
void omtTestRealloc(omMemCell cell, unsigned long spec)
Definition: omtTestAlloc.c:180
void InitCellAddrContent(omMemCell cell)
Definition: omtTest.c:130
void omtTestFree(omMemCell cell)
Definition: omtTestAlloc.c:135
unsigned long spec
Definition: omtTest.h:28
void omtTestDupDebug(omMemCell cell, unsigned long spec)
int omtTestErrors()
Definition: omtTestError.c:37
void omtTestFreeKeep(omMemCell cell)
omBin bin
Definition: omtTest.h:27
void * addr
Definition: omtTest.h:26
void omtTestDupKeep(omMemCell cell, unsigned long spec)
omMemCell_t cells[]
Definition: omtTest.c:11
void TestAddrContentEqual(void *s1, void *s2, size_t size)
Definition: omtTest.c:90