mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-24 23:53:04 +00:00
rust: Switch to new core::ffi types
CStr is now here. This gets rid of three vendored deps, whee. Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
313547db0f
commit
396d1d7207
9 changed files with 12 additions and 44 deletions
9
.gitmodules
vendored
9
.gitmodules
vendored
|
@ -10,18 +10,9 @@
|
||||||
[submodule "rust/vendor/cfg-if"]
|
[submodule "rust/vendor/cfg-if"]
|
||||||
path = rust/vendor/cfg-if
|
path = rust/vendor/cfg-if
|
||||||
url = https://github.com/alexcrichton/cfg-if
|
url = https://github.com/alexcrichton/cfg-if
|
||||||
[submodule "rust/vendor/cstr_core"]
|
|
||||||
path = rust/vendor/cstr_core
|
|
||||||
url = https://github.com/Amanieu/cstr_core
|
|
||||||
[submodule "rust/vendor/cty"]
|
|
||||||
path = rust/vendor/cty
|
|
||||||
url = https://github.com/japaric/cty
|
|
||||||
[submodule "rust/vendor/uuid"]
|
[submodule "rust/vendor/uuid"]
|
||||||
path = rust/vendor/uuid
|
path = rust/vendor/uuid
|
||||||
url = https://github.com/uuid-rs/uuid
|
url = https://github.com/uuid-rs/uuid
|
||||||
[submodule "rust/vendor/log"]
|
[submodule "rust/vendor/log"]
|
||||||
path = rust/vendor/log
|
path = rust/vendor/log
|
||||||
url = https://github.com/rust-lang/log
|
url = https://github.com/rust-lang/log
|
||||||
[submodule "rust/vendor/memchr"]
|
|
||||||
path = rust/vendor/memchr
|
|
||||||
url = https://github.com/BurntSushi/memchr
|
|
||||||
|
|
18
rust/Cargo.lock
generated
18
rust/Cargo.lock
generated
|
@ -10,18 +10,6 @@ version = "1.3.2"
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cstr_core"
|
|
||||||
version = "0.2.5"
|
|
||||||
dependencies = [
|
|
||||||
"cty",
|
|
||||||
"memchr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cty"
|
|
||||||
version = "0.2.2"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fatfs"
|
name = "fatfs"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
|
@ -37,16 +25,10 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "memchr"
|
|
||||||
version = "2.4.1"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust"
|
name = "rust"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cstr_core",
|
|
||||||
"cty",
|
|
||||||
"fatfs",
|
"fatfs",
|
||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
|
@ -12,15 +12,10 @@ crate-type = [ "staticlib" ]
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
[dependencies]
|
[dependencies]
|
||||||
fatfs = { path = "vendor/rust-fatfs", default-features = false, features = ["lfn", "alloc"] }
|
fatfs = { path = "vendor/rust-fatfs", default-features = false, features = ["lfn", "alloc"] }
|
||||||
cstr_core = "0.2.5"
|
|
||||||
uuid = { version = "1.7.0", default-features = false }
|
uuid = { version = "1.7.0", default-features = false }
|
||||||
cty = "0.2.2"
|
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
uuid = { path = "vendor/uuid" }
|
uuid = { path = "vendor/uuid" }
|
||||||
cty = { path = "vendor/cty" }
|
|
||||||
cstr_core = { path = "vendor/cstr_core" }
|
|
||||||
memchr = { path = "vendor/memchr" }
|
|
||||||
log = { path = "vendor/log" }
|
log = { path = "vendor/log" }
|
||||||
bitflags = { path = "vendor/bitflags" }
|
bitflags = { path = "vendor/bitflags" }
|
||||||
cfg-if = { path = "vendor/cfg-if" }
|
cfg-if = { path = "vendor/cfg-if" }
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
#![deny(unsafe_op_in_unsafe_fn)]
|
#![deny(unsafe_op_in_unsafe_fn)]
|
||||||
|
|
||||||
|
use crate::c_size_t;
|
||||||
use crate::gpt;
|
use crate::gpt;
|
||||||
use crate::nvme;
|
use crate::nvme;
|
||||||
use crate::println;
|
use crate::println;
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use core::ffi::c_void;
|
use core::ffi::{c_char, c_int, c_void, CStr};
|
||||||
use cstr_core::CStr;
|
|
||||||
use cty::*;
|
|
||||||
use fatfs::{FileSystem, FsOptions, Read, Seek, SeekFrom};
|
use fatfs::{FileSystem, FsOptions, Read, Seek, SeekFrom};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
@ -81,7 +80,7 @@ fn load_image(spec: &str) -> Result<Vec<u8>, Error> {
|
||||||
pub unsafe extern "C" fn rust_load_image(
|
pub unsafe extern "C" fn rust_load_image(
|
||||||
raw_spec: *const c_char,
|
raw_spec: *const c_char,
|
||||||
image: *mut *mut c_void,
|
image: *mut *mut c_void,
|
||||||
size: *mut size_t,
|
size: *mut c_size_t,
|
||||||
) -> c_int {
|
) -> c_int {
|
||||||
let spec = unsafe { CStr::from_ptr(raw_spec).to_str().unwrap() };
|
let spec = unsafe { CStr::from_ptr(raw_spec).to_str().unwrap() };
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
use crate::c_size_t;
|
||||||
use core::alloc::{GlobalAlloc, Layout};
|
use core::alloc::{GlobalAlloc, Layout};
|
||||||
use core::ffi::c_void;
|
use core::ffi::{c_int, c_void};
|
||||||
use core::ptr;
|
use core::ptr;
|
||||||
use cty::*;
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn malloc(size: size_t) -> *mut c_void;
|
pub fn malloc(size: c_size_t) -> *mut c_void;
|
||||||
pub fn realloc_in_place(p: *mut c_void, size: size_t) -> *mut c_void;
|
pub fn realloc_in_place(p: *mut c_void, size: c_size_t) -> *mut c_void;
|
||||||
pub fn free(p: *mut c_void);
|
pub fn free(p: *mut c_void);
|
||||||
pub fn posix_memalign(p: *mut *mut c_void, alignment: size_t, size: size_t) -> c_int;
|
pub fn posix_memalign(p: *mut *mut c_void, alignment: c_size_t, size: c_size_t) -> c_int;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DLMalloc;
|
pub struct DLMalloc;
|
||||||
|
|
|
@ -15,6 +15,10 @@ pub mod print;
|
||||||
|
|
||||||
use crate::dlmalloc::DLMalloc;
|
use crate::dlmalloc::DLMalloc;
|
||||||
|
|
||||||
|
// This is unstable in core::ffi, let's just declare it ourselves
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
type c_size_t = usize;
|
||||||
|
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL: DLMalloc = dlmalloc::DLMalloc;
|
static GLOBAL: DLMalloc = dlmalloc::DLMalloc;
|
||||||
|
|
||||||
|
|
1
rust/vendor/cstr_core
vendored
1
rust/vendor/cstr_core
vendored
|
@ -1 +0,0 @@
|
||||||
Subproject commit 35e44d2a128f29a52ac0a43baa2d9238bd7239dd
|
|
1
rust/vendor/cty
vendored
1
rust/vendor/cty
vendored
|
@ -1 +0,0 @@
|
||||||
Subproject commit dcc347dc8afb74906719e68e2f48e3ff38dcc76f
|
|
1
rust/vendor/memchr
vendored
1
rust/vendor/memchr
vendored
|
@ -1 +0,0 @@
|
||||||
Subproject commit 8e1da98fee06d66c13e66c330e3a3dd6ccf0e3a0
|
|
Loading…
Reference in a new issue