My Project
Loading...
Searching...
No Matches
Macros | Functions | Variables
omBinPage.h File Reference

Go to the source code of this file.

Macros

#define omIsAddrPageAligned(addr)    (((long) (addr) & (SIZEOF_SYSTEM_PAGE -1)) == 0)
 
#define omGetPageOfAddr(addr)    ((void*) (((long)addr) & ~(SIZEOF_SYSTEM_PAGE -1)))
 
#define omGetBinPageOfAddr(addr)    ((omBinPage) ((long) (addr) & ~(SIZEOF_SYSTEM_PAGE -1)))
 
#define omIsAddrOnPage(addr, page)   (omGetPageOfAddr(addr) == (void*) (page))
 
#define omAreAddrOnSamePage(a1, a2)    (omGetPageOfAddr(a1) == omGetPageOfAddr(a2))
 
#define OM_SIZEOF_INDEX_PAGE   (((unsigned long) SIZEOF_SYSTEM_PAGE) << LOG_BIT_SIZEOF_LONG)
 
#define omGetPageShiftOfAddr(addr)    ((((unsigned long) addr) & (OM_SIZEOF_INDEX_PAGE -1)) >> LOG_BIT_SIZEOF_SYSTEM_PAGE)
 
#define omGetPageIndexOfAddr(addr)    (((unsigned long) addr) >> (LOG_BIT_SIZEOF_LONG + LOG_BIT_SIZEOF_SYSTEM_PAGE))
 
#define omIsBinPageAddr(addr)   _omIsBinPageAddr(addr)
 
#define omFreeBinPage(addr)   omFreeBinPages(addr, 1)
 

Functions

omBinPage omAllocBinPages (int how_many)
 
omBinPage omAllocBinPage (void)
 
void omFreeBinPages (omBinPage page, int how_many)
 

Variables

unsigned long om_MaxBinPageIndex
 
unsigned long om_MinBinPageIndex
 
unsigned long * om_BinPageIndicies
 

Macro Definition Documentation

◆ OM_SIZEOF_INDEX_PAGE

#define OM_SIZEOF_INDEX_PAGE   (((unsigned long) SIZEOF_SYSTEM_PAGE) << LOG_BIT_SIZEOF_LONG)

Definition at line 58 of file omBinPage.h.

◆ omAreAddrOnSamePage

#define omAreAddrOnSamePage (   a1,
  a2 
)     (omGetPageOfAddr(a1) == omGetPageOfAddr(a2))

Definition at line 27 of file omBinPage.h.

◆ omFreeBinPage

#define omFreeBinPage (   addr)    omFreeBinPages(addr, 1)

Definition at line 88 of file omBinPage.h.

◆ omGetBinPageOfAddr

#define omGetBinPageOfAddr (   addr)     ((omBinPage) ((long) (addr) & ~(SIZEOF_SYSTEM_PAGE -1)))

Definition at line 22 of file omBinPage.h.

◆ omGetPageIndexOfAddr

#define omGetPageIndexOfAddr (   addr)     (((unsigned long) addr) >> (LOG_BIT_SIZEOF_LONG + LOG_BIT_SIZEOF_SYSTEM_PAGE))

Definition at line 63 of file omBinPage.h.

◆ omGetPageOfAddr

#define omGetPageOfAddr (   addr)     ((void*) (((long)addr) & ~(SIZEOF_SYSTEM_PAGE -1)))

Definition at line 19 of file omBinPage.h.

◆ omGetPageShiftOfAddr

#define omGetPageShiftOfAddr (   addr)     ((((unsigned long) addr) & (OM_SIZEOF_INDEX_PAGE -1)) >> LOG_BIT_SIZEOF_SYSTEM_PAGE)

Definition at line 60 of file omBinPage.h.

◆ omIsAddrOnPage

#define omIsAddrOnPage (   addr,
  page 
)    (omGetPageOfAddr(addr) == (void*) (page))

Definition at line 25 of file omBinPage.h.

◆ omIsAddrPageAligned

#define omIsAddrPageAligned (   addr)     (((long) (addr) & (SIZEOF_SYSTEM_PAGE -1)) == 0)

Definition at line 16 of file omBinPage.h.

◆ omIsBinPageAddr

#define omIsBinPageAddr (   addr)    _omIsBinPageAddr(addr)

Definition at line 68 of file omBinPage.h.

Function Documentation

◆ omAllocBinPage()

omBinPage omAllocBinPage ( void  )

Definition at line 98 of file omBinPage.c.

