mirror of https://git.kore.io/kore.git
Add kore_platform_random_uint32().
This commit is contained in:
parent
7b48959c32
commit
4ecd6d5603
|
@ -803,6 +803,7 @@ void kore_platform_schedule_read(int, void *);
|
||||||
void kore_platform_schedule_write(int, void *);
|
void kore_platform_schedule_write(int, void *);
|
||||||
void kore_platform_event_schedule(int, int, int, void *);
|
void kore_platform_event_schedule(int, int, int, void *);
|
||||||
void kore_platform_worker_setcpu(struct kore_worker *);
|
void kore_platform_worker_setcpu(struct kore_worker *);
|
||||||
|
u_int32_t kore_platform_random_uint32(void);
|
||||||
|
|
||||||
#if defined(KORE_USE_PLATFORM_SENDFILE)
|
#if defined(KORE_USE_PLATFORM_SENDFILE)
|
||||||
int kore_platform_sendfile(struct connection *, struct netbuf *);
|
int kore_platform_sendfile(struct connection *, struct netbuf *);
|
||||||
|
|
|
@ -298,6 +298,12 @@ kore_platform_sandbox(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u_int32_t
|
||||||
|
kore_platform_random_uint32(void)
|
||||||
|
{
|
||||||
|
return (arc4random());
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(KORE_USE_PLATFORM_PLEDGE)
|
#if defined(KORE_USE_PLATFORM_PLEDGE)
|
||||||
void
|
void
|
||||||
kore_platform_pledge(void)
|
kore_platform_pledge(void)
|
||||||
|
|
16
src/linux.c
16
src/linux.c
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include <sys/random.h>
|
||||||
#include <sys/epoll.h>
|
#include <sys/epoll.h>
|
||||||
#include <sys/sendfile.h>
|
#include <sys/sendfile.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
|
@ -262,3 +263,18 @@ kore_platform_sandbox(void)
|
||||||
{
|
{
|
||||||
kore_seccomp_enable();
|
kore_seccomp_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u_int32_t
|
||||||
|
kore_platform_random_uint32(void)
|
||||||
|
{
|
||||||
|
ssize_t ret;
|
||||||
|
u_int32_t val;
|
||||||
|
|
||||||
|
if ((ret = getrandom(&val, sizeof(val), 0)) == -1)
|
||||||
|
fatalx("getrandom(): %s", errno_s);
|
||||||
|
|
||||||
|
if ((size_t)ret != sizeof(val))
|
||||||
|
fatalx("getrandom() %zd != %zu", ret, sizeof(val));
|
||||||
|
|
||||||
|
return (val);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue