Top Description Inners Fields Constructors Methods
com.kenai.jffi

public abstract Class PageManager

extends Object
Class Inheritance
Known Direct Subclasses
com.kenai.jffi.PageManager.Unix, com.kenai.jffi.PageManager.Windows

Manages allocation, disposal and protection of native memory pages

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final Foreign
private int
public static final int
PROT_EXEC

The memory should be executable

public static final int
PROT_READ

The memory should be readable

public static final int
PROT_WRITE

The memory should be writable

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract long

Returns:

The native address of the allocated memory.
allocatePages
(int
The number of pages to allocate.
npages
,
int
The initial protection for the page. This must be a bitmask of PROT_READ, PROT_WRITE and PROT_EXEC.
protection
)

Allocates native memory pages.

private long
public abstract void
freePages(long
The memory address as returned from allocatePages
address
,
int
The number of pages to free.
npages
)

Free pages allocated via allocatePages

public static PageManager

Returns:

An instance of PageManager
getInstance
()

Gets the page manager for the current platform.

public final long

Returns:

The size of a page on the current system, in bytes.
pageSize
()

Gets the system page size.

public abstract void
protectPages(long
The start of the memory region.
address
,
int
The number of pages to protect.
npages
,
int
The protection mask.
protection
)

Sets the protection mask on a memory region.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

foreignback to summary
private final Foreign foreign
Annotations
@SuppressWarnings:UnusedDeclaration
pageSizeback to summary
private int pageSize
PROT_EXECback to summary
public static final int PROT_EXEC

The memory should be executable

PROT_READback to summary
public static final int PROT_READ

The memory should be readable

PROT_WRITEback to summary
public static final int PROT_WRITE

The memory should be writable

Constructor Detail

PageManagerback to summary
public PageManager()

Method Detail

allocatePagesback to summary
public abstract long allocatePages(int npages, int protection)

Allocates native memory pages. The memory allocated is aligned on a page boundary, and the size of the allocated memory is npages * pageSize.

Parameters
npages:int

The number of pages to allocate.

protection:int

The initial protection for the page. This must be a bitmask of PROT_READ, PROT_WRITE and PROT_EXEC.

Returns:long

The native address of the allocated memory.

calculatePageSizeback to summary
private long calculatePageSize()
freePagesback to summary
public abstract void freePages(long address, int npages)

Free pages allocated via allocatePages

Parameters
address:long

The memory address as returned from allocatePages

npages:int

The number of pages to free.

getInstanceback to summary
public static PageManager getInstance()

Gets the page manager for the current platform.

Returns:PageManager

An instance of PageManager

pageSizeback to summary
public final long pageSize()

Gets the system page size.

Returns:long

The size of a page on the current system, in bytes.

protectPagesback to summary
public abstract void protectPages(long address, int npages, int protection)

Sets the protection mask on a memory region.

Parameters
address:long

The start of the memory region.

npages:int

The number of pages to protect.

protection:int

The protection mask.

com.kenai.jffi back to summary

private final Class PageManager.SingletonHolder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final PageManager

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
public static final PageManager INSTANCE

Constructor Detail

SingletonHolderback to summary
private SingletonHolder()
com.kenai.jffi back to summary

pack-priv final Class PageManager.Unix

extends PageManager
Class Inheritance

Field Summary

Inherited from com.kenai.jffi.PageManager:
PROT_EXECPROT_READPROT_WRITE

Constructor Summary

AccessConstructor and Description
pack-priv
Unix()

Method Summary

Modifier and TypeMethod and Description
public long
allocatePages(int
The number of pages to allocate.
npages
,
int
The initial protection for the page. This must be a bitmask of PROT_READ, PROT_WRITE and PROT_EXEC.
protection
)

Implements abstract com.kenai.jffi.PageManager.allocatePages.

Allocates native memory pages.
public void
freePages(long
The memory address as returned from allocatePages
address
,
int
The number of pages to free.
npages
)

Implements abstract com.kenai.jffi.PageManager.freePages.

Free pages allocated via allocatePages
public void
protectPages(long
The start of the memory region.
address
,
int
The number of pages to protect.
npages
,
int
The protection mask.
protection
)