99{
100 omBinPage bin_page;
101
104
105 while (1)
106 {
107 if (om_CurrentBinPageRegion->current != NULL)
108 {
109 bin_page = om_CurrentBinPageRegion->current;
110 om_CurrentBinPageRegion->current = NEXT_PAGE(bin_page);
111 goto Found;
112 }
113 if (om_CurrentBinPageRegion->init_pages > 0)
114 {
115 bin_page = (omBinPage)om_CurrentBinPageRegion->init_addr;
116 om_CurrentBinPageRegion->init_pages--;
117 if (om_CurrentBinPageRegion->init_pages > 0)
118 om_CurrentBinPageRegion->init_addr += SIZEOF_SYSTEM_PAGE;
119 else
120 om_CurrentBinPageRegion->init_addr = NULL;
121 goto Found;
122 }
123 if (om_CurrentBinPageRegion->next != NULL)
124 {
126 }
127 else
128 {
130 new_region->prev = om_CurrentBinPageRegion;
131 om_CurrentBinPageRegion->next = new_region;
132 om_CurrentBinPageRegion = new_region;
133 }
134 }
135
136 Found:
137 bin_page->region = om_CurrentBinPageRegion;
138 om_CurrentBinPageRegion->used_pages++;
139
140 om_Info.UsedPages++;
141 om_Info.AvailPages--;
142 if (om_Info.UsedPages > om_Info.MaxPages)
143 om_Info.MaxPages = om_Info.UsedPages;
144
145 OM_ALLOC_BINPAGE_HOOK;
146 return bin_page;
147}
if(!FE_OPT_NO_SHELL_FLAG)(void) system(sys)
#define NEXT_PAGE(page)
Definition: omBinPage.c:95
static omBinPageRegion om_CurrentBinPageRegion
Definition: omBinPage.c:35
static omBinPageRegion omAllocNewBinPagesRegion(int min_pages)
Definition: omBinPage.c:294
#define NULL
Definition: omList.c:12
omInfo_t om_Info
Definition: omStats.c:16
omBinPage_t * omBinPage
Definition: omStructs.h:16
omBinPageRegion_t * omBinPageRegion
Definition: omStructs.h:20

◆ omAllocBinPages()

omBinPage omAllocBinPages ( int  how_many)

Definition at line 149 of file omBinPage.c.

150{
151 omBinPage bin_page;
152 omBinPageRegion region;
153
156
158 while (1)
159 {
160 if (region->init_pages >= how_many)
161 {
162 bin_page = (omBinPage)region->init_addr;
163 region->init_pages -= how_many;
164 if (region->init_pages)
165 region->init_addr += how_many*SIZEOF_SYSTEM_PAGE;
166 else
167 region->init_addr = NULL;
168 goto Found;
169 }
170 if ((bin_page = omTakeOutConsecutivePages(region, how_many)) != NULL)
171 {
172 goto Found;
173 }
174 if (region->next != NULL)
175 {
176 region = region->next;
177 }
178 else
179 {
180 omBinPageRegion new_region = omAllocNewBinPagesRegion(how_many);
181 region->next = new_region;
182 new_region->prev = region;
183 region = new_region;
184 }
185 }
186 /*while (1) */
187
188 Found:
189 bin_page->region = region;
190 region->used_pages += how_many;
191
192 if (region != om_CurrentBinPageRegion && OM_IS_EMPTY_REGION(region))
193 {
194 omTakeOutRegion(region);
196 }
197 om_Info.UsedPages += how_many;
198 om_Info.AvailPages -= how_many;
199 if (om_Info.UsedPages > om_Info.MaxPages)
200 om_Info.MaxPages = om_Info.UsedPages;
201
202 OM_ALLOC_BINPAGE_HOOK;
203 return bin_page;
204}
#define OM_IS_EMPTY_REGION(region)
Definition: omBinPage.c:96
OM_INLINE_LOCAL void omInsertRegionBefore(omBinPageRegion insert, omBinPageRegion before)
Definition: omBinPage.c:79
static void * omTakeOutConsecutivePages(omBinPageRegion region, int how_many)
Definition: omBinPage.c:254
OM_INLINE_LOCAL void omTakeOutRegion(omBinPageRegion region)
Definition: omBinPage.c:49

◆ omFreeBinPages()

void omFreeBinPages ( omBinPage  page,
int  how_many 
)

Definition at line 206 of file omBinPage.c.

207{
208 omBinPageRegion region = bin_page->region;
209
210 region->used_pages -= how_many;
211 if (region->used_pages == 0)
212 {
213 if (region == om_CurrentBinPageRegion)
214 {
215 if (region->next != NULL)
216 om_CurrentBinPageRegion = region->next;
217 else
218 om_CurrentBinPageRegion = region->prev;
219 }
220 omTakeOutRegion(region);
221 omFreeBinPagesRegion(region);
222 }
223 else
224 {
225 if (region != om_CurrentBinPageRegion && OM_IS_EMPTY_REGION(region))
226 {
227 omTakeOutRegion(region);
229 }
230 if (how_many > 1)
231 {
232 int i = how_many;
233 char* page = (char *)bin_page;
234
235 while (i > 1)
236 {
237 NEXT_PAGE(page) = page + SIZEOF_SYSTEM_PAGE;
238 page = NEXT_PAGE(page);
239 i--;
240 }
241 NEXT_PAGE(page) = region->current;
242 }
243 else
244 {
245 NEXT_PAGE(bin_page) = region->current;
246 }
247 region->current = (void*) bin_page;
248 }
249 om_Info.AvailPages += how_many;
250 om_Info.UsedPages -= how_many;
251 OM_FREE_BINPAGE_HOOK;
252}
int i
Definition: cfEzgcd.cc:132
OM_INLINE_LOCAL void omInsertRegionAfter(omBinPageRegion insert, omBinPageRegion after)
Definition: omBinPage.c:66
static void omFreeBinPagesRegion(omBinPageRegion region)
Definition: omBinPage.c:330

Variable Documentation

◆ om_BinPageIndicies

unsigned long* om_BinPageIndicies
extern

Definition at line 38 of file omBinPage.c.

◆ om_MaxBinPageIndex

unsigned long om_MaxBinPageIndex
extern

Definition at line 36 of file omBinPage.c.

◆ om_MinBinPageIndex

unsigned long om_MinBinPageIndex
extern

Definition at line 37 of file omBinPage.c.