Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
7de7996c
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看板
未验证
提交
7de7996c
编写于
2月 10, 2023
作者:
O
openharmony_ci
提交者:
Gitee
2月 10, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
回退 'Pull Request !720 : 修复get_nprocs_conf获取cpu数量不正确问题'
上级
6d8d4fd7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
0 addition
and
285 deletion
+0
-285
musl_src.gni
musl_src.gni
+0
-2
porting/linux/user/src/conf/legacy.c
porting/linux/user/src/conf/legacy.c
+0
-68
porting/linux/user/src/conf/sysconf.c
porting/linux/user/src/conf/sysconf.c
+0
-215
未找到文件。
musl_src.gni
浏览文件 @
7de7996c
...
...
@@ -2143,8 +2143,6 @@ musl_src_porting_file = [
"src/process/x86_64/__vfork.s",
"src/linux/cache.c",
"src/sched/sched_getcpu.c",
"src/conf/legacy.c",
"src/conf/sysconf.c",
]
musl_inc_hook_files = [
...
...
porting/linux/user/src/conf/legacy.c
已删除
100644 → 0
浏览文件 @
6d8d4fd7
#include <sys/sysinfo.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define _GNU_SOURCE
#include <dirent.h>
int
get_nprocs_conf
()
{
DIR
*
d
=
opendir
(
"/sys/devices/system/cpu"
);
struct
dirent
*
de
;
unsigned
int
cnt
=
0
;
if
(
!
d
)
return
1
;
while
((
de
=
readdir
(
d
)))
{
if
((
de
->
d_type
==
DT_DIR
)
&&
(
strlen
(
de
->
d_name
)
>
3
)
&&
(
de
->
d_name
[
0
]
==
'c'
)
&&
(
de
->
d_name
[
1
]
==
'p'
)
&&
(
de
->
d_name
[
2
]
==
'u'
)
&&
(
isdigit
(
de
->
d_name
[
3
])))
cnt
++
;
}
closedir
(
d
);
return
cnt
;
}
int
get_nprocs
()
{
int
cnt
=
1
;
FILE
*
fp
=
fopen
(
"/sys/devices/system/cpu/online"
,
"re"
);
if
(
fp
!=
NULL
)
{
char
buf
[
128
];
memset
(
buf
,
0
,
sizeof
(
buf
));
if
(
!
fgets
(
buf
,
sizeof
(
buf
),
fp
))
{
return
1
;
}
cnt
=
0
;
char
*
tmp
,
*
p
;
tmp
=
strtok_r
(
buf
,
","
,
&
p
);
while
(
tmp
!=
NULL
)
{
char
*
tok
=
strstr
(
tmp
,
"-"
);
if
(
tok
)
{
tok
++
;
cnt
+=
atoi
(
tok
)
-
atoi
(
tmp
)
+
1
;
}
else
{
cnt
+=
1
;
}
tmp
=
strtok_r
(
NULL
,
","
,
&
p
);
}
fclose
(
fp
);
}
return
cnt
;
}
long
get_phys_pages
()
{
return
sysconf
(
_SC_PHYS_PAGES
);
}
long
get_avphys_pages
()
{
return
sysconf
(
_SC_AVPHYS_PAGES
);
}
porting/linux/user/src/conf/sysconf.c
已删除
100644 → 0
浏览文件 @
6d8d4fd7
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include <sys/resource.h>
#include <signal.h>
#include <sys/sysinfo.h>
#include "syscall.h"
#include "libc.h"
#define JT(x) (-256|(x))
#define VER JT(1)
#define JT_ARG_MAX JT(2)
#define JT_MQ_PRIO_MAX JT(3)
#define JT_PAGE_SIZE JT(4)
#define JT_SEM_VALUE_MAX JT(5)
#define JT_NPROCESSORS_CONF JT(6)
#define JT_NPROCESSORS_ONLN JT(7)
#define JT_PHYS_PAGES JT(8)
#define JT_AVPHYS_PAGES JT(9)
#define JT_ZERO JT(10)
#define JT_DELAYTIMER_MAX JT(11)
#define RLIM(x) (-32768|(RLIMIT_ ## x))
long
sysconf
(
int
name
)
{
static
const
short
values
[]
=
{
[
_SC_ARG_MAX
]
=
JT_ARG_MAX
,
[
_SC_CHILD_MAX
]
=
RLIM
(
NPROC
),
[
_SC_CLK_TCK
]
=
100
,
[
_SC_NGROUPS_MAX
]
=
32
,
[
_SC_OPEN_MAX
]
=
RLIM
(
NOFILE
),
[
_SC_STREAM_MAX
]
=
-
1
,
[
_SC_TZNAME_MAX
]
=
TZNAME_MAX
,
[
_SC_JOB_CONTROL
]
=
1
,
[
_SC_SAVED_IDS
]
=
1
,
[
_SC_REALTIME_SIGNALS
]
=
VER
,
[
_SC_PRIORITY_SCHEDULING
]
=
-
1
,
[
_SC_TIMERS
]
=
VER
,
[
_SC_ASYNCHRONOUS_IO
]
=
VER
,
[
_SC_PRIORITIZED_IO
]
=
-
1
,
[
_SC_SYNCHRONIZED_IO
]
=
-
1
,
[
_SC_FSYNC
]
=
VER
,
[
_SC_MAPPED_FILES
]
=
VER
,
[
_SC_MEMLOCK
]
=
VER
,
[
_SC_MEMLOCK_RANGE
]
=
VER
,
[
_SC_MEMORY_PROTECTION
]
=
VER
,
[
_SC_MESSAGE_PASSING
]
=
VER
,
[
_SC_SEMAPHORES
]
=
VER
,
[
_SC_SHARED_MEMORY_OBJECTS
]
=
VER
,
[
_SC_AIO_LISTIO_MAX
]
=
-
1
,
[
_SC_AIO_MAX
]
=
-
1
,
[
_SC_AIO_PRIO_DELTA_MAX
]
=
JT_ZERO
,
/* ?? */
[
_SC_DELAYTIMER_MAX
]
=
JT_DELAYTIMER_MAX
,
[
_SC_MQ_OPEN_MAX
]
=
-
1
,
[
_SC_MQ_PRIO_MAX
]
=
JT_MQ_PRIO_MAX
,
[
_SC_VERSION
]
=
VER
,
[
_SC_PAGE_SIZE
]
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?
1
:
-
1
,
[
_SC_V7_LP64_OFF64
]
=
sizeof
(
long
)
==
8
?
1
:
-
1
,
[
_SC_V7_LPBIG_OFFBIG
]
=
-
1
,
[
_SC_SS_REPL_MAX
]
=
-
1
,
[
_SC_TRACE_EVENT_NAME_MAX
]
=
-
1
,
[
_SC_TRACE_NAME_MAX
]
=
-
1
,
[
_SC_TRACE_SYS_MAX
]
=
-
1
,
[
_SC_TRACE_USER_EVENT_MAX
]
=
-
1
,
[
_SC_XOPEN_STREAMS
]
=
JT_ZERO
,
[
_SC_THREAD_ROBUST_PRIO_INHERIT
]
=
-
1
,
[
_SC_THREAD_ROBUST_PRIO_PROTECT
]
=
-
1
,
};
if
(
name
>=
sizeof
(
values
)
/
sizeof
(
values
[
0
])
||
!
values
[
name
])
{
errno
=
EINVAL
;
return
-
1
;
}
else
if
(
values
[
name
]
>=
-
1
)
{
return
values
[
name
];
}
else
if
(
values
[
name
]
<
-
256
)
{
struct
rlimit
lim
;
getrlimit
(
values
[
name
]
&
16383
,
&
lim
);
if
(
lim
.
rlim_cur
==
RLIM_INFINITY
)
return
-
1
;
return
lim
.
rlim_cur
>
LONG_MAX
?
LONG_MAX
:
lim
.
rlim_cur
;
}
switch
((
unsigned
char
)
values
[
name
])
{
case
VER
&
255
:
return
_POSIX_VERSION
;
case
JT_ARG_MAX
&
255
:
return
ARG_MAX
;
case
JT_MQ_PRIO_MAX
&
255
:
return
MQ_PRIO_MAX
;
case
JT_PAGE_SIZE
&
255
:
return
PAGE_SIZE
;
case
JT_SEM_VALUE_MAX
&
255
:
return
SEM_VALUE_MAX
;
case
JT_DELAYTIMER_MAX
&
255
:
return
DELAYTIMER_MAX
;
case
JT_NPROCESSORS_CONF
&
255
:
return
get_nprocs_conf
();
case
JT_NPROCESSORS_ONLN
&
255
:
return
get_nprocs
();
case
JT_PHYS_PAGES
&
255
:
case
JT_AVPHYS_PAGES
&
255
:
;
unsigned
long
long
mem
;
struct
sysinfo
si
;
__lsysinfo
(
&
si
);
if
(
!
si
.
mem_unit
)
si
.
mem_unit
=
1
;
if
(
name
==
_SC_PHYS_PAGES
)
mem
=
si
.
totalram
;
else
mem
=
si
.
freeram
+
si
.
bufferram
;
mem
*=
si
.
mem_unit
;
mem
/=
PAGE_SIZE
;
return
(
mem
>
LONG_MAX
)
?
LONG_MAX
:
mem
;
case
JT_ZERO
&
255
:
return
0
;
}
return
values
[
name
];
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录