Implements abstract com.kenai.jffi.PageManager.protectPages.

Sets the protection mask on a memory region.
Inherited from com.kenai.jffi.PageManager:
getInstancepageSize

Constructor Detail

Unixback to summary
pack-priv Unix()

Method Detail

allocatePagesback to summary
public long allocatePages(int npages, int protection)

Implements abstract com.kenai.jffi.PageManager.allocatePages.

Doc from com.kenai.jffi.PageManager.allocatePages.

Allocates native memory pages. The memory allocated is aligned on a page boundary, and the size of the allocated memory is npages * pageSize.

Parameters
npages:int

The number of pages to allocate.

protection:int

The initial protection for the page. This must be a bitmask of PROT_READ, PROT_WRITE and PROT_EXEC.

Returns:long

The native address of the allocated memory.

Annotations
@Override
freePagesback to summary
public void freePages(long address, int npages)

Implements abstract com.kenai.jffi.PageManager.freePages.

Doc from com.kenai.jffi.PageManager.freePages.

Free pages allocated via allocatePages

Parameters
address:long

The memory address as returned from allocatePages

npages:int

The number of pages to free.

Annotations
@Override
protectPagesback to summary
public void protectPages(long address, int npages, int protection)

Implements abstract com.kenai.jffi.PageManager.protectPages.

Doc from com.kenai.jffi.PageManager.protectPages.

Sets the protection mask on a memory region.

Parameters
address:long

The start of the memory region.

npages:int

The number of pages to protect.

protection:int

The protection mask.

Annotations
@Override
com.kenai.jffi back to summary

pack-priv final Class PageManager.Windows

extends PageManager
Class Inheritance

Field Summary

Inherited from com.kenai.jffi.PageManager:
PROT_EXECPROT_READPROT_WRITE

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public long
allocatePages(int
The number of pages to allocate.
pageCount
,
int
The initial protection for the page. This must be a bitmask of PROT_READ, PROT_WRITE and PROT_EXEC.
protection
)

Implements abstract com.kenai.jffi.PageManager.allocatePages.

Allocates native memory pages.
public void
freePages(long
The memory address as returned from allocatePages
address
,
int
The number of pages to free.
pageCount
)

Implements abstract com.kenai.jffi.PageManager.freePages.

Free pages allocated via allocatePages
public void
protectPages(long
The start of the memory region.
address
,
int
The number of pages to protect.
pageCount
,
int
The protection mask.
protection
)

Implements abstract com.kenai.jffi.PageManager.protectPages.

Sets the protection mask on a memory region.
private static int
w32prot(int p)

Inherited from com.kenai.jffi.PageManager:
getInstancepageSize

Constructor Detail

Windowsback to summary
public Windows()

Method Detail

allocatePagesback to summary
public long allocatePages(int pageCount, int protection)

Implements abstract com.kenai.jffi.PageManager.allocatePages.

Doc from com.kenai.jffi.PageManager.allocatePages.

Allocates native memory pages. The memory allocated is aligned on a page boundary, and the size of the allocated memory is npages * pageSize.

Parameters
pageCount:int

The number of pages to allocate.

protection:int

The initial protection for the page. This must be a bitmask of PROT_READ, PROT_WRITE and PROT_EXEC.

Returns:long

The native address of the allocated memory.

Annotations
@Override
freePagesback to summary
public void freePages(long address, int pageCount)

Implements abstract com.kenai.jffi.PageManager.freePages.

Doc from com.kenai.jffi.PageManager.freePages.

Free pages allocated via allocatePages

Parameters
address:long

The memory address as returned from allocatePages

pageCount:int

The number of pages to free.

Annotations
@Override
protectPagesback to summary
public void protectPages(long address, int pageCount, int protection)

Implements abstract com.kenai.jffi.PageManager.protectPages.

Doc from com.kenai.jffi.PageManager.protectPages.

Sets the protection mask on a memory region.

Parameters
address:long

The start of the memory region.

pageCount:int

The number of pages to protect.

protection:int

The protection mask.

Annotations
@Override
w32protback to summary
private static int w32prot(int p)