Skip to content

[libc] Fill out generated malloc.h and related stdlib.h extensions #127293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions libc/include/malloc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,23 @@ macros:
- macro_name: M_PURGE_ALL
macro_header: malloc-macros.h
functions:
- name: malloc_usable_size
standards:
- gnu
return_type: size_t
arguments:
- type: void *
- name: mallopt
standards:
- gnu
return_type: int
arguments:
- type: int
- type: int
- name: pvalloc
standards:
- bsd
- gnu
return_type: void *
arguments:
- type: size_t
28 changes: 20 additions & 8 deletions libc/include/stdlib-malloc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# This file has declarations that appear both in <stdlib.h> and in <malloc.h>.
# These include the subset of GNU extensions that Scudo supports.
#
# Note: glibc's <stdlib.h> and <malloc.h> both also have `reallocarray`,
# which Scudo does not support and is omitted here. (Each of those glibc
# headers also has related functions the other lacks, but those should be
# covered separately in stdlib.yaml and malloc.yaml instead.)

functions:
- name: aligned_alloc
Expand Down Expand Up @@ -27,18 +33,24 @@ functions:
return_type: void *
arguments:
- type: size_t
- name: memalign
standards:
- gnu
return_type: void *
arguments:
- type: size_t
- type: size_t
- name: realloc
standards:
- stdc
return_type: void *
arguments:
- type: void *
- type: size_t

# Note: glibc's <stdlib.h> and <malloc.h> both have these, which are
# currently missing here:
# - name: reallocarray
# - name: memalign
# - name: valloc
# Each of those glibc headers also has related functions the other lacks.
# Only the common subset is mentioned here for future consideration.
- name: valloc
standards:
- bsd
- gnu
return_type: void *
arguments:
- type: size_t
8 changes: 8 additions & 0 deletions libc/include/stdlib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ functions:
arguments:
- type: long long
- type: long long
- name: posix_memalign
standards:
- posix
return_type: int
arguments:
- type: void **
- type: size_t
- type: size_t
- name: qsort
standards:
- stdc
Expand Down
Loading