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:
chao.an
2020-12-07 22:40:26 +08:00
parent 098efd4949
commit 8411ef1873
3 changed files with 26 additions and 7 deletions
+16 -2
View File
@@ -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;
}
+9 -4
View File
@@ -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
View File
@@ -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"
1 _exit unistd.h void int
35 getitimer sys/time.h !defined(CONFIG_DISABLE_POSIX_TIMERS) int int
36 getpeername sys/socket.h defined(CONFIG_NET) int int
37 getpid unistd.h pid_t
38 getrandom sys/random.h defined(CONFIG_CRYPTO_RANDOM_POOL) void ssize_t FAR void * void
39 getsockname sys/socket.h defined(CONFIG_NET) int int
40 getsockopt sys/socket.h defined(CONFIG_NET) int int
41 getuid unistd.h defined(CONFIG_SCHED_USER_IDENTITY) uid_t