cygwin-devel vs libbsd-devel: arc4random_stir() macro in stdlib.h breaks bsd/stdlib.h
Christian Franke
Christian.Franke@t-online.de
Sat Mar 15 12:04:17 GMT 2025
Corinna Vinschen via Cygwin wrote:
> On Mar 14 17:12, Corinna Vinschen via Cygwin wrote:
>> On Mar 14 16:50, Corinna Vinschen via Cygwin wrote:
>>> On Mar 14 13:48, Christian Franke via Cygwin wrote:
>>>> $ nm /usr/lib/libbsd.dll.a | grep ' arc4random' || echo not found
>>>> not found
>>>>
>>>> I guess:
>>>> - arc4random_addrandom() should be removed from libcygwin.a or added to
>>>> cygwin/stdlib.h.
>>> No, we can't do that (OpenSSH)
>> Ooooh, you mean arc4random_addrandom. My excuse for a brain was still
>> thinking of arc4random_stir *facepalm*
>>
>> Hmm...
>>
>>>> - all arc4random*() should be hidden for __CYGWIN__ in bsd/stdlib.h.
>>> This, we can do. Let me check.
> Check out cygwin-3.6.0-0.440.g5ec497dc80bc in conjunction with
> libbsd-0.12.2-4, both building right now.
Looks good ...
$ nm /usr/lib/libcygwin.a | grep ' arc4random'
0000000000000000 T arc4random
0000000000000000 T arc4random_buf
0000000000000000 T arc4random_uniform
$ gcc -E -xc - <<<'#include <stdlib.h>' | grep arc4random
__uint32_t arc4random (void);
__uint32_t arc4random_uniform (__uint32_t);
void arc4random_buf (void *, size_t);
$ nm /usr/lib/libbsd.dll.a | grep ' arc4random' || echo not found
not found
... except that bsd/stdlib.h still advertises the functions which could
no longer be linked:
$ gcc -E -xc - <<<'#include <bsd/stdlib.h>' | grep arc4random
__uint32_t arc4random (void);
__uint32_t arc4random_uniform (__uint32_t);
void arc4random_buf (void *, size_t);
void arc4random_stir(void);
void arc4random_addrandom(unsigned char *dat, int datlen);
Mostly cosmetic as this would not result in false positive
AC_CHECK_FUNC*() results.
I would suggest to revert the recent bsd/stdlib.h change and move the
__CYGWIN__ check to the top level #if instead, see attached patch.
--
Thanks,
Christian
-------------- next part --------------
--- bsd/stdlib.h-0.12.2-4 2025-03-14 20:18:36.000000000 +0100
+++ bsd/stdlib.h 2025-03-15 12:35:53.465262000 +0100
@@ -51,12 +51,10 @@
#include <stdint.h>
__BEGIN_DECLS
-#if !defined(__APPLE__) && !defined(__sun)
-#if (!defined(__GLIBC__) || \
+#if !defined(__APPLE__) && !defined(__CYGWIN__) && !defined(__sun)
+#if !defined(__GLIBC__) || \
!__GLIBC_PREREQ(2, 36) || \
- !defined(_DEFAULT_SOURCE)) && \
- (!defined(__CYGWIN__) || \
- !__BSD_VISIBLE)
+ !defined(_DEFAULT_SOURCE)
uint32_t arc4random(void);
void arc4random_buf(void *_buf, size_t n);
uint32_t arc4random_uniform(uint32_t upper_bound);
More information about the Cygwin
mailing list