My Project
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
omAllocPrivate.h File Reference
#include "omalloc/omAllocSystem.h"

Go to the source code of this file.

Data Structures

struct  omBinPage_t
 
struct  omBin_t
 
struct  omSpecBin_t
 

Macros

#define SIZEOF_OM_BIN_PAGE_HEADER   (5*SIZEOF_VOIDP + SIZEOF_LONG)
 
#define SIZEOF_OM_BIN_PAGE   (SIZEOF_SYSTEM_PAGE - SIZEOF_OM_BIN_PAGE_HEADER)
 
#define omGetTopBinOfPage(page)    ((omBin) ( ((unsigned long) ((page)->bin_sticky)) & ~((unsigned long)SIZEOF_VOIDP - 1)))
 
#define omGetStickyOfPage(page)    (((unsigned long) ((page)->bin_sticky)) & ((unsigned long)SIZEOF_VOIDP-1))
 
#define omSetTopBinOfPage(page, bin)    (page)->bin_sticky= (void*)((unsigned long)bin + omGetStickyOfPage(page))
 
#define omSetStickyOfPage(page, sticky)
 
#define omSetTopBinAndStickyOfPage(page, bin, sticky)
 
#define omGetTopBinOfAddr(addr)    omGetTopBinOfPage(((omBinPage) omGetPageOfAddr(addr)))
 
#define omGetBinOfAddr(addr)   omGetBinOfPage(omGetBinPageOfAddr(addr))
 
#define omSizeOfBinAddr(addr)   _omSizeOfBinAddr(addr)
 
#define omSizeWOfBin(bin_ptr)   ((bin_ptr)->sizeW)
 
#define _omSizeOfBinAddr(addr)   ((omSizeWOfBinAddr(addr)) << LOG_SIZEOF_LONG)
 
#define omSizeWOfBinAddr(addr)   ((omGetTopBinOfAddr(addr))->sizeW)
 
#define __omTypeAllocFromNonEmptyPage(type, addr, page)
 
#define __omFreeToPage(addr, page)
 
#define __omTypeAllocBin(type, addr, bin)
 
#define __omTypeAlloc0Bin(type, addr, bin)
 
#define __omFreeBinAddr(addr)
 
#define __omTypeReallocBin(old_addr, old_bin, new_type, new_addr, new_bin)
 
#define __omTypeRealloc0Bin(old_addr, old_bin, new_type, new_addr, new_bin)
 
#define omSmallSize2Bin(size)   om_Size2Bin[((size) -1)>>LOG_SIZEOF_OM_ALIGNMENT]
 
#define __omTypeAlloc(type, addr, size)
 
#define __omTypeAlloc0(type, addr, size)
 
#define __omTypeAllocAligned   __omTypeAlloc
 
#define __omTypeAlloc0Aligned   __omTypeAlloc0
 
#define __omFreeSize(addr, size)
 
#define __omFree(addr)
 
#define ___omTypeRealloc(old_addr, new_type, new_addr, new_size, SIZE_2_BIN, REALLOC_BIN, flags)
 
#define ___omTypeReallocSize(old_addr, old_size, new_type, new_addr, new_size, SIZE_2_BIN, REALLOC_BIN, flags)
 
#define __omTypeRealloc(old_addr, new_type, new_addr, new_size)    ___omTypeRealloc(old_addr, new_type, new_addr, new_size, omSmallSize2Bin, __omTypeReallocBin, 0)
 
#define __omTypeRealloc0(old_addr, new_type, new_addr, new_size)    ___omTypeRealloc(old_addr, new_type, new_addr, new_size, omSmallSize2Bin, __omTypeRealloc0Bin, 1)
 
#define __omTypeReallocSize(old_addr, old_size, new_type, new_addr, new_size)    ___omTypeReallocSize(old_addr, old_size, new_type, new_addr, new_size, omSmallSize2Bin, __omTypeReallocBin, 0)
 
