sync package to port/linux

This commit is contained in:
Lyon 2023-08-02 18:47:57 +08:00
parent 9cab1f6341
commit ccfeaf43cc
4 changed files with 35 additions and 8 deletions

View File

@ -1,4 +1,4 @@
#include "PikaPlatform_socket.h"
#include "PikaPlatform_socket.h"
/*
The functinos start with PIKA_WEAK are weak functions,
you need to override them in your platform.
@ -99,9 +99,9 @@ PIKA_WEAK struct hostent* pika_platform_gethostbyname(const char* __name) {
}
/* inet_ntoa */
PIKA_WEAK char* pika_platform_inet_ntoa(struct in_addr in_addr_val) {
PIKA_WEAK char* pika_platform_inet_ntoa(struct in_addr __addr) {
#if defined(__linux__) || defined(_WIN32) || PIKA_LWIP_ENABLE
return inet_ntoa(in_addr_val);
return inet_ntoa(__addr);
#else
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
#endif
@ -203,8 +203,10 @@ PIKA_WEAK int pika_platform_close(int __fd) {
}
PIKA_WEAK int pika_platform_write(int __fd, const void* __buf, size_t __nbyte) {
#if defined(__linux__) || defined(_WIN32) || PIKA_LWIP_ENABLE
#if defined(__linux__) || PIKA_LWIP_ENABLE
return write(__fd, __buf, __nbyte);
#elif defined(_WIN32)
return send(__fd, __buf, __nbyte, 0);
#else
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
#endif

View File

@ -1,4 +1,4 @@
#include "PikaObj.h"
#include "PikaObj.h"
#ifdef __linux__
#include <arpa/inet.h>
#include <errno.h>
@ -15,7 +15,6 @@
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <io.h>
#define O_NONBLOCK 0x0004 /* non blocking I/O, from BSD */
#define F_GETFL 3
@ -63,7 +62,7 @@ int pika_platform_setsockopt(int __fd,
const void* __optval,
socklen_t __optlen);
int pika_platform_htons(int __hostshort);
char* pika_platform_inet_ntoa(struct in_addr in_addr_val);
char* pika_platform_inet_ntoa(struct in_addr __addr);
struct hostent* pika_platform_gethostbyname(const char* __name);
/* os file API */

View File

@ -1,4 +1,4 @@
#include "PikaPlatform_socket.h"
#include "PikaPlatform_socket.h"
#include "_socket_socket.h"
#if !PIKASCRIPT_VERSION_REQUIRE_MINIMUN(1, 12, 0)

26
port/linux/pkg-pull.sh Normal file
View File

@ -0,0 +1,26 @@
#!/bin/bash
# 验证参数数量
if [ "$#" -ne 1 ]; then
echo "错误:需要一个参数"
echo "用法:$0 <package_name>"
exit 1
fi
src_dir="../../package/${1}"
dest_dir="package/pikascript/pikascript-lib/${1}"
# 验证源目录是否存在
if [ ! -d "$src_dir" ]; then
echo "错误:源目录不存在"
exit 2
fi
# 如果目标目录不存在,创建它
mkdir -p "$dest_dir"
# 把源目录中的文件拷贝到目标目录
cp -r "$src_dir/"* "$dest_dir/"
echo "拷贝完成"