authorgravatar for pat.github@tullmann.orgPat Tullmann <pat.github@tullmann.org> 2024-06-26 12:51:19-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-07-03 02:57:24-04:00
loga31fe8aa3ed4868fb10000c1e3eeaa094488fc94
tree64eadd24cae7bd3a2671b9c0451eb9a91d3e3982
parent5e3bad3556435663fa9220390248a5ed4f75be47

glibc headers: arc4random* functions added in glibc 2.36

Here's the glibc v2.36 announcment noting the addition of arc4random, arc4random_buf and arc4random_uniform: https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS;h=8420a65cd06874ee09518366b8fba746a557212a;hb=6f4e0fcfa2d2b0915816a3a3a1d48b4763a7dee2 Tested with the testcase from the bug. I get a compile-time error when building against older glibc (instead of a linker error), and no errors (as before) when compiling against v2.36 or later. And the glibc_compat regression tests pass. Fix #20426

1 files changed, 6 insertions(+), 0 deletions(-)

lib/libc/include/generic-glibc/stdlib.h+6
...@@ -653,6 +653,11 @@ extern int lcong48_r (unsigned short int __param[7],...@@ -653,6 +653,11 @@ extern int lcong48_r (unsigned short int __param[7],
653 struct drand48_data *__buffer)653 struct drand48_data *__buffer)
654 __THROW __nonnull ((1, 2));654 __THROW __nonnull ((1, 2));
655655
656/*
657 * arc4random* symbols introduced in glibc 2.36:
658 * https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS;h=8420a65cd06874ee09518366b8fba746a557212a;hb=6f4e0fcfa2d2b0915816a3a3a1d48b4763a7dee2
659 */
660# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 36) || __GLIBC__ > 2
656/* Return a random integer between zero and 2**32-1 (inclusive). */661/* Return a random integer between zero and 2**32-1 (inclusive). */
657extern __uint32_t arc4random (void)662extern __uint32_t arc4random (void)
658 __THROW __wur;663 __THROW __wur;
...@@ -665,6 +670,7 @@ extern void arc4random_buf (void *__buf, size_t __size)...@@ -665,6 +670,7 @@ extern void arc4random_buf (void *__buf, size_t __size)
665 limit (exclusive). */670 limit (exclusive). */
666extern __uint32_t arc4random_uniform (__uint32_t __upper_bound)671extern __uint32_t arc4random_uniform (__uint32_t __upper_bound)
667 __THROW __wur;672 __THROW __wur;
673# endif /* glibc v2.36 and later */
668# endif /* Use misc. */674# endif /* Use misc. */
669#endif /* Use misc or X/Open. */675#endif /* Use misc or X/Open. */
670676