From b590df0979c92f50b24ec7d56fc65f431b11411c Mon Sep 17 00:00:00 2001 From: lyon Date: Thu, 10 Nov 2022 17:17:29 +0800 Subject: [PATCH] rename platform_socket.h to pika_socket.h --- package/requests/webclient.h | 2 +- package/socket/_socket.c | 13 +-------- package/socket/pika_socket.h | 28 +++++++++++++++++++ .../pikascript-lib/requests/webclient.h | 2 +- .../pikascript-lib/socket/_socket.c | 2 +- .../pikascript-lib/socket/pika_socket.h | 28 +++++++++++++++++++ 6 files changed, 60 insertions(+), 15 deletions(-) create mode 100644 package/socket/pika_socket.h create mode 100644 port/linux/package/pikascript/pikascript-lib/socket/pika_socket.h diff --git a/package/requests/webclient.h b/package/requests/webclient.h index 4bafe6eef..9984a7f29 100644 --- a/package/requests/webclient.h +++ b/package/requests/webclient.h @@ -20,7 +20,7 @@ #include #include "pika_adapter_rtt.h" /* depend on the socket module */ -#include "../socket/platform_socket.h" +#include "../socket/pika_socket.h" #define RT_USING_SAL 1 diff --git a/package/socket/_socket.c b/package/socket/_socket.c index ae8d60c25..d27a2941c 100644 --- a/package/socket/_socket.c +++ b/package/socket/_socket.c @@ -1,16 +1,5 @@ -#include "_socket.h" #include "_socket_socket.h" -#ifdef __linux__ -#include -#include -#else -/* - You need to create the __platform_socket.h for your platform. - For example: - You can #include "lwip/socket.h" in the __platform_socket.h -*/ -#include "__platform_socket.h" -#endif +#include "pika_socket.h" #if !PIKASCRIPT_VERSION_REQUIRE_MINIMUN(1, 10, 4) #error "This library requires PikaScript version 1.10.4 or higher" diff --git a/package/socket/pika_socket.h b/package/socket/pika_socket.h new file mode 100644 index 000000000..6d40c6b68 --- /dev/null +++ b/package/socket/pika_socket.h @@ -0,0 +1,28 @@ +#include "PikaObj.h" +#ifdef __linux__ +#include +#include +#include +#include +#else +/* + You need to create the __platform_socket.h for your platform. + For example: + You can #include "lwip/socket.h" in the __platform_socket.h +*/ +#include "__platform_socket.h" +#endif +int __platform_socket(int __domain, int __type, int __protocol); +int __platform_bind(int __fd, + const struct sockaddr* __addr, + socklen_t __addr_len); + +int __platform_listen(int __fd, int __n); +int __platform_accept(int __fd, struct sockaddr* __addr, socklen_t* __addr_len); +int __platform_connect(int __fd, + const struct sockaddr* __addr, + socklen_t __addr_len); +int __platform_send(int __fd, const void* __buf, size_t __n, int __flags); +int __platform_recv(int __fd, void* __buf, size_t __n, int __flags); +int __platform_close(int __fd); +int __platform_gethostname(char* __name, size_t __len); diff --git a/port/linux/package/pikascript/pikascript-lib/requests/webclient.h b/port/linux/package/pikascript/pikascript-lib/requests/webclient.h index 4bafe6eef..9984a7f29 100644 --- a/port/linux/package/pikascript/pikascript-lib/requests/webclient.h +++ b/port/linux/package/pikascript/pikascript-lib/requests/webclient.h @@ -20,7 +20,7 @@ #include #include "pika_adapter_rtt.h" /* depend on the socket module */ -#include "../socket/platform_socket.h" +#include "../socket/pika_socket.h" #define RT_USING_SAL 1 diff --git a/port/linux/package/pikascript/pikascript-lib/socket/_socket.c b/port/linux/package/pikascript/pikascript-lib/socket/_socket.c index f658fde7d..d27a2941c 100644 --- a/port/linux/package/pikascript/pikascript-lib/socket/_socket.c +++ b/port/linux/package/pikascript/pikascript-lib/socket/_socket.c @@ -1,5 +1,5 @@ #include "_socket_socket.h" -#include "platform_socket.h" +#include "pika_socket.h" #if !PIKASCRIPT_VERSION_REQUIRE_MINIMUN(1, 10, 4) #error "This library requires PikaScript version 1.10.4 or higher" diff --git a/port/linux/package/pikascript/pikascript-lib/socket/pika_socket.h b/port/linux/package/pikascript/pikascript-lib/socket/pika_socket.h new file mode 100644 index 000000000..6d40c6b68 --- /dev/null +++ b/port/linux/package/pikascript/pikascript-lib/socket/pika_socket.h @@ -0,0 +1,28 @@ +#include "PikaObj.h" +#ifdef __linux__ +#include +#include +#include +#include +#else +/* + You need to create the __platform_socket.h for your platform. + For example: + You can #include "lwip/socket.h" in the __platform_socket.h +*/ +#include "__platform_socket.h" +#endif +int __platform_socket(int __domain, int __type, int __protocol); +int __platform_bind(int __fd, + const struct sockaddr* __addr, + socklen_t __addr_len); + +int __platform_listen(int __fd, int __n); +int __platform_accept(int __fd, struct sockaddr* __addr, socklen_t* __addr_len); +int __platform_connect(int __fd, + const struct sockaddr* __addr, + socklen_t __addr_len); +int __platform_send(int __fd, const void* __buf, size_t __n, int __flags); +int __platform_recv(int __fd, void* __buf, size_t __n, int __flags); +int __platform_close(int __fd); +int __platform_gethostname(char* __name, size_t __len);