Skip to content

Commit

Permalink
Fix building std for Hermit after c_char change
Browse files Browse the repository at this point in the history
  • Loading branch information
mkroening authored and gitbot committed Feb 20, 2025
1 parent 2814149 commit 8a6245a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions std/src/sys/pal/hermit/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::hermit_abi::{
self, DT_DIR, DT_LNK, DT_REG, DT_UNKNOWN, O_APPEND, O_CREAT, O_DIRECTORY, O_EXCL, O_RDONLY,
O_RDWR, O_TRUNC, O_WRONLY, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG, dirent64, stat as stat_struct,
};
use crate::ffi::{CStr, OsStr, OsString};
use crate::ffi::{CStr, OsStr, OsString, c_char};
use crate::io::{self, BorrowedCursor, Error, ErrorKind, IoSlice, IoSliceMut, SeekFrom};
use crate::os::hermit::ffi::OsStringExt;
use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
Expand Down Expand Up @@ -204,7 +204,7 @@ impl Iterator for ReadDir {
// the size of dirent64. The file name is always a C string and terminated by `\0`.
// Consequently, we are able to ignore the last byte.
let name_bytes =
unsafe { CStr::from_ptr(&dir.d_name as *const _ as *const i8).to_bytes() };
unsafe { CStr::from_ptr(&dir.d_name as *const _ as *const c_char).to_bytes() };
let entry = DirEntry {
root: self.inner.root.clone(),
ino: dir.d_ino,
Expand Down Expand Up @@ -445,7 +445,7 @@ impl DirBuilder {

pub fn mkdir(&self, path: &Path) -> io::Result<()> {
run_path_with_cstr(path, &|path| {
cvt(unsafe { hermit_abi::mkdir(path.as_ptr(), self.mode.into()) }).map(|_| ())
cvt(unsafe { hermit_abi::mkdir(path.as_ptr().cast(), self.mode.into()) }).map(|_| ())
})
}

Expand Down
2 changes: 1 addition & 1 deletion std/src/sys/pal/hermit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub unsafe extern "C" fn runtime_entry(
}

// initialize environment
os::init_environment(env as *const *const i8);
os::init_environment(env);

let result = unsafe { main(argc as isize, argv) };

Expand Down
4 changes: 2 additions & 2 deletions std/src/sys/pal/hermit/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::slice::memchr;
use super::hermit_abi;
use crate::collections::HashMap;
use crate::error::Error as StdError;
use crate::ffi::{CStr, OsStr, OsString};
use crate::ffi::{CStr, OsStr, OsString, c_char};
use crate::marker::PhantomData;
use crate::os::hermit::ffi::OsStringExt;
use crate::path::{self, PathBuf};
Expand Down Expand Up @@ -70,7 +70,7 @@ pub fn current_exe() -> io::Result<PathBuf> {

static ENV: Mutex<Option<HashMap<OsString, OsString>>> = Mutex::new(None);

pub fn init_environment(env: *const *const i8) {
pub fn init_environment(env: *const *const c_char) {
let mut guard = ENV.lock().unwrap();
let map = guard.insert(HashMap::new());

Expand Down

0 comments on commit 8a6245a

Please sign in to comment.