Browse Source

Merge pull request #4 from AzureMarker/master

Add init method to force linking, and other changes
pull/5/head
Meziu 3 years ago committed by GitHub
parent
commit
a554d6d9e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      Cargo.toml
  2. 17
      src/lib.rs

9
Cargo.toml

@ -5,10 +5,5 @@ version = "0.1.0"
license = "MIT/Apache 2.0" license = "MIT/Apache 2.0"
edition = "2018" edition = "2018"
[lib] [dependencies]
name = "linker_fix_3ds" libc = { git = "https://github.com/Meziu/libc.git" }
path = "src/lib.rs"
crate-type = ["staticlib", "lib"]
[dependencies.libc]
git = "https://github.com/Meziu/libc.git"

17
src/lib.rs

@ -1,7 +1,19 @@
#![no_std]
extern crate libc; extern crate libc;
/// Call this somewhere to force Rust to link this module.
/// The call doesn't need to execute, just exist.
///
/// See https://github.com/rust-lang/rust/issues/47384
pub fn init() {}
#[no_mangle] #[no_mangle]
extern "C" fn posix_memalign(memptr: *mut *mut libc::c_void, align: libc::size_t, size: libc::size_t) -> libc::c_int { extern "C" fn posix_memalign(
memptr: *mut *mut libc::c_void,
align: libc::size_t,
size: libc::size_t,
) -> libc::c_int {
unsafe { unsafe {
*memptr = libc::memalign(align, size); *memptr = libc::memalign(align, size);
} }
@ -9,11 +21,10 @@ extern "C" fn posix_memalign(memptr: *mut *mut libc::c_void, align: libc::size_t
0 0
} }
#[no_mangle] #[no_mangle]
unsafe extern "C" fn realpath( unsafe extern "C" fn realpath(
path: *const libc::c_char, path: *const libc::c_char,
resolved_path: *mut libc::c_char resolved_path: *mut libc::c_char,
) -> *mut libc::c_char { ) -> *mut libc::c_char {
libc::memcpy(resolved_path as _, path as _, libc::strlen(path)); libc::memcpy(resolved_path as _, path as _, libc::strlen(path));

Loading…
Cancel
Save