summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/os
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-06-08 05:45:17 +0200
committerSven Gothel <[email protected]>2011-06-08 05:50:17 +0200
commita87c56c95099de5b6cbc9bd8bf6f1924a3dd6387 (patch)
tree0e5c81a4b3a2b136d50d827729dc727cd99d615c /src/java/com/jogamp/common/os
parent5de9de569622bc7baeee3a85b1ee5aa172830513 (diff)
Merged Locator -> IOUtil; int Platform.getPageSize(); Added unit test for IOUtil and Platform's page size
Diffstat (limited to 'src/java/com/jogamp/common/os')
-rw-r--r--src/java/com/jogamp/common/os/Platform.java18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java
index e31e123..0775f37 100644
--- a/src/java/com/jogamp/common/os/Platform.java
+++ b/src/java/com/jogamp/common/os/Platform.java
@@ -57,7 +57,7 @@ public class Platform {
private static final boolean is32Bit;
private static final int pointerSizeInBits;
- private static final long pageSize;
+ private static final int pageSize;
static {
@@ -84,7 +84,11 @@ public class Platform {
if(libsLoaded) {
pointerSizeInBits = getPointerSizeInBitsImpl();
- pageSize = getPageSizeImpl();
+ final long pageSizeL = getPageSizeImpl();
+ if(Integer.MAX_VALUE < pageSizeL) {
+ throw new InternalError("PageSize exceeds integer value: " + pageSizeL);
+ }
+ pageSize = (int) pageSizeL ;
}else{
pointerSizeInBits = -1;
pageSize = -1;
@@ -253,8 +257,16 @@ public class Platform {
return pointerSizeInBits/8;
}
- public static long getPageSize() {
+ public static int getPageSize() {
return pageSize;
}
+
+ public static int getPageNumber(int size) {
+ return ( size + ( pageSize - 1) ) / pageSize ; // integer arithmetic
+ }
+
+ public static int getPageAlignedSize(int size) {
+ return getPageNumber(size) * pageSize;
+ }
}