#define __omTypeRealloc0Size(old_addr, old_size, new_type, new_addr, new_size)    ___omTypeReallocSize(old_addr, old_size, new_type, new_addr, new_size, omSmallSize2Bin, __omTypeRealloc0Bin, 1)
 
#define __omTypeReallocAligned   __omTypeRealloc
 
#define __omTypeRealloc0Aligned   __omTypeRealloc0
 
#define __omTypeReallocAlignedSize   __omTypeReallocSize
 
#define __omTypeRealloc0AlignedSize   __omTypeRealloc0Size
 

Functions

voidomAllocBinFromFullPage (omBin bin)
 
void omFreeToPageFault (omBinPage page, void *addr)
 
voidomDoRealloc (void *old_addr, size_t new_size, int flags)
 

Variables

omSpecBin om_SpecBin
 
omBin om_StickyBins
 
omBinPage_t om_ZeroPage []
 
omBin om_Size2Bin []
 
omBin_t om_StaticBin []
 

Data Structure Documentation

◆ omBinPage_s

struct omBinPage_s

Definition at line 18 of file omAllocPrivate.h.

Data Fields
void * bin_sticky
void * current
omBinPage next
omBinPage prev
omBinPageRegion region
long used_blocks

◆ omBin_s

struct omBin_s

Definition at line 36 of file omAllocPrivate.h.

Data Fields
omBin_next curr
omBinPage current_page
omBinPage last_page
long max_blocks
omBin next
size_t size
size_t sizeW
unsigned long sticky

◆ omSpecBin_s

struct omSpecBin_s

Definition at line 47 of file omAllocPrivate.h.

Data Fields
omBin bin
long max_blocks
omSpecBin next
long ref

Macro Definition Documentation

◆ ___omTypeRealloc

#define ___omTypeRealloc (   old_addr,
  new_type,
  new_addr,
  new_size,
  SIZE_2_BIN,
  REALLOC_BIN,
  flags 
)
Value:
do \
{ \
size_t __new_size = new_size; \
{ \
} \
else \
{ \
} \
} \
while (0)
void * omDoRealloc(void *old_addr, size_t new_size, int flags)
Definition om_Alloc.c:229
#define omGetBinOfAddr(addr)
#define omIsBinPageAddr(addr)
Definition omBinPage.h:68
omBin_t * omBin
Definition omStructs.h:12
#define OM_MAX_BLOCK_SIZE
Definition omTables.c:31
int status int void size_t count const char int flags
Definition si_signals.h:83

Definition at line 314 of file omAllocPrivate.h.

◆ ___omTypeReallocSize

#define ___omTypeReallocSize (   old_addr,
  old_size,
  new_type,
  new_addr,
  new_size,
  SIZE_2_BIN,
  REALLOC_BIN,
  flags 
)

◆ __omFree

#define __omFree (   addr)
Value:
do \
{ \
{ \
} \
else \
{ \
omFreeLarge(addr); \
} \
} \
while (0)

Definition at line 298 of file omAllocPrivate.h.

300{ \
301 if (omIsBinPageAddr(addr)) \
302 { \
303 __omFreeBinAddr(addr); \
304 } \
305 else \
306 { \
307 omFreeLarge(addr); \
308 } \
309} \
310while (0)

◆ __omFreeBinAddr

#define __omFreeBinAddr (   addr)
Value:
do \
{ \
REGISTER void* __om_addr = (void*) (addr); \
} \
while (0)
#define omGetBinPageOfAddr(addr)
Definition omBinPage.h:22
omBinPage_t * omBinPage
Definition omStructs.h:16
#define REGISTER
Definition omalloc.h:27

Definition at line 163 of file omAllocPrivate.h.

165{ \
166 REGISTER void* __om_addr = (void*) (addr); \
169} \
170while (0)

◆ __omFreeSize

