My Project
Loading...
Searching...
No Matches
omInline.h
Go to the documentation of this file.
1/*******************************************************************
2 * File: omInline.c
3 * Purpose: implementation of omalloc functions which could
4 * be inlined
5 * Author: [email protected] (Olaf Bachmann)
6 * Created: 11/99
7 *******************************************************************/
8#if defined(OM_INLINE) || defined(OM_ALLOC_C)
9
10#ifndef OM_INLINE_H
11#define OM_INLINE_H
12
13OM_INLINE_IMPL omBin omGetBinOfPage(omBinPage page)
14{
15 unsigned long sticky = omGetStickyOfPage(page);
16 omBin bin = omGetTopBinOfPage(page);
17
18 if (! omIsStickyBin(bin))
19 {
20 while (bin->sticky != sticky && bin->next != NULL)
21 {
22 bin = bin->next;
23 }
24 }
25 return bin;
26}
27
28OM_INLINE_IMPL int _omIsBinPageAddr(const void* addr)
29{
30 unsigned long index = omGetPageIndexOfAddr(addr);
32 {
33 unsigned long shift = omGetPageShiftOfAddr(addr);
34 return ((om_BinPageIndicies[index - om_MinBinPageIndex] & (((unsigned long) 1) << shift)) != 0L);
35 }
36 return 0;
37}
38
39OM_INLINE_IMPL void* _omAllocBin(omBin bin)
40{
41 void* addr;
42 __omTypeAllocBin(void*, addr, bin);
43 return addr;
44}
45OM_INLINE_IMPL void* _omAlloc0Bin(omBin bin)
46{
47 void* addr;
48 __omTypeAlloc0Bin(void*, addr, bin);
49 return addr;
50}
51OM_INLINE_IMPL void* _omReallocBin(void* addr, omBin old_bin, omBin new_bin)
52{
53 void* new_addr;
54 __omTypeReallocBin(addr, old_bin, void*, new_addr, new_bin);
55 return new_addr;
56}
57OM_INLINE_IMPL void* _omRealloc0Bin(void* addr, omBin old_bin, omBin new_bin)
58{
59 void* new_addr;
60 __omTypeRealloc0Bin(addr, old_bin, void*, new_addr, new_bin);
61 return new_addr;
62}
63
64
65OM_INLINE_IMPL void* _omAlloc(size_t size)
66{
67 void* addr;
68 __omTypeAlloc(void*, addr, size);
69 return addr;
70}
71OM_INLINE_IMPL void* _omAlloc0(size_t size)
72{
73 void* addr;
74 __omTypeAlloc0(void*, addr, size);
75 return addr;
76}
77OM_INLINE_IMPL void* _omReallocSize(void* addr, size_t old_size, size_t new_size)
78{
79 void* new_addr;
80 __omTypeReallocSize(addr, old_size, void*, new_addr, new_size);
81 return new_addr;
82}
83OM_INLINE_IMPL void* _omRealloc0Size(void* addr, size_t old_size, size_t new_size)
84{
85 void* new_addr;
86 __omTypeRealloc0Size(addr, old_size, void*, new_addr, new_size);
87 return new_addr;
88}
89OM_INLINE_IMPL void* _omRealloc(void* addr, size_t size)
90{
91 void* new_addr;
92 __omTypeRealloc(addr, void*, new_addr, size);
93 return new_addr;
94}
95OM_INLINE_IMPL void* _omRealloc0(void* addr, size_t size)
96{
97 void* new_addr;
98 __omTypeRealloc0(addr, void*, new_addr, size);
99 return new_addr;
100}
101
102#ifdef OM_ALIGNMENT_NEEDS_WORK
103OM_INLINE_IMPL void* _omAllocAligned(size_t size)
104{
105 void* addr;
106 __omTypeAllocAligned(void*, addr, size);
107 return addr;
108}
109OM_INLINE_IMPL void* _omAlloc0Aligned(size_t size)
110{
111 void* addr;
112 __omTypeAlloc0Aligned(void*, addr, size);
113 return addr;
114}
115OM_INLINE_IMPL void* _omReallocAlignedSize(void* addr, size_t old_size, size_t new_size)
116{
117 void* new_addr;
118 __omTypeReallocAlignedSize(addr, old_size, void*, new_addr, new_size);
119 return new_addr;
120}
121OM_INLINE_IMPL void* _omRealloc0AlignedSize(void* addr, size_t old_size, size_t new_size)
122{
123 void* new_addr;
124 __omTypeRealloc0AlignedSize(addr, old_size, void*, new_addr, new_size);
125 return new_addr;
126}
127OM_INLINE_IMPL void* _omReallocAligned(void* addr, size_t size)
128{
129 void* new_addr;
130 __omTypeReallocAligned(addr, void*, new_addr, size);
131 return new_addr;
132}
133OM_INLINE_IMPL void* _omRealloc0Aligned(void* addr, size_t size)
134{
135 void* new_addr;
136 __omTypeRealloc0Aligned(addr, void*, new_addr, size);
137 return new_addr;
138}
139
140OM_INLINE_IMPL void* _omMemDupAligned(void* addr)
141{
142 void* r;
143 size_t sizeW = omSizeWOfAddr(addr);
144 __omTypeAllocAligned(void*, r, sizeW << LOG_SIZEOF_LONG);
145 omMemcpyW(r, addr, sizeW);
146 return r;
147}
148
149#endif /* OM_ALIGNMENT_NEEDS_WORK */
150
151OM_INLINE_IMPL char* _omStrDup(const char* s)
152{
153 void* r;
154 size_t i=(size_t)0;
155
156 while (s[i]) i++;
157 i++;
158 __omTypeAlloc(void*, r, i);
159 memcpy(r, (void*) s, i);
160 return (char*) r;
161}
162
163OM_INLINE_IMPL void* _omMemDup(void* addr)
164{
165 void* r;
166 if (omIsNormalBinPageAddr(addr))
167 {
168 omBin bin = omGetTopBinOfAddr(addr);
169 __omTypeAllocBin(void*, r, bin);
170 omMemcpyW(r, addr, bin->sizeW);
171 }
172 else
173 {
174 size_t size = omSizeWOfAddr(addr);
175 __omTypeAlloc(void*, r, size << LOG_SIZEOF_LONG);
176 omMemcpyW(r, addr, size);
177 }
178 return r;
179}
180
181OM_INLINE_IMPL void* _omalloc(size_t size)
182{
183 void* addr;
184 if (! size) size = (size_t)1;
185 __omTypeAllocAligned(void*, addr,size);
186 return addr;
187}
188
189OM_INLINE_IMPL void* _omalloc0(size_t size)
190{
191 void* addr;
192 if (! size) size = (size_t)1;
193 __omTypeAlloc0Aligned(void*,addr, size);
194 return addr;
195}
196
197OM_INLINE_IMPL void* _omreallocSize(void* addr, size_t old_size, size_t new_size)
198{
199 void* new_addr;
200
201 if (!new_size) new_size = (size_t)1;
202 if (addr != NULL)
203 {
204 __omTypeReallocAlignedSize(addr, old_size, void* , new_addr, new_size);
205 }
206 else
207 {
208 __omTypeAllocAligned(void* , new_addr, new_size);
209 }
210 return new_addr;
211}
212
213OM_INLINE_IMPL void* _omrealloc0Size(void* addr, size_t old_size, size_t new_size)
214{
215 void* new_addr;
216
217 if (!new_size) new_size = (size_t)1;
218 if (addr != NULL && old_size > ((size_t)0))
219 {
220 __omTypeRealloc0AlignedSize(addr, old_size, void* , new_addr, new_size);
221 }
222 else
223 {
224 __omTypeAlloc0(void* , new_addr, new_size);
225 }
226 return new_addr;
227}
228
229OM_INLINE_IMPL void* _omrealloc(void* addr, size_t size)
230{
231 void* new_addr;
232
233 if (!size) size = (size_t)1;
234 if (addr != NULL)
235 {
236 __omTypeReallocAligned(addr, void* , new_addr, size);
237 }
238 else
239 {
240 __omTypeAlloc(void* , new_addr, size);
241 }
242 return new_addr;
243}
244
245OM_INLINE_IMPL void* _omrealloc0(void* addr, size_t size)
246{
247 void* new_addr;
248
249 if (!size) size = (size_t)1;
250 if (addr != NULL)
251 {
252 __omTypeRealloc0Aligned(addr, void* , new_addr, size);
253 }
254 else
255 {
256 __omTypeAlloc0(void* , new_addr, size);
257 }
258 return new_addr;
259}
260#endif /* OM_INLINE_H */
261
262#endif /* defined(OM_INLINE) || defined(OM_ALLOC_C) */
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
int i
Definition: cfEzgcd.cc:132
const CanonicalForm int s
Definition: facAbsFact.cc:51
#define __omTypeRealloc0Size(old_addr, old_size, new_type, new_addr, new_size)
#define __omTypeReallocBin(old_addr, old_bin, new_type, new_addr, new_bin)
#define __omTypeAlloc0Bin(type, addr, bin)
#define omGetTopBinOfAddr(addr)
#define __omTypeRealloc0Bin(old_addr, old_bin, new_type, new_addr, new_bin)
#define __omTypeRealloc(old_addr, new_type, new_addr, new_size)
#define __omTypeRealloc0(old_addr, new_type, new_addr, new_size)
#define __omTypeAllocBin(type, addr, bin)
#define __omTypeRealloc0Aligned
#define omGetTopBinOfPage(page)
#define __omTypeReallocSize(old_addr, old_size, new_type, new_addr, new_size)
#define __omTypeAlloc0(type, addr, size)
#define __omTypeAlloc(type, addr, size)
#define omGetStickyOfPage(page)
#define __omTypeRealloc0AlignedSize
#define __omTypeAllocAligned
#define __omTypeAlloc0Aligned
#define __omTypeReallocAligned
#define __omTypeReallocAlignedSize
unsigned long om_MaxBinPageIndex
Definition: omBinPage.c:36
unsigned long om_MinBinPageIndex
Definition: omBinPage.c:37
unsigned long * om_BinPageIndicies
Definition: omBinPage.c:38
#define omGetPageShiftOfAddr(addr)
Definition: omBinPage.h:60
#define omGetPageIndexOfAddr(addr)
Definition: omBinPage.h:63
#define omIsStickyBin(bin)
Definition: omBin.h:33
#define omIsNormalBinPageAddr(addr)
Definition: omDebug.h:14
OM_INLINE_DECL void * _omReallocBin(void *addr, omBin old_bin, omBin new_bin)
OM_INLINE_DECL char * _omStrDup(const char *s)
OM_INLINE_DECL omBin omGetBinOfPage(omBinPage page)
OM_INLINE_DECL void * _omalloc(size_t size)
OM_INLINE_DECL void * _omalloc0(size_t size)
OM_INLINE_DECL void * _omAlloc0Bin(omBin bin)
OM_INLINE_DECL void * _omRealloc0(void *addr, size_t size)
OM_INLINE_DECL int _omIsBinPageAddr(const void *addr)
OM_INLINE_DECL void * _omRealloc(void *addr, size_t size)
OM_INLINE_DECL void * _omAlloc(size_t size)
OM_INLINE_DECL void * _omReallocSize(void *addr, size_t old_size, size_t new_size)
OM_INLINE_DECL void * _omRealloc0Bin(void *addr, omBin old_bin, omBin new_bin)
OM_INLINE_DECL void * _omrealloc(void *addr, size_t size)
OM_INLINE_DECL void * _omMemDup(void *addr)
OM_INLINE_DECL void * _omreallocSize(void *addr, size_t old_size, size_t new_size)
OM_INLINE_DECL void * _omRealloc0Size(void *addr, size_t old_size, size_t new_size)
OM_INLINE_DECL void * _omAlloc0(size_t size)
OM_INLINE_DECL void * _omrealloc0(void *addr, size_t size)
OM_INLINE_DECL void * _omrealloc0Size(void *addr, size_t old_size, size_t new_size)
OM_INLINE_DECL void * _omAllocBin(omBin bin)
#define NULL
Definition: omList.c:12
#define omMemcpyW(p1, p2, l)
Definition: omMemOps.h:29
omBinPage_t * omBinPage
Definition: omStructs.h:16
omBin_t * omBin
Definition: omStructs.h:12
static int index(p_Length length, p_Ord ord)
Definition: p_Procs_Impl.h:592
#define omSizeWOfAddr(P)
Definition: xalloc.h:223