summaryrefslogtreecommitdiff
path: root/emulator
diff options
context:
space:
mode:
authorFabrice Fontaine <fontaine.fabrice@gmail.com>2022-02-14 21:17:39 +0100
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-02-15 13:36:35 -0800
commitfb57ad9b9d107856e5f1c8135da04ffa2f7a11ac (patch)
tree50b56120715eefaeab8632d8cb16d8e2f19f937d /emulator
parentb5ff08b267445f9407d6eefad86cde45ec3a50a2 (diff)
downloadbluez-fb57ad9b9d107856e5f1c8135da04ffa2f7a11ac.tar.gz
build: Fix errors with glibc < 2.25
getrandom and sys/random.h are only available since glibc 2.25: https://www.gnu.org/software/gnulib/manual/html_node/sys_002frandom_002eh.html resulting in the following build failures since version 5.63 and https://git.kernel.org/pub/scm/bluetooth/bluez.git/log/?qt=grep&q=getrandom: plugins/autopair.c:20:24: fatal error: sys/random.h: No such file or directory #include <sys/random.h> ^ To fix this build failure, add util_getrandom and a fallback (borrowed from pipewire and licensed under MIT): https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/master/src/pipewire/utils.c Fixes: - http://autobuild.buildroot.org/results/6b8870d12e0804d6154230a7322c49416c1dc0e2
Diffstat (limited to 'emulator')
-rw-r--r--emulator/le.c3
-rw-r--r--emulator/phy.c3
2 files changed, 2 insertions, 4 deletions
diff --git a/emulator/le.c b/emulator/le.c
index f8f313f2c..7656a657c 100644
--- a/emulator/le.c
+++ b/emulator/le.c
@@ -20,7 +20,6 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/uio.h>
-#include <sys/random.h>
#include <time.h>
#include "lib/bluetooth.h"
@@ -509,7 +508,7 @@ static unsigned int get_adv_delay(void)
/* The advertising delay is a pseudo-random value with a range
* of 0 ms to 10 ms generated for each advertising event.
*/
- if (getrandom(&val, sizeof(val), 0) < 0) {
+ if (util_getrandom(&val, sizeof(val), 0) < 0) {
/* If it fails to get the random number, use a static value */
val = 5;
}
diff --git a/emulator/phy.c b/emulator/phy.c
index 44cace438..7de85fb05 100644
--- a/emulator/phy.c
+++ b/emulator/phy.c
@@ -19,7 +19,6 @@
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
-#include <sys/random.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <time.h>
@@ -174,7 +173,7 @@ struct bt_phy *bt_phy_new(void)
mainloop_add_fd(phy->rx_fd, EPOLLIN, phy_rx_callback, phy, NULL);
if (!get_random_bytes(&phy->id, sizeof(phy->id))) {
- if (getrandom(&phy->id, sizeof(phy->id), 0) < 0) {
+ if (util_getrandom(&phy->id, sizeof(phy->id), 0) < 0) {
mainloop_remove_fd(phy->rx_fd);
close(phy->tx_fd);
close(phy->rx_fd);