From 132d4924cb191a0a16f9b42ccb718803c52b0295 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 7 Jun 2011 23:39:52 +0200 Subject: Platform: Add getPageSize() --- src/java/com/jogamp/common/os/Platform.java | 7 +++++++ src/native/common/Platform.c | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'src') diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java index 3bd9966..e31e123 100644 --- a/src/java/com/jogamp/common/os/Platform.java +++ b/src/java/com/jogamp/common/os/Platform.java @@ -57,6 +57,7 @@ public class Platform { private static final boolean is32Bit; private static final int pointerSizeInBits; + private static final long pageSize; static { @@ -83,8 +84,10 @@ public class Platform { if(libsLoaded) { pointerSizeInBits = getPointerSizeInBitsImpl(); + pageSize = getPageSizeImpl(); }else{ pointerSizeInBits = -1; + pageSize = -1; } is32Bit = initArch(); @@ -161,6 +164,7 @@ public class Platform { } private static native int getPointerSizeInBitsImpl(); + private static native long getPageSizeImpl(); /** @@ -249,5 +253,8 @@ public class Platform { return pointerSizeInBits/8; } + public static long getPageSize() { + return pageSize; + } } diff --git a/src/native/common/Platform.c b/src/native/common/Platform.c index f0e4e11..c385e12 100644 --- a/src/native/common/Platform.c +++ b/src/native/common/Platform.c @@ -3,8 +3,27 @@ #include +#include "com_jogamp_common_os_Platform.h" + +#if defined(_WIN32) + #include +#else /* assume POSIX sysconf() availability */ + #include +#endif + JNIEXPORT jint JNICALL Java_com_jogamp_common_os_Platform_getPointerSizeInBitsImpl(JNIEnv *env, jclass _unused) { return sizeof(void *) * 8; } +JNIEXPORT jlong JNICALL +Java_com_jogamp_common_os_Platform_getPageSizeImpl(JNIEnv *env, jclass _unused) { +#if defined(_WIN32) + SYSTEM_INFO si; + GetSystemInfo(&si); + return (jlong) si.dwPageSize; +#else + return (jlong) sysconf(_SC_PAGESIZE); +#endif +} + -- cgit v1.2.3