Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
6988f27f
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看板
未验证
提交
6988f27f
编写于
6月 08, 2022
作者:
O
openharmony_ci
提交者:
Gitee
6月 08, 2022
浏览文件
操作
浏览文件
下载
差异文件
!315 增加tgkill和sched_cpualloc.c接口和libctest相关测试用例
Merge pull request !315 from fangting10/master
上级
af0d3bda
d5725d87
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
227 addition
and
1 deletion
+227
-1
libc-test/src/functional/sched_cpualloc.c
libc-test/src/functional/sched_cpualloc.c
+20
-0
libc-test/src/functional/test_src_functional.gni
libc-test/src/functional/test_src_functional.gni
+2
-0
libc-test/src/functional/tgkill.c
libc-test/src/functional/tgkill.c
+18
-0
musl_src.gni
musl_src.gni
+5
-0
porting/linux/user/include/sched.h
porting/linux/user/include/sched.h
+152
-0
porting/linux/user/include/signal.h
porting/linux/user/include/signal.h
+1
-1
porting/linux/user/src/sched/sched_cpualloc.c
porting/linux/user/src/sched/sched_cpualloc.c
+11
-0
porting/linux/user/src/signal/signal.c
porting/linux/user/src/signal/signal.c
+18
-0
未找到文件。
libc-test/src/functional/sched_cpualloc.c
0 → 100644
浏览文件 @
6988f27f
// sched_cpualloc(0) should return unique pointers
// (often expected and gnulib replaces sched_cpualloc if sched_cpualloc(0) returns 0)
#include <stdlib.h>
#include <sched.h>
#include "test.h"
int
main
(
void
)
{
cpu_set_t
*
p
=
__sched_cpualloc
(
0
);
cpu_set_t
*
q
=
__sched_cpualloc
(
0
);
cpu_set_t
*
r
=
__sched_cpualloc
(
0
);
if
(
!
p
||
!
q
||
!
r
)
t_error
(
"sched_cpualloc(0) returned NULL
\n
"
);
if
(
p
==
q
||
p
==
r
||
q
==
r
)
t_error
(
"sched_cpualloc(0) returned non-unique pointers: %p, %p, %p
\n
"
,
p
,
q
,
r
);
free
(
q
);
free
(
p
);
free
(
r
);
return
t_status
;
}
libc-test/src/functional/test_src_functional.gni
浏览文件 @
6988f27f
...
...
@@ -61,6 +61,8 @@ functional_list = [
"strtold",
"swprintf",
"sched_setscheduler",
"sched_cpualloc",
"tgkill",
"tgmath",
"time",
"tls_align",
...
...
libc-test/src/functional/tgkill.c
0 → 100644
浏览文件 @
6988f27f
#include <stdio.h>
#include <errno.h>
#include "test.h"
#include <stdlib.h>
#include <signal.h>
int
main
(
int
argc
,
char
*
argv
[]){
int
tgid
,
tid
;
tgid
=
atoi
(
argv
[
1
]);
tid
=
atoi
(
argv
[
2
]);
if
(
tgkill
(
tgid
,
tid
,
SIGPROF
)
==
-
1
&&
errno
!=
ESRCH
)
{
perror
(
"tgkill failed"
);
}
return
0
;
}
\ No newline at end of file
musl_src.gni
浏览文件 @
6988f27f
...
...
@@ -911,6 +911,7 @@ musl_src_file = [
"src/regex/regerror.c",
"src/regex/regexec.c",
"src/regex/tre-mem.c",
"src/sched/sched_cpualloc.c",
"src/sched/affinity.c",
"src/sched/sched_cpucount.c",
"src/sched/sched_get_priority_max.c",
...
...
@@ -1834,6 +1835,8 @@ musl_src_porting_file = [
"include/sys/capability.h",
"include/sys/socket.h",
"include/sys/sysinfo.h",
"include/signal.h",
"include/sched.h",
"src/internal/dynlink.h",
"include/unistd.h",
"include/dlfcn.h",
...
...
@@ -1864,6 +1867,8 @@ musl_src_porting_file = [
"ldso/ns_config.c",
"ldso/strops.c",
"src/thread/pthread_create.c",
"src/sched/sched_cpualloc.c",
"src/signal/signal.c",
]
musl_inc_hook_files = [
...
...
porting/linux/user/include/sched.h
0 → 100644
浏览文件 @
6988f27f
#ifndef _SCHED_H
#define _SCHED_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <features.h>
#define __NEED_struct_timespec
#define __NEED_pid_t
#define __NEED_time_t
#ifdef _GNU_SOURCE
#define __NEED_size_t
#endif
#include <bits/alltypes.h>
#include <stddef.h>
struct
sched_param
{
int
sched_priority
;
int
__reserved1
;
#if _REDIR_TIME64
long
__reserved2
[
4
];
#else
struct
{
time_t
__reserved1
;
long
__reserved2
;
}
__reserved2
[
2
];
#endif
int
__reserved3
;
};
int
sched_get_priority_max
(
int
);
int
sched_get_priority_min
(
int
);
int
sched_getparam
(
pid_t
,
struct
sched_param
*
);
int
sched_getscheduler
(
pid_t
);
int
sched_rr_get_interval
(
pid_t
,
struct
timespec
*
);
int
sched_setparam
(
pid_t
,
const
struct
sched_param
*
);
int
sched_setscheduler
(
pid_t
,
int
,
const
struct
sched_param
*
);
int
sched_yield
(
void
);
#define SCHED_OTHER 0
#define SCHED_FIFO 1
#define SCHED_RR 2
#define SCHED_BATCH 3
#define SCHED_IDLE 5
#define SCHED_DEADLINE 6
#define SCHED_RESET_ON_FORK 0x40000000
#ifdef _GNU_SOURCE
#define CSIGNAL 0x000000ff
#define CLONE_VM 0x00000100
#define CLONE_FS 0x00000200
#define CLONE_FILES 0x00000400
#define CLONE_SIGHAND 0x00000800
#define CLONE_PIDFD 0x00001000
#define CLONE_PTRACE 0x00002000
#define CLONE_VFORK 0x00004000
#define CLONE_PARENT 0x00008000
#define CLONE_THREAD 0x00010000
#define CLONE_NEWNS 0x00020000
#define CLONE_SYSVSEM 0x00040000
#define CLONE_SETTLS 0x00080000
#define CLONE_PARENT_SETTID 0x00100000
#define CLONE_CHILD_CLEARTID 0x00200000
#define CLONE_DETACHED 0x00400000
#define CLONE_UNTRACED 0x00800000
#define CLONE_CHILD_SETTID 0x01000000
#define CLONE_NEWCGROUP 0x02000000
#define CLONE_NEWUTS 0x04000000
#define CLONE_NEWIPC 0x08000000
#define CLONE_NEWUSER 0x10000000
#define CLONE_NEWPID 0x20000000
#define CLONE_NEWNET 0x40000000
#define CLONE_IO 0x80000000
int
clone
(
int
(
*
)(
void
*
),
void
*
,
int
,
void
*
,
...);
int
unshare
(
int
);
int
setns
(
int
,
int
);
void
*
memcpy
(
void
*
__restrict
,
const
void
*
__restrict
,
size_t
);
int
memcmp
(
const
void
*
,
const
void
*
,
size_t
);
void
*
memset
(
void
*
,
int
,
size_t
);
void
*
calloc
(
size_t
,
size_t
);
void
free
(
void
*
);
typedef
struct
cpu_set_t
{
unsigned
long
__bits
[
128
/
sizeof
(
long
)];
}
cpu_set_t
;
cpu_set_t
*
__sched_cpualloc
(
size_t
__count
);
int
__sched_cpucount
(
size_t
,
const
cpu_set_t
*
);
int
sched_getcpu
(
void
);
int
sched_getaffinity
(
pid_t
,
size_t
,
cpu_set_t
*
);
int
sched_setaffinity
(
pid_t
,
size_t
,
const
cpu_set_t
*
);
#define __CPU_op_S(i, size, set, op) ( (i)/8U >= (size) ? 0 : \
(((
unsigned
long
*
)(
set
))[(
i
)
/
8
/
sizeof
(
long
)]
op
(
1UL
<<
((
i
)
%
(
8
*
sizeof
(
long
)))))
)
#define CPU_SET_S(i, size, set) __CPU_op_S(i, size, set, |=)
#define CPU_CLR_S(i, size, set) __CPU_op_S(i, size, set, &=~)
#define CPU_ISSET_S(i, size, set) __CPU_op_S(i, size, set, &)
#define __CPU_op_func_S(func, op) \
static
__inline
void
__CPU_
##
func
##
_S
(
size_t
__size
,
cpu_set_t
*
__dest
,
\
const
cpu_set_t
*
__src1
,
const
cpu_set_t
*
__src2
)
\
{
\
size_t
__i
;
\
for
(
__i
=
0
;
__i
<
__size
/
sizeof
(
long
);
__i
++
)
\
((
unsigned
long
*
)
__dest
)[
__i
]
=
((
unsigned
long
*
)
__src1
)[
__i
]
\
op
((
unsigned
long
*
)
__src2
)[
__i
]
;
\
}
__CPU_op_func_S
(
AND
,
&
)
__CPU_op_func_S
(
OR
,
|
)
__CPU_op_func_S
(
XOR
,
^
)
#define CPU_AND_S(a,b,c,d) __CPU_AND_S(a,b,c,d)
#define CPU_OR_S(a,b,c,d) __CPU_OR_S(a,b,c,d)
#define CPU_XOR_S(a,b,c,d) __CPU_XOR_S(a,b,c,d)
#define CPU_COUNT_S(size,set) __sched_cpucount(size,set)
#define CPU_ZERO_S(size,set) memset(set,0,size)
#define CPU_EQUAL_S(size,set1,set2) (!memcmp(set1,set2,size))
#define CPU_ALLOC_SIZE(n) (sizeof(long) * ( (n)/(8*sizeof(long)) \
+
((
n
)
%
(
8
*
sizeof
(
long
))
+
8
*
sizeof
(
long
)
-
1
)
/
(
8
*
sizeof
(
long
))
)
)
#define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
#define CPU_FREE(set) free(set)
#define CPU_SETSIZE 128
#define CPU_SET(i, set) CPU_SET_S(i,sizeof(cpu_set_t),set)
#define CPU_CLR(i, set) CPU_CLR_S(i,sizeof(cpu_set_t),set)
#define CPU_ISSET(i, set) CPU_ISSET_S(i,sizeof(cpu_set_t),set)
#define CPU_AND(d,s1,s2) CPU_AND_S(sizeof(cpu_set_t),d,s1,s2)
#define CPU_OR(d,s1,s2) CPU_OR_S(sizeof(cpu_set_t),d,s1,s2)
#define CPU_XOR(d,s1,s2) CPU_XOR_S(sizeof(cpu_set_t),d,s1,s2)
#define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t),set)
#define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t),set)
#define CPU_EQUAL(s1,s2) CPU_EQUAL_S(sizeof(cpu_set_t),s1,s2)
#endif
#if _REDIR_TIME64
__REDIR
(
sched_rr_get_interval
,
__sched_rr_get_interval_time64
);
#endif
#ifdef __cplusplus
}
#endif
#endif
porting/linux/user/include/signal.h
浏览文件 @
6988f27f
...
...
@@ -201,7 +201,7 @@ int __libc_current_sigrtmax(void);
#define MUSL_SIGNAL_JSHEAP_PRIV (SIGRTMIN + 3)
int
kill
(
pid_t
,
int
);
int
tgkill
(
int
__tgid
,
int
__tid
,
int
__signal
);
int
sigemptyset
(
sigset_t
*
);
int
sigfillset
(
sigset_t
*
);
int
sigaddset
(
sigset_t
*
,
int
);
...
...
porting/linux/user/src/sched/sched_cpualloc.c
0 → 100644
浏览文件 @
6988f27f
#define _GNU_SOURCE 1
#include <sched.h>
#include <malloc.h>
cpu_set_t
*
__sched_cpualloc
(
size_t
count
)
{
// The static analyzer complains that CPU_ALLOC_SIZE eventually expands to
// N * sizeof(unsigned long), which is incompatible with cpu_set_t. This is
// on purpose.
return
(
cpu_set_t
*
)
malloc
(
CPU_ALLOC_SIZE
(
count
));
// NOLINT
}
porting/linux/user/src/signal/signal.c
0 → 100644
浏览文件 @
6988f27f
#include <signal.h>
#include "syscall.h"
void
(
*
signal
(
int
sig
,
void
(
*
func
)(
int
)))(
int
)
{
struct
sigaction
sa_old
,
sa
=
{
.
sa_handler
=
func
,
.
sa_flags
=
SA_RESTART
};
if
(
__sigaction
(
sig
,
&
sa
,
&
sa_old
)
<
0
)
return
SIG_ERR
;
return
sa_old
.
sa_handler
;
}
int
tgkill
(
int
__tgid
,
int
__tid
,
int
__signal
){
return
__syscall
(
SYS_tgkill
,
__tgid
,
__tid
,
__signal
);
}
weak_alias
(
signal
,
bsd_signal
);
weak_alias
(
signal
,
__sysv_signal
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录