#define __omFreeSize (   addr,
  size 
)
Value:
do \
{ \
{ \
} \
else \
{ \
omFreeLarge(addr); \
} \
} \
while (0)
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition cf_ops.cc:600

Definition at line 284 of file omAllocPrivate.h.

286{ \
288 { \
289 __omFreeBinAddr(addr); \
290 } \
291 else \
292 { \
293 omFreeLarge(addr); \
294 } \
295} \
296while (0)

◆ __omFreeToPage

#define __omFreeToPage (   addr,
  page 
)
Value:
do \
{ \
if ((page)->used_blocks > 0L) \
{ \
*((void**) (addr)) = (page)->current; \
((page)->used_blocks)--; \
(page)->current = (addr); \
} \
else \
{ \
} \
} \
while (0)

Definition at line 124 of file omAllocPrivate.h.

126{ \
127 if ((page)->used_blocks > 0L) \
128 { \
129 *((void**) (addr)) = (page)->current; \
130 ((page)->used_blocks)--; \
131 (page)->current = (addr); \
132 } \
133 else \
134 { \
135 omFreeToPageFault(page, addr); \
136 } \
137} \
138while (0)

◆ __omTypeAlloc

#define __omTypeAlloc (   type,
  addr,
  size 
)
Value:
do \
{ \
size_t __size = size; \
{ \
__omTypeAllocBin(type, addr, __om_bin); \
} \
else \
{ \
addr = (type) omAllocLarge(__size); \
} \
} \
#define omSmallSize2Bin(size)
void * omAllocLarge(size_t size)

Definition at line 213 of file omAllocPrivate.h.

215{ \
216 size_t __size = size; \
218 { \
220 __omTypeAllocBin(type, addr, __om_bin); \
221 } \
222 else \
223 { \
224 addr = (type) omAllocLarge(__size); \
225 } \
226} \
227while(0)

◆ __omTypeAlloc0

#define __omTypeAlloc0 (   type,
  addr,
  size 
)
Value:
do \
{ \
size_t __size = size; \
{ \
} \
else \
{ \
addr = (type) omAlloc0Large(__size); \
} \
} \
while (0)
void * omAlloc0Large(size_t size)

Definition at line 229 of file omAllocPrivate.h.

231{ \
232 size_t __size = size; \
234 { \
236 __omTypeAlloc0Bin(type, addr, __om_bin); \
237 } \
238 else \
239 { \
240 addr = (type) omAlloc0Large(__size); \
241 } \
242} \
243while (0)

◆ __omTypeAlloc0Aligned

#define __omTypeAlloc0Aligned   __omTypeAlloc0

Definition at line 281 of file omAllocPrivate.h.

◆ __omTypeAlloc0Bin

#define __omTypeAlloc0Bin (   type,
  addr,
  bin 
)
Value:
do \
{ \
__omTypeAllocBin(type, addr, bin); \
omMemsetW(addr, 0, (bin)->sizeW); \
} \
while (0)

Definition at line 154 of file omAllocPrivate.h.

156{ \
157 __omTypeAllocBin(type, addr, bin); \
158 omMemsetW(addr, 0, (bin)->sizeW); \
159} \
160while (0)

◆ __omTypeAllocAligned

#define __omTypeAllocAligned   __omTypeAlloc

Definition at line 280 of file omAllocPrivate.h.

◆ __omTypeAllocBin

#define __omTypeAllocBin (   type,
  addr,
  bin 
)
Value:
do \
{ \
REGISTER omBinPage __om_page = (bin)->current_page; \
if (__om_page->current != NULL) \
addr = (type) omAllocBinFromFullPage(bin); \
} \
while (0)
void * omAllocBinFromFullPage(omBin bin)
Definition om_Alloc.c:119
#define NULL
Definition omList.c:12

Definition at line 143 of file omAllocPrivate.h.

145{ \
146 REGISTER omBinPage __om_page = (bin)->current_page; \
147 if (__om_page->current != NULL) \
149 else \
150 addr = (type) omAllocBinFromFullPage(bin); \
151} \
152while (0)

