mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-25 06:59:57 -05: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
1 changed files with 13 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue