source: git/omalloc/omtTest.h @ e70e45

spielwiese
Last change on this file since e70e45 was e70e45, checked in by Olaf Bachmann <obachman@…>, 24 years ago
* re-added files git-svn-id: file:///usr/local/Singular/svn/trunk@4521 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.0 KB
Line 
1#include <time.h>
2#include <string.h>
3
4#define TRACK_LEVEL   1
5#define CHECK_LEVEL   1
6// #define MAX_CELLS  500000   
7#define MAX_CELLS     100000
8// #define MAX_CELLS     10000
9#define KEEP_ADDR     100
10#define END_CHECK_LEVEL 5
11
12#ifdef OM_TEST_MALLOC
13#define OM_EMULATE_OMALLOC
14#endif
15
16
17#include "omStructs.h"
18
19struct omMemCell_s
20{
21  void* addr;
22  omBin bin;
23  int spec;
24};
25
26typedef struct omMemCell_s omMemCell_t;
27typedef omMemCell_t* omMemCell;
28
29extern omMemCell_t cells[];
30void TestAlloc(omMemCell cell, int spec);
31void TestRealloc(omMemCell cell, int spec);
32void TestFree(omMemCell cell);
33
34#if CHECK_LEVEL > 2
35#define myprintf(format, args...) \
36  printf(format, ## args)
37#define myfflush(what) fflush(what)
38#else
39#define myprintf(format, args...) ((void) 0)
40#define myfflush(what)            ((void) 0)
41#endif
42
43#define GET_SIZE(spec)      (spec & ((1 << 14) -1))
44#define SET_SIZE(spec, size) spec = ((spec & ~((1 << 14) -1)) | (size))
45#define IS_ALIGNED(spec)    (spec & (1 << 15))
46#define IS_ZERO(spec)       (spec & (1 << 16))
47#define IS_BIN(spec)        (spec & (1 << 17))
48#define IS_SPEC_BIN(spec)   (spec & (1 << 18))
49#define IS_INLINE(spec)     (spec & (1 << 19))
50#define DO_FREE(spec)       (!(spec & (1 << 20))  && !(spec & (1 << 21)))
51#define DO_REALLOC(spec)    ((spec & (1 << 20))  && (spec & (1 << 21)))
52#define DO_DUP(spec)        ((spec & (1 << 20)) && ! (spec & (1 << 21)))
53#if CHECK_LEVEL > 0
54//#define DO_CHECK(spec)      1
55#define DO_CHECK(spec)      (spec & (1 << 22))
56#define DO_FREE_CHECK(spec) (spec & (1 << 23))
57#else
58#define DO_CHECK(spec)      0
59#define DO_FREE_CHECK(spec) 0
60#endif
61#if CHECK_LEVEL > 0 && TRACK_LEVEL > 0
62#define DO_TRACK(spec)      (spec & (1 << 24))
63#define GET_TRACK(spec)     (((spec & ((1 << 27) | (1 << 26) | (1 << 25))) >> 25) % 5) + TRACK_LEVEL
64// #define DO_TRACK(spec)      TRACK_LEVEL
65// #define GET_TRACK(spec)     TRACK_LEVEL
66#else
67#define DO_TRACK(spec)      0
68#define GET_TRACK(spec)     0
69#endif
70#define IS_FREE_SIZE(spec)  (spec & (1 << 28))
71#define IS_FREE_BIN(spec)   (spec & (1 << 29))
72#define IS_SLOPPY(spec)     (spec & (1 << 30))
73
74
75#define SPEC_MAX   (((unsigned long) (1 << 31)) -1)
76#define SIZE_MAX  ((1 << 14) -1)
77#define RANGE_MIN (1 << 6)
78#define RANGE_MAX (1 << 14)
79
80#define PAGES_PER_REGION 128
81
82void omTestAlloc(omMemCell cell, int spec);
83void omTestRealloc(omMemCell cell, int spec);
84void omTestDup(omMemCell cell, int spec);
85void omTestFree(omMemCell cell);
86
87void omTestAllocDebug(omMemCell cell, int spec);
88void omTestReallocDebug(omMemCell cell, int spec);
89void omTestDupDebug(omMemCell cell, int spec);
90void omTestFreeDebug(omMemCell cell);
91void InitCellAddrContent(omMemCell cell);
92int omTestErrors();
93
94#if CHECK_LEVEL > 0
95void omTestDebug(omMemCell cell);
96void TestAddrContent(void* addr, unsigned long value, size_t size);
97void TestAddrContentEqual(void* s1, void* s2, size_t size);
98#else
99#define omTestDebug(cell)               ((void)0)
100#define TestAddrContent(a,v,s)          ((void)0)
101#define TestAddrContentEqual(s1, s2, s) ((void)0)
102#endif
Note: See TracBrowser for help on using the repository browser.