diff options
Diffstat (limited to 'make')
-rwxr-xr-x | make/build.xml | 423 | ||||
-rwxr-xr-x | make/dynlink-macosx.cfg | 25 | ||||
-rwxr-xr-x | make/dynlink-unix-CustomJavaCode.java | 18 | ||||
-rwxr-xr-x | make/dynlink-unix.cfg | 22 | ||||
-rwxr-xr-x | make/dynlink-windows-CustomJavaCode.java | 11 | ||||
-rwxr-xr-x | make/dynlink-windows.cfg | 25 | ||||
-rwxr-xr-x | make/gluegen.properties | 12 | ||||
-rwxr-xr-x | make/stub_includes/macosx/dynamic-linker.h | 46 | ||||
-rwxr-xr-x | make/stub_includes/unix/dynamic-linker.h | 47 | ||||
-rwxr-xr-x | make/stub_includes/windows/dynamic-linker.h | 31 |
10 files changed, 660 insertions, 0 deletions
diff --git a/make/build.xml b/make/build.xml index ab538be..884c499 100755 --- a/make/build.xml +++ b/make/build.xml @@ -96,6 +96,425 @@ </antlr> </target> + <!-- Use GlueGen to generate the source code for the NativeLibrary + implementation. Note that to make the build process simpler (in + particular, the nightly builds) we do not do this every time we + run the build, but instead check in the generated sources to + the source tree. --> + + <property name="gluegen.root" value="../" /> + <import file="gluegen-cpptasks.xml" /> + <target name="generate.nativelibrary.sources" depends="init" > + <!-- Define the appropriate include paths --> + <dirset id="stub.includes.fileset.windows" dir="."> + <include name="stub_includes/windows/**" /> + </dirset> + <dirset id="stub.includes.fileset.unix" dir="."> + <include name="stub_includes/unix/**" /> + </dirset> + <dirset id="stub.includes.fileset.macosx" dir="."> + <include name="stub_includes/macosx/**" /> + </dirset> + <!-- Define the classpath we should use --> + <path id="gluegen.classpath" > + <pathelement location="${classes}" /> + <pathelement location="${antlr.jar}" /> + </path> + <!-- Define the GlueGen task we just built --> + <taskdef name="gluegen" classname="com.sun.gluegen.ant.GlueGenTask" + classpathref="gluegen.classpath" /> + + <!-- Execute it against all of the OSs' header files --> + <gluegen src="stub_includes/windows/dynamic-linker.h" + config="dynlink-windows.cfg" + includeRefId="stub.includes.fileset.windows" + emitter="com.sun.gluegen.JavaEmitter"> + <classpath refid="gluegen.classpath" /> + </gluegen> + <gluegen src="stub_includes/unix/dynamic-linker.h" + config="dynlink-unix.cfg" + includeRefId="stub.includes.fileset.unix" + emitter="com.sun.gluegen.JavaEmitter"> + <classpath refid="gluegen.classpath" /> + </gluegen> + <gluegen src="stub_includes/macosx/dynamic-linker.h" + config="dynlink-macosx.cfg" + includeRefId="stub.includes.fileset.macosx" + emitter="com.sun.gluegen.JavaEmitter"> + <classpath refid="gluegen.classpath" /> + </gluegen> + </target> + + <!-- ================================================================== --> + <!-- + - Set up java.home.dir appropriately on all platforms. + --> + <target name="setup.java.home.dir.nonmacosx" depends="load.user.properties" unless="isOSX"> + <!-- java home dir is up one directory as java.home points to '<java-install-dir>/jre' --> + <property name="java.home.dir" value="${java.home}/.." /> + </target> + <target name="setup.java.home.dir.macosx" depends="load.user.properties" if="isOSX"> + <property name="java.home.dir" value="/System/Library/Frameworks/JavaVM.framework/Home" /> + </target> + <target name="setup.java.home.dir" depends="setup.java.home.dir.nonmacosx,setup.java.home.dir.macosx" > + <property name="java.includes.dir" value="${java.home.dir}/include" /> + </target> + + <!-- ================================================================== --> + <!-- + - Compile the native C code for GlueGen's dynamic linker interface. + --> + + <target name="declare.win32.vc6" if="isVC6"> + <echo message="Win32.VC6" /> + <property name="compiler.cfg.id" value="compiler.cfg.win32.msvc" /> + <property name="linker.cfg.id" value="linker.cfg.win32.msvc" /> + <property name="gluegen.rt.natives.jar" value="gluegen-rt-natives-windows-i586.jar" /> + </target> + + <target name="declare.win32.vc7" if="isVC7"> + <echo message="Win32.VC7" /> + <property name="compiler.cfg.id" value="compiler.cfg.win32.msvc" /> + <property name="linker.cfg.id" value="linker.cfg.win32.msvc" /> + <property name="gluegen.rt.natives.jar" value="gluegen-rt-natives-windows-i586.jar" /> + </target> + + <target name="declare.win32.vc8" if="isVC8"> + <echo message="Win32.VC8" /> + <property name="compiler.cfg.id" value="compiler.cfg.win32.msvc" /> + <property name="linker.cfg.id" value="linker.cfg.win32.msvc" /> + <property name="gluegen.rt.natives.jar" value="gluegen-rt-natives-windows-i586.jar" /> + </target> + + <target name="declare.win32.vc8_x64" if="isVC8_X64"> + <echo message="Win32.VC8_X64" /> + <property name="compiler.cfg.id" value="compiler.cfg.win32.msvc" /> + <property name="linker.cfg.id" value="linker.cfg.win32.msvc" /> + <property name="gluegen.rt.natives.jar" value="gluegen-rt-natives-windows-amd64.jar" /> + </target> + + <target name="declare.win32.mingw" if="isMingW"> + <echo message="Win32.MingW" /> + <property name="compiler.cfg.id" value="compiler.cfg.win32.mingw" /> + <property name="linker.cfg.id" value="linker.cfg.win32.mingw" /> + <property name="gluegen.rt.natives.jar" value="gluegen-rt-natives-windows-i586.jar" /> + </target> + + <target name="declare.win32" depends="declare.win32.vc6,declare.win32.vc7,declare.win32.vc8,declare.win32.vc8_x64,declare.win32.mingw" if="isWindows" > + <property name="c.src.dir" value="windows" /> + <property name="java.includes.dir.platform" value="${java.includes.dir}/win32" /> + <property name="gluegen.rt.natives.dso" value="gluegen-rt.dll" /> + </target> + + <target name="declare.linux.x86" if="isLinuxX86"> + <echo message="Linux.x86" /> + <property name="compiler.cfg.id" value="compiler.cfg.linux" /> + <property name="linker.cfg.id" value="linker.cfg.linux" /> + <property name="gluegen.rt.natives.jar" value="gluegen-rt-natives-linux-i586.jar" /> + </target> + + <target name="declare.linux.amd64" if="isLinuxAMD64"> + <echo message="Linux.AMD64" /> + <property name="compiler.cfg.id" value="compiler.cfg.linux.amd64" /> + <property name="linker.cfg.id" value="linker.cfg.linux.amd64" /> + <property name="gluegen.rt.natives.jar" value="gluegen-rt-natives-linux-amd64.jar" /> + </target> + + <target name="declare.linux.ia64" if="isLinuxIA64"> + <echo message="Linux.IA64" /> + <property name="compiler.cfg.id" value="compiler.cfg.linux" /> + <property name="linker.cfg.id" value="linker.cfg.linux" /> + <property name="gluegen.rt.natives.jar" value="gluegen-rt-natives-linux-ia64.jar" /> + </target> + + <target name="declare.linux" depends="declare.linux.x86,declare.linux.amd64,declare.linux.ia64" if="isLinux" > + <property name="c.src.dir" value="unix" /> + <property name="java.includes.dir.platform" value="${java.includes.dir}/linux" /> + <property name="gluegen.rt.natives.dso" value="libgluegen-rt.so" /> + </target> + + <target name="declare.solaris32" if="isSolaris32Bit"> + <echo message="Solaris" /> + <property name="compiler.cfg.id" value="compiler.cfg.solaris" /> + <property name="linker.cfg.id" value="linker.cfg.solaris" /> + <property name="gluegen.rt.natives.jar" value="gluegen-rt-natives-solaris-${os.arch}.jar" /> + </target> + + <target name="declare.solarisSparcv9" if="isSolarisSparcv9"> + <echo message="SolarisSparcv9" /> + <property name="compiler.cfg.id" value="compiler.cfg.solarisSparcv9" /> + <property name="linker.cfg.id" value="linker.cfg.solarisSparcv9" /> + <property name="gluegen.rt.natives.jar" value="gluegen-rt-natives-solaris-sparcv9.jar" /> + </target> + + <target name="declare.solarisAMD64" if="isSolarisAMD64"> + <echo message="SolarisAMD64" /> + <property name="compiler.cfg.id" value="compiler.cfg.solarisAMD64" /> + <property name="linker.cfg.id" value="linker.cfg.solarisAMD64" /> + <property name="gluegen.rt.natives.jar" value="gluegen-rt-natives-solaris-amd64.jar" /> + </target> + + <target name="declare.solaris" depends="declare.solaris32,declare.solarisSparcv9,declare.solarisAMD64" if="isSolaris" > + <property name="c.src.dir" value="unix" /> + <property name="java.includes.dir.platform" value="${java.includes.dir}/solaris" /> + <property name="gluegen.rt.natives.dso" value="libgluegen-rt.so" /> + </target> + + <target name="declare.macosx.ppc" unless="macosxfat"> + <property name="gluegen.rt.natives.jar" value="gluegen-rt-natives-macosx-ppc.jar" /> + </target> + + <target name="declare.macosx.universal" if="macosxfat"> + <property name="gluegen.rt.natives.jar" value="gluegen-rt-natives-macosx-universal.jar" /> + </target> + + <target name="declare.macosx" depends="declare.macosx.ppc,declare.macosx.universal" if="isOSX"> + <echo message="MacOSX" /> + <property name="compiler.cfg.id" value="compiler.cfg.macosx" /> + <property name="linker.cfg.id" value="linker.cfg.macosx" /> + <property name="c.src.dir" value="macosx" /> + <property name="java.includes.dir.platform" value="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Headers" /> + <property name="gluegen.rt.natives.dso" value="libgluegen-rt.jnilib" /> + </target> + + <target name="declare.freebsd" if="isFreeBSD"> + <echo message="FreeBSD" /> + <property name="compiler.cfg.id" value="compiler.cfg.freebsd" /> + <property name="linker.cfg.id" value="linker.cfg.linux" /> + <property name="c.src.dir" value="unix" /> + <property name="java.includes.dir.freebsd" value="${java.includes.dir}/freebsd" /> + <property name="gluegen.rt.natives.jar" value="gluegen-rt-natives-freebsd-i586.jar" /> + <property name="gluegen.rt.natives.dso" value="libgluegen-rt.so" /> + </target> + + <target name="declare.hpux" if="isHPUX"> + <echo message="HP-UX" /> + <property name="compiler.cfg.id" value="compiler.cfg.hpux" /> + <property name="linker.cfg.id" value="linker.cfg.hpux" /> + <property name="c.src.dir" value="unix" /> + <property name="java.includes.dir.hpux" value="${java.includes.dir}/hp-ux" /> + <property name="gluegen.rt.natives.jar" value="gluegen-rt-natives-hpux-hppa.jar" /> + <property name="gluegen.rt.natives.dso" value="libgluegen-rt.so" /> + </target> + + <target name="c.configure" depends="gluegen.cpptasks.detect.os,gluegen.cpptasks.detect.compiler,setup.java.home.dir,declare.win32,declare.linux,declare.solaris,declare.macosx,declare.freebsd,declare.hpux" unless="build.javaonly" > + <!-- compiler configuration --> + <compiler id="compiler.cfg.linux" name="gcc" /> + + <compiler id="compiler.cfg.linux.amd64" name="gcc"> + <compilerarg value="-fPIC"/> + </compiler> + + <compiler id="compiler.cfg.solaris" name="suncc"> + </compiler> + + <compiler id="compiler.cfg.solarisSparcv9" name="suncc"> + <compilerarg value="-fast" /> + <compilerarg value="-xchip=ultra" /> + <compilerarg value="-xarch=v9a" /> + <compilerarg value="-xcode=32" /> + </compiler> + + <compiler id="compiler.cfg.solarisAMD64" name="suncc"> + <compilerarg value="-fast" /> + <compilerarg value="-xchip=opteron" /> + <compilerarg value="-xarch=amd64" /> + <!-- <compilerarg value="-xcache=64/64/2:1024/64/16" /> --> + </compiler> + + <compiler id="compiler.cfg.win32.mingw" name="gcc"> + <defineset> + <define name="_DEBUG" if="c.compiler.use-debug"/> + <define name="DEBUG" if="c.compiler.use-debug"/> + <define name="NDEBUG" unless="c.compiler.use-debug"/> + + <define name="DBUILD_DLL" /> + <define name="_WINGDI_" /> + <define name="_STRICT_ANSI" /> + <define name="_JNI_IMPLEMENTATION_" /> + </defineset> + </compiler> + + <compiler id="compiler.cfg.win32.msvc" name="msvc"> + <compilerarg value="/W3"/> <!-- set warning level --> + <compilerarg value="/Ob1"/> <!-- inline only functions marked inline --> + <compilerarg value="/GF"/> <!-- enable string pooling --> + <compilerarg value="/Gy"/> <!-- enable function level linking --> + <compilerarg value="/GS" if="isVC7"/> <!-- buffer security checks --> + <compilerarg value="/Wp64" if="isVC7"/> <!-- detect 64-bit port problems --> + <compilerarg value="/RTCcsu" if="isVC7"/> <!-- various runtime checks --> + <!-- Note: previous compiler options for VC7 were: + Debug: /MDd /Yd /GS /RTCs /RTCu /RTCc /W3 /Od /GF /EHsc /Zi /GS /Gy /Wp64 /Zi /D "_DEBUG" + Optimized: /MD /W3 /O2 /Ob1 /GF /EHsc /GS /Gy /Wp64 /D "NDEBUG" --> + <compilerarg value="/GS" if="isVC8"/> <!-- buffer security checks --> + <compilerarg value="/Wp64" if="isVC8"/> <!-- detect 64-bit port problems --> + <compilerarg value="/RTCcsu" if="isVC8"/> <!-- various runtime checks --> + + <defineset> + <define name="_DEBUG" if="c.compiler.use-debug"/> + <define name="DEBUG" if="c.compiler.use-debug"/> + <define name="NDEBUG" unless="c.compiler.use-debug"/> + </defineset> + </compiler> + + <compiler id="compiler.cfg.macosx" name="gcc"> + <compilerarg value="-arch" if="macosxfat"/> + <compilerarg value="ppc" if="macosxfat"/> + <compilerarg value="-arch" if="macosxfat"/> + <compilerarg value="i386" if="macosxfat"/> + <compilerarg value="-Wmost" /> + <compilerarg value="-ObjC" /> + <defineset> + <define name="macosx" /> + </defineset> + </compiler> + + <compiler id="compiler.cfg.freebsd" name="gcc" /> + + <compiler id="compiler.cfg.hpux" name="aCC"> + <!-- Interpret source as ANSI C89 (not C++) --> + <compilerarg value="-Ae"/> + <!-- Dereferences are performed with four-byte loads and stores. --> + <compilerarg value="+u4"/> + <!-- Suppress warnings: + 942: signed/unsigned assignment compatibility + 129: redeclarations in stub_includes --> + <compilerarg value="+W942,129"/> + <defineset> + <!-- aCC doesn't seem to define a generic system macro, a la + "__sun". The documentation claims it defines the following, + but don't seem to work: __HP_aCC, __LP64__, __RISC_0__. + HP-UX docs on JNI say to use the defs below + (http://www.hp.com/products1/unix/java/infolibrary/prog_guide/JNI_java2.html) --> + <!-- Single underscore prefix, as recommended by aCC docs... --> + <define name="_HPUX"/> + <define name="_POSIX_C_SOURCE" value="199506L"/> + </defineset> + </compiler> + + <!-- linker configuration --> + + <linker id="linker.cfg.linux" name="gcc" /> + + <linker id="linker.cfg.linux.amd64" name="gcc" /> + + <linker id="linker.cfg.solaris" name="suncc" /> + + <linker id="linker.cfg.solarisSparcv9" name="suncc"> + <linkerarg value="-xarch=v9a" /> + </linker> + + <linker id="linker.cfg.solarisAMD64" name="suncc"> + <linkerarg value="-xarch=amd64" /> + </linker> + + <linker id="linker.cfg.win32.mingw" name="gcc" incremental="false"> + <linkerarg value="-Wl,--kill-at" /> <!-- remove @ from function names --> + </linker> + + <linker id="linker.cfg.win32.msvc" name="msvc" incremental="false"> + <linkerarg value="/OPT:REF,ICF" /> <!-- enable link-time optimisations --> + <linkerarg value="/SUBSYSTEM:WINDOWS" /> <!-- output is not a console app as uses WinMain entry point --> + <linkerarg value="/MACHINE:X86" if="isVC6" /> <!-- explicity set target platform --> + <linkerarg value="/MACHINE:X86" if="isVC7" /> <!-- explicity set target platform --> + <linkerarg value="/MACHINE:X86" if="isVC8" /> <!-- explicity set target platform --> + <linkerarg value="/MACHINE:X64" if="isVC8_X64"/> <!-- explicity set target platform (IX64) --> + </linker> + + <linker id="linker.cfg.macosx" name="gcc"> + <linkerarg value="-arch" if="macosxfat"/> + <linkerarg value="ppc" if="macosxfat"/> + <linkerarg value="-arch" if="macosxfat"/> + <linkerarg value="i386" if="macosxfat"/> + </linker> + + <linker id="linker.cfg.hpux" name="aCC" /> + + <!-- Common properties --> + <property name="java.includes.dir" value="${java.home.dir}/include" /> <!-- NOTE: this MUST be relative for FileSet --> + + <property name="c.compiler.src.files" value="src/native/${c.src.dir}/*.c" /> + + <property name="output.lib.name" value="gluegen-rt" /> + </target> + + <target name="c.rename.lib.mingw" if="isMingW"> + <!-- FIXME: this is a hack; the cpptask should have an option to change the + suffix or at least understand the override from .so to .dll --> + <move file="../build/obj/libgluegen-rt.so" tofile="../build/obj/gluegen-rt.dll" /> + </target> + + <target name="c.rename.lib.macosx" if="isOSX"> + <!-- FIXME: this is a hack; the cpptask should have an option to change the + suffix or at least understand the override from dylib to jnilib --> + <move file="../build/obj/libgluegen-rt.dylib" tofile="../build/obj/libgluegen-rt.jnilib" /> + </target> + + <target name="c.build" depends="c.configure" unless="build.javaonly" > + <fail message="Requires '${c.compiler.src.files}'" unless="c.compiler.src.files"/> + <fail message="Requires '${compiler.cfg.id}'" unless="compiler.cfg.id"/> + <fail message="Requires '${linker.cfg.id}'" unless="linker.cfg.id"/> + <fail message="Requires '${output.lib.name}'" unless="output.lib.name"/> + + <echo message="Output lib name = ${output.lib.name}" /> + + <!-- NOTE: the value of the debug and optimise attributes will not be overridden if already set externally --> + <property name="c.compiler.debug" value="false" /> + <!-- Optimise flags one of { none, size, speed, minimal, full, aggressive, extreme, unsafe } --> + <property name="c.compiler.optimise" value="none" /> + + <condition property="c.compiler.use-debug"><istrue value="${c.compiler.debug}"/></condition> + + <mkdir dir="../build/obj" /> + + <echo message="Compiling ${c.compiler.src.files}" /> + <echo message="user.dir=${user.dir}" /> + + <cc outtype="shared" + objdir="../build/obj" + outfile="../build/obj/${output.lib.name}" + optimize="${c.compiler.optimise}" + debug="${c.compiler.debug}" + multithreaded="true" + exceptions="false" + rtti="false"> + + <!-- TODO: versioninfo companyname="java.net" + legalcopyright="Copyright" + productname="GlueGen" + productversion="x.y.z" + description="Description" + fileversion="x.y.z" + filecomments="File Comment" /--> + + <fileset dir=".."> + <patternset> + <include name="${c.compiler.src.files}" /> + </patternset> + </fileset> + + <compiler extends="${compiler.cfg.id}" > + <sysincludepath path="${java.includes.dir}"/> + <sysincludepath path="${java.includes.dir.platform}"/> + </compiler> + + <linker extends="${linker.cfg.id}" /> + </cc> + + <antcall target="c.rename.lib.mingw" inheritRefs="true" /> + <antcall target="c.rename.lib.macosx" inheritRefs="true" /> + <!-- Create Java Web Start jar file from built file --> + <jar destfile="../build/${gluegen.rt.natives.jar}"> + <fileset dir="../build/obj"> + <include name="${gluegen.rt.natives.dso}" /> + </fileset> + </jar> + </target> + + <target name="build.nativelibrary" if="build.native" > + <antcall target="c.build" inheritRefs="true" /> + </target> + <!-- ================================================================== --> <!-- - Build GlueGen. @@ -146,6 +565,10 @@ <classpath refid="antlr.classpath" /> </javac> + <!-- Build the (native code) NativeLibrary support for + gluegen-rt.jar using the just-built GlueGen. --> + <antcall target="build.nativelibrary" inheritRefs="true" /> + <!-- Build gluegen.jar. --> <jar destfile="${build}/gluegen.jar" manifest="Manifest"> <fileset dir="${classes}"> diff --git a/make/dynlink-macosx.cfg b/make/dynlink-macosx.cfg new file mode 100755 index 0000000..8ba4c51 --- /dev/null +++ b/make/dynlink-macosx.cfg @@ -0,0 +1,25 @@ +Style AllStatic +JavaClass MacOSXDynamicLinkerImpl +Package com.sun.gluegen.runtime +Implements MacOSXDynamicLinkerImpl DynamicLinker +JavaOutputDir ../src/java +NativeOutputDir ../src/native/macosx +HierarchicalNativeOutput false + +# Note that we can use the same CustomJavaCode as the unix +# implementation, but some of the constants (e.g. RTLD_GLOBAL) resolve +# to different values +IncludeAs CustomJavaCode MacOSXDynamicLinkerImpl dynlink-unix-CustomJavaCode.java +CustomCCode #include <dlfcn.h> +CustomCCode #include </usr/include/machine/types.h> + +ArgumentIsString dlopen 0 +ArgumentIsString dlsym 1 +ReturnsString dlerror +Opaque long void* + +# Hide the platform-specific functions +AccessControl dlopen PRIVATE +AccessControl dlsym PRIVATE +AccessControl dlclose PRIVATE +AccessControl dlerror PRIVATE diff --git a/make/dynlink-unix-CustomJavaCode.java b/make/dynlink-unix-CustomJavaCode.java new file mode 100755 index 0000000..36a1603 --- /dev/null +++ b/make/dynlink-unix-CustomJavaCode.java @@ -0,0 +1,18 @@ +public long openLibrary(String pathname) { + // Note we use RTLD_GLOBAL visibility to allow this functionality to + // be used to pre-resolve dependent libraries of JNI code without + // requiring that all references to symbols in those libraries be + // looked up dynamically via the ProcAddressTable mechanism; in + // other words, one can actually link against the library instead of + // having to dlsym all entry points. System.loadLibrary() uses + // RTLD_LOCAL visibility so can't be used for this purpose. + return dlopen(pathname, RTLD_GLOBAL); +} + +public long lookupSymbol(long libraryHandle, String symbolName) { + return dlsym(libraryHandle, symbolName); +} + +public void closeLibrary(long libraryHandle) { + dlclose(libraryHandle); +} diff --git a/make/dynlink-unix.cfg b/make/dynlink-unix.cfg new file mode 100755 index 0000000..d762c8f --- /dev/null +++ b/make/dynlink-unix.cfg @@ -0,0 +1,22 @@ +Style AllStatic +JavaClass UnixDynamicLinkerImpl +Package com.sun.gluegen.runtime +Implements UnixDynamicLinkerImpl DynamicLinker +JavaOutputDir ../src/java +NativeOutputDir ../src/native/unix +HierarchicalNativeOutput false + +IncludeAs CustomJavaCode UnixDynamicLinkerImpl dynlink-unix-CustomJavaCode.java +CustomCCode #include <dlfcn.h> +CustomCCode #include <inttypes.h> + +ArgumentIsString dlopen 0 +ArgumentIsString dlsym 1 +ReturnsString dlerror +Opaque long void* + +# Hide the platform-specific functions +AccessControl dlopen PRIVATE +AccessControl dlsym PRIVATE +AccessControl dlclose PRIVATE +AccessControl dlerror PRIVATE diff --git a/make/dynlink-windows-CustomJavaCode.java b/make/dynlink-windows-CustomJavaCode.java new file mode 100755 index 0000000..986ec81 --- /dev/null +++ b/make/dynlink-windows-CustomJavaCode.java @@ -0,0 +1,11 @@ +public long openLibrary(String libraryName) { + return LoadLibraryA(libraryName); +} + +public long lookupSymbol(long libraryHandle, String symbolName) { + return GetProcAddress(libraryHandle, symbolName); +} + +public void closeLibrary(long libraryHandle) { + FreeLibrary(libraryHandle); +} diff --git a/make/dynlink-windows.cfg b/make/dynlink-windows.cfg new file mode 100755 index 0000000..871326e --- /dev/null +++ b/make/dynlink-windows.cfg @@ -0,0 +1,25 @@ +Style AllStatic +JavaClass WindowsDynamicLinkerImpl +Package com.sun.gluegen.runtime +Implements WindowsDynamicLinkerImpl DynamicLinker +JavaOutputDir ../src/java +NativeOutputDir ../src/native/windows +HierarchicalNativeOutput false + +IncludeAs CustomJavaCode WindowsDynamicLinkerImpl dynlink-windows-CustomJavaCode.java +CustomCCode #include <windows.h> +CustomCCode /* This typedef is only needed for VC6 */ +CustomCCode #if _MSC_VER <= 1200 +CustomCCode typedef int intptr_t; +CustomCCode #endif + +ArgumentIsString LoadLibraryA 0 +ArgumentIsString GetProcAddress 1 +Opaque long HANDLE +Opaque long PROC + +# Hide the platform-specific functions +AccessControl GetLastError PRIVATE +AccessControl LoadLibraryA PRIVATE +AccessControl GetProcAddress PRIVATE +AccessControl FreeLibrary PRIVATE diff --git a/make/gluegen.properties b/make/gluegen.properties index 9ca1f06..81aba60 100755 --- a/make/gluegen.properties +++ b/make/gluegen.properties @@ -15,3 +15,15 @@ antlr.jar=C:/Users/kbr/ANTLR/antlr-2.7.2/antlr.jar # antlr.jar=/Users/kbr/antlr-2.7.2/antlr.jar # Solaris # antlr.jar=/export/kbr/ANTLR/antlr-2.7.2/antlr.jar + +# If you are building the native code for the GlueGen run-time library +# on Windows and have the Microsoft Visual C++ compilers installed, +# you can choose an alternate compiler with which to build the native +# code. Valid strings here are "vc6", "vc7", "vc8", "vc8_x64", and +# "mingw". +win32.c.compiler=vc6 + +# If you are building the native code for the GlueGen run-time library +# on a Mac OS X system supporting cross-compilation and want to +# generate fat (PPC and x86) binaries, uncomment the property below +# macosxfat=true diff --git a/make/stub_includes/macosx/dynamic-linker.h b/make/stub_includes/macosx/dynamic-linker.h new file mode 100755 index 0000000..11afcdc --- /dev/null +++ b/make/stub_includes/macosx/dynamic-linker.h @@ -0,0 +1,46 @@ +/* Portions extracted from Mac OS X dlfcn.h */ + +/* + * Copyright (c) 2004-2005 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* + Based on the dlcompat work done by: + Jorge Acereda <[email protected]> & + Peter O'Gorman <[email protected]> +*/ + +extern int dlclose(void * __handle); +extern char * dlerror(void); +extern void * dlopen(const char * __path, int __mode); +extern void * dlsym(void * __handle, const char * __symbol); + +#define RTLD_LAZY 0x1 +#define RTLD_NOW 0x2 +#define RTLD_LOCAL 0x4 +#define RTLD_GLOBAL 0x8 + +/* + * Special handle arguments for dlsym(). + */ +#define RTLD_NEXT -1LL /* Search subsequent objects. */ +#define RTLD_DEFAULT -2LL /* Use default search algorithm. */ diff --git a/make/stub_includes/unix/dynamic-linker.h b/make/stub_includes/unix/dynamic-linker.h new file mode 100755 index 0000000..7071438 --- /dev/null +++ b/make/stub_includes/unix/dynamic-linker.h @@ -0,0 +1,47 @@ +/* Portions extracted from Solaris dlfcn.h */ + +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 1989 AT&T + * All Rights Reserved + * + */ + +/* + * Valid values for handle argument to dlsym(3x). + */ +#define RTLD_NEXT -1LL /* look in `next' dependency */ +#define RTLD_DEFAULT -2LL /* look up symbol from scope */ + /* of current object */ +#define RTLD_SELF -3LL /* look in `ourself' */ +#define RTLD_PROBE -4LL /* look up symbol from scope */ + /* of current object, */ + /* using currently */ + /* loaded objects only. */ + +/* + * Valid values for mode argument to dlopen. + */ +#define RTLD_LAZY 0x00001 /* deferred function binding */ +#define RTLD_NOW 0x00002 /* immediate function binding */ +#define RTLD_NOLOAD 0x00004 /* don't load object */ + +#define RTLD_GLOBAL 0x00100 /* export symbols to others */ +#define RTLD_LOCAL 0x00000 /* symbols are only available */ + /* to group members */ +#define RTLD_PARENT 0x00200 /* add parent (caller) to */ + /* a group dependencies */ +#define RTLD_GROUP 0x00400 /* resolve symbols within */ + /* members of the group */ +#define RTLD_WORLD 0x00800 /* resolve symbols within */ + /* global objects */ +#define RTLD_NODELETE 0x01000 /* do not remove members */ +#define RTLD_FIRST 0x02000 /* only first object is */ + /* available for dlsym */ + +extern void *dlopen(const char *, int); +extern void *dlsym(void *, const char *); +extern int dlclose(void *); +extern char *dlerror(void); diff --git a/make/stub_includes/windows/dynamic-linker.h b/make/stub_includes/windows/dynamic-linker.h new file mode 100755 index 0000000..e8a8bd5 --- /dev/null +++ b/make/stub_includes/windows/dynamic-linker.h @@ -0,0 +1,31 @@ +/* Windows #defines and typedefs required for processing of extracts + from WINDOWS.H */ + +#define FAR +#define WINBASEAPI +#define WINAPI +#define CONST const +#define VOID void +typedef int BOOL; +typedef unsigned char BYTE; +typedef unsigned int DWORD; +typedef int INT; +typedef int INT32; +typedef __int64 INT64; +typedef float FLOAT; +typedef struct _handle* HANDLE; +typedef HANDLE HMODULE; +typedef long LONG; +typedef const char* LPCSTR; +typedef void* LPVOID; +typedef struct _proc* PROC; +typedef unsigned int* PUINT; +typedef unsigned int UINT; +typedef unsigned short USHORT; +typedef unsigned short WORD; + +// Dynamic loading routines +WINBASEAPI DWORD WINAPI GetLastError(VOID); +WINBASEAPI HMODULE WINAPI LoadLibraryA(LPCSTR lpLibFileName); +WINBASEAPI PROC WINAPI GetProcAddress(HMODULE hModule, LPCSTR lpProcName); +WINBASEAPI BOOL WINAPI FreeLibrary(HMODULE hLibModule); |