Stub ifaddrs.h

This commit is contained in:
Jeremy Soller
2025-12-19 12:18:21 -07:00
parent 3654575ca1
commit 7301eff5ba
3 changed files with 54 additions and 0 deletions
+12
View File
@@ -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
+41
View File
@@ -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
}
+1
View File
@@ -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;