summaryrefslogtreecommitdiff
path: root/src/sys/aio.rs
diff options
context:
space:
mode:
authorWolfgang Ginolas <wolfgang.ginolas@gwif.eu>2017-11-05 19:43:16 +0100
committerWolfgang Ginolas <wolfgang.ginolas@gwif.eu>2017-11-05 21:23:21 +0100
commit718bd9d75ec948afe211b4b49935044ab2004822 (patch)
tree52086f14aa3b202a98d46fb766f615c07544c8ec /src/sys/aio.rs
parentba9ee75ec0333f66d25b09d5c18bbaefac23714f (diff)
downloadnix-718bd9d75ec948afe211b4b49935044ab2004822.zip
Use libc_enum! where possible
Some enums which use different names for values than libc still set the discriminators manually. closes #254
Diffstat (limited to 'src/sys/aio.rs')
-rw-r--r--src/sys/aio.rs59
1 files changed, 31 insertions, 28 deletions
diff --git a/src/sys/aio.rs b/src/sys/aio.rs
index 4be0da7b..bfb0d9b2 100644
--- a/src/sys/aio.rs
+++ b/src/sys/aio.rs
@@ -13,38 +13,41 @@ use sys::time::TimeSpec;
/// Mode for `AioCb::fsync`. Controls whether only data or both data and
/// metadata are synced.
-#[repr(i32)]
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum AioFsyncMode {
- /// do it like `fsync`
- O_SYNC = libc::O_SYNC,
- /// on supported operating systems only, do it like `fdatasync`
- #[cfg(any(target_os = "openbsd", target_os = "bitrig",
- target_os = "netbsd", target_os = "macos", target_os = "ios",
- target_os = "linux"))]
- O_DSYNC = libc::O_DSYNC
+libc_enum! {
+ #[repr(i32)]
+ pub enum AioFsyncMode {
+ /// do it like `fsync`
+ O_SYNC,
+ /// on supported operating systems only, do it like `fdatasync`
+ #[cfg(any(target_os = "openbsd", target_os = "bitrig",
+ target_os = "netbsd", target_os = "macos", target_os = "ios",
+ target_os = "linux"))]
+ O_DSYNC
+ }
}
-/// When used with `lio_listio`, determines whether a given `aiocb` should be
-/// used for a read operation, a write operation, or ignored. Has no effect for
-/// any other aio functions.
-#[repr(i32)]
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum LioOpcode {
- LIO_NOP = libc::LIO_NOP,
- LIO_WRITE = libc::LIO_WRITE,
- LIO_READ = libc::LIO_READ
+libc_enum! {
+ /// When used with `lio_listio`, determines whether a given `aiocb` should be
+ /// used for a read operation, a write operation, or ignored. Has no effect for
+ /// any other aio functions.
+ #[repr(i32)]
+ pub enum LioOpcode {
+ LIO_NOP,
+ LIO_WRITE,
+ LIO_READ,
+ }
}
-/// Mode for `lio_listio`.
-#[repr(i32)]
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub enum LioMode {
- /// Requests that `lio_listio` block until all requested operations have
- /// been completed
- LIO_WAIT = libc::LIO_WAIT,
- /// Requests that `lio_listio` return immediately
- LIO_NOWAIT = libc::LIO_NOWAIT,
+libc_enum! {
+ /// Mode for `lio_listio`.
+ #[repr(i32)]
+ pub enum LioMode {
+ /// Requests that `lio_listio` block until all requested operations have
+ /// been completed
+ LIO_WAIT,
+ /// Requests that `lio_listio` return immediately
+ LIO_NOWAIT,
+ }
}
/// Return values for `AioCb::cancel and aio_cancel_all`