◆ __omTypeAllocFromNonEmptyPage

#define __omTypeAllocFromNonEmptyPage (   type,
  addr,
  page 
)
Value:
do \
{ \
((page)->used_blocks)++; \
addr = (type)((page)->current); \
(page)->current = *((void**) (page)->current); \
} \
while (0)

Definition at line 115 of file omAllocPrivate.h.

117{ \
118 ((page)->used_blocks)++; \
119 addr = (type)((page)->current); \
120 (page)->current = *((void**) (page)->current); \
121} \
122while (0)

◆ __omTypeRealloc

Definition at line 348 of file omAllocPrivate.h.

◆ __omTypeRealloc0

Definition at line 350 of file omAllocPrivate.h.

◆ __omTypeRealloc0Aligned

#define __omTypeRealloc0Aligned   __omTypeRealloc0

Definition at line 368 of file omAllocPrivate.h.

◆ __omTypeRealloc0AlignedSize

#define __omTypeRealloc0AlignedSize   __omTypeRealloc0Size

Definition at line 370 of file omAllocPrivate.h.

◆ __omTypeRealloc0Bin

#define __omTypeRealloc0Bin (   old_addr,
  old_bin,
  new_type,
  new_addr,
  new_bin 
)
Value:
do \
{ \
{ \
if (new_bin->sizeW > old_sizeW) \
omMemsetW((void**)new_addr + old_sizeW, 0, new_bin->sizeW - old_sizeW); \
} \
else \
{ \
} \
} \
while (0)
#define omIsNormalBinPageAddr(addr)
Definition omDebug.h:14
#define omSizeWOfAddr(P)
Definition xalloc.h:223

Definition at line 190 of file omAllocPrivate.h.

192{ \
193 if (old_bin != new_bin) \
194 { \
198 if (new_bin->sizeW > old_sizeW) \
199 omMemsetW((void**)new_addr + old_sizeW, 0, new_bin->sizeW - old_sizeW); \
201 } \
202 else \
203 { \
205 } \
206} \
207while (0)

◆ __omTypeRealloc0Size

Definition at line 354 of file omAllocPrivate.h.

◆ __omTypeReallocAligned

#define __omTypeReallocAligned   __omTypeRealloc

Definition at line 367 of file omAllocPrivate.h.

◆ __omTypeReallocAlignedSize

#define __omTypeReallocAlignedSize   __omTypeReallocSize

Definition at line 369 of file omAllocPrivate.h.

◆ __omTypeReallocBin

#define __omTypeReallocBin (   old_addr,
  old_bin,
  new_type,
  new_addr,
  new_bin 
)
Value:

Definition at line 172 of file omAllocPrivate.h.

174{ \
175 if (old_bin != new_bin) \
176 { \
181 } \
182 else \
183 { \
185 } \
186} \
187while (0)

◆ __omTypeReallocSize

Definition at line 352 of file omAllocPrivate.h.

◆ _omSizeOfBinAddr

#define _omSizeOfBinAddr (   addr)    ((omSizeWOfBinAddr(addr)) << LOG_SIZEOF_LONG)

Definition at line 102 of file omAllocPrivate.h.

◆ omGetBinOfAddr

#define omGetBinOfAddr (   addr)    omGetBinOfPage(omGetBinPageOfAddr(addr))

Definition at line 80 of file omAllocPrivate.h.

◆ omGetStickyOfPage

#define omGetStickyOfPage (   page)     (((unsigned long) ((page)->bin_sticky)) & ((unsigned long)SIZEOF_VOIDP-1))

Definition at line 67 of file omAllocPrivate.h.

◆ omGetTopBinOfAddr

#define omGetTopBinOfAddr (   addr)     omGetTopBinOfPage(((omBinPage) omGetPageOfAddr(addr)))

Definition at line 78 of file omAllocPrivate.h.

