Skip to content

Commit

Permalink
added Z_FEATURE_UNSTABLE_API, reliability put under it (#601)
Browse files Browse the repository at this point in the history
* added Z_FEATURE_UNSTABLE_API, reliability put under it

* test on unstable build moved to separate task to accelerate ci

* separate build with unstable api
  • Loading branch information
milyin authored Aug 22, 2024
1 parent cf62926 commit df1dfc9
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 4 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/build-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ jobs:
if: always()
run: kill ${{ steps.run-zenoh.outputs.zenohd-pid }}

unstable_build:
name: Check compilation with unstable API
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build with unstable
run: |
sudo apt install -y ninja-build
Z_FEATURE_UNSTABLE_API=1 CMAKE_GENERATOR=Ninja make
st_build:
needs: zenoh_build
name: Build and test in single thread on ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ set(BATCH_UNICAST_SIZE 2048 CACHE STRING "Use this to override the maximum unica
set(BATCH_MULTICAST_SIZE 2048 CACHE STRING "Use this to override the maximum multicast batch size")
set(Z_CONFIG_SOCKET_TIMEOUT 100 CACHE STRING "Default socket timeout in milliseconds")

set(Z_FEATURE_UNSTABLE_API 0 CACHE STRING "Toggle unstable Zenoh-C API")
set(Z_FEATURE_PUBLICATION 1 CACHE STRING "Toggle publication feature")
set(Z_FEATURE_SUBSCRIPTION 1 CACHE STRING "Toggle subscription feature")
set(Z_FEATURE_QUERY 1 CACHE STRING "Toggle query feature")
Expand All @@ -208,6 +209,7 @@ set(Z_FEATURE_INTEREST 1 CACHE STRING "Toggle interest feature")

add_compile_definitions("Z_BUILD_DEBUG=$<CONFIG:Debug>")
message(STATUS "Building with feature confing:\n\
* UNSTABLE_API: ${Z_FEATURE_UNSTABLE_API}\n\
* MULTI-THREAD: ${Z_FEATURE_MULTI_THREAD}\n\
* PUBLICATION: ${Z_FEATURE_PUBLICATION}\n\
* SUBSCRIPTION: ${Z_FEATURE_SUBSCRIPTION}\n\
Expand Down
3 changes: 2 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ ZENOH_DEBUG?=0

# Feature config toggle
# Accepted values: 0, 1
Z_FEATURE_UNSTABLE_API?=0
Z_FEATURE_MULTI_THREAD?=1
Z_FEATURE_PUBLICATION?=1
Z_FEATURE_SUBSCRIPTION?=1
Expand Down Expand Up @@ -78,7 +79,7 @@ CROSSIMG_PREFIX=zenoh-pico_
# - ARM: old versions of dockcross/dockcross were creating some issues since they used an old GCC (4.8.3) which lacks <stdatomic.h> (even using -std=gnu11)

CMAKE_OPT=-DZENOH_DEBUG=$(ZENOH_DEBUG) -DBUILD_EXAMPLES=$(BUILD_EXAMPLES) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DBUILD_TESTING=$(BUILD_TESTING) -DBUILD_MULTICAST=$(BUILD_MULTICAST)\
-DZ_FEATURE_MULTI_THREAD=$(Z_FEATURE_MULTI_THREAD) -DZ_FEATURE_INTEREST=$(Z_FEATURE_INTEREST) \
-DZ_FEATURE_MULTI_THREAD=$(Z_FEATURE_MULTI_THREAD) -DZ_FEATURE_INTEREST=$(Z_FEATURE_INTEREST) -DZ_FEATURE_UNSTABLE_API=$(Z_FEATURE_UNSTABLE_API)\
-DZ_FEATURE_PUBLICATION=$(Z_FEATURE_PUBLICATION) -DZ_FEATURE_SUBSCRIPTION=$(Z_FEATURE_SUBSCRIPTION) -DZ_FEATURE_QUERY=$(Z_FEATURE_QUERY) -DZ_FEATURE_QUERYABLE=$(Z_FEATURE_QUERYABLE)\
-DZ_FEATURE_RAWETH_TRANSPORT=$(Z_FEATURE_RAWETH_TRANSPORT) -DFRAG_MAX_SIZE=$(FRAG_MAX_SIZE) -DBATCH_UNICAST_SIZE=$(BATCH_UNICAST_SIZE) -DBATCH_MULTICAST_SIZE=$(BATCH_MULTICAST_SIZE)\
-DBUILD_INTEGRATION=$(BUILD_INTEGRATION) -DBUILD_TOOLS=$(BUILD_TOOLS) -DBUILD_SHARED_LIBS=$(BUILD_SHARED_LIBS) -H.
Expand Down
1 change: 1 addition & 0 deletions PackageConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
set(ZENOHPICO_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
set(CMAKE_SYSTEM_NAME @CMAKE_SYSTEM_NAME@)

set(ZENOHPICO_FEATURE_UNSTABLE_API @Z_FEATURE_UNSTABLE_API@)
set(ZENOHPICO_FEATURE_MULTI_THREAD @Z_FEATURE_MULTI_THREAD@)
set(ZENOHPICO_FEATURE_PUBLICATION @Z_FEATURE_PUBLICATION@)
set(ZENOHPICO_FEATURE_SUBSCRIPTION @Z_FEATURE_SUBSCRIPTION@)
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
language = 'c'
c_autodoc_roots = ['../include/zenoh-pico/api/']
c_autodoc_compilation_args = [
"-DZ_FEATURE_UNSTABLE_API=1",
"-DZ_FEATURE_PUBLICATION=1",
"-DZ_FEATURE_SUBSCRIPTION=1",
"-DZ_FEATURE_QUERY=1",
Expand Down
6 changes: 5 additions & 1 deletion include/zenoh-pico/api/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,14 @@ _Z_OWNED_TYPE_VALUE(_z_value_t, reply_err)
* Represents the configuration used to configure a subscriber upon declaration :c:func:`z_declare_subscriber`.
*
* Members:
* z_reliability_t reliability: The subscription reliability value.
* (unstable) z_reliability_t reliability: The subscription reliability value.
*/
typedef struct {
#ifdef Z_FEATURE_UNSTABLE_API
z_reliability_t reliability;
#else
uint8_t __dummy; // Just to avoid empty structures that might cause undefined behavior
#endif
} z_subscriber_options_t;

/**
Expand Down
12 changes: 11 additions & 1 deletion src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,13 @@ void _z_subscriber_drop(_z_subscriber_t *sub) { _z_undeclare_and_clear_subscribe
_Z_OWNED_FUNCTIONS_VALUE_NO_COPY_IMPL(_z_subscriber_t, subscriber, _z_subscriber_check, _z_subscriber_null,
_z_subscriber_drop)

void z_subscriber_options_default(z_subscriber_options_t *options) { options->reliability = Z_RELIABILITY_DEFAULT; }
void z_subscriber_options_default(z_subscriber_options_t *options) {
#if Z_FEATURE_UNSTABLE_API == 1
options->reliability = Z_RELIABILITY_DEFAULT;
#else
options->__dummy = 0;
#endif
}

int8_t z_declare_subscriber(z_owned_subscriber_t *sub, const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keyexpr,
z_moved_closure_sample_t *callback, const z_subscriber_options_t *options) {
Expand Down Expand Up @@ -1599,7 +1605,11 @@ int8_t z_declare_subscriber(z_owned_subscriber_t *sub, const z_loaned_session_t

_z_subinfo_t subinfo = _z_subinfo_default();
if (options != NULL) {
#if Z_FEATURE_UNSTABLE_API == 1
subinfo.reliability = options->reliability;
#else
subinfo.reliability = Z_RELIABILITY_DEFAULT;
#endif
}
_z_subscriber_t int_sub =
_z_declare_subscriber(zs, key, subinfo, callback->_this._val.call, callback->_this._val.drop, ctx);
Expand Down
2 changes: 1 addition & 1 deletion zenohpico.pc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ prefix=/usr/local
Name: zenohpico
Description:
URL:
Version: 1.0.20240819dev
Version: 1.0.20240822dev
Cflags: -I${prefix}/include
Libs: -L${prefix}/lib -lzenohpico

0 comments on commit df1dfc9

Please sign in to comment.