Skip to content

add glibc versioning for a number of headers #24237

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 7 commits into from
Jun 24, 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
5 changes: 5 additions & 0 deletions lib/libc/include/generic-glibc/sys/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

__BEGIN_DECLS

// zig patch: getrandom and getentropy were added in glibc 2.25
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25) || __GLIBC__ > 2

/* Write LENGTH bytes of randomness starting at BUFFER. Return the
number of bytes written, or -1 on error. */
ssize_t getrandom (void *__buffer, size_t __length,
Expand All @@ -40,6 +43,8 @@ ssize_t getrandom (void *__buffer, size_t __length,
int getentropy (void *__buffer, size_t __length) __wur
__attr_access ((__write_only__, 1, 2));

#endif /* glibc 2.25 or later */

__END_DECLS

#endif /* _SYS_RANDOM_H */
5 changes: 5 additions & 0 deletions lib/libc/include/generic-glibc/sys/single_threaded.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */

// zig patch: sys/single_threaded.h header was added in glibc 2.35
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 35
#error "sys/single_threaded.h did not exist before glibc 2.35"
#endif /* error for glibc before 2.35 */

#ifndef _SYS_SINGLE_THREADED_H
#define _SYS_SINGLE_THREADED_H

Expand Down
6 changes: 6 additions & 0 deletions lib/libc/include/generic-glibc/threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */


// zig patch: threads header was added in glibc 2.28
#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 28
#error "threads.h did not exist before glibc 2.28"
#endif /* error for glibc before 2.28 */

#ifndef _THREADS_H
#define _THREADS_H 1

Expand Down
6 changes: 6 additions & 0 deletions lib/libc/include/generic-glibc/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -1138,10 +1138,16 @@ extern int lockf64 (int __fd, int __cmd, __off64_t __len) __wur;
while (__result == -1L && errno == EINTR); \
__result; }))

// zig patch: copy_file_range was added in glibc 2.27
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 27) || __GLIBC__ > 2

/* Copy LENGTH bytes from INFD to OUTFD. */
ssize_t copy_file_range (int __infd, __off64_t *__pinoff,
int __outfd, __off64_t *__poutoff,
size_t __length, unsigned int __flags);

#endif /* glibc 2.27 or later */

#endif /* __USE_GNU */

#if defined __USE_POSIX199309 || defined __USE_UNIX98
Expand Down