◆ omGetTopBinOfPage

#define omGetTopBinOfPage (   page)     ((omBin) ( ((unsigned long) ((page)->bin_sticky)) & ~((unsigned long)SIZEOF_VOIDP - 1)))

Definition at line 65 of file omAllocPrivate.h.

◆ omSetStickyOfPage

#define omSetStickyOfPage (   page,
  sticky 
)
Value:
(page)->bin_sticky = (void*)(((unsigned long)sticky & ((unsigned long)SIZEOF_VOIDP-1)) + \
#define omGetTopBinOfPage(page)

Definition at line 71 of file omAllocPrivate.h.

◆ omSetTopBinAndStickyOfPage

#define omSetTopBinAndStickyOfPage (   page,
  bin,
  sticky 
)
Value:
(page)->bin_sticky= (void*)(((unsigned long)sticky & (SIZEOF_VOIDP-1)) \
+ (unsigned long)bin)

Definition at line 74 of file omAllocPrivate.h.

◆ omSetTopBinOfPage

#define omSetTopBinOfPage (   page,
  bin 
)     (page)->bin_sticky= (void*)((unsigned long)bin + omGetStickyOfPage(page))

Definition at line 69 of file omAllocPrivate.h.

◆ omSizeOfBinAddr

#define omSizeOfBinAddr (   addr)    _omSizeOfBinAddr(addr)

Definition at line 97 of file omAllocPrivate.h.

◆ omSizeWOfBin

#define omSizeWOfBin (   bin_ptr)    ((bin_ptr)->sizeW)

Definition at line 100 of file omAllocPrivate.h.

◆ omSizeWOfBinAddr

#define omSizeWOfBinAddr (   addr)    ((omGetTopBinOfAddr(addr))->sizeW)

Definition at line 103 of file omAllocPrivate.h.

◆ omSmallSize2Bin

#define omSmallSize2Bin (   size)    om_Size2Bin[((size) -1)>>LOG_SIZEOF_OM_ALIGNMENT]

Definition at line 211 of file omAllocPrivate.h.

◆ SIZEOF_OM_BIN_PAGE

#define SIZEOF_OM_BIN_PAGE   (SIZEOF_SYSTEM_PAGE - SIZEOF_OM_BIN_PAGE_HEADER)

Definition at line 32 of file omAllocPrivate.h.

◆ SIZEOF_OM_BIN_PAGE_HEADER

#define SIZEOF_OM_BIN_PAGE_HEADER   (5*SIZEOF_VOIDP + SIZEOF_LONG)

Definition at line 31 of file omAllocPrivate.h.

Function Documentation

◆ omAllocBinFromFullPage()

void * omAllocBinFromFullPage ( omBin  bin)
extern

Definition at line 119 of file om_Alloc.c.

120{
121 void* addr;
123 omAssume(bin->current_page->current == NULL);
124
125 if (bin->current_page != om_ZeroPage)
126 {
127 omAssume(bin->last_page != NULL);
128 /* Set this to zero, but preserve the first bit,
129 so that tracking works */
130#ifdef OM_HAVE_TRACK
131 bin->current_page->used_blocks &= (((unsigned long) 1) << (BIT_SIZEOF_LONG -1));
132#else
133 bin->current_page->used_blocks = 0;
134#endif
135 }
136
137 if (!bin->sticky && bin->current_page->next != NULL)
138 {
139 omAssume(bin->current_page->next->current != NULL);
140 newpage = bin->current_page->next;
141 }
142 else
143 {
144 // need to Allocate new page
146 omInsertBinPage(bin->current_page, newpage, bin);
147 }
148
149 bin->current_page = newpage;
151 newpage->current != NULL);
153 return addr;
154}
#define BIT_SIZEOF_LONG
Definition auxiliary.h:80
#define __omTypeAllocFromNonEmptyPage(type, addr, page)
#define omAssume(x)
Definition omError.h:85
omBinPage_t om_ZeroPage[]
Definition om_Alloc.c:19
OM_INLINE_LOCAL void omInsertBinPage(omBinPage after, omBinPage page, omBin bin)
Definition om_Alloc.c:90
static omBinPage omAllocNewBinPage(omBin bin)
Definition om_Alloc.c:32

