Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix building std for Hermit after c_char change #134254

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions library/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 library/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 library/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
Loading