Skip to content

Commit 3bd98b3

Browse files
committed
Emerald: renamed user_std to emerald_std
1 parent fcdc6e2 commit 3bd98b3

File tree

12 files changed

+63
-62
lines changed

12 files changed

+63
-62
lines changed

library/std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ r-efi-alloc = { version = "1.0.0", features = ['rustc-dep-of-std']}
5959

6060
[target.'cfg(target_os = "emerald")'.dependencies]
6161
# This is from `https://github.com/Amjad50/Emerald`, i.e. it must be run from that context
62-
user_std = { version = "0.2.2", package = "emerald_std", features = ['rustc-dep-of-std'] }
62+
emerald_std = { version = "0.2.2", features = ['rustc-dep-of-std'] }
6363

6464
[features]
6565
backtrace = [

library/std/src/os/emerald/io/owned.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl Drop for OwnedFd {
176176
#[inline]
177177
fn drop(&mut self) {
178178
unsafe {
179-
user_std::io::syscall_close(self.fd)
179+
emerald_std::io::syscall_close(self.fd)
180180
.expect("Invalid FD somehow slipped and should not be closed")
181181
}
182182
// unsafe {
@@ -428,7 +428,7 @@ impl<T: AsFd> AsFd for Box<T> {
428428
impl AsFd for io::Stdin {
429429
#[inline]
430430
fn as_fd(&self) -> BorrowedFd<'_> {
431-
unsafe { BorrowedFd::borrow_raw(user_std::io::FD_STDIN) }
431+
unsafe { BorrowedFd::borrow_raw(emerald_std::io::FD_STDIN) }
432432
}
433433
}
434434

@@ -437,15 +437,15 @@ impl<'a> AsFd for io::StdinLock<'a> {
437437
#[inline]
438438
fn as_fd(&self) -> BorrowedFd<'_> {
439439
// SAFETY: user code should not close stdin out from under the standard library
440-
unsafe { BorrowedFd::borrow_raw(user_std::io::FD_STDIN) }
440+
unsafe { BorrowedFd::borrow_raw(emerald_std::io::FD_STDIN) }
441441
}
442442
}
443443

444444
#[stable(feature = "io_safety", since = "1.63.0")]
445445
impl AsFd for io::Stdout {
446446
#[inline]
447447
fn as_fd(&self) -> BorrowedFd<'_> {
448-
unsafe { BorrowedFd::borrow_raw(user_std::io::FD_STDOUT) }
448+
unsafe { BorrowedFd::borrow_raw(emerald_std::io::FD_STDOUT) }
449449
}
450450
}
451451

@@ -454,15 +454,15 @@ impl<'a> AsFd for io::StdoutLock<'a> {
454454
#[inline]
455455
fn as_fd(&self) -> BorrowedFd<'_> {
456456
// SAFETY: user code should not close stdout out from under the standard library
457-
unsafe { BorrowedFd::borrow_raw(user_std::io::FD_STDOUT) }
457+
unsafe { BorrowedFd::borrow_raw(emerald_std::io::FD_STDOUT) }
458458
}
459459
}
460460

461461
#[stable(feature = "io_safety", since = "1.63.0")]
462462
impl AsFd for io::Stderr {
463463
#[inline]
464464
fn as_fd(&self) -> BorrowedFd<'_> {
465-
unsafe { BorrowedFd::borrow_raw(user_std::io::FD_STDERR) }
465+
unsafe { BorrowedFd::borrow_raw(emerald_std::io::FD_STDERR) }
466466
}
467467
}
468468

@@ -471,6 +471,6 @@ impl<'a> AsFd for io::StderrLock<'a> {
471471
#[inline]
472472
fn as_fd(&self) -> BorrowedFd<'_> {
473473
// SAFETY: user code should not close stderr out from under the standard library
474-
unsafe { BorrowedFd::borrow_raw(user_std::io::FD_STDERR) }
474+
unsafe { BorrowedFd::borrow_raw(emerald_std::io::FD_STDERR) }
475475
}
476476
}

library/std/src/os/emerald/io/raw.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,47 +174,47 @@ impl IntoRawFd for fs::File {
174174
impl AsRawFd for io::Stdin {
175175
#[inline]
176176
fn as_raw_fd(&self) -> RawFd {
177-
user_std::io::FD_STDIN
177+
emerald_std::io::FD_STDIN
178178
}
179179
}
180180

181181
#[stable(feature = "asraw_stdio", since = "1.21.0")]
182182
impl AsRawFd for io::Stdout {
183183
#[inline]
184184
fn as_raw_fd(&self) -> RawFd {
185-
user_std::io::FD_STDOUT
185+
emerald_std::io::FD_STDOUT
186186
}
187187
}
188188

189189
#[stable(feature = "asraw_stdio", since = "1.21.0")]
190190
impl AsRawFd for io::Stderr {
191191
#[inline]
192192
fn as_raw_fd(&self) -> RawFd {
193-
user_std::io::FD_STDERR
193+
emerald_std::io::FD_STDERR
194194
}
195195
}
196196

197197
#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
198198
impl<'a> AsRawFd for io::StdinLock<'a> {
199199
#[inline]
200200
fn as_raw_fd(&self) -> RawFd {
201-
user_std::io::FD_STDIN
201+
emerald_std::io::FD_STDIN
202202
}
203203
}
204204

205205
#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
206206
impl<'a> AsRawFd for io::StdoutLock<'a> {
207207
#[inline]
208208
fn as_raw_fd(&self) -> RawFd {
209-
user_std::io::FD_STDOUT
209+
emerald_std::io::FD_STDOUT
210210
}
211211
}
212212

213213
#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
214214
impl<'a> AsRawFd for io::StderrLock<'a> {
215215
#[inline]
216216
fn as_raw_fd(&self) -> RawFd {
217-
user_std::io::FD_STDERR
217+
emerald_std::io::FD_STDERR
218218
}
219219
}
220220

library/std/src/sys/emerald/alloc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ use crate::alloc::{GlobalAlloc, Layout, System};
44
unsafe impl GlobalAlloc for System {
55
#[inline]
66
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
7-
unsafe { user_std::alloc::alloc(layout) }
7+
unsafe { emerald_std::alloc::alloc(layout) }
88
}
99

1010
#[inline]
1111
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
12-
unsafe { user_std::alloc::alloc_zeroed(layout) }
12+
unsafe { emerald_std::alloc::alloc_zeroed(layout) }
1313
}
1414

1515
#[inline]
1616
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
17-
unsafe { user_std::alloc::dealloc(ptr, layout) }
17+
unsafe { emerald_std::alloc::dealloc(ptr, layout) }
1818
}
1919

2020
#[inline]
2121
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
22-
unsafe { user_std::alloc::realloc(ptr, layout, new_size) }
22+
unsafe { emerald_std::alloc::realloc(ptr, layout, new_size) }
2323
}
2424
}

library/std/src/sys/emerald/fd.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
sys_common::{AsInner, FromInner, IntoInner},
99
};
1010

11-
use user_std::io::FileMeta;
11+
use emerald_std::io::FileMeta;
1212

1313
use super::syscall_to_io_error;
1414

@@ -43,7 +43,7 @@ impl FileDesc {
4343
// })?;
4444
// Ok(ret as usize)
4545
let ret = unsafe {
46-
user_std::io::syscall_read(self.0.as_raw_fd(), buf).map_err(syscall_to_io_error)?
46+
emerald_std::io::syscall_read(self.0.as_raw_fd(), buf).map_err(syscall_to_io_error)?
4747
};
4848
Ok(ret as usize)
4949
}
@@ -84,7 +84,7 @@ impl FileDesc {
8484
)
8585
};
8686
let ret = unsafe {
87-
user_std::io::syscall_read(self.0.as_raw_fd(), buf).map_err(syscall_to_io_error)?
87+
emerald_std::io::syscall_read(self.0.as_raw_fd(), buf).map_err(syscall_to_io_error)?
8888
};
8989

