Disable SL_INC_STD_BSD_API_NAMING in SimpleLink

And only define bits that we need afterwards.

PUBLISHED_FROM=b7e945dd16c7999753104428e29b5f0c1c9e666f
This commit is contained in:
Deomid Ryabkov 2016-04-07 18:20:11 +01:00 committed by Marko Mikulicic
parent 68b29b683d
commit d31d8a764b

View File

@ -415,6 +415,7 @@ unsigned long os_random(void);
#include <errno.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#ifndef __TI_COMPILER_VERSION__
@ -433,29 +434,11 @@ 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 EACCES
#undef EADDRINUSE
#undef EADDRNOTAVAIL
#undef EAFNOSUPPORT
#undef EAGAIN
#undef EBADF
#undef ECONNREFUSED
#undef EDESTADDRREQ
#undef EFAULT
#undef EINVAL
#undef EISCONN
#undef ENETUNREACH
#undef ENOBUFS
#undef ENOMEM
#undef ENOPROTOOPT
#undef ENOTCONN
#undef EOPNOTSUPP
#undef EPROTONOSUPPORT
#undef EPROTOTYPE
#undef ETIMEDOUT
#undef EWOULDBLOCK
#undef FD_CLR
#undef FD_ISSET
#undef FD_SET
@ -464,12 +447,75 @@ unsigned long os_random(void);
#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
/* rojer: gethostbyname() and sl_NetAppDnsGetHostByName are NOT compatible. */
#undef gethostbyname
#endif /* !__SIMPLELINK_H__ */
typedef int sock_t;
#define INVALID_SOCKET (-1)
@ -481,9 +527,6 @@ typedef struct stat cs_stat_t;
#define INT64_X_FMT PRIx64
#define __cdecl
#undef close /* Defined by SL's socket.h */
#define closesocket(x) sl_Close(x)
#define fileno(x) -1
/* Some functions we implement for Mongoose. */
@ -493,7 +536,7 @@ char *inet_ntoa(struct in_addr in);
int inet_pton(int af, const char *src, void *dst);
#ifdef __TI_COMPILER_VERSION__
#define timeval SlTimeval_t
#define timeval SlTimeval_t
int gettimeofday(struct timeval *t, void *tz);
#else
#undef timeval
@ -503,7 +546,7 @@ long int random(void);
#undef select
#define select(nfds, rfds, wfds, efds, tout) \
sl_Select((nfds), (rfds), (wfds), (efds), (struct SlTimeval_t *) (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__
@ -531,7 +574,7 @@ int _stat(const char *pathname, struct stat *st);
#define __S_IFCHR 0020000
#define __S_IFREG 0100000
#define __S_ISTYPE(mode, mask) (((mode) & __S_IFMT) == (mask))
#define __S_ISTYPE(mode, mask) (((mode) &__S_IFMT) == (mask))
#define S_IFDIR __S_IFDIR
#define S_IFCHR __S_IFCHR
@ -544,7 +587,6 @@ int _stat(const char *pathname, struct stat *st);
#endif /* __TI_COMPILER_VERSION__ */
#ifdef CC3200_FS_SPIFFS
#include <common/spiffs/spiffs.h>