Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
3d2d485a
Commit
3d2d485a
authored
Jan 17, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine ndk-build
Fix #2077.
parent
94f04ae3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
16 deletions
+7
-16
core/src/main/jni/Android.mk
core/src/main/jni/Android.mk
+1
-5
core/src/main/jni/Application.mk
core/src/main/jni/Application.mk
+0
-3
core/src/main/jni/jni-helper.cpp
core/src/main/jni/jni-helper.cpp
+6
-8
No files found.
core/src/main/jni/Android.mk
View file @
3d2d485a
...
@@ -327,7 +327,7 @@ LOCAL_SRC_FILES:= jni-helper.cpp
...
@@ -327,7 +327,7 @@ LOCAL_SRC_FILES:= jni-helper.cpp
LOCAL_LDLIBS
:=
-ldl
-llog
LOCAL_LDLIBS
:=
-ldl
-llog
LOCAL_STATIC_LIBRARIES
:=
cpufeatures
libancillary
LOCAL_STATIC_LIBRARIES
:=
libancillary
include
$(BUILD_SHARED_LIBRARY)
include
$(BUILD_SHARED_LIBRARY)
...
@@ -477,7 +477,3 @@ libpcre_src_files := \
...
@@ -477,7 +477,3 @@ libpcre_src_files := \
LOCAL_SRC_FILES
:=
$(
addprefix
pcre/,
$(libpcre_src_files)
)
$(LOCAL_PATH)
/patch/pcre/pcre_chartables.c
LOCAL_SRC_FILES
:=
$(
addprefix
pcre/,
$(libpcre_src_files)
)
$(LOCAL_PATH)
/patch/pcre/pcre_chartables.c
include
$(BUILD_STATIC_LIBRARY)
include
$(BUILD_STATIC_LIBRARY)
# Import cpufeatures
$(call
import-module,android/cpufeatures)
core/src/main/jni/Application.mk
View file @
3d2d485a
APP_ABI
:=
armeabi-v7a arm64-v8a x86
APP_PLATFORM
:=
android-21
APP_STL
:=
c++_static
APP_STL
:=
c++_static
NDK_TOOLCHAIN_VERSION
:=
clang
core/src/main/jni/jni-helper.cpp
View file @
3d2d485a
...
@@ -13,7 +13,7 @@ using namespace std;
...
@@ -13,7 +13,7 @@ using namespace std;
// Based on: https://android.googlesource.com/platform/libcore/+/564c7e8/luni/src/main/native/libcore_io_Linux.cpp#256
// Based on: https://android.googlesource.com/platform/libcore/+/564c7e8/luni/src/main/native/libcore_io_Linux.cpp#256
static
void
throwException
(
JNIEnv
*
env
,
jclass
exceptionClass
,
jmethodID
ctor2
,
const
char
*
functionName
,
int
error
)
{
static
void
throwException
(
JNIEnv
*
env
,
jclass
exceptionClass
,
jmethodID
ctor2
,
const
char
*
functionName
,
int
error
)
{
jstring
detailMessage
=
env
->
NewStringUTF
(
functionName
);
jstring
detailMessage
=
env
->
NewStringUTF
(
functionName
);
if
(
detailMessage
==
NULL
)
{
if
(
detailMessage
==
nullptr
)
{
// Not really much we can do here. We're probably dead in the water,
// Not really much we can do here. We're probably dead in the water,
// but let's try to stumble on...
// but let's try to stumble on...
env
->
ExceptionClear
();
env
->
ExceptionClear
();
...
@@ -24,7 +24,7 @@ static void throwException(JNIEnv* env, jclass exceptionClass, jmethodID ctor2,
...
@@ -24,7 +24,7 @@ static void throwException(JNIEnv* env, jclass exceptionClass, jmethodID ctor2,
static
void
throwErrnoException
(
JNIEnv
*
env
,
const
char
*
functionName
)
{
static
void
throwErrnoException
(
JNIEnv
*
env
,
const
char
*
functionName
)
{
int
error
=
errno
;
int
error
=
errno
;
static
jclass
ErrnoException
=
static_cast
<
jclass
>
(
env
->
NewGlobalRef
(
static
auto
ErrnoException
=
static_cast
<
jclass
>
(
env
->
NewGlobalRef
(
env
->
FindClass
(
"android/system/ErrnoException"
)));
env
->
FindClass
(
"android/system/ErrnoException"
)));
static
jmethodID
ctor2
=
env
->
GetMethodID
(
ErrnoException
,
"<init>"
,
"(Ljava/lang/String;I)V"
);
static
jmethodID
ctor2
=
env
->
GetMethodID
(
ErrnoException
,
"<init>"
,
"(Ljava/lang/String;I)V"
);
throwException
(
env
,
ErrnoException
,
ctor2
,
functionName
,
error
);
throwException
(
env
,
ErrnoException
,
ctor2
,
functionName
,
error
);
...
@@ -33,10 +33,10 @@ static void throwErrnoException(JNIEnv* env, const char* functionName) {
...
@@ -33,10 +33,10 @@ static void throwErrnoException(JNIEnv* env, const char* functionName) {
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wunused-parameter"
extern
"C"
{
extern
"C"
{
JNIEXPORT
void
JNICALL
JNIEXPORT
void
JNICALL
Java_com_github_shadowsocks_JniHelper_sendFd
(
JNIEnv
*
env
,
j
object
thiz
,
jint
tun_fd
,
jstring
path
)
{
Java_com_github_shadowsocks_JniHelper_sendFd
(
JNIEnv
*
env
,
j
class
type
,
jint
tun_fd
,
jstring
path
)
{
int
fd
;
int
fd
;
struct
sockaddr_un
addr
;
struct
sockaddr_un
addr
;
const
char
*
sock_str
=
env
->
GetStringUTFChars
(
path
,
0
);
const
char
*
sock_str
=
env
->
GetStringUTFChars
(
path
,
nullptr
);
if
((
fd
=
socket
(
AF_UNIX
,
SOCK_STREAM
,
0
))
==
-
1
)
{
if
((
fd
=
socket
(
AF_UNIX
,
SOCK_STREAM
,
0
))
==
-
1
)
{
throwErrnoException
(
env
,
"socket"
);
throwErrnoException
(
env
,
"socket"
);
...
@@ -58,12 +58,11 @@ quit:
...
@@ -58,12 +58,11 @@ quit:
close
(
fd
);
close
(
fd
);
quit2:
quit2:
env
->
ReleaseStringUTFChars
(
path
,
sock_str
);
env
->
ReleaseStringUTFChars
(
path
,
sock_str
);
return
;
}
}
JNIEXPORT
jbyteArray
JNICALL
JNIEXPORT
jbyteArray
JNICALL
Java_com_github_shadowsocks_JniHelper_parseNumericAddress
(
JNIEnv
*
env
,
j
object
thiz
,
jstring
str
)
{
Java_com_github_shadowsocks_JniHelper_parseNumericAddress
(
JNIEnv
*
env
,
j
class
type
,
jstring
str
)
{
const
char
*
src
=
env
->
GetStringUTFChars
(
str
,
0
);
const
char
*
src
=
env
->
GetStringUTFChars
(
str
,
nullptr
);
jbyte
dst
[
max
(
sizeof
(
in_addr
),
sizeof
(
in6_addr
))];
jbyte
dst
[
max
(
sizeof
(
in_addr
),
sizeof
(
in6_addr
))];
jbyteArray
arr
=
nullptr
;
jbyteArray
arr
=
nullptr
;
if
(
inet_pton
(
AF_INET
,
src
,
dst
)
==
1
)
{
if
(
inet_pton
(
AF_INET
,
src
,
dst
)
==
1
)
{
...
@@ -81,7 +80,6 @@ Java_com_github_shadowsocks_JniHelper_parseNumericAddress(JNIEnv *env, jobject t
...
@@ -81,7 +80,6 @@ Java_com_github_shadowsocks_JniHelper_parseNumericAddress(JNIEnv *env, jobject t
/*
/*
* This is called by the VM when the shared library is first loaded.
* This is called by the VM when the shared library is first loaded.
*/
*/
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
jint
JNI_OnLoad
(
JavaVM
*
vm
,
void
*
reserved
)
{
jint
JNI_OnLoad
(
JavaVM
*
vm
,
void
*
reserved
)
{
return
JNI_VERSION_1_6
;
return
JNI_VERSION_1_6
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment