Skip to content

Commit 3206127

Browse files
committed
Fix style
1 parent b54e313 commit 3206127

File tree

2 files changed

+64
-62
lines changed

2 files changed

+64
-62
lines changed

src/unix/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,11 @@ pub const DT_REG: u8 = 8;
223223
pub const DT_LNK: u8 = 10;
224224
pub const DT_SOCK: u8 = 12;
225225

226-
#[cfg(not(target_os = "redox"))]
227-
pub const FD_CLOEXEC: ::c_int = 0x1;
226+
cfg_if! {
227+
if #[cfg(not(target_os = "redox"))] {
228+
pub const FD_CLOEXEC: ::c_int = 0x1;
229+
}
230+
}
228231

229232
pub const USRQUOTA: ::c_int = 0;
230233
pub const GRPQUOTA: ::c_int = 1;

src/unix/redox/mod.rs

Lines changed: 59 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ pub type pthread_t = *mut ::c_void;
1919
pub type pthread_attr_t = *mut ::c_void;
2020
pub type pthread_cond_t = *mut ::c_void;
2121
pub type pthread_condattr_t = *mut ::c_void;
22-
// Must be usize due to libstd/sys_common/thread_local.rs, should be *mut ::c_void
22+
// Must be usize due to libstd/sys_common/thread_local.rs,
23+
// should technically be *mut ::c_void
2324
pub type pthread_key_t = usize;
2425
pub type pthread_mutex_t = *mut ::c_void;
2526
pub type pthread_mutexattr_t = *mut ::c_void;
@@ -143,7 +144,9 @@ s! {
143144
pub ss_family: ::sa_family_t,
144145
__ss_padding: [
145146
u8;
146-
128 - ::core::mem::size_of::<sa_family_t>() - ::core::mem::size_of::<c_ulong>()
147+
128 -
148+
::core::mem::size_of::<sa_family_t>() -
149+
::core::mem::size_of::<c_ulong>()
147150
],
148151
__ss_align: ::c_ulong,
149152
}
@@ -302,11 +305,6 @@ pub const O_SYMLINK: ::c_int = 0x4000_0000;
302305
// TODO: Fix negative values missing from includes
303306
pub const O_NOFOLLOW: ::c_int = -0x8000_0000;
304307

305-
// malloc.h
306-
extern {
307-
pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
308-
}
309-
310308
// netdb.h
311309
pub const EAI_SYSTEM: ::c_int = -11;
312310

@@ -348,19 +346,6 @@ pub const PTHREAD_MUTEX_INITIALIZER: ::pthread_mutex_t = -1isize as *mut _;
348346
pub const PTHREAD_COND_INITIALIZER: ::pthread_cond_t = -1isize as *mut _;
349347
pub const PTHREAD_RWLOCK_INITIALIZER: ::pthread_rwlock_t = -1isize as *mut _;
350348
pub const PTHREAD_STACK_MIN : ::size_t = 4096;
351-
extern {
352-
pub fn pthread_atfork(prepare: ::Option<unsafe extern fn()>,
353-
parent: ::Option<unsafe extern fn()>,
354-
child: ::Option<unsafe extern fn()>) -> ::c_int;
355-
pub fn pthread_create(tid: *mut ::pthread_t,
356-
attr: *const ::pthread_attr_t,
357-
start: extern fn(*mut ::c_void) -> *mut ::c_void,
358-
arg: *mut ::c_void) -> ::c_int;
359-
// TODO: relibc {
360-
pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t,
361-
clock_id: ::clockid_t) -> ::c_int;
362-
// }
363-
}
364349

365350
// signal.h
366351
pub const SIG_BLOCK: ::c_int = 0;
@@ -398,11 +383,6 @@ pub const SIGIO: ::c_int = 29;
398383
pub const SIGPWR: ::c_int = 30;
399384
pub const SIGSYS: ::c_int = 31;
400385
pub const NSIG: ::c_int = 32;
401-
extern {
402-
pub fn pthread_sigmask(how: ::c_int,
403-
set: *const ::sigset_t,
404-
oldset: *mut ::sigset_t) -> ::c_int;
405-
}
406386

407387
// sys/epoll.h
408388
pub const EPOLL_CLOEXEC: ::c_int = 0x0100_0000;
@@ -425,18 +405,6 @@ pub const EPOLLEXCLUSIVE: ::c_int = 0;
425405
pub const EPOLLWAKEUP: ::c_int = 0;
426406
pub const EPOLLONESHOT: ::c_int = 0;
427407
pub const EPOLLET: ::c_int = 0;
428-
extern {
429-
pub fn epoll_create(size: ::c_int) -> ::c_int;
430-
pub fn epoll_create1(flags: ::c_int) -> ::c_int;
431-
pub fn epoll_wait(epfd: ::c_int,
432-
events: *mut ::epoll_event,
433-
maxevents: ::c_int,
434-
timeout: ::c_int) -> ::c_int;
435-
pub fn epoll_ctl(epfd: ::c_int,
436-
op: ::c_int,
437-
fd: ::c_int,
438-
event: *mut ::epoll_event) -> ::c_int;
439-
}
440408

