Commit 0dfcd92b by 1256748979@qq.com

init

parent d4edad2b
......@@ -5,22 +5,31 @@ project(Wandun)
include_directories(${CMAKE_SOURCE_DIR}/include)
if(${CMAKE_ANDROID_ARCH_ABI} STREQUAL "arm64-v8a")
set(ARCH_DEPENDENDED_SRC
set(ARCH_DEPENDED_SRC
wd_syscall64.s)
elseif (${CMAKE_ANDROID_ARCH_ABI} STREQUAL "armeabi-v7a")
set(ARCH_DEPENDENDED_SRC
set(ARCH_DEPENDED1_SRC
wd_syscall32.s)
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-fvisibility=hidden -O3 -fno-unwind-tables")
add_library(wdun
add_library(
wdun
SHARED
core.cpp
wd_syscall.cpp
jni_helper.cpp
${ARCH_DEPENDENDED_SRC}
)
${ARCH_DEPENDED_SRC}
)
target_link_libraries(wdun log)
add_library(cJson SHARED IMPORTED)
set_target_properties(
cJson
PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/lib/${CMAKE_ANDROID_ARCH_ABI}/libcJson.a
)
target_link_libraries(wdun cJson log)
enable_language(ASM)
\ No newline at end of file
......@@ -5,6 +5,7 @@
#include <jni.h>
#include <syscall.h>
#include "wdun.h"
#include "cJSON.h"
//import asm symbol
IMPORTWDSYSCALL
......@@ -14,7 +15,6 @@ IMPORTWDSYSCALL
#define WDMAIN_GETWDID_METHOD_SIG "()Ljava/lang/String;"
jstring jni_get_wdid(JNIEnv* env, jobject thiz) {
}
JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
......@@ -25,6 +25,10 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
JNINativeMethod methods[] = {{WDMAIN_GETWDID_METHOD_NAME, WDMAIN_GETWDID_METHOD_SIG, (void*)jni_get_wdid}};
env->RegisterNatives(cls, methods, sizeof(methods)/sizeof(JNINativeMethod));
}
cJSON* json = cJSON_CreateObject();
cJSON_AddStringToObject(json, "name", "zhanglei");
char* json_str = cJSON_Print(json);
cJSON_free(json);
return JNI_VERSION_1_6;
}
......@@ -18,8 +18,8 @@
#endif
#define IMPORTWDSYSCALL \
extern "C" int wd_syscall32(int cmd, ...);\
extern "C" int wd_syscall64(int cmd, ...);
__attribute__((visibility("hidden"))) extern "C" int wd_syscall32(int cmd, ...);\
__attribute__((visibility("hidden"))) extern "C" int wd_syscall64(int cmd, ...);
extern "C" int wd_set_errno(int n);
......
......@@ -2,7 +2,6 @@
// Created by Fear1ess on 2021/4/1.
//
#include <__clang_cuda_device_functions.h>
#include "jni_helper.h"
void wdCheckException(JNIEnv* env) {
......@@ -26,8 +25,7 @@ char wdGetMethodRetType(const char* sig) {
jvalue wdGetStaticField(JNIEnv* env, const char* clsName, const char* fieldName, const char* fieldSig) {
jclass cls = env->FindClass(clsName);
jfieldID fieldId = env->GetStaticFieldID(cls, fieldName, fieldSig);
jvalue value;
memset(value, 0, sizeof(jvalue));
jvalue value = {0};
switch(wdGetFieldType(fieldSig)) {
case '[':
case 'L':
......@@ -67,8 +65,7 @@ jvalue wdGetStaticField(JNIEnv* env, const char* clsName, const char* fieldName,
jvalue wdGetField(JNIEnv* env, jobject obj, const char* fieldName, const char* fieldSig) {
jclass cls = env->GetObjectClass(obj);
jfieldID fieldId = env->GetFieldID(cls, fieldName, fieldSig);
jvalue value;
memset(value, 0, sizeof(jvalue));
jvalue value = {0};
switch(wdGetFieldType(fieldSig)) {
case '[':
case 'L':
......@@ -197,8 +194,7 @@ jobject wdNewObject(JNIEnv* env, const char* clsName, const char* methodSig, ...
jvalue wdCallStaticMethod(JNIEnv* env, const char* clsName, const char* methodName, const char* methodSig, va_list args) {
jclass cls = env->FindClass(clsName);
jmethodID methodId = env->GetStaticMethodID(cls, methodName, methodSig);
jvalue value;
memset(value, 0, sizeof(jvalue));
jvalue value = {0};
switch(wdGetMethodRetType(methodSig)) {
case 'V':
env->CallStaticVoidMethodV(cls, methodId, args);
......@@ -241,8 +237,7 @@ jvalue wdCallStaticMethod(JNIEnv* env, const char* clsName, const char* methodNa
jvalue wdCallMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, va_list args) {
jclass cls = env->GetObjectClass(obj);
jmethodID methodId = env->GetMethodID(cls, methodName, methodSig);
jvalue value;
memset(value, 0, sizeof(jvalue));
jvalue value = {0};
switch(wdGetMethodRetType(methodSig)) {
case 'V':
env->CallVoidMethodV(obj, methodId, args);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment