Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
fc2b8ddd
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看板
提交
fc2b8ddd
编写于
10月 04, 2022
作者:
M
Maxim Polyakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed a various warnings
Signed-off-by:
N
Maxim Polyakov
<
polyakov.maksim@huawei.com
>
上级
07820e42
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
216 addition
and
57 deletion
+216
-57
libc-test/src/functional/test-iterate.c
libc-test/src/functional/test-iterate.c
+17
-1
libc-test/src/functional/test-mallinfo.c
libc-test/src/functional/test-mallinfo.c
+15
-0
libc-test/src/functional/test-malloc-api-common.h
libc-test/src/functional/test-malloc-api-common.h
+21
-3
libc-test/src/functional/test-malloc-backtrace.c
libc-test/src/functional/test-malloc-backtrace.c
+15
-0
libc-test/src/functional/test-malloc-disable.c
libc-test/src/functional/test-malloc-disable.c
+15
-0
libc-test/src/functional/test-malloc-info-stats-print.h
libc-test/src/functional/test-malloc-info-stats-print.h
+15
-0
libc-test/src/functional/test-malloc-info.c
libc-test/src/functional/test-malloc-info.c
+16
-2
libc-test/src/functional/test-malloc-stats-common.h
libc-test/src/functional/test-malloc-stats-common.h
+46
-23
libc-test/src/functional/test-malloc-stats-print.c
libc-test/src/functional/test-malloc-stats-print.c
+15
-0
libc-test/src/functional/test-mallopt.c
libc-test/src/functional/test-mallopt.c
+15
-0
porting/linux/user/include/malloc.h
porting/linux/user/include/malloc.h
+2
-1
porting/linux/user/src/env/__libc_start_main.c
porting/linux/user/src/env/__libc_start_main.c
+0
-1
porting/linux/user/src/malloc/stats.c
porting/linux/user/src/malloc/stats.c
+24
-3
porting/linux/user/src/thread/pthread_getspecific.c
porting/linux/user/src/thread/pthread_getspecific.c
+0
-11
porting/linux/user/src/thread/pthread_setspecific.c
porting/linux/user/src/thread/pthread_setspecific.c
+0
-12
未找到文件。
libc-test/src/functional/test-iterate.c
浏览文件 @
fc2b8ddd
/*
* Copyright (C) 2022 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 <stdio.h>
#include <malloc.h>
#include <stdlib.h>
...
...
@@ -33,7 +48,8 @@ static const size_t allocs_sizes[ALLOCATIONS_NUMBER] = {
2
*
1024
*
1024
,
8
*
1024
*
1024
,
16
*
1024
*
1024
,
32
*
1024
*
1024
};
32
*
1024
*
1024
};
void
iterate_callback
(
void
*
base
,
size_t
size
,
void
*
data
)
{
...
...
libc-test/src/functional/test-mallinfo.c
浏览文件 @
fc2b8ddd
/*
* Copyright (C) 2022 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 "test-malloc-stats-common.h"
static
int
stats_from_mallinfo
(
malloc_thread_stats_t
*
stats
,
long
long
*
total_free_heap_space
,
int
use_mallinfo2
)
...
...
libc-test/src/functional/test-malloc-api-common.h
浏览文件 @
fc2b8ddd
/*
* Copyright (C) 2022 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.
*/
#ifndef TEST_ITERATE_DISABLE_COMMON_H
#define TEST_ITERATE_DISABLE_COMMON_H
...
...
@@ -7,12 +22,15 @@ int check_and_report(const char *message, int (*check_func)(void))
{
t_printf
(
"%s..."
,
message
);
int
ret
=
check_func
();
if
(
ret
==
0
)
{
if
(
ret
==
0
)
{
t_printf
(
"Success
\n
"
);
}
else
{
}
else
{
t_error
(
"Failed
\n
"
);
}
return
ret
;
}
#endif //TEST_ITERATE_DISABLE_COMMON_H
\ No newline at end of file
#endif // TEST_ITERATE_DISABLE_COMMON_H
\ No newline at end of file
libc-test/src/functional/test-malloc-backtrace.c
浏览文件 @
fc2b8ddd
/*
* Copyright (C) 2022 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 <malloc.h>
#include "test-malloc-api-common.h"
...
...
libc-test/src/functional/test-malloc-disable.c
浏览文件 @
fc2b8ddd
/*
* Copyright (C) 2022 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 <stdio.h>
#include <malloc.h>
#include <stdlib.h>
...
...
libc-test/src/functional/test-malloc-info-stats-print.h
浏览文件 @
fc2b8ddd
/*
* Copyright (C) 2022 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.
*/
#ifndef TEST_MALLOC_STATS_H
#define TEST_MALLOC_STATS_H
...
...
libc-test/src/functional/test-malloc-info.c
浏览文件 @
fc2b8ddd
/*
* Copyright (C) 2022 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 <stdlib.h>
#include "test-malloc-info-stats-print.h"
...
...
@@ -27,8 +42,7 @@ static const xmlChar *get_attribute(const char *attr_name, xmlNodePtr node)
return
NULL
;
}
static
xmlNodePtr
find_child_node_with_attr
(
const
char
*
name
,
const
char
*
attr_name
,
const
char
*
attr_value
,
xmlNodePtr
parent
)
static
xmlNodePtr
find_child_node_with_attr
(
const
char
*
name
,
const
char
*
attr_name
,
const
char
*
attr_value
,
xmlNodePtr
parent
)
{
if
(
parent
==
NULL
)
{
...
...
libc-test/src/functional/test-malloc-stats-common.h
浏览文件 @
fc2b8ddd
/*
* Copyright (C) 2022 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.
*/
#ifndef TEST_MALLOC_STATS_COMMON_H
#define TEST_MALLOC_STATS_COMMON_H
...
...
@@ -11,27 +26,34 @@
#include "test.h"
#define SIZES_COUNT 11
#define SIZE_ALIGN (8
*
sizeof(size_t))
#define MMAP_THRESHOLD ((0x1c00
*
SIZE_ALIGN) - OVERHEAD)
#define LIST_OVERHEAD (2
*sizeof(void
*))
#define OVERHEAD (2
*sizeof(size_t) + sizeof(void
*) + LIST_OVERHEAD)
#define SIZE_ALIGN (8
*
sizeof(size_t))
#define MMAP_THRESHOLD ((0x1c00
*
SIZE_ALIGN) - OVERHEAD)
#define LIST_OVERHEAD (2
* sizeof(void
*))
#define OVERHEAD (2
* sizeof(size_t) + sizeof(void
*) + LIST_OVERHEAD)
static
size_t
sizes
[
SIZES_COUNT
]
=
{
23
,
32
,
256
,
3072
,
3584
,
229376
,
262144
,
327680
,
8
*
1024
*
1024
,
16
*
1024
*
1024
,
23
,
32
,
256
,
3072
,
3584
,
229376
,
262144
,
327680
,
8
*
1024
*
1024
,
16
*
1024
*
1024
,
32
*
1024
*
1024
};
typedef
struct
{
typedef
struct
{
long
long
mmapped_regions
;
long
long
total_mmapped_memory
;
long
long
total_allocated_memory
;
}
malloc_thread_stats_t
;
typedef
struct
{
typedef
struct
{
size_t
alloc_size
;
pthread_barrier_t
*
alloc_barrier
;
pthread_barrier_t
*
free_barrier
;
...
...
@@ -41,8 +63,10 @@ typedef struct {
static
malloc_thread_stats_t
get_total_from_test_sizes
()
{
malloc_thread_stats_t
total_stats
=
{
0
};
for
(
size_t
i
=
0
;
i
<
SIZES_COUNT
;
i
++
)
{
if
(
sizes
[
i
]
>
MMAP_THRESHOLD
)
{
for
(
size_t
i
=
0
;
i
<
SIZES_COUNT
;
i
++
)
{
if
(
sizes
[
i
]
>
MMAP_THRESHOLD
)
{
total_stats
.
total_mmapped_memory
+=
sizes
[
i
];
total_stats
.
mmapped_regions
++
;
}
...
...
@@ -53,7 +77,8 @@ static malloc_thread_stats_t get_total_from_test_sizes()
static
int
expect_greater_equal
(
long
long
amt1
,
long
long
amt2
,
const
char
*
amt1_name
,
const
char
*
amt2_name
)
{
if
(
amt1
>=
amt2
)
{
if
(
amt1
>=
amt2
)
{
return
1
;
}
t_error
(
"Expected %s(value: %lld) to be >= %s(value: %lld)
\n
"
,
amt1_name
,
amt1
,
amt2_name
,
amt2
);
...
...
@@ -62,7 +87,8 @@ static int expect_greater_equal(long long amt1, long long amt2, const char *amt1
static
int
expect_equal
(
long
long
amt
,
long
long
value
,
const
char
*
amt_name
)
{
if
(
amt
==
value
)
{
if
(
amt
==
value
)
{
return
1
;
}
t_error
(
"Expected %s(value: %lld) to be %lld
\n
"
,
amt_name
,
amt
,
value
);
...
...
@@ -77,23 +103,20 @@ static int validate_total_allocated(malloc_thread_stats_t *total_stats)
total_stats
->
total_allocated_memory
,
total_from_test_sizes
.
total_allocated_memory
,
"allocated memory"
,
"total memory from test sizes"
);
"total memory from test sizes"
);
result
&=
expect_greater_equal
(
total_stats
->
total_mmapped_memory
,
total_from_test_sizes
.
total_mmapped_memory
,
"mmapped memory"
,
"total large memory from test sizes"
);
"total large memory from test sizes"
);
result
&=
expect_equal
(
total_stats
->
mmapped_regions
,
total_from_test_sizes
.
mmapped_regions
,
"mmapped regions"
);
"mmapped regions"
);
return
result
;
}
static
int
validate_all_freed
(
malloc_thread_stats_t
*
total_stats
)
static
int
validate_all_freed
(
malloc_thread_stats_t
*
total_stats
)
{
int
result
=
expect_equal
(
total_stats
->
total_allocated_memory
,
0
,
"allocated memory"
);
result
&=
expect_equal
(
total_stats
->
total_mmapped_memory
,
0
,
"mmapped memory"
);
...
...
@@ -112,4 +135,4 @@ static void *allocate_wait_free(void *arg)
return
NULL
;
}
#endif //TEST_MALLOC_STATS_COMMON_H
#endif //
TEST_MALLOC_STATS_COMMON_H
libc-test/src/functional/test-malloc-stats-print.c
浏览文件 @
fc2b8ddd
/*
* Copyright (C) 2022 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 "test-malloc-info-stats-print.h"
static
void
stderr_stats_cb
(
void
)
...
...
libc-test/src/functional/test-mallopt.c
浏览文件 @
fc2b8ddd
/*
* Copyright (C) 2022 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 <malloc.h>
#include "test-malloc-api-common.h"
...
...
porting/linux/user/include/malloc.h
浏览文件 @
fc2b8ddd
#ifndef _MALLOC_H
#define _MALLOC_H
#include <stdio.h>
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
@@ -10,7 +12,6 @@ extern "C" {
#define __NEED_uintptr_t
#include <bits/alltypes.h>
#include <stdio.h>
void
*
malloc
(
size_t
);
void
*
calloc
(
size_t
,
size_t
);
...
...
porting/linux/user/src/env/__libc_start_main.c
浏览文件 @
fc2b8ddd
...
...
@@ -107,7 +107,6 @@ static int libc_start_main_stage2(int (*main)(int,char **,char **), int argc, ch
#endif
libc
.
initialized
=
1
;
/* Pass control to the application */
exit
(
main
(
argc
,
argv
,
envp
));
return
0
;
...
...
porting/linux/user/src/malloc/stats.c
浏览文件 @
fc2b8ddd
/*
* Copyright (C) 2022 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 <stdarg.h>
#include <malloc.h>
#include <errno.h>
#include <string.h>
#include "pthread_impl.h"
#include "malloc_impl.h"
...
...
@@ -27,8 +43,11 @@ static void stat_printf(write_cb_fun *write_cb, void *write_cb_arg, const char *
va_list
args
;
va_start
(
args
,
fmt
);
char
buf
[
STAT_PRINTF_MAX_LEN
+
1
];
vsnprintf
(
buf
,
STAT_PRINTF_MAX_LEN
,
fmt
,
args
);
write_cb
(
write_cb_arg
,
buf
);
if
(
vsnprintf
(
buf
,
STAT_PRINTF_MAX_LEN
,
fmt
,
args
))
{
write_cb
(
write_cb_arg
,
buf
);
}
else
{
fprintf
(
stderr
,
"Error writing to buffer"
);
}
va_end
(
args
);
}
...
...
@@ -175,7 +194,9 @@ static void print_total_free_heap_space(
static
void
print_to_file
(
void
*
fp
,
const
char
*
s
)
{
fputs
(
s
,
fp
);
if
(
fputs
(
s
,
fp
)
==
EOF
)
{
fprintf
(
stderr
,
"Error writing to file stream: %s"
,
strerror
(
errno
));
}
}
static
void
add_stats
(
malloc_stats_t
*
destination
,
const
malloc_stats_t
*
source
)
...
...
porting/linux/user/src/thread/pthread_getspecific.c
已删除
100644 → 0
浏览文件 @
07820e42
#include "pthread_impl.h"
#include <threads.h>
static
void
*
__pthread_getspecific
(
pthread_key_t
k
)
{
struct
pthread
*
self
=
__pthread_self
();
return
self
->
tsd
[
k
];
}
weak_alias
(
__pthread_getspecific
,
pthread_getspecific
);
weak_alias
(
__pthread_getspecific
,
tss_get
);
porting/linux/user/src/thread/pthread_setspecific.c
已删除
100644 → 0
浏览文件 @
07820e42
#include "pthread_impl.h"
int
pthread_setspecific
(
pthread_key_t
k
,
const
void
*
x
)
{
struct
pthread
*
self
=
__pthread_self
();
/* Avoid unnecessary COW */
if
(
self
->
tsd
[
k
]
!=
x
)
{
self
->
tsd
[
k
]
=
(
void
*
)
x
;
self
->
tsd_used
=
1
;
}
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录