Loading...
Searching...
No Matches
omInline.h
Go to the documentation of this file.
/*******************************************************************
* File: omInline.c
* Purpose: implementation of omalloc functions which could
* be inlined
* Author: obachman@mathematik.uni-kl.de (Olaf Bachmann)
* Created: 11/99
*******************************************************************/
#if defined(OM_INLINE) || defined(OM_ALLOC_C)
#ifndef OM_INLINE_H
#define OM_INLINE_H
OM_INLINE_IMPL omBin omGetBinOfPage(omBinPage page)
{
unsigned long sticky = omGetStickyOfPage(page);
omBin bin = omGetTopBinOfPage(page);
if (! omIsStickyBin(bin))
{
while (bin->sticky != sticky && bin->next != NULL)
{
bin = bin->next;
}
}
return bin;
}
OM_INLINE_IMPL int _omIsBinPageAddr(const void* addr)
{
unsigned long index = omGetPageIndexOfAddr(addr);
if (index >= om_MinBinPageIndex && index <= om_MaxBinPageIndex)
{
unsigned long shift = omGetPageShiftOfAddr(addr);
return ((om_BinPageIndicies[index - om_MinBinPageIndex] & (((unsigned long) 1) << shift)) != 0L);
}
return 0;
}
OM_INLINE_IMPL void* _omAllocBin(omBin bin)
{
void* addr;
__omTypeAllocBin(void*, addr, bin);
return addr;
}
OM_INLINE_IMPL void* _omAlloc0Bin(omBin bin)
{
void* addr;
__omTypeAlloc0Bin(void*, addr, bin);
return addr;
}
OM_INLINE_IMPL void* _omReallocBin(void* addr, omBin old_bin, omBin new_bin)
{
void* new_addr;
__omTypeReallocBin(addr, old_bin, void*, new_addr, new_bin);
return new_addr;
}
OM_INLINE_IMPL void* _omRealloc0Bin(void* addr, omBin old_bin, omBin new_bin)
{
void* new_addr;
__omTypeRealloc0Bin(addr, old_bin, void*, new_addr, new_bin);
return new_addr;
}
OM_INLINE_IMPL void* _omAlloc(size_t size)
{
void* addr;
__omTypeAlloc(void*, addr, size);
return addr;
}
OM_INLINE_IMPL void* _omAlloc0(size_t size)
{
void* addr;
__omTypeAlloc0(void*, addr, size);
return addr;
}
OM_INLINE_IMPL void* _omReallocSize(void* addr, size_t old_size, size_t new_size)
{
void* new_addr;
__omTypeReallocSize(addr, old_size, void*, new_addr, new_size);
return new_addr;
}
OM_INLINE_IMPL void* _omRealloc0Size(void* addr, size_t old_size, size_t new_size)
{
void* new_addr;
__omTypeRealloc0Size(addr, old_size, void*, new_addr, new_size);
return new_addr;
}
OM_INLINE_IMPL void* _omRealloc(void* addr, size_t size)
{
void* new_addr;
__omTypeRealloc(addr, void*, new_addr, size);
return new_addr;
}
OM_INLINE_IMPL void* _omRealloc0(void* addr, size_t size)
{
void* new_addr;
__omTypeRealloc0(addr, void*, new_addr, size);
return new_addr;
}
#ifdef OM_ALIGNMENT_NEEDS_WORK
OM_INLINE_IMPL void* _omAllocAligned(size_t size)
{
void* addr;
__omTypeAllocAligned(void*, addr, size);
return addr;
}
OM_INLINE_IMPL void* _omAlloc0Aligned(size_t size)
{
void* addr;
__omTypeAlloc0Aligned(void*, addr, size);
return addr;
}
OM_INLINE_IMPL void* _omReallocAlignedSize(void* addr, size_t old_size, size_t new_size)
{
void* new_addr;
__omTypeReallocAlignedSize(addr, old_size, void*, new_addr, new_size);
return new_addr;
}
OM_INLINE_IMPL void* _omRealloc0AlignedSize(void* addr, size_t old_size, size_t new_size)
{
void* new_addr;
__omTypeRealloc0AlignedSize(addr, old_size, void*, new_addr, new_size);
return new_addr;
}
OM_INLINE_IMPL void* _omReallocAligned(void* addr, size_t size)
{
void* new_addr;
__omTypeReallocAligned(addr, void*, new_addr, size);
return new_addr;
}
OM_INLINE_IMPL void* _omRealloc0Aligned(void* addr, size_t size)
{
void* new_addr;
__omTypeRealloc0Aligned(addr, void*, new_addr, size);
return new_addr;
}
OM_INLINE_IMPL void* _omMemDupAligned(void* addr)
{
void* r;
size_t sizeW = omSizeWOfAddr(addr);
__omTypeAllocAligned(void*, r, sizeW << LOG_SIZEOF_LONG);
omMemcpyW(r, addr, sizeW);
return r;
}
#endif /* OM_ALIGNMENT_NEEDS_WORK */
OM_INLINE_IMPL char* _omStrDup(const char* s)
{
void* r;
size_t i=(size_t)0;
while (s[i]) i++;
i++;
__omTypeAlloc(void*, r, i);
memcpy(r, (void*) s, i);
return (char*) r;
}
OM_INLINE_IMPL void* _omMemDup(void* addr)
{
void* r;
if (omIsNormalBinPageAddr(addr))
{
omBin bin = omGetTopBinOfAddr(addr);
__omTypeAllocBin(void*, r, bin);
omMemcpyW(r, addr, bin->sizeW);
}
else
{
size_t size = omSizeWOfAddr(addr);
__omTypeAlloc(void*, r, size << LOG_SIZEOF_LONG);
omMemcpyW(r, addr, size);
}
return r;
}
OM_INLINE_IMPL void* _omalloc(size_t size)
{
void* addr;
if (! size) size = (size_t)1;
__omTypeAllocAligned(void*, addr,size);
return addr;
}
OM_INLINE_IMPL void* _omalloc0(size_t size)
{
void* addr;
if (! size) size = (size_t)1;
__omTypeAlloc0Aligned(void*,addr, size);
return addr;
}
OM_INLINE_IMPL void* _omreallocSize(void* addr, size_t old_size, size_t new_size)
{
void* new_addr;
if (!new_size) new_size = (size_t)1;
if (addr != NULL)
{
__omTypeReallocAlignedSize(addr, old_size, void* , new_addr, new_size);
}
else
{
__omTypeAllocAligned(void* , new_addr, new_size);
}
return new_addr;
}
OM_INLINE_IMPL void* _omrealloc0Size(void* addr, size_t old_size, size_t new_size)
{
void* new_addr;
if (!new_size) new_size = (size_t)1;
if (addr != NULL && old_size > ((size_t)0))
{
__omTypeRealloc0AlignedSize(addr, old_size, void* , new_addr, new_size);
}
else
{
__omTypeAlloc0(void* , new_addr, new_size);
}
return new_addr;
}
OM_INLINE_IMPL void* _omrealloc(void* addr, size_t size)
{
void* new_addr;
if (!size) size = (size_t)1;
if (addr != NULL)
{
__omTypeReallocAligned(addr, void* , new_addr, size);
}
else
{
__omTypeAlloc(void* , new_addr, size);
}
return new_addr;
}
OM_INLINE_IMPL void* _omrealloc0(void* addr, size_t size)
{
void* new_addr;
if (!size) size = (size_t)1;
if (addr != NULL)
{
__omTypeRealloc0Aligned(addr, void* , new_addr, size);
}
else
{
__omTypeAlloc0(void* , new_addr, size);
}
return new_addr;
}
#endif /* OM_INLINE_H */
#endif /* defined(OM_INLINE) || defined(OM_ALLOC_C) */
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition cf_ops.cc:600
i
int i
Definition cfEzgcd.cc:132
s
const CanonicalForm int s
Definition facAbsFact.cc:51
__omTypeRealloc0Size
#define __omTypeRealloc0Size(old_addr, old_size, new_type, new_addr, new_size)
Definition omAllocPrivate.h:354
__omTypeReallocBin
#define __omTypeReallocBin(old_addr, old_bin, new_type, new_addr, new_bin)
Definition omAllocPrivate.h:172
__omTypeAlloc0Bin
#define __omTypeAlloc0Bin(type, addr, bin)
Definition omAllocPrivate.h:154
omGetTopBinOfAddr
#define omGetTopBinOfAddr(addr)
Definition omAllocPrivate.h:78
__omTypeRealloc0Bin
#define __omTypeRealloc0Bin(old_addr, old_bin, new_type, new_addr, new_bin)
Definition omAllocPrivate.h:190
__omTypeRealloc
#define __omTypeRealloc(old_addr, new_type, new_addr, new_size)
Definition omAllocPrivate.h:348
__omTypeRealloc0
#define __omTypeRealloc0(old_addr, new_type, new_addr, new_size)
Definition omAllocPrivate.h:350
__omTypeAllocBin
#define __omTypeAllocBin(type, addr, bin)
Definition omAllocPrivate.h:143
__omTypeRealloc0Aligned
#define __omTypeRealloc0Aligned
Definition omAllocPrivate.h:368
omGetTopBinOfPage
#define omGetTopBinOfPage(page)
Definition omAllocPrivate.h:65
__omTypeReallocSize
#define __omTypeReallocSize(old_addr, old_size, new_type, new_addr, new_size)
Definition omAllocPrivate.h:352
__omTypeAlloc0
#define __omTypeAlloc0(type, addr, size)
Definition omAllocPrivate.h:229
__omTypeAlloc
#define __omTypeAlloc(type, addr, size)
Definition omAllocPrivate.h:213
omGetStickyOfPage
#define omGetStickyOfPage(page)
Definition omAllocPrivate.h:67
__omTypeRealloc0AlignedSize
#define __omTypeRealloc0AlignedSize
Definition omAllocPrivate.h:370
__omTypeAllocAligned
#define __omTypeAllocAligned
Definition omAllocPrivate.h:280
__omTypeAlloc0Aligned
#define __omTypeAlloc0Aligned
Definition omAllocPrivate.h:281
__omTypeReallocAligned
#define __omTypeReallocAligned
Definition omAllocPrivate.h:367
__omTypeReallocAlignedSize
#define __omTypeReallocAlignedSize
Definition omAllocPrivate.h:369
om_MaxBinPageIndex
unsigned long om_MaxBinPageIndex
Definition omBinPage.c:36
om_MinBinPageIndex
unsigned long om_MinBinPageIndex
Definition omBinPage.c:37
om_BinPageIndicies
unsigned long * om_BinPageIndicies
Definition omBinPage.c:38
omGetPageShiftOfAddr
#define omGetPageShiftOfAddr(addr)
Definition omBinPage.h:60
omGetPageIndexOfAddr
#define omGetPageIndexOfAddr(addr)
Definition omBinPage.h:63
omIsStickyBin
#define omIsStickyBin(bin)
Definition omBin.h:33
omIsNormalBinPageAddr
#define omIsNormalBinPageAddr(addr)
Definition omDebug.h:14
_omReallocBin
OM_INLINE_DECL void * _omReallocBin(void *addr, omBin old_bin, omBin new_bin)
_omStrDup
OM_INLINE_DECL char * _omStrDup(const char *s)
omGetBinOfPage
OM_INLINE_DECL omBin omGetBinOfPage(omBinPage page)
_omalloc
OM_INLINE_DECL void * _omalloc(size_t size)
_omalloc0
OM_INLINE_DECL void * _omalloc0(size_t size)
_omAlloc0Bin
OM_INLINE_DECL void * _omAlloc0Bin(omBin bin)
_omRealloc0
OM_INLINE_DECL void * _omRealloc0(void *addr, size_t size)
_omIsBinPageAddr
OM_INLINE_DECL int _omIsBinPageAddr(const void *addr)
_omRealloc
OM_INLINE_DECL void * _omRealloc(void *addr, size_t size)
_omAlloc
OM_INLINE_DECL void * _omAlloc(size_t size)
_omReallocSize
OM_INLINE_DECL void * _omReallocSize(void *addr, size_t old_size, size_t new_size)
_omRealloc0Bin
OM_INLINE_DECL void * _omRealloc0Bin(void *addr, omBin old_bin, omBin new_bin)
_omrealloc
OM_INLINE_DECL void * _omrealloc(void *addr, size_t size)
_omMemDup
OM_INLINE_DECL void * _omMemDup(void *addr)
_omreallocSize
OM_INLINE_DECL void * _omreallocSize(void *addr, size_t old_size, size_t new_size)
_omRealloc0Size
OM_INLINE_DECL void * _omRealloc0Size(void *addr, size_t old_size, size_t new_size)
_omAlloc0
OM_INLINE_DECL void * _omAlloc0(size_t size)
_omrealloc0
OM_INLINE_DECL void * _omrealloc0(void *addr, size_t size)
_omrealloc0Size
OM_INLINE_DECL void * _omrealloc0Size(void *addr, size_t old_size, size_t new_size)
_omAllocBin
OM_INLINE_DECL void * _omAllocBin(omBin bin)
NULL
#define NULL
Definition omList.c:12
omMemcpyW
#define omMemcpyW(p1, p2, l)
Definition omMemOps.h:29
omBinPage
omBinPage_t * omBinPage
Definition omStructs.h:16
omBin
omBin_t * omBin
Definition omStructs.h:12
index
static int index(p_Length length, p_Ord ord)
Definition p_Procs_Impl.h:592
omSizeWOfAddr
#define omSizeWOfAddr(P)
Definition xalloc.h:223