From 7ff738390e55d57a0f513c467a9da3b08c6902ab Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Tue, 29 Oct 2024 01:02:02 -0600 Subject: Add a way to make private object members --- libhw/host_include/libhw/host_net.h | 8 ++++++++ libhw/host_net.c | 2 ++ libhw/rp2040_hwspi.c | 1 + libhw/rp2040_include/libhw/rp2040_hwspi.h | 4 ++++ libhw/rp2040_include/libhw/w5500.h | 7 +++++++ libhw/w5500.c | 1 + 6 files changed, 23 insertions(+) (limited to 'libhw') diff --git a/libhw/host_include/libhw/host_net.h b/libhw/host_include/libhw/host_net.h index 1b1ba7a..bfef5c9 100644 --- a/libhw/host_include/libhw/host_net.h +++ b/libhw/host_include/libhw/host_net.h @@ -9,20 +9,26 @@ #include /* for uint16_6 */ +#include + #include struct _hostnet_tcp_conn { implements_net_stream_conn; + BEGIN_PRIVATE(LIBHW_HOST_NET_H) int fd; uint64_t read_deadline_ns; + END_PRIVATE(LIBHW_HOST_NET_H) }; struct hostnet_tcp_listener { implements_net_stream_listener; + BEGIN_PRIVATE(LIBHW_HOST_NET_H) int fd; struct _hostnet_tcp_conn active_conn; + END_PRIVATE(LIBHW_HOST_NET_H) }; void hostnet_tcp_listener_init(struct hostnet_tcp_listener *self, uint16_t port); @@ -30,8 +36,10 @@ void hostnet_tcp_listener_init(struct hostnet_tcp_listener *self, uint16_t port) struct hostnet_udp_conn { implements_net_packet_conn; + BEGIN_PRIVATE(LIBHW_HOST_NET_H) int fd; uint64_t read_deadline_ns; + END_PRIVATE(LIBHW_HOST_NET_H) }; void hostnet_udp_conn_init(struct hostnet_udp_conn *self, uint16_t port); diff --git a/libhw/host_net.c b/libhw/host_net.c index 1563ced..904019a 100644 --- a/libhw/host_net.c +++ b/libhw/host_net.c @@ -23,6 +23,8 @@ #include #include + +#define IMPLEMENTATION_FOR_LIBHW_HOST_NET_H YES #include /* common *********************************************************************/ diff --git a/libhw/rp2040_hwspi.c b/libhw/rp2040_hwspi.c index 96c3d14..b4adeb7 100644 --- a/libhw/rp2040_hwspi.c +++ b/libhw/rp2040_hwspi.c @@ -12,6 +12,7 @@ #include +#define IMPLEMENTATION_FOR_LIBHW_RP2040_HWSPI_H YES #include static void rp2040_hwspi_readwritev(implements_spi *, const struct bidi_iovec *iov, int iovcnt); diff --git a/libhw/rp2040_include/libhw/rp2040_hwspi.h b/libhw/rp2040_include/libhw/rp2040_hwspi.h index db8285d..8d90dbb 100644 --- a/libhw/rp2040_include/libhw/rp2040_hwspi.h +++ b/libhw/rp2040_include/libhw/rp2040_hwspi.h @@ -10,6 +10,8 @@ #include /* for bi_* */ +#include + #include enum rp2040_hwspi_instance { @@ -20,8 +22,10 @@ enum rp2040_hwspi_instance { struct rp2040_hwspi { implements_spi; + BEGIN_PRIVATE(LIBHW_RP2040_HWSPI_H) void /*spi_inst_t*/ *inst; uint pin_cs; + END_PRIVATE(LIBHW_RP2040_HWSPI_H) }; /** diff --git a/libhw/rp2040_include/libhw/w5500.h b/libhw/rp2040_include/libhw/w5500.h index 6f12c39..037d4f1 100644 --- a/libhw/rp2040_include/libhw/w5500.h +++ b/libhw/rp2040_include/libhw/w5500.h @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -17,13 +18,16 @@ struct _w5500_tcp_conn { /* const-after-init */ implements_net_stream_conn; /* mutable */ + BEGIN_PRIVATE(LIBHW_W5500_H) bool read_open; bool write_open; + END_PRIVATE(LIBHW_W5500_H) }; struct _w5500_tcp_listener { /* const-after-init */ implements_net_stream_listener; + BEGIN_PRIVATE(LIBHW_W5500_H) uint8_t socknum; struct _w5500_tcp_conn active_conn; @@ -31,11 +35,13 @@ struct _w5500_tcp_listener { uint16_t port; cr_mutex_t cmd_mu; cr_sema_t listen_sema, read_sema; + END_PRIVATE(LIBHW_W5500_H) }; struct w5500 { /* const-after-init */ implements_spi *spidev; + BEGIN_PRIVATE(LIBHW_W5500_H) uint pin_intr; uint pin_reset; struct net_eth_addr hwaddr; @@ -44,6 +50,7 @@ struct w5500 { uint16_t next_local_port; struct _w5500_tcp_listener listeners[8]; cr_sema_t intr; + END_PRIVATE(LIBHW_W5500_H) }; /** diff --git a/libhw/w5500.c b/libhw/w5500.c index a141fb3..0d9cd01 100644 --- a/libhw/w5500.c +++ b/libhw/w5500.c @@ -73,6 +73,7 @@ #include /* for cr_yield() */ #include /* for VCALL_SELF() */ +#define IMPLEMENTATION_FOR_LIBHW_W5500_H YES #include #include "w5500_ll.h" -- cgit v1.2.3-2-g168b