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

Fix compilation issues #431

Merged
merged 37 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d0b9d85
feat: remove deprecated files
jean-roland Jun 17, 2024
54b4f33
fix: library ignored unix compile options, issue #422
jean-roland Jun 17, 2024
1bf8ae0
fix: update deprecated syscalls
jean-roland Jun 17, 2024
28ab164
fix: previously ignored compilation errors
jean-roland Jun 17, 2024
6867b75
fix: bad function return type
jean-roland Jun 17, 2024
2ae914a
fix: cast strtoul return value
jean-roland Jun 17, 2024
0dd262b
fix: avoid mask instruction
jean-roland Jun 17, 2024
b036c95
fix: ptrdiff_t casting
jean-roland Jun 17, 2024
4682867
fix: unsigned constants
jean-roland Jun 17, 2024
a35f6ce
fix: ext size calculation
jean-roland Jun 17, 2024
bc24c04
fix: ext number calculation
jean-roland Jun 17, 2024
8632b8e
fix: internal int type casting
jean-roland Jun 17, 2024
3c58c51
fix: unix system type casting
jean-roland Jun 17, 2024
da6ebf1
chore: run clang
jean-roland Jun 17, 2024
42cd1d6
fix: windows compilation
jean-roland Jun 17, 2024
1666150
fix: usleep arg type cast
jean-roland Jun 18, 2024
61de711
fix: set lease factor as int
jean-roland Jun 18, 2024
91e1095
fix: lease substraction on unsigned type
jean-roland Jun 18, 2024
631699f
build: use debug config by default with cmake
jean-roland Jun 18, 2024
a73ef90
ci: switch tests to dev/1.0.0 zenoh branch
jean-roland Jun 18, 2024
d28d369
fix: missing end of file
jean-roland Jun 18, 2024
f62c8ed
fix: replace ssize_t
jean-roland Jun 18, 2024
d2ec628
fix: missing end of file newline
jean-roland Jun 18, 2024
c3c0c19
build: don't set -Wpedantic on unix c99
jean-roland Jun 18, 2024
ac6c8b0
fix: missing end of file newline
jean-roland Jun 18, 2024
6b19d5d
fix: bad function prototypes
jean-roland Jun 18, 2024
ab42c3f
fix: bad return function
jean-roland Jun 18, 2024
da18cd7
fix: bad function prototype
jean-roland Jun 18, 2024
c053fdc
fix: missing end of file newline
jean-roland Jun 18, 2024
325c795
fix: remove linux specific type cast
jean-roland Jun 18, 2024
2cf39a7
fix: raweth & single thread compilation issues
jean-roland Jun 18, 2024
764e375
fix: modularity compilation issues
jean-roland Jun 18, 2024
93a3b69
fix: raweth compilation issues
jean-roland Jun 18, 2024
e848b7d
fix: api test compiler issue
jean-roland Jun 18, 2024
4741963
fix: sub memory leak
jean-roland Jun 19, 2024
9c97908
fix: remove rebase shenanigans
jean-roland Jun 19, 2024
0b87c2b
fix: empty struct error
jean-roland Jun 20, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/build-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
uses: eclipse-zenoh/ci/build-crates-standalone@main
with:
repo: eclipse-zenoh/zenoh
branch: interests
branch: dev/1.0.0
artifact-patterns: |
^zenohd$
^libzenoh_plugin_rest.so$
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
BUILD_TESTING: OFF # Workaround for Windows as it seems the previous step is being ignored
BUILD_MULTICAST: OFF # Workaround for Windows as it seems the previous step is being ignored
BUILD_INTEGRATION: ON # Workaround for Windows as it seems the previous step is being ignored
ZENOH_BRANCH: interests
ZENOH_BRANCH: dev/1.0.0
2 changes: 1 addition & 1 deletion .github/workflows/multicast.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
BUILD_TESTING: OFF
BUILD_MULTICAST: ON
BUILD_INTEGRATION: OFF
ZENOH_BRANCH: interests
ZENOH_BRANCH: dev/1.0.0

- name: Test debug
run: make test
Expand Down
73 changes: 39 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,42 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Generic")
endif()
endif()

