MSP432 port, step 1

Doesn't actually work yet, but bits common with CC3200 (SimpleLink) are
moved out.

PUBLISHED_FROM=9d9a51cf7d8262694199c46bfd0ac514fc88889e
This commit is contained in:
Deomid Ryabkov 2016-04-08 17:15:50 +01:00 committed by rojer
parent 0be132f3b5
commit f36b452f00
2 changed files with 386 additions and 243 deletions

View File

@ -533,7 +533,8 @@ typedef int cs_dirent_dummy;
#ifndef _WIN32
#include <stddef.h>
#if !defined(CS_PLATFORM) || CS_PLATFORM != CS_P_CC3200
#if !defined(CS_PLATFORM) || \
(CS_PLATFORM != CS_P_CC3200 && CS_PLATFORM != CS_P_MSP432)
#include <sys/time.h>
#endif
#else
@ -10051,7 +10052,156 @@ int mg_set_protocol_coap(struct mg_connection *nc) {
#endif /* MG_DISABLE_COAP */
#ifdef MG_MODULE_LINES
#line 1 "./src/../../common/platforms/cc3200/cc3200_fs_slfs.c"
#line 1 "./src/../../common/platforms/cc3200/cc3200_libc.c"
#endif
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
#if CS_PLATFORM == CS_P_CC3200
#include <stdio.h>
#include <string.h>
#ifndef __TI_COMPILER_VERSION__
#include <reent.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#endif
#include <inc/hw_types.h>
#include <inc/hw_memmap.h>
#include <driverlib/prcm.h>
#include <driverlib/rom.h>
#include <driverlib/rom_map.h>
#include <driverlib/uart.h>
#include <driverlib/utils.h>
#define CONSOLE_UART UARTA0_BASE
#ifndef __TI_COMPILER_VERSION__
int _gettimeofday_r(struct _reent *r, struct timeval *tp, void *tzp) {
#else
int gettimeofday(struct timeval *tp, void *tzp) {
#endif
unsigned long long r1 = 0, r2;
/* Achieve two consecutive reads of the same value. */
do {
r2 = r1;
r1 = PRCMSlowClkCtrFastGet();
} while (r1 != r2);
/* This is a 32768 Hz counter. */
tp->tv_sec = (r1 >> 15);
/* 1/32768-th of a second is 30.517578125 microseconds, approx. 31,
* but we round down so it doesn't overflow at 32767 */
tp->tv_usec = (r1 & 0x7FFF) * 30;
return 0;
}
long int random(void) {
return 42; /* FIXME */
}
void fprint_str(FILE *fp, const char *str) {
while (*str != '\0') {
if (*str == '\n') MAP_UARTCharPut(CONSOLE_UART, '\r');
MAP_UARTCharPut(CONSOLE_UART, *str++);
}
}
void _exit(int status) {
fprint_str(stderr, "_exit\n");
/* cause an unaligned access exception, that will drop you into gdb */
*(int *) 1 = status;
while (1)
; /* avoid gcc warning because stdlib abort() has noreturn attribute */
}
void _not_implemented(const char *what) {
fprint_str(stderr, what);
fprint_str(stderr, " is not implemented\n");
_exit(42);
}
int _kill(int pid, int sig) {
(void) pid;
(void) sig;
_not_implemented("_kill");
return -1;
}
int _getpid() {
fprint_str(stderr, "_getpid is not implemented\n");
return 42;
}
int _isatty(int fd) {
/* 0, 1 and 2 are TTYs. */
return fd < 2;
}
#endif /* CS_PLATFORM == CS_P_CC3200 */
#ifdef MG_MODULE_LINES
#line 1 "./src/../../common/platforms/msp432/msp432_libc.c"
#endif
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
#if CS_PLATFORM == CS_P_MSP432
int gettimeofday(struct timeval *tp, void *tzp) {
/* FIXME */
tp->tv_sec = 42;
tp->tv_usec = 123;
return 0;
}
long int random(void) {
return 42; /* FIXME */
}
#endif /* CS_PLATFORM == CS_P_MSP432 */
#ifdef MG_MODULE_LINES
#line 1 "./src/../../common/platforms/simplelink/sl_fs_slfs.h"
#endif
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
#ifndef CS_SMARTJS_PLATFORMS_SIMPLELINK_SL_FS_SLFS_H_
#define CS_SMARTJS_PLATFORMS_SIMPLELINK_SL_FS_SLFS_H_
#if defined(MG_FS_SLFS)
#include <stdio.h>
#ifndef __TI_COMPILER_VERSION__
#include <unistd.h>
#include <sys/stat.h>
#endif
#define MAX_OPEN_SLFS_FILES 8
/* Indirect libc interface - same functions, different names. */
int fs_slfs_open(const char *pathname, int flags, mode_t mode);
int fs_slfs_close(int fd);
ssize_t fs_slfs_read(int fd, void *buf, size_t count);
ssize_t fs_slfs_write(int fd, const void *buf, size_t count);
int fs_slfs_stat(const char *pathname, struct stat *s);
int fs_slfs_fstat(int fd, struct stat *s);
off_t fs_slfs_lseek(int fd, off_t offset, int whence);
int fs_slfs_unlink(const char *filename);
int fs_slfs_rename(const char *from, const char *to);
#endif /* defined(MG_FS_SLFS) */
#endif /* CS_SMARTJS_PLATFORMS_SIMPLELINK_SL_FS_SLFS_H_ */
#ifdef MG_MODULE_LINES
#line 1 "./src/../../common/platforms/simplelink/sl_fs_slfs.c"
#endif
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
@ -10060,19 +10210,21 @@ int mg_set_protocol_coap(struct mg_connection *nc) {
/* Standard libc interface to TI SimpleLink FS. */
#if CS_PLATFORM == CS_P_CC3200 && defined(CC3200_FS_SLFS)
#if defined(MG_FS_SLFS) || defined(CC3200_FS_SLFS)
/* Amalgamated: #include "cc3200_fs_slfs.h" */
/* Amalgamated: #include "common/platforms/simplelink/sl_fs_slfs.h" */
#include <errno.h>
#if CS_PLATFORM == CS_P_CC3200
#include <inc/hw_types.h>
#endif
#include <simplelink/include/simplelink.h>
#include <simplelink/include/fs.h>
/* Amalgamated: #include "common/cs_dbg.h" */
extern int set_errno(int e); /* From cc3200_fs.c */
extern int set_errno(int e); /* From sl_fs.c */
/*
* With SLFS, you have to pre-declare max file size. Yes. Really.
@ -10239,16 +10391,17 @@ int fs_slfs_rename(const char *from, const char *to) {
return set_errno(ENOTSUP);
}
#endif /* CS_PLATFORM == CS_P_CC3200 && defined(CC3200_FS_SLFS) */
#endif /* defined(MG_FS_SLFS) || defined(CC3200_FS_SLFS) */
#ifdef MG_MODULE_LINES
#line 1 "./src/../../common/platforms/cc3200/cc3200_fs.c"
#line 1 "./src/../../common/platforms/simplelink/sl_fs.c"
#endif
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
#if CS_PLATFORM == CS_P_CC3200
#if defined(MG_SOCKET_SIMPLELINK) && \
(defined(MG_FS_SLFS) || defined(MG_FS_SPIFFS))
#include <errno.h>
#include <stdio.h>
@ -10258,11 +10411,13 @@ int fs_slfs_rename(const char *from, const char *to) {
#include <file.h>
#endif
#if CS_PLATFORM == CS_P_CC3200
#include <inc/hw_types.h>
#include <inc/hw_memmap.h>
#include <driverlib/rom.h>
#include <driverlib/rom_map.h>
#include <driverlib/uart.h>
#endif
/* Amalgamated: #include "common/cs_dbg.h" */
/* Amalgamated: #include "common/platform.h" */
@ -10271,8 +10426,8 @@ int fs_slfs_rename(const char *from, const char *to) {
/* Amalgamated: #include "cc3200_fs_spiffs.h" */
#endif
#ifdef CC3200_FS_SLFS
/* Amalgamated: #include "cc3200_fs_slfs.h" */
#ifdef MG_FS_SLFS
/* Amalgamated: #include "sl_fs_slfs.h" */
#endif
#define NUM_SYS_FDS 3
@ -10306,7 +10461,7 @@ enum fd_type {
#ifdef CC3200_FS_SPIFFS
FD_SPIFFS,
#endif
#ifdef CC3200_FS_SLFS
#ifdef MG_FS_SLFS
FD_SLFS
#endif
};
@ -10317,7 +10472,7 @@ static int fd_type(int fd) {
return FD_SPIFFS;
}
#endif
#ifdef CC3200_FS_SLFS
#ifdef MG_FS_SLFS
if (fd >= SLFS_FD_BASE && fd < SLFS_FD_BASE + MAX_OPEN_SLFS_FILES) {
return FD_SLFS;
}
@ -10329,7 +10484,7 @@ int _open(const char *pathname, int flags, mode_t mode) {
int fd = -1;
pathname = drop_dir(pathname);
if (is_sl_fname(pathname)) {
#ifdef CC3200_FS_SLFS
#ifdef MG_FS_SLFS
fd = fs_slfs_open(sl_fname(pathname), flags, mode);
if (fd >= 0) fd += SLFS_FD_BASE;
#endif
@ -10359,7 +10514,7 @@ int _stat(const char *pathname, struct stat *st) {
return 0;
}
if (is_sl) {
#ifdef CC3200_FS_SLFS
#ifdef MG_FS_SLFS
res = fs_slfs_stat(fname, st);
#endif
} else {
@ -10385,7 +10540,7 @@ int _close(int fd) {
r = fs_spiffs_close(fd - SPIFFS_FD_BASE);
break;
#endif
#ifdef CC3200_FS_SLFS
#ifdef MG_FS_SLFS
case FD_SLFS:
r = fs_slfs_close(fd - SLFS_FD_BASE);
break;
@ -10409,7 +10564,7 @@ off_t _lseek(int fd, off_t offset, int whence) {
r = fs_spiffs_lseek(fd - SPIFFS_FD_BASE, offset, whence);
break;
#endif
#ifdef CC3200_FS_SLFS
#ifdef MG_FS_SLFS
case FD_SLFS:
r = fs_slfs_lseek(fd - SLFS_FD_BASE, offset, whence);
break;
@ -10439,7 +10594,7 @@ int _fstat(int fd, struct stat *s) {
r = fs_spiffs_fstat(fd - SPIFFS_FD_BASE, s);
break;
#endif
#ifdef CC3200_FS_SLFS
#ifdef MG_FS_SLFS
case FD_SLFS:
r = fs_slfs_fstat(fd - SLFS_FD_BASE, s);
break;
@ -10469,7 +10624,7 @@ ssize_t _read(int fd, void *buf, size_t count) {
r = fs_spiffs_read(fd - SPIFFS_FD_BASE, buf, count);
break;
#endif
#ifdef CC3200_FS_SLFS
#ifdef MG_FS_SLFS
case FD_SLFS:
r = fs_slfs_read(fd - SLFS_FD_BASE, buf, count);
break;
@ -10491,11 +10646,13 @@ ssize_t _write(int fd, const void *buf, size_t count) {
r = set_errno(EACCES);
break;
}
#if CS_PLATFORM == CS_P_CC3200
for (i = 0; i < count; i++) {
const char c = ((const char *) buf)[i];
if (c == '\n') MAP_UARTCharPut(CONSOLE_UART, '\r');
MAP_UARTCharPut(CONSOLE_UART, c);
}
#endif
r = count;
break;
}
@ -10504,7 +10661,7 @@ ssize_t _write(int fd, const void *buf, size_t count) {
r = fs_spiffs_write(fd - SPIFFS_FD_BASE, buf, count);
break;
#endif
#ifdef CC3200_FS_SLFS
#ifdef MG_FS_SLFS
case FD_SLFS:
r = fs_slfs_write(fd - SLFS_FD_BASE, buf, count);
break;
@ -10518,7 +10675,7 @@ int _rename(const char *from, const char *to) {
from = drop_dir(from);
to = drop_dir(to);
if (is_sl_fname(from) || is_sl_fname(to)) {
#ifdef CC3200_FS_SLFS
#ifdef MG_FS_SLFS
r = fs_slfs_rename(sl_fname(from), sl_fname(to));
#endif
} else {
@ -10539,7 +10696,7 @@ int _unlink(const char *filename) {
int r = -1;
filename = drop_dir(filename);
if (is_sl_fname(filename)) {
#ifdef CC3200_FS_SLFS
#ifdef MG_FS_SLFS
r = fs_slfs_unlink(sl_fname(filename));
#endif
} else {
@ -10591,7 +10748,7 @@ int mkdir(const char *path, mode_t mode) {
int cc3200_fs_init() {
int ret = 1;
#ifdef __TI_COMPILER_VERSION__
#ifdef CC3200_FS_SLFS
#ifdef MG_FS_SLFS
ret = (add_device("SL", _MSA, fs_slfs_open, fs_slfs_close, fs_slfs_read,
fs_slfs_write, fs_slfs_lseek, fs_slfs_unlink,
fs_slfs_rename) == 0);
@ -10600,108 +10757,17 @@ int cc3200_fs_init() {
return ret;
}
#endif /* CS_PLATFORM == CS_P_CC3200 */
#endif /* defined(MG_SOCKET_SIMPLELINK) && (defined(MG_FS_SLFS) || \
defined(MG_FS_SPIFFS)) */
#ifdef MG_MODULE_LINES
#line 1 "./src/../../common/platforms/cc3200/cc3200_libc.c"
#line 1 "./src/../../common/platforms/simplelink/sl_socket.c"
#endif
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
#if CS_PLATFORM == CS_P_CC3200
#include <stdio.h>
#include <string.h>
#ifndef __TI_COMPILER_VERSION__
#include <reent.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#endif
#include <inc/hw_types.h>
#include <inc/hw_memmap.h>
#include <driverlib/prcm.h>
#include <driverlib/rom.h>
#include <driverlib/rom_map.h>
#include <driverlib/uart.h>
#include <driverlib/utils.h>
#define CONSOLE_UART UARTA0_BASE
#ifndef __TI_COMPILER_VERSION__
int _gettimeofday_r(struct _reent *r, struct timeval *tp, void *tzp) {
#else
int gettimeofday(struct timeval *tp, void *tzp) {
#endif
unsigned long long r1 = 0, r2;
/* Achieve two consecutive reads of the same value. */
do {
r2 = r1;
r1 = PRCMSlowClkCtrFastGet();
} while (r1 != r2);
/* This is a 32768 Hz counter. */
tp->tv_sec = (r1 >> 15);
/* 1/32768-th of a second is 30.517578125 microseconds, approx. 31,
* but we round down so it doesn't overflow at 32767 */
tp->tv_usec = (r1 & 0x7FFF) * 30;
return 0;
}
long int random(void) {
return 42; /* FIXME */
}
void fprint_str(FILE *fp, const char *str) {
while (*str != '\0') {
if (*str == '\n') MAP_UARTCharPut(CONSOLE_UART, '\r');
MAP_UARTCharPut(CONSOLE_UART, *str++);
}
}
void _exit(int status) {
fprint_str(stderr, "_exit\n");
/* cause an unaligned access exception, that will drop you into gdb */
*(int *) 1 = status;
while (1)
; /* avoid gcc warning because stdlib abort() has noreturn attribute */
}
void _not_implemented(const char *what) {
fprint_str(stderr, what);
fprint_str(stderr, " is not implemented\n");
_exit(42);
}
int _kill(int pid, int sig) {
(void) pid;
(void) sig;
_not_implemented("_kill");
return -1;
}
int _getpid() {
fprint_str(stderr, "_getpid is not implemented\n");
return 42;
}
int _isatty(int fd) {
/* 0, 1 and 2 are TTYs. */
return fd < 2;
}
#endif /* CS_PLATFORM == CS_P_CC3200 */
#ifdef MG_MODULE_LINES
#line 1 "./src/../../common/platforms/cc3200/cc3200_socket.c"
#endif
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
#if CS_PLATFORM == CS_P_CC3200
#ifdef MG_SOCKET_SIMPLELINK
#include <errno.h>
#include <stdio.h>
@ -10745,4 +10811,4 @@ int inet_pton(int af, const char *src, void *dst) {
return 1;
}
#endif /* CS_PLATFORM == CS_P_CC3200 */
#endif /* MG_SOCKET_SIMPLELINK */

View File

@ -75,11 +75,15 @@
#define CS_P_WINDOWS 2
#define CS_P_ESP_LWIP 3
#define CS_P_CC3200 4
#define CS_P_MSP432 5
/* If not specified explicitly, we guess platform by defines. */
#ifndef CS_PLATFORM
#ifdef cc3200
#if defined(TARGET_IS_MSP432P4XX) || defined(__MSP432P401R__)
#define CS_PLATFORM CS_P_MSP432
#elif defined(cc3200)
#define CS_PLATFORM CS_P_CC3200
#elif defined(__unix__) || defined(__APPLE__)
#define CS_PLATFORM CS_P_UNIX
@ -434,88 +438,6 @@ unsigned long os_random(void);
#define MG_DISABLE_DIRECTORY_LISTING 1
#endif
/* If simplelink.h is already included, all bets are off. */
#ifndef __SIMPLELINK_H__
#ifndef __TI_COMPILER_VERSION__
#undef __CONCAT
#undef FD_CLR
#undef FD_ISSET
#undef FD_SET
#undef FD_SETSIZE
#undef FD_ZERO
#undef fd_set
#endif
/* We want to disable SL_INC_STD_BSD_API_NAMING, so we include user.h ourselves
* and undef it. */
#define PROVISIONING_API_H_
#include <simplelink/user.h>
#undef PROVISIONING_API_H_
#undef SL_INC_STD_BSD_API_NAMING
#include <simplelink/include/simplelink.h>
/* Now define only the subset of the BSD API that we use.
* Notably, close(), read() and write() are not defined. */
#define AF_INET SL_AF_INET
#define socklen_t SlSocklen_t
#define sockaddr SlSockAddr_t
#define sockaddr_in SlSockAddrIn_t
#define in_addr SlInAddr_t
#define SOCK_STREAM SL_SOCK_STREAM
#define SOCK_DGRAM SL_SOCK_DGRAM
#define FD_SET SL_FD_SET
#define FD_CLR SL_FD_CLR
#define FD_ISSET SL_FD_ISSET
#define FD_ZERO SL_FD_ZERO
#define fd_set SlFdSet_t
#define htonl sl_Htonl
#define ntohl sl_Ntohl
#define htons sl_Htons
#define ntohs sl_Ntohs
#define accept sl_Accept
#define closesocket sl_Close
#define bind sl_Bind
#define connect sl_Connect
#define listen sl_Listen
#define recv sl_Recv
#define recvfrom sl_RecvFrom
#define select sl_Select
#define send sl_Send
#define sendto sl_SendTo
#define socket sl_Socket
#ifndef EACCES
#define EACCES SL_EACCES
#endif
#ifndef EAFNOSUPPORT
#define EAFNOSUPPORT SL_EAFNOSUPPORT
#endif
#ifndef EAGAIN
#define EAGAIN SL_EAGAIN
#endif
#ifndef EBADF
#define EBADF SL_EBADF
#endif
#ifndef EINVAL
#define EINVAL SL_EINVAL
#endif
#ifndef ENOMEM
#define ENOMEM SL_ENOMEM
#endif
#ifndef EWOULDBLOCK
#define EWOULDBLOCK SL_EWOULDBLOCK
#endif
#define SOMAXCONN 8
#endif /* !__SIMPLELINK_H__ */
typedef int sock_t;
#define INVALID_SOCKET (-1)
@ -531,23 +453,14 @@ typedef struct stat cs_stat_t;
/* Some functions we implement for Mongoose. */
const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
char *inet_ntoa(struct in_addr in);
int inet_pton(int af, const char *src, void *dst);
#ifdef __TI_COMPILER_VERSION__
struct SlTimeval_t;
#define timeval SlTimeval_t
int gettimeofday(struct timeval *t, void *tz);
#else
#undef timeval
#endif
long int random(void);
#undef select
#define select(nfds, rfds, wfds, efds, tout) \
sl_Select((nfds), (rfds), (wfds), (efds), (struct SlTimeval_t *)(tout))
/* TI's libc does not have stat & friends, add them. */
#ifdef __TI_COMPILER_VERSION__
@ -603,6 +516,10 @@ int closedir(DIR *dir);
struct dirent *readdir(DIR *dir);
#endif /* CC3200_FS_SPIFFS */
#ifdef CC3200_FS_SLFS
#define MG_FS_SLFS
#endif
#endif /* CS_PLATFORM == CS_P_CC3200 */
#endif /* CS_COMMON_PLATFORMS_PLATFORM_CC3200_H_ */
/*
@ -610,6 +527,198 @@ struct dirent *readdir(DIR *dir);
* All rights reserved
*/
#ifndef CS_COMMON_PLATFORMS_PLATFORM_MSP432_H_
#define CS_COMMON_PLATFORMS_PLATFORM_MSP432_H_
#if CS_PLATFORM == CS_P_MSP432
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#ifndef __TI_COMPILER_VERSION__
#include <fcntl.h>
#include <sys/time.h>
#endif
#define MG_SOCKET_SIMPLELINK 1
#define MG_DISABLE_SOCKETPAIR 1
#define MG_DISABLE_SYNC_RESOLVER 1
#define MG_DISABLE_POPEN 1
#define MG_DISABLE_CGI 1
#define MG_DISABLE_DAV 1
#define MG_DISABLE_DIRECTORY_LISTING 1
typedef int sock_t;
#define INVALID_SOCKET (-1)
#define SIZE_T_FMT "u"
typedef struct stat cs_stat_t;
#define DIRSEP '/'
#define to64(x) strtoll(x, NULL, 10)
#define INT64_FMT PRId64
#define INT64_X_FMT PRIx64
#define __cdecl
#define fileno(x) -1
/* Some functions we implement for Mongoose. */
#ifdef __TI_COMPILER_VERSION__
struct SlTimeval_t;
#define timeval SlTimeval_t
int gettimeofday(struct timeval *t, void *tz);
#endif
long int random(void);
/* TI's libc does not have stat & friends, add them. */
#ifdef __TI_COMPILER_VERSION__
#include <file.h>
typedef unsigned int mode_t;
typedef size_t _off_t;
typedef long ssize_t;
struct stat {
int st_ino;
mode_t st_mode;
int st_nlink;
time_t st_mtime;
off_t st_size;
};
int _stat(const char *pathname, struct stat *st);
#define stat(a, b) _stat(a, b)
#define __S_IFMT 0170000
#define __S_IFDIR 0040000
#define __S_IFCHR 0020000
#define __S_IFREG 0100000
#define __S_ISTYPE(mode, mask) (((mode) &__S_IFMT) == (mask))
#define S_IFDIR __S_IFDIR
#define S_IFCHR __S_IFCHR
#define S_IFREG __S_IFREG
#define S_ISDIR(mode) __S_ISTYPE((mode), __S_IFDIR)
#define S_ISREG(mode) __S_ISTYPE((mode), __S_IFREG)
/* As of 5.2.7, TI compiler does not support va_copy() yet. */
#define va_copy(apc, ap) ((apc) = (ap))
#endif /* __TI_COMPILER_VERSION__ */
#endif /* CS_PLATFORM == CS_P_MSP432 */
#endif /* CS_COMMON_PLATFORMS_PLATFORM_MSP432_H_ */
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
#ifndef CS_SMARTJS_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_
#define CS_SMARTJS_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_
/* If simplelink.h is already included, all bets are off. */
#if defined(MG_SOCKET_SIMPLELINK) && !defined(__SIMPLELINK_H__)
#ifndef __TI_COMPILER_VERSION__
#undef __CONCAT
#undef FD_CLR
#undef FD_ISSET
#undef FD_SET
#undef FD_SETSIZE
#undef FD_ZERO
#undef fd_set
#endif
/* We want to disable SL_INC_STD_BSD_API_NAMING, so we include user.h ourselves
* and undef it. */
#define PROVISIONING_API_H_
#include <simplelink/user.h>
#undef PROVISIONING_API_H_
#undef SL_INC_STD_BSD_API_NAMING
#include <simplelink/include/simplelink.h>
/* Now define only the subset of the BSD API that we use.
* Notably, close(), read() and write() are not defined. */
#define AF_INET SL_AF_INET
#define socklen_t SlSocklen_t
#define sockaddr SlSockAddr_t
#define sockaddr_in SlSockAddrIn_t
#define in_addr SlInAddr_t
#define SOCK_STREAM SL_SOCK_STREAM
#define SOCK_DGRAM SL_SOCK_DGRAM
#define FD_SET SL_FD_SET
#define FD_CLR SL_FD_CLR
#define FD_ISSET SL_FD_ISSET
#define FD_ZERO SL_FD_ZERO
#define fd_set SlFdSet_t
#define htonl sl_Htonl
#define ntohl sl_Ntohl
#define htons sl_Htons
#define ntohs sl_Ntohs
#define accept sl_Accept
#define closesocket sl_Close
#define bind sl_Bind
#define connect sl_Connect
#define listen sl_Listen
#define recv sl_Recv
#define recvfrom sl_RecvFrom
#define send sl_Send
#define sendto sl_SendTo
#define socket sl_Socket
#define select(nfds, rfds, wfds, efds, tout) \
sl_Select((nfds), (rfds), (wfds), (efds), (struct SlTimeval_t *)(tout))
#ifndef EACCES
#define EACCES SL_EACCES
#endif
#ifndef EAFNOSUPPORT
#define EAFNOSUPPORT SL_EAFNOSUPPORT
#endif
#ifndef EAGAIN
#define EAGAIN SL_EAGAIN
#endif
#ifndef EBADF
#define EBADF SL_EBADF
#endif
#ifndef EINVAL
#define EINVAL SL_EINVAL
#endif
#ifndef ENOMEM
#define ENOMEM SL_ENOMEM
#endif
#ifndef EWOULDBLOCK
#define EWOULDBLOCK SL_EWOULDBLOCK
#endif
#define SOMAXCONN 8
const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
char *inet_ntoa(struct in_addr in);
int inet_pton(int af, const char *src, void *dst);
#endif /* defined(MG_SOCKET_SIMPLELINK) && !defined(__SIMPLELINK_H__) */
#endif /* CS_SMARTJS_PLATFORMS_SIMPLELINK_CS_SIMPLELINK_H_ */
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
#ifndef CS_COMMON_CS_DBG_H_
#define CS_COMMON_CS_DBG_H_
@ -3507,35 +3616,3 @@ uint32_t mg_coap_compose(struct mg_coap_message *cm, struct mbuf *io);
#endif /* MG_ENABLE_COAP */
#endif /* CS_MONGOOSE_SRC_COAP_H_ */
/*
* Copyright (c) 2014-2016 Cesanta Software Limited
* All rights reserved
*/
#ifndef CS_SMARTJS_PLATFORMS_CC3200_CC3200_FS_SLFS_H_
#define CS_SMARTJS_PLATFORMS_CC3200_CC3200_FS_SLFS_H_
#if CS_PLATFORM == CS_P_CC3200 && defined(CC3200_FS_SLFS)
#include <stdio.h>
#ifndef __TI_COMPILER_VERSION__
#include <unistd.h>
#include <sys/stat.h>
#endif
#define MAX_OPEN_SLFS_FILES 8
/* Indirect libc interface - same functions, different names. */
int fs_slfs_open(const char *pathname, int flags, mode_t mode);
int fs_slfs_close(int fd);
ssize_t fs_slfs_read(int fd, void *buf, size_t count);
ssize_t fs_slfs_write(int fd, const void *buf, size_t count);
int fs_slfs_stat(const char *pathname, struct stat *s);
int fs_slfs_fstat(int fd, struct stat *s);
off_t fs_slfs_lseek(int fd, off_t offset, int whence);
int fs_slfs_unlink(const char *filename);
int fs_slfs_rename(const char *from, const char *to);
#endif /* CS_PLATFORM == CS_P_CC3200 && defined(CC3200_FS_SLFS) */
#endif /* CS_SMARTJS_PLATFORMS_CC3200_CC3200_FS_SLFS_H_ */