Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
b21cbbe5
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
1 年多 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b21cbbe5
编写于
5月 19, 2023
作者:
Y
yinchuang
提交者:
Gitee
5月 19, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of gitee.com:openharmony/third_party_musl into musl_print
Signed-off-by:
N
yinchuang
<
yinchuang@huawei.com
>
上级
44b4fcb2
1c0784c5
变更
27
隐藏空白更改
内联
并排
Showing
27 changed file
with
903 addition
and
419 deletion
+903
-419
dynamic.list
dynamic.list
+3
-0
libc-test/src/common/BUILD.gn
libc-test/src/common/BUILD.gn
+1
-0
libc-test/src/functionalext/supplement/dirent/readdir.c
libc-test/src/functionalext/supplement/dirent/readdir.c
+1
-1
libc-test/src/functionalext/supplement/network/getaddrinfo.c
libc-test/src/functionalext/supplement/network/getaddrinfo.c
+39
-2
libc-test/src/functionalext/trace/trace_marker.c
libc-test/src/functionalext/trace/trace_marker.c
+106
-44
libc-test/src/functionalext/trace/trace_stresstest.c
libc-test/src/functionalext/trace/trace_stresstest.c
+5
-5
libc.map.txt
libc.map.txt
+120
-193
musl_src.gni
musl_src.gni
+5
-0
musl_template.gni
musl_template.gni
+1
-0
porting/linux/user/include/trace/trace_marker.h
porting/linux/user/include/trace/trace_marker.h
+20
-5
porting/linux/user/ldso/dynlink.c
porting/linux/user/ldso/dynlink.c
+124
-77
porting/linux/user/src/env/getenv.c
porting/linux/user/src/env/getenv.c
+24
-0
porting/linux/user/src/internal/pthread_impl.h
porting/linux/user/src/internal/pthread_impl.h
+0
-3
porting/linux/user/src/internal/stdio_impl.h
porting/linux/user/src/internal/stdio_impl.h
+115
-0
porting/linux/user/src/network/lookup_name.c
porting/linux/user/src/network/lookup_name.c
+4
-0
porting/linux/user/src/network/resolvconf.c
porting/linux/user/src/network/resolvconf.c
+101
-12
porting/linux/user/src/sigchain/sigchain.c
porting/linux/user/src/sigchain/sigchain.c
+9
-4
porting/linux/user/src/stdio/__fdopen.c
porting/linux/user/src/stdio/__fdopen.c
+1
-0
porting/linux/user/src/stdio/__stdio_read.c
porting/linux/user/src/stdio/__stdio_read.c
+31
-0
porting/linux/user/src/stdio/fread.c
porting/linux/user/src/stdio/fread.c
+74
-0
porting/linux/user/src/thread/pthread_create.c
porting/linux/user/src/thread/pthread_create.c
+5
-10
porting/linux/user/src/trace/trace_marker.c
porting/linux/user/src/trace/trace_marker.c
+55
-19
porting/liteos_a/user/src/thread/pthread_create.c
porting/liteos_a/user/src/thread/pthread_create.c
+4
-13
scripts/runtest.sh
scripts/runtest.sh
+15
-1
scripts/runtest_Windows.bat
scripts/runtest_Windows.bat
+13
-7
src/network/lookup.h
src/network/lookup.h
+4
-0
src/network/res_cache.c
src/network/res_cache.c
+23
-23
未找到文件。
dynamic.list
浏览文件 @
b21cbbe5
...
...
@@ -44,4 +44,7 @@ __progname;
__progname_full;
__stack_chk_guard;
exit;
_Exit;
};
libc-test/src/common/BUILD.gn
浏览文件 @
b21cbbe5
...
...
@@ -105,6 +105,7 @@ config("config_unittest") {
"-Wno-error=unused-function",
"-g",
"-D_FILE_OFFSET_BITS=64",
"-Wno-constant-conversion",
]
ldflags = [ "-nostdlib" ]
...
...
libc-test/src/functionalext/supplement/dirent/readdir.c
浏览文件 @
b21cbbe5
...
...
@@ -43,7 +43,7 @@ void readdir_0200(void)
DIR
*
dir
=
(
DIR
*
)
""
;
struct
dirent
*
ret
;
ret
=
readdir
(
dir
);
EXPECT_TRUE
(
"readdir_0200"
,
NULL
==
ret
);
EXPECT_TRUE
(
"
readdir_0200"
,
NULL
==
ret
);
}
int
main
(
int
argc
,
char
*
argv
[])
...
...
libc-test/src/functionalext/supplement/network/getaddrinfo.c
浏览文件 @
b21cbbe5
/**
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022
-2023
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -16,6 +16,9 @@
#include <netdb.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <pthread.h>
#include <string.h>
#include <errno.h>
#include "functionalext.h"
...
...
@@ -276,7 +279,7 @@ void getaddrinfo_1500(void)
EXPECT_EQ
(
"getaddrinfo_1500"
,
ret
,
SOCKTYPE_NOTSUPPORTED
);
}
int
main
(
int
argc
,
char
*
argv
[]
)
static
void
*
test_all_cases
(
void
*
arg
)
{
getaddrinfo_0100
();
getaddrinfo_0200
();
...
...
@@ -293,6 +296,40 @@ int main(int argc, char *argv[])
getaddrinfo_1300
();
getaddrinfo_1400
();
getaddrinfo_1500
();
return
arg
;
}
static
void
do_test_concurrently
(
void
*
(
*
test
)
(
void
*
arg
),
size_t
num_threads
)
{
pthread_t
*
threads
=
(
pthread_t
*
)
malloc
(
sizeof
(
pthread_t
)
*
num_threads
);
if
(
threads
==
NULL
)
{
t_error
(
"Failed to allocate memory: %s
\n
"
,
strerror
(
errno
));
return
;
}
size_t
last
=
0
;
while
(
last
<
num_threads
)
{
if
(
pthread_create
(
&
(
threads
[
last
]),
NULL
,
test
,
NULL
))
{
t_error
(
"Failed to create thread: %s
\n
"
,
strerror
(
errno
));
break
;
}
last
++
;
}
for
(
size_t
i
=
0
;
i
<
last
;
i
++
)
{
if
(
pthread_join
(
threads
[
i
],
NULL
))
{
t_error
(
"Failed to join thread: %s
\n
"
,
strerror
(
errno
));
}
}
free
(
threads
);
return
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
size_t
num_threads
=
16
;
do_test_concurrently
(
test_all_cases
,
num_threads
);
return
t_status
;
}
libc-test/src/functionalext/trace/trace_marker.c
浏览文件 @
b21cbbe5
...
...
@@ -15,6 +15,7 @@
#include <trace/trace_marker.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdbool.h>
...
...
@@ -25,6 +26,8 @@
#include <unistd.h>
#define BUFFER_LEN 10240
#define READ_BUFFER_SIZE 4096
#define OUTFILE "/data/local/tmp/musl.trace"
#define EXPECT_TRUE(c) \
do \
{ \
...
...
@@ -38,21 +41,64 @@
t_error("[%s] failed \n"); \
} while (0)
#ifndef TRACE_TEMP_FAILURE_RETRY
#define TRACE_TEMP_FAILURE_RETRY(exp) \
({ \
long int _rc; \
do { \
_rc = (long int)(exp); \
} while ((_rc == -1) && (errno == EINTR)); \
_rc; \
})
#endif
typedef
void
(
*
TEST_FUN
)(
void
);
static
const
int
WAIT_TIME
=
1
;
static
const
int
count
=
10
;
static
const
int
count
=
100
;
static
void
clear_trace
()
{
if
(
access
(
"/sys/kernel/tracing/trace"
,
F_OK
)
==
0
)
{
system
(
"echo > /sys/kernel/tracing/trace"
);
}
if
(
access
(
"/sys/kernel/debug/tracing/trace"
,
F_OK
)
==
0
)
{
system
(
"echo > /sys/kernel/tracing/trace"
);
}
return
;
}
static
void
dump_trace
(
int
trace_fd
)
{
char
buffer
[
READ_BUFFER_SIZE
];
int
nwrite
;
int
nread
;
int
out_fd
=
open
(
OUTFILE
,
O_WRONLY
|
O_CREAT
);
if
(
out_fd
==
-
1
)
{
return
;
}
do
{
nread
=
TRACE_TEMP_FAILURE_RETRY
(
read
(
trace_fd
,
buffer
,
READ_BUFFER_SIZE
));
if
((
nread
==
0
)
||
(
nread
==
-
1
))
{
break
;
}
nwrite
=
TRACE_TEMP_FAILURE_RETRY
(
write
(
out_fd
,
buffer
,
nread
));
}
while
(
nwrite
>
0
);
close
(
out_fd
);
}
/**
* @tc.name : trace_marker
* @tc.desc : Test trace_marker_begin and trace_marker_end.
* @tc.level : Level 0
*/
static
void
trace_marker_0010
(
void
)
{
clear_trace
();
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_begin
(
"Musl_Trace_Marker_010
0"
,
""
);
trace_marker_end
();
trace_marker_begin
(
HITRACE_TAG_MUSL
,
"Musl_Trace_Marker_001
0"
,
""
);
trace_marker_end
(
HITRACE_TAG_MUSL
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -67,7 +113,7 @@ static void trace_marker_0010(void)
char
buf_begin
[
BUFFER_LEN
]
=
{
0
};
char
buf_end
[
BUFFER_LEN
]
=
{
0
};
int
buf_begin_fd
=
snprintf
(
buf_begin
,
BUFFER_LEN
,
"B|%d|%s"
,
getpid
(),
"Musl_Trace_Marker_0
10
0"
);
int
buf_begin_fd
=
snprintf
(
buf_begin
,
BUFFER_LEN
,
"B|%d|%s"
,
getpid
(),
"Musl_Trace_Marker_0
01
0"
);
if
(
buf_begin_fd
<
0
)
{
close
(
trace_fd
);
return
;
...
...
@@ -100,9 +146,10 @@ static void trace_marker_0010(void)
*/
static
void
trace_marker_0020
(
void
)
{
clear_trace
();
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_async_begin
(
"async_begin_0200"
,
"trace_async"
,
1
);
trace_marker_async_end
(
"async_end_0200"
,
"trace_async"
,
1
);
trace_marker_async_begin
(
HITRACE_TAG_MUSL
,
"async_begin_0200"
,
"trace_async"
,
1
);
trace_marker_async_end
(
HITRACE_TAG_MUSL
,
"async_end_0200"
,
"trace_async"
,
1
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -150,9 +197,10 @@ static void trace_marker_0020(void)
*/
static
void
trace_marker_0030
(
void
)
{
clear_trace
();
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
int
traceCount
=
5
;
trace_marker_count
(
"traceCount"
,
traceCount
);
trace_marker_count
(
HITRACE_TAG_MUSL
,
"traceCount"
,
traceCount
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -195,6 +243,7 @@ static void trace_marker_0030(void)
*/
static
void
trace_marker_0040
(
void
)
{
clear_trace
();
bool
trace_sucess
=
false
;
char
buffer_fir
[
BUFFER_LEN
]
=
{
0
};
char
buffer_sec
[
BUFFER_LEN
]
=
{
0
};
...
...
@@ -208,8 +257,8 @@ static void trace_marker_0040(void)
}
else
if
(
fpid
==
0
)
{
int
pidChild
=
getpid
();
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_begin
(
"Trace_Marker0400_Forkfir"
,
""
);
trace_marker_end
();
trace_marker_begin
(
HITRACE_TAG_MUSL
,
"Trace_Marker0400_Forkfir"
,
""
);
trace_marker_end
(
HITRACE_TAG_MUSL
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
|
O_APPEND
);
...
...
@@ -246,8 +295,8 @@ static void trace_marker_0040(void)
exit
(
pidChild
);
}
else
{
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_begin
(
"Trace_Marker0400_Forksec"
,
""
);
trace_marker_end
();
trace_marker_begin
(
HITRACE_TAG_MUSL
,
"Trace_Marker0400_Forksec"
,
""
);
trace_marker_end
(
HITRACE_TAG_MUSL
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
|
O_APPEND
);
...
...
@@ -291,6 +340,7 @@ static void trace_marker_0040(void)
*/
static
void
trace_marker_0050
(
void
)
{
clear_trace
();
bool
trace_async_sucess
=
false
;
char
buffer_forkFir
[
BUFFER_LEN
]
=
{
0
};
char
buffer_forkSec
[
BUFFER_LEN
]
=
{
0
};
...
...
@@ -304,8 +354,8 @@ static void trace_marker_0050(void)
}
else
if
(
fpid
==
0
)
{
int
pidChild
=
getpid
();
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_async_begin
(
"async0500_Forkfir"
,
"begin_fir"
,
2
);
trace_marker_async_end
(
"async0500_Forkfir"
,
"end_fir"
,
2
);
trace_marker_async_begin
(
HITRACE_TAG_MUSL
,
"async0500_Forkfir"
,
"begin_fir"
,
2
);
trace_marker_async_end
(
HITRACE_TAG_MUSL
,
"async0500_Forkfir"
,
"end_fir"
,
2
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
|
O_APPEND
);
...
...
@@ -342,8 +392,8 @@ static void trace_marker_0050(void)
exit
(
pidChild
);
}
else
{
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_async_begin
(
"async0500_Forksec"
,
"begin_sec"
,
3
);
trace_marker_async_end
(
"async0500_Forksec"
,
"end_sec"
,
3
);
trace_marker_async_begin
(
HITRACE_TAG_MUSL
,
"async0500_Forksec"
,
"begin_sec"
,
3
);
trace_marker_async_end
(
HITRACE_TAG_MUSL
,
"async0500_Forksec"
,
"end_sec"
,
3
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
|
O_APPEND
);
...
...
@@ -387,6 +437,7 @@ static void trace_marker_0050(void)
*/
static
void
trace_marker_0060
(
void
)
{
clear_trace
();
int
traceCount
=
5
;
bool
trace_count_sucess
=
false
;
char
buffer_forkFir
[
BUFFER_LEN
]
=
{
0
};
...
...
@@ -401,7 +452,7 @@ static void trace_marker_0060(void)
int
pidChild
=
getpid
();
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_count
(
"traceCount_forkfir"
,
traceCount
);
trace_marker_count
(
HITRACE_TAG_MUSL
,
"traceCount_forkfir"
,
traceCount
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
|
O_APPEND
);
...
...
@@ -432,7 +483,7 @@ static void trace_marker_0060(void)
exit
(
pidChild
);
}
else
{
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_count
(
"traceCount_forksec"
,
traceCount
);
trace_marker_count
(
HITRACE_TAG_MUSL
,
"traceCount_forksec"
,
traceCount
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
|
O_APPEND
);
...
...
@@ -466,8 +517,8 @@ static void trace_marker_0060(void)
static
void
*
ThreadTraceMarkerFir
(
void
*
arg
)
{
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_begin
(
"Trace_Marker_Threadfir"
,
"pthreadfir"
);
trace_marker_end
();
trace_marker_begin
(
HITRACE_TAG_MUSL
,
"Trace_Marker_Threadfir"
,
"pthreadfir"
);
trace_marker_end
(
HITRACE_TAG_MUSL
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -512,8 +563,8 @@ static void *ThreadTraceMarkerFir(void *arg)
static
void
*
ThreadTraceMarkerSec
(
void
*
arg
)
{
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_begin
(
"Trace_Marker_Threadsec"
,
"pthreadsec"
);
trace_marker_end
();
trace_marker_begin
(
HITRACE_TAG_MUSL
,
"Trace_Marker_Threadsec"
,
"pthreadsec"
);
trace_marker_end
(
HITRACE_TAG_MUSL
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -562,6 +613,7 @@ static void *ThreadTraceMarkerSec(void *arg)
*/
static
void
trace_marker_0070
(
void
)
{
clear_trace
();
int
res
;
const
char
msgThread1
[
1024
]
=
{
"msgThread1"
};
const
char
msgThread2
[
1024
]
=
{
"msgThread2"
};
...
...
@@ -582,8 +634,8 @@ static void trace_marker_0070(void)
static
void
*
ThreadTraceMarkerAsyncFir
(
void
*
arg
)
{
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_async_begin
(
"Async_Threadfir"
,
"begin_threadfir"
,
4
);
trace_marker_async_end
(
"Async_Threadfir"
,
"end_threadfir"
,
4
);
trace_marker_async_begin
(
HITRACE_TAG_MUSL
,
"Async_Threadfir"
,
"begin_threadfir"
,
4
);
trace_marker_async_end
(
HITRACE_TAG_MUSL
,
"Async_Threadfir"
,
"end_threadfir"
,
4
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -628,8 +680,8 @@ static void *ThreadTraceMarkerAsyncFir(void *arg)
static
void
*
ThreadTraceMarkerAsyncSec
(
void
*
arg
)
{
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_async_begin
(
"Async_Threadsec"
,
"begin_threadsec"
,
5
);
trace_marker_async_end
(
"Async_Threadsec"
,
"end_threadsec"
,
5
);
trace_marker_async_begin
(
HITRACE_TAG_MUSL
,
"Async_Threadsec"
,
"begin_threadsec"
,
5
);
trace_marker_async_end
(
HITRACE_TAG_MUSL
,
"Async_Threadsec"
,
"end_threadsec"
,
5
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -678,6 +730,7 @@ static void *ThreadTraceMarkerAsyncSec(void *arg)
*/
static
void
trace_marker_0080
(
void
)
{
clear_trace
();
int
res
;
const
char
msgThread1
[
1024
]
=
{
"msgThread3"
};
const
char
msgThread2
[
1024
]
=
{
"msgThread4"
};
...
...
@@ -699,7 +752,7 @@ static void *ThreadTraceMarkerCountFir(void *arg)
{
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
int
traceCount
=
5
;
trace_marker_count
(
"traceCount_Threadfir"
,
traceCount
);
trace_marker_count
(
HITRACE_TAG_MUSL
,
"traceCount_Threadfir"
,
traceCount
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -740,7 +793,7 @@ static void *ThreadTraceMarkerCountSec(void *arg)
{
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
int
traceCount
=
5
;
trace_marker_count
(
"traceCount_Threadsec"
,
traceCount
);
trace_marker_count
(
HITRACE_TAG_MUSL
,
"traceCount_Threadsec"
,
traceCount
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -783,6 +836,7 @@ static void *ThreadTraceMarkerCountSec(void *arg)
*/
static
void
trace_marker_0090
(
void
)
{
clear_trace
();
int
res
;
const
char
msgThread1
[
1024
]
=
{
"msgThread5"
};
const
char
msgThread2
[
1024
]
=
{
"msgThread6"
};
...
...
@@ -807,9 +861,10 @@ static void trace_marker_0090(void)
*/
static
void
trace_marker_0100
(
void
)
{
clear_trace
();
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_begin
(
"Musl_Trace_Marker_0100"
,
NULL
);
trace_marker_end
();
trace_marker_begin
(
HITRACE_TAG_MUSL
,
"Musl_Trace_Marker_0100"
,
NULL
);
trace_marker_end
(
HITRACE_TAG_MUSL
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -858,13 +913,14 @@ static void trace_marker_0100(void)
*/
static
void
trace_marker_0110
(
void
)
{
clear_trace
();
char
message
[
1026
]
=
{
0
};
memset
(
message
,
1
,
1025
);
message
[
1025
]
=
'\0'
;
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_begin
(
message
,
""
);
trace_marker_end
();
trace_marker_begin
(
HITRACE_TAG_MUSL
,
message
,
""
);
trace_marker_end
(
HITRACE_TAG_MUSL
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -914,9 +970,10 @@ static void trace_marker_0110(void)
*/
static
void
trace_marker_0120
(
void
)
{
clear_trace
();
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_begin
(
NULL
,
""
);
trace_marker_end
();
trace_marker_begin
(
HITRACE_TAG_MUSL
,
NULL
,
""
);
trace_marker_end
(
HITRACE_TAG_MUSL
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -957,9 +1014,10 @@ static void trace_marker_0120(void)
*/
static
void
trace_marker_0140
(
void
)
{
clear_trace
();
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_async_begin
(
"async_begin_0200"
,
NULL
,
1
);
trace_marker_async_end
(
"async_end_0200"
,
NULL
,
1
);
trace_marker_async_begin
(
HITRACE_TAG_MUSL
,
"async_begin_0200"
,
NULL
,
1
);
trace_marker_async_end
(
HITRACE_TAG_MUSL
,
"async_end_0200"
,
NULL
,
1
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -1009,13 +1067,14 @@ static void trace_marker_0140(void)
*/
static
void
trace_marker_0150
(
void
)
{
clear_trace
();
char
message
[
1026
]
=
{
0
};
memset
(
message
,
1
,
1025
);
message
[
1025
]
=
'\0'
;
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_async_begin
(
message
,
"trace_async"
,
1
);
trace_marker_async_end
(
message
,
"trace_async"
,
1
);
trace_marker_async_begin
(
HITRACE_TAG_MUSL
,
message
,
"trace_async"
,
1
);
trace_marker_async_end
(
HITRACE_TAG_MUSL
,
message
,
"trace_async"
,
1
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -1063,9 +1122,10 @@ static void trace_marker_0150(void)
*/
static
void
trace_marker_0160
(
void
)
{
clear_trace
();
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_async_begin
(
NULL
,
"trace_async"
,
1
);
trace_marker_async_end
(
NULL
,
"trace_async"
,
1
);
trace_marker_async_begin
(
HITRACE_TAG_MUSL
,
NULL
,
"trace_async"
,
1
);
trace_marker_async_end
(
HITRACE_TAG_MUSL
,
NULL
,
"trace_async"
,
1
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -1113,13 +1173,14 @@ static void trace_marker_0160(void)
*/
static
void
trace_marker_0180
(
void
)
{
clear_trace
();
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
int
traceCount
=
5
;
char
message
[
1026
]
=
{
0
};
memset
(
message
,
1
,
1025
);
message
[
1025
]
=
'\0'
;
trace_marker_count
(
message
,
traceCount
);
trace_marker_count
(
HITRACE_TAG_MUSL
,
message
,
traceCount
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -1162,9 +1223,10 @@ static void trace_marker_0180(void)
*/
static
void
trace_marker_0190
(
void
)
{
clear_trace
();
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
int
traceCount
=
5
;
trace_marker_count
(
NULL
,
traceCount
);
trace_marker_count
(
HITRACE_TAG_MUSL
,
NULL
,
traceCount
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
int
trace_fd
=
open
(
"/sys/kernel/tracing/trace"
,
O_CLOEXEC
|
O_RDONLY
);
...
...
@@ -1217,7 +1279,7 @@ TEST_FUN G_Fun_Array[] = {
trace_marker_0160
,
trace_marker_0180
,
trace_marker_0190
,
};
};
int
main
(
void
)
{
...
...
@@ -1227,4 +1289,4 @@ int main(void)
}
return
t_status
;
}
}
\ No newline at end of file
libc-test/src/functionalext/trace/trace_stresstest.c
浏览文件 @
b21cbbe5
...
...
@@ -49,8 +49,8 @@ static void trace_marker_stresstest_0010(void)
while
(
traceCount
<=
5000
)
{
snprintf
(
buf
,
BUFFER_LEN
,
"%d"
,
traceCount
);
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_async_begin
(
"Trace_Marker_Async_Begin"
,
buf
,
1
);
trace_marker_async_end
(
"Trace_Marker_Async_End"
,
buf
,
1
);
trace_marker_async_begin
(
HITRACE_TAG_MUSL
,
"Trace_Marker_Async_Begin"
,
buf
,
1
);
trace_marker_async_end
(
HITRACE_TAG_MUSL
,
"Trace_Marker_Async_End"
,
buf
,
1
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
printf
(
"trace_marker_async_begin has been running times is:%d
\n
"
,
traceCount
);
traceCount
++
;
...
...
@@ -69,8 +69,8 @@ static void trace_marker_stresstest_0010(void)
while
(
traceCount
<=
5000
)
{
snprintf
(
buf
,
BUFFER_LEN
,
"%d"
,
traceCount
);
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_begin
(
"Trace_Marker"
,
buf
);
trace_marker_end
();
trace_marker_begin
(
HITRACE_TAG_MUSL
,
"Trace_Marker"
,
buf
);
trace_marker_end
(
HITRACE_TAG_MUSL
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
printf
(
"trace_marker_begin has been running times is:%d
\n
"
,
traceCount
);
traceCount
++
;
...
...
@@ -82,7 +82,7 @@ static void trace_marker_stresstest_0010(void)
while
(
traceCount
<=
5000
)
{
system
(
"cd /sys/kernel/debug/tracing;echo 1 > tracing_on"
);
trace_marker_count
(
"traceCount"
,
traceCount
);
trace_marker_count
(
HITRACE_TAG_MUSL
,
"traceCount"
,
traceCount
);
system
(
"cd /sys/kernel/debug/tracing;echo 0 > tracing_on"
);
printf
(
"trace_marker_count has been running times is:%d
\n
"
,
traceCount
);
traceCount
++
;
...
...
libc.map.txt
浏览文件 @
b21cbbe5
...
...
@@ -77,11 +77,11 @@
__fxstatat64;
__getcwd_chk;
__getdelim;
__getgmtoff;
#
__getgmtoff;
__getitimer_time64;
__getrusage_time64;
__gettimeofday_time64;
__getzonename;
#
__getzonename;
__gmtime64;
__gmtime64_r;
__gnu_Unwind_Find_exidx;
...
...
@@ -130,8 +130,8 @@
__libc_free;
__libc_malloc;
__libc_malloc_default_dispatch;
__libc_mmap;
__libc_munmap;
#
__libc_mmap;
#
__libc_munmap;
__libc_start_main;
__lldb_mmap;
__localtime64;
...
...
@@ -142,14 +142,14 @@
__lxstat64;
__memchr_diagnose;
__memcpy_chk;
__memmove_aarch64;
#
__memmove_aarch64;
__memmove_chk;
__mempcpy_chk;
__memrchr_chk;
__memset_chk;
__mktime64;
__mq_timedreceive_time64;
__mq_timedsend_time64;
#
__mq_timedreceive_time64;
#
__mq_timedsend_time64;
__mtx_timedlock_time64;
__musl_libc_globals;
__nanosleep_time64;
...
...
@@ -160,7 +160,7 @@
__open64_diagnose;
__openat_diagnose;
__openat64_diagnose;
__optpos;
#
__optpos;
__optreset;
__overflow;
__poll_diagnose;
...
...
@@ -174,20 +174,20 @@
__pthread_cond_timedwait_time64;
__pthread_gettid_np;
__pthread_mutex_timedlock_time64;
__pthread_release_signal_stack;
__pthread_reserve_signal_stack;
#
__pthread_release_signal_stack;
#
__pthread_reserve_signal_stack;
__pthread_rwlock_timedrdlock_time64;
__pthread_rwlock_timedwrlock_time64;
__pthread_timedjoin_np_time64;
#
__pthread_timedjoin_np_time64;
__pwrite_chk;
__read_chk;
__readlink_chk;
__readlinkat_chk;
__reboot;
#
__reboot;
__recv_diagnose;
__recvfrom_diagnose;
__recvmmsg_time64;
__res_state;
#
__res_state;
__sched_cpualloc;
__sched_cpucount;
__sched_rr_get_interval_time64;
...
...
@@ -313,20 +313,20 @@
add_special_signal_handler;
adjtime;
adjtimex;
aio_cancel;
aio_cancel64;
aio_error;
aio_error64;
aio_fsync;
aio_fsync64;
aio_read;
aio_read64;
aio_return;
aio_return64;
aio_suspend;
aio_suspend64;
aio_write;
aio_write64;
#
aio_cancel;
#
aio_cancel64;
#
aio_error;
#
aio_error64;
#
aio_fsync;
#
aio_fsync64;
#
aio_read;
#
aio_read64;
#
aio_return;
#
aio_return64;
#
aio_suspend;
#
aio_suspend64;
#
aio_write;
#
aio_write64;
alarm;
aligned_alloc;
alphasort;
...
...
@@ -421,7 +421,7 @@
cfsetospeed;
cfsetspeed;
chdir;
check_asan_path;
#
check_asan_path;
chmod;
chown;
chroot;
...
...
@@ -451,8 +451,8 @@
cnd_signal;
cnd_timedwait;
cnd_wait;
configor_free;
configor_init;
#
configor_free;
#
configor_init;
confstr;
conj;
conjf;
...
...
@@ -480,7 +480,7 @@
creat;
creat64;
crypt;
crypt_r;
#
crypt_r;
csin;
csinf;
csinh;
...
...
@@ -524,9 +524,9 @@
dlns_inherit;
dlns_init;
dlns_set_namespace_allowed_libs;
dlns_set_namespace_lib_path;
dlns_set_namespace_permitted_paths;
dlns_set_namespace_separated;
#
dlns_set_namespace_lib_path;
#
dlns_set_namespace_permitted_paths;
#
dlns_set_namespace_separated;
dlopen;
dlopen_ext;
dlopen_ns;
...
...
@@ -537,7 +537,7 @@
dn_skipname;
dngettext;
dns_get_addr_info_from_netsys_cache;
dns_set_addr_info_to_netsys_cache;
#
dns_set_addr_info_to_netsys_cache;
dprintf;
drand48;
drem;
...
...
@@ -548,8 +548,8 @@
duplocale;
eaccess;
ecvt;
encode_ptr;
encrypt;
#
encode_ptr;
#
encrypt;
endgrent;
endhostent;
endmntent;
...
...
@@ -668,7 +668,7 @@
fgetxattr;
fileno;
fileno_unlocked;
find_ns_by_name;
#
find_ns_by_name;
finish_install_ohos_malloc_hooks;
finite;
finitef;
...
...
@@ -762,7 +762,7 @@
get_application_target_sdk_version;
get_avphys_pages;
get_current_dir_name;
get_default_ns;
#
get_default_ns;
get_device_api_version;
get_fatal_message;
get_nprocs;
...
...
@@ -857,7 +857,7 @@
getsockopt;
getspent;
getspnam;
getspnam_r;
#
getspnam_r;
getsubopt;
gettext;
GetThreadName;
...
...
@@ -886,7 +886,7 @@
gmtime_r;
grantpt;
h_errno;
handle_asan_path_open;
#
handle_asan_path_open;
HashMapAdd;
HashMapCreate;
HashMapDestroy;
...
...
@@ -945,11 +945,11 @@
inotify_init1;
inotify_rm_watch;
insque;
INVALID_SOCKET;
#
INVALID_SOCKET;
ioctl;
is_accessible;
#
is_accessible;
is_allow_internet;
is_sharable;
#
is_sharable;
isalnum;
isalnum_l;
isalpha;
...
...
@@ -1034,8 +1034,8 @@
lgetxattr;
link;
linkat;
lio_listio;
lio_listio64;
#
lio_listio;
#
lio_listio64;
listen;
listxattr;
llabs;
...
...
@@ -1143,16 +1143,16 @@
modfl;
mount;
mprotect;
mq_close;
mq_getattr;
mq_notify;
mq_open;
mq_receive;
mq_send;
mq_setattr;
mq_timedreceive;
mq_timedsend;
mq_unlink;
#
mq_close;
#
mq_getattr;
#
mq_notify;
#
mq_open;
#
mq_receive;
#
mq_send;
#
mq_setattr;
#
mq_timedreceive;
#
mq_timedsend;
#
mq_unlink;
mrand48;
mremap;
msgctl;
...
...
@@ -1178,7 +1178,7 @@
nearbyintf;
nearbyintl;
newlocale;
next_key;
#
next_key;
nextafter;
nextafterf;
nextafterl;
...
...
@@ -1192,10 +1192,10 @@
nl_langinfo;
nl_langinfo_l;
nrand48;
ns_add_dso;
#
ns_add_dso;
ns_add_inherit;
ns_alloc;
ns_free;
#
ns_alloc;
#
ns_free;
ns_get16;
ns_get32;
ns_initparse;
...
...
@@ -1203,17 +1203,17 @@
ns_parserr;
ns_put16;
ns_put32;
ns_set_allowed_libs;
ns_set_asan_lib_paths;
ns_set_asan_permitted_paths;
ns_set_env_paths;
ns_set_lib_paths;
ns_set_name;
ns_set_permitted_paths;
ns_set_separated;
#
ns_set_allowed_libs;
#
ns_set_asan_lib_paths;
#
ns_set_asan_permitted_paths;
#
ns_set_env_paths;
#
ns_set_lib_paths;
#
ns_set_name;
#
ns_set_permitted_paths;
#
ns_set_separated;
ns_skiprr;
nslist_add_ns;
nslist_init;
#
nslist_add_ns;
#
nslist_init;
ntohl;
ntohs;
OH_HashMapAdd;
...
...
@@ -1338,7 +1338,7 @@
pthread_barrierattr_getpshared;
pthread_barrierattr_init;
pthread_barrierattr_setpshared;
pthread_cancel;
#
pthread_cancel;
pthread_cond_broadcast;
pthread_cond_clockwait;
pthread_cond_destroy;
...
...
@@ -1372,7 +1372,7 @@
pthread_key_delete;
pthread_kill;
pthread_mutex_clocklock;
pthread_mutex_consistent;
#
pthread_mutex_consistent;
pthread_mutex_destroy;
pthread_mutex_getprioceiling;
pthread_mutex_init;
...
...
@@ -1386,12 +1386,12 @@
pthread_mutexattr_destroy;
pthread_mutexattr_getprotocol;
pthread_mutexattr_getpshared;
pthread_mutexattr_getrobust;
#
pthread_mutexattr_getrobust;
pthread_mutexattr_gettype;
pthread_mutexattr_init;
pthread_mutexattr_setprotocol;
pthread_mutexattr_setpshared;
pthread_mutexattr_setrobust;
#
pthread_mutexattr_setrobust;
pthread_mutexattr_settype;
pthread_once;
pthread_rwlock_clockrdlock;
...
...
@@ -1415,7 +1415,7 @@
pthread_setaffinity_np;
pthread_setattr_default_np;
pthread_setcancelstate;
pthread_setcanceltype;
#
pthread_setcanceltype;
pthread_setconcurrency;
pthread_setname_np;
pthread_setschedparam;
...
...
@@ -1427,9 +1427,9 @@
pthread_spin_lock;
pthread_spin_trylock;
pthread_spin_unlock;
pthread_testcancel;
pthread_timedjoin_np;
pthread_tryjoin_np;
#
pthread_testcancel;
#
pthread_timedjoin_np;
#
pthread_tryjoin_np;
ptrace;
ptsname;
ptsname_r;
...
...
@@ -1578,7 +1578,7 @@
sethostname;
setitimer;
setjmp;
setkey;
#
setkey;
setlinebuf;
setlocale;
setlogmask;
...
...
@@ -1601,6 +1601,7 @@
setsockopt;
setspent;
setstate;
SetThreadInfoCallback;
settimeofday;
setuid;
setusershell;
...
...
@@ -1608,8 +1609,8 @@
setutxent;
setvbuf;
setxattr;
shm_open;
shm_unlink;
#
shm_open;
#
shm_unlink;
shmat;
shmctl;
shmdt;
...
...
@@ -1659,7 +1660,7 @@
sockatmark;
socket;
SOCKET_ADDR;
SOCKET_TYPE;
#
SOCKET_TYPE;
socketpair;
splice;
sprintf;
...
...
@@ -1670,7 +1671,7 @@
srand48;
srandom;
sscanf;
stack_naming;
#
stack_naming;
stat;
stat64;
statfs;
...
...
@@ -1813,11 +1814,11 @@
towlower_l;
towupper;
towupper_l;
trace_marker_async_begin;
trace_marker_async_end;
#
trace_marker_async_begin;
#
trace_marker_async_end;
trace_marker_begin;
trace_marker_count;
trace_marker_end;
#
trace_marker_count;
#
trace_marker_end;
trunc;
truncate;
truncate64;
...
...
@@ -1958,111 +1959,37 @@
y1f;
yn;
ynf;
dlopen_ns_ext;
init_cfi_shadow;
map_dso_to_cfi_shadow;
unmap_dso_from_cfi_shadow;
__cfi_slowpath;
__cfi_slowpath_diag;
__memleak_hook_flag;
SystemFindParameter;
SystemGetParameterCommitId;
SystemGetParameterValue;
GetSystemCommitId;
mallopt;
TestParameterReaderPerformance;
reallocarray;
CachedParameterCreate;
CachedParameterGet;
CachedParameterDestroy;
CachedParameterGetChanged;
malloc_stats_print;
GetParamLabelIndex;
malloc_disable;
malloc_enable;
malloc_info;
malloc_iterate;
GetLabelIndex;
tcgetwinsize;
_Fork;
malloc_backtrace;
tcsetwinsize;
qsort_r;
local:
mq_close;
mq_getattr;
mq_notify;
mq_open;
mq_receive;
mq_send;
mq_setattr;
mq_timedreceive;
mq_timedsend;
mq_unlink;
__mq_timedreceive_time64;
__mq_timedsend_time64;
shm_open;
shm_unlink;
pthread_cancel;
# pthread_setcancelstate;
pthread_setcanceltype;
pthread_testcancel;
pthread_mutex_consistent;
pthread_mutexattr_getrobust;
pthread_mutexattr_setrobust;
__optpos;
aio_cancel;
aio_cancel64;
aio_error;
aio_error64;
aio_fsync;
aio_fsync64;
aio_read;
aio_read64;
aio_return;
aio_return64;
aio_suspend;
aio_suspend64;
aio_write;
aio_write64;
lio_listio;
lio_listio64;
setkey;
__getgmtoff;
__getzonename;
__libc_mmap;
__libc_munmap;
# __mem_typeset;
__memmove_aarch64;
__pthread_release_signal_stack;
__pthread_reserve_signal_stack;
__pthread_timedjoin_np_time64;
__reboot;
__res_state;
check_asan_path;
configor_free;
configor_init;
# crypt;
crypt_r;
dlns_set_namespace_lib_path;
dlns_set_namespace_permitted_paths;
dlns_set_namespace_separated;
dns_get_addr_info_from_net;
dns_set_addr_info_to_net;
dns_set_addr_info_to_netsys_cache;
encode_ptr;
encrypt;
find_ns_by_name;
get_default_ns;
# getspnam;
getspnam_r;
handle_asan_path_open;
HiLogAdapterIsLoggable;
HiLogAdapterPrint;
INVALID_SOCKET;
is_accessible;
is_allow_inherit;
is_sharable;
next_key;
ns_add_dso;
ns_alloc;
ns_free;
ns_set_allowed_libs;
ns_set_asan_lib_paths;
ns_set_asan_permitted_paths;
ns_set_env_paths;
ns_set_lib_paths;
ns_set_name;
ns_set_permitted_paths;
ns_set_separated;
nslist_add_ns;
nslist_init;
# ohos_malloc_hook_shared_library;
pthread_timedjoin_np;
pthread_tryjoin_np;
SOCKER_ADDR;
SOCKET_TYPE;
spnam;
stack_naming;
strlist_alloc;
strlist_free;
strlist_set;
strlwc;
strsplit;
strtrim;
sys_cache;
trace_marker_async_begin;
trace_marker_async_end;
trace_marker_count;
trace_marker_end;
*;
};
musl_src.gni
浏览文件 @
b21cbbe5
...
...
@@ -144,6 +144,7 @@ if (musl_arch == "arm") {
musl_src_arch_file = [
"src/fenv/x86_64/fenv.s",
"src/ldso/x86_64/dlsym.s",
"src/ldso/x86_64/dlvsym.s",
"src/ldso/x86_64/tlsdesc.s",
"src/math/x86_64/__invtrigl.s",
"src/math/x86_64/acosl.s",
...
...
@@ -2165,6 +2166,9 @@ musl_src_porting_file = [
"src/ldso/x86_64/dlvsym.s",
"src/stdio/__fdopen.c",
"src/stdio/vfprintf.c",
"src/stdio/__stdio_read.c",
"src/stdio/fread.c",
"src/internal/stdio_impl.h",
"src/internal/vdso.c",
"src/time/clock_gettime.c",
"src/time/clock_getres.c",
...
...
@@ -2180,6 +2184,7 @@ musl_src_porting_file = [
"src/sigchain/sigchain.c",
"src/conf/legacy.c",
"src/conf/sysconf.c",
"src/env/getenv.c",
]
musl_inc_hook_files = [
...
...
musl_template.gni
浏览文件 @
b21cbbe5
...
...
@@ -154,6 +154,7 @@ template("musl_libs") {
defines += [
"OHOS_DNS_PROXY_BY_NETSYS=1",
"OHOS_PERMISSION_INTERNET=1",
"STANDARD_SYSTEM",
]
}
...
...
porting/linux/user/include/trace/trace_marker.h
浏览文件 @
b21cbbe5
...
...
@@ -16,6 +16,8 @@
#ifndef _TRACE_TRACE_MARKER_H
#define _TRACE_TRACE_MARKER_H
#include <stdint.h>
#define TRACE_MARKER_MESSAGE_LEN 1024
#ifdef __cplusplus
...
...
@@ -23,42 +25,55 @@ extern "C"
{
#endif
static
const
uint64_t
HITRACE_TAG_ALWAYS
=
(
1ULL
<<
0
);
// This tag is always enabled.
static
const
uint64_t
HITRACE_TAG_MUSL
=
(
1ULL
<<
12
);
// musl tag.
/**
* @brief Reset trace_marker trace switch status
*/
void
trace_marker_reset
(
void
);
/**
* @brief Write the function call information to the trace_marker node in kernel space,
* used on the same thread as trace_marker_end(),with the symbol "B".
* @param label The tagLabel of current sub-system.
* @param message The function of information.
* @param value The value which want to trace.
*/
void
trace_marker_begin
(
const
char
*
message
,
const
char
*
value
);
void
trace_marker_begin
(
uint64_t
label
,
const
char
*
message
,
const
char
*
value
);
/**
* @brief Write the terminator to the trace_marker node of the kernel space,
* used on the same thread as trace_marker_begin(),with the symbol "E".
* @param label The tagLabel of current sub-system.
*/
void
trace_marker_end
(
void
);
void
trace_marker_end
(
uint64_t
label
);
/**
* @brief Write the function call information to the trace_marker node in kernel space,
* used in a different thread than trace_marker_async_end(),with the symbol "S".
* @param label The tagLabel of current sub-system.
* @param message The function of information.
* @param value The value which want to trace.
*/
void
trace_marker_async_begin
(
const
char
*
message
,
const
char
*
value
,
int
taskId
);
void
trace_marker_async_begin
(
uint64_t
label
,
const
char
*
message
,
const
char
*
value
,
int
taskId
);
/**
* @brief Write the terminator to the trace_marker node in kernel space,
* used in a different thread than trace_marker_async_begin(),with the symbol "F".
* @param label The tagLabel of current sub-system.
* @param message The function of information.
* @param value The value which want to trace.
*/
void
trace_marker_async_end
(
const
char
*
message
,
const
char
*
value
,
int
taskId
);
void
trace_marker_async_end
(
uint64_t
label
,
const
char
*
message
,
const
char
*
value
,
int
taskId
);
/**
* @brief Marks a pre-traced numeric variable,with the symbol "C".
* @param label The tagLabel of current sub-system.
* @param message The function of information.
* @param value The value which want to trace.
*/
void
trace_marker_count
(
const
char
*
message
,
int
value
);
void
trace_marker_count
(
uint64_t
label
,
const
char
*
message
,
int
value
);
#ifdef __cplusplus
}
...
...
porting/linux/user/ldso/dynlink.c
浏览文件 @
b21cbbe5
...
...
@@ -37,6 +37,8 @@
#include "pthread_impl.h"
#include "fork_impl.h"
#include "strops.h"
#include "trace/trace_marker.h"
#ifdef OHOS_ENABLE_PARAMETER
#include "sys_param.h"
#endif
...
...
@@ -103,7 +105,7 @@ struct reserved_address_params {
#endif
};
typedef
void
(
*
stage3_func
)(
size_t
*
,
size_t
*
);
typedef
void
(
*
stage3_func
)(
size_t
*
,
size_t
*
,
size_t
*
);
static
struct
builtin_tls
{
char
c
[
8
];
...
...
@@ -304,6 +306,8 @@ static void init_namespace(struct dso *app)
char
file_path
[
sizeof
"/etc/ld-musl-namespace-"
+
sizeof
(
LDSO_ARCH
)
+
sizeof
".ini"
+
1
]
=
{
0
};
(
void
)
snprintf
(
file_path
,
sizeof
file_path
,
"/etc/ld-musl-namespace-%s.ini"
,
LDSO_ARCH
);
LD_LOGI
(
"init_namespace file_path:%{public}s"
,
file_path
);
trace_marker_reset
();
trace_marker_begin
(
HITRACE_TAG_MUSL
,
"parse linker config"
,
file_path
);
int
ret
=
conf
->
parse
(
file_path
,
app_path
);
if
(
ret
<
0
)
{
LD_LOGE
(
"init_namespace ini file parse failed!"
);
...
...
@@ -311,6 +315,7 @@ static void init_namespace(struct dso *app)
if
(
!
sys_path
)
get_sys_path
(
conf
);
init_default_namespace
(
app
);
configor_free
();
trace_marker_end
(
HITRACE_TAG_MUSL
);
return
;
}
...
...
@@ -326,6 +331,7 @@ static void init_namespace(struct dso *app)
if
(
!
nsl
)
{
LD_LOGE
(
"init nslist fail!"
);
configor_free
();
trace_marker_end
(
HITRACE_TAG_MUSL
);
return
;
}
strlist
*
s_ns
=
conf
->
get_namespaces
();
...
...
@@ -345,6 +351,7 @@ static void init_namespace(struct dso *app)
set_ns_inherits
(
nsl
->
nss
[
i
],
conf
);
}
configor_free
();
trace_marker_end
(
HITRACE_TAG_MUSL
);
return
;
}
...
...
@@ -2474,7 +2481,13 @@ static void do_init_fini(struct dso **queue)
if
(
dyn
[
0
]
&
(
1
<<
DT_INIT_ARRAY
))
{
size_t
n
=
dyn
[
DT_INIT_ARRAYSZ
]
/
sizeof
(
size_t
);
size_t
*
fn
=
laddr
(
p
,
dyn
[
DT_INIT_ARRAY
]);
if
(
p
!=
&
ldso
)
{
trace_marker_begin
(
HITRACE_TAG_MUSL
,
"calling constructors: "
,
p
->
name
);
}
while
(
n
--
)
((
void
(
*
)(
void
))
*
fn
++
)();
if
(
p
!=
&
ldso
)
{
trace_marker_end
(
HITRACE_TAG_MUSL
);
}
}
pthread_mutex_lock
(
&
init_fini_lock
);
...
...
@@ -2596,6 +2609,9 @@ hidden void __dls2(unsigned char *base, size_t *sp)
}
else
{
ldso
.
base
=
base
;
}
size_t
aux
[
AUX_CNT
];
decode_vec
(
auxv
,
aux
,
AUX_CNT
);
libc
.
page_size
=
aux
[
AT_PAGESZ
];
Ehdr
*
ehdr
=
(
void
*
)
ldso
.
base
;
ldso
.
name
=
ldso
.
shortname
=
"libc.so"
;
ldso
.
phnum
=
ehdr
->
e_phnum
;
...
...
@@ -2632,8 +2648,8 @@ hidden void __dls2(unsigned char *base, size_t *sp)
* symbolically as a barrier against moving the address
* load across the above relocation processing. */
struct
symdef
dls2b_def
=
find_sym
(
&
ldso
,
"__dls2b"
,
0
);
if
(
DL_FDPIC
)
((
stage3_func
)
&
ldso
.
funcdescs
[
dls2b_def
.
sym
-
ldso
.
syms
])(
sp
,
auxv
);
else
((
stage3_func
)
laddr
(
&
ldso
,
dls2b_def
.
sym
->
st_value
))(
sp
,
auxv
);
if
(
DL_FDPIC
)
((
stage3_func
)
&
ldso
.
funcdescs
[
dls2b_def
.
sym
-
ldso
.
syms
])(
sp
,
auxv
,
aux
);
else
((
stage3_func
)
laddr
(
&
ldso
,
dls2b_def
.
sym
->
st_value
))(
sp
,
auxv
,
aux
);
}
/* Stage 2b sets up a valid thread pointer, which requires relocations
...
...
@@ -2642,7 +2658,7 @@ hidden void __dls2(unsigned char *base, size_t *sp)
* so that loads of the thread pointer and &errno can be pure/const and
* thereby hoistable. */
void
__dls2b
(
size_t
*
sp
,
size_t
*
auxv
)
void
__dls2b
(
size_t
*
sp
,
size_t
*
auxv
,
size_t
*
aux
)
{
/* Setup early thread pointer in builtin_tls for ldso/libc itself to
* use during dynamic linking. If possible it will also serve as the
...
...
@@ -2656,8 +2672,8 @@ void __dls2b(size_t *sp, size_t *auxv)
}
struct
symdef
dls3_def
=
find_sym
(
&
ldso
,
"__dls3"
,
0
);
if
(
DL_FDPIC
)
((
stage3_func
)
&
ldso
.
funcdescs
[
dls3_def
.
sym
-
ldso
.
syms
])(
sp
,
auxv
);
else
((
stage3_func
)
laddr
(
&
ldso
,
dls3_def
.
sym
->
st_value
))(
sp
,
auxv
);
if
(
DL_FDPIC
)
((
stage3_func
)
&
ldso
.
funcdescs
[
dls3_def
.
sym
-
ldso
.
syms
])(
sp
,
auxv
,
aux
);
else
((
stage3_func
)
laddr
(
&
ldso
,
dls3_def
.
sym
->
st_value
))(
sp
,
auxv
,
aux
);
}
/* Stage 3 of the dynamic linker is called with the dynamic linker/libc
...
...
@@ -2665,10 +2681,9 @@ void __dls2b(size_t *sp, size_t *auxv)
* process dependencies and relocations for the main application and
* transfer control to its entry point. */
void
__dls3
(
size_t
*
sp
,
size_t
*
auxv
)
void
__dls3
(
size_t
*
sp
,
size_t
*
auxv
,
size_t
*
aux
)
{
static
struct
dso
app
,
vdso
;
size_t
aux
[
AUX_CNT
];
size_t
i
;
char
*
env_preload
=
0
;
char
*
replace_argv0
=
0
;
...
...
@@ -2681,10 +2696,8 @@ void __dls3(size_t *sp, size_t *auxv)
/* Find aux vector just past environ[] and use it to initialize
* global data that may be needed before we can make syscalls. */
__environ
=
envp
;
decode_vec
(
auxv
,
aux
,
AUX_CNT
);
search_vec
(
auxv
,
&
__sysinfo
,
AT_SYSINFO
);
__pthread_self
()
->
sysinfo
=
__sysinfo
;
libc
.
page_size
=
aux
[
AT_PAGESZ
];
libc
.
secure
=
((
aux
[
0
]
&
0x7800
)
!=
0x7800
||
aux
[
AT_UID
]
!=
aux
[
AT_EUID
]
||
aux
[
AT_GID
]
!=
aux
[
AT_EGID
]
||
aux
[
AT_SECURE
]);
...
...
@@ -3094,6 +3107,8 @@ static void *dlopen_impl(
pthread_setcancelstate
(
PTHREAD_CANCEL_DISABLE
,
&
cs
);
pthread_rwlock_wrlock
(
&
lock
);
__inhibit_ptc
();
trace_marker_reset
();
trace_marker_begin
(
HITRACE_TAG_MUSL
,
"dlopen: "
,
file
);
debug
.
state
=
RT_ADD
;
_dl_debug_state
();
...
...
@@ -3170,12 +3185,14 @@ static void *dlopen_impl(
LD_LOGE
(
"dlopen_impl create loadtask failed"
);
goto
end
;
}
trace_marker_begin
(
HITRACE_TAG_MUSL
,
"loading: entry so"
,
file
);
if
(
!
load_library_header
(
task
))
{
error
(
noload
?
"Library %s is not already loaded"
:
"Error loading shared library %s: %m"
,
file
);
LD_LOGE
(
"dlopen_impl load library header failed for %{public}s"
,
task
->
name
);
trace_marker_end
(
HITRACE_TAG_MUSL
);
// "loading: entry so" trace end.
goto
end
;
}
if
(
reserved_address
)
{
...
...
@@ -3188,6 +3205,7 @@ static void *dlopen_impl(
"Library %s is not already loaded"
:
"Error loading shared library %s: %m"
,
file
);
trace_marker_end
(
HITRACE_TAG_MUSL
);
// "loading: entry so" trace end.
goto
end
;
}
if
(
!
task
->
isloaded
)
{
...
...
@@ -3210,6 +3228,7 @@ static void *dlopen_impl(
free_loadtasks
(
tasks
);
tasks
=
NULL
;
#else
trace_marker_begin
(
HITRACE_TAG_MUSL
,
"loading: entry so"
,
file
);
p
=
load_library
(
file
,
head
,
ns
,
true
,
reserved_address
?
&
reserved_params
:
NULL
);
}
...
...
@@ -3218,11 +3237,13 @@ static void *dlopen_impl(
"Library %s is not already loaded"
:
"Error loading shared library %s: %m"
,
file
);
trace_marker_end
(
HITRACE_TAG_MUSL
);
// "loading: entry so" trace end.
goto
end
;
}
/* First load handling */
load_deps
(
p
,
reserved_address
&&
reserved_address_recursive
?
&
reserved_params
:
NULL
);
#endif
trace_marker_end
(
HITRACE_TAG_MUSL
);
// "loading: entry so" trace end.
extend_bfs_deps
(
p
);
pthread_mutex_lock
(
&
init_fini_lock
);
int
constructed
=
p
->
constructed
;
...
...
@@ -3246,9 +3267,11 @@ static void *dlopen_impl(
}
}
struct
dso
*
reloc_head_so
=
p
;
trace_marker_begin
(
HITRACE_TAG_MUSL
,
"linking: entry so"
,
p
->
name
);
if
(
!
p
->
relocated
)
{
reloc_all
(
p
,
extinfo
);
}
trace_marker_end
(
HITRACE_TAG_MUSL
);
reloc_head_so
->
is_reloc_head_so_dep
=
false
;
for
(
size_t
i
=
0
;
reloc_head_so
->
deps
[
i
];
i
++
)
{
reloc_head_so
->
deps
[
i
]
->
is_reloc_head_so_dep
=
false
;
...
...
@@ -3297,6 +3320,7 @@ end:
free
(
ctor_queue
);
}
pthread_setcancelstate
(
cs
,
0
);
trace_marker_end
(
HITRACE_TAG_MUSL
);
// "dlopen: " trace end.
return
p
;
}
...
...
@@ -3487,31 +3511,19 @@ void *addr2dso(size_t a)
{
struct
dso
*
p
;
size_t
i
;
if
(
DL_FDPIC
)
for
(
p
=
head
;
p
;
p
=
p
->
next
)
{
i
=
count_syms
(
p
);
if
(
a
-
(
size_t
)
p
->
funcdescs
<
i
*
sizeof
(
*
p
->
funcdescs
))
return
p
;
}
for
(
p
=
head
;
p
;
p
=
p
->
next
)
{
if
(
DL_FDPIC
&&
p
->
loadmap
)
{
for
(
i
=
0
;
i
<
p
->
loadmap
->
nsegs
;
i
++
)
{
if
(
a
-
p
->
loadmap
->
segs
[
i
].
p_vaddr
<
p
->
loadmap
->
segs
[
i
].
p_memsz
)
return
p
;
}
}
else
{
Phdr
*
ph
=
p
->
phdr
;
size_t
phcnt
=
p
->
phnum
;
size_t
entsz
=
p
->
phentsize
;
size_t
base
=
(
size_t
)
p
->
base
;
for
(;
phcnt
--
;
ph
=
(
void
*
)((
char
*
)
ph
+
entsz
))
{
if
(
ph
->
p_type
!=
PT_LOAD
)
continue
;
if
(
a
-
base
-
ph
->
p_vaddr
<
ph
->
p_memsz
)
return
p
;
}
if
(
a
-
(
size_t
)
p
->
map
<
p
->
map_len
)
return
0
;
if
(
a
<
p
->
map
||
a
-
(
size_t
)
p
->
map
>=
p
->
map_len
)
continue
;
Phdr
*
ph
=
p
->
phdr
;
size_t
phcnt
=
p
->
phnum
;
size_t
entsz
=
p
->
phentsize
;
size_t
base
=
(
size_t
)
p
->
base
;
for
(;
phcnt
--
;
ph
=
(
void
*
)((
char
*
)
ph
+
entsz
))
{
if
(
ph
->
p_type
!=
PT_LOAD
)
continue
;
if
(
a
-
base
-
ph
->
p_vaddr
<
ph
->
p_memsz
)
return
p
;
}
if
(
a
-
(
size_t
)
p
->
map
<
p
->
map_len
)
return
0
;
}
return
0
;
}
...
...
@@ -3544,8 +3556,11 @@ static void *do_dlsym(struct dso *p, const char *s, const char *v, void *ra)
ns
=
caller
->
namespace
;
}
}
trace_marker_reset
();
trace_marker_begin
(
HITRACE_TAG_MUSL
,
"dlsym: "
,
(
s
==
NULL
?
"(NULL)"
:
s
));
struct
verinfo
verinfo
=
{
.
s
=
s
,
.
v
=
v
,
.
use_vna_hash
=
false
};
struct
symdef
def
=
find_sym2
(
p
,
&
verinfo
,
0
,
use_deps
,
ns
);
trace_marker_end
(
HITRACE_TAG_MUSL
);
if
(
!
def
.
sym
)
{
LD_LOGE
(
"do_dlsym failed: symbol not found. so=%{public}s s=%{public}s v=%{public}s"
,
p
->
name
,
s
,
v
);
error
(
"Symbol not found: %s, version: %s"
,
s
,
strlen
(
v
)
>
0
?
v
:
"null"
);
...
...
@@ -3580,7 +3595,8 @@ static int dlclose_impl(struct dso *p)
if
(
--
(
p
->
nr_dlopen
)
>
0
)
return
0
;
trace_marker_reset
();
trace_marker_begin
(
HITRACE_TAG_MUSL
,
"dlclose"
,
p
->
name
);
/* call destructors if needed */
if
(
p
->
constructed
)
{
size_t
dyn
[
DYN_CNT
];
...
...
@@ -3588,8 +3604,10 @@ static int dlclose_impl(struct dso *p)
if
(
dyn
[
0
]
&
(
1
<<
DT_FINI_ARRAY
))
{
n
=
dyn
[
DT_FINI_ARRAYSZ
]
/
sizeof
(
size_t
);
size_t
*
fn
=
(
size_t
*
)
laddr
(
p
,
dyn
[
DT_FINI_ARRAY
])
+
n
;
trace_marker_begin
(
HITRACE_TAG_MUSL
,
"calling destructors:"
,
p
->
name
);
while
(
n
--
)
((
void
(
*
)(
void
))
*--
fn
)();
trace_marker_end
(
HITRACE_TAG_MUSL
);
}
p
->
constructed
=
0
;
}
...
...
@@ -3667,6 +3685,7 @@ static int dlclose_impl(struct dso *p)
if
(
p
->
tls
.
size
==
0
)
{
free
(
p
);
}
trace_marker_end
(
HITRACE_TAG_MUSL
);
return
0
;
}
...
...
@@ -3746,15 +3765,71 @@ hidden int __dlclose(void *p)
return
rc
;
}
static
inline
int
sym_is_matched
(
const
Sym
*
sym
,
size_t
addr_offset_so
)
{
return
sym
->
st_value
&&
(
1
<<
(
sym
->
st_info
&
0xf
)
!=
STT_TLS
)
&&
(
addr_offset_so
>=
sym
->
st_value
)
&&
(
addr_offset_so
<
sym
->
st_value
+
sym
->
st_size
);
}
static
inline
Sym
*
find_addr_by_elf
(
size_t
addr_offset_so
,
struct
dso
*
p
)
{
uint32_t
nsym
=
p
->
hashtab
[
1
];
Sym
*
sym
=
p
->
syms
;
for
(;
nsym
;
nsym
--
,
sym
++
)
{
if
(
sym_is_matched
(
sym
,
addr_offset_so
))
{
return
sym
;
}
}
return
NULL
;
}
static
inline
Sym
*
find_addr_by_gnu
(
size_t
addr_offset_so
,
struct
dso
*
p
)
{
size_t
i
,
nsym
,
first_hash_sym_index
;
uint32_t
*
hashval
;
Sym
*
sym_tab
=
p
->
syms
;
uint32_t
*
buckets
=
p
->
ghashtab
+
4
+
(
p
->
ghashtab
[
2
]
*
sizeof
(
size_t
)
/
4
);
// Points to the first defined symbol, all symbols before it are undefined.
first_hash_sym_index
=
buckets
[
0
];
Sym
*
sym
=
&
sym_tab
[
first_hash_sym_index
];
// Get the location pointed by the last bucket.
for
(
i
=
nsym
=
0
;
i
<
p
->
ghashtab
[
0
];
i
++
)
{
if
(
buckets
[
i
]
>
nsym
)
nsym
=
buckets
[
i
];
}
for
(
i
=
first_hash_sym_index
;
i
<
nsym
;
i
++
)
{
if
(
sym_is_matched
(
sym
,
addr_offset_so
))
{
return
sym
;
}
sym
++
;
}
// Start traversing the hash list from the position pointed to by the last bucket.
if
(
nsym
)
{
hashval
=
buckets
+
p
->
ghashtab
[
0
]
+
(
nsym
-
p
->
ghashtab
[
1
]);
do
{
nsym
++
;
if
(
sym_is_matched
(
sym
,
addr_offset_so
))
{
return
sym
;
}
sym
++
;
}
while
(
!
(
*
hashval
++
&
1
));
}
return
NULL
;
}
int
dladdr
(
const
void
*
addr_arg
,
Dl_info
*
info
)
{
size_t
addr
=
(
size_t
)
addr_arg
;
struct
dso
*
p
;
Sym
*
sym
,
*
bestsym
;
uint32_t
nsym
;
Sym
*
match_sym
=
NULL
;
char
*
strings
;
size_t
best
=
0
;
size_t
besterr
=
-
1
;
pthread_rwlock_rdlock
(
&
lock
);
p
=
addr2dso
(
addr
);
...
...
@@ -3762,54 +3837,26 @@ int dladdr(const void *addr_arg, Dl_info *info)
if
(
!
p
)
return
0
;
sym
=
p
->
syms
;
strings
=
p
->
strings
;
nsym
=
count_syms
(
p
)
;
size_t
addr_offset_so
=
addr
-
(
size_t
)
p
->
base
;
if
(
DL_FDPIC
)
{
size_t
idx
=
(
addr
-
(
size_t
)
p
->
funcdescs
)
/
sizeof
(
*
p
->
funcdescs
);
if
(
idx
<
nsym
&&
(
sym
[
idx
].
st_info
&
0xf
)
==
STT_FUNC
)
{
best
=
(
size_t
)(
p
->
funcdescs
+
idx
);
bestsym
=
sym
+
idx
;
besterr
=
0
;
}
}
info
->
dli_fname
=
p
->
name
;
info
->
dli_fbase
=
p
->
map
;
if
(
!
best
)
for
(;
nsym
;
nsym
--
,
sym
++
)
{
if
(
sym
->
st_value
&&
(
1
<<
(
sym
->
st_info
&
0xf
)
&
OK_TYPES
)
&&
(
1
<<
(
sym
->
st_info
>>
4
)
&
OK_BINDS
))
{
size_t
symaddr
=
(
size_t
)
laddr
(
p
,
sym
->
st_value
);
if
(
symaddr
>
addr
||
symaddr
<=
best
)
continue
;
best
=
symaddr
;
bestsym
=
sym
;
besterr
=
addr
-
symaddr
;
if
(
addr
==
symaddr
)
break
;
}
}
if
(
p
->
ghashtab
)
{
match_sym
=
find_addr_by_gnu
(
addr_offset_so
,
p
);
if
(
best
&&
besterr
>
bestsym
->
st_size
-
1
)
{
best
=
0
;
bestsym
=
0
;
}
else
{
match_sym
=
find_addr_by_elf
(
addr_offset_so
,
p
);
}
info
->
dli_fname
=
p
->
name
;
info
->
dli_fbase
=
p
->
map
;
if
(
!
best
)
{
if
(
!
match_sym
)
{
info
->
dli_sname
=
0
;
info
->
dli_saddr
=
0
;
return
1
;
}
if
(
DL_FDPIC
&&
(
bestsym
->
st_info
&
0xf
)
==
STT_FUNC
)
best
=
(
size_t
)(
p
->
funcdescs
+
(
bestsym
-
p
->
syms
));
info
->
dli_sname
=
strings
+
bestsym
->
st_name
;
info
->
dli_saddr
=
(
void
*
)
best
;
info
->
dli_sname
=
strings
+
match_sym
->
st_name
;
info
->
dli_saddr
=
(
void
*
)
laddr
(
p
,
match_sym
->
st_value
);
return
1
;
}
...
...
@@ -4054,7 +4101,7 @@ void* dlopen_ext(const char *file, int mode, const dl_extinfo *extinfo)
mode
,
caller_addr
,
extinfo
?
extinfo
->
flag
:
0
);
return
dlopen_impl
(
file
,
mode
,
NULL
,
caller_addr
,
extinfo
);
return
dlopen_impl
(
file
,
mode
,
NULL
,
caller_addr
,
extinfo
);
}
#ifdef LOAD_ORDER_RANDOMIZATION
...
...
porting/linux/user/src/env/getenv.c
0 → 100644
浏览文件 @
b21cbbe5
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
char
*
getenv
(
const
char
*
name
)
{
if
(
name
==
NULL
||
__environ
==
NULL
)
return
0
;
size_t
i
,
l
=
0
;
const
char
*
np
;
char
**
p
,
*
ep
;
for
(;
*
(
name
+
l
)
&&
*
(
name
+
l
)
!=
'='
;
++
l
);
for
(
p
=
__environ
;
(
ep
=
*
p
)
!=
NULL
;
++
p
)
{
for
(
np
=
name
,
i
=
l
;
i
&&
*
ep
;
i
--
)
{
if
(
*
ep
++
!=
*
np
++
)
{
break
;
}
}
if
(
i
==
0
&&
*
ep
++
==
'='
)
{
return
(
ep
);
}
}
return
0
;
}
porting/linux/user/src/internal/pthread_impl.h
浏览文件 @
b21cbbe5
...
...
@@ -74,9 +74,6 @@ struct pthread {
volatile
int
killlock
[
1
];
char
*
dlerror_buf
;
void
*
stdio_locks
;
#ifdef RESERVE_SIGNAL_STACK
void
*
signal_stack
;
#endif
/* Part 3 -- the positions of these fields relative to
* the end of the structure is external and internal ABI. */
...
...
porting/linux/user/src/internal/stdio_impl.h
0 → 100644
浏览文件 @
b21cbbe5
#ifndef _STDIO_IMPL_H
#define _STDIO_IMPL_H
#include <stdio.h>
#include "syscall.h"
#define UNGET 8
#define FFINALLOCK(f) ((f)->lock>=0 ? __lockfile((f)) : 0)
#define FLOCK(f) int __need_unlock = ((f)->lock>=0 ? __lockfile((f)) : 0)
#define FUNLOCK(f) do { if (__need_unlock) __unlockfile((f)); } while (0)
#define F_PERM 1
#define F_NORD 4
#define F_NOWR 8
#define F_EOF 16
#define F_ERR 32
#define F_SVB 64
#define F_APP 128
struct
_IO_FILE
{
unsigned
flags
;
unsigned
char
*
rpos
,
*
rend
;
int
(
*
close
)(
FILE
*
);
unsigned
char
*
wend
,
*
wpos
;
unsigned
char
*
mustbezero_1
;
unsigned
char
*
wbase
;
size_t
(
*
read
)(
FILE
*
,
unsigned
char
*
,
size_t
);
size_t
(
*
readx
)(
FILE
*
,
unsigned
char
*
,
size_t
);
size_t
(
*
write
)(
FILE
*
,
const
unsigned
char
*
,
size_t
);
off_t
(
*
seek
)(
FILE
*
,
off_t
,
int
);
unsigned
char
*
buf
;
size_t
buf_size
;
FILE
*
prev
,
*
next
;
int
fd
;
int
pipe_pid
;
long
lockcount
;
int
mode
;
volatile
int
lock
;
int
lbf
;
void
*
cookie
;
off_t
off
;
char
*
getln_buf
;
void
*
mustbezero_2
;
unsigned
char
*
shend
;
off_t
shlim
,
shcnt
;
FILE
*
prev_locked
,
*
next_locked
;
struct
__locale_struct
*
locale
;
};
extern
hidden
FILE
*
volatile
__stdin_used
;
extern
hidden
FILE
*
volatile
__stdout_used
;
extern
hidden
FILE
*
volatile
__stderr_used
;
hidden
int
__lockfile
(
FILE
*
);
hidden
void
__unlockfile
(
FILE
*
);
hidden
size_t
__stdio_read
(
FILE
*
,
unsigned
char
*
,
size_t
);
hidden
size_t
__stdio_readx
(
FILE
*
,
unsigned
char
*
,
size_t
);
hidden
size_t
__stdio_write
(
FILE
*
,
const
unsigned
char
*
,
size_t
);
hidden
size_t
__stdout_write
(
FILE
*
,
const
unsigned
char
*
,
size_t
);
hidden
off_t
__stdio_seek
(
FILE
*
,
off_t
,
int
);
hidden
int
__stdio_close
(
FILE
*
);
hidden
int
__fill_buffer
(
FILE
*
f
);
hidden
int
__toread
(
FILE
*
);
hidden
int
__towrite
(
FILE
*
);
hidden
void
__stdio_exit
(
void
);
hidden
void
__stdio_exit_needed
(
void
);
#if defined(__PIC__) && (100*__GNUC__+__GNUC_MINOR__ >= 303)
__attribute__
((
visibility
(
"protected"
)))
#endif
int
__overflow
(
FILE
*
,
int
),
__uflow
(
FILE
*
);
hidden
int
__fseeko
(
FILE
*
,
off_t
,
int
);
hidden
int
__fseeko_unlocked
(
FILE
*
,
off_t
,
int
);
hidden
off_t
__ftello
(
FILE
*
);
hidden
off_t
__ftello_unlocked
(
FILE
*
);
hidden
size_t
__fwritex
(
const
unsigned
char
*
,
size_t
,
FILE
*
);
hidden
int
__putc_unlocked
(
int
,
FILE
*
);
hidden
FILE
*
__fdopen
(
int
,
const
char
*
);
hidden
int
__fmodeflags
(
const
char
*
);
hidden
FILE
*
__ofl_add
(
FILE
*
f
);
hidden
FILE
**
__ofl_lock
(
void
);
hidden
void
__ofl_unlock
(
void
);
struct
__pthread
;
hidden
void
__register_locked_file
(
FILE
*
,
struct
__pthread
*
);
hidden
void
__unlist_locked_file
(
FILE
*
);
hidden
void
__do_orphaned_stdio_locks
(
void
);
#define MAYBE_WAITERS 0x40000000
hidden
void
__getopt_msg
(
const
char
*
,
const
char
*
,
const
char
*
,
size_t
);
#define feof(f) ((f)->flags & F_EOF)
#define ferror(f) ((f)->flags & F_ERR)
#define getc_unlocked(f) \
( ((f)->rpos != (f)->rend) ? *(f)->rpos++ : __uflow((f)) )
#define putc_unlocked(c, f) \
( (((unsigned char)(c)!=(f)->lbf && (f)->wpos!=(f)->wend)) \
? *(f)->wpos++ = (unsigned char)(c) \
: __overflow((f),(unsigned char)(c)) )
/* Caller-allocated FILE * operations */
hidden
FILE
*
__fopen_rb_ca
(
const
char
*
,
FILE
*
,
unsigned
char
*
,
size_t
);
hidden
int
__fclose_ca
(
FILE
*
);
#endif
porting/linux/user/src/network/lookup_name.c
浏览文件 @
b21cbbe5
...
...
@@ -152,7 +152,11 @@ static int name_from_dns(struct address buf[static MAXADDRS], char canon[static
{
.
af
=
AF_INET
,
.
rr
=
RR_AAAA
},
};
#ifdef STANDARD_SYSTEM
for
(
i
=
0
;
i
<
1
;
i
++
)
{
#else
for
(
i
=
0
;
i
<
2
;
i
++
)
{
#endif
if
(
family
!=
afrr
[
i
].
af
)
{
qlens
[
nq
]
=
__res_mkquery
(
0
,
name
,
1
,
afrr
[
i
].
rr
,
0
,
0
,
0
,
qbuf
[
nq
],
sizeof
*
qbuf
);
...
...
porting/linux/user/src/network/resolvconf.c
浏览文件 @
b21cbbe5
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "lookup.h"
#include "stdio_impl.h"
#include <ctype.h>
...
...
@@ -5,8 +20,89 @@
#include <string.h>
#include <stdlib.h>
#include <netinet/in.h>
#define DNS_RESOLV_CONF_PATH "/etc/resolv.conf"
#if OHOS_DNS_PROXY_BY_NETSYS
#include "atomic.h"
#include <dlfcn.h>
static
void
*
open_dns_lib
(
void
)
{
static
void
*
dns_lib_handle
=
NULL
;
if
(
dns_lib_handle
!=
NULL
)
{
a_barrier
();
return
dns_lib_handle
;
}
void
*
lib
=
dlopen
(
DNS_SO_PATH
,
RTLD_LAZY
);
if
(
lib
==
NULL
)
{
DNS_CONFIG_PRINT
(
"%s: dlopen %s failed: %s"
,
__func__
,
DNS_SO_PATH
,
dlerror
());
return
NULL
;
}
void
*
old_lib
=
a_cas_p
(
&
dns_lib_handle
,
NULL
,
lib
);
if
(
old_lib
==
NULL
)
{
DNS_CONFIG_PRINT
(
"%s: %s loaded"
,
__func__
,
DNS_SO_PATH
);
return
lib
;
}
else
{
/* Another thread has already loaded the library,
* dlclose is invoked to make refcount correct */
DNS_CONFIG_PRINT
(
"%s: %s has been loaded by another thread"
,
__func__
,
DNS_SO_PATH
);
if
(
dlclose
(
lib
))
{
DNS_CONFIG_PRINT
(
"%s: dlclose %s failed: %s"
,
__func__
,
DNS_SO_PATH
,
dlerror
());
}
return
old_lib
;
}
}
static
void
*
load_from_dns_lib
(
const
char
*
symbol
)
{
void
*
lib_handle
=
open_dns_lib
();
if
(
lib_handle
==
NULL
)
{
return
NULL
;
}
void
*
sym_addr
=
dlsym
(
lib_handle
,
symbol
);
if
(
sym_addr
==
NULL
)
{
DNS_CONFIG_PRINT
(
"%s: loading symbol %s with dlsym failed: %s"
,
__func__
,
symbol
,
dlerror
());
}
return
sym_addr
;
}
void
resolve_dns_sym
(
void
**
holder
,
const
char
*
symbol
)
{
if
(
*
holder
!=
NULL
)
{
a_barrier
();
return
;
}
void
*
ptr
=
load_from_dns_lib
(
symbol
);
if
(
ptr
==
NULL
)
{
return
;
}
void
*
old_ptr
=
a_cas_p
(
holder
,
NULL
,
ptr
);
if
(
old_ptr
!=
NULL
)
{
DNS_CONFIG_PRINT
(
"%s: %s has been found by another thread"
,
__func__
,
symbol
);
}
else
{
DNS_CONFIG_PRINT
(
"%s: %s found"
,
__func__
,
symbol
);
}
}
static
GetConfig
load_config_getter
(
void
)
{
static
GetConfig
config_getter
=
NULL
;
resolve_dns_sym
((
void
**
)
&
config_getter
,
OHOS_GET_CONFIG_FUNC_NAME
);
return
config_getter
;
}
#endif
int
__get_resolv_conf
(
struct
resolvconf
*
conf
,
char
*
search
,
size_t
search_sz
)
...
...
@@ -22,22 +118,15 @@ int __get_resolv_conf(struct resolvconf *conf, char *search, size_t search_sz)
if
(
search
)
*
search
=
0
;
#if OHOS_DNS_PROXY_BY_NETSYS
void
*
handle
=
dlopen
(
DNS_SO_PATH
,
RTLD_LAZY
);
if
(
handle
==
NULL
)
{
DNS_CONFIG_PRINT
(
"__get_resolv_conf dlopen err %s
\n
"
,
dlerror
());
goto
etc_resolv_conf
;
}
GetConfig
func
=
dlsym
(
handle
,
OHOS_GET_CONFIG_FUNC_NAME
);
if
(
func
==
NULL
)
{
DNS_CONFIG_PRINT
(
"__get_resolv_conf dlsym err %s
\n
"
,
dlerror
());
dlclose
(
handle
);
GetConfig
func
=
load_config_getter
();
if
(
!
func
)
{
DNS_CONFIG_PRINT
(
"%s: loading %s failed, use %s as a fallback"
,
__func__
,
OHOS_GET_CONFIG_FUNC_NAME
,
DNS_RESOLV_CONF_PATH
);
goto
etc_resolv_conf
;
}
struct
resolv_config
config
=
{
0
};
int
ret
=
func
(
0
,
&
config
);
dlclose
(
handle
);
if
(
ret
<
0
)
{
DNS_CONFIG_PRINT
(
"__get_resolv_conf OHOS_GET_CONFIG_FUNC_NAME err %d
\n
"
,
ret
);
return
EAI_NONAME
;
...
...
@@ -74,7 +163,7 @@ netsys_conf:
etc_resolv_conf:
#endif
f
=
__fopen_rb_ca
(
"/etc/resolv.conf"
,
&
_f
,
_buf
,
sizeof
_buf
);
f
=
__fopen_rb_ca
(
DNS_RESOLV_CONF_PATH
,
&
_f
,
_buf
,
sizeof
_buf
);
if
(
!
f
)
switch
(
errno
)
{
case
ENOENT
:
case
ENOTDIR
:
...
...
porting/linux/user/src/sigchain/sigchain.c
浏览文件 @
b21cbbe5
...
...
@@ -45,7 +45,7 @@ extern int __libc_sigaction(int sig, const struct sigaction *restrict sa,
#define SIGCHAIN_PRINT_ERROR(...)
#define SIGCHAIN_PRINT_INFO(...)
#define SIGCHAIN_PRINT_DEBUG(...)
#define SIGCHAIN_LOG_FATAL(...)
#define SIGCHAIN_LOG_FATAL(...)
#endif
#define SIGCHAIN_PRINT_FATAL(...) do { \
...
...
@@ -167,7 +167,7 @@ static void signal_chain_handler(int signo, siginfo_t* siginfo, void* ucontext_r
sigchain_sigmask
(
SIG_SETMASK
,
&
sig_chains
[
signo
-
1
].
sca_special_actions
[
i
].
sca_mask
,
&
previous_mask
);
bool
previous_value
=
get_handling_signal
();
bool
previous_value
=
get_handling_signal
();
if
(
!
noreturn
)
{
set_handling_signal
(
true
);
}
...
...
@@ -201,8 +201,13 @@ static void signal_chain_handler(int signo, siginfo_t* siginfo, void* ucontext_r
if
(
sig_chains
[
signo
-
1
].
sig_action
.
sa_handler
==
SIG_IGN
)
{
return
;
}
else
if
(
sig_chains
[
signo
-
1
].
sig_action
.
sa_handler
==
SIG_DFL
)
{
SIGCHAIN_PRINT_FATAL
(
"%{public}s exiting due to SIG_DFL handler for signal: %{public}d"
,
__func__
,
signo
);
SIGCHAIN_PRINT_DEBUG
(
"%{public}s SIG_DFL handler for signal: %{public}d"
,
__func__
,
signo
);
remove_all_special_handler
(
signo
);
if
(
__syscall
(
SYS_rt_tgsigqueueinfo
,
__syscall
(
SYS_getpid
),
__syscall
(
SYS_gettid
),
signo
,
siginfo
)
!=
0
)
{
SIGCHAIN_PRINT_ERROR
(
"Failed to rethrow sig(%{public}d), errno(%{public}d)."
,
signo
,
errno
);
}
else
{
SIGCHAIN_PRINT_INFO
(
"pid(%{public}d) rethrow sig(%{public}d)."
,
__syscall
(
SYS_getpid
),
signo
);
}
}
else
{
sig_chains
[
signo
-
1
].
sig_action
.
sa_handler
(
signo
);
}
...
...
porting/linux/user/src/stdio/__fdopen.c
浏览文件 @
b21cbbe5
...
...
@@ -93,6 +93,7 @@ FILE *__fdopen(int fd, const char *mode)
f
->
write
=
__stdio_write
;
f
->
seek
=
__stdio_seek
;
f
->
close
=
__stdio_close
;
f
->
readx
=
__stdio_readx
;
if
(
!
libc
.
threaded
)
{
f
->
lock
=
-
1
;
...
...
porting/linux/user/src/stdio/__stdio_read.c
0 → 100644
浏览文件 @
b21cbbe5
#include "stdio_impl.h"
#include <sys/uio.h>
size_t
__stdio_readx
(
FILE
*
f
,
unsigned
char
*
buf
,
size_t
len
)
{
return
syscall
(
SYS_read
,
f
->
fd
,
buf
,
len
);
}
size_t
__stdio_read
(
FILE
*
f
,
unsigned
char
*
buf
,
size_t
len
)
{
struct
iovec
iov_buf
[
2
]
=
{
{
.
iov_base
=
buf
,
.
iov_len
=
len
-
!!
f
->
buf_size
},
{
.
iov_base
=
f
->
buf
,
.
iov_len
=
f
->
buf_size
}
};
ssize_t
cnt
;
cnt
=
iov_buf
[
0
].
iov_len
?
syscall
(
SYS_readv
,
f
->
fd
,
iov_buf
,
2
)
:
syscall
(
SYS_read
,
f
->
fd
,
iov_buf
[
1
].
iov_base
,
iov_buf
[
1
].
iov_len
);
if
(
cnt
<=
0
)
{
f
->
flags
|=
cnt
?
F_ERR
:
F_EOF
;
return
0
;
}
if
(
cnt
<=
iov_buf
[
0
].
iov_len
)
{
return
cnt
;
}
cnt
-=
iov_buf
[
0
].
iov_len
;
f
->
rpos
=
f
->
buf
;
f
->
rend
=
f
->
buf
+
cnt
;
if
(
f
->
buf_size
)
buf
[
len
-
1
]
=
*
f
->
rpos
++
;
return
len
;
}
porting/linux/user/src/stdio/fread.c
0 → 100644
浏览文件 @
b21cbbe5
#include "stdio_impl.h"
#include <string.h>
#define MIN(a,b) ((a)<(b) ? (a) : (b))
int
__fill_buffer
(
FILE
*
f
)
{
int
r
=
__toread
(
f
);
if
(
r
!=
0
)
{
return
r
;
}
int
k
=
f
->
readx
(
f
,
f
->
buf
,
f
->
buf_size
);
if
(
k
<=
0
)
{
f
->
flags
|=
(
k
==
0
)
?
F_EOF
:
F_ERR
;
f
->
rpos
=
f
->
rend
;
return
k
;
}
f
->
rpos
=
f
->
buf
;
f
->
rend
=
f
->
rpos
+
k
;
return
0
;
}
size_t
fread
(
void
*
restrict
destv
,
size_t
size
,
size_t
nmemb
,
FILE
*
restrict
f
)
{
unsigned
char
*
dest
=
destv
;
size_t
len
=
size
*
nmemb
,
l
=
len
,
k
;
if
(
!
size
)
{
nmemb
=
0
;
}
FLOCK
(
f
);
f
->
mode
|=
f
->
mode
-
1
;
while
(
l
>
0
)
{
if
(
f
->
rpos
!=
f
->
rend
)
{
/* First exhaust the buffer. */
k
=
MIN
(
f
->
rend
-
f
->
rpos
,
l
);
memcpy
(
dest
,
f
->
rpos
,
k
);
f
->
rpos
+=
k
;
dest
+=
k
;
l
-=
k
;
}
/* done */
if
(
l
==
0
)
{
goto
exit
;
}
/* if user buffer is longer than file buffer, read directly */
if
(
l
>
f
->
buf_size
)
{
break
;
}
if
(
__fill_buffer
(
f
))
{
goto
exit
;
}
}
/* Read the remainder directly */
for
(;
l
;
l
-=
k
,
dest
+=
k
)
{
k
=
f
->
readx
(
f
,
dest
,
l
);
if
(
k
<=
0
)
{
f
->
flags
|=
(
k
==
0
?
F_EOF
:
F_ERR
);
break
;
}
}
exit:
FUNLOCK
(
f
);
return
(
len
-
l
)
/
size
;
}
weak_alias
(
fread
,
fread_unlocked
);
porting/linux/user/src/thread/pthread_create.c
浏览文件 @
b21cbbe5
...
...
@@ -61,7 +61,6 @@ void __pthread_reserve_signal_stack()
sigaltstack
(
&
signal_stack
,
NULL
);
pthread_t
self
=
__pthread_self
();
self
->
signal_stack
=
stack
;
char
name
[
ANON_STACK_NAME_SIZE
];
snprintf
(
name
,
ANON_STACK_NAME_SIZE
,
"signal_stack:%d"
,
__pthread_self
()
->
tid
);
prctl
(
PR_SET_VMA
,
PR_SET_VMA_ANON_NAME
,
signal_stack
.
ss_sp
,
signal_stack
.
ss_size
,
name
);
...
...
@@ -70,17 +69,13 @@ void __pthread_reserve_signal_stack()
void
__pthread_release_signal_stack
()
{
pthread_t
self
=
__pthread_self
();
if
(
self
->
signal_stack
==
NULL
)
{
return
;
}
stack_t
signal_stack
;
stack_t
signal_stack
,
old_stack
;
memset
(
&
signal_stack
,
0
,
sizeof
(
signal_stack
));
signal_stack
.
ss_flags
=
SS_DISABLE
;
sigaltstack
(
&
signal_stack
,
NULL
);
munmap
(
self
->
signal_stack
,
RESERVE_SIGNAL_STACK_SIZE
);
self
->
signal_stack
=
NULL
;
sigaltstack
(
&
signal_stack
,
&
old_stack
);
if
(
old_stack
.
ss_flags
!=
SS_DISABLE
)
{
munmap
(
old_stack
.
ss_sp
,
old_stack
.
ss_size
);
}
}
weak_alias
(
__pthread_reserve_signal_stack
,
pthread_reserve_signal_stack
);
...
...
porting/linux/user/src/trace/trace_marker.c
浏览文件 @
b21cbbe5
...
...
@@ -24,22 +24,58 @@
#include <sys/types.h>
#include <unistd.h>
#include "musl_log.h"
#ifdef OHOS_ENABLE_PARAMETER
#include "sys_param.h"
#endif
#ifndef MUSL_TEMP_FAILURE_RETRY
#define MUSL_TEMP_FAILURE_RETRY(exp)
\
({ \
long int _rc; \
do { \
_rc = (long int)(exp); \
#define MUSL_TEMP_FAILURE_RETRY(exp) \
({
\
long int _rc;
\
do {
\
_rc = (long int)(exp);
\
} while ((_rc == -1) && (errno == EINTR)); \
_rc; \
_rc;
\
})
#endif
#define LIKELY(exp) (__builtin_expect(!!(exp), 1))
#ifdef OHOS_ENABLE_PARAMETER
#define TRACE_PROPERTY_FLAG "debug.hitrace.tags.enableflags"
static
uint64_t
g_trace_switch_status
=
0
;
uint64_t
get_uint64_sysparam
(
CachedHandle
cachedhandle
)
{
char
*
param_value
=
CachedParameterGet
(
cachedhandle
);
if
(
param_value
!=
NULL
)
{
return
strtoull
(
param_value
,
NULL
,
0
);
}
return
0
;
}
#endif
void
trace_marker_reset
(
void
)
{
#ifdef OHOS_ENABLE_PARAMETER
static
CachedHandle
trace_switch_handle
=
NULL
;
if
(
trace_switch_handle
==
NULL
)
{
trace_switch_handle
=
CachedParameterCreate
(
TRACE_PROPERTY_FLAG
,
"0"
);
}
g_trace_switch_status
=
get_uint64_sysparam
(
trace_switch_handle
);
#else
return
;
#endif
}
// Check whether the user space trace function is enabled
static
inline
bool
is_enable_trace
(
void
)
static
inline
bool
is_enable_trace
(
uint64_t
label
)
{
return
true
;
#ifdef OHOS_ENABLE_PARAMETER
return
(((
g_trace_switch_status
&
label
)
!=
0
)
||
((
g_trace_switch_status
&
HITRACE_TAG_ALWAYS
)
!=
0
));
#else
return
false
;
#endif
}
// Get the fd of trace_marker
...
...
@@ -54,9 +90,9 @@ static inline int get_trace_marker_fd(void)
/* Write the function call information to the trace_marker node in kernel space,
used on the same thread as trace_marker_end(),with the symbol "B". */
void
trace_marker_begin
(
const
char
*
message
,
const
char
*
value
)
void
trace_marker_begin
(
uint64_t
label
,
const
char
*
message
,
const
char
*
value
)
{
if
(
!
is_enable_trace
()
||
message
==
NULL
)
{
if
(
LIKELY
((
!
is_enable_trace
(
label
)
||
message
==
NULL
))
)
{
return
;
}
...
...
@@ -68,7 +104,7 @@ void trace_marker_begin(const char *message, const char *value)
char
buf
[
TRACE_MARKER_MESSAGE_LEN
]
=
{
0
};
int
len
=
0
;
if
(
value
==
NULL
)
{
len
=
snprintf
(
buf
,
TRACE_MARKER_MESSAGE_LEN
,
"B|%d
%s"
,
getpid
(),
message
);
len
=
snprintf
(
buf
,
TRACE_MARKER_MESSAGE_LEN
,
"B|%d
|
%s"
,
getpid
(),
message
);
}
else
{
len
=
snprintf
(
buf
,
TRACE_MARKER_MESSAGE_LEN
,
"B|%d|%s %s"
,
getpid
(),
message
,
value
);
}
...
...
@@ -87,9 +123,9 @@ void trace_marker_begin(const char *message, const char *value)
/* Write the terminator to the trace_marker node of the kernel space,
used on the same thread as trace_marker_begin(),with the symbol "E". */
void
trace_marker_end
(
void
)
void
trace_marker_end
(
uint64_t
label
)
{
if
(
!
is_enable_trace
(
))
{
if
(
LIKELY
(
!
is_enable_trace
(
label
)
))
{
return
;
}
...
...
@@ -115,9 +151,9 @@ void trace_marker_end(void)
/* Write the function call information to the trace_marker node in kernel space,
used in a different thread than trace_marker_async_end(),with the symbol "S". */
void
trace_marker_async_begin
(
const
char
*
message
,
const
char
*
value
,
int
taskId
)
void
trace_marker_async_begin
(
uint64_t
label
,
const
char
*
message
,
const
char
*
value
,
int
taskId
)
{
if
(
!
is_enable_trace
()
||
message
==
NULL
)
{
if
(
LIKELY
((
!
is_enable_trace
(
label
)
||
message
==
NULL
))
)
{
return
;
}
...
...
@@ -148,9 +184,9 @@ void trace_marker_async_begin(const char *message, const char *value, int taskId
/* Write the terminator to the trace_marker node in kernel space,
used in a different thread than trace_marker_async_begin(),with the symbol "F". */
void
trace_marker_async_end
(
const
char
*
message
,
const
char
*
value
,
int
taskId
)
void
trace_marker_async_end
(
uint64_t
label
,
const
char
*
message
,
const
char
*
value
,
int
taskId
)
{
if
(
!
is_enable_trace
()
||
message
==
NULL
)
{
if
(
LIKELY
((
!
is_enable_trace
(
label
)
||
message
==
NULL
))
)
{
return
;
}
...
...
@@ -180,9 +216,9 @@ void trace_marker_async_end(const char *message, const char *value, int taskId)
}
// A numeric variable used to mark a pre trace, with the symbol "C".
void
trace_marker_count
(
const
char
*
message
,
int
value
)
void
trace_marker_count
(
uint64_t
label
,
const
char
*
message
,
int
value
)
{
if
(
!
is_enable_trace
()
||
message
==
NULL
)
{
if
(
LIKELY
((
!
is_enable_trace
(
label
)
||
message
==
NULL
))
)
{
return
;
}
...
...
porting/liteos_a/user/src/thread/pthread_create.c
浏览文件 @
b21cbbe5
...
...
@@ -70,18 +70,6 @@ _Noreturn void __pthread_exit(void *result)
__block_app_sigs
(
&
set
);
/* This atomic potentially competes with a concurrent pthread_detach
* call; the loser is responsible for freeing thread resources. */
int
state
=
a_cas
(
&
self
->
detach_state
,
DT_JOINABLE
,
DT_EXITING
);
if
(
state
==
DT_DETACHED
&&
self
->
map_base
)
{
/* Since __unmapself bypasses the normal munmap code path,
* explicitly wait for vmlock holders first. This must be
* done before any locks are taken, to avoid lock ordering
* issues that could lead to deadlock. */
__vm_wait
();
}
/* Access to target the exiting thread with syscalls that use
* its kernel tid is controlled by killlock. For detached threads,
* any use past this point would have undefined behavior, but for
...
...
@@ -99,7 +87,6 @@ _Noreturn void __pthread_exit(void *result)
if
(
self
->
next
==
self
)
{
__tl_unlock
();
UNLOCK
(
self
->
killlock
);
self
->
detach_state
=
state
;
__restore_sigs
(
&
set
);
exit
(
0
);
}
...
...
@@ -138,6 +125,10 @@ _Noreturn void __pthread_exit(void *result)
self
->
prev
->
next
=
self
->
next
;
self
->
prev
=
self
->
next
=
self
;
/* This atomic potentially competes with a concurrent pthread_detach
* call; the loser is responsible for freeing thread resources. */
int
state
=
a_cas
(
&
self
->
detach_state
,
DT_JOINABLE
,
DT_EXITING
);
#if 0
if (state==DT_DETACHED && self->map_base) {
/* Robust list will no longer be valid, and was already
...
...
scripts/runtest.sh
浏览文件 @
b21cbbe5
...
...
@@ -7,6 +7,13 @@ touch /data/tests/libc-test/REPORT
touch
/data/tests/libc-test/FileList.txt
touch
/data/tests/libc-test/SkipList.txt
echo
'root:This.is.a.test:18997:0:99999:7:::'
>
/etc/shadow
param
set
debug.hitrace.tags.enableflags 1
ARCH
=
arm
ABILIST
=
$(
param get const.product.cpu.abilist
)
if
[
$ABILIST
==
"arm64-v8a"
]
;
then
ARCH
=
aarch64
fi
function
FileSuffix
()
{
local
filename
=
"
$1
"
...
...
@@ -29,8 +36,15 @@ ShieldedList=("trace_stresstest" "syslog" "vsyslog" "runtest"
#Some math test cases need to skip.
"acoshl"
"asinhl"
"erfcl"
"fenv"
"fma"
"fmaf"
"fmal"
"lgammal"
"nearbyint"
"nearbyintf"
"nearbyintl"
"rint"
"rintf"
"rintl"
"sqrt"
"sqrtf"
"sqrtl"
"tgammal"
#TODO-arm32
"dlopen_ns"
"malloc-brk-fail"
"pthread_cancel"
"res_send"
)
#TODO-aarch64
if
[
$ARCH
==
"aarch64"
]
;
then
ShieldedList+
=(
"faccessat"
"signal"
"unittest_hilog_vsnprint"
"yn"
)
fi
for
skiped
in
${
ShieldedList
[*]
}
;
do
echo
$skiped
>>
/data/tests/libc-test/SkipList.txt
done
...
...
@@ -62,4 +76,4 @@ do
./runtest
-w
''
-t
30
$file
>>
/data/tests/libc-test/REPORT
fi
fi
done
\ No newline at end of file
done
scripts/runtest_Windows.bat
浏览文件 @
b21cbbe5
...
...
@@ -14,6 +14,7 @@ set REMOTE=/data/tests/libc-test
set
REMOTESYSTEM
=
/system/lib
@REM runtest脚本所在目录
set
SHDIR
=
%LOCAL%
\third_party\musl\scripts
set
ARCH
=
arm
@REM 检查设备是否连接
echo
checking
HDC
device
...
...
@@ -33,6 +34,11 @@ if exist %TESTDIR% (
@REM 在单板创建目录, 需要预先创建好才能传输到相应位置。
:hdcStart
for
/F
"usebackq delims=="
%%r
in
(
`hdc shell param get const.product.cpu.abilist`
)
DO
(
echo
%%r
|
findstr
"arm64-v8a"
&&
set
ARCH
=
aarch64
)
echo
detect
arch
=
%ARCH%
echo
.
echo
now
mkdir
...
hdc
shell
rm
-rf /data/tests/libc-test
...
...
@@ -56,9 +62,9 @@ hdc shell chmod +x %REMOTE%/src/*
hdc
shell
mount
-o
rw
,
remount
/
hdc
shell
chmod
777
/etc
hdc
shell
cp
/etc/ld-musl-namespace-
arm
.ini
/etc/ld-musl-namespace-arm
.ini.bak
hdc
file
send
%LOCAL%
\third_party\musl\porting\linux\user\config\ld
-musl-namespace-
arm
-test
.ini
^
/etc/ld-musl-namespace-
arm
.ini
hdc
shell
cp
/etc/ld-musl-namespace
-
%ARCH%
.ini
/etc/ld-musl-namespace
-
%ARCH%
.ini.bak
hdc
file
send
%LOCAL%
\third_party\musl\porting\linux\user\config\ld
-musl-namespace
-
%ARCH%
-test
.ini
^
/etc/ld-musl-namespace
-
%ARCH%
.ini
hdc
shell
mkdir
%REMOTE%
/src/A
hdc
shell
mkdir
%REMOTE%
/src/B
hdc
shell
mkdir
%REMOTE%
/src/C
...
...
@@ -97,7 +103,7 @@ if exist Summary.txt (
hdc
file
recv
%REMOTE%
/FileList
.txt
%~dp0
FileList
.txt
hdc
file
recv
%REMOTE%
/SkipList
.txt
%~dp0
SkipList
.txt
for
/f
"delims=:"
%%a
in
(
'dir /b "
%TESTDIR%
"
^|
findstr /n .*'
)
do
set
all
=
%%a
for
/f
"delims=:"
%%a
in
(
'dir /b
/a:-d
"
%TESTDIR%
"
^|
findstr /n .*'
)
do
set
all
=
%%a
for
/f
%%b
in
(
' find /c /v ""
^<
"FileList.txt" '
)
do
set
/a
run
=
%%b
for
/f
%%c
in
(
' find /c "FAIL"
^<
"REPORT" '
)
do
set
fail
=
%%c
...
...
@@ -106,13 +112,13 @@ echo ===================================
set
/a
pass
=
%run%
-
%fail%
set
/a
skip
=
%all%
-
%run%
echo
SUMMARY
echo
SUMMARY
-
%ARCH%
echo
All
:
%all%
^|
Run
:
%run%
^|
Skip
:
%skip%
echo
Pass
:
[
%pass%
/
%run%
]
echo
Fail
:
[
%fail%
/
%run%
]
(
echo
SUMMARY
echo
SUMMARY
-
%ARCH%
echo
All
:
%all%
^|
Run
:
%run%
^|
Skip
:
%skip%
echo
Pass
:
[
%pass%
/
%run%
]
echo
Fail
:
[
%fail%
/
%run%
]
...
...
@@ -140,4 +146,4 @@ echo Device not found, please check your device.
:end
echo
.
pause
exit
\ No newline at end of file
exit
src/network/lookup.h
浏览文件 @
b21cbbe5
...
...
@@ -113,6 +113,10 @@ typedef int32_t (*GetCache)(uint16_t netId, struct param_wrapper param,
typedef
int32_t
(
*
SetCache
)(
uint16_t
netId
,
struct
param_wrapper
param
,
struct
addrinfo
*
res
);
/* If the memory holder points to stores NULL value, try to load symbol from the
* dns lib into holder; otherwise, it does nothing. */
hidden
void
resolve_dns_sym
(
void
**
holder
,
const
char
*
symbol
);
void
dns_set_addr_info_to_netsys_cache
(
const
char
*
__restrict
host
,
const
char
*
__restrict
serv
,
const
struct
addrinfo
*
__restrict
...
...
src/network/res_cache.c
浏览文件 @
b21cbbe5
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022
-2023
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -23,25 +23,33 @@
#if OHOS_DNS_PROXY_BY_NETSYS
#include "atomic.h"
static
GetCache
load_cache_getter
(
void
)
{
static
GetCache
cache_getter
=
NULL
;
resolve_dns_sym
((
void
**
)
&
cache_getter
,
OHOS_GET_CACHE_FUNC_NAME
);
return
cache_getter
;
}
static
SetCache
load_cache_setter
(
void
)
{
static
SetCache
cache_setter
=
NULL
;
resolve_dns_sym
((
void
**
)
&
cache_setter
,
OHOS_SET_CACHE_FUNC_NAME
);
return
cache_setter
;
}
void
dns_set_addr_info_to_netsys_cache
(
const
char
*
restrict
host
,
const
char
*
restrict
serv
,
const
struct
addrinfo
*
restrict
hint
,
struct
addrinfo
*
res
)
{
void
*
handle
=
dlopen
(
DNS_SO_PATH
,
RTLD_LAZY
);
if
(
handle
==
NULL
)
{
DNS_CONFIG_PRINT
(
"dns_set_addr_info_to_netsys_cache dlopen err %s
\n
"
,
dlerror
());
return
;
}
SetCache
func
=
dlsym
(
handle
,
OHOS_SET_CACHE_FUNC_NAME
);
if
(
func
==
NULL
)
{
DNS_CONFIG_PRINT
(
"dns_set_addr_info_to_netsys_cache dlsym err %s
\n
"
,
dlerror
());
dlclose
(
handle
);
SetCache
func
=
load_cache_setter
();
if
(
!
func
)
{
DNS_CONFIG_PRINT
(
"%s: loading %s failed"
,
__func__
,
OHOS_SET_CACHE_FUNC_NAME
);
return
;
}
struct
param_wrapper
param
=
{(
char
*
)
host
,
(
char
*
)
serv
,
(
struct
addrinfo
*
)
hint
};
int
ret
=
func
(
0
,
param
,
res
);
dlclose
(
handle
);
if
(
ret
<
0
)
{
DNS_CONFIG_PRINT
(
"dns_set_addr_info_to_netsys_cache OHOS_SET_CACHE_FUNC_NAME err %d
\n
"
,
ret
);
return
;
...
...
@@ -52,16 +60,9 @@ hint, struct addrinfo *res) {
int
dns_get_addr_info_from_netsys_cache
(
const
char
*
restrict
host
,
const
char
*
restrict
serv
,
const
struct
addrinfo
*
restrict
hint
,
struct
addrinfo
**
restrict
res
)
{
void
*
handle
=
dlopen
(
DNS_SO_PATH
,
RTLD_LAZY
);
if
(
handle
==
NULL
)
{
DNS_CONFIG_PRINT
(
"dns_get_addr_info_from_netsys_cache dlopen err %s
\n
"
,
dlerror
());
return
-
1
;
}
GetCache
func
=
dlsym
(
handle
,
OHOS_GET_CACHE_FUNC_NAME
);
if
(
func
==
NULL
)
{
DNS_CONFIG_PRINT
(
"dns_get_addr_info_from_netsys_cache dlsym err %s
\n
"
,
dlerror
());
dlclose
(
handle
);
GetCache
func
=
load_cache_getter
();
if
(
!
func
)
{
DNS_CONFIG_PRINT
(
"%s: loading %s failed"
,
__func__
,
OHOS_GET_CACHE_FUNC_NAME
);
return
-
1
;
}
...
...
@@ -69,7 +70,6 @@ int dns_get_addr_info_from_netsys_cache(const char *restrict host, const char *r
uint32_t
num
=
0
;
struct
param_wrapper
param
=
{(
char
*
)
host
,
(
char
*
)
serv
,
(
struct
addrinfo
*
)
hint
};
int
ret
=
func
(
0
,
param
,
addr_info
,
&
num
);
dlclose
(
handle
);
if
(
ret
<
0
)
{
DNS_CONFIG_PRINT
(
"dns_get_addr_info_from_netsys_cache OHOS_GET_CACHE_FUNC_NAME err %d
\n
"
,
ret
);
return
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录