new file mode 100644
@@ -0,0 +1,131 @@
+From 7d79a14addcea972e801709413f5c9a5226e3ad3 Mon Sep 17 00:00:00 2001
+From: Jean-Roland Gosse <jean.roland.gosse@gmail.com>
+Date: Mon, 8 Jan 2024 17:40:03 +0100
+Subject: [PATCH] Remove nop or replace with macro (#314)
+
+* feat: remove nop instructions
+
+* feat: revert partly previous commit
+
+* feat: replace nops by configurable macro
+
+Upstream: https://github.com/eclipse-zenoh/zenoh-pico/commit/7d79a14addcea972e801709413f5c9a5226e3ad3
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+---
+ include/zenoh-pico/config.h | 7 +++++++
+ src/link/endpoint.c | 6 ------
+ src/system/arduino/esp32/network.cpp | 4 ++--
+ src/system/unix/system.c | 10 +++++-----
+ 4 files changed, 14 insertions(+), 13 deletions(-)
+
+diff --git a/include/zenoh-pico/config.h b/include/zenoh-pico/config.h
+index c1bb5ad83..084981a3e 100644
+--- a/include/zenoh-pico/config.h
++++ b/include/zenoh-pico/config.h
+@@ -309,4 +309,11 @@
+ #define Z_FRAG_MAX_SIZE 300000
+ #endif
+
++/**
++ * Default "nop" instruction
++ */
++#ifndef ZP_ASM_NOP
++#define ZP_ASM_NOP __asm__("nop")
++#endif
++
+ #endif /* INCLUDE_ZENOH_PICO_CONFIG_H */
+diff --git a/src/link/endpoint.c b/src/link/endpoint.c
+index ff596a07b..035e646a6 100644
+--- a/src/link/endpoint.c
++++ b/src/link/endpoint.c
+@@ -360,9 +360,7 @@ size_t _z_endpoint_config_strlen(const _z_str_intmap_t *s, const char *proto) {
+ } else
+ #endif
+ {
+- __asm__("nop");
+ }
+-
+ return len;
+ }
+
+@@ -398,9 +395,7 @@ char *_z_endpoint_config_to_str(const _z_str_intmap_t *s, const char *proto) {
+ } else
+ #endif
+ {
+- __asm__("nop");
+ }
+-
+ return res;
+ }
+
+diff --git a/src/system/arduino/esp32/network.cpp b/src/system/arduino/esp32/network.cpp
+index c088f1ce1..cac67f77b 100644
+--- a/src/system/arduino/esp32/network.cpp
++++ b/src/system/arduino/esp32/network.cpp
+@@ -558,7 +558,7 @@ int8_t _z_open_bt(_z_sys_net_socket_t *sock, const char *gname, uint8_t mode, ui
+ uint8_t connected = sock->_bts->connect(gname);
+ if (!connected) {
+ while (!sock->_bts->connected(tout)) {
+- __asm__("nop");
++ ZP_ASM_NOP;
+ }
+ }
+ } else {
+@@ -584,7 +584,7 @@ int8_t _z_listen_bt(_z_sys_net_socket_t *sock, const char *gname, uint8_t mode,
+ uint8_t connected = sock->_bts->connect(gname);
+ if (!connected) {
+ while (!sock->_bts->connected(tout)) {
+- __asm__("nop");
++ ZP_ASM_NOP;
+ }
+ }
+ } else {
+diff --git a/src/system/unix/system.c b/src/system/unix/system.c
+index 28223b83f..de5e4e505 100644
+--- a/src/system/unix/system.c
++++ b/src/system/unix/system.c
+@@ -32,7 +32,7 @@ uint8_t z_random_u8(void) {
+ uint8_t ret = 0;
+ #if defined(ZENOH_LINUX)
+ while (getrandom(&ret, sizeof(uint8_t), 0) <= 0) {
+- __asm__("nop");
++ ZP_ASM_NOP;
+ }
+ #elif defined(ZENOH_MACOS) || defined(ZENOH_BSD)
+ ret = z_random_u32();
+@@ -45,7 +45,7 @@ uint16_t z_random_u16(void) {
+ uint16_t ret = 0;
+ #if defined(ZENOH_LINUX)
+ while (getrandom(&ret, sizeof(uint16_t), 0) <= 0) {
+- __asm__("nop");
++ ZP_ASM_NOP;
+ }
+ #elif defined(ZENOH_MACOS) || defined(ZENOH_BSD)
+ ret = z_random_u32();
+@@ -58,7 +58,7 @@ uint32_t z_random_u32(void) {
+ uint32_t ret = 0;
+ #if defined(ZENOH_LINUX)
+ while (getrandom(&ret, sizeof(uint32_t), 0) <= 0) {
+- __asm__("nop");
++ ZP_ASM_NOP;
+ }
+ #elif defined(ZENOH_MACOS) || defined(ZENOH_BSD)
+ ret = arc4random();
+@@ -71,7 +71,7 @@ uint64_t z_random_u64(void) {
+ uint64_t ret = 0;
+ #if defined(ZENOH_LINUX)
+ while (getrandom(&ret, sizeof(uint64_t), 0) <= 0) {
+- __asm__("nop");
++ ZP_ASM_NOP;
+ }
+ #elif defined(ZENOH_MACOS) || defined(ZENOH_BSD)
+ ret |= z_random_u32();
+@@ -85,7 +85,7 @@ 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");
++ ZP_ASM_NOP;
+ }
+ #elif defined(ZENOH_MACOS) || defined(ZENOH_BSD)
+ arc4random_buf(buf, len);
@@ -11,4 +11,10 @@ LIBZENOH_PICO_LICENSE_FILES = LICENSE
LIBZENOH_PICO_SUPPORTS_IN_SOURCE_BUILD = NO
LIBZENOH_PICO_INSTALL_STAGING = YES
+# __asm__("nop") is unsupported by or1k so define it to an empty value
+ifeq ($(BR2_or1k),y)
+LIBZENOH_PICO_CONF_OPTS += \
+ -DCMAKE_C_FLAGS="$(TARGET_CFLAGS) -DZP_ASM_NOP"
+endif
+
$(eval $(cmake-package))
Fix the following build failure with or1k raises since the addition of the package in commit a96361901dcc7b962a0c43f163e97a2de65687f3: /home/autobuild/autobuild/instance-1/output-1/build/libzenoh-pico-0.10.0-rc/src/link/endpoint.c: Assembler messages: /home/autobuild/autobuild/instance-1/output-1/build/libzenoh-pico-0.10.0-rc/src/link/endpoint.c:358: Error: unrecognized instruction `nop' Fixes: - http://autobuild.buildroot.org/results/fd0b2c666a1dc1537162d15b27743abd270243ed Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> --- ...001-Remove-nop-or-replace-with-macro.patch | 131 ++++++++++++++++++ package/libzenoh-pico/libzenoh-pico.mk | 6 + 2 files changed, 137 insertions(+) create mode 100644 package/libzenoh-pico/0001-Remove-nop-or-replace-with-macro.patch