Skip to content

Commit

Permalink
Merge pull request #1179 from hermit-os/abi
Browse files Browse the repository at this point in the history
fix(abi): various typedefs
  • Loading branch information
mkroening committed May 8, 2024
2 parents 95694b4 + 5ec743b commit d32c082
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ pub struct Dirent64 {
/// File type
pub d_type: u8,
/// Filename (null-terminated)
pub d_name: PhantomData<u8>,
pub d_name: PhantomData<c_char>,
}

#[hermit_macro::system]
Expand Down
12 changes: 6 additions & 6 deletions src/syscalls/socket.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(dead_code)]
#![allow(nonstandard_style)]
use alloc::sync::Arc;
use core::ffi::c_void;
use core::ffi::{c_char, c_void};
use core::mem::size_of;
use core::ops::DerefMut;

Expand Down Expand Up @@ -83,7 +83,7 @@ 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)]
Expand All @@ -93,7 +93,7 @@ pub struct sockaddr_in {
pub sin_family: sa_family_t,
pub sin_port: in_port_t,
pub sin_addr: in_addr,
pub sin_zero: [u8; 8],
pub sin_zero: [c_char; 8],
}

#[cfg(all(any(feature = "tcp", feature = "udp"), not(feature = "newlib")))]
Expand Down Expand Up @@ -239,7 +239,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 @@ -571,8 +571,8 @@ pub unsafe extern "C" fn sys_freeaddrinfo(_ai: *mut addrinfo) {}

#[hermit_macro::system]
pub unsafe extern "C" fn sys_getaddrinfo(
_nodename: *const u8,
_servname: *const u8,
_nodename: *const c_char,
_servname: *const c_char,
_hints: *const addrinfo,
_res: *mut *mut addrinfo,
) -> i32 {
Expand Down
19 changes: 11 additions & 8 deletions src/syscalls/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ use crate::errno::*;
use crate::syscalls::usleep;
use crate::time::{itimerval, timespec, timeval};

pub(crate) const CLOCK_REALTIME: u64 = 1;
pub(crate) const CLOCK_PROCESS_CPUTIME_ID: u64 = 2;
pub(crate) const CLOCK_THREAD_CPUTIME_ID: u64 = 3;
pub(crate) const CLOCK_MONOTONIC: u64 = 4;
#[allow(non_camel_case_types)]
pub type clockid_t = i32;

pub(crate) const CLOCK_REALTIME: clockid_t = 1;
pub(crate) const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 2;
pub(crate) const CLOCK_THREAD_CPUTIME_ID: clockid_t = 3;
pub(crate) const CLOCK_MONOTONIC: clockid_t = 4;
pub(crate) const TIMER_ABSTIME: i32 = 4;

/// Finds the resolution (or precision) of a clock.
Expand All @@ -20,7 +23,7 @@ pub(crate) const TIMER_ABSTIME: i32 = 4;
/// - `CLOCK_THREAD_CPUTIME_ID`
/// - `CLOCK_MONOTONIC`
#[hermit_macro::system]
pub unsafe extern "C" fn sys_clock_getres(clock_id: u64, res: *mut timespec) -> i32 {
pub unsafe extern "C" fn sys_clock_getres(clock_id: clockid_t, res: *mut timespec) -> i32 {
assert!(
!res.is_null(),
"sys_clock_getres called with a zero res parameter"
Expand Down Expand Up @@ -49,7 +52,7 @@ pub unsafe extern "C" fn sys_clock_getres(clock_id: u64, res: *mut timespec) ->
/// - `CLOCK_REALTIME`
/// - `CLOCK_MONOTONIC`
#[hermit_macro::system]
pub unsafe extern "C" fn sys_clock_gettime(clock_id: u64, tp: *mut timespec) -> i32 {
pub unsafe extern "C" fn sys_clock_gettime(clock_id: clockid_t, tp: *mut timespec) -> i32 {
assert!(
!tp.is_null(),
"sys_clock_gettime called with a zero tp parameter"
Expand Down Expand Up @@ -86,7 +89,7 @@ pub unsafe extern "C" fn sys_clock_gettime(clock_id: u64, tp: *mut timespec) ->
/// - `CLOCK_MONOTONIC`
#[hermit_macro::system]
pub unsafe extern "C" fn sys_clock_nanosleep(
clock_id: u64,
clock_id: clockid_t,
flags: i32,
rqtp: *const timespec,
_rmtp: *mut timespec,
Expand Down Expand Up @@ -122,7 +125,7 @@ pub unsafe extern "C" fn sys_clock_nanosleep(
}

#[hermit_macro::system]
pub unsafe extern "C" fn sys_clock_settime(_clock_id: u64, _tp: *const timespec) -> i32 {
pub unsafe extern "C" fn sys_clock_settime(_clock_id: clockid_t, _tp: *const timespec) -> i32 {
// We don't support setting any clocks yet.
debug!("sys_clock_settime is unimplemented, returning -EINVAL");
-EINVAL
Expand Down

0 comments on commit d32c082

Please sign in to comment.