Files
RedBear-OS/local/patches/relibc/redox.patch
T

68 lines
2.1 KiB
Diff

diff --git a/src/c/stdlib.c b/src/c/stdlib.c
index 62e98108..a9c72392 100644
--- a/src/c/stdlib.c
+++ b/src/c/stdlib.c
@@ -4,6 +4,13 @@ long double strtold(const char *nptr, char **endptr) {
return (long double)strtod(nptr, endptr);
}
+long double relibc_compat_cpp_strtold(const char *nptr, char **endptr)
+ __asm__("_Z7strtoldPKcPPc");
+
+long double relibc_compat_cpp_strtold(const char *nptr, char **endptr) {
+ return strtold(nptr, endptr);
+}
+
double relibc_ldtod(const long double* val) {
return (double)(*val);
}
diff --git a/src/header/fcntl/mod.rs b/src/header/fcntl/mod.rs
index 6a4db2fa..82484375 100644
--- a/src/header/fcntl/mod.rs
+++ b/src/header/fcntl/mod.rs
@@ -7,6 +7,7 @@ use core::num::NonZeroU64;
use crate::{
c_str::CStr,
error::ResultExt,
+ header::unistd::close,
platform::{
Pal, Sys,
types::{c_char, c_int, c_short, c_ulonglong, mode_t, off_t, pid_t},
@@ -74,5 +75,22 @@ pub unsafe extern "C" fn fcntl(fildes: c_int, cmd: c_int, mut __valist: ...) ->
_ => 0,
};
+ if cmd == F_DUPFD_CLOEXEC {
+ let new_fd = Sys::fcntl(fildes, F_DUPFD_CLOEXEC, arg).or_minus_one_errno();
+ if new_fd >= 0 {
+ return new_fd;
+ }
+
+ let new_fd = Sys::fcntl(fildes, F_DUPFD, arg).or_minus_one_errno();
+ if new_fd < 0 {
+ return -1;
+ }
+ if Sys::fcntl(new_fd, F_SETFD, FD_CLOEXEC as c_ulonglong).or_minus_one_errno() < 0 {
+ let _ = close(new_fd);
+ return -1;
+ }
+ return new_fd;
+ }
+
Sys::fcntl(fildes, cmd, arg).or_minus_one_errno()
}
diff --git a/src/header/fcntl/linux.rs b/src/header/fcntl/linux.rs
index 9a3978dc..906ad525 100644
--- a/src/header/fcntl/linux.rs
+++ b/src/header/fcntl/linux.rs
@@ -15,7 +15,7 @@ pub const O_DIRECTORY: c_int = 0x1_0000;
pub const O_NOFOLLOW: c_int = 0x2_0000;
pub const O_CLOEXEC: c_int = 0x8_0000;
pub const O_PATH: c_int = 0x20_0000;
-pub const FD_CLOEXEC: c_int = 0x8_0000;
+pub const FD_CLOEXEC: c_int = 1;
// Defined for compatibility
pub const O_NDELAY: c_int = O_NONBLOCK;