Skip to content

Commit 244e960

Browse files
author
Alex Zepeda
committed
Solaris doesn't include a flock function
Disable the flock wrapper and related consts on Solaris, but leave them in place for OpenSolaris derivatives like Illumos which do have a BSD-esque flock.
1 parent 28ab9b9 commit 244e960

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/unix/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,7 @@ extern "C" {
10671067
)]
10681068
pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) -> *mut ::c_char;
10691069

1070+
#[cfg(not(target_os = "solaris"))]
10701071
pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
10711072

10721073
#[cfg_attr(target_os = "netbsd", link_name = "__times13")]

src/unix/solarish/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,10 +1915,16 @@ pub const SHUT_RD: ::c_int = 0;
19151915
pub const SHUT_WR: ::c_int = 1;
19161916
pub const SHUT_RDWR: ::c_int = 2;
19171917

1918-
pub const LOCK_SH: ::c_int = 1;
1919-
pub const LOCK_EX: ::c_int = 2;
1920-
pub const LOCK_NB: ::c_int = 4;
1921-
pub const LOCK_UN: ::c_int = 8;
1918+
// These don't exist on Solaris, but do on OpenSolaris derivatives
1919+
// e.g. https://illumos.org/man/3C/flock
1920+
cfg_if! {
1921+
if #[cfg(not(target_os = "solaris"))] {
1922+
pub const LOCK_SH: ::c_int = 1;
1923+
pub const LOCK_EX: ::c_int = 2;
1924+
pub const LOCK_NB: ::c_int = 4;
1925+
pub const LOCK_UN: ::c_int = 8;
1926+
}
1927+
}
19221928

19231929
pub const F_RDLCK: ::c_short = 1;
19241930
pub const F_WRLCK: ::c_short = 2;

0 commit comments

Comments
 (0)