Skip to content

Commit 8531a0c

Browse files
committed
FreeBSD: new rand()/srand() ABI in 13
https://reviews.freebsd.org/rS357382
1 parent 6dc32e3 commit 8531a0c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/unix/bsd/freebsdlike/freebsd/mod.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,14 @@ pub const EXTATTR_NAMESPACE_EMPTY: ::c_int = 0;
335335
pub const EXTATTR_NAMESPACE_USER: ::c_int = 1;
336336
pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2;
337337

338-
pub const RAND_MAX: ::c_int = 0x7fff_fffd;
338+
cfg_if! {
339+
if #[cfg(any(freebsd10, freebsd11, freebsd12))] {
340+
pub const RAND_MAX: ::c_int = 0x7fff_fffd;
341+
} else {
342+
pub const RAND_MAX: ::c_int = 0x7fff_ffff;
343+
}
344+
}
345+
339346
pub const PTHREAD_STACK_MIN: ::size_t = MINSIGSTKSZ;
340347
pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 4;
341348
pub const SIGSTKSZ: ::size_t = MINSIGSTKSZ + 32768;

src/unix/bsd/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,15 @@ extern "C" {
580580
pub fn abs(i: ::c_int) -> ::c_int;
581581
pub fn atof(s: *const ::c_char) -> ::c_double;
582582
pub fn labs(i: ::c_long) -> ::c_long;
583+
#[cfg_attr(
584+
all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)),
585+
link_name = "rand@FBSD_1.0"
586+
)]
583587
pub fn rand() -> ::c_int;
588+
#[cfg_attr(
589+
all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)),
590+
link_name = "srand@FBSD_1.0"
591+
)]
584592
pub fn srand(seed: ::c_uint);
585593

586594
pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;

0 commit comments

Comments
 (0)