Skip to content

Commit

Permalink
Merge pull request #572 from hermit-os/abi
Browse files Browse the repository at this point in the history
fix(abi): various typedefs
  • Loading branch information
mkroening authored May 8, 2024
2 parents 0ae6041 + ef3ea55 commit e530717
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 166 deletions.
52 changes: 9 additions & 43 deletions hermit-abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#![allow(clippy::result_unit_err)]

pub mod errno;
pub mod tcplistener;
pub mod tcpstream;

use core::ffi::c_char;
pub use core::ffi::{c_int, c_short, c_void};
Expand Down Expand Up @@ -39,13 +37,9 @@ pub const HIGH_PRIO: Priority = Priority::from(3);
pub const NORMAL_PRIO: Priority = Priority::from(2);
pub const LOW_PRIO: Priority = Priority::from(1);

/// A handle, identifying a socket
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default, Hash)]
pub struct Handle(usize);

pub const FUTEX_RELATIVE_TIMEOUT: u32 = 1;
pub const CLOCK_REALTIME: u64 = 1;
pub const CLOCK_MONOTONIC: u64 = 4;
pub const CLOCK_REALTIME: clockid_t = 1;
pub const CLOCK_MONOTONIC: clockid_t = 4;
pub const STDIN_FILENO: c_int = 0;
pub const STDOUT_FILENO: c_int = 1;
pub const STDERR_FILENO: c_int = 2;
Expand Down Expand Up @@ -87,34 +81,6 @@ pub struct timeval {
pub tv_usec: suseconds_t,
}

/// Internet protocol version.
#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
pub enum Version {
Unspecified,
Ipv4,
Ipv6,
}

/// A four-octet IPv4 address.
#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default)]
pub struct Ipv4Address(pub [u8; 4]);

/// A sixteen-octet IPv6 address.
#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default)]
pub struct Ipv6Address(pub [u8; 16]);

/// An internetworking address.
#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
pub enum IpAddress {
/// An unspecified address.
/// May be used as a placeholder for storage where the address is not assigned yet.
Unspecified,
/// An IPv4 address.
Ipv4(Ipv4Address),
/// An IPv6 address.
Ipv6(Ipv6Address),
}

/// The largest number `rand` will return
pub const RAND_MAX: i32 = 2_147_483_647;

Expand Down Expand Up @@ -201,17 +167,17 @@ pub struct in6_addr {
pub struct sockaddr {
pub sa_len: u8,
pub sa_family: sa_family_t,
pub sa_data: [u8; 14],
pub sa_data: [c_char; 14],
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sockaddr_in {
pub sin_len: u8,
pub sin_family: sa_family_t,
pub sin_port: u16,
pub sin_port: in_port_t,
pub sin_addr: in_addr,
pub sin_zero: [u8; 8],
pub sin_zero: [c_char; 8],
}

#[repr(C)]
Expand All @@ -233,7 +199,7 @@ pub struct addrinfo {
pub ai_socktype: i32,
pub ai_protocol: i32,
pub ai_addrlen: socklen_t,
pub ai_canonname: *mut u8,
pub ai_canonname: *mut c_char,
pub ai_addr: *mut sockaddr,
pub ai_next: *mut addrinfo,
}
Expand Down Expand Up @@ -323,7 +289,7 @@ pub struct dirent64 {
/// File type
pub d_type: u8,
/// Filename (null-terminated)
pub d_name: [u8; 256],
pub d_name: [c_char; 256],
}

pub const DT_UNKNOWN: u8 = 0;
Expand Down Expand Up @@ -761,8 +727,8 @@ extern "C" {

#[link_name = "sys_getaddrinfo"]
pub fn getaddrinfo(
nodename: *const i8,
servname: *const u8,
nodename: *const c_char,
servname: *const c_char,
hints: *const addrinfo,
res: *mut *mut addrinfo,
) -> i32;
Expand Down
13 changes: 0 additions & 13 deletions hermit-abi/src/tcplistener.rs

This file was deleted.

110 changes: 0 additions & 110 deletions hermit-abi/src/tcpstream.rs

This file was deleted.

0 comments on commit e530717

Please sign in to comment.