Possibly working code to cross-compile Windows native DLL. Whee!
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2559 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,49 @@
|
|||||||
|
#
|
||||||
|
# $Id: Makefile,v 1.1 2003/05/09 03:22:16 mdb Exp $
|
||||||
|
|
||||||
|
NAME=unsafe
|
||||||
|
|
||||||
|
#
|
||||||
|
# Executable definitions
|
||||||
|
|
||||||
|
CC=i586-mingw32msvc-gcc
|
||||||
|
RM=rm
|
||||||
|
CP=cp
|
||||||
|
MKDIR=mkdir
|
||||||
|
DLLWRAP=i586-mingw32msvc-dllwrap
|
||||||
|
#
|
||||||
|
# Directory definitions
|
||||||
|
|
||||||
|
ROOT=../../../../../../..
|
||||||
|
INSTALL_PATH=${ROOT}/dist/lib/i686-Windows
|
||||||
|
|
||||||
|
#
|
||||||
|
# Source files
|
||||||
|
|
||||||
|
SRCS = com_threerings_util_unsafe_Unsafe.c
|
||||||
|
OBJS = ${SRCS:.c=.o}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Parameter and file definitions
|
||||||
|
|
||||||
|
INCLUDES=
|
||||||
|
CFLAGS=-I.. -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux
|
||||||
|
|
||||||
|
LDFLAGS=-L/usr/X11R6/lib
|
||||||
|
LIBS=
|
||||||
|
TARGET=${NAME}.dll
|
||||||
|
INSTALL_TARGET=${INSTALL_PATH}/${TARGET}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Target definitions
|
||||||
|
|
||||||
|
all: ${INSTALL_TARGET}
|
||||||
|
|
||||||
|
${INSTALL_TARGET}: ${OBJS}
|
||||||
|
@${MKDIR} -p ${INSTALL_PATH}
|
||||||
|
${DLLWRAP} --output-def ${NAME}.def --add-stdcall-alias \
|
||||||
|
-o ${INSTALL_TARGET} -s ${OBJS}
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-${RM} ${OBJS}
|
||||||
|
-${RM} ${INSTALL_TARGET}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* $Id: com_threerings_util_unsafe_Unsafe.c,v 1.1 2003/05/09 03:22:16 mdb Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <jni.h>
|
||||||
|
#include <jvmpi.h>
|
||||||
|
|
||||||
|
#include "com_threerings_util_unsafe_Unsafe.h"
|
||||||
|
|
||||||
|
/* global jvmpi interface pointer */
|
||||||
|
static JVMPI_Interface* jvmpi;
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL
|
||||||
|
Java_com_threerings_util_unsafe_Unsafe_enableGC (JNIEnv* env, jclass clazz)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Reenabling GC.\n");
|
||||||
|
jvmpi->EnableGC();
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL
|
||||||
|
Java_com_threerings_util_unsafe_Unsafe_disableGC (JNIEnv* env, jclass clazz)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Disabling GC.\n");
|
||||||
|
jvmpi->DisableGC();
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL
|
||||||
|
Java_com_threerings_util_unsafe_Unsafe_nativeSleep (
|
||||||
|
JNIEnv* env, jclass clazz, jint millis)
|
||||||
|
{
|
||||||
|
/* not supported */
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user