Merge pull request #3631 from cesanta/c89diab

add more C89-like targets; fix related stuff
This commit is contained in:
Sergey Lyubka
2026-07-10 10:29:32 +01:00
committed by GitHub
9 changed files with 59 additions and 16 deletions
+20 -2
View File
@@ -52,6 +52,24 @@ jobs:
test/health.awk < log > json
scp -o "StrictHostKeyChecking=no" json "root@176.9.217.245:/data/downloads/health/linux_${{ matrix.target }}_${{ matrix.cc }}_${{ matrix.ssl }}_${{ matrix.select }}_$(date +"%Y%m%d").json"
c89:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [diabish, ppc_diabish]
ssl: ["", BUILTIN]
name: C89 ${{ matrix.target }} SSL=${{ matrix.ssl }}
env:
SSL: ${{ matrix.ssl }}
TFLAGS: -DMG_ENABLE_POLL=0 -DMG_ENABLE_EPOLL=0 -DMG_ENABLE_CHACHA20=0 -DMQTT_LOCALHOST -DNO_ZU_TEST
steps:
- uses: actions/checkout@v5
with: { fetch-depth: 2 }
- run: | # GH runners seem to overflow the 32-bit FS for the QEMU PPC (works for me in RHEL9)
if [[ "${{ matrix.target }}" = ppc_* ]]; then export TFLAGS="$TFLAGS -D_FILE_OFFSET_BITS=64"; fi
sudo apt -y update ; sudo apt -y install binfmt-support qemu-user-static && ./test/setup_mqtt_server.sh && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make -C test ${{ matrix.target }}
mip:
runs-on: ubuntu-latest
strategy:
@@ -87,13 +105,13 @@ jobs:
strategy:
fail-fast: false
matrix:
target: [mip_vc98]
target: [mip_vc98, mip_diabish, mip_ppc_diabish]
ipv6: [0, 1]
name: MIP C89 ${{ matrix.target }} IPV6=${{ matrix.ipv6 }}
steps:
- uses: actions/checkout@v5
with: { fetch-depth: 2 }
- run: make -C test ${{ matrix.target }} IPV6=${{ matrix.ipv6 }}
- run: sudo apt -y update ; sudo apt -y install binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make -C test ${{ matrix.target }} IPV6=${{ matrix.ipv6 }}
mipbe:
runs-on: ubuntu-latest
strategy:
+6 -4
View File
@@ -1014,9 +1014,11 @@ static size_t mg_dash_print_endpoint(mg_pfn_t fn, void *arg, va_list *ap) {
void mg_dash_send_change(struct mg_mgr *mgr, struct mg_field_set *set) {
struct mg_connection *c;
for (c = mgr->conns; c != NULL; c = c->next) {
struct mg_dash_cdata *d = (struct mg_dash_cdata *) c->data;
struct mg_dash_user *u = d->u;
struct mg_dash_cdata *d;
struct mg_dash_user *u;
if (!c->is_websocket) continue;
d = (struct mg_dash_cdata *) c->data;
u = d->u;
if (u == NULL) continue;
if (set->index != NULL && *set->index < 0) {
int sz = mg_dash_array_size(set, u);
@@ -8797,7 +8799,7 @@ static void rx_ndp_ra(struct mg_tcpip_if *ifp, struct pkt *pkt) {
bool gotl2addr = false, gotprefix = false, changed = false;
uint8_t l2[sizeof(struct mg_l2addr)];
uint32_t mtu = 0;
uint8_t *prefix, prefix_len;
uint8_t *prefix = NULL, prefix_len = 0;
if (pkt->pay.len < sizeof(*ra)) return;
if (ifp->state6 == MG_TCPIP_STATE_UP) {
@@ -18841,7 +18843,7 @@ void mg_tls_ctx_free(struct mg_mgr *mgr) {
#if MG_TLS == MG_TLS_BUILTIN
#if MG_TLS == MG_TLS_BUILTIN && MG_ENABLE_CHACHA20
// ******* BEGIN: chacha-portable/chacha-portable.h ********
#if !defined(__cplusplus) && !defined(_MSC_VER) && \
+1 -1
View File
@@ -3363,7 +3363,7 @@ int mg_uecc_generate_random_int(mg_uecc_word_t *random,
#if MG_TLS == MG_TLS_BUILTIN
#if MG_TLS == MG_TLS_BUILTIN && MG_ENABLE_CHACHA20
#ifndef __PORTABLE_8439_H
#define __PORTABLE_8439_H
#if defined(__cplusplus)
+4 -2
View File
@@ -167,9 +167,11 @@ static size_t mg_dash_print_endpoint(mg_pfn_t fn, void *arg, va_list *ap) {
void mg_dash_send_change(struct mg_mgr *mgr, struct mg_field_set *set) {
struct mg_connection *c;
for (c = mgr->conns; c != NULL; c = c->next) {
struct mg_dash_cdata *d = (struct mg_dash_cdata *) c->data;
struct mg_dash_user *u = d->u;
struct mg_dash_cdata *d;
struct mg_dash_user *u;
if (!c->is_websocket) continue;
d = (struct mg_dash_cdata *) c->data;
u = d->u;
if (u == NULL) continue;
if (set->index != NULL && *set->index < 0) {
int sz = mg_dash_array_size(set, u);
+1 -1
View File
@@ -972,7 +972,7 @@ static void rx_ndp_ra(struct mg_tcpip_if *ifp, struct pkt *pkt) {
bool gotl2addr = false, gotprefix = false, changed = false;
uint8_t l2[sizeof(struct mg_l2addr)];
uint32_t mtu = 0;
uint8_t *prefix, prefix_len;
uint8_t *prefix = NULL, prefix_len = 0;
if (pkt->pay.len < sizeof(*ra)) return;
if (ifp->state6 == MG_TCPIP_STATE_UP) {
+1 -1
View File
@@ -7,7 +7,7 @@
#include "tls_chacha20.h"
#include "tls.h"
#if MG_TLS == MG_TLS_BUILTIN
#if MG_TLS == MG_TLS_BUILTIN && MG_ENABLE_CHACHA20
// ******* BEGIN: chacha-portable/chacha-portable.h ********
#if !defined(__cplusplus) && !defined(_MSC_VER) && \
+1 -1
View File
@@ -8,7 +8,7 @@
#include "config.h"
#include "tls.h"
#if MG_TLS == MG_TLS_BUILTIN
#if MG_TLS == MG_TLS_BUILTIN && MG_ENABLE_CHACHA20
#ifndef __PORTABLE_8439_H
#define __PORTABLE_8439_H
#if defined(__cplusplus)
+20
View File
@@ -248,6 +248,26 @@ mip_port_s390: CC = $(DOCKER) mdashnet/s390 cc
mip_port_s390: RUN = $(DOCKER) --init mdashnet/s390
mip_port_s390: mip_port_test
diabish: CC = gcc
diabish: CFLAGS += -std=gnu89 -Werror=declaration-after-statement -Werror=vla -Wno-pedantic
diabish: test
mip_diabish: CC = gcc
mip_diabish: CFLAGS += -std=gnu89 -Werror=declaration-after-statement -Werror=vla -Wno-pedantic
mip_diabish: mip_test
ppc_diabish: ASAN=
ppc_diabish: CFLAGS += -std=gnu89 -Werror=declaration-after-statement -Werror=vla -Wno-pedantic
ppc_diabish: CC = $(DOCKER) dockcross/linux-ppc powerpc-unknown-linux-gnu-gcc -static
ppc_diabish: RUN = qemu-ppc-static
ppc_diabish: test
mip_ppc_diabish: ASAN=
mip_ppc_diabish: CFLAGS += -std=gnu89 -Werror=declaration-after-statement -Werror=vla -Wno-pedantic
mip_ppc_diabish: CC = $(DOCKER) dockcross/linux-ppc powerpc-unknown-linux-gnu-gcc -static
mip_ppc_diabish: RUN = qemu-ppc-static
mip_ppc_diabish: mip_test
arm: DEFS += -DMG_ENABLE_POSIX_FS=0 -DMG_ENABLE_TCPIP=1 -DMG_ENABLE_TCPIP_DRIVER_INIT=0 -DMG_ARCH=MG_ARCH_ARMGCC -DNO_SLEEP_ABORT
arm: mongoose.h $(SRCS) mip_test.c
$(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
+5 -4
View File
@@ -339,7 +339,7 @@ static void sntp_cb(struct mg_connection *c, int ev, void *ev_data) {
int64_t received = *(int64_t *) ev_data;
*(int64_t *) c->fn_data = received;
MG_DEBUG(("got time: %lld", received));
#if MG_ARCH == MG_ARCH_UNIX
#if MG_ARCH == MG_ARCH_UNIX && defined(__STDC__) && defined(__STDC_VERSION__)
struct timeval tv = {0, 0};
gettimeofday(&tv, 0);
int64_t ms = (int64_t) tv.tv_sec * 1000 + tv.tv_usec / 1000;
@@ -1462,7 +1462,7 @@ static void test_tls(void) {
const char *url = "https://localhost:12347";
char buf[FETCH_BUF_SIZE];
struct mg_tls_opts opts;
struct mg_str data = mg_unpacked("/Makefile");
struct mg_str data = mg_unpacked("/fuzz.c");
char bigdata[FETCH_BUF_SIZE - 256]; // leave extra room
struct mg_str bd;
ASSERT(data.buf != NULL && data.len > 0);
@@ -1505,6 +1505,7 @@ static void test_tls(void) {
// otherwise it will end with 200 and shorter file contents
ASSERT(fetch(&mgr, buf, "https://localhost:8443",
"GET /thefile HTTP/1.0\n\n") == 200);
data = mg_unpacked("/Makefile");
ASSERT(cmpbody(buf, data.buf) == 0); // "thefile" links to Makefile
ASSERT(system("killall tls_multirec/server") == 0);
} else {
@@ -3014,7 +3015,7 @@ static void test_util(void) {
static void test_crc32(void) {
// echo -n aaa | cksum -o3
ASSERT(mg_crc32(0, 0, 0) == 0);
ASSERT(mg_crc32(0, "a", 1) == 3904355907);
ASSERT(mg_crc32(0, "a", 1) == 3904355907U);
ASSERT(mg_crc32(0, "abc", 3) == 891568578);
ASSERT(mg_crc32(mg_crc32(0, "ab", 2), "c", 1) == 891568578);
}
@@ -4501,7 +4502,7 @@ static bool test_upload_dir(const struct mg_dash_user *u, char *buf, size_t len)
struct test_file_entry {
char name[64];
size_t size;
uint64_t size;
};
static struct test_file_entry s_test_file;
static int s_test_file_index;