# Language options
if(NOT CMAKE_C_STANDARD)
if(c_std_11 IN_LIST CMAKE_C_COMPILE_FEATURES)
set(CMAKE_C_STANDARD 11)
message(STATUS "Setting C11 as the C Standard")
else()
# C99 pedantic doesn't like unix header anonymous structure
set(CMAKE_C_STANDARD 99)
message(STATUS "Setting C99 as the C Standard")
endif()
endif()
set(CMAKE_C_STANDARD_REQUIRED TRUE)

# Compile options
if(CMAKE_BUILD_TYPE MATCHES "RELEASE" OR "Release")
if(UNIX)
add_compile_options(-pipe -O3)
elseif(CMAKE_SYSTEM_NAME MATCHES "Generic")
add_compile_options(-pipe -O3)
endif()
else()
if(UNIX)
add_compile_options(-c -Wall -Wextra -Werror -Wshadow -Wunused -Wstrict-prototypes -pipe -g -O0)
# C99 pedantic doesn't like struct anonymous in unix header
if (NOT CMAKE_C_STANDARD STREQUAL "99")
add_compile_options(-Wpedantic)
endif()
# add_compile_options(-Wconversion)
# add_link_options(-fsanitize=address)
elseif(MSVC)
add_compile_options(/W4 /WX /Od /wd4127)
elseif(CMAKE_SYSTEM_NAME MATCHES "Generic")
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes -pipe -g -O0)
endif()
endif()

set(Libname "zenohpico")
if(BUILD_SHARED_LIBS)
add_library(${Libname} SHARED)
Expand All @@ -50,16 +86,6 @@ function(add_definition value)
target_compile_definitions(${Libname} PUBLIC ${value})
endfunction()

if(NOT CMAKE_C_STANDARD)
if(c_std_11 IN_LIST CMAKE_C_COMPILE_FEATURES)
set(CMAKE_C_STANDARD 11)
message(STATUS "Setting C11 as the C Standard")
else()
set(CMAKE_C_STANDARD 99)
message(STATUS "Setting C99 as the C Standard")
endif()
endif()
set(CMAKE_C_STANDARD_REQUIRED TRUE)
add_definition(ZENOH_C_STANDARD=${CMAKE_C_STANDARD})

# while in development, use timestamp for patch version:
Expand Down Expand Up @@ -175,31 +201,11 @@ if(CHECK_THREADS)
find_package(Threads REQUIRED)
endif()

if(CMAKE_BUILD_TYPE MATCHES "DEBUG")
if(UNIX)
# FIXME: seems to not apply to library files, Issue #422
add_compile_options(-c -Wall -Wextra -Werror -Wshadow -Wpedantic -Wunused -Wstrict-prototypes -pipe -g -O0)
# add_compile_options(-Wconversion)
# add_link_options(-fsanitize=address)
elseif(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /std:c11 /experimental:c11atomics")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest /experimental:c11atomics")
add_compile_options(/W4 /WX /Od /wd4127)
elseif(CMAKE_SYSTEM_NAME MATCHES "Generic")
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes -pipe -g -O0)
endif()
elseif(CMAKE_BUILD_TYPE MATCHES "RELEASE")
if(UNIX)
add_compile_options(-pipe -O3)
elseif(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /std:c11 /experimental:c11atomics")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest /experimental:c11atomics")
elseif(CMAKE_SYSTEM_NAME MATCHES "Generic")
add_compile_options(-pipe -O3)
endif()
if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /std:c11 /experimental:c11atomics")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest /experimental:c11atomics")
endif()


