Skip to content

Commit 198d2d4

Browse files
authored
Rollup merge of #134254 - hermit-os:hermit-c_char, r=workingjubilee
Fix building `std` for Hermit after `c_char` change These changes were made necessary by #132975.
2 parents c58b8bc + 4e8359c commit 198d2d4

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

library/std/src/sys/pal/hermit/fs.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::hermit_abi::{
33
self, DT_DIR, DT_LNK, DT_REG, DT_UNKNOWN, O_APPEND, O_CREAT, O_DIRECTORY, O_EXCL, O_RDONLY,
44
O_RDWR, O_TRUNC, O_WRONLY, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG, dirent64, stat as stat_struct,
55
};
6-
use crate::ffi::{CStr, OsStr, OsString};
6+
use crate::ffi::{CStr, OsStr, OsString, c_char};
77
use crate::io::{self, BorrowedCursor, Error, ErrorKind, IoSlice, IoSliceMut, SeekFrom};
88
use crate::os::hermit::ffi::OsStringExt;
99
use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
@@ -204,7 +204,7 @@ impl Iterator for ReadDir {
204204
// the size of dirent64. The file name is always a C string and terminated by `\0`.
205205
// Consequently, we are able to ignore the last byte.
206206
let name_bytes =
207-
unsafe { CStr::from_ptr(&dir.d_name as *const _ as *const i8).to_bytes() };
207+
unsafe { CStr::from_ptr(&dir.d_name as *const _ as *const c_char).to_bytes() };
208208
let entry = DirEntry {
209209
root: self.inner.root.clone(),
210210
ino: dir.d_ino,
@@ -445,7 +445,7 @@ impl DirBuilder {
445445

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

library/std/src/sys/pal/hermit/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub unsafe extern "C" fn runtime_entry(
8585
}
8686

8787
// initialize environment
88-
os::init_environment(env as *const *const i8);
88+
os::init_environment(env);
8989

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

library/std/src/sys/pal/hermit/os.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::slice::memchr;
33
use super::hermit_abi;
44
use crate::collections::HashMap;
55
use crate::error::Error as StdError;
6-
use crate::ffi::{CStr, OsStr, OsString};
6+
use crate::ffi::{CStr, OsStr, OsString, c_char};
77
use crate::marker::PhantomData;
88
use crate::os::hermit::ffi::OsStringExt;
99
use crate::path::{self, PathBuf};
@@ -70,7 +70,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
7070

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

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

0 commit comments

Comments
 (0)