mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Add freebsd support
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1101,7 +1101,7 @@ checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a"
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.2"
|
||||
source = "git+https://github.com/coolreader18/parking_lot?branch=remutex-is_owned#391cf555e94c05450cea2e88b42c95c6631ab163"
|
||||
source = "git+https://github.com/Amanieu/parking_lot#2b3032f95d4aa5b1ccdf41b937c60603f569763c"
|
||||
dependencies = [
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
@@ -88,7 +88,14 @@ const ERROR_CODES: &[(&str, i32)] = &[
|
||||
e!(ENODEV),
|
||||
e!(EHOSTUNREACH),
|
||||
e!(cfg(not(windows)), ENOMSG),
|
||||
e!(cfg(not(any(target_os = "openbsd", windows))), ENODATA),
|
||||
e!(
|
||||
cfg(not(any(
|
||||
target_os = "openbsd",
|
||||
target_os = "freebsd",
|
||||
windows
|
||||
))),
|
||||
ENODATA
|
||||
),
|
||||
e!(cfg(not(windows)), ENOTBLK),
|
||||
e!(ENOSYS),
|
||||
e!(EPIPE),
|
||||
@@ -142,7 +149,14 @@ const ERROR_CODES: &[(&str, i32)] = &[
|
||||
e!(ENOENT),
|
||||
e!(EEXIST),
|
||||
e!(EDQUOT),
|
||||
e!(cfg(not(any(target_os = "openbsd", windows))), ENOSTR),
|
||||
e!(
|
||||
cfg(not(any(
|
||||
target_os = "openbsd",
|
||||
target_os = "freebsd",
|
||||
windows
|
||||
))),
|
||||
ENOSTR
|
||||
),
|
||||
e!(EFAULT),
|
||||
e!(EFBIG),
|
||||
e!(ENOTCONN),
|
||||
@@ -151,7 +165,14 @@ const ERROR_CODES: &[(&str, i32)] = &[
|
||||
e!(ECONNABORTED),
|
||||
e!(ENETUNREACH),
|
||||
e!(ESTALE),
|
||||
e!(cfg(not(any(target_os = "openbsd", windows))), ENOSR),
|
||||
e!(
|
||||
cfg(not(any(
|
||||
target_os = "openbsd",
|
||||
target_os = "freebsd",
|
||||
windows
|
||||
))),
|
||||
ENOSR
|
||||
),
|
||||
e!(ENOMEM),
|
||||
e!(ENOTSOCK),
|
||||
e!(EMLINK),
|
||||
@@ -162,7 +183,14 @@ const ERROR_CODES: &[(&str, i32)] = &[
|
||||
e!(ENAMETOOLONG),
|
||||
e!(ENOTTY),
|
||||
e!(ESOCKTNOSUPPORT),
|
||||
e!(cfg(not(any(target_os = "openbsd", windows))), ETIME),
|
||||
e!(
|
||||
cfg(not(any(
|
||||
target_os = "openbsd",
|
||||
target_os = "freebsd",
|
||||
windows
|
||||
))),
|
||||
ETIME
|
||||
),
|
||||
e!(ETOOMANYREFS),
|
||||
e!(EMFILE),
|
||||
e!(cfg(not(windows)), ETXTBSY),
|
||||
|
||||
@@ -791,6 +791,8 @@ mod _os {
|
||||
{
|
||||
#[cfg(target_os = "android")]
|
||||
use std::os::android::fs::MetadataExt;
|
||||
#[cfg(target_os = "freebsd")]
|
||||
use std::os::freebsd::fs::MetadataExt;
|
||||
#[cfg(target_os = "linux")]
|
||||
use std::os::linux::fs::MetadataExt;
|
||||
#[cfg(target_os = "macos")]
|
||||
@@ -1375,11 +1377,14 @@ mod posix {
|
||||
pub(super) use std::os::unix::fs::OpenOptionsExt;
|
||||
use std::os::unix::io::RawFd;
|
||||
|
||||
#[cfg(not(any(target_os = "redox", target_os = "freebsd")))]
|
||||
#[pyattr]
|
||||
use libc::O_DSYNC;
|
||||
#[pyattr]
|
||||
use libc::{O_CLOEXEC, O_NONBLOCK, WNOHANG};
|
||||
#[cfg(not(target_os = "redox"))]
|
||||
#[pyattr]
|
||||
use libc::{O_DSYNC, O_NDELAY, O_NOCTTY};
|
||||
use libc::{O_NDELAY, O_NOCTTY};
|
||||
|
||||
#[pyattr]
|
||||
const EX_OK: i8 = exitcode::OK as i8;
|
||||
@@ -1506,7 +1511,7 @@ mod posix {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
fn getgroups() -> nix::Result<Vec<Gid>> {
|
||||
use libc::{c_int, gid_t};
|
||||
use std::ptr;
|
||||
@@ -1525,7 +1530,7 @@ mod posix {
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd"))]
|
||||
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "redox")))]
|
||||
use nix::unistd::getgroups;
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
@@ -2007,26 +2012,9 @@ mod posix {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd"))]
|
||||
type ModeT = u32;
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
type ModeT = i32;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
type ModeT = u16;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "linux",
|
||||
target_os = "openbsd",
|
||||
target_os = "redox",
|
||||
target_os = "android",
|
||||
))]
|
||||
#[pyfunction]
|
||||
fn umask(mask: ModeT, _vm: &VirtualMachine) -> PyResult<ModeT> {
|
||||
let ret_mask = unsafe { libc::umask(mask) };
|
||||
Ok(ret_mask)
|
||||
fn umask(mask: libc::mode_t) -> libc::mode_t {
|
||||
unsafe { libc::umask(mask) }
|
||||
}
|
||||
|
||||
#[pyattr]
|
||||
@@ -2069,12 +2057,7 @@ mod posix {
|
||||
}
|
||||
|
||||
// cfg from nix
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "freebsd",
|
||||
target_os = "linux",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "openbsd"))]
|
||||
#[pyfunction]
|
||||
fn getresuid(vm: &VirtualMachine) -> PyResult<(u32, u32, u32)> {
|
||||
let mut ruid = 0;
|
||||
@@ -2089,12 +2072,7 @@ mod posix {
|
||||
}
|
||||
|
||||
// cfg from nix
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "freebsd",
|
||||
target_os = "linux",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "openbsd"))]
|
||||
#[pyfunction]
|
||||
fn getresgid(vm: &VirtualMachine) -> PyResult<(u32, u32, u32)> {
|
||||
let mut rgid = 0;
|
||||
@@ -2126,12 +2104,7 @@ mod posix {
|
||||
}
|
||||
|
||||
// cfg from nix
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "freebsd",
|
||||
target_os = "linux",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "openbsd"))]
|
||||
#[pyfunction]
|
||||
fn setregid(rgid: u32, egid: u32, vm: &VirtualMachine) -> PyResult<()> {
|
||||
let ret = unsafe { libc::setregid(rgid, egid) };
|
||||
@@ -2157,12 +2130,7 @@ mod posix {
|
||||
}
|
||||
|
||||
// cfg from nix
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "freebsd",
|
||||
target_os = "linux",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "redox")))]
|
||||
#[pyfunction]
|
||||
fn setgroups(group_ids: PyIterable<u32>, vm: &VirtualMachine) -> PyResult<()> {
|
||||
let gids = group_ids
|
||||
@@ -2540,10 +2508,21 @@ mod posix {
|
||||
type PriorityWhichType = libc::c_int;
|
||||
}
|
||||
}
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(target_os = "freebsd")] {
|
||||
type PriorityWhoType = i32;
|
||||
} else {
|
||||
type PriorityWhoType = u32;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[pyfunction]
|
||||
fn getpriority(which: PriorityWhichType, who: u32, vm: &VirtualMachine) -> PyResult {
|
||||
fn getpriority(
|
||||
which: PriorityWhichType,
|
||||
who: PriorityWhoType,
|
||||
vm: &VirtualMachine,
|
||||
) -> PyResult {
|
||||
Errno::clear();
|
||||
let retval = unsafe { libc::getpriority(which, who) };
|
||||
if errno() != 0 {
|
||||
@@ -2557,7 +2536,7 @@ mod posix {
|
||||
#[pyfunction]
|
||||
fn setpriority(
|
||||
which: PriorityWhichType,
|
||||
who: u32,
|
||||
who: PriorityWhoType,
|
||||
priority: i32,
|
||||
vm: &VirtualMachine,
|
||||
) -> PyResult<()> {
|
||||
|
||||
@@ -219,7 +219,7 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: &PyObjectRef) {
|
||||
"SIGSYS" => ctx.new_int(libc::SIGSYS as u8),
|
||||
});
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "openbsd")))]
|
||||
#[cfg(not(any(target_os = "macos", target_os = "openbsd", target_os = "freebsd")))]
|
||||
{
|
||||
extend_module!(vm, module, {
|
||||
"SIGPWR" => ctx.new_int(libc::SIGPWR as u8),
|
||||
|
||||
@@ -1126,15 +1126,19 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
|
||||
"SO_OOBINLINE" => ctx.new_int(c::SO_OOBINLINE),
|
||||
"SO_ERROR" => ctx.new_int(c::SO_ERROR),
|
||||
"TCP_NODELAY" => ctx.new_int(c::TCP_NODELAY),
|
||||
"NI_NAMEREQD" => ctx.new_int(c::NI_NAMEREQD),
|
||||
"NI_NOFQDN" => ctx.new_int(c::NI_NOFQDN),
|
||||
"NI_NUMERICHOST" => ctx.new_int(c::NI_NUMERICHOST),
|
||||
"NI_NUMERICSERV" => ctx.new_int(c::NI_NUMERICSERV),
|
||||
});
|
||||
|
||||
#[cfg(not(target_os = "freebsd"))]
|
||||
extend_module!(vm, module, {
|
||||
"AI_PASSIVE" => ctx.new_int(c::AI_PASSIVE),
|
||||
"AI_NUMERICHOST" => ctx.new_int(c::AI_NUMERICHOST),
|
||||
"AI_ALL" => ctx.new_int(c::AI_ALL),
|
||||
"AI_ADDRCONFIG" => ctx.new_int(c::AI_ADDRCONFIG),
|
||||
"AI_NUMERICSERV" => ctx.new_int(c::AI_NUMERICSERV),
|
||||
"NI_NAMEREQD" => ctx.new_int(c::NI_NAMEREQD),
|
||||
"NI_NOFQDN" => ctx.new_int(c::NI_NOFQDN),
|
||||
"NI_NUMERICHOST" => ctx.new_int(c::NI_NUMERICHOST),
|
||||
"NI_NUMERICSERV" => ctx.new_int(c::NI_NUMERICSERV),
|
||||
});
|
||||
|
||||
#[cfg(not(windows))]
|
||||
|
||||
Reference in New Issue
Block a user