Skip to content

Commit ed48398

Browse files
authored
[libc] Fill out generated malloc.h and related stdlib.h extensions (llvm#127293)
This updates the generated stdlib.h and malloc.h headers to include the subsets of extenion functions declared by glibc that are also supported by Scudo and that use only simple types. Scudo's extensions not declared by glibc are omitted. glibc's extensions not implemented by Scudo are omitted. The mallinfo and mallinfo2 functions are omitted (at least for now) since they need struct definitions for their return types.
1 parent 963ff1c commit ed48398

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

libc/include/malloc.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,23 @@ macros:
99
- macro_name: M_PURGE_ALL
1010
macro_header: malloc-macros.h
1111
functions:
12+
- name: malloc_usable_size
13+
standards:
14+
- gnu
15+
return_type: size_t
16+
arguments:
17+
- type: void *
1218
- name: mallopt
1319
standards:
1420
- gnu
1521
return_type: int
1622
arguments:
1723
- type: int
1824
- type: int
25+
- name: pvalloc
26+
standards:
27+
- bsd
28+
- gnu
29+
return_type: void *
30+
arguments:
31+
- type: size_t

libc/include/stdlib-malloc.yaml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# This file has declarations that appear both in <stdlib.h> and in <malloc.h>.
2+
# These include the subset of GNU extensions that Scudo supports.
3+
#
4+
# Note: glibc's <stdlib.h> and <malloc.h> both also have `reallocarray`,
5+
# which Scudo does not support and is omitted here. (Each of those glibc
6+
# headers also has related functions the other lacks, but those should be
7+
# covered separately in stdlib.yaml and malloc.yaml instead.)
28

39
functions:
410
- name: aligned_alloc
@@ -27,18 +33,24 @@ functions:
2733
return_type: void *
2834
arguments:
2935
- type: size_t
36+
- name: memalign
37+
standards:
38+
- gnu
39+
return_type: void *
40+
arguments:
41+
- type: size_t
42+
- type: size_t
3043
- name: realloc
3144
standards:
3245
- stdc
3346
return_type: void *
3447
arguments:
3548
- type: void *
3649
- type: size_t
37-
38-
# Note: glibc's <stdlib.h> and <malloc.h> both have these, which are
39-
# currently missing here:
40-
# - name: reallocarray
41-
# - name: memalign
42-
# - name: valloc
43-
# Each of those glibc headers also has related functions the other lacks.
44-
# Only the common subset is mentioned here for future consideration.
50+
- name: valloc
51+
standards:
52+
- bsd
53+
- gnu
54+
return_type: void *
55+
arguments:
56+
- type: size_t

libc/include/stdlib.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ functions:
127127
arguments:
128128
- type: long long
129129
- type: long long
130+
- name: posix_memalign
131+
standards:
132+
- posix
133+
return_type: int
134+
arguments:
135+
- type: void **
136+
- type: size_t
137+
- type: size_t
130138
- name: qsort
131139
standards:
132140
- stdc

0 commit comments

Comments
 (0)