Stub ifaddrs.h
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
sys_includes = ["features.h", "netinet/in.h", "sys/socket.h"]
|
||||
include_guard = "_RELIBC_IFADDRS_H"
|
||||
language = "C"
|
||||
style = "Tag"
|
||||
no_includes = true
|
||||
cpp_compat = true
|
||||
|
||||
[export.rename]
|
||||
"sockaddr" = "struct sockaddr"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
@@ -0,0 +1,41 @@
|
||||
//! `ifaddrs.h` implementation
|
||||
|
||||
use core::ptr;
|
||||
|
||||
use crate::{
|
||||
header::{errno, stdlib, sys_socket::sockaddr},
|
||||
platform::{self, types::*},
|
||||
};
|
||||
|
||||
#[repr(C)]
|
||||
union ifaddrs_ifa_ifu {
|
||||
ifu_broadaddr: *mut sockaddr,
|
||||
ifu_dstaddr: *mut sockaddr,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct ifaddrs {
|
||||
ifa_next: *mut ifaddrs,
|
||||
ifa_name: *mut c_char,
|
||||
ifa_flags: c_uint,
|
||||
ifa_addr: *mut sockaddr,
|
||||
ifa_netmask: *mut sockaddr,
|
||||
ifa_ifu: ifaddrs_ifa_ifu,
|
||||
ifa_data: *mut c_void,
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn freeifaddrs(mut ifa: *mut ifaddrs) {
|
||||
while !ifa.is_null() {
|
||||
let next = (*ifa).ifa_next;
|
||||
stdlib::free(ifa.cast());
|
||||
ifa = next;
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn getifaddrs(ifap: *mut *mut ifaddrs) -> c_int {
|
||||
//TODO: implement getifaddrs
|
||||
platform::ERRNO.set(errno::ENOSYS);
|
||||
-1
|
||||
}
|
||||
@@ -29,6 +29,7 @@ pub mod getopt;
|
||||
pub mod glob;
|
||||
pub mod grp;
|
||||
// TODO: iconv.h
|
||||
pub mod ifaddrs;
|
||||
pub mod inttypes;
|
||||
// iso646.h implemented in C
|
||||
pub mod langinfo;
|
||||
|
||||
Reference in New Issue
Block a user