Skip to content

Commit 672e9d6

Browse files
committed
Changed SeekData and SeekHole hardcoded values to libc ones and
added availability only to linux freebsd and dragonflybsd.
1 parent 5759ba7 commit 672e9d6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/unistd.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,12 +750,14 @@ pub enum Whence {
750750
/// Specify an offset relative to the next location in the file greater than or
751751
/// equal to offset that contains some data. If offset points to
752752
/// some data, then the file offset is set to offset.
753+
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))]
753754
SeekData,
754755
/// Specify an offset relative to the next hole in the file greater than
755756
/// or equal to offset. If offset points into the middle of a hole, then
756757
/// the file offset should be set to offset. If there is no hole past offset,
757758
/// then the file offset should be adjusted to the end of the file (i.e., there
758759
/// is an implicit hole at the end of any file).
760+
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))]
759761
SeekHole
760762
}
761763

@@ -765,8 +767,10 @@ impl Whence {
765767
&Whence::SeekSet => libc::SEEK_SET,
766768
&Whence::SeekCur => libc::SEEK_CUR,
767769
&Whence::SeekEnd => libc::SEEK_END,
768-
&Whence::SeekData => 3,
769-
&Whence::SeekHole => 4
770+
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))]
771+
&Whence::SeekData => libc::SEEK_DATA,
772+
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"))]
773+
&Whence::SeekHole => libc::SEEK_HOLE
770774
}
771775
}
772776

0 commit comments

Comments
 (0)