441409
// sys/stat.h
442410
pub const S_IFMT: ::c_int = 0o0_170_000;
@@ -479,9 +447,6 @@ pub const TIOCGPGRP: ::c_ulong = 0x540F;
479447
pub const TIOCSPGRP: ::c_ulong = 0x5410;
480448
pub const TIOCGWINSZ: ::c_ulong = 0x5413;
481449
pub const TIOCSWINSZ: ::c_ulong = 0x5414;
482-
extern {
483-
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
484-
}
485450

486451
// sys/select.h
487452
pub const FD_SETSIZE: usize = 1024;
@@ -507,23 +472,6 @@ pub const SO_SNDTIMEO: ::c_int = 21;
507472
pub const SOCK_STREAM: ::c_int = 1;
508473
pub const SOCK_DGRAM: ::c_int = 2;
509474
pub const SOL_SOCKET: ::c_int = 1;
510-
extern {
511-
pub fn bind(socket: ::c_int, address: *const ::sockaddr,
512-
address_len: ::socklen_t) -> ::c_int;
513-
pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
514-
flags: ::c_int, addr: *mut ::sockaddr,
515-
addrlen: *mut ::socklen_t) -> ::ssize_t;
516-
}
517-
518-
// sys/uio.h
519-
extern {
520-
pub fn readv(fd: ::c_int,
521-
iov: *const ::iovec,
522-
iovcnt: ::c_int) -> ::ssize_t;
523-
pub fn writev(fd: ::c_int,
524-
iov: *const ::iovec,
525-
iovcnt: ::c_int) -> ::ssize_t;
526-
}
527475

528476
// sys/wait.h
529477
pub const WNOHANG: ::c_int = 1;
@@ -534,9 +482,6 @@ pub const NCCS: usize = 32;
534482
// time.h
535483
pub const CLOCK_REALTIME: ::c_int = 1;
536484
pub const CLOCK_MONOTONIC: ::c_int = 4;
537-
extern {
538-
pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
539-
}
540485

541486
// unistd.h
542487
pub const _SC_PAGESIZE: ::c_int = 30;
@@ -590,3 +535,57 @@ cfg_if! {
590535
// Unknown target_pointer_width
591536
}
592537
}
538+
539+
extern {
540+
// malloc.h
541+
pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
542+
543+
// pthread.h
544+
pub fn pthread_atfork(prepare: ::Option<unsafe extern fn()>,
545+
parent: ::Option<unsafe extern fn()>,
546+
child: ::Option<unsafe extern fn()>) -> ::c_int;
547+
pub fn pthread_create(tid: *mut ::pthread_t,
548+
attr: *const ::pthread_attr_t,
549+
start: extern fn(*mut ::c_void) -> *mut ::c_void,
550+
arg: *mut ::c_void) -> ::c_int;
551+
pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t,
552+
clock_id: ::clockid_t) -> ::c_int;
553+
554+
// signal.h
555+
pub fn pthread_sigmask(how: ::c_int,
556+
set: *const ::sigset_t,
557+
oldset: *mut ::sigset_t) -> ::c_int;
558+
559+
// sys/epoll.h
560+
pub fn epoll_create(size: ::c_int) -> ::c_int;
561+
pub fn epoll_create1(flags: ::c_int) -> ::c_int;
562+
pub fn epoll_wait(epfd: ::c_int,
563+
events: *mut ::epoll_event,
564+
maxevents: ::c_int,
565+
timeout: ::c_int) -> ::c_int;
566+
pub fn epoll_ctl(epfd: ::c_int,
567+
op: ::c_int,
568+
fd: ::c_int,
569+
event: *mut ::epoll_event) -> ::c_int;
570+
571+
// sys/ioctl.h
572+
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
573+
574+
// sys/socket.h
575+
pub fn bind(socket: ::c_int, address: *const ::sockaddr,
576+
address_len: ::socklen_t) -> ::c_int;
577+
pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
578+
flags: ::c_int, addr: *mut ::sockaddr,
579+
addrlen: *mut ::socklen_t) -> ::ssize_t;
580+
581+
// sys/uio.h
582+
pub fn readv(fd: ::c_int,
583+
iov: *const ::iovec,
584+
iovcnt: ::c_int) -> ::ssize_t;
585+
pub fn writev(fd: ::c_int,
586+
iov: *const ::iovec,
587+
iovcnt: ::c_int) -> ::ssize_t;
588+
589+
// time.h
590+
pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
591+
}

0 commit comments

Comments
 (0)