Skip to content

Commit 962b984

Browse files
committed
FreeBSD: new rand()/srand() ABI in 13
https://reviews.freebsd.org/rS357382
1 parent 9fc2574 commit 962b984

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
@@ -322,7 +322,14 @@ pub const EXTATTR_NAMESPACE_EMPTY: ::c_int = 0;
322322
pub const EXTATTR_NAMESPACE_USER: ::c_int = 1;
323323
pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2;
324324

325-
pub const RAND_MAX: ::c_int = 0x7fff_fffd;
325+
cfg_if! {
326+
if #[cfg(any(freebsd10, freebsd11, freebsd12))] {
327+
pub const RAND_MAX: ::c_int = 0x7fff_fffd;
328+
} else {
329+
pub const RAND_MAX: ::c_int = 0x7fff_ffff;
330+
}
331+
}
332+
326333
pub const PTHREAD_STACK_MIN: ::size_t = MINSIGSTKSZ;
327334
pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 4;
328335
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)