Skip to content

Commit 0e3de1a

Browse files
committed
Remove c_int and c_void from root
These were exported for some weird reason and then left in for documentation. Also some parts of certain modules used them and others used the libc:: prefix. This was removed to improve the docs and also code consistency
1 parent fc5f0bd commit 0e3de1a

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ pub mod libc {
3131
pub use self::libc::*;
3232
}
3333

34-
pub use libc::{c_int, c_void};
3534
pub use errno::Errno;
3635

3736
pub mod errno;
@@ -96,7 +95,7 @@ pub enum Error {
9695
/// The operation involved a conversion to Rust's native String type, which failed because the
9796
/// string did not contain all valid UTF-8.
9897
InvalidUtf8,
99-
/// The operation is not supported by Nix, in this instance either use the libc bindings or
98+
/// The operation is not supported by Nix, in this instance either use the libc bindings or
10099
/// consult the module documentation to see if there is a more appropriate interface available.
101100
UnsupportedOperation,
102101
}

src/sys/aio.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl<'a> AioCb<'a> {
9494
/// be prioritized at the process's priority level minus `prio`
9595
/// * `sigev_notify` Determines how you will be notified of event
9696
/// completion.
97-
pub fn from_fd(fd: RawFd, prio: ::c_int,
97+
pub fn from_fd(fd: RawFd, prio: libc::c_int,
9898
sigev_notify: SigevNotify) -> AioCb<'a> {
9999
let mut a = AioCb::common_init(fd, prio, sigev_notify);
100100
a.aio_offset = 0;
@@ -118,13 +118,13 @@ impl<'a> AioCb<'a> {
118118
/// * `opcode` This field is only used for `lio_listio`. It determines
119119
/// which operation to use for this individual aiocb
120120
pub fn from_mut_slice(fd: RawFd, offs: off_t, buf: &'a mut [u8],
121-
prio: ::c_int, sigev_notify: SigevNotify,
121+
prio: libc::c_int, sigev_notify: SigevNotify,
122122
opcode: LioOpcode) -> AioCb<'a> {
123123
let mut a = AioCb::common_init(fd, prio, sigev_notify);
124124
a.aio_offset = offs;
125125
a.aio_nbytes = buf.len() as size_t;
126126
a.aio_buf = buf.as_ptr() as *mut c_void;
127-
a.aio_lio_opcode = opcode as ::c_int;
127+
a.aio_lio_opcode = opcode as libc::c_int;
128128

129129
let aiocb = AioCb { aiocb: a, mutable: true, in_progress: false,
130130
keeper: Keeper::phantom(PhantomData)};
@@ -146,13 +146,13 @@ impl<'a> AioCb<'a> {
146146
/// * `opcode` This field is only used for `lio_listio`. It determines
147147
/// which operation to use for this individual aiocb
148148
pub fn from_boxed_slice(fd: RawFd, offs: off_t, buf: Rc<Box<[u8]>>,
149-
prio: ::c_int, sigev_notify: SigevNotify,
149+
prio: libc::c_int, sigev_notify: SigevNotify,
150150
opcode: LioOpcode) -> AioCb<'a> {
151151
let mut a = AioCb::common_init(fd, prio, sigev_notify);
152152
a.aio_offset = offs;
153153
a.aio_nbytes = buf.len() as size_t;
154154
a.aio_buf = buf.as_ptr() as *mut c_void;
155-
a.aio_lio_opcode = opcode as ::c_int;
155+
a.aio_lio_opcode = opcode as libc::c_int;
156156

157157
let aiocb = AioCb{ aiocb: a, mutable: true, in_progress: false,
158158
keeper: Keeper::boxed(buf)};
@@ -173,7 +173,7 @@ impl<'a> AioCb<'a> {
173173
// AioCb, and they must all be the same type. We're basically stuck with
174174
// using an unsafe function, since aio (as designed in C) is an unsafe API.
175175
pub fn from_slice(fd: RawFd, offs: off_t, buf: &'a [u8],
176-
prio: ::c_int, sigev_notify: SigevNotify,
176+
prio: libc::c_int, sigev_notify: SigevNotify,
177177
opcode: LioOpcode) -> AioCb {
178178
let mut a = AioCb::common_init(fd, prio, sigev_notify);
179179
a.aio_offset = offs;
@@ -183,14 +183,14 @@ impl<'a> AioCb<'a> {
183183
// it.
184184
a.aio_buf = buf.as_ptr() as *mut c_void;
185185
assert!(opcode != LioOpcode::LIO_READ, "Can't read into an immutable buffer");
186-
a.aio_lio_opcode = opcode as ::c_int;
186+
a.aio_lio_opcode = opcode as libc::c_int;
187187

188188
let aiocb = AioCb { aiocb: a, mutable: false, in_progress: false,
189189
keeper: Keeper::none};
190190
aiocb
191191
}
192192

193-
fn common_init(fd: RawFd, prio: ::c_int,
193+
fn common_init(fd: RawFd, prio: libc::c_int,
194194
sigev_notify: SigevNotify) -> libc::aiocb {
195195
// Use mem::zeroed instead of explicitly zeroing each field, because the
196196
// number and name of reserved fields is OS-dependent. On some OSes,
@@ -235,7 +235,7 @@ impl<'a> AioCb<'a> {
235235
pub fn fsync(&mut self, mode: AioFsyncMode) -> Result<()> {
236236
let p: *mut libc::aiocb = &mut self.aiocb;
237237
self.in_progress = true;
238-
Errno::result(unsafe { libc::aio_fsync(mode as ::c_int, p) }).map(drop)
238+
Errno::result(unsafe { libc::aio_fsync(mode as libc::c_int, p) }).map(drop)
239239
}
240240

241241
/// Asynchronously reads from a file descriptor into a buffer

src/sys/event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct KEvent {
2121
#[cfg(any(target_os = "openbsd", target_os = "freebsd",
2222
target_os = "dragonfly", target_os = "macos",
2323
target_os = "ios"))]
24-
type type_of_udata = *mut ::c_void;
24+
type type_of_udata = *mut libc::c_void;
2525
#[cfg(any(target_os = "openbsd", target_os = "freebsd",
2626
target_os = "dragonfly", target_os = "macos",
2727
target_os = "ios"))]
@@ -127,7 +127,7 @@ libc_bitflags!(
127127
#[cfg(any(target_os = "macos", target_os = "ios"))]
128128
NOTE_EXITSTATUS,
129129
NOTE_EXTEND,
130-
#[cfg(any(target_os = "macos",
130+
#[cfg(any(target_os = "macos",
131131
target_os = "ios",
132132
target_os = "freebsd",
133133
target_os = "dragonfly"))]

src/sys/signal.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -523,20 +523,20 @@ impl SigEvent {
523523
SigevNotify::SigevThreadId{..} => 4 // No SIGEV_THREAD_ID defined
524524
};
525525
sev.sigev_signo = match sigev_notify {
526-
SigevNotify::SigevSignal{ signal, .. } => signal as ::c_int,
526+
SigevNotify::SigevSignal{ signal, .. } => signal as libc::c_int,
527527
#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
528528
SigevNotify::SigevKevent{ kq, ..} => kq,
529529
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
530-
SigevNotify::SigevThreadId{ signal, .. } => signal as ::c_int,
530+
SigevNotify::SigevThreadId{ signal, .. } => signal as libc::c_int,
531531
_ => 0
532532
};
533533
sev.sigev_value.sival_ptr = match sigev_notify {
534534
SigevNotify::SigevNone => ptr::null_mut::<libc::c_void>(),
535-
SigevNotify::SigevSignal{ si_value, .. } => si_value as *mut ::c_void,
535+
SigevNotify::SigevSignal{ si_value, .. } => si_value as *mut libc::c_void,
536536
#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
537-
SigevNotify::SigevKevent{ udata, .. } => udata as *mut ::c_void,
537+
SigevNotify::SigevKevent{ udata, .. } => udata as *mut libc::c_void,
538538
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
539-
SigevNotify::SigevThreadId{ si_value, .. } => si_value as *mut ::c_void,
539+
SigevNotify::SigevThreadId{ si_value, .. } => si_value as *mut libc::c_void,
540540
};
541541
SigEvent::set_tid(&mut sev, &sigev_notify);
542542
SigEvent{sigevent: sev}

0 commit comments

Comments
 (0)