Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
serges147 committed Dec 18, 2024
1 parent 192a3a8 commit 0627e4e
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 97 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
sudo apt-get -y install gcc-multilib g++-multilib clang-tidy-$LLVM_VERSION
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-$LLVM_VERSION 50
clang-tidy --version
- run: >
- run: |
cmake --preset OCVSMD-Debian
cmake --build --preset OCVSMD-Debian-Debug -DCMAKE_CXX_COMPILER=${{ matrix.cxx-compiler }}
- uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
- run: |
sudo apt update -y && sudo apt upgrade -y
sudo apt install gcc-multilib g++-multilib
- run: >
- run: |
cmake --preset OCVSMD-Debian
cmake --build --preset OCVSMD-Debian-Release -DCMAKE_CXX_COMPILER=${{ matrix.cxx-compiler }}
- uses: actions/upload-artifact@v4
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ find_program(clang_format NAMES clang-format)
if (NOT clang_format)
message(STATUS "Could not locate clang-format")
else ()
file(GLOB_RECURSE format_files ${include_dir}/**/*.[ch]pp ${src_dir}/**/*.[ch]pp ${test_dir}/**/*.[ch]pp)
file(GLOB_RECURSE format_files
${include_dir}/**/*.[ch]pp
${src_dir}/**/*.[ch]
${src_dir}/**/*.[ch]pp
${test_dir}/**/*.[ch]pp
)
message(STATUS "Using clang-format: ${clang_format}")
add_custom_target(format COMMAND ${clang_format} -i -fallback-style=none -style=file --verbose ${format_files})
endif ()
Expand Down
40 changes: 20 additions & 20 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": 7,
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 27,
"minor": 25,
"patch": 0
},
"configurePresets": [
Expand Down Expand Up @@ -76,20 +76,10 @@
],
"buildPresets": [
{
"name": "OCVSMD-Darwin-Release",
"displayName": "Darwin Linux OCVSMD (Release)",
"description": "Builds OCVSMD for MacOS",
"configurePreset": "OCVSMD-Darwin",
"configuration": "Release",
"targets": [
"ocvsmd"
]
},
{
"name": "OCVSMD-Darwin-Debug",
"displayName": "Darwin Linux OCVSMD (Debug)",
"description": "Builds OCVSMD for MacOS",
"configurePreset": "OCVSMD-Darwin",
"name": "OCVSMD-Debian-Debug",
"displayName": "Debian Linux OCVSMD (Debug)",
"description": "Builds OCVSMD for Debian Linux distributions",
"configurePreset": "OCVSMD-Debian",
"configuration": "Debug",
"targets": [
"ocvsmd"
Expand All @@ -106,14 +96,24 @@
]
},
{
"name": "OCVSMD-Debian-Debug",
"displayName": "Debian Linux OCVSMD (Debug)",
"description": "Builds OCVSMD for Debian Linux distributions",
"configurePreset": "OCVSMD-Debian",
"name": "OCVSMD-Darwin-Debug",
"displayName": "Darwin Linux OCVSMD (Debug)",
"description": "Builds OCVSMD for MacOS",
"configurePreset": "OCVSMD-Darwin",
"configuration": "Debug",
"targets": [
"ocvsmd"
]
},
{
"name": "OCVSMD-Darwin-Release",
"displayName": "Darwin Linux OCVSMD (Release)",
"description": "Builds OCVSMD for MacOS",
"configurePreset": "OCVSMD-Darwin",
"configuration": "Release",
"targets": [
"ocvsmd"
]
}
]
}
147 changes: 74 additions & 73 deletions src/daemon/engine/platform/udp/udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,90 +28,91 @@
#include <stddef.h>

#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif

/// These definitions are highly platform-specific.
/// Note that LibUDPard does not require the same socket to be usable for both transmission and reception.
typedef struct
{
int fd;
} UDPTxHandle;
typedef struct
{
int fd;
} UDPRxHandle;
/// These definitions are highly platform-specific.
/// Note that LibUDPard does not require the same socket to be usable for both transmission and reception.
typedef struct
{
int fd;
} UDPTxHandle;
typedef struct
{
int fd;
} UDPRxHandle;

/// Initialize a TX socket for use with LibUDPard.
/// The local iface address is used to specify the egress interface for multicast traffic.
/// Per LibUDPard design, there is one TX socket per redundant interface, so the application needs to invoke
/// this function once per interface.
/// On error returns a negative error code.
int16_t udpTxInit(UDPTxHandle* const self, const uint32_t local_iface_address);
/// Initialize a TX socket for use with LibUDPard.
/// The local iface address is used to specify the egress interface for multicast traffic.
/// Per LibUDPard design, there is one TX socket per redundant interface, so the application needs to invoke
/// this function once per interface.
/// On error returns a negative error code.
int16_t udpTxInit(UDPTxHandle* const self, const uint32_t local_iface_address);

