Skip to content

Commit

Permalink
Set __rlimit_resource_t definition for all uclibc (c_ulong).
Browse files Browse the repository at this point in the history
Bring all linux RLIMIT definitions into arch/generic/mod.rs or respective architectures.
Define all RLIMIT constants for all architectures.
Move BLKSSZGET/BLKPBSZGET with their other Ioctls Constants.
arch/generic/mod.rs No need to check for mips(64), powerpc(64), or sparc(64).
  • Loading branch information
lancethepants committed Feb 21, 2022
1 parent c55c52d commit ad3f860
Show file tree
Hide file tree
Showing 37 changed files with 296 additions and 303 deletions.
230 changes: 136 additions & 94 deletions src/unix/linux_like/linux/arch/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,103 +114,90 @@ pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING;

// Ioctl Constants

cfg_if! {
if #[cfg(not(any(target_arch = "mips",
target_arch = "mips64",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "sparc",
target_arch = "sparc64")))] {

pub const TCGETS: ::Ioctl = 0x5401;
pub const TCSETS: ::Ioctl = 0x5402;
pub const TCSETSW: ::Ioctl = 0x5403;
pub const TCSETSF: ::Ioctl = 0x5404;
pub const TCGETA: ::Ioctl = 0x5405;
pub const TCSETA: ::Ioctl = 0x5406;
pub const TCSETAW: ::Ioctl = 0x5407;
pub const TCSETAF: ::Ioctl = 0x5408;
pub const TCSBRK: ::Ioctl = 0x5409;
pub const TCXONC: ::Ioctl = 0x540A;
pub const TCFLSH: ::Ioctl = 0x540B;
pub const TIOCEXCL: ::Ioctl = 0x540C;
pub const TIOCNXCL: ::Ioctl = 0x540D;
pub const TIOCSCTTY: ::Ioctl = 0x540E;
pub const TIOCGPGRP: ::Ioctl = 0x540F;
pub const TIOCSPGRP: ::Ioctl = 0x5410;
pub const TIOCOUTQ: ::Ioctl = 0x5411;
pub const TIOCSTI: ::Ioctl = 0x5412;
pub const TIOCGWINSZ: ::Ioctl = 0x5413;
pub const TIOCSWINSZ: ::Ioctl = 0x5414;
pub const TIOCMGET: ::Ioctl = 0x5415;
pub const TIOCMBIS: ::Ioctl = 0x5416;
pub const TIOCMBIC: ::Ioctl = 0x5417;
pub const TIOCMSET: ::Ioctl = 0x5418;
pub const TIOCGSOFTCAR: ::Ioctl = 0x5419;
pub const TIOCSSOFTCAR: ::Ioctl = 0x541A;
pub const FIONREAD: ::Ioctl = 0x541B;
pub const TIOCINQ: ::Ioctl = FIONREAD;
pub const TIOCLINUX: ::Ioctl = 0x541C;
pub const TIOCCONS: ::Ioctl = 0x541D;
pub const TIOCGSERIAL: ::Ioctl = 0x541E;
pub const TIOCSSERIAL: ::Ioctl = 0x541F;
pub const TIOCPKT: ::Ioctl = 0x5420;
pub const FIONBIO: ::Ioctl = 0x5421;
pub const TIOCNOTTY: ::Ioctl = 0x5422;
pub const TIOCSETD: ::Ioctl = 0x5423;
pub const TIOCGETD: ::Ioctl = 0x5424;
pub const TCSBRKP: ::Ioctl = 0x5425;
pub const TIOCSBRK: ::Ioctl = 0x5427;
pub const TIOCCBRK: ::Ioctl = 0x5428;
pub const TIOCGSID: ::Ioctl = 0x5429;
pub const TCGETS2: ::Ioctl = 0x802c542a;
pub const TCSETS2: ::Ioctl = 0x402c542b;
pub const TCSETSW2: ::Ioctl = 0x402c542c;
pub const TCSETSF2: ::Ioctl = 0x402c542d;
pub const TIOCGRS485: ::Ioctl = 0x542E;
pub const TIOCSRS485: ::Ioctl = 0x542F;
pub const TIOCGPTN: ::Ioctl = 0x80045430;
pub const TIOCSPTLCK: ::Ioctl = 0x40045431;
pub const TIOCGDEV: ::Ioctl = 0x80045432;
pub const TCGETX: ::Ioctl = 0x5432;
pub const TCSETX: ::Ioctl = 0x5433;
pub const TCSETXF: ::Ioctl = 0x5434;
pub const TCSETXW: ::Ioctl = 0x5435;
pub const TIOCSIG: ::Ioctl = 0x40045436;
pub const TIOCVHANGUP: ::Ioctl = 0x5437;
pub const TIOCGPKT: ::Ioctl = 0x80045438;
pub const TIOCGPTLCK: ::Ioctl = 0x80045439;
pub const TIOCGEXCL: ::Ioctl = 0x80045440;
pub const TIOCGPTPEER: ::Ioctl = 0x5441;
// pub const TIOCGISO7816: ::Ioctl = 0x80285442;
// pub const TIOCSISO7816: ::Ioctl = 0xc0285443;
pub const FIONCLEX: ::Ioctl = 0x5450;
pub const FIOCLEX: ::Ioctl = 0x5451;
pub const FIOASYNC: ::Ioctl = 0x5452;
pub const TIOCSERCONFIG: ::Ioctl = 0x5453;
pub const TIOCSERGWILD: ::Ioctl = 0x5454;
pub const TIOCSERSWILD: ::Ioctl = 0x5455;
pub const TIOCGLCKTRMIOS: ::Ioctl = 0x5456;
pub const TIOCSLCKTRMIOS: ::Ioctl = 0x5457;
pub const TIOCSERGSTRUCT: ::Ioctl = 0x5458;
pub const TIOCSERGETLSR: ::Ioctl = 0x5459;
pub const TIOCSERGETMULTI: ::Ioctl = 0x545A;
pub const TIOCSERSETMULTI: ::Ioctl = 0x545B;
pub const TIOCMIWAIT: ::Ioctl = 0x545C;
pub const TIOCGICOUNT: ::Ioctl = 0x545D;
}
}
pub const TCGETS: ::Ioctl = 0x5401;
pub const TCSETS: ::Ioctl = 0x5402;
pub const TCSETSW: ::Ioctl = 0x5403;
pub const TCSETSF: ::Ioctl = 0x5404;
pub const TCGETA: ::Ioctl = 0x5405;
pub const TCSETA: ::Ioctl = 0x5406;
pub const TCSETAW: ::Ioctl = 0x5407;
pub const TCSETAF: ::Ioctl = 0x5408;
pub const TCSBRK: ::Ioctl = 0x5409;
pub const TCXONC: ::Ioctl = 0x540A;
pub const TCFLSH: ::Ioctl = 0x540B;
pub const TIOCEXCL: ::Ioctl = 0x540C;
pub const TIOCNXCL: ::Ioctl = 0x540D;
pub const TIOCSCTTY: ::Ioctl = 0x540E;
pub const TIOCGPGRP: ::Ioctl = 0x540F;
pub const TIOCSPGRP: ::Ioctl = 0x5410;
pub const TIOCOUTQ: ::Ioctl = 0x5411;
pub const TIOCSTI: ::Ioctl = 0x5412;
pub const TIOCGWINSZ: ::Ioctl = 0x5413;
pub const TIOCSWINSZ: ::Ioctl = 0x5414;
pub const TIOCMGET: ::Ioctl = 0x5415;
pub const TIOCMBIS: ::Ioctl = 0x5416;
pub const TIOCMBIC: ::Ioctl = 0x5417;
pub const TIOCMSET: ::Ioctl = 0x5418;
pub const TIOCGSOFTCAR: ::Ioctl = 0x5419;
pub const TIOCSSOFTCAR: ::Ioctl = 0x541A;
pub const FIONREAD: ::Ioctl = 0x541B;
pub const TIOCINQ: ::Ioctl = FIONREAD;
pub const TIOCLINUX: ::Ioctl = 0x541C;
pub const TIOCCONS: ::Ioctl = 0x541D;
pub const TIOCGSERIAL: ::Ioctl = 0x541E;
pub const TIOCSSERIAL: ::Ioctl = 0x541F;
pub const TIOCPKT: ::Ioctl = 0x5420;
pub const FIONBIO: ::Ioctl = 0x5421;
pub const TIOCNOTTY: ::Ioctl = 0x5422;
pub const TIOCSETD: ::Ioctl = 0x5423;
pub const TIOCGETD: ::Ioctl = 0x5424;
pub const TCSBRKP: ::Ioctl = 0x5425;
pub const TIOCSBRK: ::Ioctl = 0x5427;
pub const TIOCCBRK: ::Ioctl = 0x5428;
pub const TIOCGSID: ::Ioctl = 0x5429;
pub const TCGETS2: ::Ioctl = 0x802c542a;
pub const TCSETS2: ::Ioctl = 0x402c542b;
pub const TCSETSW2: ::Ioctl = 0x402c542c;
pub const TCSETSF2: ::Ioctl = 0x402c542d;
pub const TIOCGRS485: ::Ioctl = 0x542E;
pub const TIOCSRS485: ::Ioctl = 0x542F;
pub const TIOCGPTN: ::Ioctl = 0x80045430;
pub const TIOCSPTLCK: ::Ioctl = 0x40045431;
pub const TIOCGDEV: ::Ioctl = 0x80045432;
pub const TCGETX: ::Ioctl = 0x5432;
pub const TCSETX: ::Ioctl = 0x5433;
pub const TCSETXF: ::Ioctl = 0x5434;
pub const TCSETXW: ::Ioctl = 0x5435;
pub const TIOCSIG: ::Ioctl = 0x40045436;
pub const TIOCVHANGUP: ::Ioctl = 0x5437;
pub const TIOCGPKT: ::Ioctl = 0x80045438;
pub const TIOCGPTLCK: ::Ioctl = 0x80045439;
pub const TIOCGEXCL: ::Ioctl = 0x80045440;
pub const TIOCGPTPEER: ::Ioctl = 0x5441;
// pub const TIOCGISO7816: ::Ioctl = 0x80285442;
// pub const TIOCSISO7816: ::Ioctl = 0xc0285443;
pub const FIONCLEX: ::Ioctl = 0x5450;
pub const FIOCLEX: ::Ioctl = 0x5451;
pub const FIOASYNC: ::Ioctl = 0x5452;
pub const TIOCSERCONFIG: ::Ioctl = 0x5453;
pub const TIOCSERGWILD: ::Ioctl = 0x5454;
pub const TIOCSERSWILD: ::Ioctl = 0x5455;
pub const TIOCGLCKTRMIOS: ::Ioctl = 0x5456;
pub const TIOCSLCKTRMIOS: ::Ioctl = 0x5457;
pub const TIOCSERGSTRUCT: ::Ioctl = 0x5458;
pub const TIOCSERGETLSR: ::Ioctl = 0x5459;
pub const TIOCSERGETMULTI: ::Ioctl = 0x545A;
pub const TIOCSERSETMULTI: ::Ioctl = 0x545B;
pub const TIOCMIWAIT: ::Ioctl = 0x545C;
pub const TIOCGICOUNT: ::Ioctl = 0x545D;
pub const BLKSSZGET: ::Ioctl = 0x1268;
pub const BLKPBSZGET: ::Ioctl = 0x127B;

cfg_if! {
if #[cfg(any(target_arch = "arm",
target_arch = "s390x"))] {
pub const FIOQSIZE: ::Ioctl = 0x545E;
} else if #[cfg(not(any(target_arch = "mips",
target_arch = "mips64",
target_arch = "powerpc",
target_arch = "powerpc64",
target_arch = "sparc",
target_arch = "sparc64")))] {
} else {
pub const FIOQSIZE: ::Ioctl = 0x5460;
}
}
Expand All @@ -230,5 +217,60 @@ pub const TIOCM_DSR: ::c_int = 0x100;
pub const BOTHER: ::speed_t = 0o010000;
pub const IBSHIFT: ::tcflag_t = 16;

pub const BLKSSZGET: ::Ioctl = 0x1268;
pub const BLKPBSZGET: ::Ioctl = 0x127B;
// RLIMIT Constants

cfg_if! {
if #[cfg(any(target_env = "gnu",
target_env = "uclibc"))] {

pub const RLIMIT_CPU: ::__rlimit_resource_t = 0;
pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1;
pub const RLIMIT_DATA: ::__rlimit_resource_t = 2;
pub const RLIMIT_STACK: ::__rlimit_resource_t = 3;
pub const RLIMIT_CORE: ::__rlimit_resource_t = 4;
pub const RLIMIT_RSS: ::__rlimit_resource_t = 5;
pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6;
pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7;
pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8;
pub const RLIMIT_AS: ::__rlimit_resource_t = 9;
pub const RLIMIT_LOCKS: ::__rlimit_resource_t = 10;
pub const RLIMIT_SIGPENDING: ::__rlimit_resource_t = 11;
pub const RLIMIT_MSGQUEUE: ::__rlimit_resource_t = 12;
pub const RLIMIT_NICE: ::__rlimit_resource_t = 13;
pub const RLIMIT_RTPRIO: ::__rlimit_resource_t = 14;
pub const RLIMIT_RTTIME: ::__rlimit_resource_t = 15;
pub const RLIMIT_NLIMITS: ::__rlimit_resource_t = RLIM_NLIMITS;

} else if #[cfg(target_env = "musl")] {

pub const RLIMIT_CPU: ::c_int = 0;
pub const RLIMIT_FSIZE: ::c_int = 1;
pub const RLIMIT_DATA: ::c_int = 2;
pub const RLIMIT_STACK: ::c_int = 3;
pub const RLIMIT_CORE: ::c_int = 4;
pub const RLIMIT_RSS: ::c_int = 5;
pub const RLIMIT_NPROC: ::c_int = 6;
pub const RLIMIT_NOFILE: ::c_int = 7;
pub const RLIMIT_MEMLOCK: ::c_int = 8;
pub const RLIMIT_AS: ::c_int = 9;
pub const RLIMIT_LOCKS: ::c_int = 10;
pub const RLIMIT_SIGPENDING: ::c_int = 11;
pub const RLIMIT_MSGQUEUE: ::c_int = 12;
pub const RLIMIT_NICE: ::c_int = 13;
pub const RLIMIT_RTPRIO: ::c_int = 14;
pub const RLIMIT_RTTIME: ::c_int = 15;
pub const RLIM_NLIMITS: ::c_int = 15;
pub const RLIMIT_NLIMITS: ::c_int = RLIM_NLIMITS;
}
}

cfg_if! {
if #[cfg(target_env = "gnu")] {
pub const RLIM_NLIMITS: ::__rlimit_resource_t = 16;
}
else if #[cfg(target_env = "uclibc")] {
pub const RLIM_NLIMITS: ::__rlimit_resource_t = 15;
}
}

pub const RLIM_INFINITY: ::rlim_t = !0;
75 changes: 73 additions & 2 deletions src/unix/linux_like/linux/arch/mips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ pub const TIOCSLTC: ::Ioctl = 0x7475;
pub const TIOCGETP: ::Ioctl = 0x7408;
pub const TIOCSETP: ::Ioctl = 0x7409;
pub const TIOCSETN: ::Ioctl = 0x740a;
pub const BLKSSZGET: ::Ioctl = 0x20001268;
pub const BLKPBSZGET: ::Ioctl = 0x2000127B;

cfg_if! {
if #[cfg(target_env = "musl")] {
Expand All @@ -208,5 +210,74 @@ pub const TIOCM_DSR: ::c_int = 0x400;
pub const BOTHER: ::speed_t = 0o010000;
pub const IBSHIFT: ::tcflag_t = 16;

pub const BLKSSZGET: ::Ioctl = 0x20001268;
pub const BLKPBSZGET: ::Ioctl = 0x2000127B;
// RLIMIT Constants

cfg_if! {
if #[cfg(any(target_env = "gnu",
target_env = "uclibc"))] {

pub const RLIMIT_CPU: ::__rlimit_resource_t = 0;
pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1;
pub const RLIMIT_DATA: ::__rlimit_resource_t = 2;
pub const RLIMIT_STACK: ::__rlimit_resource_t = 3;
pub const RLIMIT_CORE: ::__rlimit_resource_t = 4;
pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 5;
pub const RLIMIT_AS: ::__rlimit_resource_t = 6;
pub const RLIMIT_RSS: ::__rlimit_resource_t = 7;
pub const RLIMIT_NPROC: ::__rlimit_resource_t = 8;
pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 9;
pub const RLIMIT_LOCKS: ::__rlimit_resource_t = 10;
pub const RLIMIT_SIGPENDING: ::__rlimit_resource_t = 11;
pub const RLIMIT_MSGQUEUE: ::__rlimit_resource_t = 12;
pub const RLIMIT_NICE: ::__rlimit_resource_t = 13;
pub const RLIMIT_RTPRIO: ::__rlimit_resource_t = 14;
pub const RLIMIT_RTTIME: ::__rlimit_resource_t = 15;
pub const RLIMIT_NLIMITS: ::__rlimit_resource_t = RLIM_NLIMITS;

} else if #[cfg(target_env = "musl")] {

pub const RLIMIT_CPU: ::c_int = 0;
pub const RLIMIT_FSIZE: ::c_int = 1;
pub const RLIMIT_DATA: ::c_int = 2;
pub const RLIMIT_STACK: ::c_int = 3;
pub const RLIMIT_CORE: ::c_int = 4;
pub const RLIMIT_NOFILE: ::c_int = 5;
pub const RLIMIT_AS: ::c_int = 6;
pub const RLIMIT_RSS: ::c_int = 7;
pub const RLIMIT_NPROC: ::c_int = 8;
pub const RLIMIT_MEMLOCK: ::c_int = 9;
pub const RLIMIT_LOCKS: ::c_int = 10;
pub const RLIMIT_SIGPENDING: ::c_int = 11;
pub const RLIMIT_MSGQUEUE: ::c_int = 12;
pub const RLIMIT_NICE: ::c_int = 13;
pub const RLIMIT_RTPRIO: ::c_int = 14;
pub const RLIMIT_RTTIME: ::c_int = 15;
pub const RLIM_NLIMITS: ::c_int = 15;
pub const RLIMIT_NLIMITS: ::c_int = RLIM_NLIMITS;
pub const RLIM_INFINITY: ::rlim_t = !0;
}
}

cfg_if! {
if #[cfg(target_env = "gnu")] {
pub const RLIM_NLIMITS: ::__rlimit_resource_t = 16;
} else if #[cfg(target_env = "uclibc")] {
pub const RLIM_NLIMITS: ::__rlimit_resource_t = 15;
}
}

cfg_if! {
if #[cfg(target_arch = "mips64",
any(target_env = "gnu",
target_env = "uclibc"))] {
pub const RLIM_INFINITY: ::rlim_t = !0;
}
}

cfg_if! {
if #[cfg(target_arch = "mips",
any(target_env = "gnu",
target_env = "uclibc"))] {
pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff;
}
}
Loading

0 comments on commit ad3f860

Please sign in to comment.