Add TI support

This commit is contained in:
Alex Alashkin committed 2022-05-15 19:25:50 +03:00
1 parent 95e22e8d4f
commit 0ed7545947
8 files changed
+88 -8

No files matched your search

+16 -4
View File
@@ -2006,9 +2006,7 @@ static void logs(const char *buf, size_t len) {
static void mg_log_stdout(const void *buf, size_t len, void *userdata) {
(void) userdata, (void) buf, (void) len;
#if MG_ENABLE_FILE
logs((const char *) buf, len);
#endif
}
static const char *s_spec = "2";
@@ -3156,6 +3154,9 @@ struct mg_connection *mg_sntp_connect(struct mg_mgr *mgr, const char *url,
#define MG_SOCK_ERRNO errno
typedef Socket_t SOCKET;
#define INVALID_SOCKET FREERTOS_INVALID_SOCKET
#elif MG_ARCH == MG_ARCH_TIRTOS
#define MG_SOCK_ERRNO errno
#define closesocket(x) close(x)
#else
#define MG_SOCK_ERRNO errno
#ifndef closesocket
@@ -3319,6 +3320,16 @@ static void mg_set_non_blocking_mode(SOCKET fd) {
lwip_fcntl(fd, F_SETFL, O_NONBLOCK);
#elif MG_ARCH == MG_ARCH_AZURERTOS
fcntl(fd, F_SETFL, O_NONBLOCK);
#elif MG_ARCH == MG_ARCH_TIRTOS
int val = 0;
setsockopt(fd, 0, SO_BLOCKING, &val, sizeof(val));
int status = 0;
int res = SockStatus(fd, FDSTATUS_SEND, &status);
if (res == 0 && status > 0) {
val = status / 2;
int val_size = sizeof(val);
res = SockSet(fd, SOL_SOCKET, SO_SNDLOWAT, &val, val_size);
}
#else
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK); // Non-blocking mode
fcntl(fd, F_SETFD, FD_CLOEXEC); // Set close-on-exec
@@ -3436,7 +3447,7 @@ static void close_conn(struct mg_connection *c) {
}
static void setsockopts(struct mg_connection *c) {
#if MG_ARCH == MG_ARCH_FREERTOS_TCP || MG_ARCH == MG_ARCH_AZURERTOS
#if MG_ARCH == MG_ARCH_FREERTOS_TCP || MG_ARCH == MG_ARCH_AZURERTOS || MG_ARCH == MG_ARCH_TIRTOS
(void) c;
#else
int on = 1;
@@ -3477,6 +3488,7 @@ void mg_connect_resolved(struct mg_connection *c) {
mg_error(c, "connect: %d", MG_SOCK_ERRNO);
}
}
(void)rc;
MG_DEBUG(("%lu %p", c->id, c->fd));
}
@@ -3502,7 +3514,7 @@ static void accept_conn(struct mg_mgr *mgr, struct mg_connection *lsn) {
if (MG_SOCK_ERRNO != EAGAIN)
#endif
MG_ERROR(("%lu accept failed, errno %d", lsn->id, MG_SOCK_ERRNO));
#if ((MG_ARCH != MG_ARCH_WIN32) && (MG_ARCH != MG_ARCH_FREERTOS_TCP))
#if (MG_ARCH != MG_ARCH_WIN32) && (MG_ARCH != MG_ARCH_FREERTOS_TCP) && (MG_ARCH != MG_ARCH_TIRTOS)
} else if ((long) fd >= FD_SETSIZE) {
MG_ERROR(("%ld > %ld", (long) fd, (long) FD_SETSIZE));
closesocket(fd);