Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove nop or replace with macro #314

Merged
merged 3 commits into from
Jan 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: remove nop instructions
jean-roland committed Jan 8, 2024
commit a1b3ca6064845e5b4b33a8e9e97e9f0e85096867
6 changes: 0 additions & 6 deletions src/link/endpoint.c
Original file line number Diff line number Diff line change
@@ -360,10 +360,7 @@ size_t _z_endpoint_config_strlen(const _z_str_intmap_t *s, const char *proto) {
#endif
if (_z_str_eq(proto, RAWETH_SCHEMA) == true) {
len = _z_raweth_config_strlen(s);
} else {
__asm__("nop");
}

return len;
}

@@ -398,10 +395,7 @@ char *_z_endpoint_config_to_str(const _z_str_intmap_t *s, const char *proto) {
#endif
if (_z_str_eq(proto, RAWETH_SCHEMA) == true) {
_z_raweth_config_to_str(s);
} else {
__asm__("nop");
}

return res;
}

8 changes: 2 additions & 6 deletions src/system/arduino/esp32/network.cpp
Original file line number Diff line number Diff line change
@@ -557,9 +557,7 @@ 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)) {
__asm__("nop");
}
while (!sock->_bts->connected(tout));
}
} else {
delete sock->_bts;
@@ -583,9 +581,7 @@ 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)) {
__asm__("nop");
}
while (!sock->_bts->connected(tout));
}
} else {
delete sock->_bts;
25 changes: 10 additions & 15 deletions src/system/unix/system.c
Original file line number Diff line number Diff line change
@@ -31,9 +31,8 @@
uint8_t z_random_u8(void) {
uint8_t ret = 0;
#if defined(ZENOH_LINUX)
while (getrandom(&ret, sizeof(uint8_t), 0) <= 0) {
__asm__("nop");
}
while (getrandom(&ret, sizeof(uint8_t), 0) <= 0)
;
#elif defined(ZENOH_MACOS) || defined(ZENOH_BSD)
ret = z_random_u32();
#endif
@@ -44,9 +43,8 @@ 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) {
__asm__("nop");
}
while (getrandom(&ret, sizeof(uint16_t), 0) <= 0)
;
#elif defined(ZENOH_MACOS) || defined(ZENOH_BSD)
ret = z_random_u32();
#endif
@@ -57,9 +55,8 @@ 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) {
__asm__("nop");
}
while (getrandom(&ret, sizeof(uint32_t), 0) <= 0)
;
#elif defined(ZENOH_MACOS) || defined(ZENOH_BSD)
ret = arc4random();
#endif
@@ -70,9 +67,8 @@ 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) {
__asm__("nop");
}
while (getrandom(&ret, sizeof(uint64_t), 0) <= 0)
;
#elif defined(ZENOH_MACOS) || defined(ZENOH_BSD)
ret |= z_random_u32();
ret = ret << 32;
@@ -84,9 +80,8 @@ 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) {
__asm__("nop");
}
while (getrandom(buf, len, 0) <= 0)
;
#elif defined(ZENOH_MACOS) || defined(ZENOH_BSD)
arc4random_buf(buf, len);
#endif