Skip to content

Commit cca407c

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 cca407c

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/unix/mod.rs

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

1070-
pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
1070+
cfg_if! {
1071+
if #[cfg(not(target_os = "solaris"))] {
1072+
pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
1073+
}
1074+
}
10711075

10721076
#[cfg_attr(target_os = "netbsd", link_name = "__times13")]
10731077
pub fn times(buf: *mut ::tms) -> ::clock_t;

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)