五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

基于Linux的JNI動態(tài)函數(shù)注冊

2020-10-09 17:16 作者:開源開發(fā)者  | 我要投稿



cmake_minimum_required(VERSION 3.2)


project(AlgorithmLibrary)


set(ProjectDir ${CMAKE_CURRENT_SOURCE_DIR})


set(LIBRARY_OUTPUT_PATH ${ProjectDir}/lib)


set(DynamicRegisterDir ${CMAKE_CURRENT_SOURCE_DIR}/DynamicRegister/)


include_directories(


? ? ./include /opt/jdk1.8.0_201/include/?


? ? ${DynamicRegisterDir}


? ? TimeComplexity/


? ? Test/


)


add_library(

? ??

? ? AlgorithmLibrary SHARED?


? ? ${DynamicRegisterDir}/DynamicRegisterMethod.cpp


? ? TimeComplexity/InstrucNumTime.cpp


? ? Test/Test.cpp


)

動態(tài)函數(shù)注冊核心代碼


#ifndef DynamicRegisterMethod

#define DynamicRegisterMethod

#include <Common.h>

#include <InstrucNumTime.h>

#include <Test.h>

#endif


#include <DynamicRegisterMethod.h>


using namespace std;


char* javaClass []? = {


? ? (char*)"com/ossit/demo01/App",


};


static JNINativeMethod getMethod[1][2] = {


? ? {

? ? ? ? {(char*)"printInstructionTime",(char*)"()V",(void*)printInstructionTime},

? ? ? ? {(char*)"test",(char*)"()V",(void*)test}

? ? ? ?

? ? }

? ??

};


int registerNativeMethods(JNIEnv* env,const char* name,

? ? JNINativeMethod* methods,jint nmethods){


? ? jclass jcls;

? ??

? ? jcls = env->FindClass(name);


? ? if(jcls == NULL) {


? ? ? ? return JNI_FALSE;



? ? }


? ? if(env->RegisterNatives(jcls,methods,nmethods) < 0){


? ? ? ? return JNI_FALSE;


? ? }

? ??

? ? return JNI_TRUE;


}



JNIEXPORT int JNICALL JNI_OnLoad(JavaVM* vm,void* reserved){

? ??

? ? JNIEnv* env;


? ? if(vm->GetEnv(reinterpret_cast<void**>(&env),JNI_VERSION_1_6) != JNI_OK){


? ? ? ? return JNI_FALSE;


? ? }


? ? int count=0;


? ? for(int i=0;i < sizeof(javaClass)/sizeof(javaClass[0]);i++){

? ? ? ??

? ? ? ? for(int j=0;j< sizeof(getMethod[i])/sizeof(getMethod[i][0]);j++){

? ? ? ? ? ??

? ? ? ? ? ? if(getMethod[i][j].fnPtr != NULL){


? ? ? ? ? ? ? ? count++;

? ? ? ? ? ? ? ??

? ? ? ? ? ? }

? ? ? ? }


? ? ? ? registerNativeMethods(env,javaClass[i],&getMethod[i][0],count);


? ? ? ? count = 0;

? ? }


? ? cout << "LoadAlgorithmLibrary" << endl;

? ??

? ? return JNI_VERSION_1_6;

}

#ifndef Common

#define Common

#include <jni.h>

#include <iostream>

#include <stdio.h>


#endif


#ifndef Test

#define Test

#include <Common.h>

void test();

#endif

#include <Test.h>


void test(){

? ? int l;

? ? short s;

? ? char c;


? ? l =? 0xabcddcba;

? ? s = l;

? ? c = l;


? ? printf("寬度溢出\n");

? ? printf("l = 0x%x (%d bits)\n", l, sizeof(l) * 8);

? ? printf("s = 0x%x (%d bits)\n", s, sizeof(s) * 8);

? ? printf("c = 0x%x (%d bits)\n", c, sizeof(c) * 8);


? ? printf("整型提升\n");

? ? printf("s + c = 0x%x (%d bits)\n", s+c, sizeof(s+c) * 8);

}

#include <InstrucNumTime.h>

#include <cmath>

#include <ctime>


using namespace std;


/**

?*?

?* 計(jì)算機(jī)處理指令數(shù)的時(shí)間

?*?

**/




void printInstructionTime(){

? ??

??



? ? for(jint i=1;i<=9;i++){

? ? ? ??


? ? ? ? jint number = pow(10,i);


? ? ? ? clock_t startTime = clock();


? ? ? ? jint sum = 0;


? ? ? ? for(jint j=0;j<number;j++){

? ? ? ? ? ? sum += j;

? ? ? ? }

? ?

? ? ? ? clock_t endTime = clock();


? ? ? ? cout << "10^" << i << " : " << (jdouble)(endTime-startTime)/CLOCKS_PER_SEC << "s" << endl;

? ? ??

? ? }


}

#ifndef InstrucNumTime

#define InstrucNumTime

#include <Common.h>

void printInstructionTime();

#endif


基于Linux的JNI動態(tài)函數(shù)注冊的評論 (共 條)

分享到微博請遵守國家法律
寿阳县| 贡山| 涞源县| 柳林县| 聂荣县| 原阳县| 武隆县| 雅安市| 开原市| 土默特右旗| 临海市| 佛坪县| 綦江县| 贵州省| 井冈山市| 贵南县| 唐山市| 新巴尔虎左旗| 大关县| 绥江县| 册亨县| 沛县| 砚山县| 樟树市| 会理县| 明水县| 马龙县| 淳安县| 新源县| 渑池县| 南康市| 体育| 普安县| 东丰县| 绿春县| 延吉市| 南昌县| 马龙县| 奉贤区| 沽源县| 双辽市|