- java.lang.Object
-
- de.ibapl.jnhw.common.memory.AbstractNativeMemory
-
- Direct Known Subclasses:
OpaqueMemory32,OpaqueMemory64
public abstract class AbstractNativeMemory extends Object
- Author:
- aploese
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractNativeMemory.SetMem
-
Field Summary
Fields Modifier and Type Field Description protected longbaseAddressprotected static CleanerCLEANERprotected static LoggerLOGprotected static MemoryAccessorMEM_ACCESSstatic StringMEM_ACCESS_PROPERTYstatic longNULLAbstractNativeMemoryparent
-
Constructor Summary
Constructors Modifier Constructor Description AbstractNativeMemory(AbstractNativeMemory parent, long offset, long sizeInBytes)Creates a new memory which will be freed at the end of life.protectedAbstractNativeMemory(NativeAddressHolder addressHolder)Create a static memory slice which will NOT be freed - its static.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static longcalcOffsetForAlignment(AbstractNativeMemory mem, Alignment structAlignment, long startOffset)Neede for calculating baseaddress of onTheFlyprotected longgetOffset()calc the offsetprotected abstract longgetSizeInBytes()static longgetSizeInBytes(AbstractNativeMemory instance)Get the size in bytes if instance.static booleanisSameAddress(NativeAddressHolder nativeAddress, AbstractNativeMemory om)test if adresses are the same.static longoffsetof(AbstractNativeMemory member)Get the offset of member to direct parent.static <T extends AbstractNativeMemory>
NativeAddressHolder<T>toNativeAddressHolder(T value)static longtoUintptr_t(AbstractNativeMemory instance)static longtoUintptr_tOrNULL(AbstractNativeMemory instance)
-
-
-
Field Detail
-
NULL
public static final long NULL
- See Also:
- Constant Field Values
-
CLEANER
protected static final Cleaner CLEANER
-
LOG
protected static final Logger LOG
-
MEM_ACCESS_PROPERTY
public static final String MEM_ACCESS_PROPERTY
- See Also:
- Constant Field Values
-
MEM_ACCESS
protected static final MemoryAccessor MEM_ACCESS
-
baseAddress
protected final long baseAddress
-
parent
public final AbstractNativeMemory parent
-
-
Constructor Detail
-
AbstractNativeMemory
protected AbstractNativeMemory(NativeAddressHolder addressHolder)
Create a static memory slice which will NOT be freed - its static.- Parameters:
addressHolder- the base address.
-
AbstractNativeMemory
public AbstractNativeMemory(AbstractNativeMemory parent, long offset, long sizeInBytes)
Creates a new memory which will be freed at the end of life.- Parameters:
sizeInBytes-
-
-
Method Detail
-
toNativeAddressHolder
public static <T extends AbstractNativeMemory> NativeAddressHolder<T> toNativeAddressHolder(T value)
-
getSizeInBytes
public static final long getSizeInBytes(AbstractNativeMemory instance)
Get the size in bytes if instance. Wrap instance.getSizeInBytes() - so the namespace of instanes of AbstractNativeMemory is not pollutet.- Parameters:
instance- the instance.- Returns:
- the instance.getSizeInBytes() .
-
toUintptr_t
public static final long toUintptr_t(AbstractNativeMemory instance)
-
toUintptr_tOrNULL
public static final long toUintptr_tOrNULL(AbstractNativeMemory instance)
-
offsetof
public static long offsetof(AbstractNativeMemory member)
Get the offset of member to direct parent.- Parameters:
member- the direct member of parent.- Returns:
- the offset om menber in its parent.
-
calcOffsetForAlignment
public static long calcOffsetForAlignment(AbstractNativeMemory mem, Alignment structAlignment, long startOffset)
Neede for calculating baseaddress of onTheFlyint8_t data0; struct onTheFly { int64_t first };- Parameters:
mem- the mem to put datat0 and onTheFlystructAlignment- the alignment of onTheFly here ist will be 8 byte from int64_tstartOffset- the offset in mem where you intend to place onTheFly- Returns:
- the aligned offset
-
isSameAddress
public static boolean isSameAddress(NativeAddressHolder nativeAddress, AbstractNativeMemory om)
test if adresses are the same. If either nativeAddress or om is null and the other has a address of 0 it is considered as the same address.- Parameters:
nativeAddress-om-- Returns:
-
getOffset
protected final long getOffset()
calc the offset- Returns:
-
getSizeInBytes
protected abstract long getSizeInBytes()
-
-