-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
155 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[unstable] | ||
patch-in-config = true | ||
|
||
[build] | ||
rustc = "@BUILD_ROOT@/tools/host-rust/bin/rustc" | ||
target = "x86_64-unknown-managarm-system" | ||
|
||
[target.x86_64-unknown-managarm-system] | ||
linker = "@BUILD_ROOT@/tools/system-gcc/bin/x86_64-managarm-gcc" | ||
|
||
[patch.crates-io] | ||
libc = { path = "@SRC_ROOT@/ports/rust-libc" } | ||
num_cpus = { path = "@SRC_ROOT@/ports/rust-num-cpus" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
patches/rust-libc/0002-managarm-Add-missing-glue-for-memmap-and-num_cpus.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
From 048651aee5a4d29f174c27446abc546fab2f250c Mon Sep 17 00:00:00 2001 | ||
From: Matt Taylor <mstaveleytaylor@gmail.com> | ||
Date: Sat, 8 May 2021 19:33:53 +0100 | ||
Subject: [PATCH 2/2] managarm: Add missing glue for memmap and num_cpus | ||
|
||
--- | ||
src/unix/mlibc/mod.rs | 16 ++++++++++++++++ | ||
1 file changed, 16 insertions(+) | ||
|
||
diff --git a/src/unix/mlibc/mod.rs b/src/unix/mlibc/mod.rs | ||
index 51b9ee9..28dc0f0 100644 | ||
--- a/src/unix/mlibc/mod.rs | ||
+++ b/src/unix/mlibc/mod.rs | ||
@@ -19,6 +19,19 @@ pub type socklen_t = ::c_ulong; | ||
// options/internal/include/bits/off_t.h | ||
pub type off_t = ::c_long; | ||
|
||
+// abis/mlibc/vm-flags.h | ||
+pub const MAP_ANON: ::c_int = 8; | ||
+pub const MAP_PRIVATE: ::c_int = 1; | ||
+pub const MAP_SHARED: ::c_int = 2; | ||
+pub const PROT_EXEC: ::c_int = 4; | ||
+pub const PROT_READ: ::c_int = 1; | ||
+pub const PROT_WRITE: ::c_int = 2; | ||
+ | ||
+// options/posix/include/sys/mman.h | ||
+pub const MAP_FAILED: *mut ::c_void = usize::MAX as *mut ::c_void; | ||
+pub const MS_ASYNC: ::c_int = 1; | ||
+pub const MS_SYNC: ::c_int = 2; | ||
+ | ||
// options/ansi/include/time.h | ||
pub const CLOCK_MONOTONIC: clockid_t = 1; | ||
pub const CLOCK_REALTIME: clockid_t = 0; | ||
@@ -151,6 +164,7 @@ pub const STDERR_FILENO: ::c_int = 2; | ||
pub const STDIN_FILENO: ::c_int = 0; | ||
pub const STDOUT_FILENO: ::c_int = 1; | ||
pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 1; | ||
+pub const _SC_NPROCESSORS_ONLN: ::c_int = 6; | ||
pub const _SC_PAGESIZE: ::c_int = _SC_PAGE_SIZE; | ||
pub const _SC_PAGE_SIZE: ::c_int = 3; | ||
|
||
@@ -521,6 +535,8 @@ extern "C" { | ||
result: *mut *mut passwd, | ||
) -> ::c_int; | ||
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; | ||
+ pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; | ||
+ pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; | ||
pub fn pthread_condattr_setclock( | ||
attr: *mut pthread_condattr_t, | ||
clock_id: ::clockid_t, | ||
-- | ||
2.31.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
From 4b2069349810204ec0cd3e2d8c7fef3e71833d06 Mon Sep 17 00:00:00 2001 | ||
From: Matt Taylor <mstaveleytaylor@gmail.com> | ||
Date: Fri, 7 May 2021 19:16:06 +0100 | ||
Subject: [PATCH] managarm: Initial port | ||
|
||
--- | ||
src/lib.rs | 8 ++++++++ | ||
1 file changed, 8 insertions(+) | ||
|
||
diff --git a/src/lib.rs b/src/lib.rs | ||
index 6c8280f..d911c49 100644 | ||
--- a/src/lib.rs | ||
+++ b/src/lib.rs | ||
@@ -254,6 +254,13 @@ fn get_num_cpus() -> usize { | ||
cpus as usize | ||
} | ||
|
||
+#[cfg(target_os = "managarm")] | ||
+fn get_num_cpus() -> usize { | ||
+ unsafe { | ||
+ libc::sysconf(libc::_SC_NPROCESSORS_ONLN) as usize | ||
+ } | ||
+} | ||
+ | ||
#[cfg(target_os = "openbsd")] | ||
fn get_num_cpus() -> usize { | ||
use std::ptr; | ||
@@ -420,6 +427,7 @@ fn get_num_cpus() -> usize { | ||
target_os = "netbsd", | ||
target_os = "haiku", | ||
target_os = "hermit", | ||
+ target_os = "managarm", | ||
windows, | ||
)))] | ||
fn get_num_cpus() -> usize { | ||
-- | ||
2.31.1 | ||
|