Skip to content

Commit

Permalink
feat: revert partly previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Jan 8, 2024
1 parent a1b3ca6 commit 0869657
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
8 changes: 6 additions & 2 deletions src/system/arduino/esp32/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,9 @@ int8_t _z_open_bt(_z_sys_net_socket_t *sock, const char *gname, uint8_t mode, ui
sock->_bts->begin(gname, true);
uint8_t connected = sock->_bts->connect(gname);
if (!connected) {
while (!sock->_bts->connected(tout));
while (!sock->_bts->connected(tout)) {
__asm__("nop");
}
}
} else {
delete sock->_bts;
Expand All @@ -581,7 +583,9 @@ int8_t _z_listen_bt(_z_sys_net_socket_t *sock, const char *gname, uint8_t mode,
sock->_bts->begin(gname, true);
uint8_t connected = sock->_bts->connect(gname);
if (!connected) {
while (!sock->_bts->connected(tout));
while (!sock->_bts->connected(tout)) {
__asm__("nop");
}
}
} else {
delete sock->_bts;
Expand Down
25 changes: 15 additions & 10 deletions src/system/unix/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
uint8_t z_random_u8(void) {
uint8_t ret = 0;
#if defined(ZENOH_LINUX)
while (getrandom(&ret, sizeof(uint8_t), 0) <= 0)
;
while (getrandom(&ret, sizeof(uint8_t), 0) <= 0) {
__asm__("nop");
}
#elif defined(ZENOH_MACOS) || defined(ZENOH_BSD)
ret = z_random_u32();
#endif
Expand All @@ -43,8 +44,9 @@ uint8_t z_random_u8(void) {
uint16_t z_random_u16(void) {
uint16_t ret = 0;
#if defined(ZENOH_LINUX)
while (getrandom(&ret, sizeof(uint16_t), 0) <= 0)
;
while (getrandom(&ret, sizeof(uint16_t), 0) <= 0) {
__asm__("nop");
}
#elif defined(ZENOH_MACOS) || defined(ZENOH_BSD)
ret = z_random_u32();
#endif
Expand All @@ -55,8 +57,9 @@ uint16_t z_random_u16(void) {
uint32_t z_random_u32(void) {
uint32_t ret = 0;
#if defined(ZENOH_LINUX)
while (getrandom(&ret, sizeof(uint32_t), 0) <= 0)
;
while (getrandom(&ret, sizeof(uint32_t), 0) <= 0) {
__asm__("nop");
}
#elif defined(ZENOH_MACOS) || defined(ZENOH_BSD)
ret = arc4random();
#endif
Expand All @@ -67,8 +70,9 @@ uint32_t z_random_u32(void) {
uint64_t z_random_u64(void) {
uint64_t ret = 0;
#if defined(ZENOH_LINUX)
while (getrandom(&ret, sizeof(uint64_t), 0) <= 0)
;
while (getrandom(&ret, sizeof(uint64_t), 0) <= 0) {
__asm__("nop");
}
#elif defined(ZENOH_MACOS) || defined(ZENOH_BSD)
ret |= z_random_u32();
ret = ret << 32;
Expand All @@ -80,8 +84,9 @@ uint64_t z_random_u64(void) {

void z_random_fill(void *buf, size_t len) {
#if defined(ZENOH_LINUX)
while (getrandom(buf, len, 0) <= 0)
;
while (getrandom(buf, len, 0) <= 0) {
__asm__("nop");
}
#elif defined(ZENOH_MACOS) || defined(ZENOH_BSD)
arc4random_buf(buf, len);
#endif
Expand Down

0 comments on commit 0869657

Please sign in to comment.