mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
Add userspace implementation of getrandom() for FreeBSD 11
This commit is contained in:
parent
087811e171
commit
9f53057b51
1 changed files with 18 additions and 0 deletions
|
|
@ -29,6 +29,24 @@
|
||||||
#endif
|
#endif
|
||||||
#include <sys/random.h>
|
#include <sys/random.h>
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
// FreeBSD versions < 12 do not have getrandom() syscall
|
||||||
|
// Give a poor-man implementation here
|
||||||
|
// Can be removed after September 30, 2021
|
||||||
|
#if __FreeBSD_version < 1200000
|
||||||
|
ssize_t getrandom(void *buf, size_t buflen, unsigned int flags) {
|
||||||
|
int fd = open("/dev/random", O_CLOEXEC);
|
||||||
|
if (fd < 0)
|
||||||
|
return -1;
|
||||||
|
ssize_t bytes = read(fd, buf, buflen);
|
||||||
|
close(fd);
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <spa/debug/types.h>
|
#include <spa/debug/types.h>
|
||||||
|
|
||||||
#include "pipewire/impl.h"
|
#include "pipewire/impl.h"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue