imported Iakin's public domain jcpuid library allowing the detection of CPU types from java
imported Iakin's modifications to jbigi to use the jcpuid library in detecting what jbigi implementation to load imported and slightly updated Iakin's scripts to build jbigi for lots of architectures (yay iakin!)
This commit is contained in:
52
core/c/jcpuid/build.sh
Normal file
52
core/c/jcpuid/build.sh
Normal file
@ -0,0 +1,52 @@
|
||||
#/bin/sh
|
||||
|
||||
case `uname -sr` in
|
||||
MINGW*)
|
||||
echo "Building windows .dll's";;
|
||||
CYGWIN*)
|
||||
echo "Building windows .dll's";;
|
||||
Linux*)
|
||||
echo "Building linux .so's";;
|
||||
FreeBSD*)
|
||||
echo "Building freebsd .so's";;
|
||||
*)
|
||||
echo "Unsupported build environment"
|
||||
exit;;
|
||||
esac
|
||||
|
||||
rm -rf lib
|
||||
mkdir lib
|
||||
mkdir lib/freenet
|
||||
mkdir lib/freenet/support
|
||||
mkdir lib/freenet/support/CPUInformation
|
||||
|
||||
CPP="g++"
|
||||
|
||||
case `uname -sr` in
|
||||
MINGW*)
|
||||
JAVA_HOME="/c/software/j2sdk1.4.2_05"
|
||||
COMPILEFLAGS="-Wall"
|
||||
INCLUDES="-I. -Iinclude -I$JAVA_HOME/include/ -I$JAVA_HOME/include/win32/"
|
||||
LINKFLAGS="-shared -static -static-libgcc -Wl,--kill-at"
|
||||
LIBFILE="lib/freenet/support/CPUInformation/jcpuid-x86-windows.dll";;
|
||||
FreeBSD*)
|
||||
COMPILEFLAGS="-Wall"
|
||||
INCLUDES="-I. -Iinclude -I$JAVA_HOME/include/ -I$JAVA_HOME/include/freebsd/"
|
||||
LINKFLAGS="-shared -static -static-libgcc -Wl,-soname,libjcpuid-x86-freebsd.so"
|
||||
LIBFILE="lib/freenet/support/CPUInformation/libjcpuid-x86-freebsd.so";;
|
||||
Linux*)
|
||||
COMPILEFLAGS="-fPIC -Wall"
|
||||
INCLUDES="-I. -Iinclude -I$JAVA_HOME/include -I$JAVA_HOME/include/linux"
|
||||
LINKFLAGS="-shared -static -static-libgcc -Wl,-soname,libjcpuid-x86-linux.so"
|
||||
LIBFILE="lib/freenet/support/CPUInformation/libjcpuid-x86-linux.so";;
|
||||
esac
|
||||
|
||||
echo "Compiling C code..."
|
||||
rm -f $LIBFILE
|
||||
$CPP $LINKFLAGS $INCLUDES src/*.cpp -o $LIBFILE
|
||||
strip $LIBFILE
|
||||
echo Built $LIBFILE
|
||||
|
||||
#g++ -shared -static -static-libgcc -Iinclude -I$JAVA_HOME/include \
|
||||
# -I$JAVA_HOME/include/linux src/*.cpp \
|
||||
# -o lib/freenet/support/CPUInformation/libjcpuid-x86-linux.so
|
21
core/c/jcpuid/include/jcpuid.h
Normal file
21
core/c/jcpuid/include/jcpuid.h
Normal file
@ -0,0 +1,21 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class freenet_support_CPUInformation_CPUID */
|
||||
|
||||
#ifndef _Included_freenet_support_CPUInformation_CPUID
|
||||
#define _Included_freenet_support_CPUInformation_CPUID
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: freenet_support_CPUInformation_CPUID
|
||||
* Method: doCPUID
|
||||
* Signature: (I)Lfreenet/support/CPUInformation/CPUID$CPUIDResult;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_freenet_support_CPUInformation_CPUID_doCPUID
|
||||
(JNIEnv *, jclass, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
2
core/c/jcpuid/msvc/IMPORTANT.txt
Normal file
2
core/c/jcpuid/msvc/IMPORTANT.txt
Normal file
@ -0,0 +1,2 @@
|
||||
You will need to rename the 'cpuinformation' par of the output folder '..\lib\freenet\support\cpuinformation' to 'CPUInformation' before importing the files to a .jar.
|
||||
Unfortunately MSVC doesn't respect the casing of the entered output folder.
|
24
core/c/jcpuid/msvc/jcpuid.sln
Normal file
24
core/c/jcpuid/msvc/jcpuid.sln
Normal file
@ -0,0 +1,24 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jcpuid", "jcpuid.vcproj", "{161B6AD9-3825-4BA5-893D-D90B09846849}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
|
||||
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{161B6AD9-3825-4BA5-893D-D90B09846849}.Debug.ActiveCfg = Debug|Win32
|
||||
{161B6AD9-3825-4BA5-893D-D90B09846849}.Debug.Build.0 = Debug|Win32
|
||||
{161B6AD9-3825-4BA5-893D-D90B09846849}.Release.ActiveCfg = Release|Win32
|
||||
{161B6AD9-3825-4BA5-893D-D90B09846849}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
BIN
core/c/jcpuid/msvc/jcpuid.suo
Normal file
BIN
core/c/jcpuid/msvc/jcpuid.suo
Normal file
Binary file not shown.
139
core/c/jcpuid/msvc/jcpuid.vcproj
Normal file
139
core/c/jcpuid/msvc/jcpuid.vcproj
Normal file
@ -0,0 +1,139 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="jcpuid"
|
||||
ProjectGUID="{161B6AD9-3825-4BA5-893D-D90B09846849}"
|
||||
RootNamespace="jcpuid"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="..\lib\freenet\support\CPUInformation"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;jcpuid_EXPORTS"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/jcpuid-x86-windows.dll"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/jcpuid.pdb"
|
||||
SubSystem="2"
|
||||
ImportLibrary="$(OutDir)/jcpuid.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="..\lib\freenet\support\CPUInformation"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""$(SolutionDir)\..\include""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;jcpuid_EXPORTS"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/jcpuid-x86-windows.dll"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
ImportLibrary="$(OutDir)/jcpuid.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath="..\src\jcpuid.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
<File
|
||||
RelativePath="..\include\jcpuid.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
35
core/c/jcpuid/src/jcpuid.cpp
Normal file
35
core/c/jcpuid/src/jcpuid.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include "jcpuid.h"
|
||||
|
||||
//Executes the indicated subfunction of the CPUID operation
|
||||
JNIEXPORT jobject JNICALL Java_freenet_support_CPUInformation_CPUID_doCPUID
|
||||
(JNIEnv * env, jclass cls, jint iFunction)
|
||||
{
|
||||
int a,b,c,d;
|
||||
jclass clsResult = env->FindClass ("freenet/support/CPUInformation/CPUID$CPUIDResult");
|
||||
jmethodID constructor = env->GetMethodID(clsResult,"<init>","(IIII)V" );
|
||||
#ifdef _MSC_VER
|
||||
//Use MSVC assembler notation
|
||||
_asm
|
||||
{
|
||||
mov eax, iFunction
|
||||
cpuid
|
||||
mov a, eax
|
||||
mov b, ebx
|
||||
mov c, ecx
|
||||
mov d, edx
|
||||
}
|
||||
#else
|
||||
//Use GCC assembler notation
|
||||
asm
|
||||
(
|
||||
"cpuid"
|
||||
: "=a" (a),
|
||||
"=b" (b),
|
||||
"=c"(c),
|
||||
"=d"(d)
|
||||
:"a"(iFunction)
|
||||
);
|
||||
#endif
|
||||
return env->NewObject(clsResult,constructor,a,b,c,d);
|
||||
}
|
||||
|
Reference in New Issue
Block a user