file(GLOB_RECURSE PublicHeaders
"include/zenoh-pico/api/*.h"
"include/zenoh-pico/collections/*.h"
Expand All @@ -216,7 +222,6 @@ target_include_directories(${Libname} PUBLIC ${PROJECT_SOURCE_DIR}/include)
file(GLOB_RECURSE Sources
"src/api/*.c"
"src/collections/*.c"
"src/deprecated/*.c"
"src/link/*.c"
"src/net/*.c"
"src/protocol/*.c"
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ int main(int argc, char **argv) {
z_drop(z_move(sample));
}
printf(">> [Subscriber] Nothing to pull... sleep for %zu ms\n", interval);
zp_sleep_ms(interval);
z_sleep_ms(interval);
}

z_undeclare_subscriber(z_move(sub));
Expand Down
28 changes: 15 additions & 13 deletions include/zenoh-pico/api/handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
\
static inline void _z_##handler_name##_elem_free(void **elem) { \
elem_drop_f((elem_owned_type *)*elem); \
zp_free(*elem); \
z_free(*elem); \
*elem = NULL; \
} \
static inline void _z_##handler_name##_elem_move(void *dst, void *src) { \
memcpy(dst, src, sizeof(elem_owned_type)); \
zp_free(src); \
z_free(src); \
} \
static inline void _z_##handler_name##_send(const elem_loaned_type *elem, void *context) { \
elem_owned_type *internal_elem = (elem_owned_type *)zp_malloc(sizeof(elem_owned_type)); \
elem_owned_type *internal_elem = (elem_owned_type *)z_malloc(sizeof(elem_owned_type)); \
if (internal_elem == NULL) { \
_Z_ERROR("Out of memory"); \
return; \
Expand Down Expand Up @@ -115,16 +115,18 @@
/* elem_copy_f */ _z_##item_name##_rc_copy, \
/* elem_drop_f */ z_##item_name##_drop)

#define _Z_CHANNEL_DEFINE_DUMMY(item_name, kind_name) \
typedef struct { \
} z_owned_##kind_name##_handler_##item_name##_t; \
typedef struct { \
} z_loaned_##kind_name##_handler_##item_name##_t; \
void *z_##kind_name##_handler_##item_name##_loan(); \
void *z_##kind_name##_handler_##item_name##_move(); \
void *z_##kind_name##_handler_##item_name##_drop(); \
void *z_##kind_name##_handler_##item_name##_recv(); \
void *z_##kind_name##_handler_##item_name##_try_recv();
#define _Z_CHANNEL_DEFINE_DUMMY(item_name, kind_name) \
typedef struct { \
uint8_t _foo; \
} z_owned_##kind_name##_handler_##item_name##_t; \
typedef struct { \
uint8_t _foo; \
} z_loaned_##kind_name##_handler_##item_name##_t; \
void *z_##kind_name##_handler_##item_name##_loan(void); \
void *z_##kind_name##_handler_##item_name##_move(void); \
void *z_##kind_name##_handler_##item_name##_drop(void); \
void *z_##kind_name##_handler_##item_name##_recv(void); \
void *z_##kind_name##_handler_##item_name##_try_recv(void);

// This macro defines:
// z_ring_channel_sample_new()
Expand Down
6 changes: 3 additions & 3 deletions include/zenoh-pico/collections/fifo_mt.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
typedef struct {
_z_fifo_t _fifo;
#if Z_FEATURE_MULTI_THREAD == 1
zp_mutex_t _mutex;
zp_condvar_t _cv_not_full;
zp_condvar_t _cv_not_empty;
z_mutex_t _mutex;
z_condvar_t _cv_not_full;
z_condvar_t _cv_not_empty;
#endif
} _z_fifo_mt_t;

Expand Down
4 changes: 2 additions & 2 deletions include/zenoh-pico/collections/ring_mt.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
typedef struct {
_z_ring_t _ring;
#if Z_FEATURE_MULTI_THREAD == 1
zp_mutex_t _mutex;
zp_condvar_t _cv_not_empty;
z_mutex_t _mutex;
z_condvar_t _cv_not_empty;
#endif
} _z_ring_mt_t;

Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
* Default session lease expire factor.
*/
#ifndef Z_TRANSPORT_LEASE_EXPIRE_FACTOR
#define Z_TRANSPORT_LEASE_EXPIRE_FACTOR 3.5
#define Z_TRANSPORT_LEASE_EXPIRE_FACTOR 3
#endif

/**
Expand Down
88 changes: 0 additions & 88 deletions include/zenoh-pico/deprecated/platform.h

This file was deleted.

2 changes: 1 addition & 1 deletion include/zenoh-pico/link/config/bt.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ int8_t _z_bt_config_from_str(_z_str_intmap_t *strint, const char *s);
int8_t _z_bt_config_from_strn(_z_str_intmap_t *strint, const char *s, size_t n);
#endif

#endif /* ZENOH_PICO_LINK_CONFIG_BT_H */
#endif /* ZENOH_PICO_LINK_CONFIG_BT_H */
2 changes: 1 addition & 1 deletion include/zenoh-pico/link/config/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ int8_t _z_serial_config_from_str(_z_str_intmap_t *strint, const char *s);
int8_t _z_serial_config_from_strn(_z_str_intmap_t *strint, const char *s, size_t n);
#endif

#endif /* ZENOH_PICO_LINK_CONFIG_SERIAL_H */
#endif /* ZENOH_PICO_LINK_CONFIG_SERIAL_H */
2 changes: 1 addition & 1 deletion include/zenoh-pico/protocol/definitions/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
#define _Z_FLAGS(h) (_Z_FLAGS_MASK & (h))
#define _Z_HAS_FLAG(h, f) (((h) & (f)) != 0)
#define _Z_SET_FLAG(h, f) (h |= f)
#define _Z_CLEAR_FLAG(h, f) (h &= ~(f))
#define _Z_CLEAR_FLAG(h, f) (h &= (uint8_t)(~(f)))

#endif /* INCLUDE_ZENOH_PICO_PROTOCOL_DEFINITIONS_CORE_H */
2 changes: 1 addition & 1 deletion include/zenoh-pico/session/push.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@

int8_t _z_trigger_push(_z_session_t *zn, _z_n_msg_push_t *push);

#endif /* ZENOH_PICO_SESSION_PUSH_H */
#endif /* ZENOH_PICO_SESSION_PUSH_H */
2 changes: 1 addition & 1 deletion include/zenoh-pico/session/reply.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ int8_t _z_trigger_reply_partial(_z_session_t *zn, _z_zint_t id, _z_keyexpr_t key

int8_t _z_trigger_reply_final(_z_session_t *zn, _z_n_msg_response_final_t *final);

#endif /* ZENOH_PICO_SESSION_REPLY_H */
#endif /* ZENOH_PICO_SESSION_REPLY_H */
2 changes: 1 addition & 1 deletion include/zenoh-pico/session/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ uint16_t _z_get_resource_id(_z_session_t *zn);
_z_resource_t *_z_get_resource_by_id(_z_session_t *zn, uint16_t mapping, _z_zint_t rid);
_z_resource_t *_z_get_resource_by_key(_z_session_t *zn, const _z_keyexpr_t *keyexpr);
_z_keyexpr_t _z_get_expanded_key_from_key(_z_session_t *zn, const _z_keyexpr_t *keyexpr);
int16_t _z_register_resource(_z_session_t *zn, const _z_keyexpr_t key, uint16_t id, uint16_t register_to_mapping);
uint16_t _z_register_resource(_z_session_t *zn, const _z_keyexpr_t key, uint16_t id, uint16_t register_to_mapping);
void _z_unregister_resource(_z_session_t *zn, uint16_t id, uint16_t mapping);
void _z_unregister_resources_for_peer(_z_session_t *zn, uint16_t mapping);
void _z_flush_resources(_z_session_t *zn);
Expand Down
4 changes: 2 additions & 2 deletions include/zenoh-pico/system/link/raweth.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ size_t _z_send_raweth(const _z_sys_net_socket_t *sock, const void *buff, size_t
size_t _z_receive_raweth(const _z_sys_net_socket_t *sock, void *buff, size_t buff_len, _z_slice_t *addr,
const _zp_raweth_whitelist_array_t *whitelist);
int8_t _z_close_raweth(_z_sys_net_socket_t *sock);
size_t _z_raweth_ntohs(size_t val);
size_t _z_raweth_htons(size_t val);
uint16_t _z_raweth_ntohs(uint16_t val);
uint16_t _z_raweth_htons(uint16_t val);

#endif

Expand Down
1 change: 0 additions & 1 deletion include/zenoh-pico/system/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <stdint.h>

#include "zenoh-pico/config.h"
#include "zenoh-pico/deprecated/platform.h"
#include "zenoh-pico/system/platform-common.h"

#endif /* ZENOH_PICO_SYSTEM_PLATFORM_H */
Loading
Loading