9090
// Safety: `ret` bytes were written to the initialized portion of the buffer
@@ -108,7 +108,7 @@ impl FileDesc {
108108
// })?;
109109
// Ok(ret as usize)
110110
let ret = unsafe {
111-
user_std::io::syscall_write(self.0.as_raw_fd(), buf).map_err(syscall_to_io_error)?
111+
emerald_std::io::syscall_write(self.0.as_raw_fd(), buf).map_err(syscall_to_io_error)?
112112
};
113113
Ok(ret as usize)
114114
}
@@ -201,15 +201,15 @@ impl FileDesc {
201201

202202
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
203203
let blocking_mode = if nonblocking {
204-
user_std::io::BlockingMode::None
204+
emerald_std::io::BlockingMode::None
205205
} else {
206206
todo!("Not sure which mode to put here")
207-
// user_std::io::BlockingMode::Line
208-
// user_std::io::BlockingMode::Block(1)
207+
// emerald_std::io::BlockingMode::Line
208+
// emerald_std::io::BlockingMode::Block(1)
209209
};
210210

211211
unsafe {
212-
user_std::io::syscall_set_file_meta(
212+
emerald_std::io::syscall_set_file_meta(
213213
self.as_raw_fd(),
214214
FileMeta::BlockingMode(blocking_mode),
215215
)

library/std/src/sys/emerald/fs.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use core::ffi::CStr;
22

3-
use user_std::io::FileStat;
3+
use emerald_std::io::FileStat;
44

55
use crate::ffi::OsString;
66
use crate::fmt;
@@ -32,7 +32,7 @@ pub struct ReadDir {
3232
}
3333

3434
pub struct DirEntry {
35-
system_entry: user_std::io::DirEntry,
35+
system_entry: emerald_std::io::DirEntry,
3636
parent_path: PathBuf,
3737
}
3838

@@ -45,7 +45,7 @@ pub struct FileTimes {}
4545
pub struct FilePermissions(!);
4646

4747
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
48-
pub struct FileType(user_std::io::FileType);
48+
pub struct FileType(emerald_std::io::FileType);
4949

5050
#[derive(Debug)]
5151
pub struct DirBuilder {}
@@ -113,11 +113,11 @@ impl FileTimes {
113113

114114
impl FileType {
115115
pub fn is_dir(&self) -> bool {
116-
self.0 == user_std::io::FileType::Directory
116+
self.0 == emerald_std::io::FileType::Directory
117117
}
118118

119119
pub fn is_file(&self) -> bool {
120-
self.0 == user_std::io::FileType::File
120+
self.0 == emerald_std::io::FileType::File
121121
}
122122

123123
pub fn is_symlink(&self) -> bool {
@@ -128,7 +128,7 @@ impl FileType {
128128
impl ReadDir {
129129
fn new(path: &Path) -> io::Result<ReadDir> {
130130
let raw_fd = run_path_with_cstr(path, |path| unsafe {
131-
user_std::io::syscall_open_dir(path).map_err(syscall_to_io_error)
131+
emerald_std::io::syscall_open_dir(path).map_err(syscall_to_io_error)
132132
})?;
133133

134134
Ok(ReadDir {
@@ -142,9 +142,9 @@ impl ReadDir {
142142
fn populate_next_entries(&mut self) -> io::Result<bool> {
143143
assert!(self.fetched_entries.is_empty());
144144

145-
let mut entries = [user_std::io::DirEntry::default(); 16];
145+
let mut entries = [emerald_std::io::DirEntry::default(); 16];
146146
let num_entries = unsafe {
147-
user_std::io::syscall_read_dir(self.fd.as_raw_fd(), &mut entries)
147+
emerald_std::io::syscall_read_dir(self.fd.as_raw_fd(), &mut entries)
148148
.map_err(syscall_to_io_error)?
149149
};
150150

@@ -240,7 +240,7 @@ impl File {
240240
let access_mode = 0;
241241

242242
let fd = unsafe {
243-
user_std::io::syscall_open(path, access_mode, flags).map_err(syscall_to_io_error)
243+
emerald_std::io::syscall_open(path, access_mode, flags).map_err(syscall_to_io_error)
244244
}?;
245245

246246
Ok(unsafe { FileDesc::from_raw_fd(fd as usize) })
@@ -428,7 +428,7 @@ pub fn stat(p: &Path) -> io::Result<FileAttr> {
428428
let mut stat = FileStat::default();
429429

430430
unsafe {
431-
user_std::io::syscall_stat(c_path, &mut stat)
431+
emerald_std::io::syscall_stat(c_path, &mut stat)
432432
.map_err(syscall_to_io_error)
433433
.map(|_| FileAttr(stat))
434434
}

library/std/src/sys/emerald/io.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::mem;
22

33
use crate::os::emerald::io::{AsFd, AsRawFd};
44
use crate::sys::emerald::syscall_to_io_error;
5-
use user_std::io::FileMeta;
5+
use emerald_std::io::FileMeta;
66

77
#[derive(Copy, Clone)]
88
pub struct IoSlice<'a>(&'a [u8]);
@@ -53,7 +53,7 @@ impl<'a> IoSliceMut<'a> {
5353
pub fn is_terminal(file: &impl AsFd) -> bool {
5454
let mut meta = FileMeta::IsTerminal(false);
5555
unsafe {
56-
user_std::io::syscall_get_file_meta(file.as_fd().as_raw_fd(), &mut meta)
56+
emerald_std::io::syscall_get_file_meta(file.as_fd().as_raw_fd(), &mut meta)
5757
.map_err(syscall_to_io_error)
5858
.expect("syscall_get_file_meta failed");
5959
}

library/std/src/sys/emerald/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub mod time;
2929
mod common;
3030
pub use common::*;
3131

32-
use user_std::SyscallError;
32+
use emerald_std::SyscallError;
3333

3434
fn syscall_to_io_error(e: SyscallError) -> crate::io::Error {
3535
match e {

library/std/src/sys/emerald/os.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use user_std::SyscallError;
1+
use emerald_std::SyscallError;
22

33
use crate::error::Error as StdError;
44
use crate::ffi::{OsStr, OsString};
@@ -40,7 +40,7 @@ pub fn getcwd() -> io::Result<PathBuf> {
4040
// Safety: the size is equal to the capacity, I'm setting the length so we can access the slice
4141
// its safe to use since the data will be overwritten by getcwd
4242
buf.set_len(buf.capacity());
43-
match user_std::io::syscall_get_cwd(&mut buf) {
43+
match emerald_std::io::syscall_get_cwd(&mut buf) {
4444
Ok(len) => {
4545
// Safety: forcing the length back to the safe space
4646
buf.set_len(len);
@@ -61,7 +61,7 @@ pub fn getcwd() -> io::Result<PathBuf> {
6161

6262
pub fn chdir(p: &path::Path) -> io::Result<()> {
6363
run_path_with_cstr(p, |p| unsafe {
64-
user_std::io::syscall_chdir(p).map_err(syscall_to_io_error)
64+
emerald_std::io::syscall_chdir(p).map_err(syscall_to_io_error)
6565
})
6666
}
6767

@@ -168,7 +168,7 @@ pub fn home_dir() -> Option<PathBuf> {
168168
}
169169

170170
pub fn exit(code: i32) -> ! {
171-
unsafe { user_std::process::exit(code) }
171+
unsafe { emerald_std::process::exit(code) }
172172
}
173173

174174
pub fn getpid() -> u32 {

library/std/src/sys/emerald/pipe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use user_std::io::syscall_create_pipe;
1+
use emerald_std::io::syscall_create_pipe;
22

33
use crate::{
44
io::{self, BorrowedCursor, IoSlice, IoSliceMut},

0 commit comments

Comments
 (0)