From 161fa671cb3d4b447261e0c44237eb9930188c2f Mon Sep 17 00:00:00 2001 From: arvinzzz Date: Thu, 25 Aug 2022 18:10:50 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20iccarm=E9=80=82=E9=85=8D=E8=A1=A5?= =?UTF-8?q?=E5=85=85=E7=BD=91=E7=BB=9C=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=20close:=20#I5O540?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: arvinzzz --- porting/liteos_m_iccarm/kernel/iccarm.gni | 4 ++++ porting/liteos_m_iccarm/kernel/src/network/htonl.c | 8 ++++++++ porting/liteos_m_iccarm/kernel/src/network/htons.c | 8 ++++++++ porting/liteos_m_iccarm/kernel/src/network/ntohl.c | 8 ++++++++ porting/liteos_m_iccarm/kernel/src/network/ntohs.c | 8 ++++++++ 5 files changed, 36 insertions(+) create mode 100644 porting/liteos_m_iccarm/kernel/src/network/htonl.c create mode 100644 porting/liteos_m_iccarm/kernel/src/network/htons.c create mode 100644 porting/liteos_m_iccarm/kernel/src/network/ntohl.c create mode 100644 porting/liteos_m_iccarm/kernel/src/network/ntohs.c diff --git a/porting/liteos_m_iccarm/kernel/iccarm.gni b/porting/liteos_m_iccarm/kernel/iccarm.gni index 52f01c71..1635ad11 100644 --- a/porting/liteos_m_iccarm/kernel/iccarm.gni +++ b/porting/liteos_m_iccarm/kernel/iccarm.gni @@ -34,4 +34,8 @@ ICCARM_ADAPT_SRC_COMMON = [ "$MUSLPORTINGDIR/src/malloc.c", "$MUSLPORTINGDIR/src/fs.c", "$MUSLPORTINGDIR/src/misc/realpath.c", + "$MUSLPORTINGDIR/src/network/htonl.c", + "$MUSLPORTINGDIR/src/network/htons.c", + "$MUSLPORTINGDIR/src/network/ntohl.c", + "$MUSLPORTINGDIR/src/network/ntohs.c", ] diff --git a/porting/liteos_m_iccarm/kernel/src/network/htonl.c b/porting/liteos_m_iccarm/kernel/src/network/htonl.c new file mode 100644 index 00000000..6622d16c --- /dev/null +++ b/porting/liteos_m_iccarm/kernel/src/network/htonl.c @@ -0,0 +1,8 @@ +#include +#include + +uint32_t htonl(uint32_t n) +{ + union { int i; char c; } u = { 1 }; + return u.c ? bswap_32(n) : n; +} diff --git a/porting/liteos_m_iccarm/kernel/src/network/htons.c b/porting/liteos_m_iccarm/kernel/src/network/htons.c new file mode 100644 index 00000000..03a3a1d5 --- /dev/null +++ b/porting/liteos_m_iccarm/kernel/src/network/htons.c @@ -0,0 +1,8 @@ +#include +#include + +uint16_t htons(uint16_t n) +{ + union { int i; char c; } u = { 1 }; + return u.c ? bswap_16(n) : n; +} diff --git a/porting/liteos_m_iccarm/kernel/src/network/ntohl.c b/porting/liteos_m_iccarm/kernel/src/network/ntohl.c new file mode 100644 index 00000000..d6fce459 --- /dev/null +++ b/porting/liteos_m_iccarm/kernel/src/network/ntohl.c @@ -0,0 +1,8 @@ +#include +#include + +uint32_t ntohl(uint32_t n) +{ + union { int i; char c; } u = { 1 }; + return u.c ? bswap_32(n) : n; +} diff --git a/porting/liteos_m_iccarm/kernel/src/network/ntohs.c b/porting/liteos_m_iccarm/kernel/src/network/ntohs.c new file mode 100644 index 00000000..745cef42 --- /dev/null +++ b/porting/liteos_m_iccarm/kernel/src/network/ntohs.c @@ -0,0 +1,8 @@ +#include +#include + +uint16_t ntohs(uint16_t n) +{ + union { int i; char c; } u = { 1 }; + return u.c ? bswap_16(n) : n; +} -- GitLab