From fc284c2e581ff1a96cfaf975d33e50728ac47233 Mon Sep 17 00:00:00 2001 From: Landon Fuller Date: Tue, 19 Dec 2006 19:46:10 +0000 Subject: [PATCH] Let's use one copy of this identical code git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@102 ed5b42cb-e716-0410-a449-f6a68f950b19 --- .../Linux/com_threerings_util_unsafe_Unsafe.c | 98 +------------------ 1 file changed, 1 insertion(+), 97 deletions(-) mode change 100644 => 120000 src/java/com/threerings/util/unsafe/Linux/com_threerings_util_unsafe_Unsafe.c diff --git a/src/java/com/threerings/util/unsafe/Linux/com_threerings_util_unsafe_Unsafe.c b/src/java/com/threerings/util/unsafe/Linux/com_threerings_util_unsafe_Unsafe.c deleted file mode 100644 index 04ac0526..00000000 --- a/src/java/com/threerings/util/unsafe/Linux/com_threerings_util_unsafe_Unsafe.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * $Id: com_threerings_util_unsafe_Unsafe.c 3653 2005-07-21 19:10:08Z mdb $ - */ - -#include -#include -#include - -#include -#include -#include -#include - -#include "com_threerings_util_unsafe_Unsafe.h" - -/* global jvmpi interface pointer */ -static JVMPI_Interface* jvmpi; - -/** A sleep method that uses select(). This seems to have about 10ms - * granularity where nanosleep() has about 20ms. Sigh. */ -static int select_sleep (int millisecs) -{ - fd_set dummy; - struct timeval toWait; - FD_ZERO(&dummy); - toWait.tv_sec = millisecs / 1000; - toWait.tv_usec = (millisecs % 1000) * 1000; - return select(0, &dummy, NULL, NULL, &toWait); -} - -JNIEXPORT void JNICALL -Java_com_threerings_util_unsafe_Unsafe_enableGC (JNIEnv* env, jclass clazz) -{ - jvmpi->EnableGC(); -} - -JNIEXPORT void JNICALL -Java_com_threerings_util_unsafe_Unsafe_disableGC (JNIEnv* env, jclass clazz) -{ - jvmpi->DisableGC(); -} - -JNIEXPORT void JNICALL -Java_com_threerings_util_unsafe_Unsafe_nativeSleep ( - JNIEnv* env, jclass clazz, jint millis) -{ -/* struct timespec tmspec; */ -/* tmspec.tv_sec = millis/1000; */ -/* tmspec.tv_nsec = (millis%1000)*1000000; */ -/* if (nanosleep(&tmspec, NULL) < 0) { */ -/* fprintf(stderr, "nanosleep() failed: %s\n", strerror(errno)); */ -/* } */ - if (select_sleep(millis) < 0) { - fprintf(stderr, "select_sleep() failed: %s\n", strerror(errno)); - } -} - -JNIEXPORT jboolean JNICALL -Java_com_threerings_util_unsafe_Unsafe_nativeSetuid ( - JNIEnv* env, jclass clazz, jint uid) -{ - if (setuid((uid_t)uid) != 0) { - fprintf(stderr, "setuid(%d) failed: %s\n", uid, strerror(errno)); - return JNI_FALSE; - } - return JNI_TRUE; -} - -JNIEXPORT jboolean JNICALL -Java_com_threerings_util_unsafe_Unsafe_nativeSetgid ( - JNIEnv* env, jclass clazz, jint gid) -{ - if (setgid((gid_t)gid) != 0) { - fprintf(stderr, "setgid(%d) failed: %s\n", gid, strerror(errno)); - return JNI_FALSE; - } - return JNI_TRUE; -} - -JNIEXPORT jboolean JNICALL -Java_com_threerings_util_unsafe_Unsafe_init (JNIEnv* env, jclass clazz) -{ - JavaVM* jvm; - - if ((*env)->GetJavaVM(env, &jvm) > 0) { - fprintf(stderr, "Failed to get JavaVM from env.\n"); - return JNI_FALSE; - } - - /* get jvmpi interface pointer */ - if (((*jvm)->GetEnv(jvm, (void**)&jvmpi, JVMPI_VERSION_1)) < 0) { - fprintf(stderr, "Failed to get JVMPI from JavaVM.\n"); - return JNI_FALSE; - } - - return JNI_TRUE; -} diff --git a/src/java/com/threerings/util/unsafe/Linux/com_threerings_util_unsafe_Unsafe.c b/src/java/com/threerings/util/unsafe/Linux/com_threerings_util_unsafe_Unsafe.c new file mode 120000 index 00000000..f28bcf8e --- /dev/null +++ b/src/java/com/threerings/util/unsafe/Linux/com_threerings_util_unsafe_Unsafe.c @@ -0,0 +1 @@ +../FreeBSD/com_threerings_util_unsafe_Unsafe.c \ No newline at end of file