From a71262437d867f9c2c30872f8693cb396393c37d Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Sun, 12 Jun 2022 12:43:01 +0100 Subject: [PATCH] Use mip for arm and riscv targets --- Makefile | 6 ++++-- mip/mip.c | 14 +++++++++++--- mongoose.c | 14 +++++++++++--- test/unit_test.c | 3 +-- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 9f806039..08db3470 100644 --- a/Makefile +++ b/Makefile @@ -100,11 +100,13 @@ valgrind: valgrind_unit_test infer: infer run -- cc test/unit_test.c -c -W -Wall -Werror -Isrc -I. -O2 -DMG_ENABLE_MBEDTLS=1 -DMG_ENABLE_LINES -I/usr/local/Cellar/mbedtls/2.23.0/include -DMG_ENABLE_IPV6=1 -g -o /dev/null +arm: DEFS += -DMG_ENABLE_FILE=0 -DMG_ENABLE_MIP=1 -DMG_ARCH=MG_ARCH_NEWLIB arm: mongoose.h $(SRCS) - $(DOCKER) mdashnet/armgcc arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb $(SRCS) test/mongoose_custom.c -Itest -DMG_ARCH=MG_ARCH_NEWLIB $(OPTS) $(WARN) $(INCS) $(DEFS) -o unit_test -nostartfiles --specs nosys.specs -e 0 + $(DOCKER) mdashnet/armgcc arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb $(SRCS) $(OPTS) $(WARN) $(INCS) $(DEFS) $(TFLAGS) -o unit_test -nostartfiles --specs nosys.specs -e 0 +riscv: DEFS += -DMG_ENABLE_FILE=0 -DMG_ENABLE_MIP=1 -DMG_ARCH=MG_ARCH_NEWLIB riscv: mongoose.h $(SRCS) - $(DOCKER) mdashnet/riscv riscv-none-elf-gcc -march=rv32imc -mabi=ilp32 $(SRCS) test/mongoose_custom.c -Itest -DMG_ARCH=MG_ARCH_NEWLIB $(OPTS) $(WARN) $(INCS) $(DEFS) -o unit_test + $(DOCKER) mdashnet/riscv riscv-none-elf-gcc -march=rv32imc -mabi=ilp32 $(SRCS) $(OPTS) $(WARN) $(INCS) $(DEFS) $(TFLAGS) -o unit_test #vc98: VCFLAGS += -DMG_ENABLE_IPV6=1 vc98: Makefile mongoose.h $(SRCS) diff --git a/mip/mip.c b/mip/mip.c index ce28beb9..3b3d20ff 100644 --- a/mip/mip.c +++ b/mip/mip.c @@ -316,8 +316,9 @@ static struct ip *tx_ip(struct mip_if *ifp, uint8_t proto, uint32_t ip_src, return ip; } -void tx_udp(struct mip_if *ifp, uint32_t ip_src, uint16_t sport, - uint32_t ip_dst, uint16_t dport, const void *buf, size_t len) { +static void tx_udp(struct mip_if *ifp, uint32_t ip_src, uint16_t sport, + uint32_t ip_dst, uint16_t dport, const void *buf, + size_t len) { struct ip *ip = tx_ip(ifp, 17, ip_src, ip_dst, len + sizeof(struct udp)); struct udp *udp = (struct udp *) (ip + 1); udp->sport = sport; @@ -438,7 +439,8 @@ static void rx_dhcp(struct mip_if *ifp, struct pkt *pkt) { } } -struct mg_connection *getpeer(struct mg_mgr *mgr, struct pkt *pkt, bool lsn) { +static struct mg_connection *getpeer(struct mg_mgr *mgr, struct pkt *pkt, + bool lsn) { struct mg_connection *c = NULL; for (c = mgr->conns; c != NULL; c = c->next) { if (c->is_udp && pkt->udp && c->loc.port == pkt->udp->dport) break; @@ -721,6 +723,12 @@ void mip_init(struct mg_mgr *mgr, struct mip_ipcfg *ipcfg, mgr->extraconnsize = sizeof(struct tcpstate); } +int mg_mkpipe(struct mg_mgr *m, mg_event_handler_t fn, void *d, bool udp) { + (void) m, (void) fn, (void) d, (void) udp; + MG_ERROR(("Not implemented")); + return -1; +} + void mg_connect_resolved(struct mg_connection *c) { struct mip_if *ifp = (struct mip_if *) c->mgr->priv; if (ifp->eport < MIP_ETHEMERAL_PORT) ifp->eport = MIP_ETHEMERAL_PORT; diff --git a/mongoose.c b/mongoose.c index 34464e23..3166d908 100644 --- a/mongoose.c +++ b/mongoose.c @@ -6096,8 +6096,9 @@ static struct ip *tx_ip(struct mip_if *ifp, uint8_t proto, uint32_t ip_src, return ip; } -void tx_udp(struct mip_if *ifp, uint32_t ip_src, uint16_t sport, - uint32_t ip_dst, uint16_t dport, const void *buf, size_t len) { +static void tx_udp(struct mip_if *ifp, uint32_t ip_src, uint16_t sport, + uint32_t ip_dst, uint16_t dport, const void *buf, + size_t len) { struct ip *ip = tx_ip(ifp, 17, ip_src, ip_dst, len + sizeof(struct udp)); struct udp *udp = (struct udp *) (ip + 1); udp->sport = sport; @@ -6218,7 +6219,8 @@ static void rx_dhcp(struct mip_if *ifp, struct pkt *pkt) { } } -struct mg_connection *getpeer(struct mg_mgr *mgr, struct pkt *pkt, bool lsn) { +static struct mg_connection *getpeer(struct mg_mgr *mgr, struct pkt *pkt, + bool lsn) { struct mg_connection *c = NULL; for (c = mgr->conns; c != NULL; c = c->next) { if (c->is_udp && pkt->udp && c->loc.port == pkt->udp->dport) break; @@ -6501,6 +6503,12 @@ void mip_init(struct mg_mgr *mgr, struct mip_ipcfg *ipcfg, mgr->extraconnsize = sizeof(struct tcpstate); } +int mg_mkpipe(struct mg_mgr *m, mg_event_handler_t fn, void *d, bool udp) { + (void) m, (void) fn, (void) d, (void) udp; + MG_ERROR(("Not implemented")); + return -1; +} + void mg_connect_resolved(struct mg_connection *c) { struct mip_if *ifp = (struct mip_if *) c->mgr->priv; if (ifp->eport < MIP_ETHEMERAL_PORT) ifp->eport = MIP_ETHEMERAL_PORT; diff --git a/test/unit_test.c b/test/unit_test.c index 25e5075f..8e4b02d5 100644 --- a/test/unit_test.c +++ b/test/unit_test.c @@ -9,7 +9,7 @@ static int s_num_tests = 0; s_num_tests++; \ if (!(expr)) { \ printf("FAILURE %s:%d: %s\n", __FILE__, __LINE__, #expr); \ - exit(EXIT_FAILURE); \ + abort(); \ } \ } while (0) @@ -2248,7 +2248,6 @@ static void test_rewrites(void) { ASSERT(fetch(&mgr, buf, url, "GET /foo HTTP/1.0\n\n") == 301); ASSERT(fetch(&mgr, buf, url, "GET /foo/ HTTP/1.0\n\n") == 200); // printf("-->[%s]\n", buf); - // exit(0); mg_mgr_free(&mgr); ASSERT(mgr.conns == NULL); }