Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/base/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub(crate) mod openbsd;
pub(crate) mod qnx_sdp;
pub(crate) mod qtee;
pub(crate) mod redox;
pub(crate) mod serenity;
pub(crate) mod solaris;
pub(crate) mod solid;
pub(crate) mod teeos;
Expand Down
21 changes: 21 additions & 0 deletions compiler/rustc_target/src/spec/base/serenity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use crate::spec::{FramePointer, Os, PanicStrategy, RelroLevel, TargetOptions, cvs};

pub(crate) fn opts() -> TargetOptions {
TargetOptions {
os: Os::Serenity,
dynamic_linking: true,
frame_pointer: FramePointer::Always,
families: cvs!["unix"],
default_dwarf_version: 5,
has_rpath: true,
no_default_libraries: false,
position_independent_executables: true,
static_position_independent_executables: false,
relro_level: RelroLevel::Full,
has_thread_local: true,
panic_strategy: PanicStrategy::Abort,
crt_static_default: false,
crt_static_respected: false,
..Default::default()
}
}
4 changes: 4 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,9 @@ supported_targets! {

("aarch64-unknown-hyperlight", aarch64_unknown_hyperlight),
("x86_64-unknown-hyperlight", x86_64_unknown_hyperlight),

("aarch64-unknown-serenity", aarch64_unknown_serenity),
("x86_64-unknown-serenity", x86_64_unknown_serenity),
}

/// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]>
Expand Down Expand Up @@ -1885,6 +1888,7 @@ crate::target_spec_enum! {
Qurt = "qurt",
Redox = "redox",
Rtems = "rtems",
Serenity = "serenity",
Solaris = "solaris",
SolidAsp3 = "solid_asp3",
TeeOs = "teeos",
Expand Down
22 changes: 22 additions & 0 deletions compiler/rustc_target/src/spec/targets/aarch64_unknown_serenity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use crate::spec::{Arch, StackProbeType, Target, base};

pub(crate) fn target() -> Target {
let mut base = base::serenity::opts();
base.max_atomic_width = Some(128);
base.stack_probes = StackProbeType::Inline;
base.features = "+v8a".into();

Target {
llvm_target: "aarch64-unknown-serenity".into(),
metadata: crate::spec::TargetMetadata {
description: Some("SerenityOS AArch64".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
},
pointer_width: 64,
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
arch: Arch::AArch64,
options: base
}
}
24 changes: 24 additions & 0 deletions compiler/rustc_target/src/spec/targets/x86_64_unknown_serenity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use crate::spec::{Arch, Cc, LinkerFlavor, Lld, StackProbeType, Target, base};

pub(crate) fn target() -> Target {
let mut base = base::serenity::opts();
base.cpu = "x86-64".into();
base.max_atomic_width = Some(64);
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.stack_probes = StackProbeType::Inline;

Target {
llvm_target: "x86_64-unknown-serenity".into(),
metadata: crate::spec::TargetMetadata {
description: Some("SerenityOS x86_64".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
},
pointer_width: 64,
data_layout:
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
arch: Arch::X86_64,
options: base,
}
}
1 change: 1 addition & 0 deletions library/std/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ fn main() {
|| target_os == "nuttx"
|| target_os == "cygwin"
|| target_os == "vexos"
|| target_os == "serenity"

// See src/bootstrap/src/core/build_steps/synthetic_targets.rs
|| env::var("RUSTC_BOOTSTRAP_SYNTHETIC_TARGET").is_ok()
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/os/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ pub mod openbsd;
pub mod redox;
#[cfg(target_os = "rtems")]
pub mod rtems;
#[cfg(target_os = "serenity")]
pub mod serenity;
#[cfg(target_os = "solaris")]
pub mod solaris;
#[cfg(target_os = "solid_asp3")]
Expand Down
95 changes: 95 additions & 0 deletions library/std/src/os/serenity/fs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#![stable(feature = "metadata_ext", since = "1.1.0")]

use crate::fs::Metadata;
use crate::sys::AsInner;

/// OS-specific extensions to [`fs::Metadata`].
///
/// [`fs::Metadata`]: crate::fs::Metadata
#[stable(feature = "metadata_ext", since = "1.1.0")]
pub trait MetadataExt {
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_dev(&self) -> u64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_ino(&self) -> u64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_mode(&self) -> u32;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_nlink(&self) -> u64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_uid(&self) -> u32;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_gid(&self) -> u32;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_rdev(&self) -> u64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_size(&self) -> u64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_atime(&self) -> i64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_atime_nsec(&self) -> i64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_mtime(&self) -> i64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_mtime_nsec(&self) -> i64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_ctime(&self) -> i64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_ctime_nsec(&self) -> i64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_blksize(&self) -> u64;
#[stable(feature = "metadata_ext2", since = "1.8.0")]
fn st_blocks(&self) -> u64;
}

#[stable(feature = "metadata_ext", since = "1.1.0")]
impl MetadataExt for Metadata {
fn st_dev(&self) -> u64 {
self.as_inner().as_inner().st_dev as u64
}
fn st_ino(&self) -> u64 {
self.as_inner().as_inner().st_ino as u64
}
fn st_mode(&self) -> u32 {
self.as_inner().as_inner().st_mode as u32
}
fn st_nlink(&self) -> u64 {
self.as_inner().as_inner().st_nlink as u64
}
fn st_uid(&self) -> u32 {
self.as_inner().as_inner().st_uid as u32
}
fn st_gid(&self) -> u32 {
self.as_inner().as_inner().st_gid as u32
}
fn st_rdev(&self) -> u64 {
self.as_inner().as_inner().st_rdev as u64
}
fn st_size(&self) -> u64 {
self.as_inner().as_inner().st_size as u64
}
fn st_atime(&self) -> i64 {
self.as_inner().as_inner().st_atim.tv_sec as i64
}
fn st_atime_nsec(&self) -> i64 {
self.as_inner().as_inner().st_atim.tv_nsec as i64
}
fn st_mtime(&self) -> i64 {
self.as_inner().as_inner().st_mtim.tv_sec as i64
}
fn st_mtime_nsec(&self) -> i64 {
self.as_inner().as_inner().st_mtim.tv_nsec as i64
}
fn st_ctime(&self) -> i64 {
self.as_inner().as_inner().st_ctim.tv_sec as i64
}
fn st_ctime_nsec(&self) -> i64 {
self.as_inner().as_inner().st_ctim.tv_nsec as i64
}
fn st_blksize(&self) -> u64 {
self.as_inner().as_inner().st_blksize as u64
}
fn st_blocks(&self) -> u64 {
self.as_inner().as_inner().st_blocks as u64
}
}
7 changes: 7 additions & 0 deletions library/std/src/os/serenity/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//! Serenity-specific definitions.

#![stable(feature = "raw_ext", since = "1.1.0")]
#![forbid(unsafe_op_in_unsafe_fn)]

pub mod fs;
pub mod raw;
15 changes: 15 additions & 0 deletions library/std/src/os/serenity/raw.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![stable(feature = "raw_ext", since = "1.1.0")]
#![deprecated(
since = "1.8.0",
note = "these type aliases are no longer supported by \
the standard library, the `libc` crate on \
crates.io should be used instead for the correct \
definitions"
)]
#![allow(deprecated)]

#[stable(feature = "pthread_t", since = "1.8.0")]
pub type pthread_t = i32;

#[stable(feature = "raw_ext", since = "1.1.0")]
pub use libc::{blkcnt_t, blksize_t, dev_t, ino_t, mode_t, nlink_t, off_t, time_t};
2 changes: 2 additions & 0 deletions library/std/src/os/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ mod platform {
pub use crate::os::redox::*;
#[cfg(target_os = "rtems")]
pub use crate::os::rtems::*;
#[cfg(target_os = "serenity")]
pub use crate::os::serenity::*;
#[cfg(target_os = "solaris")]
pub use crate::os::solaris::*;
#[cfg(target_os = "vita")]
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/args/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub fn args() -> Args {
target_os = "hurd",
target_os = "rtems",
target_os = "nuttx",
target_os = "serenity",
))]
mod imp {
use crate::ffi::c_char;
Expand Down
6 changes: 6 additions & 0 deletions library/std/src/sys/fd/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const READ_LIMIT: usize = cfg_select! {
target_os = "openbsd",
target_vendor = "apple",
target_os = "cygwin",
target_os = "serenity",
))]
const fn max_iov() -> usize {
libc::IOV_MAX as usize
Expand Down Expand Up @@ -123,6 +124,7 @@ const fn max_iov() -> usize {
target_os = "vita",
target_vendor = "apple",
target_os = "cygwin",
target_os = "serenity",
)))]
const fn max_iov() -> usize {
16 // The minimum value required by POSIX.
Expand Down Expand Up @@ -247,6 +249,7 @@ impl FileDesc {
target_os = "netbsd",
target_os = "openbsd", // OpenBSD 2.7
all(target_os = "macos", target_arch = "aarch64"),
target_os = "serenity",
))]
pub fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result<usize> {
let ret = cvt(unsafe {
Expand All @@ -273,6 +276,7 @@ impl FileDesc {
target_os = "netbsd",
target_os = "openbsd",
target_vendor = "apple",
target_os = "serenity",
)))]
pub fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result<usize> {
io::default_read_vectored(|b| self.read_at(b, offset), bufs)
Expand Down Expand Up @@ -443,6 +447,7 @@ impl FileDesc {
target_os = "netbsd",
target_os = "openbsd", // OpenBSD 2.7
all(target_os = "macos", target_arch = "aarch64"),
target_os = "serenity",
))]
pub fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize> {
let ret = cvt(unsafe {
Expand All @@ -469,6 +474,7 @@ impl FileDesc {
target_os = "netbsd",
target_os = "openbsd",
target_vendor = "apple",
target_os = "serenity",
)))]
pub fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize> {
io::default_write_vectored(|b| self.write_at(b, offset), bufs)
Expand Down
Loading
Loading