summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common/sys/random.h
diff options
context:
space:
mode:
authorThorsten Glaser <tg@debian.org>2025-04-07 00:23:45 +0200
committerWaldemar Brodkorb <wbx@openadk.org>2025-04-07 00:24:40 +0200
commit8a6bb3fb10bef1a31088e845f6b4b2ae44959ef3 (patch)
tree20976e9dde9b449d8d0acca305f00b43659c3936 /libc/sysdeps/linux/common/sys/random.h
parentf82757461a7fdec3233766494d7003bc89f71241 (diff)
add getentropy(), fix return value of getrandom()HEADmaster
Signed-off-by: Thorsten Glaser <tg@debian.org>
Diffstat (limited to 'libc/sysdeps/linux/common/sys/random.h')
-rw-r--r--libc/sysdeps/linux/common/sys/random.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/libc/sysdeps/linux/common/sys/random.h b/libc/sysdeps/linux/common/sys/random.h
index 3d24e439b..c3d9cf575 100644
--- a/libc/sysdeps/linux/common/sys/random.h
+++ b/libc/sysdeps/linux/common/sys/random.h
@@ -4,11 +4,19 @@
#ifndef _SYS_RANDOM_H
#define _SYS_RANDOM_H 1
+
#include <features.h>
#include <stddef.h>
__BEGIN_DECLS
+#include <bits/types.h>
+
+#ifndef __ssize_t_defined
+typedef __ssize_t ssize_t;
+# define __ssize_t_defined
+#endif
+
#if defined __UCLIBC_LINUX_SPECIFIC__
# if 0 /*def __ASSUME_GETRANDOM_SYSCALL */
# include <linux/random.h>
@@ -26,9 +34,15 @@ __BEGIN_DECLS
# define GRND_RANDOM 0x0002
# define GRND_INSECURE 0x0004
# endif
-/* FIXME: aren't there a couple of __restrict and const missing ? */
-extern int getrandom(void *__buf, size_t count, unsigned int flags)
+extern ssize_t getrandom(void *__buf, size_t count, unsigned int flags)
__nonnull ((1)) __wur;
+
+/* OpenBSD-compatible access to random bytes.
+ May be a cancellation point here, unlike in glibc/musl. */
+# ifndef __getentropy_defined
+extern int getentropy(void *__buf, size_t __len) __nonnull ((1)) __wur;
+# define __getentropy_defined
+# endif
#endif
__END_DECLS