/// Send a datagram to the specified endpoint without blocking using the specified IP DSCP field value.
/// A real-time embedded system should normally accept a transmission deadline here for the networking stack.
/// Returns 1 on success, 0 if the socket is not ready for sending, or a negative error code.
int16_t udpTxSend(UDPTxHandle* const self,
const uint32_t remote_address,
const uint16_t remote_port,
const uint8_t dscp,
const size_t payload_size,
const void* const payload);
/// Send a datagram to the specified endpoint without blocking using the specified IP DSCP field value.
/// A real-time embedded system should normally accept a transmission deadline here for the networking stack.
/// Returns 1 on success, 0 if the socket is not ready for sending, or a negative error code.
int16_t udpTxSend(UDPTxHandle* const self,
const uint32_t remote_address,
const uint16_t remote_port,
const uint8_t dscp,
const size_t payload_size,
const void* const payload);

/// No effect if the argument is invalid.
/// This function is guaranteed to invalidate the handle.
void udpTxClose(UDPTxHandle* const self);
/// No effect if the argument is invalid.
/// This function is guaranteed to invalidate the handle.
void udpTxClose(UDPTxHandle* const self);

/// Initialize an RX socket for use with LibUDPard, for subscription to subjects or for RPC traffic.
/// The socket will be bound to the specified multicast group and port.
/// Most socket APIs, in particular the Berkeley sockets, require the local iface address to be known,
/// because it is used to decide which egress port to send IGMP membership reports over.
/// On error returns a negative error code.
int16_t udpRxInit(UDPRxHandle* const self,
const uint32_t local_iface_address,
const uint32_t multicast_group,
const uint16_t remote_port);
/// Initialize an RX socket for use with LibUDPard, for subscription to subjects or for RPC traffic.
/// The socket will be bound to the specified multicast group and port.
/// Most socket APIs, in particular the Berkeley sockets, require the local iface address to be known,
/// because it is used to decide which egress port to send IGMP membership reports over.
/// On error returns a negative error code.
int16_t udpRxInit(UDPRxHandle* const self,
const uint32_t local_iface_address,
const uint32_t multicast_group,
const uint16_t remote_port);

/// Read one datagram from the socket without blocking.
/// The size of the destination buffer is specified in inout_payload_size; it is updated to the actual size of the
/// received datagram upon return.
/// Returns 1 on success, 0 if the socket is not ready for reading, or a negative error code.
int16_t udpRxReceive(UDPRxHandle* const self, size_t* const inout_payload_size, void* const out_payload);
/// Read one datagram from the socket without blocking.
/// The size of the destination buffer is specified in inout_payload_size; it is updated to the actual size of the
/// received datagram upon return.
/// Returns 1 on success, 0 if the socket is not ready for reading, or a negative error code.
int16_t udpRxReceive(UDPRxHandle* const self, size_t* const inout_payload_size, void* const out_payload);

/// No effect if the argument is invalid.
/// This function is guaranteed to invalidate the handle.
void udpRxClose(UDPRxHandle* const self);
/// No effect if the argument is invalid.
/// This function is guaranteed to invalidate the handle.
void udpRxClose(UDPRxHandle* const self);

/// Auxiliary types for use with the I/O multiplexing function.
/// The "ready" flag is updated to indicate whether the handle is ready for I/O.
/// The "user_*" fields can be used for user-defined purposes.
typedef struct
{
UDPTxHandle* handle;
bool ready;
void* user_reference;
} UDPTxAwaitable;
typedef struct
{
UDPRxHandle* handle;
bool ready;
void* user_reference;
} UDPRxAwaitable;
/// Auxiliary types for use with the I/O multiplexing function.
/// The "ready" flag is updated to indicate whether the handle is ready for I/O.
/// The "user_*" fields can be used for user-defined purposes.
typedef struct
{
UDPTxHandle* handle;
bool ready;
void* user_reference;
} UDPTxAwaitable;
typedef struct
{
UDPRxHandle* handle;
bool ready;
void* user_reference;
} UDPRxAwaitable;

/// Suspend execution until the expiration of the timeout (in microseconds) or until any of the specified handles
/// become ready for reading (the RX group) or writing (the TX group).
/// The function may return earlier than the timeout even if no handles are ready.
/// On error returns a negative error code.
int16_t udpWait(const uint64_t timeout_usec,
const size_t tx_count,
UDPTxAwaitable* const tx,
const size_t rx_count,
UDPRxAwaitable* const rx);
/// Suspend execution until the expiration of the timeout (in microseconds) or until any of the specified handles
/// become ready for reading (the RX group) or writing (the TX group).
/// The function may return earlier than the timeout even if no handles are ready.
/// On error returns a negative error code.
int16_t udpWait(const uint64_t timeout_usec,
const size_t tx_count,
UDPTxAwaitable* const tx,
const size_t rx_count,
UDPRxAwaitable* const rx);

/// Convert an interface address from string to binary representation; e.g., "127.0.0.1" --> 0x7F000001.
/// Returns zero if the address is not recognized.
uint32_t udpParseIfaceAddress(const char* const address);
/// Convert an interface address from string to binary representation; e.g., "127.0.0.1" --> 0x7F000001.
/// Returns zero if the address is not recognized.
uint32_t udpParseIfaceAddress(const char* const address);

#ifdef __cplusplus
}
Expand Down

0 comments on commit 0627e4e

Please sign in to comment.