Skip to content

[libc] Share hdrgen declarations between stdlib.h and malloc.h #127278

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 15, 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
17 changes: 0 additions & 17 deletions libc/include/malloc.h.def

This file was deleted.

16 changes: 10 additions & 6 deletions libc/include/malloc.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
header: malloc.h
header_template: malloc.h.def
macros: []
types: []
enums: []
objects: []
standards:
- gnu
merge_yaml_files:
- stdlib-malloc.yaml
macros:
- macro_name: M_PURGE
macro_header: malloc-macros.h
- macro_name: M_PURGE_ALL
macro_header: malloc-macros.h
functions:
- name: mallopt
standards:
- GNUExtensions
- gnu
return_type: int
arguments:
- type: int
Expand Down
44 changes: 44 additions & 0 deletions libc/include/stdlib-malloc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This file has declarations that appear both in <stdlib.h> and in <malloc.h>.

functions:
- name: aligned_alloc
standards:
- stdc
return_type: void *
arguments:
- type: size_t
- type: size_t
- name: calloc
standards:
- stdc
return_type: void *
arguments:
- type: size_t
- type: size_t
- name: free
standards:
- stdc
return_type: void
arguments:
- type: void *
- name: malloc
standards:
- stdc
return_type: void *
arguments:
- 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this comment!

35 changes: 2 additions & 33 deletions libc/include/stdlib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ header: stdlib.h
header_template: stdlib.h.def
standards:
- stdc
merge_yaml_files:
- stdlib-malloc.yaml
macros: []
types:
- type_name: __atexithandler_t
Expand Down Expand Up @@ -34,13 +36,6 @@ functions:
return_type: int
arguments:
- type: int
- name: aligned_alloc
standards:
- stdc
return_type: void *
arguments:
- type: size_t
- type: size_t
- name: at_quick_exit
standards:
- stdc
Expand Down Expand Up @@ -87,13 +82,6 @@ functions:
- type: size_t
- type: size_t
- type: __bsearchcompare_t
- name: calloc
standards:
- stdc
return_type: void *
arguments:
- type: size_t
- type: size_t
- name: div
standards:
- stdc
Expand All @@ -107,12 +95,6 @@ functions:
return_type: _Noreturn void
arguments:
- type: int
- name: free
standards:
- stdc
return_type: void
arguments:
- type: void *
- name: getenv
standards:
- stdc
Expand Down Expand Up @@ -145,12 +127,6 @@ functions:
arguments:
- type: long long
- type: long long
- name: malloc
standards:
- stdc
return_type: void *
arguments:
- type: size_t
- name: qsort
standards:
- stdc
Expand Down Expand Up @@ -182,13 +158,6 @@ functions:
return_type: int
arguments:
- type: void
- name: realloc
standards:
- stdc
return_type: void *
arguments:
- type: void *
- type: size_t
- name: srand
standards:
- stdc
Expand Down
Loading