mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-26 22:41:03 +08:00
Add TI support
This commit is contained in:
parent
95e22e8d4f
commit
0ed7545947
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -120,6 +120,8 @@ jobs:
|
||||
path: infineon/infineon-xmc4700_4800-lwip-rtx-rtos
|
||||
- name: zephyr
|
||||
path: zephyr
|
||||
- name: ti
|
||||
path: ti/ti-ek-tm4c1294xl-http-server
|
||||
name: ${{ matrix.example.name }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
10
examples/ti/ti-ek-tm4c1294xl-http-server/Makefile
Normal file
10
examples/ti/ti-ek-tm4c1294xl-http-server/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
NAME = ti-ek-tm4c1294xl-http-server
|
||||
DOCKER ?= docker run -v $(CURDIR):/workspace mdashnet/ccs
|
||||
|
||||
build:
|
||||
git clone --depth 1 https://github.com/mongoose-examples/$(NAME)
|
||||
cp ./../../../mongoose.[ch] $(NAME)/
|
||||
$(DOCKER) /opt/ti/ccs/eclipse/eclipse -noSplash -data /workspace -application com.ti.ccstudio.apps.projectBuild -ccs.autoImport -ccs.projects $(NAME) -ccs.configuration Release
|
||||
|
||||
clean:
|
||||
rm -rf $(NAME)
|
20
mongoose.c
20
mongoose.c
@ -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);
|
||||
|
22
mongoose.h
22
mongoose.h
@ -39,6 +39,7 @@ extern "C" {
|
||||
#define MG_ARCH_ZEPHYR 9
|
||||
#define MG_ARCH_NEWLIB 10
|
||||
#define MG_ARCH_RTX 11
|
||||
#define MG_ARCH_TIRTOS 12
|
||||
|
||||
#if !defined(MG_ARCH)
|
||||
#if defined(__unix__) || defined(__APPLE__)
|
||||
@ -392,6 +393,27 @@ struct timeval {
|
||||
#endif
|
||||
|
||||
|
||||
#if MG_ARCH == MG_ARCH_TIRTOS
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
extern int SockStatus(SOCKET hSock, int request, int *results );
|
||||
extern int SockSet(SOCKET hSock, int Type, int Prop, void *pbuf, int size);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if MG_ARCH == MG_ARCH_UNIX
|
||||
|
||||
#define _DARWIN_UNLIMITED_SELECT 1 // No limit on file descriptors
|
||||
|
@ -12,6 +12,7 @@
|
||||
#define MG_ARCH_ZEPHYR 9
|
||||
#define MG_ARCH_NEWLIB 10
|
||||
#define MG_ARCH_RTX 11
|
||||
#define MG_ARCH_TIRTOS 12
|
||||
|
||||
#if !defined(MG_ARCH)
|
||||
#if defined(__unix__) || defined(__APPLE__)
|
||||
|
21
src/arch_tirtos.h
Normal file
21
src/arch_tirtos.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#if MG_ARCH == MG_ARCH_TIRTOS
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
extern int SockStatus(SOCKET hSock, int request, int *results );
|
||||
extern int SockSet(SOCKET hSock, int Type, int Prop, void *pbuf, int size);
|
||||
|
||||
#endif
|
@ -12,9 +12,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";
|
||||
|
18
src/sock.c
18
src/sock.c
@ -19,6 +19,9 @@
|
||||
#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
|
||||
@ -182,6 +185,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
|
||||
@ -299,7 +312,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;
|
||||
@ -340,6 +353,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));
|
||||
}
|
||||
|
||||
@ -365,7 +379,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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user