mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-02-05 17:28:23 +08:00
insert freertos and lwip platform for network
This commit is contained in:
parent
a67a71f944
commit
ebe10bc5f4
@ -108,20 +108,34 @@ int platform_net_socket_close(int fd) {
|
|||||||
return __platform_close(fd);
|
return __platform_close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
int platform_net_socket_set_block(int fd) {
|
PIKA_WEAK int platform_net_socket_set_block(int fd) {
|
||||||
|
#ifdef __linux
|
||||||
return __platform_fcntl(
|
return __platform_fcntl(
|
||||||
fd, F_SETFL, __platform_fcntl(fd, F_GETFL, F_GETFL) & ~O_NONBLOCK);
|
fd, F_SETFL, __platform_fcntl(fd, F_GETFL, F_GETFL) & ~O_NONBLOCK);
|
||||||
|
#elif PIKA_LWIP_ENABLE
|
||||||
|
unsigned long mode = 0;
|
||||||
|
return ioctlsocket(fd, FIONBIO, &mode);
|
||||||
|
#else
|
||||||
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int platform_net_socket_set_nonblock(int fd) {
|
PIKA_WEAK int platform_net_socket_set_nonblock(int fd) {
|
||||||
|
#ifdef __linux
|
||||||
return __platform_fcntl(
|
return __platform_fcntl(
|
||||||
fd, F_SETFL, __platform_fcntl(fd, F_GETFL, F_GETFL) | O_NONBLOCK);
|
fd, F_SETFL, __platform_fcntl(fd, F_GETFL, F_GETFL) | O_NONBLOCK);
|
||||||
|
#elif PIKA_LWIP_ENABLE
|
||||||
|
unsigned long mode = 1;
|
||||||
|
return ioctlsocket(fd, FIONBIO, &mode);
|
||||||
|
#else
|
||||||
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int platform_net_socket_setsockopt(int fd,
|
PIKA_WEAK int platform_net_socket_setsockopt(int fd,
|
||||||
int level,
|
int level,
|
||||||
int optname,
|
int optname,
|
||||||
const void* optval,
|
const void* optval,
|
||||||
socklen_t optlen) {
|
socklen_t optlen) {
|
||||||
return __platform_setsockopt(fd, level, optname, optval, optlen);
|
return __platform_setsockopt(fd, level, optname, optval, optlen);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
PIKA_WEAK int __platform_socket(int __domain, int __type, int __protocol) {
|
PIKA_WEAK int __platform_socket(int __domain, int __type, int __protocol) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return socket(__domain, __type, __protocol);
|
return socket(__domain, __type, __protocol);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -15,7 +15,7 @@ PIKA_WEAK int __platform_socket(int __domain, int __type, int __protocol) {
|
|||||||
PIKA_WEAK int __platform_bind(int __fd,
|
PIKA_WEAK int __platform_bind(int __fd,
|
||||||
const struct sockaddr* __addr,
|
const struct sockaddr* __addr,
|
||||||
socklen_t __addr_len) {
|
socklen_t __addr_len) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return bind(__fd, __addr, __addr_len);
|
return bind(__fd, __addr, __addr_len);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -23,7 +23,7 @@ PIKA_WEAK int __platform_bind(int __fd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
PIKA_WEAK int __platform_listen(int __fd, int __n) {
|
PIKA_WEAK int __platform_listen(int __fd, int __n) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return listen(__fd, __n);
|
return listen(__fd, __n);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -33,7 +33,7 @@ PIKA_WEAK int __platform_listen(int __fd, int __n) {
|
|||||||
PIKA_WEAK int __platform_accept(int __fd,
|
PIKA_WEAK int __platform_accept(int __fd,
|
||||||
struct sockaddr* __addr,
|
struct sockaddr* __addr,
|
||||||
socklen_t* __addr_len) {
|
socklen_t* __addr_len) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return accept(__fd, __addr, __addr_len);
|
return accept(__fd, __addr, __addr_len);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -43,7 +43,7 @@ PIKA_WEAK int __platform_accept(int __fd,
|
|||||||
PIKA_WEAK int __platform_connect(int __fd,
|
PIKA_WEAK int __platform_connect(int __fd,
|
||||||
const struct sockaddr* __addr,
|
const struct sockaddr* __addr,
|
||||||
socklen_t __addr_len) {
|
socklen_t __addr_len) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return connect(__fd, __addr, __addr_len);
|
return connect(__fd, __addr, __addr_len);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -54,7 +54,7 @@ PIKA_WEAK int __platform_send(int __fd,
|
|||||||
const void* __buf,
|
const void* __buf,
|
||||||
size_t __n,
|
size_t __n,
|
||||||
int __flags) {
|
int __flags) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return send(__fd, __buf, __n, __flags);
|
return send(__fd, __buf, __n, __flags);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -62,7 +62,7 @@ PIKA_WEAK int __platform_send(int __fd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
PIKA_WEAK int __platform_recv(int __fd, void* __buf, size_t __n, int __flags) {
|
PIKA_WEAK int __platform_recv(int __fd, void* __buf, size_t __n, int __flags) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return recv(__fd, __buf, __n, __flags);
|
return recv(__fd, __buf, __n, __flags);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -71,7 +71,7 @@ PIKA_WEAK int __platform_recv(int __fd, void* __buf, size_t __n, int __flags) {
|
|||||||
|
|
||||||
/* gethostname */
|
/* gethostname */
|
||||||
PIKA_WEAK int __platform_gethostname(char* __name, size_t __len) {
|
PIKA_WEAK int __platform_gethostname(char* __name, size_t __len) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return gethostname(__name, __len);
|
return gethostname(__name, __len);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -82,7 +82,7 @@ PIKA_WEAK int __platform_getaddrinfo(const char* __name,
|
|||||||
const char* __service,
|
const char* __service,
|
||||||
const struct addrinfo* __req,
|
const struct addrinfo* __req,
|
||||||
struct addrinfo** __pai) {
|
struct addrinfo** __pai) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return getaddrinfo(__name, __service, __req, __pai);
|
return getaddrinfo(__name, __service, __req, __pai);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -90,7 +90,7 @@ PIKA_WEAK int __platform_getaddrinfo(const char* __name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
PIKA_WEAK void __platform_freeaddrinfo(struct addrinfo* __ai) {
|
PIKA_WEAK void __platform_freeaddrinfo(struct addrinfo* __ai) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
freeaddrinfo(__ai);
|
freeaddrinfo(__ai);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -102,7 +102,7 @@ PIKA_WEAK int __platform_setsockopt(int __fd,
|
|||||||
int __optname,
|
int __optname,
|
||||||
const void* __optval,
|
const void* __optval,
|
||||||
socklen_t __optlen) {
|
socklen_t __optlen) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return setsockopt(__fd, __level, __optname, __optval, __optlen);
|
return setsockopt(__fd, __level, __optname, __optval, __optlen);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -116,3 +116,22 @@ PIKA_WEAK int __platform_fcntl(int fd, int cmd, long arg) {
|
|||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* os file API */
|
||||||
|
PIKA_WEAK int __platform_close(int __fd) {
|
||||||
|
#ifdef __linux__
|
||||||
|
return close(__fd);
|
||||||
|
#elif PIKA_FREERTOS_ENABLE
|
||||||
|
return closesocket(__fd);
|
||||||
|
#else
|
||||||
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
PIKA_WEAK int __platform_write(int __fd, const void* __buf, size_t __nbyte) {
|
||||||
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
|
return write(__fd, __buf, __nbyte);
|
||||||
|
#else
|
||||||
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@ -5,6 +5,12 @@
|
|||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#elif PIKA_LWIP_ENABLE
|
||||||
|
#include <lwip/sockets.h>
|
||||||
|
#include "lwip/api.h"
|
||||||
|
#include "lwip/netdb.h"
|
||||||
|
#include "lwip/opt.h"
|
||||||
|
#include "lwip/sys.h"
|
||||||
#else
|
#else
|
||||||
/*
|
/*
|
||||||
You need to create the __platform_socket.h for your platform.
|
You need to create the __platform_socket.h for your platform.
|
||||||
@ -38,8 +44,6 @@ int __platform_setsockopt(int __fd,
|
|||||||
socklen_t __optlen);
|
socklen_t __optlen);
|
||||||
|
|
||||||
/* os file API */
|
/* os file API */
|
||||||
int __platform_open(const char* __file, int __oflag, ...);
|
|
||||||
int __platform_close(int fd);
|
int __platform_close(int fd);
|
||||||
int __platform_read(int fd, void* buf, size_t count);
|
|
||||||
int __platform_write(int fd, const void* buf, size_t count);
|
int __platform_write(int fd, const void* buf, size_t count);
|
||||||
int __platform_fcntl(int fd, int cmd, long arg);
|
int __platform_fcntl(int fd, int cmd, long arg);
|
||||||
|
@ -114,41 +114,3 @@ char* _socket__gethostname(PikaObj* self) {
|
|||||||
__platform_gethostname(hostname_buff, 128);
|
__platform_gethostname(hostname_buff, 128);
|
||||||
return obj_cacheStr(self, hostname);
|
return obj_cacheStr(self, hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* os file API */
|
|
||||||
|
|
||||||
PIKA_WEAK int __platform_close(int __fd) {
|
|
||||||
#ifdef __linux__
|
|
||||||
return close(__fd);
|
|
||||||
#else
|
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
PIKA_WEAK int __platform_open(const char* __file, int __oflag, ...) {
|
|
||||||
#ifdef __linux__
|
|
||||||
va_list args;
|
|
||||||
va_start(args, __oflag);
|
|
||||||
int __mode = va_arg(args, int);
|
|
||||||
va_end(args);
|
|
||||||
return open(__file, __oflag, __mode);
|
|
||||||
#else
|
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
PIKA_WEAK int __platform_read(int __fd, void* __buf, size_t __nbyte) {
|
|
||||||
#ifdef __linux__
|
|
||||||
return read(__fd, __buf, __nbyte);
|
|
||||||
#else
|
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
PIKA_WEAK int __platform_write(int __fd, const void* __buf, size_t __nbyte) {
|
|
||||||
#ifdef __linux__
|
|
||||||
return write(__fd, __buf, __nbyte);
|
|
||||||
#else
|
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
@ -108,20 +108,34 @@ int platform_net_socket_close(int fd) {
|
|||||||
return __platform_close(fd);
|
return __platform_close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
int platform_net_socket_set_block(int fd) {
|
PIKA_WEAK int platform_net_socket_set_block(int fd) {
|
||||||
|
#ifdef __linux
|
||||||
return __platform_fcntl(
|
return __platform_fcntl(
|
||||||
fd, F_SETFL, __platform_fcntl(fd, F_GETFL, F_GETFL) & ~O_NONBLOCK);
|
fd, F_SETFL, __platform_fcntl(fd, F_GETFL, F_GETFL) & ~O_NONBLOCK);
|
||||||
|
#elif PIKA_LWIP_ENABLE
|
||||||
|
unsigned long mode = 0;
|
||||||
|
return ioctlsocket(fd, FIONBIO, &mode);
|
||||||
|
#else
|
||||||
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int platform_net_socket_set_nonblock(int fd) {
|
PIKA_WEAK int platform_net_socket_set_nonblock(int fd) {
|
||||||
|
#ifdef __linux
|
||||||
return __platform_fcntl(
|
return __platform_fcntl(
|
||||||
fd, F_SETFL, __platform_fcntl(fd, F_GETFL, F_GETFL) | O_NONBLOCK);
|
fd, F_SETFL, __platform_fcntl(fd, F_GETFL, F_GETFL) | O_NONBLOCK);
|
||||||
|
#elif PIKA_LWIP_ENABLE
|
||||||
|
unsigned long mode = 1;
|
||||||
|
return ioctlsocket(fd, FIONBIO, &mode);
|
||||||
|
#else
|
||||||
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int platform_net_socket_setsockopt(int fd,
|
PIKA_WEAK int platform_net_socket_setsockopt(int fd,
|
||||||
int level,
|
int level,
|
||||||
int optname,
|
int optname,
|
||||||
const void* optval,
|
const void* optval,
|
||||||
socklen_t optlen) {
|
socklen_t optlen) {
|
||||||
return __platform_setsockopt(fd, level, optname, optval, optlen);
|
return __platform_setsockopt(fd, level, optname, optval, optlen);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
PIKA_WEAK int __platform_socket(int __domain, int __type, int __protocol) {
|
PIKA_WEAK int __platform_socket(int __domain, int __type, int __protocol) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return socket(__domain, __type, __protocol);
|
return socket(__domain, __type, __protocol);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -15,7 +15,7 @@ PIKA_WEAK int __platform_socket(int __domain, int __type, int __protocol) {
|
|||||||
PIKA_WEAK int __platform_bind(int __fd,
|
PIKA_WEAK int __platform_bind(int __fd,
|
||||||
const struct sockaddr* __addr,
|
const struct sockaddr* __addr,
|
||||||
socklen_t __addr_len) {
|
socklen_t __addr_len) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return bind(__fd, __addr, __addr_len);
|
return bind(__fd, __addr, __addr_len);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -23,7 +23,7 @@ PIKA_WEAK int __platform_bind(int __fd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
PIKA_WEAK int __platform_listen(int __fd, int __n) {
|
PIKA_WEAK int __platform_listen(int __fd, int __n) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return listen(__fd, __n);
|
return listen(__fd, __n);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -33,7 +33,7 @@ PIKA_WEAK int __platform_listen(int __fd, int __n) {
|
|||||||
PIKA_WEAK int __platform_accept(int __fd,
|
PIKA_WEAK int __platform_accept(int __fd,
|
||||||
struct sockaddr* __addr,
|
struct sockaddr* __addr,
|
||||||
socklen_t* __addr_len) {
|
socklen_t* __addr_len) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return accept(__fd, __addr, __addr_len);
|
return accept(__fd, __addr, __addr_len);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -43,7 +43,7 @@ PIKA_WEAK int __platform_accept(int __fd,
|
|||||||
PIKA_WEAK int __platform_connect(int __fd,
|
PIKA_WEAK int __platform_connect(int __fd,
|
||||||
const struct sockaddr* __addr,
|
const struct sockaddr* __addr,
|
||||||
socklen_t __addr_len) {
|
socklen_t __addr_len) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return connect(__fd, __addr, __addr_len);
|
return connect(__fd, __addr, __addr_len);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -54,7 +54,7 @@ PIKA_WEAK int __platform_send(int __fd,
|
|||||||
const void* __buf,
|
const void* __buf,
|
||||||
size_t __n,
|
size_t __n,
|
||||||
int __flags) {
|
int __flags) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return send(__fd, __buf, __n, __flags);
|
return send(__fd, __buf, __n, __flags);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -62,7 +62,7 @@ PIKA_WEAK int __platform_send(int __fd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
PIKA_WEAK int __platform_recv(int __fd, void* __buf, size_t __n, int __flags) {
|
PIKA_WEAK int __platform_recv(int __fd, void* __buf, size_t __n, int __flags) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return recv(__fd, __buf, __n, __flags);
|
return recv(__fd, __buf, __n, __flags);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -71,7 +71,7 @@ PIKA_WEAK int __platform_recv(int __fd, void* __buf, size_t __n, int __flags) {
|
|||||||
|
|
||||||
/* gethostname */
|
/* gethostname */
|
||||||
PIKA_WEAK int __platform_gethostname(char* __name, size_t __len) {
|
PIKA_WEAK int __platform_gethostname(char* __name, size_t __len) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return gethostname(__name, __len);
|
return gethostname(__name, __len);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -82,7 +82,7 @@ PIKA_WEAK int __platform_getaddrinfo(const char* __name,
|
|||||||
const char* __service,
|
const char* __service,
|
||||||
const struct addrinfo* __req,
|
const struct addrinfo* __req,
|
||||||
struct addrinfo** __pai) {
|
struct addrinfo** __pai) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return getaddrinfo(__name, __service, __req, __pai);
|
return getaddrinfo(__name, __service, __req, __pai);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -90,7 +90,7 @@ PIKA_WEAK int __platform_getaddrinfo(const char* __name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
PIKA_WEAK void __platform_freeaddrinfo(struct addrinfo* __ai) {
|
PIKA_WEAK void __platform_freeaddrinfo(struct addrinfo* __ai) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
freeaddrinfo(__ai);
|
freeaddrinfo(__ai);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -102,7 +102,7 @@ PIKA_WEAK int __platform_setsockopt(int __fd,
|
|||||||
int __optname,
|
int __optname,
|
||||||
const void* __optval,
|
const void* __optval,
|
||||||
socklen_t __optlen) {
|
socklen_t __optlen) {
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
return setsockopt(__fd, __level, __optname, __optval, __optlen);
|
return setsockopt(__fd, __level, __optname, __optval, __optlen);
|
||||||
#else
|
#else
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
@ -116,3 +116,22 @@ PIKA_WEAK int __platform_fcntl(int fd, int cmd, long arg) {
|
|||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* os file API */
|
||||||
|
PIKA_WEAK int __platform_close(int __fd) {
|
||||||
|
#ifdef __linux__
|
||||||
|
return close(__fd);
|
||||||
|
#elif PIKA_FREERTOS_ENABLE
|
||||||
|
return closesocket(__fd);
|
||||||
|
#else
|
||||||
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
PIKA_WEAK int __platform_write(int __fd, const void* __buf, size_t __nbyte) {
|
||||||
|
#if defined(__linux__) || PIKA_LWIP_ENABLE
|
||||||
|
return write(__fd, __buf, __nbyte);
|
||||||
|
#else
|
||||||
|
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@ -44,8 +44,6 @@ int __platform_setsockopt(int __fd,
|
|||||||
socklen_t __optlen);
|
socklen_t __optlen);
|
||||||
|
|
||||||
/* os file API */
|
/* os file API */
|
||||||
int __platform_open(const char* __file, int __oflag, ...);
|
|
||||||
int __platform_close(int fd);
|
int __platform_close(int fd);
|
||||||
int __platform_read(int fd, void* buf, size_t count);
|
|
||||||
int __platform_write(int fd, const void* buf, size_t count);
|
int __platform_write(int fd, const void* buf, size_t count);
|
||||||
int __platform_fcntl(int fd, int cmd, long arg);
|
int __platform_fcntl(int fd, int cmd, long arg);
|
||||||
|
@ -114,41 +114,3 @@ char* _socket__gethostname(PikaObj* self) {
|
|||||||
__platform_gethostname(hostname_buff, 128);
|
__platform_gethostname(hostname_buff, 128);
|
||||||
return obj_cacheStr(self, hostname);
|
return obj_cacheStr(self, hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* os file API */
|
|
||||||
|
|
||||||
PIKA_WEAK int __platform_close(int __fd) {
|
|
||||||
#ifdef __linux__
|
|
||||||
return close(__fd);
|
|
||||||
#else
|
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
PIKA_WEAK int __platform_open(const char* __file, int __oflag, ...) {
|
|
||||||
#ifdef __linux__
|
|
||||||
va_list args;
|
|
||||||
va_start(args, __oflag);
|
|
||||||
int __mode = va_arg(args, int);
|
|
||||||
va_end(args);
|
|
||||||
return open(__file, __oflag, __mode);
|
|
||||||
#else
|
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
PIKA_WEAK int __platform_read(int __fd, void* __buf, size_t __nbyte) {
|
|
||||||
#ifdef __linux__
|
|
||||||
return read(__fd, __buf, __nbyte);
|
|
||||||
#else
|
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
PIKA_WEAK int __platform_write(int __fd, const void* __buf, size_t __nbyte) {
|
|
||||||
#ifdef __linux__
|
|
||||||
return write(__fd, __buf, __nbyte);
|
|
||||||
#else
|
|
||||||
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
@ -336,6 +336,14 @@
|
|||||||
#define PIKA_EVENT_LIST_SIZE 16
|
#define PIKA_EVENT_LIST_SIZE 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef PIKA_LWIP_ENABLE
|
||||||
|
#define PIKA_LWIP_ENABLE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PIKA_FREERTOS_ENABLE
|
||||||
|
#define PIKA_FREERTOS_ENABLE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/* configuration validation */
|
/* configuration validation */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user