mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
libs/libc: correct the getrandom(2) prototype
Reference here: https://man7.org/linux/man-pages/man2/getrandom.2.html https://www.freebsd.org/cgi/man.cgi?query=getrandom&sektion=2&manpath=freebsd-release-ports Change-Id: I9813a46ad80db1436524a1fc44be40e4bf17105c Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
+16
-2
@@ -559,11 +559,17 @@ void up_randompool_initialize(void)
|
||||
* together.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
* On success, getrandom() returns the number of bytes that were copied
|
||||
* to the buffer buf. This may be less than the number of bytes
|
||||
* requested via buflen if either GRND_RANDOM was specified in flags and
|
||||
* insufficient entropy was present in the random source or the system
|
||||
* call was interrupted by a signal.
|
||||
|
||||
* On error, -1 is returned, and errno is set appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void getrandom(FAR void *bytes, size_t nbytes, unsigned int flags)
|
||||
ssize_t getrandom(FAR void *bytes, size_t nbytes, unsigned int flags)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -572,5 +578,13 @@ void getrandom(FAR void *bytes, size_t nbytes, unsigned int flags)
|
||||
{
|
||||
rng_buf_internal(bytes, nbytes);
|
||||
nxsem_post(&g_rng.rd_sem);
|
||||
ret = nbytes;
|
||||
}
|
||||
else
|
||||
{
|
||||
set_errno(-ret);
|
||||
ret = ERROR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -48,8 +48,7 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/*
|
||||
* Flags for getrandom(2)
|
||||
/* Flags for getrandom(2)
|
||||
*
|
||||
* GRND_NONBLOCK Don't block and return EAGAIN instead
|
||||
* GRND_RANDOM No effect
|
||||
@@ -84,11 +83,17 @@
|
||||
* together.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
* On success, getrandom() returns the number of bytes that were copied
|
||||
* to the buffer buf. This may be less than the number of bytes
|
||||
* requested via buflen if either GRND_RANDOM was specified in flags and
|
||||
* insufficient entropy was present in the random source or the system
|
||||
* call was interrupted by a signal.
|
||||
*
|
||||
* On error, -1 is returned, and errno is set appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void getrandom(FAR void *bytes, size_t nbytes, unsigned int flags);
|
||||
ssize_t getrandom(FAR void *bytes, size_t nbytes, unsigned int flags);
|
||||
|
||||
#endif /* CONFIG_CRYPTO_RANDOM_POOL */
|
||||
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@
|
||||
"getitimer","sys/time.h","!defined(CONFIG_DISABLE_POSIX_TIMERS)","int","int","FAR struct itimerval *"
|
||||
"getpeername","sys/socket.h","defined(CONFIG_NET)","int","int","FAR struct sockaddr *","FAR socklen_t *"
|
||||
"getpid","unistd.h","","pid_t"
|
||||
"getrandom","sys/random.h","defined(CONFIG_CRYPTO_RANDOM_POOL)","void","FAR void *","size_t","unsigned int"
|
||||
"getrandom","sys/random.h","defined(CONFIG_CRYPTO_RANDOM_POOL)","ssize_t","void","FAR void *","size_t","unsigned int"
|
||||
"getsockname","sys/socket.h","defined(CONFIG_NET)","int","int","FAR struct sockaddr *","FAR socklen_t *"
|
||||
"getsockopt","sys/socket.h","defined(CONFIG_NET)","int","int","int","int","FAR void *","FAR socklen_t *"
|
||||
"getuid","unistd.h","defined(CONFIG_SCHED_USER_IDENTITY)","uid_t"
|
||||
|
||||
|
Reference in New Issue
Block a user