◆ omDoRealloc()

void * omDoRealloc ( void old_addr,
size_t  new_size,
int  flags 
)

Definition at line 229 of file om_Alloc.c.

230{
231 void* new_addr;
232
234 {
235 if (DO_ZERO(flag))
237 else
239 }
240 else
241 {
243 size_t min_size;
244
246
247#ifdef OM_ALIGNMENT_NEEDS_WORK
248 if (flag & 2)
250 else
251#endif
253
257
258 if (DO_ZERO(flag) && (new_size > old_size))
260
262
263 return new_addr;
264 }
265}
#define __omTypeAlloc(type, addr, size)
#define __omTypeAllocAligned
#define __omFreeSize(addr, size)
void * omRealloc0Large(void *old_addr, size_t new_size)
void * omReallocLarge(void *old_addr, size_t new_size)
size_t omSizeOfAddr(const void *addr)
#define omMemcpyW(p1, p2, l)
Definition omMemOps.h:29
#define omMemsetW(P1, W, L)
Definition omMemOps.h:161
#define DO_ZERO(flag)
Definition om_Alloc.c:226

◆ omFreeToPageFault()

void omFreeToPageFault ( omBinPage  page,
void addr 
)
extern

Definition at line 167 of file om_Alloc.c.

168{
169 omBin bin;
170 omAssume(page->used_blocks <= 0L);
171
172#ifdef OM_HAVE_TRACK
173 if (page->used_blocks < 0L)
174 {
175 omFreeTrackAddr(addr);
176 return;
177 }
178#endif
179
180 bin = omGetBinOfPage(page);
181 if ((page->current != NULL) || (bin->max_blocks <= 1))
182 {
183 // all blocks of page are now collected
185 // page can be freed
186 if (bin->max_blocks > 0)
188 else
189 omFreeBinPages(page, - bin->max_blocks);
190#ifdef OM_HAVE_TRACK
192#endif
193 }
194 else
195 {
196 // page was full
197 page->current = addr;
198 page->used_blocks = bin->max_blocks - 2;
199 *((void**)addr) = NULL;
200
202#if defined(PAGE_BEFORE_CURRENT)
203 if (bin->current_page->prev != NULL)
204 omInsertBinPage(bin->current_page->prev, page);
205 else
206 omInsertBinPage(bin->current_page, page, bin);
207 bin->current_page = page;
208#else
209# if defined(PAGE_AFTER_CURRENT)
210 omInsertBinPage(bin->current_page, page, bin);
211# else
212 omInsertBinPage(bin->last_page, page, bin);
213# endif
214#endif
215 }
216}
void omFreeBinPages(omBinPage bin_page, int how_many)
Definition omBinPage.c:206
#define omFreeBinPage(addr)
Definition omBinPage.h:88
OM_INLINE_DECL omBin omGetBinOfPage(omBinPage page)
OM_INLINE_LOCAL void omTakeOutBinPage(omBinPage page, omBin bin)
Definition om_Alloc.c:59

Variable Documentation

◆ om_Size2Bin

omBin om_Size2Bin
extern

Definition at line 84 of file omAllocPrivate.h.

◆ om_SpecBin

omSpecBin om_SpecBin
extern

Definition at line 20 of file om_Alloc.c.

◆ om_StaticBin

omBin_t om_StaticBin[]
extern

◆ om_StickyBins

omBin om_StickyBins
extern

Definition at line 374 of file omBin.c.

◆ om_ZeroPage

omBinPage_t om_ZeroPage[]
extern

Definition at line 19 of file om_Alloc.c.

19{{0, NULL, NULL, NULL, NULL}};