mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-10-14 20:02:38 +00:00
Reinstate compatibility with older Linux with no getrandom()
Commit42d8b2b1
"Remove legacy FreeBSD compatibility code" removed compatibility with old versions of FreeBSD, but also removed compatibility with old versions of Linux and glibc, which was requested in #833. This partially reverts commit42d8b2b167
. Resolves: #833 Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
31f387868a
commit
e167123667
|
@ -34,6 +34,19 @@
|
||||||
#include <sys/random.h>
|
#include <sys/random.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_GETRANDOM
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
#include <spa/utils/string.h>
|
#include <spa/utils/string.h>
|
||||||
#include <spa/debug/types.h>
|
#include <spa/debug/types.h>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue