Skip to content

Commit 3d65979

Browse files
committed
Split up Solaris and illumos targets
1 parent 08e8a3a commit 3d65979

File tree

4 files changed

+162
-101
lines changed

4 files changed

+162
-101
lines changed

src/unix/mod.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,12 @@ pub const S_ISUID: ::mode_t = 0x800;
226226
pub const S_ISGID: ::mode_t = 0x400;
227227
pub const S_ISVTX: ::mode_t = 0x200;
228228

229-
pub const IF_NAMESIZE: ::size_t = 16;
230-
pub const IFNAMSIZ: ::size_t = IF_NAMESIZE;
229+
cfg_if! {
230+
if #[cfg(not(any(target_os = "illumos", target_os = "solaris")))] {
231+
pub const IF_NAMESIZE: ::size_t = 16;
232+
pub const IFNAMSIZ: ::size_t = IF_NAMESIZE;
233+
}
234+
}
231235

232236
pub const LOG_EMERG: ::c_int = 0;
233237
pub const LOG_ALERT: ::c_int = 1;
@@ -611,7 +615,6 @@ extern "C" {
611615
all(target_os = "macos", target_arch = "x86"),
612616
link_name = "listen$UNIX2003"
613617
)]
614-
#[cfg_attr(target_os = "illumos", link_name = "__xnet_listen")]
615618
pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int;
616619
#[cfg_attr(
617620
all(target_os = "macos", target_arch = "x86"),
@@ -854,6 +857,7 @@ extern "C" {
854857
pub fn geteuid() -> uid_t;
855858
pub fn getgid() -> gid_t;
856859
pub fn getgroups(ngroups_max: ::c_int, groups: *mut gid_t) -> ::c_int;
860+
#[cfg_attr(target_os = "illumos", link_name = "getloginx")]
857861
pub fn getlogin() -> *mut c_char;
858862
#[cfg_attr(
859863
all(target_os = "macos", target_arch = "x86"),
@@ -910,6 +914,7 @@ extern "C" {
910914
all(target_os = "macos", target_arch = "x86"),
911915
link_name = "ttyname_r$UNIX2003"
912916
)]
917+
#[cfg_attr(target_os = "illumos", link_name = "__posix_ttyname_r")]
913918
pub fn ttyname_r(
914919
fd: ::c_int,
915920
buf: *mut c_char,
@@ -1216,6 +1221,7 @@ extern "C" {
12161221
pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
12171222
pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int;
12181223

1224+
#[cfg_attr(target_os = "illumos", link_name = "__xnet_getaddrinfo")]
12191225
pub fn getaddrinfo(
12201226
node: *const c_char,
12211227
service: *const c_char,

src/unix/solarish/illumos.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
s! {
2+
pub struct shmid_ds {
3+
pub shm_perm: ::ipc_perm,
4+
pub shm_segsz: ::size_t,
5+
pub shm_amp: *mut ::c_void,
6+
pub shm_lkcnt: ::c_ushort,
7+
pub shm_lpid: ::pid_t,
8+
pub shm_cpid: ::pid_t,
9+
pub shm_nattch: ::shmatt_t,
10+
pub shm_cnattch: ::c_ulong,
11+
pub shm_atime: ::time_t,
12+
pub shm_dtime: ::time_t,
13+
pub shm_ctime: ::time_t,
14+
pub shm_pad4: [i64; 4],
15+
}
16+
}
17+
18+
pub const AF_LOCAL: ::c_int = 1; // AF_UNIX
19+
pub const AF_FILE: ::c_int = 1; // AF_UNIX
20+
21+
extern "C" {
22+
pub fn mincore(
23+
addr: ::caddr_t,
24+
len: ::size_t,
25+
vec: *mut ::c_char,
26+
) -> ::c_int;
27+
}

src/unix/solarish/mod.rs

+32-98
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pub type c_char = i8;
22
pub type c_long = i64;
33
pub type c_ulong = u64;
4+
pub type caddr_t = *mut ::c_char;
45

56
pub type clockid_t = ::c_int;
67
pub type blkcnt_t = ::c_long;
@@ -36,9 +37,6 @@ pub type id_t = ::c_int;
3637
pub type idtype_t = ::c_uint;
3738
pub type shmatt_t = ::c_ulong;
3839

39-
pub type door_attr_t = ::c_uint;
40-
pub type door_id_t = ::c_ulonglong;
41-
4240
#[cfg_attr(feature = "extra_traits", derive(Debug))]
4341
pub enum timezone {}
4442
impl ::Copy for timezone {}
@@ -217,33 +215,6 @@ s! {
217215
pub ai_next: *mut addrinfo,
218216
}
219217

220-
pub struct shmid_ds {
221-
pub shm_perm: ipc_perm,
222-
pub shm_segsz: ::size_t,
223-
#[cfg(target_os = "illumos")]
224-
pub shm_amp: *mut ::c_void,
225-
#[cfg(target_os = "solaris")]
226-
pub shm_flags: ::uintptr_t,
227-
pub shm_lkcnt: ::c_ushort,
228-
pub shm_lpid: ::pid_t,
229-
pub shm_cpid: ::pid_t,
230-
pub shm_nattch: ::shmatt_t,
231-
pub shm_cnattch: ::c_ulong,
232-
pub shm_atime: ::time_t,
233-
pub shm_dtime: ::time_t,
234-
pub shm_ctime: ::time_t,
235-
#[cfg(target_os = "illumos")]
236-
pub shm_pad4: [i64; 4],
237-
#[cfg(target_os = "solaris")]
238-
pub shm_amp: *mut ::c_void,
239-
#[cfg(target_os = "solaris")]
240-
pub shm_gransize: u64,
241-
#[cfg(target_os = "solaris")]
242-
pub shm_allocated: u64,
243-
#[cfg(target_os = "solaris")]
244-
pub shm_pad4: [i64; 1],
245-
}
246-
247218
pub struct sigset_t {
248219
bits: [u32; 4],
249220
}
@@ -371,7 +342,7 @@ s! {
371342
pub mq_maxmsg: ::c_long,
372343
pub mq_msgsize: ::c_long,
373344
pub mq_curmsgs: ::c_long,
374-
_pad: [::c_int; 4]
345+
_pad: [::c_int; 12]
375346
}
376347

377348
pub struct port_event {
@@ -382,11 +353,6 @@ s! {
382353
pub portev_user: *mut ::c_void,
383354
}
384355

385-
pub struct door_desc_t__d_data__d_desc {
386-
pub d_descriptor: ::c_int,
387-
pub d_id: ::door_id_t
388-
}
389-
390356
pub struct exit_status {
391357
e_termination: ::c_short,
392358
e_exit: ::c_short,
@@ -431,7 +397,14 @@ s! {
431397
}
432398

433399
s_no_extra_traits! {
434-
#[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed))]
400+
#[cfg_attr(all(
401+
any(target_arch = "x86", target_arch = "x86_64"),
402+
libc_packedN
403+
), repr(packed(4)))]
404+
#[cfg_attr(all(
405+
any(target_arch = "x86", target_arch = "x86_64"),
406+
not(libc_packedN)
407+
), repr(packed))]
435408
pub struct epoll_event {
436409
pub events: u32,
437410
pub u64: u64,
@@ -505,28 +478,6 @@ s_no_extra_traits! {
505478
pub sigev_notify_attributes: *const ::pthread_attr_t,
506479
__sigev_pad2: ::c_int,
507480
}
508-
509-
#[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))]
510-
pub union door_desc_t__d_data {
511-
pub d_desc: door_desc_t__d_data__d_desc,
512-
d_resv: [::c_int; 5], /* Check out /usr/include/sys/door.h */
513-
}
514-
515-
#[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))]
516-
pub struct door_desc_t {
517-
pub d_attributes: door_attr_t,
518-
pub d_data: door_desc_t__d_data,
519-
}
520-
521-
#[cfg_attr(feature = "extra_traits", allow(missing_debug_implementations))]
522-
pub struct door_arg_t {
523-
pub data_ptr: *const ::c_char,
524-
pub data_size: ::size_t,
525-
pub desc_ptr: *const door_desc_t,
526-
pub dec_num: ::c_uint,
527-
pub rbuf: *const ::c_char,
528-
pub rsize: ::size_t,
529-
}
530481
}
531482

532483
cfg_if! {
@@ -1018,7 +969,7 @@ pub const O_CREAT: ::c_int = 256;
1018969
pub const O_EXCL: ::c_int = 1024;
1019970
pub const O_NOCTTY: ::c_int = 2048;
1020971
pub const O_TRUNC: ::c_int = 512;
1021-
pub const O_NOFOLLOW: ::c_int = 0x200000;
972+
pub const O_NOFOLLOW: ::c_int = 0x20000;
1022973
pub const O_SEARCH: ::c_int = 0x200000;
1023974
pub const O_EXEC: ::c_int = 0x400000;
1024975
pub const O_CLOEXEC: ::c_int = 0x800000;
@@ -1361,7 +1312,7 @@ pub const RLIMIT_AS: ::c_int = RLIMIT_VMEM;
13611312

13621313
#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
13631314
pub const RLIM_NLIMITS: rlim_t = 7;
1364-
pub const RLIM_INFINITY: rlim_t = 0x7fffffff;
1315+
pub const RLIM_INFINITY: rlim_t = 0xfffffffffffffffd;
13651316

13661317
pub const RUSAGE_SELF: ::c_int = 0;
13671318
pub const RUSAGE_CHILDREN: ::c_int = -1;
@@ -1375,8 +1326,6 @@ pub const MADV_FREE: ::c_int = 5;
13751326

13761327
pub const AF_UNSPEC: ::c_int = 0;
13771328
pub const AF_UNIX: ::c_int = 1;
1378-
pub const AF_LOCAL: ::c_int = 0;
1379-
pub const AF_FILE: ::c_int = 0;
13801329
pub const AF_INET: ::c_int = 2;
13811330
pub const AF_IMPLINK: ::c_int = 3;
13821331
pub const AF_PUP: ::c_int = 4;
@@ -1465,6 +1414,9 @@ pub const MSG_DUPCTRL: ::c_int = 0x800;
14651414
pub const MSG_XPG4_2: ::c_int = 0x8000;
14661415
pub const MSG_MAXIOVLEN: ::c_int = 16;
14671416

1417+
pub const IF_NAMESIZE: ::size_t = 32;
1418+
pub const IFNAMSIZ: ::size_t = 16;
1419+
14681420
// https://docs.oracle.com/cd/E23824_01/html/821-1475/if-7p.html
14691421
pub const IFF_UP: ::c_int = 0x0000000001; // Address is up
14701422
pub const IFF_BROADCAST: ::c_int = 0x0000000002; // Broadcast address valid
@@ -1780,8 +1732,6 @@ pub const PORT_SOURCE_FD: ::c_int = 4;
17801732
pub const PORT_SOURCE_ALERT: ::c_int = 5;
17811733
pub const PORT_SOURCE_MQ: ::c_int = 6;
17821734
pub const PORT_SOURCE_FILE: ::c_int = 7;
1783-
pub const PORT_SOURCE_POSTWAIT: ::c_int = 8;
1784-
pub const PORT_SOURCE_SIGNAL: ::c_int = 9;
17851735

17861736
pub const NONROOT_USR: ::c_short = 2;
17871737
pub const _UTX_USERSIZE: usize = 32;
@@ -1888,7 +1838,6 @@ pub const EPOLLERR: ::c_int = 0x8;
18881838
pub const EPOLLHUP: ::c_int = 0x10;
18891839
pub const EPOLLET: ::c_int = 0x80000000;
18901840
pub const EPOLLRDHUP: ::c_int = 0x2000;
1891-
pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000;
18921841
pub const EPOLLONESHOT: ::c_int = 0x40000000;
18931842
pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
18941843
pub const EPOLL_CTL_ADD: ::c_int = 1;
@@ -1920,9 +1869,9 @@ pub const B230400: speed_t = 20;
19201869
pub const B307200: speed_t = 21;
19211870
pub const B460800: speed_t = 22;
19221871
pub const B921600: speed_t = 23;
1923-
pub const CSTART: ::tcflag_t = 021;
1924-
pub const CSTOP: ::tcflag_t = 023;
1925-
pub const CSWTCH: ::tcflag_t = 032;
1872+
pub const CSTART: ::tcflag_t = 0o21;
1873+
pub const CSTOP: ::tcflag_t = 0o23;
1874+
pub const CSWTCH: ::tcflag_t = 0o32;
19261875
pub const CSIZE: ::tcflag_t = 0o000060;
19271876
pub const CS5: ::tcflag_t = 0;
19281877
pub const CS6: ::tcflag_t = 0o000020;
@@ -2137,11 +2086,6 @@ extern "C" {
21372086
pub fn freeifaddrs(ifa: *mut ::ifaddrs);
21382087

21392088
pub fn stack_getbounds(sp: *mut ::stack_t) -> ::c_int;
2140-
pub fn mincore(
2141-
addr: *const ::c_void,
2142-
len: ::size_t,
2143-
vec: *mut c_char,
2144-
) -> ::c_int;
21452089
pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int;
21462090
pub fn setgroups(ngroups: ::c_int, ptr: *const ::gid_t) -> ::c_int;
21472091
pub fn ioctl(fildes: ::c_int, request: ::c_int, ...) -> ::c_int;
@@ -2237,6 +2181,7 @@ extern "C" {
22372181
options: ::c_int,
22382182
) -> ::c_int;
22392183

2184+
#[cfg_attr(target_os = "illumos", link_name = "_glob_ext")]
22402185
pub fn glob(
22412186
pattern: *const ::c_char,
22422187
flags: ::c_int,
@@ -2246,6 +2191,7 @@ extern "C" {
22462191
pglob: *mut ::glob_t,
22472192
) -> ::c_int;
22482193

2194+
#[cfg_attr(target_os = "illumos", link_name = "_globfree_ext")]
22492195
pub fn globfree(pglob: *mut ::glob_t);
22502196

22512197
pub fn posix_madvise(
@@ -2426,11 +2372,6 @@ extern "C" {
24262372
events: ::c_int,
24272373
user: *mut ::c_void,
24282374
) -> ::c_int;
2429-
pub fn fexecve(
2430-
fd: ::c_int,
2431-
argv: *const *const ::c_char,
2432-
envp: *const *const ::c_char,
2433-
) -> ::c_int;
24342375
#[cfg_attr(
24352376
any(target_os = "solaris", target_os = "illumos"),
24362377
link_name = "__posix_getgrgid_r"
@@ -2555,25 +2496,6 @@ extern "C" {
25552496
pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
25562497
pub fn uname(buf: *mut ::utsname) -> ::c_int;
25572498
pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
2558-
pub fn door_call(d: ::c_int, params: *const door_arg_t) -> ::c_int;
2559-
pub fn door_return(
2560-
data_ptr: *const ::c_char,
2561-
data_size: ::size_t,
2562-
desc_ptr: *const door_desc_t,
2563-
num_desc: ::c_uint,
2564-
);
2565-
pub fn door_create(
2566-
server_procedure: extern "C" fn(
2567-
cookie: *const ::c_void,
2568-
argp: *const ::c_char,
2569-
arg_size: ::size_t,
2570-
dp: *const door_desc_t,
2571-
n_desc: ::c_uint,
2572-
),
2573-
cookie: *const ::c_void,
2574-
attributes: door_attr_t,
2575-
) -> ::c_int;
2576-
pub fn fattach(fildes: ::c_int, path: *const ::c_char) -> ::c_int;
25772499

25782500
pub fn makeutx(ux: *const utmpx) -> *mut utmpx;
25792501
pub fn modutx(ux: *const utmpx) -> *mut utmpx;
@@ -2604,3 +2526,15 @@ extern "C" {
26042526

26052527
mod compat;
26062528
pub use self::compat::*;
2529+
2530+
cfg_if! {
2531+
if #[cfg(target_os = "illumos")] {
2532+
mod illumos;
2533+
pub use self::illumos::*;
2534+
} else if #[cfg(target_os = "solaris")] {
2535+
mod solaris;
2536+
pub use self::solaris::*;
2537+
} else {
2538+
// Unknown target_os
2539+
}
2540+
}

0 commit comments

Comments
 (0)