authorgravatar for m@pyc.acMarc <m@pyc.ac> 2025-06-24 23:14:00+07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-06-24 16:14:00+00:00
log75d6d4c3f20423eede8ecaf7bcc4eaa501c1af9d
tree3123352e95386733edebf61e495d4c198f3d789e
parent35329b510c26efdc95fdb79a041d8e0b04381126
signaturebadge-check Signed by PGP key B5690EEEBB952194

add glibc versioning for a number of headers (#24237)

* getrandom was added in glibc 2.25 https://sourceware.org/bugzilla/show_bug.cgi?id=17252 * copy_file_range was added in glibc 2.27 https://sourceware.org/git/?p=glibc.git;a=commit;h=bad7a0c81f501fbbcc79af9eaa4b8254441c4a1f * threads.h should not exist for glibc < 2.28 * single_threaded.h should not exist for glibc < 2.35 * Apply suggestions from code review Co-authored-by: Alex Rønne Petersen <alex@alexrp.com> * 2.35 instead of 35 * before 2.35 instead of 2.34 and before --------- Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>

4 files changed, 22 insertions(+), 0 deletions(-)

lib/libc/include/generic-glibc/sys/random.h+5
......@@ -29,6 +29,9 @@
2929
3030__BEGIN_DECLS
3131
32// zig patch: getrandom and getentropy were added in glibc 2.25
33#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25) || __GLIBC__ > 2
34
3235/* Write LENGTH bytes of randomness starting at BUFFER. Return the
3336 number of bytes written, or -1 on error. */
3437ssize_t getrandom (void *__buffer, size_t __length,
......@@ -40,6 +43,8 @@ ssize_t getrandom (void *__buffer, size_t __length,
4043int getentropy (void *__buffer, size_t __length) __wur
4144 __attr_access ((__write_only__, 1, 2));
4245
46#endif /* glibc 2.25 or later */
47
4348__END_DECLS
4449
4550#endif /* _SYS_RANDOM_H */
\ No newline at end of file
lib/libc/include/generic-glibc/sys/single_threaded.h+5
......@@ -16,6 +16,11 @@
1616 License along with the GNU C Library; if not, see
1717 <https://www.gnu.org/licenses/>. */
1818
19// zig patch: sys/single_threaded.h header was added in glibc 2.35
20#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 35
21 #error "sys/single_threaded.h did not exist before glibc 2.35"
22#endif /* error for glibc before 2.35 */
23
1924#ifndef _SYS_SINGLE_THREADED_H
2025#define _SYS_SINGLE_THREADED_H
2126
lib/libc/include/generic-glibc/threads.h+6
......@@ -16,6 +16,12 @@
1616 License along with the GNU C Library; if not, see
1717 <https://www.gnu.org/licenses/>. */
1818
19
20// zig patch: threads header was added in glibc 2.28
21#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 28
22 #error "threads.h did not exist before glibc 2.28"
23#endif /* error for glibc before 2.28 */
24
1925#ifndef _THREADS_H
2026#define _THREADS_H 1
2127
lib/libc/include/generic-glibc/unistd.h+6
......@@ -1138,10 +1138,16 @@ extern int lockf64 (int __fd, int __cmd, __off64_t __len) __wur;
11381138 while (__result == -1L && errno == EINTR); \
11391139 __result; }))
11401140
1141// zig patch: copy_file_range was added in glibc 2.27
1142#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 27) || __GLIBC__ > 2
1143
11411144/* Copy LENGTH bytes from INFD to OUTFD. */
11421145ssize_t copy_file_range (int __infd, __off64_t *__pinoff,
11431146 int __outfd, __off64_t *__poutoff,
11441147 size_t __length, unsigned int __flags);
1148
1149#endif /* glibc 2.27 or later */
1150
11451151#endif /* __USE_GNU */
11461152
11471153#if defined __USE_POSIX199309 || defined __USE_UNIX98