Skip to content

Commit df4b69d

Browse files
author
Askar Safin
committed
Add htonl, htons, ntohl, ntohs
1 parent 2fd2b60 commit df4b69d

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

libc-test/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ fn test_apple(target: &str) {
177177

178178
headers! { cfg:
179179
"aio.h",
180+
"arpa/inet.h",
180181
"CommonCrypto/CommonCrypto.h",
181182
"CommonCrypto/CommonRandom.h",
182183
"copyfile.h",
@@ -192,6 +193,17 @@ fn test_apple(target: &str) {
192193
"grp.h",
193194
"iconv.h",
194195
"ifaddrs.h",
196+
197+
"sys/types.h",
198+
"sys/socket.h",
199+
// "endian.h", NO
200+
"libkern/OSByteOrder.h",
201+
// "sys/endian.h", NO
202+
// "socket.h", NO
203+
"netinet/in.h",
204+
"arpa/inet.h",
205+
// "endian.h", NO
206+
195207
"langinfo.h",
196208
"libgen.h",
197209
"libproc.h",

libc-test/semver/unix.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,8 @@ grantpt
583583
group
584584
hostent
585585
hstrerror
586+
htonl
587+
htons
586588
if_indextoname
587589
if_nametoindex
588590
in6_addr
@@ -651,6 +653,8 @@ munmap
651653
nanosleep
652654
nfds_t
653655
nlink_t
656+
ntohl
657+
ntohs
654658
off_t
655659
open
656660
opendir

src/unix/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,10 @@ extern "C" {
672672
) -> ::ssize_t;
673673
#[cfg_attr(target_os = "espidf", link_name = "lwip_shutdown")]
674674
pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int;
675+
pub fn htonl(hostlong: u32) -> u32;
676+
pub fn htons(hostshort: u16) -> u16;
677+
pub fn ntohl(netlong: u32) -> u32;
678+
pub fn ntohs(netshort: u16) -> u16;
675679

676680
#[cfg_attr(
677681
all(target_os = "macos", target_arch = "x86"),

0 commit comments

Comments
 (0)