mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
Revert "libs/libc: correct the getrandom(2) prototype"
This reverts commit 8411ef1873.
Signed-off-by: chao.an <anchao@xiaomi.com>
Change-Id: I29e90e01f3b8a0460ee53831d38d96edf7d12ef2
This commit is contained in:
+2
-18
@@ -555,21 +555,13 @@ void up_randompool_initialize(void)
|
||||
* Input Parameters:
|
||||
* bytes - Buffer for returned random bytes
|
||||
* nbytes - Number of bytes requested.
|
||||
* flags - Bit mask that can contain zero or more of the ORed values
|
||||
* together.
|
||||
*
|
||||
* Returned Value:
|
||||
* 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.
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t getrandom(FAR void *bytes, size_t nbytes, unsigned int flags)
|
||||
void getrandom(FAR void *bytes, size_t nbytes)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -578,13 +570,5 @@ ssize_t 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;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ static ssize_t devurand_read(FAR struct file *filep, FAR char *buffer,
|
||||
#ifdef CONFIG_DEV_URANDOM_RANDOM_POOL
|
||||
if (len > 0)
|
||||
{
|
||||
getrandom(buffer, len, 0);
|
||||
getrandom(buffer, len);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
+2
-25
@@ -44,21 +44,6 @@
|
||||
#include <nuttx/config.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Flags for getrandom(2)
|
||||
*
|
||||
* GRND_NONBLOCK Don't block and return EAGAIN instead
|
||||
* GRND_RANDOM No effect
|
||||
* GRND_INSECURE Return non-cryptographic random bytes
|
||||
*/
|
||||
|
||||
#define GRND_NONBLOCK 0x0001
|
||||
#define GRND_RANDOM 0x0002
|
||||
#define GRND_INSECURE 0x0004
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
@@ -79,21 +64,13 @@
|
||||
* Input Parameters:
|
||||
* bytes - Buffer for returned random bytes
|
||||
* nbytes - Number of bytes requested.
|
||||
* flags - Bit mask that can contain zero or more of the ORed values
|
||||
* together.
|
||||
*
|
||||
* Returned Value:
|
||||
* 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.
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t getrandom(FAR void *bytes, size_t nbytes, unsigned int flags);
|
||||
void getrandom(FAR void *bytes, size_t nbytes);
|
||||
|
||||
#endif /* CONFIG_CRYPTO_RANDOM_POOL */
|
||||
|
||||
|
||||
@@ -382,5 +382,5 @@ SYSCALL_LOOKUP(telldir, 1)
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_CRYPTO_RANDOM_POOL
|
||||
SYSCALL_LOOKUP(getrandom, 3)
|
||||
SYSCALL_LOOKUP(getrandom, 2)
|
||||
#endif
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
void uuid_create(uuid_t *u, uint32_t *status)
|
||||
{
|
||||
#ifdef CONFIG_CRYPTO_RANDOM_POOL
|
||||
getrandom(u, sizeof(uuid_t), 0);
|
||||
getrandom(u, sizeof(uuid_t));
|
||||
#else
|
||||
unsigned long *beg = (unsigned long *)u;
|
||||
unsigned long *end = (unsigned long *)(u + 1);
|
||||
|
||||
+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)","ssize_t","void","FAR void *","size_t","unsigned int"
|
||||
"getrandom","sys/random.h","defined(CONFIG_CRYPTO_RANDOM_POOL)","void","FAR void *","size_t"
|
||||
"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