From 62803782ba88cc580a75560bd63280d8ad877554 Mon Sep 17 00:00:00 2001 From: Siddharth Chandrasekaran Date: Tue, 20 Feb 2024 01:51:33 +0100 Subject: [PATCH] libosdp: Add support for windows builds For rust and python modules, we need to target windows as a first class citizen. Although we don't have any active users in those platforms ATM, it would still be a nice to have. Signed-off-by: Siddharth Chandrasekaran --- src/osdp_common.c | 2 -- src/osdp_common.h | 7 ++++--- src/osdp_file.h | 10 +++++----- src/osdp_phy.c | 4 ++-- utils | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/osdp_common.c b/src/osdp_common.c index 5b669906..02aca6f8 100644 --- a/src/osdp_common.c +++ b/src/osdp_common.c @@ -6,9 +6,7 @@ #include #include #ifndef CONFIG_DISABLE_PRETTY_LOGGING -#include #endif -#include #include "osdp_common.h" diff --git a/src/osdp_common.h b/src/osdp_common.h index 9ad72c6c..04405411 100644 --- a/src/osdp_common.h +++ b/src/osdp_common.h @@ -73,10 +73,10 @@ #define osdp_dump hexdump // for zephyr compatibility. -static inline __attribute__((noreturn)) void die() +static inline __noreturn void die() { exit(EXIT_FAILURE); - __builtin_unreachable(); + __unreachable(); } #define BUG() \ @@ -447,7 +447,8 @@ static inline int get_tx_buf_size(struct osdp_pd *pd) int packet_buf_size = sizeof(pd->packet_buf); if (pd->peer_rx_size) { - packet_buf_size = MIN(packet_buf_size, (int)pd->peer_rx_size); + if (packet_buf_size > (int)pd->peer_rx_size) + packet_buf_size = (int)pd->peer_rx_size; } return packet_buf_size; } diff --git a/src/osdp_file.h b/src/osdp_file.h index 64863745..a2e74df8 100644 --- a/src/osdp_file.h +++ b/src/osdp_file.h @@ -27,13 +27,13 @@ * @param length Length of data section in this command. * @param data File contents. Variable length */ -struct osdp_cmd_file_xfer { +PACK(struct osdp_cmd_file_xfer { uint8_t type; uint32_t size; uint32_t offset; uint16_t length; uint8_t data[]; -} __packed; +}); /** * @brief OSDP specified command: File Transfer Stat: @@ -57,12 +57,12 @@ struct osdp_cmd_file_xfer { * @param rx_size Alternate maximum message size for CMD_FILETRANSFER. If set to * 0 then no change requested, otherwise use this value */ -struct osdp_cmd_file_stat { +PACK(struct osdp_cmd_file_stat { uint8_t control; uint16_t delay; int16_t status; uint16_t rx_size; -} __packed; +}); enum file_tx_state_e { OSDP_FILE_IDLE, @@ -90,4 +90,4 @@ int osdp_file_tx_command(struct osdp_pd *pd, int file_id, uint32_t flags); int osdp_get_file_tx_state(struct osdp_pd *pd); void osdp_file_tx_abort(struct osdp_pd *pd); -#endif /* _OSDP_FILE_H_ */ \ No newline at end of file +#endif /* _OSDP_FILE_H_ */ diff --git a/src/osdp_phy.c b/src/osdp_phy.c index ff178d6d..8125a5a8 100644 --- a/src/osdp_phy.c +++ b/src/osdp_phy.c @@ -13,14 +13,14 @@ #define PKT_CONTROL_SCB 0x08 #define PKT_TRACE_MANGLED 0x80 -struct osdp_packet_header { +PACK(struct osdp_packet_header { uint8_t som; uint8_t pd_address; uint8_t len_lsb; uint8_t len_msb; uint8_t control; uint8_t data[]; -} __packed; +}); static inline bool packet_has_mark(struct osdp_pd *pd) { diff --git a/utils b/utils index 06259c43..43f63d6c 160000 --- a/utils +++ b/utils @@ -1 +1 @@ -Subproject commit 06259c43d08c699ca5245ac52382d98fd3374394 +Subproject commit 43f63d6c0a2d053227e187781e33523be16404d7