Skip to content

Commit

Permalink
Indicate weak linkage for symbols
Browse files Browse the repository at this point in the history
The items marked weak here are exactly those marked weak in musl.
  • Loading branch information
mrhota committed Feb 6, 2017
1 parent dbfe4f0 commit d985404
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub unsafe fn mremap_helper(old_address: *mut c_void,
syscall!(MREMAP, old_address, old_len, new_len, flags, new_address) as *mut c_void
}

#[cfg_attr(all(feature = "weak", not(windows), not(target_os = "macos")), linkage = "weak")]
#[no_mangle]
pub unsafe extern "C" fn madvise(address: *mut c_void, len: usize, advice: c_int) -> c_int {
syscall!(MADVISE, address, len, advice) as c_int
Expand All @@ -99,9 +100,11 @@ pub unsafe extern "C" fn mlockall(flags: c_int) -> c_int { syscall!(MLOCKALL, fl


// aliases
#[cfg_attr(all(feature = "weak", not(windows), not(target_os = "macos")), linkage = "weak")]
#[no_mangle]
pub unsafe extern "C" fn munmap(start: *mut c_void, len: size_t) -> c_int { __munmap(start, len) }

#[cfg_attr(all(feature = "weak", not(windows), not(target_os = "macos")), linkage = "weak")]
#[no_mangle]
pub unsafe extern "C" fn mmap(start: *mut c_void,
len: size_t,
Expand All @@ -113,6 +116,7 @@ pub unsafe extern "C" fn mmap(start: *mut c_void,
__mmap(start, len, prot, flags, fd, off)
}

#[cfg_attr(all(feature = "weak", not(windows), not(target_os = "macos")), linkage = "weak")]
#[no_mangle]
pub unsafe extern "C" fn mmap64(start: *mut c_void,
len: size_t,
Expand All @@ -124,6 +128,7 @@ pub unsafe extern "C" fn mmap64(start: *mut c_void,
__mmap(start, len, prot, flags, fd, off)
}

#[cfg_attr(all(feature = "weak", not(windows), not(target_os = "macos")), linkage = "weak")]
#[no_mangle]
pub unsafe extern "C" fn mremap(old_address: *mut c_void,
old_len: size_t,
Expand Down
1 change: 1 addition & 0 deletions src/string/stpcpy.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use c_types::*;

#[cfg_attr(all(feature = "weak", not(windows), not(target_os = "macos")), linkage = "weak")]
#[no_mangle]
pub unsafe extern "C" fn stpcpy(dest: *mut c_schar, source: *const c_schar) -> *mut c_schar {
// TODO(adam) compare and copy as word-size chunks
Expand Down
1 change: 1 addition & 0 deletions src/thread/vmlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use thread::{__wait, __wake};

static mut LOCK: [c_int; 2] = [0, 0];

#[cfg_attr(all(feature = "weak", not(windows), not(target_os = "macos")), linkage = "weak")]
#[no_mangle]
pub unsafe extern "C" fn __vm_wait() {
let mut tmp = LOCK[0];
Expand Down
1 change: 1 addition & 0 deletions src/time/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub unsafe extern "C" fn __clock_gettime(clock: clockid_t, spec: &mut timespec)
clock_gettime(clock, spec)
}

#[cfg_attr(all(feature = "weak", not(windows), not(target_os = "macos")), linkage = "weak")]
#[no_mangle]
pub unsafe extern "C" fn clock_gettime(clock: clockid_t, spec: &mut timespec) -> c_int {
let mut r = syscall!(CLOCK_GETTIME, clock, spec as *mut timespec) as c_int;
Expand Down

0 comments on commit d985404

Please sign in to comment.