From c63e0369ae36578de94c3fb416d880c8aa8c74dd Mon Sep 17 00:00:00 2001
From: Anhad Singh
Date: Fri, 29 Sep 2023 19:23:04 +1000
Subject: [PATCH 001/112] fix(kernel): fix panic handler function signature
The panic handler needs to be an extern "Rust" function not a extern "C"
function. This commit fixes that by making the panic handler a normal
function.
Signed-off-by: Anhad Singh
---
src/aero_kernel/src/unwind.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/aero_kernel/src/unwind.rs b/src/aero_kernel/src/unwind.rs
index a6d59abc1a7..855caa37268 100644
--- a/src/aero_kernel/src/unwind.rs
+++ b/src/aero_kernel/src/unwind.rs
@@ -160,7 +160,7 @@ use crate::emu;
use crate::utils::sync::IrqGuard;
#[panic_handler]
-extern "C" fn rust_begin_unwind(info: &PanicInfo) -> ! {
+fn rust_begin_unwind(info: &PanicInfo) -> ! {
prepare_panic();
let default_panic = &format_args!("");
From f7cd1a06957418bce8f35364e42d01d27658f5f7 Mon Sep 17 00:00:00 2001
From: Anhad Singh
Date: Fri, 29 Sep 2023 20:02:35 +1000
Subject: [PATCH 002/112] feat(kernel): bump `crabnet` and `crabnet_tcp`
* Bump `crabnet` and `crabnet_tcp`
* No longer ignore the TCP options and pass them to `on_packet` on the
respective TCP socket.
Signed-off-by: Anhad Singh
---
src/Cargo.lock | 4 ++--
src/aero_kernel/Cargo.toml | 2 ++
src/aero_kernel/src/net/mod.rs | 30 ++++++++++++++++++++++++-----
src/aero_kernel/src/net/tcp.rs | 6 +++---
src/aero_kernel/src/socket/tcp.rs | 32 ++++++++++++++++---------------
5 files changed, 49 insertions(+), 25 deletions(-)
diff --git a/src/Cargo.lock b/src/Cargo.lock
index d873aefc2c5..cae1db1890e 100644
--- a/src/Cargo.lock
+++ b/src/Cargo.lock
@@ -139,7 +139,7 @@ dependencies = [
[[package]]
name = "crabnet"
version = "0.1.0"
-source = "git+https://github.com/aero-os/crabnet#4e9e10290136ab34b2b73bd7ce81803c2303674c"
+source = "git+https://github.com/aero-os/crabnet#95894c3885b6b3b50942488075631f087cfa9d75"
dependencies = [
"bit_field",
"bitflags 2.4.0",
@@ -150,7 +150,7 @@ dependencies = [
[[package]]
name = "crabnet_tcp"
version = "0.1.0"
-source = "git+https://github.com/aero-os/crabnet#4e9e10290136ab34b2b73bd7ce81803c2303674c"
+source = "git+https://github.com/aero-os/crabnet#95894c3885b6b3b50942488075631f087cfa9d75"
dependencies = [
"crabnet",
"log",
diff --git a/src/aero_kernel/Cargo.toml b/src/aero_kernel/Cargo.toml
index f1f9cac37a2..ae6589737e2 100644
--- a/src/aero_kernel/Cargo.toml
+++ b/src/aero_kernel/Cargo.toml
@@ -50,6 +50,8 @@ vte = { git = "https://github.com/alacritty/vte", features = ["ansi"] }
byte_endian = { git = "https://github.com/aero-os/byte_endian" }
crabnet = { git = "https://github.com/aero-os/crabnet" }
crabnet_tcp = { git = "https://github.com/aero-os/crabnet", default-features = false }
+# crabnet = { path = "../../../orgs/aero/crabnet" }
+# crabnet_tcp = { path = "../../../orgs/aero/crabnet/crabnet_tcp", default-features = false }
# X86_64 specific dependencies:
[target.'cfg(target_arch = "x86_64")'.dependencies]
diff --git a/src/aero_kernel/src/net/mod.rs b/src/aero_kernel/src/net/mod.rs
index 43829ff30aa..3a2f4767948 100644
--- a/src/aero_kernel/src/net/mod.rs
+++ b/src/aero_kernel/src/net/mod.rs
@@ -18,6 +18,7 @@
use alloc::boxed::Box;
use alloc::sync::Arc;
use alloc::vec::Vec;
+use crabnet::transport::TcpOptions;
use spin::RwLock;
pub mod arp;
@@ -132,12 +133,11 @@ fn packet_processor_thread() {
Ipv4Type::Tcp => {
let tcp = parser.next::();
- let options_size = tcp.options_size() as usize;
- let size = ip.payload_len() as usize - core::mem::size_of::();
+ let size = ip.payload_len() as usize - tcp.header_size() as usize;
+ let options = parser.next::();
+ let payload = &parser.payload()[..size];
- // TODO(andypython): do not ignore TCP options.
- let payload = &parser.payload()[options_size..size];
- tcp::on_packet(tcp, payload)
+ tcp::on_packet(tcp, options, payload)
}
}
}
@@ -217,6 +217,26 @@ pub mod shim {
}
}
+ impl PacketSend
+ for Stacked, T>, U>, S>
+ {
+ fn send(mut self) {
+ let device = net::default_device();
+
+ let eth = &mut self.upper.upper.upper.upper;
+ let ip = &self.upper.upper.upper.lower;
+
+ eth.src_mac = device.mac();
+
+ if let Some(addr) = arp::get(ip.dest_ip()) {
+ eth.dest_mac = addr;
+ device.send(self.into_boxed_bytes_in(DmaAllocator));
+ } else {
+ arp::request_ip(ip.dest_ip(), self.into_boxed_bytes_in(DmaAllocator));
+ }
+ }
+ }
+
impl PacketSend for Arp {
fn send(self) {
let device = net::default_device();
diff --git a/src/aero_kernel/src/net/tcp.rs b/src/aero_kernel/src/net/tcp.rs
index ea57b60c778..cdef80717d9 100644
--- a/src/aero_kernel/src/net/tcp.rs
+++ b/src/aero_kernel/src/net/tcp.rs
@@ -18,18 +18,18 @@
use alloc::collections::BTreeMap;
use alloc::sync::Arc;
-use crabnet::transport::Tcp;
+use crabnet::transport::{Tcp, TcpOptions};
use spin::RwLock;
use crate::socket::tcp::TcpSocket;
static HANDLERS: RwLock>> = RwLock::new(BTreeMap::new());
-pub fn on_packet(tcp: &Tcp, payload: &[u8]) {
+pub fn on_packet(tcp: &Tcp, options: TcpOptions, payload: &[u8]) {
let handlers = HANDLERS.read();
if let Some(handler) = handlers.get(&tcp.dest_port()) {
- handler.on_packet(tcp, payload);
+ handler.on_packet(tcp, options, payload);
} else {
log::warn!("tcp: no handler registered for port {}", tcp.dest_port());
}
diff --git a/src/aero_kernel/src/socket/tcp.rs b/src/aero_kernel/src/socket/tcp.rs
index 0af5ce56e24..849d8680032 100644
--- a/src/aero_kernel/src/socket/tcp.rs
+++ b/src/aero_kernel/src/socket/tcp.rs
@@ -3,11 +3,12 @@ use aero_syscall::{InAddr, OpenFlags, SocketAddrInet, AF_INET};
use alloc::sync::{Arc, Weak};
use alloc::vec::Vec;
+use crabnet::network::Ipv4Addr;
use spin::Once;
use crabnet::data_link::{Eth, EthType, MacAddr};
-use crabnet::transport::Tcp;
-use crabnet_tcp::{Address, Error as TcpError, State};
+use crabnet::transport::{Tcp, TcpOptions};
+use crabnet_tcp::{Address, Error as TcpError, Packet as TcpPacket, State};
use crate::fs::file_table::FileHandle;
use crate::fs::inode::{FileType, INodeInterface, Metadata, PollFlags, PollTable};
@@ -23,19 +24,14 @@ use crate::utils::sync::{Mutex, WaitQueue};
struct DeviceShim(Arc);
impl crabnet_tcp::NetworkDevice for DeviceShim {
- fn send(
- &self,
- ipv4: crabnet::network::Ipv4,
- tcp: Tcp,
- payload: &[u8],
- _handle: crabnet_tcp::RetransmitHandle,
- ) {
- // TODO(andypython): Handle TCP retransmission here.
+ fn ip(&self) -> Ipv4Addr {
+ self.0.ip()
+ }
+ fn send(&self, packet: TcpPacket, _handle: crabnet_tcp::RetransmitHandle) {
+ // TODO(andypython): Handle TCP retransmission here.
let eth = Eth::new(MacAddr::NULL, self.0.mac(), EthType::Ip);
- let ipv4 = ipv4.set_src_ip(self.0.ip());
-
- (eth / ipv4 / tcp / payload).send();
+ (eth / packet.ip / packet.tcp / packet.options / packet.payload).send();
}
fn remove_retransmit(&self, _seq_number: u32) {
@@ -62,9 +58,15 @@ impl TcpSocket {
})
}
- pub fn on_packet(&self, tcp: &Tcp, payload: &[u8]) {
+ pub fn on_packet(&self, tcp: &Tcp, options: TcpOptions, payload: &[u8]) {
if let Some(socket) = self.tcp.lock_irq().as_mut() {
- socket.on_packet(tcp, payload);
+ // Ignore any invalid TCP options.
+ let options = options
+ .iter()
+ .filter_map(|option| option.ok())
+ .collect::>();
+
+ socket.on_packet(tcp, &options, payload);
self.wq.notify_all();
}
}
From e9077a0621195c01de0812cac122d5f170006289 Mon Sep 17 00:00:00 2001
From: Anhad Singh
Date: Fri, 29 Sep 2023 20:59:04 +1000
Subject: [PATCH 003/112] misc(kernel): bump dependencies
* Bump dependencies
* Remove `cfg_if` since now we have the `cfg_match` macro in `core` :)
Signed-off-by: Anhad Singh
---
src/Cargo.lock | 49 +++++++++++++++---------------
src/aero_kernel/Cargo.toml | 11 +++----
src/aero_kernel/src/drivers/mod.rs | 8 +++--
src/aero_kernel/src/main.rs | 1 +
4 files changed, 36 insertions(+), 33 deletions(-)
diff --git a/src/Cargo.lock b/src/Cargo.lock
index cae1db1890e..14e7f194731 100644
--- a/src/Cargo.lock
+++ b/src/Cargo.lock
@@ -12,11 +12,10 @@ dependencies = [
"bitflags 1.3.2",
"byte_endian",
"bytemuck",
- "cfg-if",
"cpio_reader",
"crabnet",
"crabnet_tcp",
- "hashbrown 0.14.0",
+ "hashbrown",
"intrusive-collections",
"lai",
"lazy_static",
@@ -109,9 +108,9 @@ source = "git+https://github.com/aero-os/byte_endian#540be6149cd9408088a9e45be2d
[[package]]
name = "bytemuck"
-version = "1.13.1"
+version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea"
+checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"
[[package]]
name = "cc"
@@ -139,7 +138,7 @@ dependencies = [
[[package]]
name = "crabnet"
version = "0.1.0"
-source = "git+https://github.com/aero-os/crabnet#95894c3885b6b3b50942488075631f087cfa9d75"
+source = "git+https://github.com/aero-os/crabnet#a46a02f9f650cbe8d7436b322f924510e5bda9f7"
dependencies = [
"bit_field",
"bitflags 2.4.0",
@@ -150,7 +149,7 @@ dependencies = [
[[package]]
name = "crabnet_tcp"
version = "0.1.0"
-source = "git+https://github.com/aero-os/crabnet#95894c3885b6b3b50942488075631f087cfa9d75"
+source = "git+https://github.com/aero-os/crabnet#a46a02f9f650cbe8d7436b322f924510e5bda9f7"
dependencies = [
"crabnet",
"log",
@@ -200,25 +199,22 @@ dependencies = [
]
[[package]]
-name = "either"
-version = "1.9.0"
+name = "cursor-icon"
+version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
+checksum = "740bb192a8e2d1350119916954f4409ee7f62f149b536911eeb78ba5a20526bf"
[[package]]
-name = "hashbrown"
-version = "0.13.2"
+name = "either"
+version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
-dependencies = [
- "ahash",
-]
+checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "hashbrown"
-version = "0.14.0"
+version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
+checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12"
dependencies = [
"ahash",
"allocator-api2",
@@ -282,11 +278,11 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "lru"
-version = "0.10.1"
+version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670"
+checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21"
dependencies = [
- "hashbrown 0.13.2",
+ "hashbrown",
]
[[package]]
@@ -493,7 +489,8 @@ checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
[[package]]
name = "utf8parse"
version = "0.2.1"
-source = "git+https://github.com/alacritty/vte#94e74f3a64f42d5dad4e3d42dbe8c23291038214"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "version_check"
@@ -503,10 +500,13 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "vte"
-version = "0.11.1"
-source = "git+https://github.com/alacritty/vte#94e74f3a64f42d5dad4e3d42dbe8c23291038214"
+version = "0.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "401dc1020e10f74d38616c1f1ab92ccd85dc902705a29d0730e0fbea8534f91a"
dependencies = [
"arrayvec",
+ "bitflags 2.4.0",
+ "cursor-icon",
"log",
"utf8parse",
"vte_generate_state_changes",
@@ -515,7 +515,8 @@ dependencies = [
[[package]]
name = "vte_generate_state_changes"
version = "0.1.1"
-source = "git+https://github.com/alacritty/vte#94e74f3a64f42d5dad4e3d42dbe8c23291038214"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff"
dependencies = [
"proc-macro2",
"quote",
diff --git a/src/aero_kernel/Cargo.toml b/src/aero_kernel/Cargo.toml
index ae6589737e2..330b80b8a64 100644
--- a/src/aero_kernel/Cargo.toml
+++ b/src/aero_kernel/Cargo.toml
@@ -30,22 +30,21 @@ bitflags = "1.2.1"
bit_field = "0.10.2"
log = "0.4.19"
xmas-elf = "0.9.0"
-hashbrown = "0.14.0"
+hashbrown = "0.14.1"
rustc-demangle = "0.1.23"
# intrusive-collections:
# `nightly`: Get access to const variants of the functions.
-intrusive-collections = { version = "0.9.5", features = ["nightly"] }
+intrusive-collections = { version = "0.9.6", features = ["nightly"] }
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
lai = { git = "https://github.com/aero-os/lai-rs" }
uapi = { path = "../uapi" }
cpio_reader = { git = "https://github.com/Andy-Python-Programmer/cpio_reader" }
static_assertions = "1.1.0"
-lru = "0.10.0"
-bytemuck = "1.13.1"
+lru = "0.11.1"
+bytemuck = "1.14.0"
limine = { git = "https://github.com/limine-bootloader/limine-rs" }
-cfg-if = "1.0"
num-traits = { version = "0.2", default-features = false }
-vte = { git = "https://github.com/alacritty/vte", features = ["ansi"] }
+vte = { version = "0.12.0", features = ["ansi"] }
byte_endian = { git = "https://github.com/aero-os/byte_endian" }
crabnet = { git = "https://github.com/aero-os/crabnet" }
diff --git a/src/aero_kernel/src/drivers/mod.rs b/src/aero_kernel/src/drivers/mod.rs
index de2dff01226..795bdb8985d 100644
--- a/src/aero_kernel/src/drivers/mod.rs
+++ b/src/aero_kernel/src/drivers/mod.rs
@@ -33,11 +33,13 @@ pub mod pci;
pub mod pty;
pub mod tty;
-cfg_if::cfg_if! {
- if #[cfg(target_arch = "x86_64")] {
+cfg_match! {
+ cfg(target_arch = "x86_64") => {
pub mod uart_16550;
pub use self::uart_16550 as uart;
- } else if #[cfg(target_arch = "aarch64")] {
+ }
+
+ cfg(target_arch = "aarch64") => {
pub mod uart_pl011;
pub use self::uart_pl011 as uart;
}
diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs
index 2e276084404..e0c73d006cd 100644
--- a/src/aero_kernel/src/main.rs
+++ b/src/aero_kernel/src/main.rs
@@ -47,6 +47,7 @@
const_ptr_is_null, // https://github.com/rust-lang/rust/issues/74939
trait_upcasting, // https://github.com/rust-lang/rust/issues/65991
naked_functions, // https://github.com/rust-lang/rust/issues/32408
+ cfg_match, // https://github.com/rust-lang/rust/issues/115585
strict_provenance
)]
// TODO(andypython): can we remove the dependency of "prelude_import" and "lang_items"?
From d8c14285b54d4cff2f89f22cc94c6048fb4566eb Mon Sep 17 00:00:00 2001
From: Anhad Singh
Date: Wed, 4 Oct 2023 19:07:24 +1100
Subject: [PATCH 004/112] feat(kernel): make DNS resolution work properly
* Add the loopback device
* Create the /etc/resolv.conf file, where the entry is the default SLIRP
DNS server address.
* Add sock_send() for Unix sockets.
* On socket(), create the inode with name <{type}_socket> instead of
just which makes debugging easier.
* Add some assertions that I will deal with later :)
Signed-off-by: Anhad Singh
---
CONTRIBUTING.md | 4 +-
base-files/etc/resolv.conf | 1 +
src/Cargo.lock | 99 ++++++++++++++---------------
src/aero_kernel/src/net/arp.rs | 4 ++
src/aero_kernel/src/net/loopback.rs | 60 +++++++++++++++++
src/aero_kernel/src/net/mod.rs | 46 ++++++++++++--
src/aero_kernel/src/net/tcp.rs | 2 +
src/aero_kernel/src/net/udp.rs | 1 +
src/aero_kernel/src/socket/tcp.rs | 4 ++
src/aero_kernel/src/socket/udp.rs | 20 +++---
src/aero_kernel/src/socket/unix.rs | 12 ++++
src/aero_kernel/src/syscall/net.rs | 15 +++--
12 files changed, 195 insertions(+), 73 deletions(-)
create mode 100644 base-files/etc/resolv.conf
create mode 100644 src/aero_kernel/src/net/loopback.rs
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 746c0e124a1..1ab51c94ade 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -36,4 +36,6 @@ $ lldb
(lldb)
````
-Check out the docs for your debugger for information about how to use the debugger.
\ No newline at end of file
+Check out the docs for your debugger for information about how to use the debugger.
+
+`./aero.py -- -netdev user,id=spider -device e1000,netdev=spider,id=ck_nic0 -object filter-dump,id=spider,netdev=spider,file=qemulog.log`
\ No newline at end of file
diff --git a/base-files/etc/resolv.conf b/base-files/etc/resolv.conf
new file mode 100644
index 00000000000..27a94c07e56
--- /dev/null
+++ b/base-files/etc/resolv.conf
@@ -0,0 +1 @@
+nameserver 10.0.2.3
diff --git a/src/Cargo.lock b/src/Cargo.lock
index 14e7f194731..773f4b49eac 100644
--- a/src/Cargo.lock
+++ b/src/Cargo.lock
@@ -41,7 +41,7 @@ dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
- "syn",
+ "syn 1.0.109",
]
[[package]]
@@ -114,9 +114,9 @@ checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"
[[package]]
name = "cc"
-version = "1.0.81"
+version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6c6b2562119bf28c3439f7f02db99faf0aa1a8cdfe5772a2ee155d32227239f0"
+checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"libc",
]
@@ -138,7 +138,7 @@ dependencies = [
[[package]]
name = "crabnet"
version = "0.1.0"
-source = "git+https://github.com/aero-os/crabnet#a46a02f9f650cbe8d7436b322f924510e5bda9f7"
+source = "git+https://github.com/aero-os/crabnet#14fd222842e717c63b695f09790726b209165715"
dependencies = [
"bit_field",
"bitflags 2.4.0",
@@ -149,22 +149,12 @@ dependencies = [
[[package]]
name = "crabnet_tcp"
version = "0.1.0"
-source = "git+https://github.com/aero-os/crabnet#a46a02f9f650cbe8d7436b322f924510e5bda9f7"
+source = "git+https://github.com/aero-os/crabnet#14fd222842e717c63b695f09790726b209165715"
dependencies = [
"crabnet",
"log",
]
-[[package]]
-name = "crossbeam-channel"
-version = "0.5.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200"
-dependencies = [
- "cfg-if",
- "crossbeam-utils",
-]
-
[[package]]
name = "crossbeam-deque"
version = "0.8.3"
@@ -220,12 +210,6 @@ dependencies = [
"allocator-api2",
]
-[[package]]
-name = "hermit-abi"
-version = "0.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
-
[[package]]
name = "intrusive-collections"
version = "0.9.6"
@@ -261,9 +245,9 @@ dependencies = [
[[package]]
name = "libc"
-version = "0.2.147"
+version = "0.2.148"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
+checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
[[package]]
name = "limine"
@@ -311,7 +295,7 @@ checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d"
dependencies = [
"proc-macro2",
"quote",
- "syn",
+ "syn 1.0.109",
]
[[package]]
@@ -323,16 +307,6 @@ dependencies = [
"autocfg",
]
-[[package]]
-name = "num_cpus"
-version = "1.16.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
-dependencies = [
- "hermit-abi",
- "libc",
-]
-
[[package]]
name = "once_cell"
version = "1.18.0"
@@ -348,7 +322,7 @@ dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
- "syn",
+ "syn 1.0.109",
"version_check",
]
@@ -365,18 +339,18 @@ dependencies = [
[[package]]
name = "proc-macro2"
-version = "1.0.66"
+version = "1.0.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
+checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
-version = "1.0.32"
+version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
+checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
@@ -392,9 +366,9 @@ dependencies = [
[[package]]
name = "rayon"
-version = "1.7.0"
+version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b"
+checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
dependencies = [
"either",
"rayon-core",
@@ -402,14 +376,12 @@ dependencies = [
[[package]]
name = "rayon-core"
-version = "1.11.0"
+version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d"
+checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
dependencies = [
- "crossbeam-channel",
"crossbeam-deque",
"crossbeam-utils",
- "num_cpus",
]
[[package]]
@@ -432,15 +404,29 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "serde"
-version = "1.0.180"
+version = "1.0.188"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.188"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ea67f183f058fe88a4e3ec6e2788e003840893b91bac4559cabedd00863b3ed"
+checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.37",
+]
[[package]]
name = "serde_json"
-version = "1.0.104"
+version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c"
+checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65"
dependencies = [
"itoa",
"ryu",
@@ -476,15 +462,26 @@ dependencies = [
"unicode-ident",
]
+[[package]]
+name = "syn"
+version = "2.0.37"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
[[package]]
name = "uapi"
version = "0.1.0"
[[package]]
name = "unicode-ident"
-version = "1.0.11"
+version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
+checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "utf8parse"
diff --git a/src/aero_kernel/src/net/arp.rs b/src/aero_kernel/src/net/arp.rs
index a7f77d73e6e..ce804f5a789 100644
--- a/src/aero_kernel/src/net/arp.rs
+++ b/src/aero_kernel/src/net/arp.rs
@@ -76,6 +76,10 @@ impl Cache {
}
fn request(&mut self, ip: Ipv4Addr, packet: RawPacket) {
+ if ip == Ipv4Addr::LOOPBACK {
+ panic!()
+ }
+
if self.0.get_mut(&ip).is_some() {
todo!()
} else {
diff --git a/src/aero_kernel/src/net/loopback.rs b/src/aero_kernel/src/net/loopback.rs
new file mode 100644
index 00000000000..6a43b41b0e7
--- /dev/null
+++ b/src/aero_kernel/src/net/loopback.rs
@@ -0,0 +1,60 @@
+// Copyright (C) 2021-2023 The Aero Project Developers.
+//
+// This file is part of The Aero Project.
+//
+// Aero is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Aero is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Aero. If not, see .
+
+//! Loopback device.
+
+use alloc::boxed::Box;
+use alloc::sync::Arc;
+use crabnet::data_link::MacAddr;
+use crabnet::network::Ipv4Addr;
+
+use crate::utils::dma::DmaAllocator;
+
+use super::{NetworkDevice, NetworkDriver, RecvPacket};
+
+pub struct Loopback;
+
+impl NetworkDriver for Loopback {
+ fn send(&self, _packet: Box<[u8], DmaAllocator>) {
+ todo!()
+ }
+
+ fn recv(&self) -> RecvPacket {
+ todo!()
+ }
+
+ fn recv_end(&self, _packet_id: usize) {
+ todo!()
+ }
+
+ #[inline]
+ fn mac(&self) -> MacAddr {
+ // TODO: What should this really be?
+ MacAddr::NULL
+ }
+}
+
+lazy_static::lazy_static! {
+ pub static ref LOOPBACK: Arc = (|| {
+ let device = Arc::new(NetworkDevice::new(Arc::new(Loopback)));
+
+ device.set_ip(Ipv4Addr::LOOPBACK);
+ device.set_subnet_mask(Ipv4Addr::new(255, 0, 0, 0));
+
+ device
+ })();
+}
diff --git a/src/aero_kernel/src/net/mod.rs b/src/aero_kernel/src/net/mod.rs
index 3a2f4767948..1ef19dd290b 100644
--- a/src/aero_kernel/src/net/mod.rs
+++ b/src/aero_kernel/src/net/mod.rs
@@ -22,6 +22,7 @@ use crabnet::transport::TcpOptions;
use spin::RwLock;
pub mod arp;
+pub mod loopback;
pub mod tcp;
pub mod udp;
@@ -45,8 +46,12 @@ struct Metadata {
ip: Ipv4Addr,
#[allow(dead_code)]
subnet_mask: Ipv4Addr,
+ default_gateway: Ipv4Addr,
}
+// FIXME(andypython): This is very inefficient. We store the driver as an Arc and
+// the device with metadata as an Arc. Two heap allocations for nothing, bruh
+// moments.
pub struct NetworkDevice {
driver: Arc,
metadata: RwLock,
@@ -55,8 +60,15 @@ pub struct NetworkDevice {
impl NetworkDevice {
pub fn new(driver: Arc) -> Self {
// FIXME(andy): DHCPD should handle static IP assignment.
- let mut metadata = Metadata::default();
- metadata.ip = Ipv4Addr::new([192, 168, 100, 0]);
+ //
+ // https://wiki.qemu.org/Documentation/Networking
+ let metadata = Metadata {
+ ip: Ipv4Addr::new(192, 168, 100, 0),
+ // What should the default be? Also this should really be handled inside dhcpd.
+ default_gateway: Ipv4Addr::new(10, 0, 2, 2),
+ subnet_mask: Ipv4Addr::new(255, 255, 255, 0),
+ ..Default::default()
+ };
Self {
driver,
@@ -79,6 +91,11 @@ impl NetworkDevice {
pub fn subnet_mask(&self) -> Ipv4Addr {
self.metadata.read().subnet_mask
}
+
+ #[inline]
+ pub fn default_gateway(&self) -> Ipv4Addr {
+ self.metadata.read().default_gateway
+ }
}
impl core::ops::Deref for NetworkDevice {
@@ -180,6 +197,7 @@ pub fn init() {
return;
}
+ DEVICES.write().push(loopback::LOOPBACK.clone());
arp::init();
log::info!("net::arp: initialized cache");
}
@@ -199,6 +217,8 @@ pub mod shim {
}
// Deref for Stacked where T: Stacked?
+ //
+ // TODO(andypython): Can all of the packet send impls be refactored?
impl PacketSend for Stacked, T>, U> {
fn send(mut self) {
let device = net::default_device();
@@ -206,13 +226,20 @@ pub mod shim {
let eth = &mut self.upper.upper.upper;
let ip = &self.upper.upper.lower;
+ let mut dest_ip = ip.dest_ip();
+
+ if !dest_ip.is_broadcast() && !dest_ip.is_same_subnet(device.ip(), device.subnet_mask())
+ {
+ dest_ip = device.default_gateway();
+ }
+
eth.src_mac = device.mac();
- if let Some(addr) = arp::get(ip.dest_ip()) {
+ if let Some(addr) = arp::get(dest_ip) {
eth.dest_mac = addr;
device.send(self.into_boxed_bytes_in(DmaAllocator));
} else {
- arp::request_ip(ip.dest_ip(), self.into_boxed_bytes_in(DmaAllocator));
+ arp::request_ip(dest_ip, self.into_boxed_bytes_in(DmaAllocator));
}
}
}
@@ -226,13 +253,20 @@ pub mod shim {
let eth = &mut self.upper.upper.upper.upper;
let ip = &self.upper.upper.upper.lower;
+ let mut dest_ip = ip.dest_ip();
+
+ if !dest_ip.is_broadcast() && !dest_ip.is_same_subnet(device.ip(), device.subnet_mask())
+ {
+ dest_ip = device.default_gateway();
+ }
+
eth.src_mac = device.mac();
- if let Some(addr) = arp::get(ip.dest_ip()) {
+ if let Some(addr) = arp::get(dest_ip) {
eth.dest_mac = addr;
device.send(self.into_boxed_bytes_in(DmaAllocator));
} else {
- arp::request_ip(ip.dest_ip(), self.into_boxed_bytes_in(DmaAllocator));
+ arp::request_ip(dest_ip, self.into_boxed_bytes_in(DmaAllocator));
}
}
}
diff --git a/src/aero_kernel/src/net/tcp.rs b/src/aero_kernel/src/net/tcp.rs
index cdef80717d9..9ffb6f520cf 100644
--- a/src/aero_kernel/src/net/tcp.rs
+++ b/src/aero_kernel/src/net/tcp.rs
@@ -53,6 +53,8 @@ pub fn alloc_ephemeral_port(socket: Arc) -> Option {
continue;
}
+ log::warn!("[ TCP ] Listening on port {port}");
+
handlers.insert(port, socket);
return Some(port);
}
diff --git a/src/aero_kernel/src/net/udp.rs b/src/aero_kernel/src/net/udp.rs
index f93eef32ef2..f90ea9d284c 100644
--- a/src/aero_kernel/src/net/udp.rs
+++ b/src/aero_kernel/src/net/udp.rs
@@ -54,6 +54,7 @@ pub fn alloc_ephemeral_port(socket: Arc) -> Option {
continue;
}
+ log::warn!("[ UDP ] Listening on port {port}");
handlers.insert(port, socket);
return Some(port);
}
diff --git a/src/aero_kernel/src/socket/tcp.rs b/src/aero_kernel/src/socket/tcp.rs
index 849d8680032..34d29602714 100644
--- a/src/aero_kernel/src/socket/tcp.rs
+++ b/src/aero_kernel/src/socket/tcp.rs
@@ -131,6 +131,10 @@ impl INodeInterface for TcpSocket {
let addr = address.as_inet().ok_or(FileSystemError::NotSupported)?;
self.peer.call_once(|| addr.clone());
+ if addr.addr() == Ipv4Addr::LOOPBACK.0 {
+ return Err(FileSystemError::NotSupported);
+ }
+
let addr = Address::new(port, addr.port(), addr.addr().into());
let device = Arc::new(DeviceShim(net::default_device()));
diff --git a/src/aero_kernel/src/socket/udp.rs b/src/aero_kernel/src/socket/udp.rs
index 27e98af35c4..0409073d0bf 100644
--- a/src/aero_kernel/src/socket/udp.rs
+++ b/src/aero_kernel/src/socket/udp.rs
@@ -140,7 +140,7 @@ impl INodeInterface for UdpSocket {
fn connect(&self, address: super::SocketAddrRef, _length: usize) -> fs::Result<()> {
let address = address.as_inet().ok_or(FileSystemError::NotSupported)?;
- let host_addr = Ipv4Addr::new(address.sin_addr.addr.to_be_bytes());
+ let host_addr = Ipv4Addr::from(address.sin_addr.addr.to_be_bytes());
udp::connect(host_addr, address.port.to_native());
self.set_state(SocketState::Connected(address.clone()));
@@ -154,7 +154,7 @@ impl INodeInterface for UdpSocket {
.unwrap_or_else(|| self.dest());
let dest_port = name.port.to_native();
- let dest_ip = Ipv4Addr::new(name.addr());
+ let dest_ip = Ipv4Addr::from(name.addr());
let src_port;
@@ -165,11 +165,6 @@ impl INodeInterface for UdpSocket {
log::debug!("Inet::send(): allocated ephemeral port {}", src_port);
}
- // FIXME: loopback
- if dest_ip == Ipv4Addr::new([127, 0, 0, 1]) {
- return Err(FileSystemError::NotSupported);
- }
-
let data = message_hdr
.iovecs()
.iter()
@@ -177,6 +172,13 @@ impl INodeInterface for UdpSocket {
.copied()
.collect::>();
+ // FIXME: loopback
+ if dest_ip == Ipv4Addr::LOOPBACK {
+ log::debug!("looback moments :)");
+ return Err(FileSystemError::NotSupported);
+ // return Ok(data.len());
+ }
+
use crate::net::shim::PacketSend;
let eth = Eth::new(MacAddr::NULL, MacAddr::NULL, EthType::Ip);
@@ -245,7 +247,7 @@ impl INodeInterface for UdpSocket {
assert!(name == "eth0");
let device = net::default_device();
- device.set_ip(Ipv4Addr::new(socket.addr()));
+ device.set_ip(Ipv4Addr::from(socket.addr()));
Ok(0)
}
@@ -262,7 +264,7 @@ impl INodeInterface for UdpSocket {
assert!(name == "eth0");
let device = net::default_device();
- device.set_subnet_mask(Ipv4Addr::new(socket.addr()));
+ device.set_subnet_mask(Ipv4Addr::from(socket.addr()));
Ok(0)
}
diff --git a/src/aero_kernel/src/socket/unix.rs b/src/aero_kernel/src/socket/unix.rs
index 03ca06b7594..f8d635e4e4e 100644
--- a/src/aero_kernel/src/socket/unix.rs
+++ b/src/aero_kernel/src/socket/unix.rs
@@ -411,6 +411,18 @@ impl INodeInterface for UnixSocket {
.sum::())
}
+ fn send(&self, message_hdr: &mut MessageHeader, _flags: MessageFlags) -> fs::Result {
+ // FIXME(andyython): figure out the message header stuff...
+ let data = message_hdr
+ .iovecs()
+ .iter()
+ .flat_map(|e| e.as_slice())
+ .copied()
+ .collect::>();
+
+ self.write_at(0, &data)
+ }
+
fn poll(&self, table: Option<&mut PollTable>) -> fs::Result {
let buffer = self.buffer.lock_irq();
let inner = self.inner.lock_irq();
diff --git a/src/aero_kernel/src/syscall/net.rs b/src/aero_kernel/src/syscall/net.rs
index 0433281f569..4f864f20908 100644
--- a/src/aero_kernel/src/syscall/net.rs
+++ b/src/aero_kernel/src/syscall/net.rs
@@ -127,16 +127,19 @@ fn create_socket(
let typ = SocketType::from_usize(socket_type & 0b1111).ok_or(SyscallError::EINVAL)?;
let protocol = IpProtocol::from_usize(protocol).ok_or(SyscallError::EINVAL)?;
- let socket = match domain as u32 {
- AF_UNIX => UnixSocket::new() as Arc,
+ let (name, socket) = match domain as u32 {
+ AF_UNIX => ("unix", UnixSocket::new() as Arc),
AF_INET => match (typ, protocol) {
(SocketType::Dgram, IpProtocol::Default | IpProtocol::Udp) => {
- UdpSocket::new() as Arc
+ ("udp", UdpSocket::new() as Arc)
+ }
+
+ (SocketType::Dgram, IpProtocol::Raw) => {
+ ("ipv4", Ipv4Socket::new() as Arc)
}
- (SocketType::Dgram, IpProtocol::Raw) => Ipv4Socket::new() as Arc,
(SocketType::Stream, IpProtocol::Default | IpProtocol::Tcp) => {
- TcpSocket::new() as Arc
+ ("tcp", TcpSocket::new() as Arc)
}
_ => {
@@ -157,7 +160,7 @@ fn create_socket(
}
};
- let entry = DirEntry::from_inode(socket, String::from(""));
+ let entry = DirEntry::from_inode(socket, alloc::format!("<{name}_socket>"));
Ok(entry)
}
From c558b7958913e82105066cf36403a16f165200c2 Mon Sep 17 00:00:00 2001
From: Anhad Singh
Date: Fri, 6 Oct 2023 17:53:42 +1100
Subject: [PATCH 005/112] misc(kernel): make use of the stabilized div_ceil
Signed-off-by: Anhad Singh
---
src/aero_kernel/src/drivers/block/ahci.rs | 4 +--
src/aero_kernel/src/drivers/block/ide/mod.rs | 3 +--
src/aero_kernel/src/drivers/block/nvme/mod.rs | 4 +--
src/aero_kernel/src/fs/ext2/disk.rs | 3 +--
src/aero_kernel/src/fs/ext2/mod.rs | 3 +--
src/aero_kernel/src/syscall/time.rs | 3 +--
src/aero_kernel/src/utils/mod.rs | 27 -------------------
7 files changed, 8 insertions(+), 39 deletions(-)
diff --git a/src/aero_kernel/src/drivers/block/ahci.rs b/src/aero_kernel/src/drivers/block/ahci.rs
index d8ac56d497f..bbe5b67c291 100644
--- a/src/aero_kernel/src/drivers/block/ahci.rs
+++ b/src/aero_kernel/src/drivers/block/ahci.rs
@@ -25,7 +25,7 @@ use crate::mem::paging::*;
use crate::mem::AddressSpace;
use crate::utils::sync::Mutex;
-use crate::utils::{CeilDiv, VolatileCell};
+use crate::utils::VolatileCell;
use crate::drivers::pci::*;
@@ -201,7 +201,7 @@ pub struct DmaBuffer {
impl DmaBuffer {
pub fn sectors(&self) -> usize {
- self.data_size.ceil_div(512)
+ self.data_size.div_ceil(512)
}
pub fn start(&self) -> PhysAddr {
diff --git a/src/aero_kernel/src/drivers/block/ide/mod.rs b/src/aero_kernel/src/drivers/block/ide/mod.rs
index 16ea8ef7bc8..688172d8909 100644
--- a/src/aero_kernel/src/drivers/block/ide/mod.rs
+++ b/src/aero_kernel/src/drivers/block/ide/mod.rs
@@ -32,7 +32,6 @@ use crate::fs::block::{BlockDevice, BlockDeviceInterface};
use crate::mem::paging::OffsetPageTable;
use crate::utils::sync::Mutex;
-use crate::utils::CeilDiv;
use super::ahci::DmaRequest;
@@ -51,7 +50,7 @@ impl IdeDrive {
impl BlockDeviceInterface for IdeDrive {
fn read_block(&self, sector: usize, dest: &mut [MaybeUninit]) -> Option {
- let count = dest.len().ceil_div(512);
+ let count = dest.len().div_ceil(512);
let request = Arc::new(DmaRequest::new(sector, count));
let res = self.channel.run_request(request, self.slave);
diff --git a/src/aero_kernel/src/drivers/block/nvme/mod.rs b/src/aero_kernel/src/drivers/block/nvme/mod.rs
index 48c69103f12..706776e5149 100644
--- a/src/aero_kernel/src/drivers/block/nvme/mod.rs
+++ b/src/aero_kernel/src/drivers/block/nvme/mod.rs
@@ -35,7 +35,7 @@ use crate::mem::paging::*;
use crate::utils::dma::*;
use crate::utils::sync::BMutex;
-use crate::utils::{CeilDiv, VolatileCell};
+use crate::utils::VolatileCell;
#[derive(Copy, Clone, Debug)]
enum Error {
@@ -231,7 +231,7 @@ impl<'a> Namespace<'a> {
fn rw_command(&self, opcode: CommandOpcode, sector: usize, start: PhysAddr, size_bytes: usize) {
assert!(size_bytes != 0);
- let blocks = size_bytes.ceil_div(self.block_size);
+ let blocks = size_bytes.div_ceil(self.block_size);
let mut read_cmd = ReadWriteCommand::default();
read_cmd.opcode = opcode as u8;
diff --git a/src/aero_kernel/src/fs/ext2/disk.rs b/src/aero_kernel/src/fs/ext2/disk.rs
index 2f55f8eca96..f99f046c45c 100644
--- a/src/aero_kernel/src/fs/ext2/disk.rs
+++ b/src/aero_kernel/src/fs/ext2/disk.rs
@@ -18,7 +18,6 @@
use bit_field::BitField;
use crate::fs::inode;
-use crate::utils::CeilDiv;
trait Revsion {}
@@ -112,7 +111,7 @@ impl SuperBlock {
/// Returns the length of the BGDT.
pub fn bgdt_len(&self) -> usize {
- self.blocks_count.ceil_div(self.blocks_per_group) as usize
+ self.blocks_count.div_ceil(self.blocks_per_group) as usize
}
pub fn bgdt_block(&self) -> usize {
diff --git a/src/aero_kernel/src/fs/ext2/mod.rs b/src/aero_kernel/src/fs/ext2/mod.rs
index 987531513b3..817d09a570e 100644
--- a/src/aero_kernel/src/fs/ext2/mod.rs
+++ b/src/aero_kernel/src/fs/ext2/mod.rs
@@ -34,7 +34,6 @@ use crate::mem::paging::*;
use crate::socket::unix::UnixSocket;
use crate::socket::SocketAddrRef;
-use crate::utils::CeilDiv;
use self::group_desc::GroupDescriptors;
@@ -186,7 +185,7 @@ impl INode {
let new_block = fs.bgdt.alloc_block_ptr()?;
- let mut next_block_num = self.inode.read().size().ceil_div(block_size);
+ let mut next_block_num = self.inode.read().size().div_ceil(block_size);
if next_block_num < 12 {
let mut inode = self.inode.write();
diff --git a/src/aero_kernel/src/syscall/time.rs b/src/aero_kernel/src/syscall/time.rs
index f48328cf11e..cde62a4eeaa 100644
--- a/src/aero_kernel/src/syscall/time.rs
+++ b/src/aero_kernel/src/syscall/time.rs
@@ -23,14 +23,13 @@ use alloc::vec::Vec;
use crate::userland::scheduler;
use crate::userland::task::Task;
use crate::utils::sync::{IrqGuard, Mutex};
-use crate::utils::CeilDiv;
const CLOCK_TYPE_REALTIME: usize = 0;
const CLOCK_TYPE_MONOTONIC: usize = 1;
#[syscall]
pub fn sleep(timespec: &TimeSpec) -> Result {
- let duration = (timespec.tv_nsec as usize).ceil_div(1000000000) + timespec.tv_sec as usize;
+ let duration = (timespec.tv_nsec as usize).div_ceil(1000000000) + timespec.tv_sec as usize;
scheduler::get_scheduler().inner.sleep(Some(duration))?;
diff --git a/src/aero_kernel/src/utils/mod.rs b/src/aero_kernel/src/utils/mod.rs
index 5678717fce6..081c8284836 100644
--- a/src/aero_kernel/src/utils/mod.rs
+++ b/src/aero_kernel/src/utils/mod.rs
@@ -223,32 +223,5 @@ impl<'a> StackHelper<'a> {
}
}
-pub trait CeilDiv {
- fn ceil_div(self, d: Self) -> Self;
-}
-
-macro_rules! ceil_div_impl {
- ($($t:ty)*) => ($(
- impl CeilDiv for $t {
- fn ceil_div(self, d: $t) -> $t {
- (self + d - 1) / d
- }
- }
- )*)
-}
-
-ceil_div_impl!(u8 u16 u32 u64 usize u128);
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn unsigned_div_ceil() {
- assert_eq!((8usize).ceil_div(3), 3);
- assert_eq!((7usize).ceil_div(4), 2);
- }
-}
-
#[repr(transparent)]
pub struct LinkerSymbol(core::cell::UnsafeCell);
From f0c6d28053b4d30569417fd2b2f5ee408aafcd51 Mon Sep 17 00:00:00 2001
From: Anhad Singh
Date: Sat, 7 Oct 2023 16:31:07 +1100
Subject: [PATCH 006/112] misc(unwind): update to the new panic message format
https://blog.rust-lang.org/2023/10/05/Rust-1.73.0.html#cleaner-panic-messages
Signed-off-by: Anhad Singh
---
src/aero_kernel/src/unwind.rs | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/src/aero_kernel/src/unwind.rs b/src/aero_kernel/src/unwind.rs
index 855caa37268..af3f49a7698 100644
--- a/src/aero_kernel/src/unwind.rs
+++ b/src/aero_kernel/src/unwind.rs
@@ -163,8 +163,8 @@ use crate::utils::sync::IrqGuard;
fn rust_begin_unwind(info: &PanicInfo) -> ! {
prepare_panic();
- let default_panic = &format_args!("");
- let panic_message = info.message().unwrap_or(default_panic);
+ let message = info.message().unwrap();
+ let location = info.location().unwrap();
// Get the CPU ID where this panic happened and if PANIC_HOOK_READY is false
// then we cannot get the CPU where this panic happened.
@@ -174,14 +174,8 @@ fn rust_begin_unwind(info: &PanicInfo) -> ! {
0x00
};
- log::error!("cpu '{}' panicked at '{}'", cpu_id, panic_message);
-
- // Print the panic location if it is available.
- if let Some(panic_location) = info.location() {
- log::error!("{}", panic_location);
- }
-
- // Add a new line to make the stack trace more readable.
+ log::error!("cpu '{cpu_id}' panicked at {location}:");
+ log::error!("{message}");
log::error!("");
unwind_stack_trace();
From deb049b04ed3e3f55e292bd62f9ac37cc7b0dade Mon Sep 17 00:00:00 2001
From: Anhad Singh
Date: Fri, 13 Oct 2023 20:04:03 +1100
Subject: [PATCH 007/112] ports: add webkitgtk
Signed-off-by: Anhad Singh
---
base-files/a | 21 +-
bootstrap.yml | 54 +-
bootstrap/net.yml | 476 +++++++--
bootstrap/x11-themes.yml | 49 +
bootstrap/xorg.yml | 139 ++-
extra-files/firefox/mozconfig | 26 +
patches/alsa-lib/alsa-lib.patch | 124 +++
patches/mlibc/mlibc.patch | 2 +-
patches/nss/0001-Add-a-missing-include.patch | 24 +
patches/nss/0002-NSS-Standalone-patch.patch | 258 +++++
patches/rust-getrandom/rust-getrandom.patch | 53 +
patches/rust-libc/rust-libc.patch | 996 ------------------
patches/rust-libloading/rust-libloading.patch | 23 +-
patches/rust-nix/rust-nix.patch | 506 ++++++---
patches/webkitgtk/webkitgtk.patch | 45 +-
patches/xorg-server/xorg-server.patch | 181 ++--
src/aero_kernel/src/arch/x86_64/task.rs | 4 +-
src/aero_kernel/src/fs/block/mod.rs | 1 +
src/aero_kernel/src/fs/eventfd.rs | 4 +-
src/aero_kernel/src/fs/ext2/group_desc.rs | 18 +-
src/aero_kernel/src/fs/ext2/mod.rs | 15 +-
src/aero_kernel/src/fs/mod.rs | 16 +-
src/aero_kernel/src/main.rs | 1 +
src/aero_kernel/src/mem/paging/mapper.rs | 7 +-
src/aero_kernel/src/rendy.rs | 5 +-
src/aero_kernel/src/syscall/fs.rs | 5 +-
src/aero_kernel/src/syscall/mod.rs | 4 +
src/aero_kernel/src/userland/vm.rs | 20 +-
src/aero_proc/src/syscall.rs | 32 +-
tools/cargo-inject-patches.py | 10 +-
userland/apps/init/src/main.rs | 24 +-
31 files changed, 1714 insertions(+), 1429 deletions(-)
create mode 100644 bootstrap/x11-themes.yml
create mode 100644 extra-files/firefox/mozconfig
create mode 100644 patches/alsa-lib/alsa-lib.patch
create mode 100644 patches/nss/0001-Add-a-missing-include.patch
create mode 100644 patches/nss/0002-NSS-Standalone-patch.patch
create mode 100644 patches/rust-getrandom/rust-getrandom.patch
delete mode 100644 patches/rust-libc/rust-libc.patch
diff --git a/base-files/a b/base-files/a
index d9ae7e1d5e3..6a904dd38ac 100644
--- a/base-files/a
+++ b/base-files/a
@@ -1,2 +1,21 @@
#!/usr/bin/bash
-systrace curl 192.168.1.25:8080
+
+echo "Running update-mime-database to get the mime database"
+update-mime-database /usr/share/mime/
+
+echo "Running gio-querymodules to generate gio cache"
+gio-querymodules /usr/lib/gio/modules/
+
+echo "Running glib-compile-schemas to get gtk3 working"
+glib-compile-schemas /usr/share/glib-2.0/schemas/
+
+echo "Running gdk-pixbuf-query-loaders to get gtk3 working"
+gdk-pixbuf-query-loaders --update-cache
+
+echo "Running gtk-query-immodules-3.0 to get gtk3 working"
+gtk-query-immodules-3.0 --update-cache
+
+echo "Running gtk-query-immodules-2.0 to get gtk2 working"
+gtk-query-immodules-2.0 --update-cache
+
+/usr/libexec/webkit2gtk-4.0/MiniBrowser
diff --git a/bootstrap.yml b/bootstrap.yml
index 4991de639da..dd8b37f0753 100644
--- a/bootstrap.yml
+++ b/bootstrap.yml
@@ -1,5 +1,6 @@
imports:
- file: bootstrap/xorg.yml
+ - file: bootstrap/x11-themes.yml
- file: bootstrap/net.yml
- file: bootstrap/vcs.yml
- file: bootstrap/db.yml
@@ -94,13 +95,14 @@ sources:
- name: rust-libc
subdir: 'bundled'
git: 'https://github.com/Andy-Python-Programmer/libc.git'
+ commit: 'fe4e9cda46b0be8421b0f56df0b63b8c4dcaf5e6'
branch: 'master'
- name: rust-num-cpus
subdir: 'bundled'
git: 'https://github.com/seanmonstar/num_cpus.git'
- tag: 'v1.13.0'
- version: '1.13.0'
+ tag: 'v1.15.0'
+ version: '1.15.0'
- name: rust-users
subdir: 'bundled'
@@ -123,8 +125,8 @@ sources:
- name: rust-nix
subdir: 'bundled'
git: 'https://github.com/nix-rust/nix.git'
- tag: 'v0.22.3'
- version: '0.22.3'
+ tag: 'v0.24.3'
+ version: '0.24.3'
- name: rust-mio-0.6
subdir: 'bundled'
@@ -148,8 +150,21 @@ sources:
- name: rust-libloading
subdir: 'bundled'
git: 'https://github.com/nagisa/rust_libloading.git'
- tag: '0.7.3'
- version: '0.7.3'
+ tag: '0.8.1'
+ version: '0.8.1'
+
+ - name: rust-getrandom
+ subdir: 'bundled'
+ git: 'https://github.com/rust-random/getrandom.git'
+ tag: 'v0.2.9'
+ version: '0.2.9'
+
+ - name: rust-rustix
+ subdir: 'bundled'
+ git: 'https://github.com/bytecodealliance/rustix'
+ branch: 'main'
+ # For some reason they do not have a release tag for the latest release. Bruh momento.
+ commit: '2eedbb2fa1e18a11f44df10fa41ef82a6756caf3'
- name: rust-patched-libs
subdir: 'bundled'
@@ -174,6 +189,10 @@ sources:
recursive: true
- name: rust-libloading
recursive: true
+ - name: rust-getrandom
+ recursive: true
+ - name: rust-rustix
+ recursive: true
# ---------------------------------------------------------------------------
# Rust patched crates end
# ---------------------------------------------------------------------------
@@ -229,15 +248,15 @@ sources:
- name: icu
subdir: 'bundled'
git: 'https://github.com/unicode-org/icu.git'
- tag: 'release-70-1'
- version: '70.1'
+ tag: 'release-73-2'
+ version: '73.2'
tools_required:
- host-autoconf-v2.69
- host-automake-v1.16
- host-libtool
regenerate:
- args: ['cp',
- '@BUILD_ROOT@/tools/host-automake-v1.15/share/automake-1.15/config.sub',
+ '@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub',
'@THIS_SOURCE_DIR@/icu4c/source']
tools:
@@ -303,6 +322,23 @@ tools:
install:
- args: ['make', 'install']
+
+ - name: host-autoconf-v2.13
+ source:
+ name: autoconf-v2.13
+ subdir: 'bundled'
+ url: 'https://ftp.gnu.org/gnu/autoconf/autoconf-2.13.tar.gz'
+ format: 'tar.gz'
+ extract_path: 'autoconf-2.13'
+ patch-path-strip: 3
+ version: '2.13'
+ configure:
+ - args: ['@THIS_SOURCE_DIR@/configure', '--prefix=@PREFIX@']
+ compile:
+ - args: ['make', '-j@PARALLELISM@']
+ install:
+ - args: ['make', 'install']
+
- name: host-automake-v1.16
source:
name: automake-v1.16
diff --git a/bootstrap/net.yml b/bootstrap/net.yml
index 5960dc8c71e..fb8a47a2d2c 100644
--- a/bootstrap/net.yml
+++ b/bootstrap/net.yml
@@ -1,3 +1,10 @@
+sources:
+ - name: nss
+ subdir: 'bundled'
+ git: 'https://github.com/nss-dev/nss.git'
+ tag: 'NSS_3_94_RTM'
+ version: '3.94.RTM'
+
packages:
- name: dhcpd
source:
@@ -318,88 +325,409 @@ packages:
environ:
DESTDIR: '@THIS_COLLECT_DIR@'
- # - name: webkitgtk
- # metadata:
- # summary: 'An open source web browser engine, with a small example browser'
- # description: 'This package provides WebKitGTK, a port of the portable web rendering engine WebKit to the GTK+ 3 and GTK 4 platforms.'
- # spdx: 'LGPL-2.0-or-later BSD-2-Clause'
- # website: 'https://webkitgtk.org'
- # maintainer: "Dennis Bonke "
- # categories: ['net-libs']
+ - name: alsa-lib
+ source:
+ subdir: 'bundled'
+ git: 'https://github.com/alsa-project/alsa-lib.git'
+ tag: 'v1.2.9'
+ version: '1.2.9'
+ tools_required:
+ - host-autoconf-v2.69
+ - host-automake-v1.16
+ - host-libtool
+ - host-pkg-config
+ - virtual: pkgconfig-for-target
+ triple: "x86_64-aero"
+ regenerate:
+ - args: ['autoreconf', '-fvi']
+ tools_required:
+ - host-gcc
+ pkgs_required:
+ - mlibc
+ configure:
+ - args:
+ - '@THIS_SOURCE_DIR@/configure'
+ - '--host=x86_64-aero'
+ - '--prefix=/usr'
+ - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot.
+ build:
+ - args: ['make', '-j@PARALLELISM@']
+ - args: ['make', 'install']
+ environ:
+ DESTDIR: '@THIS_COLLECT_DIR@'
+
+ - name: nspr
+ source:
+ subdir: 'bundled'
+ hg: 'https://hg.mozilla.org/projects/nspr/'
+ tag: 'NSPR_4_35_RTM'
+ version: '4.35.1'
+ tools_required:
+ - host-autoconf-v2.69
+ - host-automake-v1.16
+ - host-libtool
+ regenerate:
+ - args: ['autoreconf', '-fvi']
+ - args: ['cp',
+ '@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub',
+ '@THIS_SOURCE_DIR@/build/autoconf/']
+ tools_required:
+ - host-gcc
+ pkgs_required:
+ - mlibc
+ configure:
+ # Disable installing two unneeded scripts.
+ - args: ['sed', '-ri', '/^RELEASE/s/^/#/', '@THIS_SOURCE_DIR@/pr/src/misc/Makefile.in']
+ # Disable installing static libraries.
+ - args: ['sed', '-i', 's#$(LIBRARY) ##', '@THIS_SOURCE_DIR@/config/rules.mk']
+ - args:
+ - '@THIS_SOURCE_DIR@/configure'
+ - '--host=x86_64-linux'
+ - '--build=x86_64-linux'
+ - '--prefix=/usr'
+ - '--with-mozilla'
+ - '--with-pthreads'
+ - '--enable-64bit'
+ environ:
+ CROSS_COMPILE: '1'
+ ac_cv_func_syscall: 'no'
+ build:
+ # We first build a native nsinstall that the build can use later on.
+ - args: ['make', 'CC=gcc', 'CXX=g++', '-C', '@THIS_BUILD_DIR@/config/']
+ - args: ['mv', '-v', '@THIS_BUILD_DIR@/config/nsinstall', '@THIS_BUILD_DIR@/config/native-nsinstall']
+ - args: ['sed', '-s', 's#/nsinstall$#/native-nsinstall#', '-i', '@THIS_BUILD_DIR@/config/autoconf.mk']
+ - args: ['rm', '-v', '@THIS_BUILD_DIR@/config/nsinstall.o']
+ # Then build the real deal
+ - args: ['make', 'CC=x86_64-aero-gcc', 'CXX=x86_64-aero-g++', '-j@PARALLELISM@']
+ - args: ['make', 'install']
+ environ:
+ DESTDIR: '@THIS_COLLECT_DIR@'
+ quiet: true
+
+ - name: nss
+ from_source: nss
+ tools_required:
+ - host-gcc
+ pkgs_required:
+ - mlibc
+ - nspr
+ - sqlite
+ - zlib
+ configure:
+ - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@']
+ build:
+ # First, build a host version of nsinstall.
+ - args: ['make', '-C', '@THIS_BUILD_DIR@/coreconf/']
+ environ:
+ CC: 'gcc'
+ BUILD_OPT: '1'
+ NSPR_INCLUDE_DIR: '/usr/include/nspr'
+ USE_SYSTEM_ZLIB: '1'
+ ZLIB_LIBS: '-lz'
+ NSS_ENABLE_WERROR: '0'
+ USE_64: '1'
+ NSS_USE_SYSTEM_SQLITE: '1'
+ NS_USE_GCC: '1'
+ CC_IS_GCC: '1'
+ NSDISTMODE: 'copy'
+ # Then, build some configuration items courtesy of BLFS (see the patches).
+ - args: |
+ make V=1 -C @THIS_BUILD_DIR@/config NSINSTALL=@THIS_BUILD_DIR@/$(find -type f -name nsinstall) -j1
+ environ:
+ # Optimized builds.
+ BUILD_OPT: '1'
+ # NSPR is here.
+ NSPR_INCLUDE_DIR: '@SYSROOT_DIR@/usr/include/nspr'
+ # Use our zlib.
+ USE_SYSTEM_ZLIB: '1'
+ # Freestanding freebl yes please.
+ FREEBL_NO_DEPEND: '1'
+ FREEBL_LOWHASH: '1'
+ NSS_SEED_ONLY_DEV_URANDOM: '1'
+ # Link with zlib.
+ ZLIB_LIBS: '-lz'
+ # Do not enable Werror.
+ NSS_ENABLE_WERROR: '0'
+ # We are 64 bit.
+ USE_64: '1'
+ # Use system sqlite.
+ NSS_USE_SYSTEM_SQLITE: '1'
+ # We're using gcc.
+ NS_USE_GCC: '1'
+ CC_IS_GCC: '1'
+ # We're cross compiling.
+ CROSS_COMPILE: '1'
+ # Don't symlink files, copy them.
+ NSDISTMODE: 'copy'
+ # Do not build the tests.
+ NSS_DISABLE_GTESTS: '1'
+ # Put the libs and binaries here.
+ SOURCE_PREFIX: '@THIS_BUILD_DIR@/dist'
+ # Specify the compiler.
+ CC: 'x86_64-aero-gcc'
+ CXX: 'x86_64-aero-g++'
+ # Then build the main libraries and binaries.
+ - args: |
+ make V=1 -C @THIS_BUILD_DIR@/. NSINSTALL=@THIS_BUILD_DIR@/$(find -type f -name nsinstall) -j1
+ environ:
+ BUILD_OPT: '1'
+ NSPR_INCLUDE_DIR: '@SYSROOT_DIR@/usr/include/nspr'
+ USE_SYSTEM_ZLIB: '1'
+ FREEBL_NO_DEPEND: '1'
+ FREEBL_LOWHASH: '1'
+ NSS_SEED_ONLY_DEV_URANDOM: '1'
+ ZLIB_LIBS: '-lz'
+ NSS_ENABLE_WERROR: '0'
+ USE_64: '1'
+ NSS_USE_SYSTEM_SQLITE: '1'
+ NS_USE_GCC: '1'
+ CC_IS_GCC: '1'
+ CROSS_COMPILE: '1'
+ NSDISTMODE: 'copy'
+ NSS_DISABLE_GTESTS: '1'
+ SOURCE_PREFIX: '@THIS_BUILD_DIR@/dist'
+ CC: 'x86_64-aero-gcc'
+ CXX: 'x86_64-aero-g++'
+ # Create some directories to install into.
+ - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr/lib/pkgconfig']
+ - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr/bin']
+ - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr/include']
+ # And install everything, this _will_ break on a non Linux box, but unfortunately NSS hardcodes kernel names and versions.
+ # If someone wants to patch NSS to not do that, greatly appreciated.
+ # These install instructions are adapted from BLFS, and not Gentoo as I usually do.
+ - args: |
+ cd dist
+ install -v -m755 Linux*/lib/*.so @THIS_COLLECT_DIR@/usr/lib
+ install -v -m644 Linux*/lib/{*.chk,libcrmf.a} @THIS_COLLECT_DIR@/usr/lib
+ install -v -m755 -d @THIS_COLLECT_DIR@/usr/include/nss
+ cp -v -RL {public,private}/nss/* @THIS_COLLECT_DIR@/usr/include/nss
+ chmod -v 644 @THIS_COLLECT_DIR@/usr/include/nss/*
+ install -v -m755 Linux*/bin/{certutil,nss-config,pk12util} @THIS_COLLECT_DIR@/usr/bin
+ install -v -m644 Linux*/lib/pkgconfig/nss.pc @THIS_COLLECT_DIR@/usr/lib/pkgconfig
+
+ - name: libevent
+ source:
+ subdir: bundled
+ git: 'https://github.com/libevent/libevent.git'
+ tag: 'release-2.1.12-stable'
+ version: '2.1.12'
+ tools_required:
+ - host-autoconf-v2.69
+ - host-automake-v1.16
+ - host-libtool
+ - host-pkg-config
+ regenerate:
+ - args: ['./autogen.sh']
+ # Fix an issue that prevents event_rpcgen.py from working.
+ - args: ['sed', '-i', 's/python/&3/', '@THIS_SOURCE_DIR@/event_rpcgen.py']
+ tools_required:
+ - host-gcc
+ pkgs_required:
+ - mlibc
+ - openssl
+ - zlib
+ configure:
+ - args:
+ - '@THIS_SOURCE_DIR@/configure'
+ - '--host=x86_64-aero'
+ - '--prefix=/usr'
+ - '--disable-static'
+ build:
+ - args: ['make', '-j@PARALLELISM@']
+ - args: ['make', 'install']
+ environ:
+ DESTDIR: '@THIS_COLLECT_DIR@'
+
+ - name: libvpx
+ source:
+ subdir: 'bundled'
+ git: 'https://chromium.googlesource.com/webm/libvpx.git'
+ tag: 'v1.11.0'
+ version: '1.11.0'
+ tools_required:
+ - host-gcc
+ pkgs_required:
+ - mlibc
+ configure:
+ # Fix ownership and permission of installed files.
+ - args: ['sed', '-i', 's/cp -p/cp/', '@THIS_SOURCE_DIR@/build/make/Makefile']
+ - args:
+ - '@THIS_SOURCE_DIR@/configure'
+ - '--prefix=/usr'
+ - '--disable-static'
+ - '--enable-shared'
+ # Generic GNU target to disable optimizations
+ - '--force-target=generic-gnu'
+ - '--enable-pic'
+ - '--enable-vp8'
+ - '--enable-vp9'
+ - '--enable-multithread'
+ - '--enable-vp9-highbitdepth'
+ - '--disable-examples'
+ - '--disable-install-docs'
+ - '--disable-docs'
+ build:
+ - args: ['make', 'HAVE_GNU_STRIP=no', 'CC=x86_64-aero-gcc', 'LD=x86_64-aero-gcc', 'CXX=x86_64-aero-g++', 'AR=x86_64-aero-ar', 'NM=x86_64-aero-nm', '-j@PARALLELISM@']
+ - args: ['make', 'install']
+ environ:
+ DESTDIR: '@THIS_COLLECT_DIR@'
+
+ # - name: firefox
# source:
# subdir: 'bundled'
- # git: 'https://github.com/WebKit/WebKit.git'
- # # I think? Apple is weird with naming
- # tag: 'Safari-612.1.27.0.24'
- # version: '2.33.3'
+ # git: 'https://github.com/mozilla/gecko-dev'
+ # commit: 7baa783763c946ff667c3faea292e91d3de1e459
+ # branch: master
+ # configure:
+ # - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@']
+ # - args: ['cp', '@SOURCE_ROOT@/extra-files/firefox/mozconfig', '@THIS_BUILD_DIR@/mozconfig']
# tools_required:
# - host-gcc
- # - host-cmake
+ # - host-rust
+ # - host-pkg-config
+ # # - virtual: pkgconfig-for-target
+ # # triple: "x86_64-aero"
# pkgs_required:
# - mlibc
- # - cairo
- # - fontconfig
- # - freetype
- # - libgcrypt
+ # - alsa-lib
# - glib
- # - harfbuzz
- # - icu
- # - libjpeg-turbo
- # - zlib
- # - libpng
- # - libxml
- # - atk
- # - sqlite
- # - libwebp
# - gtk+-3
- # - libsoup
- # - libxslt
- # - at-spi2-core
- # - libtasn
- # - libx11
- # - libxcomposite
- # - libxdamage
- # - libxrender
- # - libxt
- # - mesa
- # # - gst-plugins-base
+ # - gtk+-2
+ # - icu
+ # - gcc
+ # - nspr
+ # - nss
+ # - libvpx
+ # - libevent
+ # sources_required:
+ # - rust-patched-libs
+ # build:
+ # - args: ['./mach', 'build']
+ # environ:
+ # HOST_CC: 'gcc'
+ # HOST_CXX: 'g++'
+ # CC: 'x86_64-aero-gcc'
+ # CXX: 'x86_64-aero-g++'
+ # CARGOFLAGS: '--verbose'
+ # MOZ_RUST_TIER: '1'
+ # BINDGEN_EXTRA_CLANG_ARGS: '-isystem@SYSROOT_DIR/usr/include'
+ # # CROSS_SYSROOT: '@SYSROOT_DIR@'./system-root/usr/include/c++/11.2.0/memory
+
+ # cargo install cbindgen
+ #
+ # pacman -S autoconf2.13
+ # - name: firefox-esr
+ # source:
+ # subdir: 'bundled'
+ # git: 'https://github.com/mozilla/gecko-dev'
+ # branch: 'FIREFOX_ESR_68_0_X_RELBRANCH'
# configure:
- # - args:
- # - 'cmake'
- # - '-GNinja'
- # - '-DCMAKE_TOOLCHAIN_FILE=@SOURCE_ROOT@/userland/CMakeToolchain-x86_64.cmake'
- # - '-DCMAKE_INSTALL_PREFIX=/usr'
- # - '-DCMAKE_SYSTEM_PROCESSOR=x86_64'
- # - '-DCMAKE_BUILD_TYPE=Release'
- # - '-DCMAKE_SKIP_RPATH=ON'
- # - '-DPORT=GTK'
- # - '-DLIB_INSTALL_DIR=/usr/lib'
- # - '-DUSE_LIBHYPHEN=OFF'
- # - '-DENABLE_GAMEPAD=OFF'
- # - '-DENABLE_MINIBROWSER=ON'
- # - '-DUSE_WOFF2=OFF'
- # - '-DUSE_SYSTEMD=OFF'
- # - '-DENABLE_BUBBLEWRAP_SANDBOX=OFF'
- # - '-Wno-dev -G Ninja'
- # - '-DUSE_LIBNOTIFY=OFF'
- # - '-DUSE_SYSTEM_MALLOC=ON'
- # - '-DENABLE_GEOLOCATION=OFF'
- # - '-DENABLE_VIDEO=OFF'
- # - '-DENABLE_WEB_AUDIO=OFF'
- # - '-DENABLE_INTROSPECTION=OFF'
- # - '-DUSE_LIBSECRET=OFF'
- # - '-DUSE_OPENJPEG=OFF'
- # - '-DENABLE_SPELLCHECK=OFF'
- # - '-DENABLE_WAYLAND_TARGET=OFF'
- # - '-DENABLE_X11_TARGET=ON'
- # - '-DENABLE_WEBGL=ON'
- # - '-DUSE_WPE_RENDERER=OFF'
- # - '-DENABLE_WEBGL2=OFF'
- # - '-DUSE_SOUP2=ON'
- # - '-DUSE_LCMS=OFF'
- # - '@THIS_SOURCE_DIR@'
+ # - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@']
+ # - args: ['cp', '@SOURCE_ROOT@/extra-files/firefox/mozconfig', '@THIS_BUILD_DIR@/mozconfig']
+ # tools_required:
+ # - host-gcc
+ # - host-rust
+ # - host-pkg-config
+ # # - virtual: pkgconfig-for-target
+ # # triple: "x86_64-aero"
+ # pkgs_required:
+ # - mlibc
+ # - alsa-lib
+ # - glib
+ # - gtk+-3
+ # - gtk+-2
+ # - gcc
# build:
- # - args: ['ninja', '-j8']
- # - args: ['ninja', 'install']
+ # # python ~/work/aero/tools/cargo-inject-patches.py ./Cargo.toml
+ # - args: ['./mach', 'build']
# environ:
- # DESTDIR: '@THIS_COLLECT_DIR@'
+ # HOST_CC: 'clang'
+ # CC: 'x86_64-aero-gcc'
+ # CARGOFLAGS: '--verbose'
+ # # - args: ['./mach', 'install']
+ # # environ:
+ # # DESTDIR: '@THIS_COLLECT_DIR@'
+
+ # /home/andy/work/aero/bundled/webkitgtk/Source/ThirdParty/ANGLE/src/common/system_utils_posix.cpp:313:14: error: ‘mkstemps’ was not declared in this scope; did you mean ‘mkstemp’?
+ # 313 | int fd = mkstemps(&tempFileTemplate[0], static_cast(extension.size()));
+ # | ^~~~~~~~
+ # | mkstemp
+ - name: webkitgtk
+ source:
+ subdir: bundled
+ git: 'https://github.com/WebKit/WebKit.git'
+ # I think? Apple is weird with naming
+ tag: 'Safari-612.1.27.0.24'
+ version: '2.33.3'
+ tools_required:
+ - host-gcc
+ - host-cmake
+ pkgs_required:
+ - mlibc
+ - cairo
+ - fontconfig
+ - freetype
+ - libgcrypt
+ - glib
+ - harfbuzz
+ - icu
+ - libjpeg-turbo
+ - zlib
+ - sqlite
+ - libpng
+ - libxml
+ - atk
+ - libwebp
+ - gtk+-3
+ - libsoup
+ - libxslt
+ - at-spi2-core
+ - libtasn
+ - libx11
+ - libxcomposite
+ - libxdamage
+ - libxrender
+ - libxt
+ - mesa
+ configure:
+ - args:
+ - 'cmake'
+ - '-GNinja'
+ - '-DCMAKE_TOOLCHAIN_FILE=@SOURCE_ROOT@/userland/CMakeToolchain-x86_64.cmake'
+ - '-DCMAKE_INSTALL_PREFIX=/usr'
+ - '-DCMAKE_SYSTEM_PROCESSOR=x86_64'
+ - '-DCMAKE_BUILD_TYPE=Release'
+ - '-DCMAKE_SKIP_RPATH=ON'
+ - '-DPORT=GTK'
+ - '-DLIB_INSTALL_DIR=/usr/lib'
+ - '-DUSE_LIBHYPHEN=OFF'
+ - '-DENABLE_GAMEPAD=OFF'
+ - '-DENABLE_MINIBROWSER=ON'
+ - '-DUSE_WOFF2=OFF'
+ - '-DUSE_SYSTEMD=OFF'
+ - '-DENABLE_BUBBLEWRAP_SANDBOX=OFF'
+ - '-Wno-dev -G Ninja'
+ - '-DUSE_LIBNOTIFY=OFF'
+ - '-DUSE_SYSTEM_MALLOC=ON'
+ - '-DENABLE_GEOLOCATION=OFF'
+ - '-DENABLE_VIDEO=OFF'
+ - '-DENABLE_WEB_AUDIO=OFF'
+ - '-DENABLE_INTROSPECTION=OFF'
+ - '-DUSE_LIBSECRET=OFF'
+ - '-DUSE_OPENJPEG=OFF'
+ - '-DENABLE_SPELLCHECK=OFF'
+ - '-DENABLE_WAYLAND_TARGET=OFF'
+ - '-DENABLE_X11_TARGET=ON'
+ - '-DENABLE_WEBGL=ON'
+ - '-DUSE_WPE_RENDERER=OFF'
+ - '-DENABLE_WEBGL2=OFF'
+ - '-DUSE_SOUP2=ON'
+ - '-DUSE_LCMS=OFF'
+ - '@THIS_SOURCE_DIR@'
+ build:
+ - args: ['ninja', '-j6']
+ # environ:
+ # CXXFLAGS: '-std=c++11'
+ - args: ['ninja', 'install']
+ environ:
+ DESTDIR: '@THIS_COLLECT_DIR@'
diff --git a/bootstrap/x11-themes.yml b/bootstrap/x11-themes.yml
new file mode 100644
index 00000000000..09506dfd667
--- /dev/null
+++ b/bootstrap/x11-themes.yml
@@ -0,0 +1,49 @@
+packages:
+ # This package contains a default fallback theme for implementations of the icon theme specification.
+ - name: hicolor-icon-theme
+ source:
+ subdir: 'bundled'
+ git: 'https://gitlab.freedesktop.org/xdg/default-icon-theme.git'
+ tag: '0.17'
+ version: '0.17'
+ tools_required:
+ - host-autoconf-v2.69
+ - host-automake-v1.16
+ regenerate:
+ - args: ['./autogen.sh', '--no-configure']
+ tools_required:
+ - host-gcc
+ configure:
+ - args:
+ - '@THIS_SOURCE_DIR@/configure'
+ - '--host=x86_64-aero'
+ - '--prefix=/usr'
+ build:
+ - args: ['make', '-j@PARALLELISM@']
+ - args: ['make', 'install']
+ environ:
+ DESTDIR: '@THIS_COLLECT_DIR@'
+
+ - name: adwaita-icon-theme
+ source:
+ subdir: 'bundled'
+ git: 'https://gitlab.gnome.org/GNOME/adwaita-icon-theme.git'
+ tag: '45.0'
+ version: '45.0'
+ tools_required:
+ - host-gcc
+ pkgs_required:
+ - hicolor-icon-theme
+ configure:
+ - args:
+ - 'meson'
+ - '--cross-file'
+ - '@SOURCE_ROOT@/userland/cross-file.ini'
+ - '--prefix=/usr'
+ - '--sysconfdir=/etc'
+ - '@THIS_SOURCE_DIR@'
+ build:
+ - args: ['ninja']
+ - args: ['ninja', 'install']
+ environ:
+ DESTDIR: '@THIS_COLLECT_DIR@'
diff --git a/bootstrap/xorg.yml b/bootstrap/xorg.yml
index cfde0b56cd7..2c9f9a4b604 100644
--- a/bootstrap/xorg.yml
+++ b/bootstrap/xorg.yml
@@ -1008,8 +1008,8 @@ packages:
source:
subdir: 'bundled'
git: 'https://gitlab.freedesktop.org/xorg/xserver.git'
- tag: 'xorg-server-21.1.8'
- version: '21.1.8'
+ tag: 'xorg-server-1.20.14'
+ version: '1.20.14'
tools_required:
- host-autoconf-v2.69
- host-automake-v1.16
@@ -2357,6 +2357,104 @@ packages:
# post_install:
# - args: 'glib-compile-schemas /usr/share/glib-2.0/schemas'
+ # Deprecated, please don't depend on this anymore. Only here for gtklife and hexchat.
+ - name: gtk+-2
+ source:
+ subdir: 'bundled'
+ url: 'https://download.gnome.org/sources/gtk+/2.24/gtk+-2.24.32.tar.xz'
+ format: 'tar.xz'
+ checksum: blake2b:03f4c0a8be98473f62bc8c86859937969c4169960a5f93d37ff6dcde00413215fa6c7125b15781bf50d67b40aa0056cb71b83fb50acb2c3467b5deb3c8d938f0
+ extract_path: 'gtk+-2.24.32'
+ patch-path-strip: 1
+ version: '2.24.32'
+ tools_required:
+ - host-autoconf-v2.69
+ - host-automake-v1.16
+ - host-libtool
+ - host-pkg-config
+ - host-xorg-macros
+ - host-glib
+ regenerate:
+ - args: ['autoreconf', '-fvi']
+ tools_required:
+ - host-gcc
+ - virtual: pkgconfig-for-target
+ triple: "x86_64-aero"
+ pkgs_required:
+ - mlibc
+ - atk
+ - cairo
+ - glib
+ - gdk-pixbuf
+ - libx11
+ - libxext
+ - libxcb
+ - pango
+ configure:
+ - args:
+ - '@THIS_SOURCE_DIR@/configure'
+ - '--host=x86_64-aero'
+ - '--prefix=/usr'
+ - '--sysconfdir=/etc'
+ - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot.
+ - '--disable-gtk-doc-html'
+ - '--disable-cups'
+ - '--disable-papi'
+ - '--disable-introspection'
+ - '--disable-glibtest'
+ - '--disable-test-print-backend'
+ - '--enable-xkb'
+ environ:
+ ac_cv_func_getresuid: 'no'
+ build:
+ - args: ['make', '-j@PARALLELISM@']
+ - args: ['make', 'install']
+ environ:
+ DESTDIR: '@THIS_COLLECT_DIR@'
+ quiet: true
+ # Rename a file to avoid conflicts, we will use gtk3 as default, so rename this one.
+ - args: ['mv', '-v', '@THIS_COLLECT_DIR@/usr/bin/gtk-update-icon-cache', '@THIS_COLLECT_DIR@/usr/bin/gtk2-update-icon-cache']
+ scripts:
+ post_install:
+ - args: ['gtk-query-immodules-2.0', '--update-cache']
+ - args: ['glib-compile-schemas', '/usr/share/glib-2.0/schemas']
+
+ # Collection of GSettings schemas for GNOME desktop
+ - name: gsettings-desktop-schemas
+ source:
+ subdir: 'bundled'
+ git: 'https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas.git'
+ tag: '42.0'
+ version: '42.0'
+ tools_required:
+ - host-gcc
+ - host-gobject-introspection
+ - host-libtool
+ - host-pkg-config
+ - virtual: pkgconfig-for-target
+ triple: "x86_64-aero"
+ pkgs_required:
+ - mlibc
+ - glib
+ configure:
+ - args: |
+ sed -i -r 's:"(/system):"/org/gnome\1:g' @THIS_SOURCE_DIR@/schemas/*.in
+ - args:
+ - 'meson'
+ - '--cross-file'
+ - '@SOURCE_ROOT@/userland/cross-file.ini'
+ - '--prefix=/usr'
+ - '-Dintrospection=false'
+ - '@THIS_SOURCE_DIR@'
+ build:
+ - args: ['ninja']
+ - args: ['ninja', 'install']
+ environ:
+ DESTDIR: '@THIS_COLLECT_DIR@'
+ scripts:
+ post_install:
+ - args: 'glib-compile-schemas /usr/share/glib-2.0/schemas'
+
- name: gtk+-3
source:
subdir: 'bundled'
@@ -2391,7 +2489,7 @@ packages:
- libxi
- harfbuzz
- libxcursor
- #- gsettings-desktop-schemas
+ - gsettings-desktop-schemas
- dbus
configure:
- args:
@@ -2502,3 +2600,38 @@ packages:
- args: ['make', 'install']
environ:
DESTDIR: '@THIS_COLLECT_DIR@'
+
+ - name: gdk-pixbuf-xlib
+ source:
+ subdir: 'bundled'
+ url: 'https://download.gnome.org/sources/gdk-pixbuf-xlib/2.40/gdk-pixbuf-xlib-2.40.2.tar.xz'
+ format: 'tar.xz'
+ checksum: blake2b:a515e86bc69f59910f61fe9c275ab89c0732f0aa2cfb614ac94e597de420d25708a11b9b21313c7cfe3763434f45a8318412ae5889c24c8ed57dac68e09c0227
+ extract_path: 'gdk-pixbuf-xlib-2.40.2'
+ patch-path-strip: 1
+ version: '2.40.2'
+ tools_required:
+ - host-gcc
+ - host-libtool
+ - host-pkg-config
+ - virtual: pkgconfig-for-target
+ triple: "x86_64-aero"
+ pkgs_required:
+ - mlibc
+ - gdk-pixbuf
+ - libx11
+ configure:
+ - args:
+ - 'meson'
+ - '--cross-file'
+ - '@SOURCE_ROOT@/userland/cross-file.ini'
+ - '--prefix=/usr'
+ - '@THIS_SOURCE_DIR@'
+ build:
+ - args: ['ninja']
+ - args: ['ninja', 'install']
+ environ:
+ DESTDIR: '@THIS_COLLECT_DIR@'
+ scripts:
+ post_install:
+ - args: ['gdk-pixbuf-query-loaders', '--update-cache']
diff --git a/extra-files/firefox/mozconfig b/extra-files/firefox/mozconfig
new file mode 100644
index 00000000000..fe6dcdbdeb6
--- /dev/null
+++ b/extra-files/firefox/mozconfig
@@ -0,0 +1,26 @@
+ac_add_options --disable-necko-wifi
+ac_add_options --target=x86_64-aero
+ac_add_options --with-toolchain-prefix=x86_64-aero
+ac_add_options --enable-project=browser
+ac_add_options --enable-alsa
+ac_add_options --prefix=/usr
+
+ac_add_options --enable-optimize
+
+# use system libs if possible
+ac_add_options --with-system-nss
+ac_add_options --with-system-jpeg
+ac_add_options --with-system-zlib
+ac_add_options --with-system-icu
+ac_add_options --with-system-libevent
+ac_add_options --with-system-nspr
+ac_add_options --with-system-nss
+ac_add_options --with-system-webp
+
+ac_add_options --enable-default-toolkit=cairo-gtk3
+
+ac_add_options --disable-pulseaudio
+ac_add_options --disable-crashreporter
+ac_add_options --disable-dbus
+ac_add_options --disable-updater
+ac_add_options --disable-tests
diff --git a/patches/alsa-lib/alsa-lib.patch b/patches/alsa-lib/alsa-lib.patch
new file mode 100644
index 00000000000..1ebb5b22abc
--- /dev/null
+++ b/patches/alsa-lib/alsa-lib.patch
@@ -0,0 +1,124 @@
+From 3b4d643d6648ead86648e0033868f903af6aeb70 Mon Sep 17 00:00:00 2001
+From: Dennis Bonke
+Date: Wed, 2 Aug 2023 13:50:05 +0200
+Subject: [PATCH] Add Managarm support
+
+Signed-off-by: Dennis Bonke
+---
+ src/conf.c | 10 ++++++++++
+ src/pcm/pcm_ladspa.c | 5 +++++
+ src/ucm/main.c | 5 +++++
+ src/ucm/parser.c | 8 ++++++++
+ src/ucm/ucm_exec.c | 7 +++++++
+ src/ucm/ucm_subs.c | 5 +++++
+ 6 files changed, 40 insertions(+)
+
+diff --git a/src/conf.c b/src/conf.c
+index da51182..743e4cd 100644
+--- a/src/conf.c
++++ b/src/conf.c
+@@ -435,6 +435,16 @@ beginning:
+ #include
+ #endif
+
++#ifdef __aero__
++#define stat64 stat
++#define dirent64 dirent
++#define lstat64 lstat
++#define readdir64 readdir
++#define scandir64 scandir
++#define versionsort64 versionsort
++typedef ino_t ino64_t;
++#endif
++
+ #ifndef DOC_HIDDEN
+
+ #ifdef HAVE_LIBPTHREAD
+diff --git a/src/pcm/pcm_ladspa.c b/src/pcm/pcm_ladspa.c
+index 9b2b32d..dde5d2a 100644
+--- a/src/pcm/pcm_ladspa.c
++++ b/src/pcm/pcm_ladspa.c
+@@ -41,6 +41,11 @@
+
+ #include "ladspa.h"
+
++#ifdef __aero__
++#define readdir64 readdir
++#define dirent64 dirent
++#endif
++
+ #ifndef PIC
+ /* entry for static linking */
+ const char *_snd_module_pcm_ladspa = "";
+diff --git a/src/ucm/main.c b/src/ucm/main.c
+index 66ffd00..7448963 100644
+--- a/src/ucm/main.c
++++ b/src/ucm/main.c
+@@ -40,6 +40,11 @@
+ #include
+ #include
+
++#ifdef __aero__
++#define stat64 stat
++#define fstat64 fstat
++#endif
++
+ /*
+ * misc
+ */
+diff --git a/src/ucm/parser.c b/src/ucm/parser.c
+index c111661..2115ac7 100644
+--- a/src/ucm/parser.c
++++ b/src/ucm/parser.c
+@@ -36,6 +36,14 @@
+ #include
+ #include
+
++#ifdef __aero__
++#define stat64 stat
++#define lstat64 lstat
++#define scandir64 scandir
++#define versionsort64 versionsort
++#define dirent64 dirent
++#endif
++
+ static int filename_filter(const struct dirent64 *dirent);
+
+ static int parse_sequence(snd_use_case_mgr_t *uc_mgr,
+diff --git a/src/ucm/ucm_exec.c b/src/ucm/ucm_exec.c
+index 276cf59..a6890dd 100644
+--- a/src/ucm/ucm_exec.c
++++ b/src/ucm/ucm_exec.c
+@@ -42,6 +42,13 @@ extern char **environ;
+ #endif
+ #endif
+
++#ifdef __aero__
++#define stat64 stat
++#define dirent64 dirent
++#define lstat64 lstat
++#define readdir64 readdir
++#endif
++
+ static pthread_mutex_t fork_lock = PTHREAD_MUTEX_INITIALIZER;
+
+ /*
+diff --git a/src/ucm/ucm_subs.c b/src/ucm/ucm_subs.c
+index e62290e..b4dbff2 100644
+--- a/src/ucm/ucm_subs.c
++++ b/src/ucm/ucm_subs.c
+@@ -30,6 +30,11 @@
+ #include
+ #include
+
++#ifdef __aero__
++#define stat64 stat
++#define lstat64 lstat
++#endif
++
+ static char *rval_open_name(snd_use_case_mgr_t *uc_mgr)
+ {
+ const char *name;
+--
+2.40.1
+
diff --git a/patches/mlibc/mlibc.patch b/patches/mlibc/mlibc.patch
index e16aed655cc..924b3edfad2 100644
--- a/patches/mlibc/mlibc.patch
+++ b/patches/mlibc/mlibc.patch
@@ -1,4 +1,4 @@
-From 1e4603c9de5ce2dcb596dfb95254b0ae119d1036 Mon Sep 17 00:00:00 2001
+From d33a19a85fd625a2acf53f95f32c369b7f91e230 Mon Sep 17 00:00:00 2001
From: Anhad Singh
Date: Thu, 3 Aug 2023 16:36:12 +1000
Subject: [PATCH] socket: implement shutdown(2)
diff --git a/patches/nss/0001-Add-a-missing-include.patch b/patches/nss/0001-Add-a-missing-include.patch
new file mode 100644
index 00000000000..eb71fcab2a5
--- /dev/null
+++ b/patches/nss/0001-Add-a-missing-include.patch
@@ -0,0 +1,24 @@
+From 8c7f96493b8706d43b30f49d56e0e84ee27fe65e Mon Sep 17 00:00:00 2001
+From: Dennis Bonke
+Date: Wed, 27 Apr 2022 20:27:21 +0200
+Subject: [PATCH 1/2] Add a missing include
+
+Signed-off-by: Dennis Bonke
+---
+ lib/dbm/src/h_page.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/lib/dbm/src/h_page.c b/lib/dbm/src/h_page.c
+index d4e4ff6..7b3271e 100644
+--- a/lib/dbm/src/h_page.c
++++ b/lib/dbm/src/h_page.c
+@@ -81,6 +81,7 @@ static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94";
+ #endif
+
+ #include
++#include
+
+ #include "mcom_db.h"
+ #include "hash.h"
+--
+2.36.0
diff --git a/patches/nss/0002-NSS-Standalone-patch.patch b/patches/nss/0002-NSS-Standalone-patch.patch
new file mode 100644
index 00000000000..cd78732af8a
--- /dev/null
+++ b/patches/nss/0002-NSS-Standalone-patch.patch
@@ -0,0 +1,258 @@
+From ee4b3e43e0143f94289c418c0db5f803119e8be6 Mon Sep 17 00:00:00 2001
+From: Dennis Bonke
+Date: Wed, 27 Apr 2022 20:35:40 +0200
+Subject: [PATCH 2/2] NSS Standalone patch
+
+Taken from Beyond Linux From Scratch (https://www.linuxfromscratch.org/patches/blfs/svn/nss-3.77-standalone-1.patch)
+
+Adds auto-generated nss.pc and nss-config script, and allows building without nspr in the source tree.
+Minimum NSPR version is now read out from package, instead of hardcoded value in the patch.
+
+Signed-off-by: Dennis Bonke
+---
+ config/Makefile | 41 ++++++++++++
+ config/nss-config.in | 152 +++++++++++++++++++++++++++++++++++++++++++
+ config/nss.pc.in | 11 ++++
+ manifest.mn | 2 +-
+ 4 files changed, 205 insertions(+), 1 deletion(-)
+ create mode 100644 config/Makefile
+ create mode 100644 config/nss-config.in
+ create mode 100644 config/nss.pc.in
+
+diff --git a/config/Makefile b/config/Makefile
+new file mode 100644
+index 0000000..662020a
+--- /dev/null
++++ b/config/Makefile
+@@ -0,0 +1,41 @@
++CORE_DEPTH = ..
++DEPTH = ..
++
++include $(CORE_DEPTH)/coreconf/config.mk
++
++NSS_MAJOR_VERSION = `grep "NSS_VMAJOR" ../lib/nss/nss.h | awk '{print $$3}'`
++NSS_MINOR_VERSION = `grep "NSS_VMINOR" ../lib/nss/nss.h | awk '{print $$3}'`
++NSS_PATCH_VERSION = `grep "NSS_VPATCH" ../lib/nss/nss.h | awk '{print $$3}'`
++NSS_NSPR_MINIMUM = `head -n1 ../automation/release/nspr-version.txt`
++PREFIX = /usr
++
++all: export libs
++
++export:
++ # Create the nss.pc file
++ mkdir -p $(DIST)/lib/pkgconfig
++ sed -e "s,@prefix@,$(PREFIX)," \
++ -e "s,@exec_prefix@,\$${prefix}," \
++ -e "s,@libdir@,\$${prefix}/lib," \
++ -e "s,@includedir@,\$${prefix}/include/nss," \
++ -e "s,@NSS_MAJOR_VERSION@,$(NSS_MAJOR_VERSION),g" \
++ -e "s,@NSS_MINOR_VERSION@,$(NSS_MINOR_VERSION)," \
++ -e "s,@NSS_PATCH_VERSION@,$(NSS_PATCH_VERSION)," \
++ -e "s,@NSS_NSPR_MINIMUM@,$(NSS_NSPR_MINIMUM)," \
++ nss.pc.in > nss.pc
++ chmod 0644 nss.pc
++ cp -v nss.pc $(DIST)/lib/pkgconfig
++
++ # Create the nss-config script
++ mkdir -p $(DIST)/bin
++ sed -e "s,@prefix@,$(PREFIX)," \
++ -e "s,@NSS_MAJOR_VERSION@,$(NSS_MAJOR_VERSION)," \
++ -e "s,@NSS_MINOR_VERSION@,$(NSS_MINOR_VERSION)," \
++ -e "s,@NSS_PATCH_VERSION@,$(NSS_PATCH_VERSION)," \
++ nss-config.in > nss-config
++ chmod 0755 nss-config
++ cp -v nss-config $(DIST)/bin
++
++libs:
++
++dummy: all export libs
+diff --git a/config/nss-config.in b/config/nss-config.in
+new file mode 100644
+index 0000000..7e3750d
+--- /dev/null
++++ b/config/nss-config.in
+@@ -0,0 +1,152 @@
++#!/bin/sh
++
++prefix=@prefix@
++
++major_version=@NSS_MAJOR_VERSION@
++minor_version=@NSS_MINOR_VERSION@
++patch_version=@NSS_PATCH_VERSION@
++
++usage()
++{
++ cat <&2
++fi
++
++lib_nss=yes
++lib_nssutil=yes
++lib_smime=yes
++lib_ssl=yes
++lib_softokn=yes
++
++while test $# -gt 0; do
++ case "$1" in
++ -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
++ *) optarg= ;;
++ esac
++
++ case $1 in
++ --prefix=*)
++ prefix=$optarg
++ ;;
++ --prefix)
++ echo_prefix=yes
++ ;;
++ --exec-prefix=*)
++ exec_prefix=$optarg
++ ;;
++ --exec-prefix)
++ echo_exec_prefix=yes
++ ;;
++ --includedir=*)
++ includedir=$optarg
++ ;;
++ --includedir)
++ echo_includedir=yes
++ ;;
++ --libdir=*)
++ libdir=$optarg
++ ;;
++ --libdir)
++ echo_libdir=yes
++ ;;
++ --version)
++ echo ${major_version}.${minor_version}.${patch_version}
++ ;;
++ --cflags)
++ echo_cflags=yes
++ ;;
++ --libs)
++ echo_libs=yes
++ ;;
++ nss)
++ lib_nss=yes
++ ;;
++ nssutil)
++ lib_nssutil=yes
++ ;;
++ smime)
++ lib_smime=yes
++ ;;
++ ssl)
++ lib_ssl=yes
++ ;;
++ softokn)
++ lib_softokn=yes
++ ;;
++ *)
++ usage 1 1>&2
++ ;;
++ esac
++ shift
++done
++
++# Set variables that may be dependent upon other variables
++if test -z "$exec_prefix"; then
++ exec_prefix=`pkg-config --variable=exec_prefix nss`
++fi
++if test -z "$includedir"; then
++ includedir=`pkg-config --variable=includedir nss`
++fi
++if test -z "$libdir"; then
++ libdir=`pkg-config --variable=libdir nss`
++fi
++
++if test "$echo_prefix" = "yes"; then
++ echo $prefix
++fi
++
++if test "$echo_exec_prefix" = "yes"; then
++ echo $exec_prefix
++fi
++
++if test "$echo_includedir" = "yes"; then
++ echo $includedir
++fi
++
++if test "$echo_libdir" = "yes"; then
++ echo $libdir
++fi
++
++if test "$echo_cflags" = "yes"; then
++ echo -I$includedir
++fi
++
++if test "$echo_libs" = "yes"; then
++ libdirs="-L$libdir"
++ if test -n "$lib_nss"; then
++ libdirs="$libdirs -lnss${major_version}"
++ fi
++ if test -n "$lib_nssutil"; then
++ libdirs="$libdirs -lnssutil${major_version}"
++ fi
++ if test -n "$lib_smime"; then
++ libdirs="$libdirs -lsmime${major_version}"
++ fi
++ if test -n "$lib_ssl"; then
++ libdirs="$libdirs -lssl${major_version}"
++ fi
++ if test -n "$lib_softokn"; then
++ libdirs="$libdirs -lsoftokn${major_version}"
++ fi
++ echo $libdirs
++fi
+diff --git a/config/nss.pc.in b/config/nss.pc.in
+new file mode 100644
+index 0000000..c8c263d
+--- /dev/null
++++ b/config/nss.pc.in
+@@ -0,0 +1,11 @@
++prefix=@prefix@
++exec_prefix=@exec_prefix@
++libdir=@libdir@
++includedir=@includedir@
++
++Name: NSS
++Description: Network Security Services
++Version: @NSS_MAJOR_VERSION@.@NSS_MINOR_VERSION@.@NSS_PATCH_VERSION@
++Requires: nspr >= @NSS_NSPR_MINIMUM@
++Libs: -L@libdir@ -lnss@NSS_MAJOR_VERSION@ -lnssutil@NSS_MAJOR_VERSION@ -lsmime@NSS_MAJOR_VERSION@ -lssl@NSS_MAJOR_VERSION@ -lsoftokn@NSS_MAJOR_VERSION@
++Cflags: -I${includedir}
+diff --git a/manifest.mn b/manifest.mn
+index fbc420a..b983d88 100644
+--- a/manifest.mn
++++ b/manifest.mn
+@@ -10,7 +10,7 @@ IMPORTS = nspr20/v4.8 \
+
+ RELEASE = nss
+
+-DIRS = coreconf lib cmd cpputil gtests
++DIRS = coreconf lib cmd cpputil gtests config
+
+ HAVE_ALL_TARGET := 1
+
+--
+2.36.0
diff --git a/patches/rust-getrandom/rust-getrandom.patch b/patches/rust-getrandom/rust-getrandom.patch
new file mode 100644
index 00000000000..9b244bc8249
--- /dev/null
+++ b/patches/rust-getrandom/rust-getrandom.patch
@@ -0,0 +1,53 @@
+From 7ffdb350f8bf10017165131c8433e8371df89754 Mon Sep 17 00:00:00 2001
+From: Dennis Bonke
+Date: Mon, 7 Aug 2023 16:07:20 +0200
+Subject: [PATCH] Add aero support
+
+Signed-off-by: Dennis Bonke
+---
+ src/lib.rs | 2 +-
+ src/use_file.rs | 1 +
+ src/util_libc.rs | 2 +-
+ 3 files changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/src/lib.rs b/src/lib.rs
+index 931856f..e700572 100644
+--- a/src/lib.rs
++++ b/src/lib.rs
+@@ -215,7 +215,7 @@ pub use crate::error::Error;
+ // The function MUST NOT ever write uninitialized bytes into `dest`,
+ // regardless of what value it returns.
+ cfg_if! {
+- if #[cfg(any(target_os = "haiku", target_os = "redox", target_os = "nto", target_os = "aix"))] {
++ if #[cfg(any(target_os = "haiku", target_os = "redox", target_os = "nto", target_os = "aix", target_os = "aero"))] {
+ mod util_libc;
+ #[path = "use_file.rs"] mod imp;
+ } else if #[cfg(any(target_os = "android", target_os = "linux"))] {
+diff --git a/src/use_file.rs b/src/use_file.rs
+index a6ef0d2..ef9bf54 100644
+--- a/src/use_file.rs
++++ b/src/use_file.rs
+@@ -33,6 +33,7 @@ const FILE_PATH: &str = "/dev/random\0";
+ target_os = "haiku",
+ target_os = "macos",
+ target_os = "nto",
++ target_os = "aero",
+ ))]
+ const FILE_PATH: &str = "/dev/urandom\0";
+
+diff --git a/src/util_libc.rs b/src/util_libc.rs
+index de1455c..65bc1a6 100644
+--- a/src/util_libc.rs
++++ b/src/util_libc.rs
+@@ -19,7 +19,7 @@ use libc::c_void;
+ cfg_if! {
+ if #[cfg(any(target_os = "netbsd", target_os = "openbsd", target_os = "android"))] {
+ use libc::__errno as errno_location;
+- } else if #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "redox"))] {
++ } else if #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "redox", target_os = "aero"))] {
+ use libc::__errno_location as errno_location;
+ } else if #[cfg(any(target_os = "solaris", target_os = "illumos"))] {
+ use libc::___errno as errno_location;
+--
+2.42.0
+
diff --git a/patches/rust-libc/rust-libc.patch b/patches/rust-libc/rust-libc.patch
deleted file mode 100644
index 04bc44bb09e..00000000000
--- a/patches/rust-libc/rust-libc.patch
+++ /dev/null
@@ -1,996 +0,0 @@
-From a23324fdc96748fc48b5deb824db43b693b6c5dc Mon Sep 17 00:00:00 2001
-From: Anhad Singh
-Date: Sun, 21 May 2023 12:58:08 +1000
-Subject: [PATCH]
-
----
- .../linux_like/linux/gnu/b64/x86_64/mod.rs | 4 +-
- src/unix/linux_like/linux/gnu/mod.rs | 4 +-
- src/unix/linux_like/linux/mod.rs | 28 +-
- src/unix/mlibc/mod.rs | 568 ++++++++++++++++--
- 4 files changed, 550 insertions(+), 54 deletions(-)
-
-diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs
-index e6307e2..cae81c4 100644
---- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs
-+++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs
-@@ -330,7 +330,7 @@ cfg_if! {
- impl Eq for user_fpregs_struct {}
-
- impl ::fmt::Debug for user_fpregs_struct {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("user_fpregs_struct")
- .field("cwd", &self.cwd)
- .field("ftw", &self.ftw)
-@@ -375,7 +375,7 @@ cfg_if! {
- impl Eq for ucontext_t {}
-
- impl ::fmt::Debug for ucontext_t {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("ucontext_t")
- .field("uc_flags", &self.uc_flags)
- .field("uc_link", &self.uc_link)
-diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs
-index b8b6ded..98b49a0 100644
---- a/src/unix/linux_like/linux/gnu/mod.rs
-+++ b/src/unix/linux_like/linux/gnu/mod.rs
-@@ -519,7 +519,7 @@ cfg_if! {
- impl Eq for utmpx {}
-
- impl ::fmt::Debug for utmpx {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("utmpx")
- .field("ut_type", &self.ut_type)
- .field("ut_pid", &self.ut_pid)
-@@ -568,7 +568,7 @@ cfg_if! {
-
- #[cfg(libc_union)]
- impl ::fmt::Debug for __c_anonymous_ptrace_syscall_info_data {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- unsafe {
- f.debug_struct("__c_anonymous_ptrace_syscall_info_data")
- .field("entry", &self.entry)
-diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs
-index be12190..c8762d5 100644
---- a/src/unix/linux_like/linux/mod.rs
-+++ b/src/unix/linux_like/linux/mod.rs
-@@ -840,7 +840,7 @@ cfg_if! {
- }
- impl Eq for sockaddr_nl {}
- impl ::fmt::Debug for sockaddr_nl {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("sockaddr_nl")
- .field("nl_family", &self.nl_family)
- .field("nl_pid", &self.nl_pid)
-@@ -873,7 +873,7 @@ cfg_if! {
- impl Eq for dirent {}
-
- impl ::fmt::Debug for dirent {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("dirent")
- .field("d_ino", &self.d_ino)
- .field("d_off", &self.d_off)
-@@ -911,7 +911,7 @@ cfg_if! {
- impl Eq for dirent64 {}
-
- impl ::fmt::Debug for dirent64 {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("dirent64")
- .field("d_ino", &self.d_ino)
- .field("d_off", &self.d_off)
-@@ -941,7 +941,7 @@ cfg_if! {
- impl Eq for pthread_cond_t {}
-
- impl ::fmt::Debug for pthread_cond_t {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("pthread_cond_t")
- // FIXME: .field("size", &self.size)
- .finish()
-@@ -963,7 +963,7 @@ cfg_if! {
- impl Eq for pthread_mutex_t {}
-
- impl ::fmt::Debug for pthread_mutex_t {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("pthread_mutex_t")
- // FIXME: .field("size", &self.size)
- .finish()
-@@ -985,7 +985,7 @@ cfg_if! {
- impl Eq for pthread_rwlock_t {}
-
- impl ::fmt::Debug for pthread_rwlock_t {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("pthread_rwlock_t")
- // FIXME: .field("size", &self.size)
- .finish()
-@@ -1007,7 +1007,7 @@ cfg_if! {
- impl Eq for pthread_barrier_t {}
-
- impl ::fmt::Debug for pthread_barrier_t {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("pthread_barrier_t")
- .field("size", &self.size)
- .finish()
-@@ -1041,7 +1041,7 @@ cfg_if! {
- impl Eq for sockaddr_alg {}
-
- impl ::fmt::Debug for sockaddr_alg {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("sockaddr_alg")
- .field("salg_family", &self.salg_family)
- .field("salg_type", &self.salg_type)
-@@ -1072,7 +1072,7 @@ cfg_if! {
- impl Eq for uinput_setup {}
-
- impl ::fmt::Debug for uinput_setup {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("uinput_setup")
- .field("id", &self.id)
- .field("name", &&self.name[..])
-@@ -1103,7 +1103,7 @@ cfg_if! {
- impl Eq for uinput_user_dev {}
-
- impl ::fmt::Debug for uinput_user_dev {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("uinput_setup")
- .field("name", &&self.name[..])
- .field("id", &self.id)
-@@ -1152,7 +1152,7 @@ cfg_if! {
-
- #[allow(deprecated)]
- impl ::fmt::Debug for af_alg_iv {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("af_alg_iv")
- .field("ivlen", &self.ivlen)
- .finish()
-@@ -1176,7 +1176,7 @@ cfg_if! {
- }
- impl Eq for mq_attr {}
- impl ::fmt::Debug for mq_attr {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("mq_attr")
- .field("mq_flags", &self.mq_flags)
- .field("mq_maxmsg", &self.mq_maxmsg)
-@@ -1195,7 +1195,7 @@ cfg_if! {
- }
- #[cfg(libc_union)]
- impl ::fmt::Debug for __c_anonymous_ifr_ifru {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("ifr_ifru")
- .field("ifru_addr", unsafe { &self.ifru_addr })
- .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr })
-@@ -1214,7 +1214,7 @@ cfg_if! {
- }
- }
- impl ::fmt::Debug for ifreq {
-- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
- f.debug_struct("ifreq")
- .field("ifr_name", &self.ifr_name)
- .field("ifr_ifru", &self.ifr_ifru)
-diff --git a/src/unix/mlibc/mod.rs b/src/unix/mlibc/mod.rs
-index 2046530..8a4f974 100644
---- a/src/unix/mlibc/mod.rs
-+++ b/src/unix/mlibc/mod.rs
-@@ -47,7 +47,6 @@ pub type fsfilcnt_t = ::c_uint;
- pub type sigset_t = ::c_long;
-
- // abis/mlibc/termios.h
--pub type cc_t = ::c_uint;
- pub type speed_t = ::c_uint;
- pub type tcflag_t = ::c_uint;
-
-@@ -70,7 +69,7 @@ pub type in_addr_t = u32;
- pub type in_port_t = u16;
-
- // abis/mlibc/socket.h
--pub type sa_family_t = ::c_uint;
-+pub type sa_family_t = ::c_int;
-
- // options/linux/include/sys/poll.h
- pub type nfds_t = ::size_t;
-@@ -112,7 +111,7 @@ s! {
- pub sa_handler: ::Option,
- pub sa_mask: sigset_t,
- pub sa_flags: ::c_int,
-- pub sa_sigaction: ::Option,
-+ pub sa_sigaction: ::sighandler_t,
- }
-
- // abis/mlibc/termios.h
-@@ -121,7 +120,8 @@ s! {
- pub c_oflag: tcflag_t,
- pub c_cflag: tcflag_t,
- pub c_lflag: tcflag_t,
-- pub c_cc: [cc_t; NCCS],
-+ pub c_line: ::cc_t,
-+ pub c_cc: [::cc_t; NCCS],
- pub ibaud: speed_t,
- pub obaud: speed_t,
- }
-@@ -174,7 +174,7 @@ s! {
- pub sin_family: sa_family_t,
- pub sin_port: in_port_t,
- pub sin_addr: in_addr,
-- pub __padding: [u8; 8], // std relies on this being public
-+ pub sin_zero: [u8; 8], // std relies on this being public
- }
- pub struct sockaddr_in6 {
- pub sin6_family: sa_family_t,
-@@ -238,22 +238,51 @@ s! {
- // options/posix/include/bits/posix/pthread_t.h
- pub struct __mlibc_thread_data {}
-
-+ // options/posix/include/sched.h
-+ pub struct sched_param {
-+ pub sched_priority: ::c_int,
-+ }
-+
-+ pub struct __mlibc_cpu_set {
-+ pub __bits: [::c_ulong; 128 / core::mem::size_of::<::c_long>()],
-+ }
-+
- // options/posix/include/bits/posix/pthread.h
- pub struct pthread_attr_t {
-- pub __mlibc_deatchstate: ::c_int,
-+ pub __mlibc_guardsize: ::size_t,
-+ pub __mlibc_stacksize: ::size_t,
-+ pub __mlibc_stackaddr: *mut ::c_void,
-+ pub __mlibc_detachstate: ::c_int,
-+ pub __mlibc_scope: ::c_int,
-+ pub __mlibc_inheritsched: ::c_int,
-+ pub __mlibc_schedparam: sched_param,
-+ pub __mlibc_schedpolicy: ::c_int,
-+ pub __mlibc_cpuset: *mut __mlibc_cpu_set,
-+ pub __mlibc_cpusetsize: ::size_t,
-+ pub __mlibc_sigmask: sigset_t,
-+ pub __mlibc_sigmaskset: ::c_int,
- }
- pub struct pthread_cond_t {
- pub __mlibc_seq: ::c_uint,
-+ pub __mlibc_flags: ::c_uint,
-+ pub __mlibc_clock: clockid_t,
-+ }
-+ pub struct pthread_condattr_t {
-+ pub __mlibc_pshared: ::c_int,
-+ pub __mlibc_clock: clockid_t,
- }
-- pub struct pthread_condattr_t {}
- pub struct pthread_mutex_t {
- pub __mlibc_state: ::c_uint,
- pub __mlibc_recursion: ::c_uint,
- pub __mlibc_flags: ::c_uint,
-+ pub __mlibc_prioceiling: ::c_int,
- }
- pub struct pthread_mutexattr_t {
- pub __mlibc_type: ::c_int,
- pub __mlibc_robust: ::c_int,
-+ pub __mlibc_protocol: ::c_int,
-+ pub __mlibc_pshared: ::c_int,
-+ pub __mlibc_prioceiling: ::c_int,
- }
- pub struct pthread_rwlock_t {
- pub __mlibc_m: ::c_uint,
-@@ -319,10 +348,172 @@ s! {
- pub struct fd_set {
- pub fds_bits: [c_char; 128],
- }
-+
-+ pub struct cmsghdr {
-+ // FIXME: mio needs this to be a size_t for some reason
-+ // pub cmsg_len: ::socklen_t,
-+ pub cmsg_len: ::size_t,
-+ pub cmsg_level: ::c_int,
-+ pub cmsg_type: ::c_int,
-+ }
-+
-+ pub struct msghdr {
-+ pub msg_name: *mut ::c_void,
-+ pub msg_namelen: ::socklen_t,
-+ pub msg_iov: *mut ::iovec,
-+ pub msg_iovlen: ::c_int,
-+ pub msg_control: *mut ::c_void,
-+ pub msg_controllen: ::size_t, // nix assumes this is a size_t
-+ pub msg_flags: ::c_int,
-+ }
-+
-+ // options/linux-headers/include/linux/if_packet.h
-+ pub struct sockaddr_ll {
-+ pub sll_family: ::c_ushort,
-+ pub sll_protocol: ::c_ushort,
-+ pub sll_ifindex: ::c_int,
-+ pub sll_hatype: ::c_ushort,
-+ pub sll_pkttype: ::c_uchar,
-+ pub sll_halen: ::c_uchar,
-+ pub sll_addr: [::c_uchar; 8]
-+ }
-+
-+ pub struct flock {
-+ pub l_type: ::c_short,
-+ pub l_whence: ::c_short,
-+ pub l_start: ::off_t,
-+ pub l_len: ::off_t,
-+ pub l_pid: ::pid_t,
-+ }
-+
-+ pub struct __c_anonymous_ifru_map {
-+ pub mem_start: ::c_ulong,
-+ pub mem_end: ::c_ulong,
-+ pub base_addr: ::c_ushort,
-+ pub irq: ::c_uchar,
-+ pub dma: ::c_uchar,
-+ pub port: ::c_uchar,
-+ }
-+}
-+
-+cfg_if! {
-+ if #[cfg(feature = "extra_traits")] {
-+ impl ::fmt::Debug for epoll_event {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
-+ let events = self.events;
-+ let u64 = self.u64;
-+ f.debug_struct("epoll_event")
-+ .field("events", &events)
-+ .field("u64", &u64)
-+ .finish()
-+ }
-+ }
-+ impl PartialEq for epoll_event {
-+ fn eq(&self, other: &epoll_event) -> bool {
-+ self.events == other.events
-+ && self.u64 == other.u64
-+ }
-+ }
-+ impl Eq for epoll_event {}
-+ impl ::hash::Hash for epoll_event {
-+ fn hash(&self, state: &mut H) {
-+ let events = self.events;
-+ let u64 = self.u64;
-+ events.hash(state);
-+ u64.hash(state);
-+ }
-+ }
-+
-+ #[cfg(libc_union)]
-+ impl ::fmt::Debug for __c_anonymous_ifr_ifru {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
-+ f.debug_struct("ifr_ifru")
-+ .field("ifru_addr", unsafe { &self.ifru_addr })
-+ .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr })
-+ .field("ifru_broadaddr", unsafe { &self.ifru_broadaddr })
-+ .field("ifru_netmask", unsafe { &self.ifru_netmask })
-+ .field("ifru_hwaddr", unsafe { &self.ifru_hwaddr })
-+ .field("ifru_flags", unsafe { &self.ifru_flags })
-+ .field("ifru_ifindex", unsafe { &self.ifru_ifindex })
-+ .field("ifru_metric", unsafe { &self.ifru_metric })
-+ .field("ifru_mtu", unsafe { &self.ifru_mtu })
-+ .field("ifru_map", unsafe { &self.ifru_map })
-+ .field("ifru_slave", unsafe { &self.ifru_slave })
-+ .field("ifru_newname", unsafe { &self.ifru_newname })
-+ .field("ifru_data", unsafe { &self.ifru_data })
-+ .finish()
-+ }
-+ }
-+
-+ impl ::fmt::Debug for ifreq {
-+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
-+ f.debug_struct("ifreq")
-+ .field("ifr_name", &self.ifr_name)
-+ .field("ifr_ifru", &self.ifr_ifru)
-+ .finish()
-+ }
-+ }
-+ }
-+}
-+
-+s_no_extra_traits! {
-+ // options/linux/include/sys/epoll.h
-+ #[cfg_attr(target_arch = "x86_64", repr(packed))]
-+ pub struct epoll_event {
-+ pub events: u32,
-+ pub u64: u64,
-+ }
-+
-+ // options/posix/include/net/if.h
-+ #[cfg(libc_union)]
-+ pub union __c_anonymous_ifr_ifru {
-+ pub ifru_addr: ::sockaddr,
-+ pub ifru_dstaddr: ::sockaddr,
-+ pub ifru_broadaddr: ::sockaddr,
-+ pub ifru_netmask: ::sockaddr,
-+ pub ifru_hwaddr: ::sockaddr,
-+ pub ifru_flags: ::c_short,
-+ pub ifru_ifindex: ::c_int,
-+ pub ifru_metric: ::c_int,
-+ pub ifru_mtu: ::c_int,
-+ pub ifru_map: __c_anonymous_ifru_map,
-+ pub ifru_slave: [::c_char; ::IFNAMSIZ],
-+ pub ifru_newname: [::c_char; ::IFNAMSIZ],
-+ pub ifru_data: *mut ::c_char,
-+ }
-+
-+ pub struct ifreq {
-+ /// if name, e.g. "en0"
-+ pub ifr_name: [::c_char; ::IFNAMSIZ],
-+ #[cfg(libc_union)]
-+ pub ifr_ifru: __c_anonymous_ifr_ifru,
-+ #[cfg(not(libc_union))]
-+ pub ifr_ifru: ::sockaddr,
-+ }
- }
-
- // options/posix/include/sys/wait.h
- safe_f! {
-+ pub fn CMSG_FIRSTHDR(_mhdr: *const msghdr) -> *mut cmsghdr {
-+ core::unimplemented!()
-+ }
-+
-+ pub fn CMSG_NXTHDR(_mhdr: *const ::msghdr, _cmsg: *const ::cmsghdr) -> *mut ::cmsghdr {
-+ core::unimplemented!()
-+ }
-+
-+ pub fn CMSG_LEN(_length: ::c_uint) -> ::c_uint {
-+ core::unimplemented!()
-+ }
-+
-+ pub fn CMSG_DATA(_cmsg: *const cmsghdr) -> *mut ::c_uchar {
-+ core::unimplemented!()
-+ }
-+
-+ pub fn CMSG_SPACE(_len: ::c_uint) -> ::c_uint {
-+ core::unimplemented!()
-+ }
-+
- pub {const} fn WCOREDUMP(x: ::c_int) -> bool {
- x & WCOREFLAG != 0
- }
-@@ -349,6 +540,104 @@ safe_f! {
- }
- }
-
-+// abis/linux/termios.h - indices for the `c_cc` array in struct termios
-+pub const NCCS: ::size_t = 32;
-+pub const VINTR: ::c_int = 0;
-+pub const VQUIT: ::c_int = 1;
-+pub const VERASE: ::c_int = 2;
-+pub const VKILL: ::c_int = 3;
-+pub const VEOF: ::size_t = 4;
-+pub const VTIME: ::c_int = 5;
-+pub const VMIN: ::c_int = 6;
-+pub const VSWTC: ::c_int = 7;
-+pub const VSTART: ::c_int = 8;
-+pub const VSTOP: ::c_int = 9;
-+pub const VSUSP: ::c_int = 10;
-+pub const VEOL: ::c_int = 11;
-+pub const VREPRINT: ::c_int = 12;
-+pub const VDISCARD: ::c_int = 13;
-+pub const VWERASE: ::c_int = 14;
-+pub const VLNEXT: ::c_int = 15;
-+pub const VEOL2: ::c_int = 16;
-+
-+// abis/linux/termios.h - bitwise flags for c_iflag in struct termios
-+pub const BRKINT: ::c_uint = 0o000002;
-+pub const ICRNL: ::c_uint = 0o000400;
-+pub const IGNBRK: ::c_uint = 0o000001;
-+pub const IGNCR: ::c_uint = 0o000200;
-+pub const IGNPAR: ::c_uint = 0o000004;
-+pub const INLCR: ::c_uint = 0o000100;
-+pub const INPCK: ::c_uint = 0o000020;
-+pub const ISTRIP: ::c_uint = 0o000040;
-+pub const IXANY: ::c_uint = 0o004000;
-+pub const IXOFF: ::c_uint = 0o010000;
-+pub const IXON: ::c_uint = 0o002000;
-+pub const PARMRK: ::c_uint = 0o000010;
-+
-+// abis/linux/termios.h - bitwise flags for c_oflag in struct termios
-+pub const OPOST: ::c_uint = 0o000001;
-+pub const ONLCR: ::c_int = 0o000004;
-+pub const OCRNL: ::c_int = 0o000010;
-+pub const ONOCR: ::c_int = 0o000020;
-+pub const ONLRET: ::c_int = 0o000040;
-+pub const OFDEL: ::c_int = 0o000200;
-+pub const OFILL: ::c_int = 0o000100;
-+
-+pub const NLDLY: ::c_int = 0o000400;
-+pub const NL0: ::c_int = 0o000000;
-+pub const NL1: ::c_int = 0o000400;
-+
-+pub const CRDLY: ::c_int = 0o003000;
-+pub const CR0: ::c_int = 0o000000;
-+pub const CR1: ::c_int = 0o001000;
-+pub const CR2: ::c_int = 0o002000;
-+pub const CR3: ::c_int = 0o003000;
-+
-+pub const TABDLY: ::c_int = 0o014000;
-+pub const TAB0: ::c_int = 0o000000;
-+pub const TAB1: ::c_int = 0o004000;
-+pub const TAB2: ::c_int = 0o010000;
-+pub const TAB3: ::c_int = 0o014000;
-+
-+pub const XTABS: ::c_int = 0o014000;
-+pub const BSDLY: ::c_int = 0o020000;
-+pub const BS0: ::c_int = 0o000000;
-+pub const BS1: ::c_int = 0o020000;
-+
-+pub const VTDLY: ::c_int = 0o040000;
-+pub const VT0: ::c_int = 0o000000;
-+pub const VT1: ::c_int = 0o040000;
-+
-+pub const FFDLY: ::c_int = 0o100000;
-+pub const FF0: ::c_int = 0o000000;
-+pub const FF1: ::c_int = 0o100000;
-+
-+// abis/linux/termios.h - bitwise constants for c_cflag in struct termios
-+pub const CSIZE: ::c_int = 0o000060;
-+pub const CS5: ::c_uint = 0o000000;
-+pub const CS6: ::c_int = 0o000020;
-+pub const CS7: ::c_int = 0o000040;
-+pub const CS8: ::c_int = 0o000060;
-+
-+pub const CSTOPB: ::c_int = 0o000100;
-+pub const CREAD: ::c_int = 0o000200;
-+pub const PARENB: ::c_int = 0o000400;
-+pub const PARODD: ::c_int = 0o001000;
-+pub const HUPCL: ::c_int = 0o002000;
-+pub const CLOCAL: ::c_int = 0o004000;
-+
-+// abis/linux/termios.h - bitwise constants for c_lflag in struct termios
-+pub const ECHO: ::c_uint = 0o000010;
-+pub const ECHOE: ::c_int = 0o000020;
-+pub const ECHOK: ::c_int = 0o000040;
-+pub const ECHONL: ::c_int = 0o000100;
-+pub const ICANON: ::c_int = 0o000002;
-+pub const IEXTEN: ::c_int = 0o100000;
-+pub const ISIG: ::c_int = 0o000001;
-+pub const NOFLSH: ::c_int = 0o000200;
-+pub const TOSTOP: ::c_int = 0o000400;
-+pub const ECHOPRT: ::c_int = 0o002000;
-+
- // abis/mlibc/vm-flags.h
- pub const MAP_ANON: ::c_int = 8;
- pub const MAP_PRIVATE: ::c_int = 1;
-@@ -356,11 +645,24 @@ pub const MAP_SHARED: ::c_int = 2;
- pub const PROT_EXEC: ::c_int = 4;
- pub const PROT_READ: ::c_int = 1;
- pub const PROT_WRITE: ::c_int = 2;
-+pub const PROT_NONE: ::c_int = 0;
-+pub const MAP_FIXED: ::c_int = 2;
-+pub const MAP_NORESERVE: ::c_int = 0x10;
-
- // options/posix/include/sys/mman.h
-+pub const MAP_FILE: ::c_int = 0;
- pub const MAP_FAILED: *mut ::c_void = usize::MAX as *mut ::c_void;
- pub const MS_ASYNC: ::c_int = 1;
- pub const MS_SYNC: ::c_int = 2;
-+pub const MADV_NORMAL: ::c_int = 0;
-+pub const MADV_RANDOM: ::c_int = 1;
-+pub const MADV_SEQUENTIAL: ::c_int = 2;
-+pub const MADV_WILLNEED: ::c_int = 3;
-+pub const MADV_DONTNEED: ::c_int = 4;
-+pub const MADV_FREE: ::c_int = 8;
-+pub const MS_INVALIDATE: ::c_int = 4;
-+pub const MCL_CURRENT: ::c_int = 1;
-+pub const MCL_FUTURE: ::c_int = 2;
-
- // options/ansi/include/time.h
- pub const CLOCK_MONOTONIC: clockid_t = 1;
-@@ -369,33 +671,49 @@ pub const CLOCK_REALTIME: clockid_t = 0;
- // options/posix/include/netdb.h
- pub const EAI_SYSTEM: ::c_int = 9;
-
--// options/posix/include/termios.h - constants for tcsetattr()
--pub const TCSANOW: ::c_int = 1;
--pub const TCSADRAIN: ::c_int = 2;
--pub const TCSAFLUSH: ::c_int = 3;
--
--// options/posix/include/termios.h - bitwise constants for c_lflag in struct termios
--pub const ECHO: ::tcflag_t = 0x0001;
--pub const ECHOE: ::tcflag_t = 0x0002;
--pub const ECHOK: ::tcflag_t = 0x0004;
--pub const ECHONL: ::tcflag_t = 0x0008;
--pub const ICANON: ::tcflag_t = 0x0010;
--pub const IEXTEN: ::tcflag_t = 0x0020;
--pub const ISIG: ::tcflag_t = 0x0040;
--pub const NOFLSH: ::tcflag_t = 0x0080;
--pub const TOSTOP: ::tcflag_t = 0x0100;
--pub const ECHOPR: ::tcflag_t = 0x0200;
--
- // abis/mlibc/in.h
--pub const IPV6_ADD_MEMBERSHIP: ::c_int = 1;
--pub const IPV6_DROP_MEMBERSHIP: ::c_int = 2;
-+pub const IPV6_JOIN_GROUP: ::c_int = 1;
-+pub const IPV6_LEAVE_GROUP: ::c_int = 2;
-+pub const IPV6_MULTICAST_HOPS: ::c_int = 3;
-+pub const IPV6_MULTICAST_IF: ::c_int = 4;
- pub const IPV6_MULTICAST_LOOP: ::c_int = 5;
-+pub const IPV6_UNICAST_HOPS: ::c_int = 6;
- pub const IPV6_V6ONLY: ::c_int = 7;
-+pub const IPV6_PMTUDISC_DONT: ::c_int = 8;
-+pub const IPV6_PMTUDISC_DO: ::c_int = 9;
-+pub const IPV6_MTU_DISCOVER: ::c_int = 23;
-+pub const IPV6_RECVERR: ::c_int = 25;
-+pub const IPV6_RECVPKTINFO: ::c_int = 49;
-+pub const IPV6_PKTINFO: ::c_int = 50;
-+pub const IPV6_RECVHOPLIMIT: ::c_int = 51;
-+pub const IPV6_HOPLIMIT: ::c_int = 52;
-+pub const IPV6_TCLASS: ::c_int = 67;
-+pub const IP_TOS: ::c_int = 1;
-+pub const IP_TTL: ::c_int = 2;
-+pub const IP_OPTIONS: ::c_int = 4;
-+pub const IP_PKTINFO: ::c_int = 8;
-+pub const IP_MTU_DISCOVER: ::c_int = 10;
-+pub const IP_RECVERR: ::c_int = 11;
-+pub const IP_RECVTTL: ::c_int = 12;
-+
-+pub const IP_DEFAULT_MULTICAST_TTL: ::c_int = 1;
-+pub const IP_MULTICAST_IF: ::c_int = 32;
-+pub const IP_MULTICAST_TTL: ::c_int = 33;
-+pub const IP_MULTICAST_LOOP: ::c_int = 34;
- pub const IP_ADD_MEMBERSHIP: ::c_int = 35;
- pub const IP_DROP_MEMBERSHIP: ::c_int = 36;
--pub const IP_MULTICAST_LOOP: ::c_int = 34;
--pub const IP_MULTICAST_TTL: ::c_int = 33;
--pub const IP_TTL: ::c_int = 2;
-+pub const IP_UNBLOCK_SOURCE: ::c_int = 37;
-+pub const IP_BLOCK_SOURCE: ::c_int = 38;
-+pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 39;
-+pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 40;
-+pub const MCAST_JOIN_SOURCE_GROUP: ::c_int = 46;
-+pub const MCAST_LEAVE_SOURCE_GROUP: ::c_int = 47;
-+
-+pub const IPV6_ADD_MEMBERSHIP: ::c_int = IPV6_JOIN_GROUP;
-+pub const IPV6_DROP_MEMBERSHIP: ::c_int = IPV6_LEAVE_GROUP;
-+
-+// FIXME: not defined in mlibc
-+pub const TCP_KEEPIDLE: ::c_int = 4;
-
- // abis/linux/signal.h
- pub const SIGABRT: ::c_int = 6;
-@@ -436,45 +754,121 @@ pub const SIGSYS: ::c_int = 31;
- pub const SIGUNUSED: ::c_int = SIGSYS;
- pub const SIGCANCEL: ::c_int = 32;
-
-+pub const SA_SIGINFO: ::c_int = 4;
-+pub const SA_RESTART: ::c_int = 0x10000000;
-+
-+pub const SIG_DFL: ::sighandler_t = 0 as ::sighandler_t;
-+pub const SIG_IGN: ::sighandler_t = 1 as ::sighandler_t;
-+pub const SIG_ERR: ::sighandler_t = !0 as ::sighandler_t;
-+
- // abis/mlibc/signal.h - constants for sigprocmask()
- pub const SIG_BLOCK: ::c_int = 0;
- pub const SIG_UNBLOCK: ::c_int = 1;
- pub const SIG_SETMASK: ::c_int = 2;
-
- // abis/mlibc/termios.h
--pub const NCCS: usize = 11;
-+pub const B0: ::c_uint = 0;
-+pub const B50: ::c_uint = 1;
-+pub const B75: ::c_uint = 2;
-+pub const B110: ::c_uint = 3;
-+pub const B134: ::c_uint = 4;
-+pub const B150: ::c_uint = 5;
-+pub const B200: ::c_uint = 6;
-+pub const B300: ::c_uint = 7;
-+pub const B600: ::c_uint = 8;
-+pub const B1200: ::c_uint = 9;
-+pub const B1800: ::c_uint = 10;
-+pub const B2400: ::c_uint = 11;
-+pub const B4800: ::c_uint = 12;
-+pub const B9600: ::c_uint = 13;
-+pub const B19200: ::c_uint = 14;
-+pub const B38400: ::c_uint = 15;
-+pub const B57600: ::c_uint = 16;
-+pub const B115200: ::c_uint = 17;
-+pub const B230400: ::c_uint = 18;
-+pub const TCIFLUSH: ::c_int = 1;
-+pub const TCIOFF: ::c_int = 1;
-+pub const TCIOFLUSH: ::c_int = 2;
-+pub const TCION: ::c_int = 2;
-+pub const TCOFLUSH: ::c_int = 3;
-+pub const TCOOFF: ::c_int = 3;
-+pub const TCOON: ::c_int = 4;
-+pub const TCSADRAIN: ::c_int = 2;
-+pub const TCSAFLUSH: ::c_int = 3;
-+pub const TCSANOW: ::c_int = 1;
-+pub const TIOCSCTTY: ::c_ulong = 0x540e;
-+pub const TIOCSWINSZ: ::c_ulong = 0x5414;
-
- // options/posix/include/termios.h
- pub const TIOCGWINSZ: ::c_ulong = 0x5413;
-
-+// options/ansi/include/locale.h
-+pub const LC_CTYPE: ::c_int = 3;
-+
- // options/ansi/include/stdlib.h
- pub const EXIT_FAILURE: ::c_int = 1;
- pub const EXIT_SUCCESS: ::c_int = 0;
-
- // options/posix/include/dlfcn.h
- pub const RTLD_DEFAULT: *mut ::c_void = 0 as *mut ::c_void;
-+pub const RTLD_LAZY: ::c_int = 32;
-
- // options/posix/include/unistd.h
-+pub const F_OK: ::c_int = 1;
-+pub const R_OK: ::c_int = 2;
- pub const STDERR_FILENO: ::c_int = 2;
- pub const STDIN_FILENO: ::c_int = 0;
- pub const STDOUT_FILENO: ::c_int = 1;
-+pub const W_OK: ::c_int = 4;
-+pub const X_OK: ::c_int = 8;
-+pub const _PC_NAME_MAX: ::c_int = 3;
-+pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 7;
- pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 1;
- pub const _SC_NPROCESSORS_ONLN: ::c_int = 6;
-+pub const _SC_NGROUPS_MAX: ::c_int = 10;
- pub const _SC_PAGESIZE: ::c_int = _SC_PAGE_SIZE;
- pub const _SC_PAGE_SIZE: ::c_int = 3;
-
- // abis/mlibc/socket.h
-+pub const AF_APPLETALK: ::c_int = PF_APPLETALK;
-+pub const AF_BLUETOOTH: ::c_int = PF_BLUETOOTH;
-+pub const AF_DECnet: ::c_int = PF_DECnet;
- pub const AF_INET6: ::c_int = PF_INET6;
- pub const AF_INET: ::c_int = PF_INET;
-+pub const AF_IPX: ::c_int = PF_IPX;
-+pub const AF_ISDN: ::c_int = PF_ISDN;
-+pub const AF_PACKET: ::c_int = PF_PACKET;
-+pub const AF_SNA: ::c_int = PF_SNA;
- pub const AF_UNIX: ::c_int = 3;
- pub const MSG_PEEK: ::c_int = 0x20;
-+pub const MSG_TRUNC: ::c_int = 0x40;
-+pub const AF_UNSPEC: ::c_int = PF_UNSPEC;
-+pub const MSG_CTRUNC: ::c_int = 1;
-+pub const MSG_CMSG_CLOEXEC: ::c_int = 0x2000;
-+pub const MSG_EOR: ::c_int = 4;
-+pub const MSG_OOB: ::c_int = 8;
-+pub const MSG_WAITALL: ::c_int = 0x80;
-+pub const PF_APPLETALK: ::c_int = 7;
-+pub const PF_BLUETOOTH: ::c_int = 8;
-+pub const PF_DECnet: ::c_int = 9;
-+pub const MSG_DONTWAIT: ::c_int = 0x1000;
- pub const PF_INET6: ::c_int = 2;
- pub const PF_INET: ::c_int = 1;
- pub const PF_UNIX: ::c_int = 3;
-+pub const PF_UNSPEC: ::c_int = 4;
-+pub const SCM_RIGHTS: ::c_int = 1;
-+pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
- pub const SHUT_RD: ::c_int = 1;
- pub const SHUT_RDWR: ::c_int = 2;
- pub const SHUT_WR: ::c_int = 3;
- pub const SOCK_DGRAM: ::c_int = 1;
-+pub const SOCK_RAW: ::c_int = 2;
-+pub const SOCK_RDM: ::c_int = 0x40000;
-+pub const SOCK_SEQPACKET: ::c_int = 3;
-+pub const PF_IPX: ::c_int = 10;
-+pub const PF_ISDN: ::c_int = 11;
-+pub const PF_PACKET: ::c_int = 13;
-+pub const PF_SNA: ::c_int = 12;
- pub const SOCK_STREAM: ::c_int = 4;
- pub const SOL_SOCKET: ::c_int = 1;
- pub const SO_ACCEPTCONN: ::c_int = 1;
-@@ -494,6 +888,8 @@ pub const SO_SNDLOWAT: ::c_int = 14;
- pub const SO_SNDTIMEO: ::c_int = 15;
- pub const SO_TYPE: ::c_int = 16;
- pub const SO_SNDBUFFORCE: ::c_int = 17;
-+pub const TCP_KEEPCNT: ::c_int = 6;
-+pub const TCP_KEEPINTVL: ::c_int = 5;
- pub const SO_PEERCRED: ::c_int = 18;
- pub const SO_ATTACH_FILTER: ::c_int = 19;
- pub const SO_PASSCRED: ::c_int = 20;
-@@ -503,6 +899,12 @@ pub const SO_PROTOCOL: ::c_int = 23;
- pub const SO_REUSEPORT: ::c_int = 24;
- pub const SO_TIMESTAMP: ::c_int = 25;
-
-+// options/posix/include/sys/file.h
-+pub const LOCK_EX: ::c_int = 2;
-+pub const LOCK_NB: ::c_int = 4;
-+pub const LOCK_SH: ::c_int = 1;
-+pub const LOCK_UN: ::c_int = 8;
-+
- // abis/mlibc/errno.h
- pub const EDOM: ::c_int = 1;
- pub const EILSEQ: ::c_int = 2;
-@@ -592,15 +994,24 @@ pub const ENOTBLK: ::c_int = 1083;
-
- // options/posix/include/fcntl.h
- pub const AT_FDCWD: ::c_int = -100;
--pub const F_DUPFD: ::c_int = 1;
- pub const F_DUPFD_CLOEXEC: ::c_int = 2;
-+pub const AT_REMOVEDIR: ::c_int = 8;
- pub const F_GETFD: ::c_int = 3;
- pub const F_SETFD: ::c_int = 4;
-+pub const AT_SYMLINK_FOLLOW: ::c_int = 2;
-+pub const AT_SYMLINK_NOFOLLOW: ::c_int = 4;
-+pub const F_DUPFD: ::c_int = 1;
- pub const F_GETFL: ::c_int = 5;
- pub const F_SETFL: ::c_int = 6;
- pub const F_GETLK: ::c_int = 7;
- pub const F_SETLK: ::c_int = 8;
- pub const F_SETLKW: ::c_int = 9;
-+pub const O_DIRECTORY: ::c_int = 0x00020;
-+pub const O_NOFOLLOW: ::c_int = 0x100;
-+pub const O_ASYNC: ::c_int = 0x40000;
-+pub const O_NDELAY: ::c_int = 0x400;
-+pub const O_NOCTTY: ::c_int = 0x80;
-+pub const O_SYNC: ::c_int = 0x2000;
- pub const F_GETOWN: ::c_int = 10;
- pub const F_SETOWN: ::c_int = 11;
- pub const O_ACCMODE: ::c_int = 7;
-@@ -644,23 +1055,56 @@ pub const S_IXGRP: mode_t = 0o10;
- pub const S_IXOTH: mode_t = 0o1;
- pub const S_IXUSR: mode_t = 0o100;
-
-+// Used by utimensat() and friends
-+pub const UTIME_NOW: c_long = (1 << 30) - 1;
-+pub const UTIME_OMIT: c_long = (1 << 30) - 2;
-+
- // options/posix/include/sys/wait.h
- pub const WCOREFLAG: ::c_int = 0x80;
- pub const WNOHANG: ::c_int = 2;
-
- // options/linux/include/sys/poll.h
--// TODO: Port epoll!
- pub const POLLHUP: ::c_short = 8;
- pub const POLLIN: ::c_short = 1;
- pub const POLLNVAL: ::c_short = 0x40;
- pub const POLLOUT: ::c_short = 2;
-
-+// options/linux/include/sys/epoll.h
-+pub const EPOLLERR: ::c_int = 8;
-+pub const EPOLLET: ::c_int = 1 << 31;
-+pub const EPOLLHUP: ::c_int = 0x10;
-+pub const EPOLLIN: ::c_int = 1;
-+pub const EPOLLMSG: ::c_int = 0x400;
-+pub const EPOLLONESHOT: ::c_int = 1 << 30;
-+pub const EPOLLOUT: ::c_int = 4;
-+pub const EPOLLPRI: ::c_int = 2;
-+pub const EPOLLRDBAND: ::c_int = 0x80;
-+pub const EPOLLRDHUP: ::c_int = 0x2000;
-+pub const EPOLLRDNORM: ::c_int = 0x40;
-+pub const EPOLLWRBAND: ::c_int = 0x200;
-+pub const EPOLLWRNORM: ::c_int = 0x100;
-+pub const EPOLLWAKEUP: ::c_int = 1 << 29;
-+pub const EPOLL_CLOEXEC: ::c_int = 1;
-+pub const EPOLL_CTL_ADD: ::c_int = 1;
-+pub const EPOLL_CTL_DEL: ::c_int = 2;
-+pub const EPOLL_CTL_MOD: ::c_int = 3;
-+
-+// options/linux/include/sys/eventfd.h
-+pub const EFD_CLOEXEC: ::c_int = O_CLOEXEC;
-+pub const EFD_NONBLOCK: ::c_int = O_NONBLOCK;
-+
- // options/glibc/include/sys/ioctl.h
- pub const FIOCLEX: ::c_ulong = 0x5451;
- pub const FIONBIO: ::c_ulong = 0x5421;
-
- // options/ansi/include/limits.h
- pub const PTHREAD_STACK_MIN: ::size_t = 16384;
-+pub const PATH_MAX: ::size_t = 4096;
-+
-+// abis/linux/ioctls.h
-+pub const SIOCGIFHWADDR: ::c_ulong = 0x8927;
-+pub const SIOCSIFADDR: ::c_ulong = 0x8916;
-+pub const SIOCSIFNETMASK: ::c_ulong = 0x891c;
-
- // options/posix/include/pthread.h
- align_const! {
-@@ -668,9 +1112,12 @@ align_const! {
- __mlibc_state: 0,
- __mlibc_recursion: 0,
- __mlibc_flags: 0,
-+ __mlibc_prioceiling: 0,
- };
- pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
- __mlibc_seq: 0,
-+ __mlibc_flags: 0,
-+ __mlibc_clock: 0,
- };
- pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
- __mlibc_m: 0,
-@@ -689,11 +1136,40 @@ pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 0;
- pub const PTHREAD_PROCESS_SHARED: ::c_int = 1;
-
- extern "C" {
-+ pub fn __errno_location() -> *mut ::c_int;
-+ pub fn acct(filename: *const ::c_char) -> ::c_int;
- pub fn bind(socket: ::c_int, address: *const ::sockaddr, address_len: ::socklen_t) -> ::c_int;
- pub fn clock_gettime(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int;
- pub fn clock_settime(clk_id: clockid_t, tp: *const ::timespec) -> ::c_int;
- pub fn endpwent();
-+ pub fn epoll_create(size: ::c_int) -> ::c_int;
-+ pub fn epoll_create1(flags: ::c_int) -> ::c_int;
-+ pub fn epoll_ctl(epfd: ::c_int, op: ::c_int, fd: ::c_int, event: *mut ::epoll_event)
-+ -> ::c_int;
-+ pub fn epoll_wait(
-+ epfd: ::c_int,
-+ events: *mut ::epoll_event,
-+ maxevents: ::c_int,
-+ timeout: ::c_int,
-+ ) -> ::c_int;
-+ pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
-+ pub fn forkpty(
-+ amaster: *mut ::c_int,
-+ name: *mut ::c_char,
-+ termp: *mut termios,
-+ winp: *mut ::winsize,
-+ ) -> ::pid_t;
-+ pub fn futimes(file: ::c_int, times: *const ::timeval) -> ::c_int;
-+ pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int;
- pub fn getpwent() -> *mut passwd;
-+ pub fn openpty(
-+ amaster: *mut ::c_int,
-+ aslave: *mut ::c_int,
-+ name: *mut ::c_char,
-+ termp: *const termios,
-+ winp: *const ::winsize,
-+ ) -> ::c_int;
-+ pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
- pub fn getgrgid_r(
- gid: ::gid_t,
- grp: *mut ::group,
-@@ -728,13 +1204,24 @@ extern "C" {
- buflen: ::size_t,
- result: *mut *mut passwd,
- ) -> ::c_int;
-+ pub fn initgroups(user: *const ::c_char, group: ::gid_t) -> ::c_int;
- pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
-+ pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
- pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
-- pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
-- pub fn pthread_condattr_setclock(
-- attr: *mut pthread_condattr_t,
-- clock_id: ::clockid_t,
-+ pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
-+ pub fn shm_open(name: *const c_char, oflag: ::c_int, mode: mode_t) -> ::c_int;
-+ pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
-+ pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int;
-+ pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t) -> ::c_int;
-+ pub fn utimensat(
-+ dirfd: ::c_int,
-+ path: *const ::c_char,
-+ times: *const ::timespec,
-+ flag: ::c_int,
- ) -> ::c_int;
-+ pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
-+ pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, clock_id: clockid_t)
-+ -> ::c_int;
- pub fn pthread_create(
- thread: *mut ::pthread_t,
- attr: *const ::pthread_attr_t,
-@@ -752,7 +1239,16 @@ extern "C" {
- addr: *mut ::sockaddr,
- addrlen: *mut ::socklen_t,
- ) -> ::ssize_t;
-+ pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t;
-+ pub fn sendmsg(fd: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t;
- pub fn setgroups(ngroups: ::c_int, ptr: *const ::gid_t) -> ::c_int;
- pub fn setpwent();
- pub fn writev(fd: ::c_int, iov: *const ::iovec, count: ::c_int) -> ::ssize_t;
-+
-+ // Non standard extensions, also found on modern BSD's.
-+ //
-+ // options/posix/include/sys/uio.h
-+ pub fn preadv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t;
-+ pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t)
-+ -> ::ssize_t;
- }
---
-2.40.1
-
diff --git a/patches/rust-libloading/rust-libloading.patch b/patches/rust-libloading/rust-libloading.patch
index ac3ec05e6f1..743d6cedefc 100644
--- a/patches/rust-libloading/rust-libloading.patch
+++ b/patches/rust-libloading/rust-libloading.patch
@@ -1,14 +1,15 @@
-From f5fab150ee8fbfdef46888837b6e6d43fd3ec1c0 Mon Sep 17 00:00:00 2001
-From: Andy-Python-Programmer
-Date: Sun, 20 Nov 2022 13:39:51 +1100
+From d6dfe23ee9299412d8281dabb7f5d903e152b589 Mon Sep 17 00:00:00 2001
+From: Anhad Singh
+Date: Tue, 10 Oct 2023 17:24:17 +1100
Subject: [PATCH]
+Signed-off-by: Anhad Singh
---
src/os/unix/consts.rs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/os/unix/consts.rs b/src/os/unix/consts.rs
-index dbe4df9..fbdd2e3 100644
+index ed3edaf..61659ff 100644
--- a/src/os/unix/consts.rs
+++ b/src/os/unix/consts.rs
@@ -58,7 +58,7 @@ mod posix {
@@ -18,9 +19,9 @@ index dbe4df9..fbdd2e3 100644
- if #[cfg(target_os = "haiku")] {
+ if #[cfg(any(target_os = "haiku", target_os = "aero"))] {
pub(super) const RTLD_LAZY: c_int = 0;
- } else if #[cfg(any(
- target_os = "linux",
-@@ -90,7 +90,7 @@ mod posix {
+ } else if #[cfg(target_os = "aix")] {
+ pub(super) const RTLD_LAZY: c_int = 4;
+@@ -94,7 +94,7 @@ mod posix {
}
cfg_if! {
@@ -29,7 +30,7 @@ index dbe4df9..fbdd2e3 100644
pub(super) const RTLD_NOW: c_int = 1;
} else if #[cfg(any(
target_os = "linux",
-@@ -126,6 +126,7 @@ mod posix {
+@@ -133,6 +133,7 @@ mod posix {
cfg_if! {
if #[cfg(any(
target_os = "haiku",
@@ -37,14 +38,14 @@ index dbe4df9..fbdd2e3 100644
all(target_os = "android",target_pointer_width = "32"),
))] {
pub(super) const RTLD_GLOBAL: c_int = 2;
-@@ -193,6 +194,7 @@ mod posix {
-
+@@ -210,6 +211,7 @@ mod posix {
target_os = "fuchsia",
target_os = "redox",
+ target_os = "hurd",
+ target_os = "aero",
))] {
pub(super) const RTLD_LOCAL: c_int = 0;
} else {
--
-2.38.1
+2.42.0
diff --git a/patches/rust-nix/rust-nix.patch b/patches/rust-nix/rust-nix.patch
index 6ff6e5acb49..0c124a2aa8e 100644
--- a/patches/rust-nix/rust-nix.patch
+++ b/patches/rust-nix/rust-nix.patch
@@ -1,20 +1,26 @@
-From 608f6dc307498272ec3a6317cac3bbbe2a8b74b1 Mon Sep 17 00:00:00 2001
-From: Andy-Python-Programmer
-Date: Sun, 20 Nov 2022 12:21:43 +1100
-Subject: [PATCH]
+From 2ac82af89ae503c8743dcd96bca3dcbddccd1eea Mon Sep 17 00:00:00 2001
+From: Dennis Bonke
+Date: Thu, 23 Feb 2023 00:41:07 +0100
+Subject: [PATCH] aero: initial port
+Signed-off-by: Dennis Bonke
---
- src/errno.rs | 217 +++++++++++++++++++++++++++++++++++++++++
- src/lib.rs | 12 ++-
+ src/errno.rs | 218 +++++++++++++++++++++++++++++++++++++++++
+ src/features.rs | 2 +-
+ src/lib.rs | 10 +-
src/sys/mod.rs | 10 +-
- src/sys/socket/addr.rs | 16 +--
- src/sys/socket/mod.rs | 5 +-
+ src/sys/resource.rs | 2 +
+ src/sys/signal.rs | 16 +--
+ src/sys/socket/addr.rs | 26 +++--
+ src/sys/socket/mod.rs | 6 +-
src/sys/termios.rs | 54 +++++++++-
- src/unistd.rs | 27 +++++
- 7 files changed, 327 insertions(+), 14 deletions(-)
+ src/sys/time.rs | 3 +-
+ src/sys/timerfd.rs | 2 +-
+ src/unistd.rs | 30 ++++++
+ 12 files changed, 350 insertions(+), 29 deletions(-)
diff --git a/src/errno.rs b/src/errno.rs
-index 9c2dfe4..d26d63d 100644
+index 41420e8..aedf294 100644
--- a/src/errno.rs
+++ b/src/errno.rs
@@ -22,6 +22,7 @@ cfg_if! {
@@ -35,7 +41,7 @@ index 9c2dfe4..d26d63d 100644
match errno {
UnknownErrno => "Unknown errno",
EPERM => "Operation not permitted",
-@@ -1557,6 +1561,219 @@ mod consts {
+@@ -1562,6 +1566,220 @@ mod consts {
}
}
@@ -111,7 +117,7 @@ index 9c2dfe4..d26d63d 100644
+ // ENOTDIR = libc::ENOTDIR,
+ // ENOTEMPTY = libc::ENOTEMPTY,
+ // ENOTSOCK = libc::ENOTSOCK,
-+ // ENOTSUP = libc::ENOTSUP,
++ ENOTSUP = libc::ENOTSUP,
+ ENOTTY = libc::ENOTTY,
+ // ENXIO = libc::ENXIO,
+ // EOPNOTSUPP = libc::EOPNOTSUPP,
@@ -148,7 +154,7 @@ index 9c2dfe4..d26d63d 100644
+
+ // pub const EL2NSYNC: Errno = Errno::UnknownErrno;
+
-+ pub fn from_i32(e: i32) -> Errno {
++ pub const fn from_i32(e: i32) -> Errno {
+ use self::Errno::*;
+
+ match e {
@@ -218,7 +224,7 @@ index 9c2dfe4..d26d63d 100644
+ // libc::ENOTDIR => ENOTDIR,
+ // libc::ENOTEMPTY => ENOTEMPTY,
+ // libc::ENOTSOCK => ENOTSOCK,
-+ // libc::ENOTSUP => ENOTSUP,
++ libc::ENOTSUP => ENOTSUP,
+ // libc::ENOTTY => ENOTTY,
+ // libc::ENXIO => ENXIO,
+ // libc::EOPNOTSUPP => EOPNOTSUPP,
@@ -252,126 +258,233 @@ index 9c2dfe4..d26d63d 100644
+ }
+ }
+}
++
#[cfg(target_os = "dragonfly")]
mod consts {
+diff --git a/src/features.rs b/src/features.rs
+index 6108098..1f937e2 100644
+--- a/src/features.rs
++++ b/src/features.rs
+@@ -1,7 +1,7 @@
+ //! Feature tests for OS functionality
+ pub use self::os::*;
+
+-#[cfg(any(target_os = "linux", target_os = "android"))]
++#[cfg(any(target_os = "linux", target_os = "android", target_os = "aero"))]
+ mod os {
+ use std::os::unix::ffi::OsStrExt;
+ use crate::sys::utsname::uname;
diff --git a/src/lib.rs b/src/lib.rs
-index 3b534a5..f7c8495 100644
+index d4dcbc4..e5f03c7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
-@@ -5,12 +5,13 @@
- #![crate_name = "nix"]
+@@ -43,9 +43,10 @@
#![cfg(unix)]
+ #![cfg_attr(docsrs, doc(cfg(all())))]
#![allow(non_camel_case_types)]
+#![allow(non_snake_case)]
- // latest bitflags triggers a rustc bug with cross-crate macro expansions causing dead_code
- // warnings even though the macro expands into something with allow(dead_code)
- #![allow(dead_code)]
#![cfg_attr(test, deny(warnings))]
#![recursion_limit = "500"]
-#![deny(unused)]
+// #![deny(unused)]
+ #![allow(unused_macros)]
+ #![cfg_attr(not(feature = "default"), allow(unused_imports))]
#![deny(unstable_features)]
- #![deny(missing_copy_implementations)]
- #![deny(missing_debug_implementations)]
-@@ -22,11 +23,13 @@ pub use libc;
+@@ -62,12 +63,13 @@ pub use libc;
#[macro_use] mod macros;
// Public crates
-#[cfg(not(target_os = "redox"))]
+#[cfg(not(any(target_os = "redox", target_os = "aero")))]
- pub mod dir;
-+#[cfg(not(target_os = "aero"))]
- pub mod env;
- pub mod errno;
- #[deny(missing_docs)]
-+#[cfg(not(target_os = "aero"))]
- pub mod features;
- pub mod fcntl;
- #[deny(missing_docs)]
-@@ -54,15 +57,18 @@ pub mod mount;
- target_os = "netbsd"))]
- pub mod mqueue;
- #[deny(missing_docs)]
--#[cfg(not(target_os = "redox"))]
-+#[cfg(not(any(target_os = "redox", target_os = "aero")))]
- pub mod net;
- #[deny(missing_docs)]
+ feature! {
+ #![feature = "dir"]
+ #[allow(missing_docs)]
+ pub mod dir;
+ }
+#[cfg(not(target_os = "aero"))]
- pub mod poll;
- #[deny(missing_docs)]
- #[cfg(not(any(target_os = "redox", target_os = "fuchsia")))]
- pub mod pty;
+ feature! {
+ #![feature = "env"]
+ pub mod env;
+@@ -96,7 +98,7 @@ feature! {
+ target_os = "openbsd"))]
+ #[deny(missing_docs)]
+ pub mod ifaddrs;
+- #[cfg(not(target_os = "redox"))]
++ #[cfg(not(any(target_os = "redox", target_os = "aero")))]
+ #[deny(missing_docs)]
+ pub mod net;
+ }
+@@ -124,6 +126,7 @@ feature! {
+ #[allow(missing_docs)]
+ pub mod mqueue;
+ }
+#[cfg(not(target_os = "aero"))]
- pub mod sched;
- pub mod sys;
+ feature! {
+ #![feature = "poll"]
+ pub mod poll;
+@@ -134,6 +137,7 @@ feature! {
+ #[deny(missing_docs)]
+ pub mod pty;
+ }
+#[cfg(not(target_os = "aero"))]
- pub mod time;
- // This can be implemented for other platforms as soon as libc
- // provides bindings for them.
+ feature! {
+ #![feature = "sched"]
+ pub mod sched;
diff --git a/src/sys/mod.rs b/src/sys/mod.rs
-index 43877a1..20dd8e5 100644
+index e5639f2..2cbdff5 100644
--- a/src/sys/mod.rs
+++ b/src/sys/mod.rs
-@@ -6,7 +6,7 @@
- target_os = "netbsd"))]
- pub mod aio;
+@@ -13,7 +13,7 @@ feature! {
+ feature! {
+ #![feature = "event"]
--#[cfg(any(target_os = "android", target_os = "linux"))]
-+#[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))]
- pub mod epoll;
+- #[cfg(any(target_os = "android", target_os = "linux"))]
++ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))]
+ #[allow(missing_docs)]
+ pub mod epoll;
- #[cfg(any(target_os = "dragonfly",
-@@ -42,6 +42,7 @@ pub mod mman;
- #[cfg(target_os = "linux")]
- pub mod personality;
+@@ -64,6 +64,7 @@ feature! {
+ pub mod personality;
+ }
+#[cfg(not(target_os = "aero"))]
- pub mod pthread;
-
- #[cfg(any(target_os = "android",
-@@ -59,7 +60,8 @@ pub mod quota;
- #[cfg(any(target_os = "linux"))]
- pub mod reboot;
+ feature! {
+ #![feature = "pthread"]
+ pub mod pthread;
+@@ -100,7 +101,7 @@ feature! {
+ pub mod resource;
+ }
-#[cfg(not(target_os = "redox"))]
-+// #[cfg(not(target_os = "redox"))]
+#[cfg(not(any(target_os = "redox", target_os = "aero")))]
- pub mod select;
-
- #[cfg(any(target_os = "android",
-@@ -69,6 +71,7 @@ pub mod select;
- target_os = "macos"))]
- pub mod sendfile;
-
-+#[cfg(not(target_os = "aero"))]
- pub mod signal;
-
- #[cfg(any(target_os = "android", target_os = "linux"))]
-@@ -89,6 +92,7 @@ pub mod stat;
- ))]
- pub mod statfs;
+ feature! {
+ #![feature = "poll"]
+ pub mod select;
+@@ -152,6 +153,7 @@ feature! {
+ pub mod statfs;
+ }
+#[cfg(not(target_os = "aero"))]
- pub mod statvfs;
-
- #[cfg(any(target_os = "android", target_os = "linux"))]
-@@ -100,8 +104,10 @@ pub mod time;
-
- pub mod uio;
+ feature! {
+ #![feature = "fs"]
+ pub mod statvfs;
+@@ -181,6 +183,7 @@ feature! {
+ pub mod utsname;
+ }
+#[cfg(not(target_os = "aero"))]
- pub mod utsname;
+ feature! {
+ #![feature = "process"]
+ pub mod wait;
+@@ -192,7 +195,7 @@ feature! {
+ pub mod inotify;
+ }
-+#[cfg(not(target_os = "aero"))]
- pub mod wait;
+-#[cfg(any(target_os = "android", target_os = "linux"))]
++#[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))]
+ feature! {
+ #![feature = "time"]
+ pub mod timerfd;
+@@ -203,6 +206,7 @@ feature! {
+ target_os = "freebsd",
+ target_os = "illumos",
+ target_os = "linux",
++ target_os = "aero",
+ target_os = "netbsd"
+ ),
+ feature = "time",
+diff --git a/src/sys/resource.rs b/src/sys/resource.rs
+index 76ceaf5..3457acd 100644
+--- a/src/sys/resource.rs
++++ b/src/sys/resource.rs
+@@ -14,6 +14,7 @@ cfg_if! {
+ target_os = "openbsd",
+ target_os = "netbsd",
+ target_os = "macos",
++ target_os = "aero",
+ target_os = "ios",
+ target_os = "android",
+ target_os = "dragonfly",
+@@ -48,6 +49,7 @@ libc_enum! {
+ target_os = "ios",
+ target_os = "android",
+ target_os = "dragonfly",
++ target_os = "aero",
+ all(target_os = "linux", not(any(target_env = "gnu", target_env = "uclibc")))
+ ), repr(i32))]
+ #[non_exhaustive]
+diff --git a/src/sys/signal.rs b/src/sys/signal.rs
+index f982b4e..5621b6f 100644
+--- a/src/sys/signal.rs
++++ b/src/sys/signal.rs
+@@ -99,13 +99,13 @@ libc_enum!{
+ SIGSYS,
+ #[cfg(not(any(target_os = "android", target_os = "emscripten",
+ target_os = "fuchsia", target_os = "linux",
+- target_os = "redox")))]
++ target_os = "redox", target_os = "aero")))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
+ /// Emulator trap
+ SIGEMT,
+ #[cfg(not(any(target_os = "android", target_os = "emscripten",
+ target_os = "fuchsia", target_os = "linux",
+- target_os = "redox")))]
++ target_os = "redox", target_os = "aero")))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
+ /// Information request
+ SIGINFO,
+@@ -157,11 +157,11 @@ impl FromStr for Signal {
+ "SIGSYS" => Signal::SIGSYS,
+ #[cfg(not(any(target_os = "android", target_os = "emscripten",
+ target_os = "fuchsia", target_os = "linux",
+- target_os = "redox")))]
++ target_os = "redox", target_os = "aero")))]
+ "SIGEMT" => Signal::SIGEMT,
+ #[cfg(not(any(target_os = "android", target_os = "emscripten",
+ target_os = "fuchsia", target_os = "linux",
+- target_os = "redox")))]
++ target_os = "redox", target_os = "aero")))]
+ "SIGINFO" => Signal::SIGINFO,
+ _ => return Err(Errno::EINVAL),
+ })
+@@ -215,11 +215,11 @@ impl Signal {
+ Signal::SIGSYS => "SIGSYS",
+ #[cfg(not(any(target_os = "android", target_os = "emscripten",
+ target_os = "fuchsia", target_os = "linux",
+- target_os = "redox")))]
++ target_os = "redox", target_os = "aero")))]
+ Signal::SIGEMT => "SIGEMT",
+ #[cfg(not(any(target_os = "android", target_os = "emscripten",
+ target_os = "fuchsia", target_os = "linux",
+- target_os = "redox")))]
++ target_os = "redox", target_os = "aero")))]
+ Signal::SIGINFO => "SIGINFO",
+ }
+ }
+@@ -242,7 +242,7 @@ impl fmt::Display for Signal {
+ #[cfg(feature = "signal")]
+ pub use self::Signal::*;
- #[cfg(any(target_os = "android", target_os = "linux"))]
+-#[cfg(target_os = "redox")]
++#[cfg(any(target_os = "redox", target_os = "aero"))]
+ #[cfg(feature = "signal")]
+ const SIGNALS: [Signal; 29] = [
+ SIGHUP,
+@@ -349,7 +349,7 @@ const SIGNALS: [Signal; 30] = [
+ SIGSYS];
+ #[cfg(not(any(target_os = "linux", target_os = "android",
+ target_os = "fuchsia", target_os = "emscripten",
+- target_os = "redox")))]
++ target_os = "redox", target_os = "aero")))]
+ #[cfg(feature = "signal")]
+ const SIGNALS: [Signal; 31] = [
+ SIGHUP,
diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs
-index d486056..b367e18 100644
+index 4b8ab09..f23da26 100644
--- a/src/sys/socket/addr.rs
+++ b/src/sys/socket/addr.rs
-@@ -17,6 +17,7 @@ use std::os::unix::io::RawFd;
+@@ -19,6 +19,7 @@ use std::os::unix::io::RawFd;
use crate::sys::socket::addr::sys_control::SysControlAddr;
#[cfg(any(target_os = "android",
target_os = "dragonfly",
@@ -379,7 +492,7 @@ index d486056..b367e18 100644
target_os = "freebsd",
target_os = "ios",
target_os = "linux",
-@@ -46,6 +47,7 @@ pub enum AddressFamily {
+@@ -76,6 +77,7 @@ pub enum AddressFamily {
/// Low level packet interface (see [`packet(7)`](https://man7.org/linux/man-pages/man7/packet.7.html))
#[cfg(any(target_os = "android",
target_os = "linux",
@@ -387,7 +500,7 @@ index d486056..b367e18 100644
target_os = "illumos",
target_os = "fuchsia",
target_os = "solaris"))]
-@@ -245,7 +247,7 @@ impl AddressFamily {
+@@ -376,7 +378,7 @@ impl AddressFamily {
libc::AF_NETLINK => Some(AddressFamily::Netlink),
#[cfg(any(target_os = "macos", target_os = "macos"))]
libc::AF_SYSTEM => Some(AddressFamily::System),
@@ -396,7 +509,45 @@ index d486056..b367e18 100644
libc::AF_PACKET => Some(AddressFamily::Packet),
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
-@@ -653,6 +655,7 @@ pub enum SockAddr {
+@@ -707,7 +709,8 @@ pub struct UnixAddr {
+ #[cfg(any(target_os = "android",
+ target_os = "fuchsia",
+ target_os = "illumos",
+- target_os = "linux"
++ target_os = "linux",
++ target_os = "aero"
+ ))]
+ sun_len: u8
+ }
+@@ -842,7 +845,8 @@ impl UnixAddr {
+ if #[cfg(any(target_os = "android",
+ target_os = "fuchsia",
+ target_os = "illumos",
+- target_os = "linux"
++ target_os = "linux",
++ target_os = "aero"
+ ))]
+ {
+ UnixAddr { sun, sun_len }
+@@ -900,7 +904,8 @@ impl UnixAddr {
+ if #[cfg(any(target_os = "android",
+ target_os = "fuchsia",
+ target_os = "illumos",
+- target_os = "linux"
++ target_os = "linux",
++ target_os = "aero"
+ ))]
+ {
+ self.sun_len
+@@ -940,6 +945,7 @@ impl SockaddrLike for UnixAddr {
+ cfg_if!{
+ if #[cfg(any(target_os = "android",
+ target_os = "fuchsia",
++ target_os = "aero",
+ target_os = "illumos",
+ target_os = "linux"
+ ))] {
+@@ -1817,6 +1823,7 @@ pub enum SockAddr {
/// Datalink address (MAC)
#[cfg(any(target_os = "android",
target_os = "dragonfly",
@@ -404,64 +555,64 @@ index d486056..b367e18 100644
target_os = "freebsd",
target_os = "ios",
target_os = "linux",
-@@ -705,7 +708,7 @@ impl SockAddr {
- SockAddr::Alg(..) => AddressFamily::Alg,
- #[cfg(any(target_os = "ios", target_os = "macos"))]
+@@ -1886,7 +1893,7 @@ impl SockAddr {
+ #[cfg(all(feature = "ioctl",
+ any(target_os = "ios", target_os = "macos")))]
SockAddr::SysControl(..) => AddressFamily::System,
- #[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))]
+ #[cfg(feature = "net")]
SockAddr::Link(..) => AddressFamily::Packet,
#[cfg(any(target_os = "dragonfly",
- target_os = "freebsd",
-@@ -738,7 +741,7 @@ impl SockAddr {
+@@ -1923,7 +1930,7 @@ impl SockAddr {
if addr.is_null() {
None
} else {
- match AddressFamily::from_i32(i32::from((*addr).sa_family)) {
+ match AddressFamily::from_i32((*addr).sa_family as i32) {
Some(AddressFamily::Unix) => None,
+ #[cfg(feature = "net")]
Some(AddressFamily::Inet) => Some(SockAddr::Inet(
- InetAddr::V4(*(addr as *const libc::sockaddr_in)))),
-@@ -750,7 +753,7 @@ impl SockAddr {
- #[cfg(any(target_os = "ios", target_os = "macos"))]
+@@ -1938,7 +1945,7 @@ impl SockAddr {
+ any(target_os = "ios", target_os = "macos")))]
Some(AddressFamily::System) => Some(SockAddr::SysControl(
SysControlAddr(*(addr as *const libc::sockaddr_ctl)))),
- #[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))]
+ #[cfg(feature = "net")]
Some(AddressFamily::Packet) => Some(SockAddr::Link(
LinkAddr(*(addr as *const libc::sockaddr_ll)))),
- #[cfg(any(target_os = "dragonfly",
-@@ -833,7 +836,7 @@ impl SockAddr {
+@@ -2026,7 +2033,7 @@ impl SockAddr {
mem::size_of_val(sa) as libc::socklen_t
),
- #[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))]
+ #[cfg(feature = "net")]
SockAddr::Link(LinkAddr(ref addr)) => (
// This cast is always allowed in C
- unsafe {
-@@ -879,6 +882,7 @@ impl fmt::Display for SockAddr {
- #[cfg(any(target_os = "ios", target_os = "macos"))]
+@@ -2077,6 +2084,7 @@ impl fmt::Display for SockAddr {
+ any(target_os = "ios", target_os = "macos")))]
SockAddr::SysControl(ref sc) => sc.fmt(f),
#[cfg(any(target_os = "android",
+ target_os = "aero",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
-@@ -1064,7 +1068,7 @@ pub mod sys_control {
+@@ -2381,7 +2389,7 @@ pub mod sys_control {
}
-#[cfg(any(target_os = "android", target_os = "linux", target_os = "fuchsia"))]
-+#[cfg(any(target_os = "android", target_os = "linux", target_os = "aero", target_os = "fuchsia"))]
++#[cfg(any(target_os = "android", target_os = "linux", target_os = "fuchsia", target_os = "aero"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
mod datalink {
- use super::{fmt, AddressFamily};
-
+ feature! {
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
-index da5573c..3bac136 100644
+index 3f26ccf..c83182b 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
-@@ -251,6 +251,7 @@ libc_bitflags!{
+@@ -344,6 +344,7 @@ libc_bitflags!{
///
/// Only used in [`recvmsg`](fn.recvmsg.html) function.
#[cfg(any(target_os = "android",
@@ -469,7 +620,15 @@ index da5573c..3bac136 100644
target_os = "dragonfly",
target_os = "freebsd",
target_os = "linux",
-@@ -866,13 +867,13 @@ impl<'a> ControlMessage<'a> {
+@@ -355,6 +356,7 @@ libc_bitflags!{
+ /// (For more details, see [send(2)](https://linux.die.net/man/2/send)).
+ #[cfg(any(target_os = "android",
+ target_os = "dragonfly",
++ target_os = "aero",
+ target_os = "freebsd",
+ target_os = "fuchsia",
+ target_os = "haiku",
+@@ -1139,13 +1141,13 @@ impl<'a> ControlMessage<'a> {
/// The value of CMSG_LEN on this message.
/// Safe because CMSG_LEN is always safe
@@ -486,10 +645,10 @@ index da5573c..3bac136 100644
fn cmsg_len(&self) -> libc::c_uint {
unsafe{CMSG_LEN(self.len() as libc::c_uint)}
diff --git a/src/sys/termios.rs b/src/sys/termios.rs
-index 36a3601..c7bddc3 100644
+index a107f8b..6a9453e 100644
--- a/src/sys/termios.rs
+++ b/src/sys/termios.rs
-@@ -467,10 +467,19 @@ impl From for u32 {
+@@ -375,10 +375,19 @@ impl From for u32 {
}
// TODO: Add TCSASOFT, which will require treating this as a bitfield.
@@ -507,9 +666,9 @@ index 36a3601..c7bddc3 100644
+#[cfg(not(target_os = "aero"))]
+libc_enum! {
#[repr(i32)]
+ #[non_exhaustive]
pub enum SetArg {
- /// The change will occur immediately
-@@ -482,10 +491,19 @@ libc_enum! {
+@@ -391,10 +400,19 @@ libc_enum! {
}
}
@@ -527,9 +686,9 @@ index 36a3601..c7bddc3 100644
+#[cfg(not(target_os = "aero"))]
+libc_enum! {
#[repr(i32)]
+ #[non_exhaustive]
pub enum FlushArg {
- /// Flush data that was received but not read
-@@ -515,8 +533,17 @@ libc_enum! {
+@@ -426,8 +444,17 @@ libc_enum! {
}
// TODO: Make this usable directly as a slice index.
@@ -545,17 +704,18 @@ index 36a3601..c7bddc3 100644
+#[cfg(not(target_os = "aero"))]
+libc_enum! {
#[repr(usize)]
+ #[non_exhaustive]
pub enum SpecialCharacterIndices {
- VDISCARD,
-@@ -601,13 +628,22 @@ libc_bitflags! {
- IXOFF;
+@@ -524,7 +551,7 @@ libc_bitflags! {
#[cfg(not(target_os = "redox"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
IXANY;
- #[cfg(not(target_os = "redox"))]
+ #[cfg(not(any(target_os = "redox", target_os = "aero")))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
IMAXBEL;
#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))]
- IUTF8;
+@@ -533,6 +560,15 @@ libc_bitflags! {
}
}
@@ -571,7 +731,7 @@ index 36a3601..c7bddc3 100644
libc_bitflags! {
/// Flags for configuring the output mode of a terminal
pub struct OutputFlags: tcflag_t {
-@@ -791,8 +827,16 @@ libc_bitflags! {
+@@ -744,8 +780,16 @@ libc_bitflags! {
}
}
@@ -588,7 +748,7 @@ index 36a3601..c7bddc3 100644
pub struct ControlFlags: tcflag_t {
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
-@@ -859,8 +903,16 @@ libc_bitflags! {
+@@ -824,8 +868,16 @@ libc_bitflags! {
}
}
@@ -604,12 +764,46 @@ index 36a3601..c7bddc3 100644
+libc_bitflags! {
pub struct LocalFlags: tcflag_t {
#[cfg(not(target_os = "redox"))]
- ECHOKE;
+ #[cfg_attr(docsrs, doc(cfg(all())))]
+diff --git a/src/sys/time.rs b/src/sys/time.rs
+index c1ab67b..f43cf63 100644
+--- a/src/sys/time.rs
++++ b/src/sys/time.rs
+@@ -16,6 +16,7 @@ const TIMESPEC_ZERO: libc::timespec = unsafe {
+ target_os = "freebsd",
+ target_os = "illumos",
+ target_os = "linux",
++ target_os = "aero",
+ target_os = "netbsd"
+ ),
+ feature = "time",
+@@ -82,7 +83,7 @@ pub(crate) mod timer {
+ Interval(TimeSpec),
+ }
+
+- #[cfg(any(target_os = "android", target_os = "linux"))]
++ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))]
+ bitflags! {
+ /// Flags that are used for arming the timer.
+ pub struct TimerSetTimeFlags: libc::c_int {
+diff --git a/src/sys/timerfd.rs b/src/sys/timerfd.rs
+index 18acbae..0005b24 100644
+--- a/src/sys/timerfd.rs
++++ b/src/sys/timerfd.rs
+@@ -57,7 +57,7 @@ impl FromRawFd for TimerFd {
+ libc_enum! {
+ /// The type of the clock used to mark the progress of the timer. For more
+ /// details on each kind of clock, please refer to [timerfd_create(2)](https://man7.org/linux/man-pages/man2/timerfd_create.2.html).
+- #[repr(i32)]
++ #[repr(i64)]
+ #[non_exhaustive]
+ pub enum ClockId {
+ /// A settable system-wide real-time clock.
diff --git a/src/unistd.rs b/src/unistd.rs
-index d94cb99..8e26266 100644
+index d6ccdf1..af3b4a0 100644
--- a/src/unistd.rs
+++ b/src/unistd.rs
-@@ -1081,6 +1081,7 @@ pub fn pipe() -> std::result::Result<(RawFd, RawFd), Error> {
+@@ -1132,6 +1132,7 @@ feature! {
/// See also [pipe(2)](https://man7.org/linux/man-pages/man2/pipe.2.html)
#[cfg(any(target_os = "android",
target_os = "dragonfly",
@@ -617,7 +811,7 @@ index d94cb99..8e26266 100644
target_os = "emscripten",
target_os = "freebsd",
target_os = "illumos",
-@@ -1478,6 +1479,7 @@ pub fn getgroups() -> Result> {
+@@ -1550,6 +1551,7 @@ pub fn getgroups() -> Result> {
pub fn setgroups(groups: &[Gid]) -> Result<()> {
cfg_if! {
if #[cfg(any(target_os = "dragonfly",
@@ -625,7 +819,7 @@ index d94cb99..8e26266 100644
target_os = "freebsd",
target_os = "illumos",
target_os = "ios",
-@@ -1799,6 +1801,14 @@ pub fn mkstemp(template: &P) -> Result<(RawFd, PathBuf)> {
+@@ -1886,6 +1888,14 @@ feature! {
/// - [pathconf(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pathconf.html)
/// - [limits.h](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html)
/// - [unistd.h](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html)
@@ -639,8 +833,8 @@ index d94cb99..8e26266 100644
+#[cfg(not(target_os = "aero"))]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[repr(i32)]
- pub enum PathconfVar {
-@@ -1978,6 +1988,17 @@ pub fn pathconf(path: &P, var: PathconfVar) -> Result for User {
- gid: Gid::from_raw((*pw).pw_gid),
+@@ -2913,18 +2937,21 @@ impl From<&libc::passwd> for User {
+ gid: Gid::from_raw(pw.pw_gid),
#[cfg(not(any(target_os = "android",
target_os = "fuchsia",
+ target_os = "aero",
target_os = "illumos",
target_os = "linux",
target_os = "solaris")))]
- class: CString::new(CStr::from_ptr((*pw).pw_class).to_bytes()).unwrap(),
+ class: CString::new(CStr::from_ptr(pw.pw_class).to_bytes()).unwrap(),
#[cfg(not(any(target_os = "android",
target_os = "fuchsia",
+ target_os = "aero",
target_os = "illumos",
target_os = "linux",
target_os = "solaris")))]
- change: (*pw).pw_change,
+ change: pw.pw_change,
#[cfg(not(any(target_os = "android",
target_os = "fuchsia",
+ target_os = "aero",
target_os = "illumos",
target_os = "linux",
target_os = "solaris")))]
+@@ -2960,18 +2987,21 @@ impl From for libc::passwd {
+ pw_gid: u.gid.0,
+ #[cfg(not(any(target_os = "android",
+ target_os = "fuchsia",
++ target_os = "aero",
+ target_os = "illumos",
+ target_os = "linux",
+ target_os = "solaris")))]
+ pw_class: u.class.into_raw(),
+ #[cfg(not(any(target_os = "android",
+ target_os = "fuchsia",
++ target_os = "aero",
+ target_os = "illumos",
+ target_os = "linux",
+ target_os = "solaris")))]
+ pw_change: u.change,
+ #[cfg(not(any(target_os = "android",
+ target_os = "fuchsia",
++ target_os = "aero",
+ target_os = "illumos",
+ target_os = "linux",
+ target_os = "solaris")))]
--
-2.38.1
+2.39.1
diff --git a/patches/webkitgtk/webkitgtk.patch b/patches/webkitgtk/webkitgtk.patch
index dc84db0ae41..f80e91ec667 100644
--- a/patches/webkitgtk/webkitgtk.patch
+++ b/patches/webkitgtk/webkitgtk.patch
@@ -37,37 +37,37 @@ index 7857bfc167..c14fbb5b6c 100644
@@ -346,7 +346,7 @@ static inline void*& framePointerImpl(mcontext_t& machineContext)
#error Unknown Architecture
#endif
-
+
-#elif OS(FUCHSIA) || OS(LINUX)
+#elif OS(FUCHSIA) || OS(LINUX) || OS(AERO)
-
+
// The following sequence depends on glibc's sys/ucontext.h.
#if CPU(X86)
@@ -497,7 +497,7 @@ static inline void*& instructionPointerImpl(mcontext_t& machineContext)
#error Unknown Architecture
#endif
-
+
-#elif OS(FUCHSIA) || OS(LINUX)
+#elif OS(FUCHSIA) || OS(LINUX) || OS(AERO)
-
+
// The following sequence depends on glibc's sys/ucontext.h.
#if CPU(X86)
@@ -655,7 +655,7 @@ inline void*& argumentPointer<1>(mcontext_t& machineContext)
#error Unknown Architecture
#endif
-
+
-#elif OS(FUCHSIA) || OS(LINUX)
+#elif OS(FUCHSIA) || OS(LINUX) || OS(AERO)
-
+
// The following sequence depends on glibc's sys/ucontext.h.
#if CPU(X86)
@@ -772,7 +772,7 @@ inline void*& llintInstructionPointer(mcontext_t& machineContext)
#error Unknown Architecture
#endif
-
+
-#elif OS(FUCHSIA) || OS(LINUX)
+#elif OS(FUCHSIA) || OS(LINUX) || OS(AERO)
-
+
// The following sequence depends on glibc's sys/ucontext.h.
#if CPU(X86)
diff --git a/Source/JavaScriptCore/runtime/Options.cpp b/Source/JavaScriptCore/runtime/Options.cpp
@@ -102,7 +102,7 @@ index 8379a69659..8f7493769f 100644
@@ -43,11 +43,11 @@
#define THUMB_FUNC_PARAM(name)
#endif
-
+
-#if (OS(LINUX) || OS(FREEBSD)) && CPU(X86_64)
+#if (OS(LINUX) || OS(FREEBSD) || OS(AERO)) && CPU(X86_64)
#define GLOBAL_REFERENCE(name) #name "@plt"
@@ -138,21 +138,21 @@ index 61f13c2b73..de93124ef8 100644
@@ -226,7 +226,7 @@
#define HAVE_HOSTED_CORE_ANIMATION 1
#endif
-
+
-#if OS(DARWIN) || OS(FUCHSIA) || ((OS(FREEBSD) || OS(LINUX)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
+#if OS(DARWIN) || OS(FUCHSIA) || OS(AERO) || ((OS(FREEBSD) || OS(LINUX)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS)))
#define HAVE_MACHINE_CONTEXT 1
#endif
-
+
@@ -238,7 +238,7 @@
#define HAVE_BACKTRACE_SYMBOLS 1
#endif
-
+
-#if OS(DARWIN) || OS(LINUX)
+#if OS(DARWIN) || OS(LINUX) || OS(AERO)
#define HAVE_DLADDR 1
#endif
-
+
diff --git a/Source/WTF/wtf/PlatformOS.h b/Source/WTF/wtf/PlatformOS.h
index e61715fb72..ed72f251a9 100644
--- a/Source/WTF/wtf/PlatformOS.h
@@ -160,13 +160,13 @@ index e61715fb72..ed72f251a9 100644
@@ -118,6 +118,11 @@
#define WTF_OS_WINDOWS 1
#endif
-
+
+/* OS(AERO) - Aero */
+#if defined(__aero__)
+#define WTF_OS_AERO 1
+#endif
+
-
+
/* OS(UNIX) - Any Unix-like system */
#if OS(AIX) \
@@ -128,6 +133,7 @@
@@ -184,12 +184,12 @@ index 743ef3dc84..3a61bc1dc3 100644
@@ -148,8 +148,8 @@ bool SQLiteDatabase::open(const String& filename, OpenMode openMode)
LOG_ERROR("SQLite database could not set temp_store to memory");
}
-
+
- if (openMode != OpenMode::ReadOnly)
- useWALJournalMode();
+ // if (openMode != OpenMode::ReadOnly)
+ // useWALJournalMode();
-
+
auto shmFileName = makeString(filename, "-shm"_s);
if (FileSystem::fileExists(shmFileName)) {
@@ -727,7 +727,7 @@ Expected SQLiteDatabase::prepareStatement(ASCIILiteral que
@@ -206,7 +206,7 @@ index efcd663f84..11e5467c10 100644
--- a/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp
+++ b/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp
@@ -46,7 +46,7 @@
-
+
// Although it's available on Darwin, SOCK_SEQPACKET seems to work differently
// than in traditional Unix so fallback to STREAM on that platform.
-#if defined(SOCK_SEQPACKET) && !OS(DARWIN)
@@ -219,14 +219,14 @@ index 998a2a7679..a490b3fb5f 100644
--- a/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp
+++ b/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp
@@ -47,8 +47,10 @@
-
+
#if HAVE(LINUX_MEMFD_H)
#include
+#if !OS(AERO)
#include
#endif
+#endif
-
+
#if PLATFORM(PLAYSTATION)
#include "ArgumentCoders.h"
@@ -132,7 +134,7 @@ static int createSharedMemory()
@@ -236,7 +236,8 @@ index 998a2a7679..a490b3fb5f 100644
- fileDescriptor = syscall(__NR_memfd_create, "WebKitSharedMemory", MFD_CLOEXEC);
+ fileDescriptor = memfd_create("WebKitSharedMemory", MFD_CLOEXEC);
} while (fileDescriptor == -1 && errno == EINTR);
-
+
if (fileDescriptor != -1)
--
-2.40.0
\ No newline at end of file
+2.40.0
+
diff --git a/patches/xorg-server/xorg-server.patch b/patches/xorg-server/xorg-server.patch
index 3ef2ef41b18..9dc515d75fd 100644
--- a/patches/xorg-server/xorg-server.patch
+++ b/patches/xorg-server/xorg-server.patch
@@ -1,100 +1,114 @@
-From b43c01a762f484fd03051b57724cdad82584c9aa Mon Sep 17 00:00:00 2001
-From: Anhad Singh
-Date: Tue, 23 May 2023 19:10:14 +1000
-Subject: [PATCH] ^)
+From 6f785e20e4034b9016aa7e6cebc204f95b7808d6 Mon Sep 17 00:00:00 2001
+From: mintsuki
+Date: Sun, 20 Feb 2022 06:19:57 +0100
+Subject: [PATCH] Lyre specific changes
-Signed-off-by: Anhad Singh
---
+ configure.ac | 2 ++
hw/xfree86/common/xf86Bus.c | 2 ++
hw/xfree86/common/xf86Config.c | 2 ++
- hw/xfree86/common/xf86Configure.c | 1 +
- hw/xfree86/common/xf86Events.c | 1 +
- hw/xfree86/common/xf86Helper.c | 1 +
+ hw/xfree86/common/xf86Configure.c | 2 ++
+ hw/xfree86/common/xf86Events.c | 2 ++
+ hw/xfree86/common/xf86Helper.c | 2 ++
hw/xfree86/common/xf86Init.c | 2 ++
- hw/xfree86/fbdevhw/fbdevhw.c | 36 +++++++++++++++---------
- hw/xfree86/fbdevhw/fbdevhw.h | 4 +--
- hw/xfree86/fbdevhw/meson.build | 2 +-
- hw/xfree86/os-support/shared/posix_tty.c | 3 ++
- hw/xfree86/os-support/shared/sigio.c | 3 ++
+ hw/xfree86/fbdevhw/fbdevhw.c | 26 +++++++++++-------------
+ hw/xfree86/fbdevhw/fbdevhw.h | 4 ++--
+ hw/xfree86/os-support/shared/posix_tty.c | 3 +++
+ hw/xfree86/os-support/shared/sigio.c | 3 +++
include/os.h | 1 +
- meson.build | 3 +-
mi/mibitblt.c | 2 ++
os/access.c | 2 +-
os/ospoll.c | 2 ++
- os/utils.c | 4 +--
- 17 files changed, 50 insertions(+), 21 deletions(-)
+ os/utils.c | 4 ++--
+ 16 files changed, 42 insertions(+), 19 deletions(-)
+diff --git a/configure.ac b/configure.ac
+index 0909cc5..f551571 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1966,6 +1966,8 @@ if test "x$XORG" = xyes; then
+ if test "x$DRM" = xyes; then
+ XORG_DRIVER_MODESETTING=yes
+ fi
++
++ XORG_DRIVER_MODESETTING=no
+
+ AC_SUBST([XORG_LIBS])
+ AC_SUBST([XORG_SYS_LIBS])
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
-index fd144db..b232e27 100644
+index a8f1073..1b1120a 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
-@@ -556,6 +556,7 @@ xf86GetDevFromEntity(int entityIndex, int instance)
+@@ -536,6 +536,7 @@ xf86GetDevFromEntity(int entityIndex, int instance)
void
xf86PostProbe(void)
{
-+#if 0
++/*
if (fbSlotClaimed && (
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
sbusSlotClaimed ||
-@@ -571,6 +572,7 @@ xf86PostProbe(void)
+@@ -551,6 +552,7 @@ xf86PostProbe(void)
))
FatalError("Cannot run in framebuffer mode. Please specify busIDs "
" for all framebuffer devices\n");
-+#endif
++*/
}
- Bool
+ int
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
-index 5d814c1..dabfec8 100644
+index 09d27ec..83be062 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
-@@ -47,6 +47,8 @@
- #endif
-
+@@ -49,6 +49,8 @@
#include
-+#include
-+
#include
++#include
++
#include "xf86.h"
+ #include "xf86Modes.h"
+ #include "xf86Parser.h"
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
-index 4347f6d..3a66af7 100644
+index 44e7591..86d48d5 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
-@@ -27,6 +27,7 @@
+@@ -27,6 +27,8 @@
#include
#endif
+#include
++
#include "xf86.h"
#include "xf86Config.h"
#include "xf86_OSlib.h"
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
-index 395bbc7..5937017 100644
+index 8a800bd..ec5d33d 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
-@@ -53,6 +53,7 @@
+@@ -53,6 +53,8 @@
#include
#endif
+#include
++
#include
#include
#include
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
-index 0389945..ac231bf 100644
+index 42a51dd..64af1dc 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
-@@ -38,6 +38,7 @@
+@@ -38,6 +38,8 @@
#include
#endif
+#include
++
#include
- #include "mi.h"
#include "os.h"
+ #include "servermd.h"
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
-index 5695e71..96c2d15 100644
+index 2ec6b2f..c1d9c24 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -37,6 +37,8 @@
@@ -107,58 +121,57 @@ index 5695e71..96c2d15 100644
#if !defined(WIN32)
#define HAS_UTSNAME 1
diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c
-index 3d8b92e..dae3960 100644
+index 9508951..bce130c 100644
--- a/hw/xfree86/fbdevhw/fbdevhw.c
+++ b/hw/xfree86/fbdevhw/fbdevhw.c
-@@ -10,12 +10,13 @@
+@@ -10,12 +10,12 @@
#include "xf86_OSproc.h"
/* pci stuff */
-#include "xf86Pci.h"
-+// #include "xf86Pci.h"
++//#include "xf86Pci.h"
#include "xf86cmap.h"
#include "fbdevhw.h"
-#include "fbpriv.h"
-+// #include "fbpriv.h"
+#include
#include "globals.h"
#include
-@@ -259,6 +260,7 @@ fbdev2xfree_timing(struct fb_var_screeninfo *var, DisplayModePtr mode)
+@@ -259,6 +259,7 @@ fbdev2xfree_timing(struct fb_var_screeninfo *var, DisplayModePtr mode)
/**
* Try to find the framebuffer device for a given PCI device
*/
-+#if 0
++/*
static int
fbdev_open_pci(struct pci_device *pPci, char **namep)
{
-@@ -303,6 +305,7 @@ fbdev_open_pci(struct pci_device *pPci, char **namep)
+@@ -303,6 +304,7 @@ fbdev_open_pci(struct pci_device *pPci, char **namep)
xf86DrvMsg(-1, X_ERROR, "Unable to find a valid framebuffer device\n");
return -1;
}
-+#endif
++*/
static int
fbdev_open(int scrnIndex, const char *dev, char **namep)
-@@ -330,6 +333,7 @@ fbdev_open(int scrnIndex, const char *dev, char **namep)
+@@ -330,6 +332,7 @@ fbdev_open(int scrnIndex, const char *dev, char **namep)
}
/* only touch non-PCI devices on this path */
-+#if 0
++/*
{
- char buf[PATH_MAX] = {0};
+ char buf[PATH_MAX];
char *sysfs_path = NULL;
-@@ -344,6 +348,7 @@ fbdev_open(int scrnIndex, const char *dev, char **namep)
+@@ -344,6 +347,7 @@ fbdev_open(int scrnIndex, const char *dev, char **namep)
}
free(sysfs_path);
}
-+#endif
++*/
if (namep) {
if (-1 == ioctl(fd, FBIOGET_FSCREENINFO, (void *) (&fix))) {
-@@ -363,14 +368,16 @@ fbdev_open(int scrnIndex, const char *dev, char **namep)
+@@ -363,14 +367,11 @@ fbdev_open(int scrnIndex, const char *dev, char **namep)
/* -------------------------------------------------------------------- */
Bool
@@ -171,16 +184,11 @@ index 3d8b92e..dae3960 100644
- fd = fbdev_open_pci(pPci, namep);
- else
- fd = fbdev_open(-1, device, namep);
-+ // if (pPci)
-+ // fd = fbdev_open_pci(pPci, namep);
-+ // else
-+ // fd = fbdev_open(-1, device, namep);
-+
+ fd = fbdev_open(-1, device, namep);
if (-1 == fd)
return FALSE;
-@@ -379,7 +386,7 @@ fbdevHWProbe(struct pci_device *pPci, char *device, char **namep)
+@@ -379,7 +380,7 @@ fbdevHWProbe(struct pci_device *pPci, char *device, char **namep)
}
Bool
@@ -189,7 +197,7 @@ index 3d8b92e..dae3960 100644
{
fbdevHWPtr fPtr;
-@@ -387,10 +394,11 @@ fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device *pPci, char *device)
+@@ -387,10 +388,7 @@ fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device *pPci, char *device)
fPtr = FBDEVHWPTR(pScrn);
/* open device */
@@ -197,15 +205,11 @@ index 3d8b92e..dae3960 100644
- fPtr->fd = fbdev_open_pci(pPci, NULL);
- else
- fPtr->fd = fbdev_open(pScrn->scrnIndex, device, NULL);
-+ // if (pPci)
-+ // fPtr->fd = fbdev_open_pci(pPci, NULL);
-+ // else
-+ // fPtr->fd = fbdev_open(pScrn->scrnIndex, device, NULL);
+ fPtr->fd = fbdev_open(pScrn->scrnIndex, device, NULL);
if (-1 == fPtr->fd) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Failed to open framebuffer device, consult warnings"
-@@ -881,7 +889,7 @@ RETRY:
+@@ -881,7 +879,7 @@ RETRY:
"FBIOBLANK: %s\n", strerror(errno));
break;
case EINTR:
@@ -214,7 +218,7 @@ index 3d8b92e..dae3960 100644
goto RETRY;
default:
fPtr->unsupported_ioctls |= (1 << FBIOBLANK_UNSUPPORTED);
-@@ -915,7 +923,7 @@ RETRY:
+@@ -915,7 +913,7 @@ RETRY:
"FBIOBLANK: %s\n", strerror(errno));
break;
case EINTR:
@@ -239,16 +243,6 @@ index 4984ccf..bb3e2f8 100644
char *device);
extern _X_EXPORT char *fbdevHWGetName(ScrnInfoPtr pScrn);
-diff --git a/hw/xfree86/fbdevhw/meson.build b/hw/xfree86/fbdevhw/meson.build
-index f3146f3..5e5e6e8 100644
---- a/hw/xfree86/fbdevhw/meson.build
-+++ b/hw/xfree86/fbdevhw/meson.build
-@@ -1,4 +1,4 @@
--if host_machine.system() == 'linux'
-+if host_machine.system() == 'linux' or host_machine.system() == 'aero'
- srcs_fbdevhw = 'fbdevhw.c'
- else
- srcs_fbdevhw = 'fbdevhwstub.c'
diff --git a/hw/xfree86/os-support/shared/posix_tty.c b/hw/xfree86/os-support/shared/posix_tty.c
index 0cb9788..e8cac5d 100644
--- a/hw/xfree86/os-support/shared/posix_tty.c
@@ -264,7 +258,7 @@ index 0cb9788..e8cac5d 100644
#include
#include "xf86.h"
diff --git a/hw/xfree86/os-support/shared/sigio.c b/hw/xfree86/os-support/shared/sigio.c
-index ad8af60..6f81278 100644
+index 247bec7..216e8cd 100644
--- a/hw/xfree86/os-support/shared/sigio.c
+++ b/hw/xfree86/os-support/shared/sigio.c
@@ -56,6 +56,9 @@
@@ -278,7 +272,7 @@ index ad8af60..6f81278 100644
#include
#include "xf86.h"
diff --git a/include/os.h b/include/os.h
-index bb3348b..64b04dc 100644
+index 2a1c29e..2a7fc76 100644
--- a/include/os.h
+++ b/include/os.h
@@ -51,6 +51,7 @@ SOFTWARE.
@@ -289,22 +283,8 @@ index bb3348b..64b04dc 100644
#ifdef MONOTONIC_CLOCK
#include
#endif
-diff --git a/meson.build b/meson.build
-index 637938a..b5d761c 100644
---- a/meson.build
-+++ b/meson.build
-@@ -439,7 +439,8 @@ if not libdrm_dep.found() and libdrm_required
- error('DRI requested, but LIBDRM not found')
- endif
-
--build_modesetting = libdrm_dep.found() and dri2proto_dep.found()
-+# build_modesetting = libdrm_dep.found() and dri2proto_dep.found()
-+build_modesetting = false
-
- build_vgahw = false
- if get_option('vgahw') == 'auto'
diff --git a/mi/mibitblt.c b/mi/mibitblt.c
-index 0b13e49..aff6539 100644
+index 43d9bd9..740c0d2 100644
--- a/mi/mibitblt.c
+++ b/mi/mibitblt.c
@@ -49,6 +49,8 @@ SOFTWARE.
@@ -317,11 +297,11 @@ index 0b13e49..aff6539 100644
#include
diff --git a/os/access.c b/os/access.c
-index 61ee8e3..24cabae 100644
+index 9724616..3c4376a 100644
--- a/os/access.c
+++ b/os/access.c
-@@ -120,7 +120,7 @@ SOFTWARE.
- #include
+@@ -117,7 +117,7 @@ SOFTWARE.
+ #endif
#endif
-#if defined(SVR4) || (defined(SYSV) && defined(__i386__)) || defined(__GNU__)
@@ -330,28 +310,28 @@ index 61ee8e3..24cabae 100644
#endif
#if defined(SYSV) && defined(__i386__)
diff --git a/os/ospoll.c b/os/ospoll.c
-index c68aabc..19006c3 100644
+index c68aabc..a3217dc 100644
--- a/os/ospoll.c
+++ b/os/ospoll.c
@@ -45,11 +45,13 @@
#define HAVE_OSPOLL 1
#endif
-+#if 0
++/*
#if !HAVE_OSPOLL && defined(HAVE_EPOLL_CREATE1)
#include
#define EPOLL 1
#define HAVE_OSPOLL 1
#endif
-+#endif
++*/
#if !HAVE_OSPOLL
#include "xserver_poll.h"
diff --git a/os/utils.c b/os/utils.c
-index 92a66e8..646722e 100644
+index 2ba1c80..63dedc6 100644
--- a/os/utils.c
+++ b/os/utils.c
-@@ -1403,7 +1403,7 @@ System(const char *command)
+@@ -1402,7 +1402,7 @@ System(const char *command)
return -1;
}
@@ -360,7 +340,7 @@ index 92a66e8..646722e 100644
}
static struct pid {
-@@ -1633,7 +1633,7 @@ Pclose(void *iop)
+@@ -1632,7 +1632,7 @@ Pclose(void *iop)
}
#endif
@@ -370,5 +350,4 @@ index 92a66e8..646722e 100644
int
--
-2.40.1
-
+2.35.1
diff --git a/src/aero_kernel/src/arch/x86_64/task.rs b/src/aero_kernel/src/arch/x86_64/task.rs
index 65dbe30a927..f6370fdbca8 100644
--- a/src/aero_kernel/src/arch/x86_64/task.rs
+++ b/src/aero_kernel/src/arch/x86_64/task.rs
@@ -77,6 +77,7 @@ pub enum AuxvType {
PhEnt = 4,
PhNum = 5,
Entry = 9,
+ Secure = 23,
}
/// Returns the first address outside the user range.
@@ -401,7 +402,7 @@ impl ArchTask {
let p2_header = loaded_binary.elf.header.pt2;
unsafe {
- let hdr: [(AuxvType, usize); 4] = [
+ let hdr: [(AuxvType, usize); 5] = [
(
AuxvType::Phdr,
(p2_header.ph_offset() + loaded_binary.base_addr.as_u64()) as usize,
@@ -409,6 +410,7 @@ impl ArchTask {
(AuxvType::PhEnt, p2_header.ph_entry_size() as usize),
(AuxvType::PhNum, p2_header.ph_count() as usize),
(AuxvType::Entry, p2_header.entry_point() as usize),
+ (AuxvType::Secure, 0),
];
stack.write(0usize); // Make it 16 bytes aligned
diff --git a/src/aero_kernel/src/fs/block/mod.rs b/src/aero_kernel/src/fs/block/mod.rs
index 6f230b56f49..c7589fec014 100644
--- a/src/aero_kernel/src/fs/block/mod.rs
+++ b/src/aero_kernel/src/fs/block/mod.rs
@@ -247,6 +247,7 @@ pub trait CachedAccess: BlockDeviceInterface {
);
page.mark_dirty();
+ page.sync();
loc += size;
offset = align_down(offset as u64 + Size4KiB::SIZE, Size4KiB::SIZE) as usize;
diff --git a/src/aero_kernel/src/fs/eventfd.rs b/src/aero_kernel/src/fs/eventfd.rs
index 19972372a38..06dd3a78789 100644
--- a/src/aero_kernel/src/fs/eventfd.rs
+++ b/src/aero_kernel/src/fs/eventfd.rs
@@ -37,7 +37,7 @@ impl EventFd {
impl INodeInterface for EventFd {
fn read_at(&self, _offset: usize, buffer: &mut [u8]) -> super::Result {
let size = core::mem::size_of::();
- assert!(buffer.len() == size);
+ assert!(buffer.len() >= size);
// SAFETY: We have above verified that it is safe to dereference
// the value.
@@ -53,7 +53,7 @@ impl INodeInterface for EventFd {
fn write_at(&self, _offset: usize, buffer: &[u8]) -> super::Result {
let size = core::mem::size_of::();
- assert!(buffer.len() == size);
+ assert!(buffer.len() >= size);
// SAFETY: We have above verified that it is safe to dereference
// the value.
diff --git a/src/aero_kernel/src/fs/ext2/group_desc.rs b/src/aero_kernel/src/fs/ext2/group_desc.rs
index 3380add761a..d3552158ba2 100644
--- a/src/aero_kernel/src/fs/ext2/group_desc.rs
+++ b/src/aero_kernel/src/fs/ext2/group_desc.rs
@@ -204,14 +204,16 @@ impl Bitmap {
/// Allocates a free bit in the bitmap and returns its index.
pub fn alloc(&mut self) -> Option {
- for (i, e) in self.bitmap.iter_mut().enumerate() {
- if *e != u8::MAX {
- for bit in 0..8 {
- if !e.get_bit(bit) {
- e.set_bit(bit, true);
-
- return Some(i * 8 + bit);
- }
+ for (i, byte) in self.bitmap.iter_mut().enumerate() {
+ if *byte == u8::MAX {
+ continue;
+ }
+
+ for bit in 0..8 {
+ if !byte.get_bit(bit) {
+ byte.set_bit(bit, true);
+
+ return Some(i * 8 + bit);
}
}
}
diff --git a/src/aero_kernel/src/fs/ext2/mod.rs b/src/aero_kernel/src/fs/ext2/mod.rs
index 817d09a570e..2c0a22ae82e 100644
--- a/src/aero_kernel/src/fs/ext2/mod.rs
+++ b/src/aero_kernel/src/fs/ext2/mod.rs
@@ -211,12 +211,17 @@ impl INode {
if block_ptrs == 0 {
block_ptrs = fs.bgdt.alloc_block_ptr()?;
+ self.inode.write().data_ptr[12] = block_ptrs as u32;
}
let block_ptrs = block_ptrs * block_size;
- let offset = block_ptrs + (new_block * core::mem::size_of::());
+ let offset = block_ptrs + (next_block_num * core::mem::size_of::());
fs.block.write(offset, &new_block.to_le_bytes());
+
+ let mut inode = self.inode.write();
+ let inode_size = inode.size() + block_size;
+ inode.set_size(inode_size);
}
Some(new_block)
@@ -303,7 +308,7 @@ impl INode {
proxy: Option>,
) -> super::Result {
if !self.metadata()?.is_directory() {
- return Err(FileSystemError::NotSupported);
+ return Err(FileSystemError::NotDirectory);
}
if DirEntryIter::new(self.sref()).any(|(e, _)| e == name) {
@@ -479,7 +484,7 @@ impl INodeInterface for INode {
fn touch(&self, parent: DirCacheItem, name: &str) -> super::Result {
if !self.metadata()?.is_directory() {
- return Err(FileSystemError::NotSupported);
+ return Err(FileSystemError::NotDirectory);
}
let inode = self.make_inode(name, FileType::File, None)?;
@@ -488,7 +493,7 @@ impl INodeInterface for INode {
fn mkdir(&self, name: &str) -> super::Result {
if !self.metadata()?.is_directory() {
- return Err(FileSystemError::NotSupported);
+ return Err(FileSystemError::NotDirectory);
}
self.make_inode(name, FileType::Directory, None)
@@ -532,7 +537,7 @@ impl INodeInterface for INode {
assert!(self.proxy.is_none());
// TODO: support shared file mappings.
- assert!(!flags.contains(MMapFlags::MAP_SHARED));
+ // assert!(!flags.contains(MMapFlags::MAP_SHARED));
let private_cp: PhysFrame = FRAME_ALLOCATOR.allocate_frame().unwrap();
private_cp.as_slice_mut().fill(0);
diff --git a/src/aero_kernel/src/fs/mod.rs b/src/aero_kernel/src/fs/mod.rs
index cc3327fbaa3..230b12a4532 100644
--- a/src/aero_kernel/src/fs/mod.rs
+++ b/src/aero_kernel/src/fs/mod.rs
@@ -21,6 +21,7 @@ use aero_syscall::SyscallError;
use alloc::collections::BTreeMap;
use alloc::sync::Arc;
+use crate::fs::cache::DirCacheImpl;
use crate::userland::scheduler;
use crate::utils::sync::Mutex;
use spin::Once;
@@ -198,7 +199,7 @@ impl Path {
}
}
-#[derive(Debug, PartialEq)]
+#[derive(Debug, Copy, Clone, PartialEq)]
pub enum LookupMode {
None,
/// Creates the file if it does not exist.
@@ -248,8 +249,17 @@ pub fn lookup_path_with(
} else {
// todo: fix this shit
cwd.inode().mkdir(component)?;
- cwd =
- lookup_path_with(cwd, Path::new(component), LookupMode::None)?;
+ cwd = match lookup_path_with(
+ cwd.clone(),
+ Path::new(component),
+ LookupMode::None,
+ ) {
+ Ok(x) => x,
+ Err(e) => {
+ dbg!(component, cwd.absolute_path_str());
+ return Err(dbg!(e));
+ }
+ };
}
}
diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs
index e0c73d006cd..125db66fd92 100644
--- a/src/aero_kernel/src/main.rs
+++ b/src/aero_kernel/src/main.rs
@@ -75,6 +75,7 @@ mod prelude {
pub use alloc::string::String;
+ pub use crate::rendy::dbg;
pub use static_assertions::*;
}
}
diff --git a/src/aero_kernel/src/mem/paging/mapper.rs b/src/aero_kernel/src/mem/paging/mapper.rs
index 94d863cf5ff..169a01bd093 100644
--- a/src/aero_kernel/src/mem/paging/mapper.rs
+++ b/src/aero_kernel/src/mem/paging/mapper.rs
@@ -1189,8 +1189,11 @@ impl<'a> OffsetPageTable<'a> {
let last_level_fork = |entry: &mut PageTableEntry, n1: &mut PageTable, i: usize| {
let mut flags = entry.flags();
- // Setup copy on write page.
- flags.remove(PageTableFlags::WRITABLE);
+ // Check if the mapping is shared.
+ if !flags.contains(PageTableFlags::BIT_10) {
+ // Setup copy on write page.
+ flags.remove(PageTableFlags::WRITABLE);
+ }
entry.set_flags(flags);
n1[i].set_frame(entry.frame().unwrap(), flags);
diff --git a/src/aero_kernel/src/rendy.rs b/src/aero_kernel/src/rendy.rs
index 0bb171e7a65..30a13e7c29d 100644
--- a/src/aero_kernel/src/rendy.rs
+++ b/src/aero_kernel/src/rendy.rs
@@ -897,7 +897,7 @@ pub macro println {
pub macro dbg {
() => {
- $crate::rendy::println!("[{}:{}]", $crate::file!(), $crate::line!());
+ log::debug!("[{}:{}]", $crate::file!(), $crate::line!());
},
($val:expr $(,)?) => {
@@ -905,8 +905,7 @@ pub macro dbg {
// of temporaries - https://stackoverflow.com/a/48732525/1063961
match $val {
tmp => {
- $crate::rendy::println!("[{}:{}] {} = {:#?}",
- core::file!(), core::line!(), core::stringify!($val), &tmp);
+ log::debug!("[{}:{}] {} = {:#?}", core::file!(), core::line!(), core::stringify!($val), &tmp);
tmp
}
}
diff --git a/src/aero_kernel/src/syscall/fs.rs b/src/aero_kernel/src/syscall/fs.rs
index f0e9a81d149..a861e0f133f 100644
--- a/src/aero_kernel/src/syscall/fs.rs
+++ b/src/aero_kernel/src/syscall/fs.rs
@@ -410,7 +410,10 @@ pub fn fcntl(fd: usize, command: usize, arg: usize) -> Result unimplemented!("fcntl: unknown command {command}"),
+ _ => {
+ log::error!("fcntl: unknown command {command}");
+ Ok(0)
+ }
}
}
diff --git a/src/aero_kernel/src/syscall/mod.rs b/src/aero_kernel/src/syscall/mod.rs
index 7c1941b6a26..db3ff553376 100644
--- a/src/aero_kernel/src/syscall/mod.rs
+++ b/src/aero_kernel/src/syscall/mod.rs
@@ -157,6 +157,10 @@ impl SysLog {
result.push_str(alloc::format!(") = {:?}", self.result.unwrap()).as_str());
log::trace!("{result}");
+
+ if self.result.unwrap().is_err() {
+ crate::unwind::unwind_stack_trace();
+ }
}
}
diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs
index fbc0fe723e8..7fe895cc29a 100644
--- a/src/aero_kernel/src/userland/vm.rs
+++ b/src/aero_kernel/src/userland/vm.rs
@@ -432,17 +432,17 @@ impl Mapping {
.mmap(offset as _, size as _, self.flags)
.expect("handle_pf_file: file does not support mmap");
- unsafe {
- offset_table.map_to(
- Page::containing_address(address),
- frame,
- PageTableFlags::PRESENT
- | PageTableFlags::USER_ACCESSIBLE
- | self.protection.into(),
- )
+ let mut flags = PageTableFlags::PRESENT
+ | PageTableFlags::USER_ACCESSIBLE
+ | self.protection.into();
+
+ if self.flags.contains(MMapFlags::MAP_SHARED) {
+ flags |= PageTableFlags::BIT_10;
}
- .expect("failed to map allocated frame for private file read")
- .flush();
+
+ unsafe { offset_table.map_to(Page::containing_address(address), frame, flags) }
+ .expect("failed to map allocated frame for private file read")
+ .flush();
true
} else if reason.contains(PageFaultErrorCode::CAUSED_BY_WRITE) {
diff --git a/src/aero_proc/src/syscall.rs b/src/aero_proc/src/syscall.rs
index 6f8751e5106..cbd5089c522 100644
--- a/src/aero_proc/src/syscall.rs
+++ b/src/aero_proc/src/syscall.rs
@@ -275,21 +275,22 @@ fn process_call_args(args: &Punctuated) -> Vec {
let len_ident = Ident::new(&format!("{}_len", ident), Span::call_site());
match arg_type {
- ArgType::Slice(is_mut) => {
- let slice_expr: Expr = if is_mut {
- syn::parse_quote! {
- crate::utils::validate_slice_mut(#data_ident as *mut _, #len_ident)?
- }
- } else {
- syn::parse_quote! {
- crate::utils::validate_slice(#data_ident as *const _, #len_ident)?
- }
- };
-
- result.push(slice_expr);
- }
- ArgType::Array(is_mut) => {
- let array_expr: Expr = if is_mut {
+ ArgType::Slice(is_mut) => {
+ let slice_expr: Expr = if is_mut {
+ syn::parse_quote! {
+ crate::utils::validate_slice_mut(#data_ident as *mut _, #len_ident)?
+ }
+ } else {
+ syn::parse_quote! {
+ crate::utils::validate_slice(#data_ident as *const _, #len_ident)?
+ }
+ };
+
+ result.push(slice_expr);
+ }
+
+ ArgType::Array(is_mut) => {
+ let array_expr: Expr = if is_mut {
syn::parse_quote! {
crate::utils::validate_array_mut(#data_ident as *mut _)?
}
@@ -299,6 +300,7 @@ fn process_call_args(args: &Punctuated) -> Vec {
result.push(array_expr);
}
+
ArgType::Pointer(is_mut) => {
let ptr_expr: Expr = if is_mut {
syn::parse_quote!(#ident as *mut _)
diff --git a/tools/cargo-inject-patches.py b/tools/cargo-inject-patches.py
index 6d2d6fe48b3..7d046383d9d 100644
--- a/tools/cargo-inject-patches.py
+++ b/tools/cargo-inject-patches.py
@@ -9,17 +9,19 @@
patched_libs = {
"backtrace": "0.3.64",
"calloop": "0.9.3",
- "libc": "0.2.139",
- "libloading": "0.7.3",
+ "libc": "0.2.149",
+ "getrandom": "0.2.9",
+ "libloading": "0.8.1",
"mio": ["0.6.23", "0.8.3"],
- "nix": "0.22.3",
- "num_cpus": "1.13.0",
+ "nix": "0.24.3",
+ "num_cpus": "1.15.0",
"users": "0.11.0",
"winit": "0.26.1",
"glutin": "0.28.0",
"glutin_glx_sys": "0.1.7",
"glutin_egl_sys": "0.1.5",
"shared_library": "0.1.9",
+ "rustix": "0.38.13"
}
parser = argparse.ArgumentParser(description="Inject patched Rust libraries into Cargo lockfiles")
diff --git a/userland/apps/init/src/main.rs b/userland/apps/init/src/main.rs
index ecbaef5d8c2..fc30f33b071 100644
--- a/userland/apps/init/src/main.rs
+++ b/userland/apps/init/src/main.rs
@@ -53,21 +53,21 @@ fn main() -> Result<(), Box> {
let stdout = OpenOptions::new().write(true).open(TTY_PATH)?; // fd=1
let stderr = OpenOptions::new().write(true).open(TTY_PATH)?; // fd=2
- {
- let stdset = FileSet::new([stdin, stdout, stderr]);
- stdset.remove_cloexec();
+ // {
+ let stdset = FileSet::new([stdin, stdout, stderr]);
+ stdset.remove_cloexec();
- Command::new("dhcpd").spawn()?;
- }
+ Command::new("dhcpd").spawn()?;
+ // }
- // Swap the `/dev/tty` std{in,out,err} file descriptors with `/dev/null` to suppress the Xorg
- // server logs.
- let stdin = OpenOptions::new().read(true).open(DEV_NULL)?; // fd=0
- let stdout = OpenOptions::new().write(true).open(DEV_NULL)?; // fd=1
- let stderr = OpenOptions::new().write(true).open(DEV_NULL)?; // fd=2
+ // // Swap the `/dev/tty` std{in,out,err} file descriptors with `/dev/null` to suppress the Xorg
+ // // server logs.
+ // let stdin = OpenOptions::new().read(true).open(DEV_NULL)?; // fd=0
+ // let stdout = OpenOptions::new().write(true).open(DEV_NULL)?; // fd=1
+ // let stderr = OpenOptions::new().write(true).open(DEV_NULL)?; // fd=2
- let stdset = FileSet::new([stdin, stdout, stderr]);
- stdset.remove_cloexec();
+ // let stdset = FileSet::new([stdin, stdout, stderr]);
+ // stdset.remove_cloexec();
Command::new("startx")
.env("RUST_BACKTRACE", "full")
From 6b2f4e75f7535b11f63457b709c4d2a3d4f6b9e4 Mon Sep 17 00:00:00 2001
From: Anhad Singh
Date: Sun, 15 Oct 2023 21:18:04 +1100
Subject: [PATCH 008/112] update
Signed-off-by: Anhad Singh
---
bootstrap.yml | 14 +-
bootstrap/vcs.yml | 92 ++--
bootstrap/xorg.yml | 91 ++--
patched.txt | 5 +
patches/glib/{glib.patch => 0001-glib.patch} | 0
...ch-out-assert-in-g_io_unix_get_flags.patch | 30 ++
patches/mlibc/mlibc.patch | 138 +++--
patches/rust-libloading/rust-libloading.patch | 23 +-
patches/rust-nix/rust-nix.patch | 507 +++++-------------
....patch => 0001-Initial-Aero-support.patch} | 22 +-
patches/webkitgtk/0002-xxx.patch | 181 +++++++
.../src/arch/x86_64/interrupts/exceptions.rs | 17 +
src/aero_kernel/src/arch/x86_64/mod.rs | 4 +-
src/aero_kernel/src/arch/x86_64/task.rs | 182 +++++--
src/aero_kernel/src/mem/mod.rs | 10 +-
src/aero_kernel/src/mem/paging/mapper.rs | 8 +-
src/aero_kernel/src/syscall/process.rs | 5 +-
src/aero_kernel/src/userland/task/mod.rs | 1 +
src/aero_kernel/src/userland/vm.rs | 53 +-
tools/cargo-inject-patches.py | 2 +-
userland/apps/init/src/main.rs | 24 +-
21 files changed, 783 insertions(+), 626 deletions(-)
create mode 100644 patched.txt
rename patches/glib/{glib.patch => 0001-glib.patch} (100%)
create mode 100644 patches/glib/0002-Patch-out-assert-in-g_io_unix_get_flags.patch
rename patches/webkitgtk/{webkitgtk.patch => 0001-Initial-Aero-support.patch} (95%)
create mode 100644 patches/webkitgtk/0002-xxx.patch
diff --git a/bootstrap.yml b/bootstrap.yml
index dd8b37f0753..90ef0bb5961 100644
--- a/bootstrap.yml
+++ b/bootstrap.yml
@@ -125,8 +125,8 @@ sources:
- name: rust-nix
subdir: 'bundled'
git: 'https://github.com/nix-rust/nix.git'
- tag: 'v0.24.3'
- version: '0.24.3'
+ tag: 'v0.22.3'
+ version: '0.22.3'
- name: rust-mio-0.6
subdir: 'bundled'
@@ -150,8 +150,8 @@ sources:
- name: rust-libloading
subdir: 'bundled'
git: 'https://github.com/nagisa/rust_libloading.git'
- tag: '0.8.1'
- version: '0.8.1'
+ tag: '0.7.3'
+ version: '0.7.3'
- name: rust-getrandom
subdir: 'bundled'
@@ -966,7 +966,7 @@ packages:
- '--libdir=lib'
- '-Dmlibc_no_headers=true'
- '-Ddisable_iconv_option=true'
- - '--buildtype=release'
+ - '--buildtype=debug'
- '-Dlinux_kernel_headers=@BUILD_ROOT@/packages/linux-headers/usr/include'
- '@THIS_SOURCE_DIR@'
build:
@@ -2202,6 +2202,10 @@ packages:
- '-Dxattr=false'
- '@THIS_SOURCE_DIR@'
environ:
+ # The warning is false positive and the more recent versions of GCC. Workaround and disable the warning.
+ #
+ # Bug 1744: https://gitlab.gnome.org/GNOME/glib/-/issues/1744
+ CFLAGS: '-Wno-error=format-nonliteral'
PKG_CONFIG_SYSROOT_DIR: '@BUILD_ROOT@/system-root'
PKG_CONFIG_LIBDIR: '@BUILD_ROOT@/system-root/usr/lib/pkgconfig:@BUILD_ROOT@/system-root/usr/share/pkgconfig'
build:
diff --git a/bootstrap/vcs.yml b/bootstrap/vcs.yml
index 8b477baa697..31b040ad96d 100644
--- a/bootstrap/vcs.yml
+++ b/bootstrap/vcs.yml
@@ -3,49 +3,49 @@ packages:
#
# Git is one of the most used version control systems designed to
# handle large projects efficiently.
- - name: git
- source:
- subdir: 'bundled'
- git: 'https://github.com/git/git.git'
- tag: 'v2.32.0'
- version: '2.32.0'
- tools_required:
- - host-autoconf-v2.69
- - host-automake-v1.16
- - host-libtool
- regenerate:
- - args: ['autoreconf']
- tools_required:
- - host-pkg-config
- - host-gcc
- - virtual: pkgconfig-for-target
- triple: "x86_64-aero"
- pkgs_required:
- - mlibc
- - python
- - libexpat
- - zlib
- - openssl
- - curl
- - libiconv
- - pcre
- configure:
- - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@']
- - args:
- - './configure'
- - '--host=x86_64-aero'
- - '--prefix=/usr'
- - '--with-python=python3'
- - '--with-gitconfig=/etc/gitconfig'
- - '--with-curl=@SYSROOT_DIR@/usr'
- - '--without-iconv'
- - '--with-libpcre'
- - 'ac_cv_fread_reads_directories=1'
- - 'ac_cv_snprintf_returns_bogus=1'
- environ:
- CURL_CONFIG: '@SYSROOT_DIR@/usr/bin/curl-config'
- build:
- - args: ['make', 'NO_GETTEXT=YesPlease', '-j@PARALLELISM@']
- - args: ['make', 'NO_GETTEXT=YesPlease', 'install']
- environ:
- DESTDIR: '@THIS_COLLECT_DIR@'
+ # - name: git
+ # source:
+ # subdir: 'bundled'
+ # git: 'https://github.com/git/git.git'
+ # tag: 'v2.32.0'
+ # version: '2.32.0'
+ # tools_required:
+ # - host-autoconf-v2.69
+ # - host-automake-v1.16
+ # - host-libtool
+ # regenerate:
+ # - args: ['autoreconf']
+ # tools_required:
+ # - host-pkg-config
+ # - host-gcc
+ # - virtual: pkgconfig-for-target
+ # triple: "x86_64-aero"
+ # pkgs_required:
+ # - mlibc
+ # - python
+ # - libexpat
+ # - zlib
+ # - openssl
+ # - curl
+ # - libiconv
+ # - pcre
+ # configure:
+ # - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@']
+ # - args:
+ # - './configure'
+ # - '--host=x86_64-aero'
+ # - '--prefix=/usr'
+ # - '--with-python=python3'
+ # - '--with-gitconfig=/etc/gitconfig'
+ # - '--with-curl=@SYSROOT_DIR@/usr'
+ # - '--without-iconv'
+ # - '--with-libpcre'
+ # - 'ac_cv_fread_reads_directories=1'
+ # - 'ac_cv_snprintf_returns_bogus=1'
+ # environ:
+ # CURL_CONFIG: '@SYSROOT_DIR@/usr/bin/curl-config'
+ # build:
+ # - args: ['make', 'NO_GETTEXT=YesPlease', '-j@PARALLELISM@']
+ # - args: ['make', 'NO_GETTEXT=YesPlease', 'install']
+ # environ:
+ # DESTDIR: '@THIS_COLLECT_DIR@'
diff --git a/bootstrap/xorg.yml b/bootstrap/xorg.yml
index 2c9f9a4b604..2078bb2a9b1 100644
--- a/bootstrap/xorg.yml
+++ b/bootstrap/xorg.yml
@@ -237,6 +237,7 @@ packages:
- mlibc
- xorg-util-macros
- xorg-proto
+ - libxcb-util
configure:
- args:
- '@THIS_SOURCE_DIR@/configure'
@@ -564,44 +565,44 @@ packages:
environ:
DESTDIR: '@THIS_COLLECT_DIR@'
- - name: mesa-demos
- source:
- subdir: 'bundled'
- git: 'https://gitlab.freedesktop.org/mesa/demos.git/'
- branch: 'master'
- tools_required:
- - host-autoconf-v2.69
- - host-automake-v1.16
- - host-libtool
- - host-pkg-config
- - host-xorg-macros
- regenerate:
- - args: ['./autogen.sh']
- environ:
- 'NOCONFIGURE': 'yes'
- tools_required:
- - host-gcc
- pkgs_required:
- - mlibc
- - mesa
- configure:
- - args:
- - '@THIS_SOURCE_DIR@/configure'
- - '--host=x86_64-aero'
- - '--prefix=/usr'
- - '--sysconfdir=/etc'
- - '--localstatedir=/var'
- - '--disable-static'
- - '--disable-gles1' # Requires some linux header that we don't have
- - '--disable-vg'
- - '--disable-osmesa'
- - '--disable-rbug'
- - '--with-system-data-files'
- build:
- - args: ['make', '-j@PARALLELISM@']
- - args: ['make', 'install']
- environ:
- DESTDIR: '@THIS_COLLECT_DIR@'
+ # - name: mesa-demos
+ # source:
+ # subdir: 'bundled'
+ # git: 'https://gitlab.freedesktop.org/mesa/demos.git/'
+ # branch: 'master'
+ # tools_required:
+ # - host-autoconf-v2.69
+ # - host-automake-v1.16
+ # - host-libtool
+ # - host-pkg-config
+ # - host-xorg-macros
+ # regenerate:
+ # - args: ['./autogen.sh']
+ # environ:
+ # 'NOCONFIGURE': 'yes'
+ # tools_required:
+ # - host-gcc
+ # pkgs_required:
+ # - mlibc
+ # - mesa
+ # configure:
+ # - args:
+ # - '@THIS_SOURCE_DIR@/configure'
+ # - '--host=x86_64-aero'
+ # - '--prefix=/usr'
+ # - '--sysconfdir=/etc'
+ # - '--localstatedir=/var'
+ # - '--disable-static'
+ # - '--disable-gles1' # Requires some linux header that we don't have
+ # - '--disable-vg'
+ # - '--disable-osmesa'
+ # - '--disable-rbug'
+ # - '--with-system-data-files'
+ # build:
+ # - args: ['make', '-j@PARALLELISM@']
+ # - args: ['make', 'install']
+ # environ:
+ # DESTDIR: '@THIS_COLLECT_DIR@'
- name: mesa
source:
@@ -868,8 +869,8 @@ packages:
source:
subdir: 'bundled'
git: 'https://gitlab.freedesktop.org/pixman/pixman.git'
- tag: 'pixman-0.40.0'
- version: '0.40.0'
+ tag: 'pixman-0.42.2'
+ version: '0.42.2'
tools_required:
- host-autoconf-v2.69
- host-automake-v1.16
@@ -2202,8 +2203,8 @@ packages:
source:
subdir: 'bundled'
git: 'https://gitlab.gnome.org/GNOME/pango.git'
- tag: '1.50.11'
- version: '1.50.11'
+ tag: '1.50.14'
+ version: '1.50.14'
tools_required:
- host-pkg-config
- host-gcc
@@ -2223,8 +2224,12 @@ packages:
- libxext
- harfbuzz
- libxft
- revision: 2
+ revision: 3
configure:
+ # False positive with GCC 13 and -O3, see bug #903259
+ #
+ # https://gitlab.gnome.org/GNOME/pango/-/issues/740
+ - args: ['sed', '-i', '-e', '/\-Werror=array-bounds/d', '@THIS_SOURCE_DIR@/meson.build']
- args:
- 'meson'
- '--cross-file'
diff --git a/patched.txt b/patched.txt
new file mode 100644
index 00000000000..f1b4bdf79af
--- /dev/null
+++ b/patched.txt
@@ -0,0 +1,5 @@
+bootstrap-host-gcc
+llvm
+rust-libc
+webkitgtk
+pixman
diff --git a/patches/glib/glib.patch b/patches/glib/0001-glib.patch
similarity index 100%
rename from patches/glib/glib.patch
rename to patches/glib/0001-glib.patch
diff --git a/patches/glib/0002-Patch-out-assert-in-g_io_unix_get_flags.patch b/patches/glib/0002-Patch-out-assert-in-g_io_unix_get_flags.patch
new file mode 100644
index 00000000000..fa109fc2557
--- /dev/null
+++ b/patches/glib/0002-Patch-out-assert-in-g_io_unix_get_flags.patch
@@ -0,0 +1,30 @@
+From fe2c4357d753d3a5baed7e2354f3542a1e87b46d Mon Sep 17 00:00:00 2001
+From: Dennis Bonke
+Date: Wed, 12 Oct 2022 02:54:15 +0200
+Subject: [PATCH 2/2] Patch out assert in g_io_unix_get_flags
+
+We don't implement the neccesary bits to fully support this, so in case of doubt, return readable and writeable.
+
+Signed-off-by: Dennis Bonke
+---
+ glib/giounix.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/glib/giounix.c b/glib/giounix.c
+index ad3aba2..e0237fc 100644
+--- a/glib/giounix.c
++++ b/glib/giounix.c
+@@ -436,7 +436,10 @@ g_io_unix_get_flags (GIOChannel *channel)
+ channel->is_writeable = TRUE;
+ break;
+ default:
+- g_assert_not_reached ();
++ channel->is_readable = TRUE;
++ channel->is_writeable = TRUE;
++ break;
++ //g_assert_not_reached ();
+ }
+
+ return flags;
+--
+2.37.2
diff --git a/patches/mlibc/mlibc.patch b/patches/mlibc/mlibc.patch
index 924b3edfad2..a72e9f7fe37 100644
--- a/patches/mlibc/mlibc.patch
+++ b/patches/mlibc/mlibc.patch
@@ -1,17 +1,19 @@
-From d33a19a85fd625a2acf53f95f32c369b7f91e230 Mon Sep 17 00:00:00 2001
+From ea350e347faaa97e0499d34582ff068510809542 Mon Sep 17 00:00:00 2001
From: Anhad Singh
-Date: Thu, 3 Aug 2023 16:36:12 +1000
-Subject: [PATCH] socket: implement shutdown(2)
+Date: Fri, 13 Oct 2023 22:50:34 +1100
+Subject: [PATCH]
Signed-off-by: Anhad Singh
---
- options/glibc/generic/execinfo.cpp | 5 ++--
- options/posix/generic/sys-socket-stubs.cpp | 9 ++++++--
- options/posix/include/mlibc/posix-sysdeps.hpp | 1 +
- sysdeps/aero/generic/signals.cpp | 19 ++++++---------
- sysdeps/aero/generic/sockets.cpp | 23 +++++++++++++++++++
- sysdeps/aero/include/aero/syscall.h | 3 +++
- 6 files changed, 44 insertions(+), 16 deletions(-)
+ options/glibc/generic/execinfo.cpp | 5 +++--
+ options/posix/generic/posix_stdlib.cpp | 2 +-
+ options/rtdl/generic/linker.cpp | 2 +-
+ sysdeps/aero/generic/aero.cpp | 9 ++++++---
+ sysdeps/aero/generic/filesystem.cpp | 10 ++++++++++
+ sysdeps/aero/generic/signals.cpp | 19 +++++++------------
+ sysdeps/aero/generic/sockets.cpp | 16 ++++++++++++++++
+ sysdeps/aero/include/aero/syscall.h | 2 ++
+ 8 files changed, 46 insertions(+), 19 deletions(-)
diff --git a/options/glibc/generic/execinfo.cpp b/options/glibc/generic/execinfo.cpp
index 3474615..aaf593a 100644
@@ -30,38 +32,74 @@ index 3474615..aaf593a 100644
}
char **backtrace_symbols(void *const *, int) {
-diff --git a/options/posix/generic/sys-socket-stubs.cpp b/options/posix/generic/sys-socket-stubs.cpp
-index 1674945..037a994 100644
---- a/options/posix/generic/sys-socket-stubs.cpp
-+++ b/options/posix/generic/sys-socket-stubs.cpp
-@@ -187,8 +187,13 @@ int setsockopt(int fd, int layer, int number,
- return mlibc::sys_setsockopt(fd, layer, number, buffer, size);
+diff --git a/options/posix/generic/posix_stdlib.cpp b/options/posix/generic/posix_stdlib.cpp
+index 76b85dc..4b783b3 100644
+--- a/options/posix/generic/posix_stdlib.cpp
++++ b/options/posix/generic/posix_stdlib.cpp
+@@ -464,7 +464,7 @@ int grantpt(int) {
}
--int shutdown(int, int) {
-- mlibc::infoLogger() << "mlibc: shutdown() is a no-op!" << frg::endlog;
-+int shutdown(int sockfd, int how) {
-+ auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_shutdown, -1);
-+ if(int e = sysdep(sockfd, how); e) {
-+ errno = e;
-+ return -1;
-+ }
-+
- return 0;
+ double strtod_l(const char *__restrict__ nptr, char ** __restrict__ endptr, locale_t) {
+- mlibc::infoLogger() << "mlibc: strtod_l ignores locale!" << frg::endlog;
++ // mlibc::infoLogger() << "mlibc: strtod_l ignores locale!" << frg::endlog;
+ return strtod(nptr, endptr);
+ }
+
+diff --git a/options/rtdl/generic/linker.cpp b/options/rtdl/generic/linker.cpp
+index c604a50..eec0b7b 100644
+--- a/options/rtdl/generic/linker.cpp
++++ b/options/rtdl/generic/linker.cpp
+@@ -18,7 +18,7 @@ uintptr_t libraryBase = 0x41000000;
+
+ constexpr bool verbose = false;
+ constexpr bool stillSlightlyVerbose = false;
+-constexpr bool logBaseAddresses = false;
++constexpr bool logBaseAddresses = true;
+ constexpr bool logRpath = false;
+ constexpr bool eagerBinding = true;
+
+diff --git a/sysdeps/aero/generic/aero.cpp b/sysdeps/aero/generic/aero.cpp
+index e6bd277..a341fcf 100644
+--- a/sysdeps/aero/generic/aero.cpp
++++ b/sysdeps/aero/generic/aero.cpp
+@@ -303,10 +303,13 @@ int sys_clone(void *tcb, pid_t *tid_out, void *stack) {
+ return 0;
+ }
+
+-void sys_thread_exit() UNIMPLEMENTED("sys_thread_exit")
++void sys_thread_exit() {
++ syscall(SYS_EXIT);
++ __builtin_trap();
++}
+
+- int sys_waitpid(pid_t pid, int *status, int flags, struct rusage *ru,
+- pid_t *ret_pid) {
++int sys_waitpid(pid_t pid, int *status, int flags, struct rusage *ru,
++ pid_t *ret_pid) {
+ if (ru) {
+ mlibc::infoLogger()
+ << "mlibc: struct rusage in sys_waitpid is unsupported"
+diff --git a/sysdeps/aero/generic/filesystem.cpp b/sysdeps/aero/generic/filesystem.cpp
+index fa5a369..33a11f4 100644
+--- a/sysdeps/aero/generic/filesystem.cpp
++++ b/sysdeps/aero/generic/filesystem.cpp
+@@ -39,6 +39,16 @@ int sys_read(int fd, void *buf, size_t count, ssize_t *bytes_read) {
+ return 0;
}
-diff --git a/options/posix/include/mlibc/posix-sysdeps.hpp b/options/posix/include/mlibc/posix-sysdeps.hpp
-index 9918188..c694079 100644
---- a/options/posix/include/mlibc/posix-sysdeps.hpp
-+++ b/options/posix/include/mlibc/posix-sysdeps.hpp
-@@ -159,6 +159,7 @@ int sys_vm_unmap(void *pointer, size_t size);
- void *__restrict buffer, socklen_t *__restrict size);
- [[gnu::weak]] int sys_setsockopt(int fd, int layer, int number,
- const void *buffer, socklen_t size);
-+[[gnu::weak]] int sys_shutdown(int sockfd, int how);
- [[gnu::weak]] int sys_sigprocmask(int how, const sigset_t *__restrict set,
- sigset_t *__restrict retrieve);
- [[gnu::weak]] int sys_sigaction(int, const struct sigaction *__restrict,
++int sys_fsync(int) {
++ mlibc::infoLogger() << "\e[35mmlibc: fsync is a stub\e[39m" << frg::endlog;
++ return 0;
++}
++
++int sys_fdatasync(int) {
++ mlibc::infoLogger() << "\e[35mmlibc: fdatasync() is a no-op\e[39m" << frg::endlog;
++ return 0;
++}
++
+ // clang-format off
+ int sys_pwrite(int fd, const void *buffer, size_t count, off_t off,
+ ssize_t *written) UNIMPLEMENTED("sys_pwrite")
diff --git a/sysdeps/aero/generic/signals.cpp b/sysdeps/aero/generic/signals.cpp
index a6f69ff..611db69 100644
--- a/sysdeps/aero/generic/signals.cpp
@@ -101,20 +139,13 @@ index a6f69ff..611db69 100644
} // namespace mlibc
\ No newline at end of file
diff --git a/sysdeps/aero/generic/sockets.cpp b/sysdeps/aero/generic/sockets.cpp
-index 2db218c..ed3fc06 100644
+index 0cce3c0..10af36a 100644
--- a/sysdeps/aero/generic/sockets.cpp
+++ b/sysdeps/aero/generic/sockets.cpp
-@@ -221,6 +221,29 @@ int sys_setsockopt(int fd, int layer, int number, const void *buffer,
+@@ -221,6 +221,22 @@ int sys_setsockopt(int fd, int layer, int number, const void *buffer,
}
}
-+int sys_shutdown(int sockfd, int how) {
-+ auto ret = syscall(SYS_SOCK_SHUTDOWN, sockfd, how);
-+ if(int e = sc_error(ret); e)
-+ return e;
-+ return 0;
-+}
-+
+int sys_peername(int fd, struct sockaddr *addr_ptr, socklen_t max_addr_length, socklen_t *actual_length) {
+ auto ret = syscall(SYS_GETPEERNAME, fd, addr_ptr, &max_addr_length);
+ if (int e = sc_error(ret); e)
@@ -131,18 +162,17 @@ index 2db218c..ed3fc06 100644
+ return 0;
+}
+
- int sys_if_nametoindex(const char *name, unsigned int *ret) {
- int fd = 0;
- int r = sys_socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, AF_UNSPEC, &fd);
+ int sys_shutdown(int sockfd, int how) {
+ auto ret = syscall(SYS_SOCK_SHUTDOWN, sockfd, how);
+ if(int e = sc_error(ret); e)
diff --git a/sysdeps/aero/include/aero/syscall.h b/sysdeps/aero/include/aero/syscall.h
-index d8bf99e..39c5b65 100644
+index 3f36e4d..39c5b65 100644
--- a/sysdeps/aero/include/aero/syscall.h
+++ b/sysdeps/aero/include/aero/syscall.h
-@@ -79,6 +79,9 @@
- #define SYS_SETPGID 72
+@@ -80,6 +80,8 @@
#define SYS_SETSID 73
#define SYS_GETPGID 74
-+#define SYS_SOCK_SHUTDOWN 75
+ #define SYS_SOCK_SHUTDOWN 75
+#define SYS_GETPEERNAME 76
+#define SYS_GETSOCKNAME 77
diff --git a/patches/rust-libloading/rust-libloading.patch b/patches/rust-libloading/rust-libloading.patch
index 743d6cedefc..ac3ec05e6f1 100644
--- a/patches/rust-libloading/rust-libloading.patch
+++ b/patches/rust-libloading/rust-libloading.patch
@@ -1,15 +1,14 @@
-From d6dfe23ee9299412d8281dabb7f5d903e152b589 Mon Sep 17 00:00:00 2001
-From: Anhad Singh
-Date: Tue, 10 Oct 2023 17:24:17 +1100
+From f5fab150ee8fbfdef46888837b6e6d43fd3ec1c0 Mon Sep 17 00:00:00 2001
+From: Andy-Python-Programmer
+Date: Sun, 20 Nov 2022 13:39:51 +1100
Subject: [PATCH]
-Signed-off-by: Anhad Singh
---
src/os/unix/consts.rs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/os/unix/consts.rs b/src/os/unix/consts.rs
-index ed3edaf..61659ff 100644
+index dbe4df9..fbdd2e3 100644
--- a/src/os/unix/consts.rs
+++ b/src/os/unix/consts.rs
@@ -58,7 +58,7 @@ mod posix {
@@ -19,9 +18,9 @@ index ed3edaf..61659ff 100644
- if #[cfg(target_os = "haiku")] {
+ if #[cfg(any(target_os = "haiku", target_os = "aero"))] {
pub(super) const RTLD_LAZY: c_int = 0;
- } else if #[cfg(target_os = "aix")] {
- pub(super) const RTLD_LAZY: c_int = 4;
-@@ -94,7 +94,7 @@ mod posix {
+ } else if #[cfg(any(
+ target_os = "linux",
+@@ -90,7 +90,7 @@ mod posix {
}
cfg_if! {
@@ -30,7 +29,7 @@ index ed3edaf..61659ff 100644
pub(super) const RTLD_NOW: c_int = 1;
} else if #[cfg(any(
target_os = "linux",
-@@ -133,6 +133,7 @@ mod posix {
+@@ -126,6 +126,7 @@ mod posix {
cfg_if! {
if #[cfg(any(
target_os = "haiku",
@@ -38,14 +37,14 @@ index ed3edaf..61659ff 100644
all(target_os = "android",target_pointer_width = "32"),
))] {
pub(super) const RTLD_GLOBAL: c_int = 2;
-@@ -210,6 +211,7 @@ mod posix {
+@@ -193,6 +194,7 @@ mod posix {
+
target_os = "fuchsia",
target_os = "redox",
- target_os = "hurd",
+ target_os = "aero",
))] {
pub(super) const RTLD_LOCAL: c_int = 0;
} else {
--
-2.42.0
+2.38.1
diff --git a/patches/rust-nix/rust-nix.patch b/patches/rust-nix/rust-nix.patch
index 0c124a2aa8e..32bf6442d21 100644
--- a/patches/rust-nix/rust-nix.patch
+++ b/patches/rust-nix/rust-nix.patch
@@ -1,26 +1,20 @@
-From 2ac82af89ae503c8743dcd96bca3dcbddccd1eea Mon Sep 17 00:00:00 2001
-From: Dennis Bonke
-Date: Thu, 23 Feb 2023 00:41:07 +0100
-Subject: [PATCH] aero: initial port
+From 608f6dc307498272ec3a6317cac3bbbe2a8b74b1 Mon Sep 17 00:00:00 2001
+From: Andy-Python-Programmer
+Date: Sun, 20 Nov 2022 12:21:43 +1100
+Subject: [PATCH]
-Signed-off-by: Dennis Bonke
---
- src/errno.rs | 218 +++++++++++++++++++++++++++++++++++++++++
- src/features.rs | 2 +-
- src/lib.rs | 10 +-
+ src/errno.rs | 217 +++++++++++++++++++++++++++++++++++++++++
+ src/lib.rs | 12 ++-
src/sys/mod.rs | 10 +-
- src/sys/resource.rs | 2 +
- src/sys/signal.rs | 16 +--
- src/sys/socket/addr.rs | 26 +++--
- src/sys/socket/mod.rs | 6 +-
+ src/sys/socket/addr.rs | 16 +--
+ src/sys/socket/mod.rs | 5 +-
src/sys/termios.rs | 54 +++++++++-
- src/sys/time.rs | 3 +-
- src/sys/timerfd.rs | 2 +-
- src/unistd.rs | 30 ++++++
- 12 files changed, 350 insertions(+), 29 deletions(-)
+ src/unistd.rs | 27 +++++
+ 7 files changed, 327 insertions(+), 14 deletions(-)
diff --git a/src/errno.rs b/src/errno.rs
-index 41420e8..aedf294 100644
+index 9c2dfe4..d26d63d 100644
--- a/src/errno.rs
+++ b/src/errno.rs
@@ -22,6 +22,7 @@ cfg_if! {
@@ -41,7 +35,7 @@ index 41420e8..aedf294 100644
match errno {
UnknownErrno => "Unknown errno",
EPERM => "Operation not permitted",
-@@ -1562,6 +1566,220 @@ mod consts {
+@@ -1557,6 +1561,219 @@ mod consts {
}
}
@@ -117,7 +111,7 @@ index 41420e8..aedf294 100644
+ // ENOTDIR = libc::ENOTDIR,
+ // ENOTEMPTY = libc::ENOTEMPTY,
+ // ENOTSOCK = libc::ENOTSOCK,
-+ ENOTSUP = libc::ENOTSUP,
++ // ENOTSUP = libc::ENOTSUP,
+ ENOTTY = libc::ENOTTY,
+ // ENXIO = libc::ENXIO,
+ // EOPNOTSUPP = libc::EOPNOTSUPP,
@@ -154,7 +148,7 @@ index 41420e8..aedf294 100644
+
+ // pub const EL2NSYNC: Errno = Errno::UnknownErrno;
+
-+ pub const fn from_i32(e: i32) -> Errno {
++ pub fn from_i32(e: i32) -> Errno {
+ use self::Errno::*;
+
+ match e {
@@ -224,7 +218,7 @@ index 41420e8..aedf294 100644
+ // libc::ENOTDIR => ENOTDIR,
+ // libc::ENOTEMPTY => ENOTEMPTY,
+ // libc::ENOTSOCK => ENOTSOCK,
-+ libc::ENOTSUP => ENOTSUP,
++ // libc::ENOTSUP => ENOTSUP,
+ // libc::ENOTTY => ENOTTY,
+ // libc::ENXIO => ENXIO,
+ // libc::EOPNOTSUPP => EOPNOTSUPP,
@@ -258,233 +252,126 @@ index 41420e8..aedf294 100644
+ }
+ }
+}
-+
#[cfg(target_os = "dragonfly")]
mod consts {
-diff --git a/src/features.rs b/src/features.rs
-index 6108098..1f937e2 100644
---- a/src/features.rs
-+++ b/src/features.rs
-@@ -1,7 +1,7 @@
- //! Feature tests for OS functionality
- pub use self::os::*;
-
--#[cfg(any(target_os = "linux", target_os = "android"))]
-+#[cfg(any(target_os = "linux", target_os = "android", target_os = "aero"))]
- mod os {
- use std::os::unix::ffi::OsStrExt;
- use crate::sys::utsname::uname;
diff --git a/src/lib.rs b/src/lib.rs
-index d4dcbc4..e5f03c7 100644
+index 3b534a5..f7c8495 100644
--- a/src/lib.rs
+++ b/src/lib.rs
-@@ -43,9 +43,10 @@
+@@ -5,12 +5,13 @@
+ #![crate_name = "nix"]
#![cfg(unix)]
- #![cfg_attr(docsrs, doc(cfg(all())))]
#![allow(non_camel_case_types)]
+#![allow(non_snake_case)]
+ // latest bitflags triggers a rustc bug with cross-crate macro expansions causing dead_code
+ // warnings even though the macro expands into something with allow(dead_code)
+ #![allow(dead_code)]
#![cfg_attr(test, deny(warnings))]
#![recursion_limit = "500"]
-#![deny(unused)]
+// #![deny(unused)]
- #![allow(unused_macros)]
- #![cfg_attr(not(feature = "default"), allow(unused_imports))]
#![deny(unstable_features)]
-@@ -62,12 +63,13 @@ pub use libc;
+ #![deny(missing_copy_implementations)]
+ #![deny(missing_debug_implementations)]
+@@ -22,11 +23,13 @@ pub use libc;
#[macro_use] mod macros;
// Public crates
-#[cfg(not(target_os = "redox"))]
+#[cfg(not(any(target_os = "redox", target_os = "aero")))]
- feature! {
- #![feature = "dir"]
- #[allow(missing_docs)]
- pub mod dir;
- }
+ pub mod dir;
+#[cfg(not(target_os = "aero"))]
- feature! {
- #![feature = "env"]
- pub mod env;
-@@ -96,7 +98,7 @@ feature! {
- target_os = "openbsd"))]
- #[deny(missing_docs)]
- pub mod ifaddrs;
-- #[cfg(not(target_os = "redox"))]
-+ #[cfg(not(any(target_os = "redox", target_os = "aero")))]
- #[deny(missing_docs)]
- pub mod net;
- }
-@@ -124,6 +126,7 @@ feature! {
- #[allow(missing_docs)]
- pub mod mqueue;
- }
+ pub mod env;
+ pub mod errno;
+ #[deny(missing_docs)]
+#[cfg(not(target_os = "aero"))]
- feature! {
- #![feature = "poll"]
- pub mod poll;
-@@ -134,6 +137,7 @@ feature! {
- #[deny(missing_docs)]
- pub mod pty;
- }
+ pub mod features;
+ pub mod fcntl;
+ #[deny(missing_docs)]
+@@ -54,15 +57,18 @@ pub mod mount;
+ target_os = "netbsd"))]
+ pub mod mqueue;
+ #[deny(missing_docs)]
+-#[cfg(not(target_os = "redox"))]
++#[cfg(not(any(target_os = "redox", target_os = "aero")))]
+ pub mod net;
+ #[deny(missing_docs)]
++#[cfg(not(target_os = "aero"))]
+ pub mod poll;
+ #[deny(missing_docs)]
+ #[cfg(not(any(target_os = "redox", target_os = "fuchsia")))]
+ pub mod pty;
+#[cfg(not(target_os = "aero"))]
- feature! {
- #![feature = "sched"]
- pub mod sched;
+ pub mod sched;
+ pub mod sys;
++#[cfg(not(target_os = "aero"))]
+ pub mod time;
+ // This can be implemented for other platforms as soon as libc
+ // provides bindings for them.
diff --git a/src/sys/mod.rs b/src/sys/mod.rs
-index e5639f2..2cbdff5 100644
+index 43877a1..20dd8e5 100644
--- a/src/sys/mod.rs
+++ b/src/sys/mod.rs
-@@ -13,7 +13,7 @@ feature! {
- feature! {
- #![feature = "event"]
+@@ -6,7 +6,7 @@
+ target_os = "netbsd"))]
+ pub mod aio;
-- #[cfg(any(target_os = "android", target_os = "linux"))]
-+ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))]
- #[allow(missing_docs)]
- pub mod epoll;
+-#[cfg(any(target_os = "android", target_os = "linux"))]
++#[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))]
+ pub mod epoll;
-@@ -64,6 +64,7 @@ feature! {
- pub mod personality;
- }
+ #[cfg(any(target_os = "dragonfly",
+@@ -42,6 +42,7 @@ pub mod mman;
+ #[cfg(target_os = "linux")]
+ pub mod personality;
+#[cfg(not(target_os = "aero"))]
- feature! {
- #![feature = "pthread"]
- pub mod pthread;
-@@ -100,7 +101,7 @@ feature! {
- pub mod resource;
- }
+ pub mod pthread;
+
+ #[cfg(any(target_os = "android",
+@@ -59,7 +60,8 @@ pub mod quota;
+ #[cfg(any(target_os = "linux"))]
+ pub mod reboot;
-#[cfg(not(target_os = "redox"))]
++// #[cfg(not(target_os = "redox"))]
+#[cfg(not(any(target_os = "redox", target_os = "aero")))]
- feature! {
- #![feature = "poll"]
- pub mod select;
-@@ -152,6 +153,7 @@ feature! {
- pub mod statfs;
- }
+ pub mod select;
+
+ #[cfg(any(target_os = "android",
+@@ -69,6 +71,7 @@ pub mod select;
+ target_os = "macos"))]
+ pub mod sendfile;
+#[cfg(not(target_os = "aero"))]
- feature! {
- #![feature = "fs"]
- pub mod statvfs;
-@@ -181,6 +183,7 @@ feature! {
- pub mod utsname;
- }
+ pub mod signal;
+
+ #[cfg(any(target_os = "android", target_os = "linux"))]
+@@ -89,6 +92,7 @@ pub mod stat;
+ ))]
+ pub mod statfs;
+#[cfg(not(target_os = "aero"))]
- feature! {
- #![feature = "process"]
- pub mod wait;
-@@ -192,7 +195,7 @@ feature! {
- pub mod inotify;
- }
+ pub mod statvfs;
--#[cfg(any(target_os = "android", target_os = "linux"))]
-+#[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))]
- feature! {
- #![feature = "time"]
- pub mod timerfd;
-@@ -203,6 +206,7 @@ feature! {
- target_os = "freebsd",
- target_os = "illumos",
- target_os = "linux",
-+ target_os = "aero",
- target_os = "netbsd"
- ),
- feature = "time",
-diff --git a/src/sys/resource.rs b/src/sys/resource.rs
-index 76ceaf5..3457acd 100644
---- a/src/sys/resource.rs
-+++ b/src/sys/resource.rs
-@@ -14,6 +14,7 @@ cfg_if! {
- target_os = "openbsd",
- target_os = "netbsd",
- target_os = "macos",
-+ target_os = "aero",
- target_os = "ios",
- target_os = "android",
- target_os = "dragonfly",
-@@ -48,6 +49,7 @@ libc_enum! {
- target_os = "ios",
- target_os = "android",
- target_os = "dragonfly",
-+ target_os = "aero",
- all(target_os = "linux", not(any(target_env = "gnu", target_env = "uclibc")))
- ), repr(i32))]
- #[non_exhaustive]
-diff --git a/src/sys/signal.rs b/src/sys/signal.rs
-index f982b4e..5621b6f 100644
---- a/src/sys/signal.rs
-+++ b/src/sys/signal.rs
-@@ -99,13 +99,13 @@ libc_enum!{
- SIGSYS,
- #[cfg(not(any(target_os = "android", target_os = "emscripten",
- target_os = "fuchsia", target_os = "linux",
-- target_os = "redox")))]
-+ target_os = "redox", target_os = "aero")))]
- #[cfg_attr(docsrs, doc(cfg(all())))]
- /// Emulator trap
- SIGEMT,
- #[cfg(not(any(target_os = "android", target_os = "emscripten",
- target_os = "fuchsia", target_os = "linux",
-- target_os = "redox")))]
-+ target_os = "redox", target_os = "aero")))]
- #[cfg_attr(docsrs, doc(cfg(all())))]
- /// Information request
- SIGINFO,
-@@ -157,11 +157,11 @@ impl FromStr for Signal {
- "SIGSYS" => Signal::SIGSYS,
- #[cfg(not(any(target_os = "android", target_os = "emscripten",
- target_os = "fuchsia", target_os = "linux",
-- target_os = "redox")))]
-+ target_os = "redox", target_os = "aero")))]
- "SIGEMT" => Signal::SIGEMT,
- #[cfg(not(any(target_os = "android", target_os = "emscripten",
- target_os = "fuchsia", target_os = "linux",
-- target_os = "redox")))]
-+ target_os = "redox", target_os = "aero")))]
- "SIGINFO" => Signal::SIGINFO,
- _ => return Err(Errno::EINVAL),
- })
-@@ -215,11 +215,11 @@ impl Signal {
- Signal::SIGSYS => "SIGSYS",
- #[cfg(not(any(target_os = "android", target_os = "emscripten",
- target_os = "fuchsia", target_os = "linux",
-- target_os = "redox")))]
-+ target_os = "redox", target_os = "aero")))]
- Signal::SIGEMT => "SIGEMT",
- #[cfg(not(any(target_os = "android", target_os = "emscripten",
- target_os = "fuchsia", target_os = "linux",
-- target_os = "redox")))]
-+ target_os = "redox", target_os = "aero")))]
- Signal::SIGINFO => "SIGINFO",
- }
- }
-@@ -242,7 +242,7 @@ impl fmt::Display for Signal {
- #[cfg(feature = "signal")]
- pub use self::Signal::*;
+ #[cfg(any(target_os = "android", target_os = "linux"))]
+@@ -100,8 +104,10 @@ pub mod time;
+
+ pub mod uio;
+
++#[cfg(not(target_os = "aero"))]
+ pub mod utsname;
+
++#[cfg(not(target_os = "aero"))]
+ pub mod wait;
--#[cfg(target_os = "redox")]
-+#[cfg(any(target_os = "redox", target_os = "aero"))]
- #[cfg(feature = "signal")]
- const SIGNALS: [Signal; 29] = [
- SIGHUP,
-@@ -349,7 +349,7 @@ const SIGNALS: [Signal; 30] = [
- SIGSYS];
- #[cfg(not(any(target_os = "linux", target_os = "android",
- target_os = "fuchsia", target_os = "emscripten",
-- target_os = "redox")))]
-+ target_os = "redox", target_os = "aero")))]
- #[cfg(feature = "signal")]
- const SIGNALS: [Signal; 31] = [
- SIGHUP,
+ #[cfg(any(target_os = "android", target_os = "linux"))]
diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs
-index 4b8ab09..f23da26 100644
+index d486056..b367e18 100644
--- a/src/sys/socket/addr.rs
+++ b/src/sys/socket/addr.rs
-@@ -19,6 +19,7 @@ use std::os::unix::io::RawFd;
+@@ -17,6 +17,7 @@ use std::os::unix::io::RawFd;
use crate::sys::socket::addr::sys_control::SysControlAddr;
#[cfg(any(target_os = "android",
target_os = "dragonfly",
@@ -492,7 +379,7 @@ index 4b8ab09..f23da26 100644
target_os = "freebsd",
target_os = "ios",
target_os = "linux",
-@@ -76,6 +77,7 @@ pub enum AddressFamily {
+@@ -46,6 +47,7 @@ pub enum AddressFamily {
/// Low level packet interface (see [`packet(7)`](https://man7.org/linux/man-pages/man7/packet.7.html))
#[cfg(any(target_os = "android",
target_os = "linux",
@@ -500,7 +387,7 @@ index 4b8ab09..f23da26 100644
target_os = "illumos",
target_os = "fuchsia",
target_os = "solaris"))]
-@@ -376,7 +378,7 @@ impl AddressFamily {
+@@ -245,7 +247,7 @@ impl AddressFamily {
libc::AF_NETLINK => Some(AddressFamily::Netlink),
#[cfg(any(target_os = "macos", target_os = "macos"))]
libc::AF_SYSTEM => Some(AddressFamily::System),
@@ -509,45 +396,7 @@ index 4b8ab09..f23da26 100644
libc::AF_PACKET => Some(AddressFamily::Packet),
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
-@@ -707,7 +709,8 @@ pub struct UnixAddr {
- #[cfg(any(target_os = "android",
- target_os = "fuchsia",
- target_os = "illumos",
-- target_os = "linux"
-+ target_os = "linux",
-+ target_os = "aero"
- ))]
- sun_len: u8
- }
-@@ -842,7 +845,8 @@ impl UnixAddr {
- if #[cfg(any(target_os = "android",
- target_os = "fuchsia",
- target_os = "illumos",
-- target_os = "linux"
-+ target_os = "linux",
-+ target_os = "aero"
- ))]
- {
- UnixAddr { sun, sun_len }
-@@ -900,7 +904,8 @@ impl UnixAddr {
- if #[cfg(any(target_os = "android",
- target_os = "fuchsia",
- target_os = "illumos",
-- target_os = "linux"
-+ target_os = "linux",
-+ target_os = "aero"
- ))]
- {
- self.sun_len
-@@ -940,6 +945,7 @@ impl SockaddrLike for UnixAddr {
- cfg_if!{
- if #[cfg(any(target_os = "android",
- target_os = "fuchsia",
-+ target_os = "aero",
- target_os = "illumos",
- target_os = "linux"
- ))] {
-@@ -1817,6 +1823,7 @@ pub enum SockAddr {
+@@ -653,6 +655,7 @@ pub enum SockAddr {
/// Datalink address (MAC)
#[cfg(any(target_os = "android",
target_os = "dragonfly",
@@ -555,64 +404,64 @@ index 4b8ab09..f23da26 100644
target_os = "freebsd",
target_os = "ios",
target_os = "linux",
-@@ -1886,7 +1893,7 @@ impl SockAddr {
- #[cfg(all(feature = "ioctl",
- any(target_os = "ios", target_os = "macos")))]
+@@ -705,7 +708,7 @@ impl SockAddr {
+ SockAddr::Alg(..) => AddressFamily::Alg,
+ #[cfg(any(target_os = "ios", target_os = "macos"))]
SockAddr::SysControl(..) => AddressFamily::System,
- #[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))]
- #[cfg(feature = "net")]
SockAddr::Link(..) => AddressFamily::Packet,
#[cfg(any(target_os = "dragonfly",
-@@ -1923,7 +1930,7 @@ impl SockAddr {
+ target_os = "freebsd",
+@@ -738,7 +741,7 @@ impl SockAddr {
if addr.is_null() {
None
} else {
- match AddressFamily::from_i32(i32::from((*addr).sa_family)) {
+ match AddressFamily::from_i32((*addr).sa_family as i32) {
Some(AddressFamily::Unix) => None,
- #[cfg(feature = "net")]
Some(AddressFamily::Inet) => Some(SockAddr::Inet(
-@@ -1938,7 +1945,7 @@ impl SockAddr {
- any(target_os = "ios", target_os = "macos")))]
+ InetAddr::V4(*(addr as *const libc::sockaddr_in)))),
+@@ -750,7 +753,7 @@ impl SockAddr {
+ #[cfg(any(target_os = "ios", target_os = "macos"))]
Some(AddressFamily::System) => Some(SockAddr::SysControl(
SysControlAddr(*(addr as *const libc::sockaddr_ctl)))),
- #[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))]
- #[cfg(feature = "net")]
Some(AddressFamily::Packet) => Some(SockAddr::Link(
LinkAddr(*(addr as *const libc::sockaddr_ll)))),
-@@ -2026,7 +2033,7 @@ impl SockAddr {
+ #[cfg(any(target_os = "dragonfly",
+@@ -833,7 +836,7 @@ impl SockAddr {
mem::size_of_val(sa) as libc::socklen_t
),
- #[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))]
- #[cfg(feature = "net")]
SockAddr::Link(LinkAddr(ref addr)) => (
// This cast is always allowed in C
-@@ -2077,6 +2084,7 @@ impl fmt::Display for SockAddr {
- any(target_os = "ios", target_os = "macos")))]
+ unsafe {
+@@ -879,6 +882,7 @@ impl fmt::Display for SockAddr {
+ #[cfg(any(target_os = "ios", target_os = "macos"))]
SockAddr::SysControl(ref sc) => sc.fmt(f),
#[cfg(any(target_os = "android",
+ target_os = "aero",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
-@@ -2381,7 +2389,7 @@ pub mod sys_control {
+@@ -1064,7 +1068,7 @@ pub mod sys_control {
}
-#[cfg(any(target_os = "android", target_os = "linux", target_os = "fuchsia"))]
-+#[cfg(any(target_os = "android", target_os = "linux", target_os = "fuchsia", target_os = "aero"))]
- #[cfg_attr(docsrs, doc(cfg(all())))]
++#[cfg(any(target_os = "android", target_os = "linux", target_os = "aero", target_os = "fuchsia"))]
mod datalink {
- feature! {
+ use super::{fmt, AddressFamily};
+
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
-index 3f26ccf..c83182b 100644
+index da5573c..3bac136 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
-@@ -344,6 +344,7 @@ libc_bitflags!{
+@@ -251,6 +251,7 @@ libc_bitflags!{
///
/// Only used in [`recvmsg`](fn.recvmsg.html) function.
#[cfg(any(target_os = "android",
@@ -620,15 +469,7 @@ index 3f26ccf..c83182b 100644
target_os = "dragonfly",
target_os = "freebsd",
target_os = "linux",
-@@ -355,6 +356,7 @@ libc_bitflags!{
- /// (For more details, see [send(2)](https://linux.die.net/man/2/send)).
- #[cfg(any(target_os = "android",
- target_os = "dragonfly",
-+ target_os = "aero",
- target_os = "freebsd",
- target_os = "fuchsia",
- target_os = "haiku",
-@@ -1139,13 +1141,13 @@ impl<'a> ControlMessage<'a> {
+@@ -866,13 +867,13 @@ impl<'a> ControlMessage<'a> {
/// The value of CMSG_LEN on this message.
/// Safe because CMSG_LEN is always safe
@@ -645,10 +486,10 @@ index 3f26ccf..c83182b 100644
fn cmsg_len(&self) -> libc::c_uint {
unsafe{CMSG_LEN(self.len() as libc::c_uint)}
diff --git a/src/sys/termios.rs b/src/sys/termios.rs
-index a107f8b..6a9453e 100644
+index 36a3601..c7bddc3 100644
--- a/src/sys/termios.rs
+++ b/src/sys/termios.rs
-@@ -375,10 +375,19 @@ impl From for u32 {
+@@ -467,10 +467,19 @@ impl From for u32 {
}
// TODO: Add TCSASOFT, which will require treating this as a bitfield.
@@ -666,9 +507,9 @@ index a107f8b..6a9453e 100644
+#[cfg(not(target_os = "aero"))]
+libc_enum! {
#[repr(i32)]
- #[non_exhaustive]
pub enum SetArg {
-@@ -391,10 +400,19 @@ libc_enum! {
+ /// The change will occur immediately
+@@ -482,10 +491,19 @@ libc_enum! {
}
}
@@ -686,9 +527,9 @@ index a107f8b..6a9453e 100644
+#[cfg(not(target_os = "aero"))]
+libc_enum! {
#[repr(i32)]
- #[non_exhaustive]
pub enum FlushArg {
-@@ -426,8 +444,17 @@ libc_enum! {
+ /// Flush data that was received but not read
+@@ -515,8 +533,17 @@ libc_enum! {
}
// TODO: Make this usable directly as a slice index.
@@ -704,18 +545,17 @@ index a107f8b..6a9453e 100644
+#[cfg(not(target_os = "aero"))]
+libc_enum! {
#[repr(usize)]
- #[non_exhaustive]
pub enum SpecialCharacterIndices {
-@@ -524,7 +551,7 @@ libc_bitflags! {
+ VDISCARD,
+@@ -601,13 +628,22 @@ libc_bitflags! {
+ IXOFF;
#[cfg(not(target_os = "redox"))]
- #[cfg_attr(docsrs, doc(cfg(all())))]
IXANY;
- #[cfg(not(target_os = "redox"))]
+ #[cfg(not(any(target_os = "redox", target_os = "aero")))]
- #[cfg_attr(docsrs, doc(cfg(all())))]
IMAXBEL;
#[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))]
-@@ -533,6 +560,15 @@ libc_bitflags! {
+ IUTF8;
}
}
@@ -731,7 +571,7 @@ index a107f8b..6a9453e 100644
libc_bitflags! {
/// Flags for configuring the output mode of a terminal
pub struct OutputFlags: tcflag_t {
-@@ -744,8 +780,16 @@ libc_bitflags! {
+@@ -791,8 +827,16 @@ libc_bitflags! {
}
}
@@ -748,7 +588,7 @@ index a107f8b..6a9453e 100644
pub struct ControlFlags: tcflag_t {
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
-@@ -824,8 +868,16 @@ libc_bitflags! {
+@@ -859,8 +903,16 @@ libc_bitflags! {
}
}
@@ -764,46 +604,12 @@ index a107f8b..6a9453e 100644
+libc_bitflags! {
pub struct LocalFlags: tcflag_t {
#[cfg(not(target_os = "redox"))]
- #[cfg_attr(docsrs, doc(cfg(all())))]
-diff --git a/src/sys/time.rs b/src/sys/time.rs
-index c1ab67b..f43cf63 100644
---- a/src/sys/time.rs
-+++ b/src/sys/time.rs
-@@ -16,6 +16,7 @@ const TIMESPEC_ZERO: libc::timespec = unsafe {
- target_os = "freebsd",
- target_os = "illumos",
- target_os = "linux",
-+ target_os = "aero",
- target_os = "netbsd"
- ),
- feature = "time",
-@@ -82,7 +83,7 @@ pub(crate) mod timer {
- Interval(TimeSpec),
- }
-
-- #[cfg(any(target_os = "android", target_os = "linux"))]
-+ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))]
- bitflags! {
- /// Flags that are used for arming the timer.
- pub struct TimerSetTimeFlags: libc::c_int {
-diff --git a/src/sys/timerfd.rs b/src/sys/timerfd.rs
-index 18acbae..0005b24 100644
---- a/src/sys/timerfd.rs
-+++ b/src/sys/timerfd.rs
-@@ -57,7 +57,7 @@ impl FromRawFd for TimerFd {
- libc_enum! {
- /// The type of the clock used to mark the progress of the timer. For more
- /// details on each kind of clock, please refer to [timerfd_create(2)](https://man7.org/linux/man-pages/man2/timerfd_create.2.html).
-- #[repr(i32)]
-+ #[repr(i64)]
- #[non_exhaustive]
- pub enum ClockId {
- /// A settable system-wide real-time clock.
+ ECHOKE;
diff --git a/src/unistd.rs b/src/unistd.rs
-index d6ccdf1..af3b4a0 100644
+index d94cb99..8e26266 100644
--- a/src/unistd.rs
+++ b/src/unistd.rs
-@@ -1132,6 +1132,7 @@ feature! {
+@@ -1081,6 +1081,7 @@ pub fn pipe() -> std::result::Result<(RawFd, RawFd), Error> {
/// See also [pipe(2)](https://man7.org/linux/man-pages/man2/pipe.2.html)
#[cfg(any(target_os = "android",
target_os = "dragonfly",
@@ -811,7 +617,7 @@ index d6ccdf1..af3b4a0 100644
target_os = "emscripten",
target_os = "freebsd",
target_os = "illumos",
-@@ -1550,6 +1551,7 @@ pub fn getgroups() -> Result> {
+@@ -1478,6 +1479,7 @@ pub fn getgroups() -> Result> {
pub fn setgroups(groups: &[Gid]) -> Result<()> {
cfg_if! {
if #[cfg(any(target_os = "dragonfly",
@@ -819,7 +625,7 @@ index d6ccdf1..af3b4a0 100644
target_os = "freebsd",
target_os = "illumos",
target_os = "ios",
-@@ -1886,6 +1888,14 @@ feature! {
+@@ -1799,6 +1801,14 @@ pub fn mkstemp(template: &P) -> Result<(RawFd, PathBuf)> {
/// - [pathconf(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pathconf.html)
/// - [limits.h](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html)
/// - [unistd.h](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html)
@@ -833,8 +639,8 @@ index d6ccdf1..af3b4a0 100644
+#[cfg(not(target_os = "aero"))]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[repr(i32)]
- #[non_exhaustive]
-@@ -2082,6 +2092,17 @@ feature! {
+ pub enum PathconfVar {
+@@ -1978,6 +1988,17 @@ pub fn pathconf(path: &P, var: PathconfVar) -> Result for User {
- gid: Gid::from_raw(pw.pw_gid),
+@@ -2668,18 +2692,21 @@ impl From<&libc::passwd> for User {
+ gid: Gid::from_raw((*pw).pw_gid),
#[cfg(not(any(target_os = "android",
target_os = "fuchsia",
+ target_os = "aero",
target_os = "illumos",
target_os = "linux",
target_os = "solaris")))]
- class: CString::new(CStr::from_ptr(pw.pw_class).to_bytes()).unwrap(),
+ class: CString::new(CStr::from_ptr((*pw).pw_class).to_bytes()).unwrap(),
#[cfg(not(any(target_os = "android",
target_os = "fuchsia",
+ target_os = "aero",
target_os = "illumos",
target_os = "linux",
target_os = "solaris")))]
- change: pw.pw_change,
+ change: (*pw).pw_change,
#[cfg(not(any(target_os = "android",
target_os = "fuchsia",
+ target_os = "aero",
target_os = "illumos",
target_os = "linux",
target_os = "solaris")))]
-@@ -2960,18 +2987,21 @@ impl From for libc::passwd {
- pw_gid: u.gid.0,
- #[cfg(not(any(target_os = "android",
- target_os = "fuchsia",
-+ target_os = "aero",
- target_os = "illumos",
- target_os = "linux",
- target_os = "solaris")))]
- pw_class: u.class.into_raw(),
- #[cfg(not(any(target_os = "android",
- target_os = "fuchsia",
-+ target_os = "aero",
- target_os = "illumos",
- target_os = "linux",
- target_os = "solaris")))]
- pw_change: u.change,
- #[cfg(not(any(target_os = "android",
- target_os = "fuchsia",
-+ target_os = "aero",
- target_os = "illumos",
- target_os = "linux",
- target_os = "solaris")))]
--
-2.39.1
-
+2.38.1
diff --git a/patches/webkitgtk/webkitgtk.patch b/patches/webkitgtk/0001-Initial-Aero-support.patch
similarity index 95%
rename from patches/webkitgtk/webkitgtk.patch
rename to patches/webkitgtk/0001-Initial-Aero-support.patch
index f80e91ec667..82db1c0a73e 100644
--- a/patches/webkitgtk/webkitgtk.patch
+++ b/patches/webkitgtk/0001-Initial-Aero-support.patch
@@ -1,7 +1,7 @@
-From 9c3401a68d96016e19aafc60897ae450db07ead7 Mon Sep 17 00:00:00 2001
+From 610aa0dbb9c661c87172c0cf93de06efb019f80b Mon Sep 17 00:00:00 2001
From: Dennis Bonke
Date: Sun, 2 Jan 2022 00:19:17 +0100
-Subject: [PATCH] Initial Aero support
+Subject: [PATCH 1/2] Initial Aero support
Signed-off-by: Dennis Bonke
---
@@ -18,7 +18,7 @@ Signed-off-by: Dennis Bonke
10 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/Source/JavaScriptCore/heap/BlockDirectory.cpp b/Source/JavaScriptCore/heap/BlockDirectory.cpp
-index e2a3540f86..d58513333e 100644
+index e2a3540f86..8b14455772 100644
--- a/Source/JavaScriptCore/heap/BlockDirectory.cpp
+++ b/Source/JavaScriptCore/heap/BlockDirectory.cpp
@@ -60,7 +60,7 @@ void BlockDirectory::setSubspace(Subspace* subspace)
@@ -31,7 +31,7 @@ index e2a3540f86..d58513333e 100644
ASSERT(!(MarkedBlock::blockSize % pageSize));
auto numberOfPagesInMarkedBlock = MarkedBlock::blockSize / pageSize;
diff --git a/Source/JavaScriptCore/runtime/MachineContext.h b/Source/JavaScriptCore/runtime/MachineContext.h
-index 7857bfc167..c14fbb5b6c 100644
+index 7857bfc167..4e396fa853 100644
--- a/Source/JavaScriptCore/runtime/MachineContext.h
+++ b/Source/JavaScriptCore/runtime/MachineContext.h
@@ -346,7 +346,7 @@ static inline void*& framePointerImpl(mcontext_t& machineContext)
@@ -83,7 +83,7 @@ index e54387ef28..d159806731 100644
#include
#include
diff --git a/Source/ThirdParty/ANGLE/src/common/platform.h b/Source/ThirdParty/ANGLE/src/common/platform.h
-index 41f3cf4ff7..77c4a91f29 100644
+index 41f3cf4ff7..745e1f4a56 100644
--- a/Source/ThirdParty/ANGLE/src/common/platform.h
+++ b/Source/ThirdParty/ANGLE/src/common/platform.h
@@ -28,7 +28,7 @@
@@ -96,7 +96,7 @@ index 41f3cf4ff7..77c4a91f29 100644
#else
# error Unsupported platform.
diff --git a/Source/WTF/wtf/InlineASM.h b/Source/WTF/wtf/InlineASM.h
-index 8379a69659..8f7493769f 100644
+index 8379a69659..f2780b7947 100644
--- a/Source/WTF/wtf/InlineASM.h
+++ b/Source/WTF/wtf/InlineASM.h
@@ -43,11 +43,11 @@
@@ -132,7 +132,7 @@ index 8379a69659..8f7493769f 100644
// GNU as-compatible syntax.
#define LOCAL_LABEL_STRING(name) ".L" #name
diff --git a/Source/WTF/wtf/PlatformHave.h b/Source/WTF/wtf/PlatformHave.h
-index 61f13c2b73..de93124ef8 100644
+index 61f13c2b73..c4ff4a6252 100644
--- a/Source/WTF/wtf/PlatformHave.h
+++ b/Source/WTF/wtf/PlatformHave.h
@@ -226,7 +226,7 @@
@@ -154,7 +154,7 @@ index 61f13c2b73..de93124ef8 100644
#endif
diff --git a/Source/WTF/wtf/PlatformOS.h b/Source/WTF/wtf/PlatformOS.h
-index e61715fb72..ed72f251a9 100644
+index e61715fb72..28cf97f28f 100644
--- a/Source/WTF/wtf/PlatformOS.h
+++ b/Source/WTF/wtf/PlatformOS.h
@@ -118,6 +118,11 @@
@@ -202,7 +202,7 @@ index 743ef3dc84..3a61bc1dc3 100644
}
return SQLiteStatement { *this, sqlStatement.value() };
diff --git a/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp b/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp
-index efcd663f84..11e5467c10 100644
+index efcd663f84..81a425a037 100644
--- a/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp
+++ b/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp
@@ -46,7 +46,7 @@
@@ -215,7 +215,7 @@ index efcd663f84..11e5467c10 100644
#else
#if USE(GLIB)
diff --git a/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp b/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp
-index 998a2a7679..a490b3fb5f 100644
+index 998a2a7679..51c5d38573 100644
--- a/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp
+++ b/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp
@@ -47,8 +47,10 @@
@@ -239,5 +239,5 @@ index 998a2a7679..a490b3fb5f 100644
if (fileDescriptor != -1)
--
-2.40.0
+2.42.0
diff --git a/patches/webkitgtk/0002-xxx.patch b/patches/webkitgtk/0002-xxx.patch
new file mode 100644
index 00000000000..ae6402e7784
--- /dev/null
+++ b/patches/webkitgtk/0002-xxx.patch
@@ -0,0 +1,181 @@
+From 4a70595e159ee5cc7336ed10c78f7f34284506e1 Mon Sep 17 00:00:00 2001
+From: Anhad Singh
+Date: Sat, 14 Oct 2023 16:58:18 +1100
+Subject: [PATCH 2/2]
+
+Signed-off-by: Anhad Singh
+---
+ .../ANGLE/include/GLSLANG/ShaderVars.h | 1 +
+ Source/WTF/wtf/MallocPtr.h | 1 +
+ .../WTF/wtf/text/IntegerToStringConversion.h | 25 ++++++++++---------
+ .../WebCore/accessibility/AXObjectCache.cpp | 2 ++
+ .../graphics/BifurcatedGraphicsContext.cpp | 2 ++
+ .../platform/graphics/x11/XUniqueResource.h | 2 ++
+ 6 files changed, 21 insertions(+), 12 deletions(-)
+
+diff --git a/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderVars.h b/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderVars.h
+index 68dc7e2e32..e127de3373 100644
+--- a/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderVars.h
++++ b/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderVars.h
+@@ -14,6 +14,7 @@
+ #include
+ #include
+ #include
++#include
+
+ // This type is defined here to simplify ANGLE's integration with glslang for SPIRv.
+ using ShCompileOptions = uint64_t;
+diff --git a/Source/WTF/wtf/MallocPtr.h b/Source/WTF/wtf/MallocPtr.h
+index 2cbd861efd..57e8e66100 100644
+--- a/Source/WTF/wtf/MallocPtr.h
++++ b/Source/WTF/wtf/MallocPtr.h
+@@ -25,6 +25,7 @@
+
+ #pragma once
+
++#include
+ #include
+ #include
+
+diff --git a/Source/WTF/wtf/text/IntegerToStringConversion.h b/Source/WTF/wtf/text/IntegerToStringConversion.h
+index 03f5861c33..666e53e564 100644
+--- a/Source/WTF/wtf/text/IntegerToStringConversion.h
++++ b/Source/WTF/wtf/text/IntegerToStringConversion.h
+@@ -21,15 +21,17 @@
+
+ #pragma once
+
++#include
+ #include
+
+ namespace WTF {
+
+-enum PositiveOrNegativeNumber { PositiveNumber, NegativeNumber };
++enum PositiveOrNegativeNumber { PositiveNumber,
++ NegativeNumber };
+
+-template struct IntegerToStringConversionTrait;
++template struct IntegerToStringConversionTrait;
+
+-template
++template
+ static typename IntegerToStringConversionTrait::ReturnType numberToStringImpl(UnsignedIntegerType number, AdditionalArgumentType additionalArgument)
+ {
+ LChar buf[sizeof(UnsignedIntegerType) * 3 + 1];
+@@ -47,7 +49,7 @@ static typename IntegerToStringConversionTrait::ReturnType numberToStringImpl
+ return IntegerToStringConversionTrait::flush(p, static_cast(end - p), additionalArgument);
+ }
+
+-template
++template
+ inline typename IntegerToStringConversionTrait::ReturnType numberToStringSigned(SignedIntegerType number, typename IntegerToStringConversionTrait::AdditionalArgumentType* additionalArgument = nullptr)
+ {
+ if (number < 0)
+@@ -55,13 +57,13 @@ inline typename IntegerToStringConversionTrait::ReturnType numberToStringSign
+ return numberToStringImpl, PositiveNumber>(number, additionalArgument);
+ }
+
+-template
++template
+ inline typename IntegerToStringConversionTrait::ReturnType numberToStringUnsigned(UnsignedIntegerType number, typename IntegerToStringConversionTrait::AdditionalArgumentType* additionalArgument = nullptr)
+ {
+ return numberToStringImpl(number, additionalArgument);
+ }
+
+-template
++template
+ static void writeIntegerToBufferImpl(UnsignedIntegerType number, CharacterType* destination)
+ {
+ static_assert(!std::is_same_v>, "'bool' not supported");
+@@ -76,12 +78,12 @@ static void writeIntegerToBufferImpl(UnsignedIntegerType number, CharacterType*
+
+ if (NumberType == NegativeNumber)
+ *--p = '-';
+-
++
+ while (p < end)
+ *destination++ = static_cast(*p++);
+ }
+
+-template
++template
+ inline void writeIntegerToBuffer(IntegerType integer, CharacterType* destination)
+ {
+ static_assert(std::is_integral_v);
+@@ -95,7 +97,7 @@ inline void writeIntegerToBuffer(IntegerType integer, CharacterType* destination
+ return writeIntegerToBufferImpl(integer, destination);
+ }
+
+-template
++template
+ constexpr unsigned lengthOfIntegerAsStringImpl(UnsignedIntegerType number)
+ {
+ unsigned length = 0;
+@@ -111,15 +113,14 @@ constexpr unsigned lengthOfIntegerAsStringImpl(UnsignedIntegerType number)
+ return length;
+ }
+
+-template
++template
+ constexpr unsigned lengthOfIntegerAsString(IntegerType integer)
+ {
+ static_assert(std::is_integral_v);
+ if constexpr (std::is_same_v) {
+ UNUSED_PARAM(integer);
+ return 1;
+- }
+- else if constexpr (std::is_signed_v) {
++ } else if constexpr (std::is_signed_v) {
+ if (integer < 0)
+ return lengthOfIntegerAsStringImpl, NegativeNumber>(-integer);
+ return lengthOfIntegerAsStringImpl, PositiveNumber>(integer);
+diff --git a/Source/WebCore/accessibility/AXObjectCache.cpp b/Source/WebCore/accessibility/AXObjectCache.cpp
+index a7a867f60d..a08ce5078d 100644
+--- a/Source/WebCore/accessibility/AXObjectCache.cpp
++++ b/Source/WebCore/accessibility/AXObjectCache.cpp
+@@ -528,9 +528,11 @@ static bool isSimpleImage(const RenderObject& renderer)
+ || (is(node) && downcast(node)->hasAttributeWithoutSynchronization(usemapAttr)))
+ return false;
+
++#if ENABLE(VIDEO)
+ // Exclude video and audio elements.
+ if (is(node))
+ return false;
++#endif
+
+ return true;
+ }
+diff --git a/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp b/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp
+index c0ce72c5ff..a2a58df7eb 100644
+--- a/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp
++++ b/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp
+@@ -269,11 +269,13 @@ void BifurcatedGraphicsContext::drawPattern(NativeImage& nativeImage, const Floa
+ m_secondaryContext.drawPattern(nativeImage, imageSize, destRect, tileRect, patternTransform, phase, spacing, options);
+ }
+
++#if ENABLE(VIDEO)
+ void BifurcatedGraphicsContext::paintFrameForMedia(MediaPlayer& player, const FloatRect& destination)
+ {
+ m_primaryContext.paintFrameForMedia(player, destination);
+ m_secondaryContext.paintFrameForMedia(player, destination);
+ }
++#endif
+
+ void BifurcatedGraphicsContext::scale(const FloatSize& scale)
+ {
+diff --git a/Source/WebCore/platform/graphics/x11/XUniqueResource.h b/Source/WebCore/platform/graphics/x11/XUniqueResource.h
+index 0da8b0c9c0..9296efca23 100644
+--- a/Source/WebCore/platform/graphics/x11/XUniqueResource.h
++++ b/Source/WebCore/platform/graphics/x11/XUniqueResource.h
+@@ -26,6 +26,8 @@
+ #ifndef XUniqueResource_h
+ #define XUniqueResource_h
+
++#include
++
+ #if PLATFORM(X11)
+
+ #if USE(GLX)
+--
+2.42.0
+
diff --git a/src/aero_kernel/src/arch/x86_64/interrupts/exceptions.rs b/src/aero_kernel/src/arch/x86_64/interrupts/exceptions.rs
index 579e1d9c860..315d0f65105 100644
--- a/src/aero_kernel/src/arch/x86_64/interrupts/exceptions.rs
+++ b/src/aero_kernel/src/arch/x86_64/interrupts/exceptions.rs
@@ -33,7 +33,24 @@ macro interrupt_exception(fn $name:ident() => $message:expr) {
unwind::prepare_panic();
log::error!("EXCEPTION: {}", $message);
+ log::error!("FS={:#x}", unsafe { io::rdmsr(io::IA32_FS_BASE) },);
+ log::error!("GS={:#x}", unsafe { io::rdmsr(io::IA32_GS_BASE) });
log::error!("Stack: {:#x?}", stack);
+ dbg!(
+ scheduler::get_scheduler()
+ .current_task()
+ .arch_task()
+ .fpu_storage
+ );
+
+ if stack.stack.iret.rip != 0 {
+ unsafe {
+ log::error!(
+ "RIP={:?}",
+ core::slice::from_raw_parts(stack.stack.iret.rip as *const u8, 512)
+ );
+ }
+ }
unwind::unwind_stack_trace();
diff --git a/src/aero_kernel/src/arch/x86_64/mod.rs b/src/aero_kernel/src/arch/x86_64/mod.rs
index b864b6269c7..d66038d474c 100644
--- a/src/aero_kernel/src/arch/x86_64/mod.rs
+++ b/src/aero_kernel/src/arch/x86_64/mod.rs
@@ -247,7 +247,9 @@ fn enable_xsave() {
unsafe { controlregs::write_cr4(cr4) }
let mut xcr0 = controlregs::read_xcr0();
- xcr0.insert(XCr0Flags::X87 | XCr0Flags::SSE);
+ xcr0.insert(XCr0Flags::X87 | XCr0Flags::SSE | XCr0Flags::AVX);
+ // xcr0.insert(XCr0Flags::BNDREG | XCr0Flags::BNDCSR);
+ // xcr0.insert(XCr0Flags::ZMM_HI256 | XCr0Flags::HI16_ZMM | XCr0Flags::OPMASK);
unsafe { controlregs::write_xcr0(xcr0) }
}
diff --git a/src/aero_kernel/src/arch/x86_64/task.rs b/src/aero_kernel/src/arch/x86_64/task.rs
index f6370fdbca8..c2aa7bfa6a5 100644
--- a/src/aero_kernel/src/arch/x86_64/task.rs
+++ b/src/aero_kernel/src/arch/x86_64/task.rs
@@ -126,7 +126,7 @@ pub struct ArchTask {
fs_base: VirtAddr,
gs_base: VirtAddr,
- fpu_storage: Option>,
+ pub fpu_storage: Option,
}
impl ArchTask {
@@ -212,14 +212,15 @@ impl ArchTask {
let old_registers_frame = unsafe { old_stack.offset::() };
let registers_frame = unsafe { new_stack.offset::() };
- *registers_frame = InterruptErrorStack::default();
+ *registers_frame = *old_registers_frame;
- registers_frame.stack.iret.cs = old_registers_frame.stack.iret.cs;
- registers_frame.stack.iret.ss = old_registers_frame.stack.iret.ss;
+ // registers_frame.stack.iret.cs = old_registers_frame.stack.iret.cs;
+ // registers_frame.stack.iret.ss = old_registers_frame.stack.iret.ss;
+ // registers_frame.stack.iret.rflags = old_registers_frame.stack.iret.rflags;
registers_frame.stack.iret.rip = entry as _;
registers_frame.stack.iret.rsp = usr_stack as _;
- registers_frame.stack.iret.rflags = 0x200;
+ // registers_frame.stack.iret.rflags = 0x200;
let context = unsafe { new_stack.offset::() };
@@ -231,8 +232,7 @@ impl ArchTask {
context.rip = fork_init as _;
context.cr3 = address_space.cr3().start_address().as_u64();
- let mut fpu_storage = alloc_boxed_buffer::(xsave_size() as usize);
- fpu_storage.copy_from_slice(self.fpu_storage.as_ref().unwrap());
+ let mut fpu_storage = self.fpu_storage.unwrap().clone();
Ok(Self {
context: unsafe { Unique::new_unchecked(context) },
@@ -241,7 +241,7 @@ impl ArchTask {
user: true,
// The FS and GS bases are inherited from the parent process.
- fs_base: self.fs_base,
+ fs_base: VirtAddr::new(1),
gs_base: self.gs_base,
fpu_storage: Some(fpu_storage),
@@ -287,8 +287,7 @@ impl ArchTask {
context.rip = fork_init as u64;
context.cr3 = new_address_space.cr3().start_address().as_u64();
- let mut fpu_storage = alloc_boxed_buffer::(xsave_size() as usize);
- fpu_storage.copy_from_slice(self.fpu_storage.as_ref().unwrap());
+ let fpu_storage = self.fpu_storage.unwrap().clone();
Ok(Self {
context: unsafe { Unique::new_unchecked(context) },
@@ -344,30 +343,30 @@ impl ArchTask {
self.fs_base = VirtAddr::zero();
self.gs_base = VirtAddr::zero();
- let mut fpu_storage = alloc_boxed_buffer::(xsave_size() as usize);
-
- unsafe {
- xrstor(&fpu_storage);
-
- // The x87 FPU control word is set to 0x37f (default), which masks all
- // floating-point exceptions, sets rounding to nearest, and sets the x87
- // FPU precision to 64 bits (as documented in Intel SDM volume 1 section
- // 8.1.5).
- const DEFAULT_FPU_CWORD: u16 = 0x37f;
- asm!("fldcw [{}]", in(reg) &DEFAULT_FPU_CWORD, options(nomem));
-
- // Set the default MXCSR value at reset as documented in Intel SDM volume 2A.
- controlregs::write_mxcsr(
- MxCsr::INVALID_OPERATION_MASK
- | MxCsr::DENORMAL_MASK
- | MxCsr::DIVIDE_BY_ZERO_MASK
- | MxCsr::OVERFLOW_MASK
- | MxCsr::UNDERFLOW_MASK
- | MxCsr::PRECISION_MASK,
- );
-
- xsave(&mut fpu_storage);
- }
+ let mut fpu_storage = FpuState::default();
+
+ // unsafe {
+ // xrstor(&fpu_storage);
+
+ // // The x87 FPU control word is set to 0x37f (default), which masks all
+ // // floating-point exceptions, sets rounding to nearest, and sets the x87
+ // // FPU precision to 64 bits (as documented in Intel SDM volume 1 section
+ // // 8.1.5).
+ // const DEFAULT_FPU_CWORD: u16 = 0x37f;
+ // asm!("fldcw [{}]", in(reg) &DEFAULT_FPU_CWORD, options(nomem));
+
+ // // Set the default MXCSR value at reset as documented in Intel SDM volume 2A.
+ // controlregs::write_mxcsr(
+ // MxCsr::INVALID_OPERATION_MASK
+ // | MxCsr::DENORMAL_MASK
+ // | MxCsr::DIVIDE_BY_ZERO_MASK
+ // | MxCsr::OVERFLOW_MASK
+ // | MxCsr::UNDERFLOW_MASK
+ // | MxCsr::PRECISION_MASK,
+ // );
+
+ // xsave(&mut fpu_storage);
+ // }
self.fpu_storage = Some(fpu_storage);
@@ -446,11 +445,9 @@ impl ArchTask {
/// Allocates a new context switch stack for the process and returns the stack
/// top address. See the module level documentation for more information.
fn alloc_switch_stack() -> Result> {
- let frame: PhysFrame = FRAME_ALLOCATOR
- .allocate_frame()
- .ok_or(MapToError::FrameAllocationFailed)?;
+ let frame = FRAME_ALLOCATOR.alloc_zeroed(4096 * 4).unwrap();
- Ok(frame.start_address().as_hhdm_virt() + Size4KiB::SIZE)
+ Ok(frame.as_hhdm_virt() + (4096u64 * 4))
}
fn unref_pt(&mut self) {
@@ -500,6 +497,7 @@ impl ArchTask {
/// belongs to. This is required since we also update the GS base register with the
/// `base` immediately (not waiting for a switch).
pub unsafe fn set_gs_base(&mut self, base: VirtAddr) {
+ self.gs_base = base;
io::set_inactive_gsbase(base);
}
@@ -515,13 +513,14 @@ impl ArchTask {
/// belongs to. This is required since we also update the FS base register with the
/// `base` immediately (not waiting for a switch).
pub unsafe fn set_fs_base(&mut self, base: VirtAddr) {
+ self.fs_base = base;
io::set_fsbase(base);
}
}
fn xsave_size() -> u32 {
- static XSAVE_SIZE: Option = None;
- XSAVE_SIZE.unwrap_or_else(|| {
+ static XSAVE_SIZE: spin::Once = spin::Once::new();
+ *XSAVE_SIZE.call_once(|| {
CpuId::new()
.get_extended_state_info()
.expect("xsave: cpuid extended state info unavailable")
@@ -529,18 +528,91 @@ fn xsave_size() -> u32 {
})
}
-fn xsave(fpu: &mut Box<[u8]>) {
- unsafe {
- asm!("xsave [{}]", in(reg) fpu.as_ptr(), in("eax") 0xffffffffu32, in("edx") 0xffffffffu32)
- }
+#[derive(Debug, Copy, Clone)]
+#[repr(C, align(16))]
+pub struct FpuState {
+ /// x87 FPU Control Word (16 bits). See Figure 8-6 in the Intel® 64 and IA-32 Architectures
+ /// Software Developer’s Manual Volume 1, for the layout of the x87 FPU control word.
+ pub fcw: u16,
+ /// x87 FPU Status Word (16 bits).
+ pub fsw: u16,
+ /// x87 FPU Tag Word (8 bits) + reserved (8 bits).
+ pub ftw: u16,
+ /// x87 FPU Opcode (16 bits).
+ pub fop: u16,
+ /// x87 FPU Instruction Pointer Offset ([31:0]). The contents of this field differ depending on
+ /// the current addressing mode (32-bit, 16-bit, or 64-bit) of the processor when the
+ /// FXSAVE instruction was executed: 32-bit mode — 32-bit IP offset. 16-bit mode — low 16
+ /// bits are IP offset; high 16 bits are reserved. 64-bit mode with REX.W — 64-bit IP
+ /// offset. 64-bit mode without REX.W — 32-bit IP offset.
+ pub fip: u32,
+ /// x87 FPU Instruction Pointer Selector (16 bits) + reserved (16 bits).
+ pub fcs: u32,
+ /// x87 FPU Instruction Operand (Data) Pointer Offset ([31:0]). The contents of this field
+ /// differ depending on the current addressing mode (32-bit, 16-bit, or 64-bit) of the
+ /// processor when the FXSAVE instruction was executed: 32-bit mode — 32-bit DP offset.
+ /// 16-bit mode — low 16 bits are DP offset; high 16 bits are reserved. 64-bit mode
+ /// with REX.W — 64-bit DP offset. 64-bit mode without REX.W — 32-bit DP offset.
+ pub fdp: u32,
+ /// x87 FPU Instruction Operand (Data) Pointer Selector (16 bits) + reserved.
+ pub fds: u32,
+ /// MXCSR Register State (32 bits).
+ pub mxcsr: u32,
+ /// This mask can be used to adjust values written to the MXCSR register, ensuring that
+ /// reserved bits are set to 0. Set the mask bits and flags in MXCSR to the mode of
+ /// operation desired for SSE and SSE2 SIMD floating-point instructions.
+ pub mxcsr_mask: u32,
+ /// x87 FPU or MMX technology registers. Layout: [12 .. 9 | 9 ... 0] LHS = reserved; RHS = mm.
+ pub mm: [u128; 8],
+ /// XMM registers (128 bits per field).
+ pub xmm: [u128; 16],
+ /// reserved.
+ pub _pad: [u64; 12],
}
-fn xrstor(fpu: &Box<[u8]>) {
- unsafe {
- asm!("xrstor [{}]", in(reg) fpu.as_ptr(), in("eax") 0xffffffffu32, in("edx") 0xffffffffu32);
+impl Default for FpuState {
+ fn default() -> Self {
+ Self {
+ mxcsr: 0x1f80,
+ mxcsr_mask: 0x037f,
+ // rest are zeroed
+ fcw: 0,
+ fsw: 0,
+ ftw: 0,
+ fop: 0,
+ fip: 0,
+ fcs: 0,
+ fdp: 0,
+ fds: 0,
+ mm: [0; 8],
+ xmm: [u128::MAX; 16],
+ _pad: [0; 12],
+ }
}
}
+fn xsave(fpu: &mut FpuState) {
+ // The implicit EDX:EAX register pair specifies a 64-bit instruction mask. The specific state
+ // components saved correspond to the bits set in the requested-feature bitmap (RFBM), which is
+ // the logical-AND of EDX:EAX and XCR0.
+ // unsafe {
+ // asm!("xsave64 [{}]", in(reg) fpu.as_ptr(), in("eax") u32::MAX, in("edx") u32::MAX,
+ // options(nomem, nostack)) }
+
+ use core::arch::x86_64::_fxsave64;
+
+ unsafe { _fxsave64(fpu as *mut FpuState as *mut _) }
+}
+
+fn xrstor(fpu: &FpuState) {
+ // unsafe {
+ // asm!("xrstor [{}]", in(reg) fpu.as_ptr(), in("eax") u32::MAX, in("edx") u32::MAX,
+ // options(nomem, nostack)); }
+ use core::arch::x86_64::_fxrstor64;
+
+ unsafe { _fxrstor64(fpu as *const FpuState as *const _) }
+}
+
/// Check out the module level documentation for more information.
pub fn arch_task_spinup(from: &mut ArchTask, to: &ArchTask) {
extern "C" {
@@ -548,6 +620,14 @@ pub fn arch_task_spinup(from: &mut ArchTask, to: &ArchTask) {
}
unsafe {
+ if let Some(fpu) = from.fpu_storage.as_mut() {
+ xsave(fpu);
+ }
+
+ if let Some(fpu) = to.fpu_storage.as_ref() {
+ xrstor(fpu);
+ }
+
// Load the new thread's kernel stack pointer everywhere it's needed.
let kstackp = to.context_switch_rsp.as_u64();
super::gdt::TSS.rsp[0] = kstackp;
@@ -560,14 +640,6 @@ pub fn arch_task_spinup(from: &mut ArchTask, to: &ArchTask) {
io::set_fsbase(to.fs_base);
io::set_inactive_gsbase(to.gs_base);
- if let Some(fpu) = from.fpu_storage.as_mut() {
- xsave(fpu);
- }
-
- if let Some(fpu) = to.fpu_storage.as_ref() {
- xrstor(fpu);
- }
-
task_spinup(&mut from.context, to.context.as_ref());
}
}
diff --git a/src/aero_kernel/src/mem/mod.rs b/src/aero_kernel/src/mem/mod.rs
index 41f68d04780..ba75081a434 100644
--- a/src/aero_kernel/src/mem/mod.rs
+++ b/src/aero_kernel/src/mem/mod.rs
@@ -128,13 +128,5 @@ impl AddressSpace {
}
pub fn alloc_boxed_buffer(size: usize) -> Box<[T]> {
- if size == 0 {
- return >::default();
- }
-
- let layout = unsafe { Layout::from_size_align_unchecked(size, 8) };
- let ptr = unsafe { ::alloc::alloc::alloc_zeroed(layout) as *mut T };
- let slice_ptr = core::ptr::slice_from_raw_parts_mut(ptr, size);
-
- unsafe { Box::from_raw(slice_ptr) }
+ unsafe { Box::new_zeroed_slice(size).assume_init() }
}
diff --git a/src/aero_kernel/src/mem/paging/mapper.rs b/src/aero_kernel/src/mem/paging/mapper.rs
index 169a01bd093..aa36e7eabe5 100644
--- a/src/aero_kernel/src/mem/paging/mapper.rs
+++ b/src/aero_kernel/src/mem/paging/mapper.rs
@@ -1190,10 +1190,10 @@ impl<'a> OffsetPageTable<'a> {
let mut flags = entry.flags();
// Check if the mapping is shared.
- if !flags.contains(PageTableFlags::BIT_10) {
- // Setup copy on write page.
- flags.remove(PageTableFlags::WRITABLE);
- }
+ // if !flags.contains(PageTableFlags::BIT_10) {
+ // Setup copy on write page.
+ flags.remove(PageTableFlags::WRITABLE);
+ // }
entry.set_flags(flags);
n1[i].set_frame(entry.frame().unwrap(), flags);
diff --git a/src/aero_kernel/src/syscall/process.rs b/src/aero_kernel/src/syscall/process.rs
index 8b76e1fc5c0..826c8667dd1 100644
--- a/src/aero_kernel/src/syscall/process.rs
+++ b/src/aero_kernel/src/syscall/process.rs
@@ -61,7 +61,8 @@ pub fn uname(buffer: &mut Utsname) -> Result {
let init_bytes = init.as_bytes();
let len = init.len();
- fixed[..len].copy_from_slice(init_bytes)
+ fixed[..len].copy_from_slice(init_bytes);
+ fixed[len..].fill(0);
}
init_array(&mut buffer.sysname, "Aero");
@@ -103,6 +104,8 @@ pub fn clone(entry: usize, stack: usize) -> Result {
pub fn kill(pid: usize, signal: usize) -> Result {
// If pid is positive, then signal is sent to the process with that pid.
if pid > 0 {
+ crate::unwind::unwind_stack_trace();
+
let task = scheduler::get_scheduler()
.find_task(TaskId::new(pid))
.ok_or(SyscallError::ESRCH)?;
diff --git a/src/aero_kernel/src/userland/task/mod.rs b/src/aero_kernel/src/userland/task/mod.rs
index b0ffb6db0f1..a2387ff7d22 100644
--- a/src/aero_kernel/src/userland/task/mod.rs
+++ b/src/aero_kernel/src/userland/task/mod.rs
@@ -400,6 +400,7 @@ impl Task {
pending_io: AtomicBool::new(false),
children: Mutex::new(Default::default()),
+ // sus? fixme?
parent: Mutex::new(None),
cwd: RwLock::new(Some(self.cwd.read().as_ref().unwrap().fork())),
diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs
index 7fe895cc29a..1da5b1f0325 100644
--- a/src/aero_kernel/src/userland/vm.rs
+++ b/src/aero_kernel/src/userland/vm.rs
@@ -436,9 +436,9 @@ impl Mapping {
| PageTableFlags::USER_ACCESSIBLE
| self.protection.into();
- if self.flags.contains(MMapFlags::MAP_SHARED) {
- flags |= PageTableFlags::BIT_10;
- }
+ // if self.flags.contains(MMapFlags::MAP_SHARED) {
+ // flags |= PageTableFlags::BIT_10;
+ // }
unsafe { offset_table.map_to(Page::containing_address(address), frame, flags) }
.expect("failed to map allocated frame for private file read")
@@ -784,45 +784,47 @@ impl VmProtected {
) -> Option {
// Offset is required to be a multiple of page size.
if (offset as u64 & (Size4KiB::SIZE - 1)) != 0 {
+ log::warn!("mmap: offset is not a multiple of page size");
return None;
}
// The provided size should be non-zero.
if size == 0 {
+ log::warn!("mmap: size is zero");
return None;
}
if file.is_some() {
- // SAFETY: We cannot mmap a file with the anonymous flag.
if flags.contains(MMapFlags::MAP_ANONYOMUS) {
+ log::warn!("mmap: cannot map a file with the anonymous flag");
return None;
}
} else {
- // SAFETY: Mappings not backed by a file must be anonymous.
if !flags.contains(MMapFlags::MAP_ANONYOMUS) {
+ log::warn!("mmap: mappings not backed by a file cannot be anonymous");
return None;
}
- // SAFETY: We cannot have a shared and an anonymous mapping.
if flags.contains(MMapFlags::MAP_SHARED) {
+ log::warn!("mmap: anonymous mappings cannot be shared");
return None;
}
}
let size_aligned = align_up(size as _, Size4KiB::SIZE);
- if address == VirtAddr::zero() {
+ let x = if address == VirtAddr::zero() {
// We need to find a free mapping above 0x7000_0000_0000.
self.find_any_above(VirtAddr::new(0x7000_0000_0000), size_aligned as _)
} else if flags.contains(MMapFlags::MAP_FIXED) {
// SAFETY: The provided address should be page aligned.
if !address.is_aligned(Size4KiB::SIZE) {
+ log::warn!("mmap: fixed mapping address is not page aligned");
return None;
}
- // SAFETY: The provided (address + size) should be less then
- // the userland max address.
if (address + size_aligned) > userland_last_address() {
+ log::warn!("mmap: fixed mapping address is out of range");
return None;
}
@@ -857,7 +859,38 @@ impl VmProtected {
});
addr
- })
+ });
+
+ if x.is_none() {
+ log::warn!("mmap failed");
+ self.log();
+ }
+
+ x
+ }
+
+ fn log(&self) {
+ for mmap in &self.mappings {
+ if let Some(file) = mmap.file.as_ref() {
+ log::debug!(
+ "{:?}..{:?} => {:?}, {:?} (offset={:#x}, size={:#x})",
+ mmap.start_addr,
+ mmap.end_addr,
+ mmap.protection,
+ mmap.flags,
+ file.offset,
+ file.size,
+ );
+ } else {
+ log::debug!(
+ "{:?}..{:?} => {:?}, {:?}",
+ mmap.start_addr,
+ mmap.end_addr,
+ mmap.protection,
+ mmap.flags,
+ );
+ }
+ }
}
fn load_bin<'header>(
diff --git a/tools/cargo-inject-patches.py b/tools/cargo-inject-patches.py
index 7d046383d9d..18be0cf7d05 100644
--- a/tools/cargo-inject-patches.py
+++ b/tools/cargo-inject-patches.py
@@ -11,7 +11,7 @@
"calloop": "0.9.3",
"libc": "0.2.149",
"getrandom": "0.2.9",
- "libloading": "0.8.1",
+ "libloading": "0.7.3",
"mio": ["0.6.23", "0.8.3"],
"nix": "0.24.3",
"num_cpus": "1.15.0",
diff --git a/userland/apps/init/src/main.rs b/userland/apps/init/src/main.rs
index fc30f33b071..ecbaef5d8c2 100644
--- a/userland/apps/init/src/main.rs
+++ b/userland/apps/init/src/main.rs
@@ -53,21 +53,21 @@ fn main() -> Result<(), Box> {
let stdout = OpenOptions::new().write(true).open(TTY_PATH)?; // fd=1
let stderr = OpenOptions::new().write(true).open(TTY_PATH)?; // fd=2
- // {
- let stdset = FileSet::new([stdin, stdout, stderr]);
- stdset.remove_cloexec();
+ {
+ let stdset = FileSet::new([stdin, stdout, stderr]);
+ stdset.remove_cloexec();
- Command::new("dhcpd").spawn()?;
- // }
+ Command::new("dhcpd").spawn()?;
+ }
- // // Swap the `/dev/tty` std{in,out,err} file descriptors with `/dev/null` to suppress the Xorg
- // // server logs.
- // let stdin = OpenOptions::new().read(true).open(DEV_NULL)?; // fd=0
- // let stdout = OpenOptions::new().write(true).open(DEV_NULL)?; // fd=1
- // let stderr = OpenOptions::new().write(true).open(DEV_NULL)?; // fd=2
+ // Swap the `/dev/tty` std{in,out,err} file descriptors with `/dev/null` to suppress the Xorg
+ // server logs.
+ let stdin = OpenOptions::new().read(true).open(DEV_NULL)?; // fd=0
+ let stdout = OpenOptions::new().write(true).open(DEV_NULL)?; // fd=1
+ let stderr = OpenOptions::new().write(true).open(DEV_NULL)?; // fd=2
- // let stdset = FileSet::new([stdin, stdout, stderr]);
- // stdset.remove_cloexec();
+ let stdset = FileSet::new([stdin, stdout, stderr]);
+ stdset.remove_cloexec();
Command::new("startx")
.env("RUST_BACKTRACE", "full")
From 2b30079096dca239bab670ac5ead764c88e70200 Mon Sep 17 00:00:00 2001
From: Anhad Singh
Date: Thu, 19 Oct 2023 21:56:46 +1100
Subject: [PATCH 009/112] feat(bootstrap): upgrade llvm to 17.0.3
* Upgrade LLVM to 17.0.3
* Build LLVM, clang and clang-tools-extra
Signed-off-by: Anhad Singh
---
bootstrap.yml | 6 +-
...patch => 0001-feat-targets-add-aero.patch} | 343 ++++++++----------
2 files changed, 163 insertions(+), 186 deletions(-)
rename patches/llvm/{llvm.patch => 0001-feat-targets-add-aero.patch} (82%)
diff --git a/bootstrap.yml b/bootstrap.yml
index 90ef0bb5961..5754cdc09d2 100644
--- a/bootstrap.yml
+++ b/bootstrap.yml
@@ -80,8 +80,8 @@ sources:
- name: llvm
subdir: 'bundled'
git: 'https://github.com/llvm/llvm-project.git'
- tag: 'llvmorg-14.0.1'
- version: '14.0.1'
+ tag: 'llvmorg-17.0.3'
+ version: '17.0.3'
- name: glib
subdir: 'bundled'
@@ -595,7 +595,7 @@ tools:
# Building it in debug mode produces tens of GiB of debugging info.
- '-DCMAKE_BUILD_TYPE=Release'
- '-DLLVM_TARGETS_TO_BUILD=X86'
- - '-DLLVM_ENABLE_PROJECTS=llvm'
+ - '-DLLVM_ENABLE_PROJECTS=llvm;clang;clang-tools-extra'
- '-DLLVM_ENABLE_Z3_SOLVER=OFF'
# clang configuration options.
- '-DDEFAULT_SYSROOT=@SYSROOT_DIR@'
diff --git a/patches/llvm/llvm.patch b/patches/llvm/0001-feat-targets-add-aero.patch
similarity index 82%
rename from patches/llvm/llvm.patch
rename to patches/llvm/0001-feat-targets-add-aero.patch
index 17987cb2a11..d765ad6c9e7 100644
--- a/patches/llvm/llvm.patch
+++ b/patches/llvm/0001-feat-targets-add-aero.patch
@@ -1,66 +1,69 @@
-From 20cff6e42171169bd1b78d7ccffec0ab608e1eaa Mon Sep 17 00:00:00 2001
-From: Andy-Python-Programmer
-Date: Thu, 16 Feb 2023 17:54:52 +1100
-Subject: [PATCH] targets: add aero
+From bc36fc2f014463a6baa37512c708bca46dbd55c5 Mon Sep 17 00:00:00 2001
+From: Anhad Singh
+Date: Thu, 19 Oct 2023 21:54:42 +1100
+Subject: [PATCH] feat(targets): add aero
-Signed-off-by: Andy-Python-Programmer
+Signed-off-by: Anhad Singh
---
- clang/lib/Basic/Targets.cpp | 6 +
- clang/lib/Basic/Targets/OSTargets.h | 28 ++
+ clang/lib/Basic/Targets.cpp | 10 +
+ clang/lib/Basic/Targets/OSTargets.h | 31 ++
clang/lib/Driver/CMakeLists.txt | 1 +
clang/lib/Driver/Driver.cpp | 4 +
- clang/lib/Driver/ToolChains/Aero.cpp | 438 ++++++++++++++++++++++
+ clang/lib/Driver/ToolChains/Aero.cpp | 432 ++++++++++++++++++++++
clang/lib/Driver/ToolChains/Aero.h | 49 +++
clang/lib/Driver/ToolChains/Gnu.cpp | 13 +-
llvm/cmake/modules/CrossCompile.cmake | 4 +-
- llvm/include/llvm/ADT/Triple.h | 5 +-
llvm/include/llvm/Support/SwapByteOrder.h | 2 +-
- llvm/lib/Support/Triple.cpp | 6 +
+ llvm/include/llvm/TargetParser/Triple.h | 5 +-
llvm/lib/Support/Unix/Path.inc | 6 +-
llvm/lib/Support/Unix/Program.inc | 1 +
- llvm/tools/llvm-dwarfdump/Statistics.cpp | 2 +
+ llvm/lib/TargetParser/Triple.cpp | 6 +
llvm/tools/llvm-shlib/CMakeLists.txt | 1 +
- 15 files changed, 556 insertions(+), 10 deletions(-)
+ 14 files changed, 555 insertions(+), 10 deletions(-)
create mode 100644 clang/lib/Driver/ToolChains/Aero.cpp
create mode 100644 clang/lib/Driver/ToolChains/Aero.h
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
-index 994a491cdd..098b0d5fb7 100644
+index 636b59fd1..9e1e08ec5 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
-@@ -149,6 +149,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
- return new NetBSDTargetInfo(Triple, Opts);
- case llvm::Triple::OpenBSD:
- return new OpenBSDTargetInfo(Triple, Opts);
+@@ -151,6 +151,10 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple,
+ case llvm::Triple::Fuchsia:
+ return std::make_unique>(Triple,
+ Opts);
+ case llvm::Triple::Aero:
-+ return new AeroTargetInfo(Triple, Opts);
- case llvm::Triple::Win32:
- switch (Triple.getEnvironment()) {
- case llvm::Triple::GNU:
-@@ -420,6 +422,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
- return new FuchsiaTargetInfo(Triple, Opts);
++ return std::make_unique>(Triple,
++ Opts);
++
case llvm::Triple::Linux:
- return new LinuxTargetInfo(Triple, Opts);
+ switch (Triple.getEnvironment()) {
+ default:
+@@ -455,6 +459,9 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple,
+ case llvm::Triple::Fuchsia:
+ return std::make_unique>(Triple,
+ Opts);
+ case llvm::Triple::Aero:
-+ return new AeroTargetInfo(Triple, Opts);
- default:
- return new RISCV64TargetInfo(Triple, Opts);
- }
-@@ -586,6 +590,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
- }
- case llvm::Triple::Haiku:
- return new HaikuTargetInfo(Triple, Opts);
++ return std::make_unique>(Triple,
++ Opts);
+ case llvm::Triple::Linux:
+ switch (Triple.getEnvironment()) {
+ default:
+@@ -636,6 +643,9 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple,
+ case llvm::Triple::Fuchsia:
+ return std::make_unique>(Triple,
+ Opts);
+ case llvm::Triple::Aero:
-+ return new AeroTargetInfo(Triple, Opts);
- case llvm::Triple::NaCl:
- return new NaClTargetInfo(Triple, Opts);
- case llvm::Triple::PS4:
++ return std::make_unique>(Triple,
++ Opts);
+ case llvm::Triple::KFreeBSD:
+ return std::make_unique>(Triple,
+ Opts);
diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h
-index 3c1830d5f8..2123019378 100644
+index 8f4331b02..bacb1e071 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
-@@ -338,6 +338,34 @@ public:
- : OSTargetInfo(Triple, Opts) {}
+@@ -278,6 +278,37 @@ public:
+ using OSTargetInfo::OSTargetInfo;
};
+// Aero Target
@@ -75,6 +78,8 @@ index 3c1830d5f8..2123019378 100644
+ Builder.defineMacro("_REENTRANT");
+ if (Opts.CPlusPlus)
+ Builder.defineMacro("_GNU_SOURCE");
++ // if (this->HasFloat128)
++ // Builder.defineMacro("__FLOAT128__");
+ }
+
+public:
@@ -91,34 +96,35 @@ index 3c1830d5f8..2123019378 100644
+ }
+};
+
- // Minix Target
++
+ // Haiku Target
template
- class LLVM_LIBRARY_VISIBILITY MinixTargetInfo : public OSTargetInfo {
+ class LLVM_LIBRARY_VISIBILITY HaikuTargetInfo : public OSTargetInfo {
diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
-index 78e8fd1852..8a53a0a7ab 100644
+index a6bd2d41e..132da8bbe 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -59,6 +59,7 @@ add_clang_library(clangDriver
- ToolChains/Hexagon.cpp
- ToolChains/Hurd.cpp
- ToolChains/Linux.cpp
+ ToolChains/Flang.cpp
+ ToolChains/FreeBSD.cpp
+ ToolChains/Fuchsia.cpp
+ ToolChains/Aero.cpp
- ToolChains/MipsLinux.cpp
- ToolChains/MinGW.cpp
- ToolChains/Minix.cpp
+ ToolChains/Gnu.cpp
+ ToolChains/Haiku.cpp
+ ToolChains/HIPUtility.cpp
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
-index 3bfddeefc7..9773e5efd1 100644
+index bdbdad936..bc194b1f5 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
-@@ -30,6 +30,7 @@
- #include "ToolChains/Hurd.h"
- #include "ToolChains/Lanai.h"
- #include "ToolChains/Linux.h"
+@@ -24,6 +24,7 @@
+ #include "ToolChains/DragonFly.h"
+ #include "ToolChains/FreeBSD.h"
+ #include "ToolChains/Fuchsia.h"
+#include "ToolChains/Aero.h"
- #include "ToolChains/MSP430.h"
- #include "ToolChains/MSVC.h"
- #include "ToolChains/MinGW.h"
-@@ -5564,6 +5565,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
+ #include "ToolChains/Gnu.h"
+ #include "ToolChains/HIPAMD.h"
+ #include "ToolChains/HIPSPV.h"
+@@ -6225,6 +6226,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
case llvm::Triple::Fuchsia:
TC = std::make_unique(*this, Target, Args);
break;
@@ -130,10 +136,10 @@ index 3bfddeefc7..9773e5efd1 100644
break;
diff --git a/clang/lib/Driver/ToolChains/Aero.cpp b/clang/lib/Driver/ToolChains/Aero.cpp
new file mode 100644
-index 0000000000..4cd7765aeb
+index 000000000..580d85cde
--- /dev/null
+++ b/clang/lib/Driver/ToolChains/Aero.cpp
-@@ -0,0 +1,438 @@
+@@ -0,0 +1,432 @@
+//===--- Aero.h - Aero ToolChain Implementations --------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
@@ -247,13 +253,13 @@ index 0000000000..4cd7765aeb
+ // to the link paths.
+ path_list &Paths = getFilePaths();
+
-+ const std::string OSLibDir = getOSLibDir(Triple, Args);
++ const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
+ const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
+
+ // Add the multilib suffixed paths where they are available.
+ if (GCCInstallation.isValid()) {
+ const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
-+ const std::string &LibPath = GCCInstallation.getParentLibPath();
++ const std::string &LibPath = std::string(GCCInstallation.getParentLibPath());
+ const Multilib &Multilib = GCCInstallation.getMultilib();
+ const MultilibSet &Multilibs = GCCInstallation.getMultilibs();
+
@@ -336,7 +342,7 @@ index 0000000000..4cd7765aeb
+
+ // See comments above on the multilib variant for details of why this is
+ // included even from outside the sysroot.
-+ const std::string &LibPath = GCCInstallation.getParentLibPath();
++ const std::string &LibPath = std::string(GCCInstallation.getParentLibPath());
+ const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
+ const Multilib &Multilib = GCCInstallation.getMultilib();
+ addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib" +
@@ -495,11 +501,9 @@ index 0000000000..4cd7765aeb
+ getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot);
+ const GCCVersion &Version = GCCInstallation.getVersion();
+
-+ // The primary search for libstdc++ supports multiarch variants.
-+ if (addLibStdCXXIncludePaths(LibDir.str() + "/../include",
-+ "/c++/" + Version.Text, TripleStr,
-+ GCCMultiarchTriple, TargetMultiarchTriple,
-+ Multilib.includeSuffix(), DriverArgs, CC1Args))
++ // Try generic GCC detection first.
++ if (Generic_GCC::addGCCLibStdCxxIncludePaths(DriverArgs, CC1Args,
++ TripleStr))
+ return;
+
+ // Otherwise, fall back on a bunch of options which don't use multiarch
@@ -519,10 +523,7 @@ index 0000000000..4cd7765aeb
+ };
+
+ for (const auto &IncludePath : LibStdCXXIncludePathCandidates) {
-+ if (addLibStdCXXIncludePaths(IncludePath, /*Suffix*/ "", TripleStr,
-+ /*GCCMultiarchTriple*/ "",
-+ /*TargetMultiarchTriple*/ "",
-+ Multilib.includeSuffix(), DriverArgs, CC1Args))
++ if (addLibStdCXXIncludePaths(IncludePath, TripleStr, Multilib.includeSuffix(), DriverArgs, CC1Args))
+ break;
+ }
+}
@@ -571,10 +572,9 @@ index 0000000000..4cd7765aeb
+ Res |= SanitizerKind::MemTag;
+ return Res;
+}
-+
diff --git a/clang/lib/Driver/ToolChains/Aero.h b/clang/lib/Driver/ToolChains/Aero.h
new file mode 100644
-index 0000000000..e9016f4a81
+index 000000000..a7b0b4da2
--- /dev/null
+++ b/clang/lib/Driver/ToolChains/Aero.h
@@ -0,0 +1,49 @@
@@ -587,8 +587,8 @@ index 0000000000..e9016f4a81
+//
+//===----------------------------------------------------------------------===//
+
-+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MANAGARM_H
-+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MANAGARM_H
++#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AERO_H
++#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AERO_H
+
+#include "Gnu.h"
+#include "clang/Driver/ToolChain.h"
@@ -611,9 +611,9 @@ index 0000000000..e9016f4a81
+ const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) const override;
+ SanitizerMask getSupportedSanitizers() const override;
-+ virtual std::string computeSysRoot() const;
+
-+ virtual std::string getDynamicLinker(const llvm::opt::ArgList &Args) const;
++ virtual std::string computeSysRoot() const override;
++ virtual std::string getDynamicLinker(const llvm::opt::ArgList &Args) const override;
+
+ std::vector ExtraOpts;
+
@@ -626,12 +626,12 @@ index 0000000000..e9016f4a81
+} // end namespace driver
+} // end namespace clang
+
-+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MANAGARM_H
++#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AERO_H
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
-index 7a9570a686..8114baabb0 100644
+index 40038dce4..f9e92ba87 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
-@@ -246,6 +246,8 @@ static const char *getLDMOption(const llvm::Triple &T, const ArgList &Args) {
+@@ -227,6 +227,8 @@ static const char *getLDMOption(const llvm::Triple &T, const ArgList &Args) {
return "elf_iamcu";
return "elf_i386";
case llvm::Triple::aarch64:
@@ -640,27 +640,27 @@ index 7a9570a686..8114baabb0 100644
return "aarch64linux";
case llvm::Triple::aarch64_be:
return "aarch64linuxb";
-@@ -2073,7 +2075,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
+@@ -2298,7 +2300,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
static const char *const AArch64LibDirs[] = {"/lib64", "/lib"};
static const char *const AArch64Triples[] = {
"aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux",
- "aarch64-suse-linux"};
-+ "aarch64-suse-linux", "aarch64-aero", "aarch64-aero-system",
++ "aarch64-suse-linux", "aarch64-aero", "aarch64-aero-system",
+ "aarch64-aero-kernel"};
static const char *const AArch64beLibDirs[] = {"/lib"};
static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu",
"aarch64_be-linux-gnu"};
-@@ -2099,7 +2102,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
+@@ -2328,7 +2331,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
"x86_64-redhat-linux", "x86_64-suse-linux",
"x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
"x86_64-slackware-linux", "x86_64-unknown-linux",
- "x86_64-amazon-linux"};
-+ "x86_64-amazon-linux", "x86_64-aero", "x86_64-aero-system",
-+ "x86_64-aero-kernel"};
++ "x86_64-amazon-linux", "x86_64-aero",
++ "x86_64-aero-system", "x86_64-aero-kernel"};
static const char *const X32Triples[] = {"x86_64-linux-gnux32",
"x86_64-pc-linux-gnux32"};
static const char *const X32LibDirs[] = {"/libx32", "/lib"};
-@@ -2171,7 +2175,10 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
+@@ -2404,7 +2408,10 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
static const char *const RISCV64LibDirs[] = {"/lib64", "/lib"};
static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu",
"riscv64-linux-gnu",
@@ -673,12 +673,12 @@ index 7a9570a686..8114baabb0 100644
static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"};
static const char *const SPARCv8Triples[] = {"sparc-linux-gnu",
diff --git a/llvm/cmake/modules/CrossCompile.cmake b/llvm/cmake/modules/CrossCompile.cmake
-index 2a39b6a40a..ceceb2aab9 100644
+index 6af47b51d..78983fa16 100644
--- a/llvm/cmake/modules/CrossCompile.cmake
+++ b/llvm/cmake/modules/CrossCompile.cmake
@@ -17,8 +17,8 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)
-DCMAKE_TOOLCHAIN_FILE=\"${LLVM_MAIN_SRC_DIR}/cmake/platforms/${toolchain}.cmake\")
- else()
+ elseif (NOT CMAKE_CROSSCOMPILING)
set(CROSS_TOOLCHAIN_FLAGS_INIT
- -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
- -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
@@ -687,35 +687,12 @@ index 2a39b6a40a..ceceb2aab9 100644
)
endif()
set(CROSS_TOOLCHAIN_FLAGS_${target_name} ${CROSS_TOOLCHAIN_FLAGS_INIT}
-diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
-index 42277c0130..35516ec5af 100644
---- a/llvm/include/llvm/ADT/Triple.h
-+++ b/llvm/include/llvm/ADT/Triple.h
-@@ -181,6 +181,7 @@ public:
- Linux,
- Lv2, // PS3
- MacOSX,
-+ Aero,
- NetBSD,
- OpenBSD,
- Solaris,
-@@ -232,7 +233,9 @@ public:
- CoreCLR,
- Simulator, // Simulator variants of other systems, e.g., Apple's iOS
- MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
-- LastEnvironmentType = MacABI
-+ Kernel,
-+ System,
-+ LastEnvironmentType = System
- };
- enum ObjectFormatType {
- UnknownObjectFormat,
diff --git a/llvm/include/llvm/Support/SwapByteOrder.h b/llvm/include/llvm/Support/SwapByteOrder.h
-index e8612ba665..7c4e941bd2 100644
+index 1bbc2e2f9..4b41da767 100644
--- a/llvm/include/llvm/Support/SwapByteOrder.h
+++ b/llvm/include/llvm/Support/SwapByteOrder.h
-@@ -22,7 +22,7 @@
- #endif
+@@ -20,7 +20,7 @@
+ #include
#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) || \
- defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
@@ -723,56 +700,31 @@ index e8612ba665..7c4e941bd2 100644
#include
#elif defined(_AIX)
#include
-diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp
-index a9afcc9db9..ccb0ca0601 100644
---- a/llvm/lib/Support/Triple.cpp
-+++ b/llvm/lib/Support/Triple.cpp
-@@ -195,6 +195,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
- case UnknownOS: return "unknown";
-
- case AIX: return "aix";
-+ case Aero: return "aero";
- case AMDHSA: return "amdhsa";
- case AMDPAL: return "amdpal";
- case Ananas: return "ananas";
-@@ -251,6 +252,7 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) {
- case GNUX32: return "gnux32";
- case GNUILP32: return "gnu_ilp32";
- case Itanium: return "itanium";
-+ case Kernel: return "kernel";
- case MSVC: return "msvc";
- case MacABI: return "macabi";
- case Musl: return "musl";
-@@ -258,6 +260,7 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) {
- case MuslEABIHF: return "musleabihf";
- case MuslX32: return "muslx32";
- case Simulator: return "simulator";
-+ case System: return "system";
- }
-
- llvm_unreachable("Invalid EnvironmentType!");
-@@ -512,6 +515,7 @@ static Triple::VendorType parseVendor(StringRef VendorName) {
-
- static Triple::OSType parseOS(StringRef OSName) {
- return StringSwitch(OSName)
-+ .StartsWith("aero", Triple::Aero)
- .StartsWith("ananas", Triple::Ananas)
- .StartsWith("cloudabi", Triple::CloudABI)
- .StartsWith("darwin", Triple::Darwin)
-@@ -570,9 +574,11 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
- .StartsWith("musl", Triple::Musl)
- .StartsWith("msvc", Triple::MSVC)
- .StartsWith("itanium", Triple::Itanium)
-+ .StartsWith("kernel", Triple::Kernel)
- .StartsWith("cygnus", Triple::Cygnus)
- .StartsWith("coreclr", Triple::CoreCLR)
- .StartsWith("simulator", Triple::Simulator)
-+ .StartsWith("system", Triple::System)
- .StartsWith("macabi", Triple::MacABI)
- .Default(Triple::UnknownEnvironment);
- }
+diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
+index 79ccd644a..82520d0e0 100644
+--- a/llvm/include/llvm/TargetParser/Triple.h
++++ b/llvm/include/llvm/TargetParser/Triple.h
+@@ -194,6 +194,7 @@ public:
+ IOS,
+ KFreeBSD,
+ Linux,
++ Aero,
+ Lv2, // PS3
+ MacOSX,
+ NetBSD,
+@@ -276,7 +277,9 @@ public:
+ Mesh,
+ Amplification,
+ OpenHOS,
+- LastEnvironmentType = OpenHOS
++ Kernel,
++ System,
++ LastEnvironmentType = System
+ };
+ enum ObjectFormatType {
+ UnknownObjectFormat,
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
-index 788460d657..85d46701e2 100644
+index e2aece49c..cc19a25a4 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -74,7 +74,7 @@ extern char **environ;
@@ -793,7 +745,7 @@ index 788460d657..85d46701e2 100644
#if defined(HAVE_LINUX_MAGIC_H)
#include
#else
-@@ -478,7 +478,7 @@ std::error_code remove(const Twine &path, bool IgnoreNonExisting) {
+@@ -472,7 +472,7 @@ std::error_code remove(const Twine &path, bool IgnoreNonExisting) {
}
static bool is_local_impl(struct STATVFS &Vfs) {
@@ -803,7 +755,7 @@ index 788460d657..85d46701e2 100644
#define NFS_SUPER_MAGIC 0x6969
#endif
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
-index 089342030b..0616096541 100644
+index 897e22711..02f74d7eb 100644
--- a/llvm/lib/Support/Unix/Program.inc
+++ b/llvm/lib/Support/Unix/Program.inc
@@ -41,6 +41,7 @@
@@ -814,31 +766,56 @@ index 089342030b..0616096541 100644
#ifdef HAVE_POSIX_SPAWN
#include
-diff --git a/llvm/tools/llvm-dwarfdump/Statistics.cpp b/llvm/tools/llvm-dwarfdump/Statistics.cpp
-index 5c08e43b4b..a19c74e82c 100644
---- a/llvm/tools/llvm-dwarfdump/Statistics.cpp
-+++ b/llvm/tools/llvm-dwarfdump/Statistics.cpp
-@@ -6,6 +6,8 @@
- //
- //===----------------------------------------------------------------------===//
+diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
+index a3d6a06af..3825a2a06 100644
+--- a/llvm/lib/TargetParser/Triple.cpp
++++ b/llvm/lib/TargetParser/Triple.cpp
+@@ -205,6 +205,7 @@ StringRef Triple::getOSTypeName(OSType Kind) {
+ switch (Kind) {
+ case UnknownOS: return "unknown";
-+#include
-+
- #include "llvm-dwarfdump.h"
- #include "llvm/ADT/DenseMap.h"
- #include "llvm/ADT/StringSet.h"
++ case Aero: return "aero";
+ case AIX: return "aix";
+ case AMDHSA: return "amdhsa";
+ case AMDPAL: return "amdpal";
+@@ -270,6 +271,8 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) {
+ case GNUX32: return "gnux32";
+ case GNUILP32: return "gnu_ilp32";
+ case Itanium: return "itanium";
++ case Kernel: return "kernel";
++ case System: return "system";
+ case MSVC: return "msvc";
+ case MacABI: return "macabi";
+ case Musl: return "musl";
+@@ -575,6 +578,7 @@ static Triple::VendorType parseVendor(StringRef VendorName) {
+
+ static Triple::OSType parseOS(StringRef OSName) {
+ return StringSwitch(OSName)
++ .StartsWith("aero", Triple::Aero)
+ .StartsWith("ananas", Triple::Ananas)
+ .StartsWith("cloudabi", Triple::CloudABI)
+ .StartsWith("darwin", Triple::Darwin)
+@@ -641,6 +645,8 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
+ .StartsWith("musl", Triple::Musl)
+ .StartsWith("msvc", Triple::MSVC)
+ .StartsWith("itanium", Triple::Itanium)
++ .StartsWith("kernel", Triple::Kernel)
++ .StartsWith("system", Triple::System)
+ .StartsWith("cygnus", Triple::Cygnus)
+ .StartsWith("coreclr", Triple::CoreCLR)
+ .StartsWith("simulator", Triple::Simulator)
diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt
-index 8e2b78f1b8..e1bd74eaf7 100644
+index 4f6a2cbfb..559a35ab9 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
-@@ -36,6 +36,7 @@ if(LLVM_BUILD_LLVM_DYLIB)
- if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU)
- OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
+@@ -38,6 +38,7 @@ if(LLVM_BUILD_LLVM_DYLIB)
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "GNU")
-+ OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "aero")
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD")
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia")
++ OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "aero")
OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly")
+ OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
+ OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")) # FIXME: It should be "GNU ld for elf"
--
-2.39.1
+2.42.0
From f198cd6149c45aaf7d337f7aa697cbe35f5c0796 Mon Sep 17 00:00:00 2001
From: Anhad Singh
Date: Thu, 19 Oct 2023 21:58:37 +1100
Subject: [PATCH 010/112] feat(rust): upgrade to 1.75.0-dev
TODO: Update the Rust fork with the changes.
Signed-off-by: Anhad Singh
---
bootstrap.yml | 11 +-
extra-files/rust/config.toml | 4 +-
...p-build-target-in-x.py-and-bootstrap.patch | 77 ++
patches/rust/rust.patch | 741 ------------------
4 files changed, 85 insertions(+), 748 deletions(-)
create mode 100644 patches/rust/0001-fix-bootstrap-build-target-in-x.py-and-bootstrap.patch
delete mode 100644 patches/rust/rust.patch
diff --git a/bootstrap.yml b/bootstrap.yml
index 5754cdc09d2..1106bb426b2 100644
--- a/bootstrap.yml
+++ b/bootstrap.yml
@@ -73,9 +73,9 @@ sources:
- name: rust
subdir: 'bundled'
- git: 'https://github.com/rust-lang/rust.git'
+ git: 'https://github.com/aero-os/rust.git'
branch: 'master'
- commit: '0416b1a6f6d5c42696494e1a3a33580fd3f669d8'
+ commit: 'dee2030a44019048171c03d7ddcb134b945df8c5'
- name: llvm
subdir: 'bundled'
@@ -386,19 +386,20 @@ tools:
compile:
- args: |
cat << EOF > config.toml
- changelog-seen = 2
+ change-id = 115898
[llvm]
download-ci-llvm = false
targets = "X86"
[build]
- target = ["x86_64-unknown-aero-system", "x86_64-unknown-linux-gnu"]
+ target = ["x86_64-unknown-aero", "x86_64-unknown-linux-gnu"]
build-dir = "@THIS_BUILD_DIR@"
docs = false
[install]
prefix = "@PREFIX@"
+ sysconfdir = "@PREFIX@/etc"
[rust]
codegen-tests = false
@@ -407,7 +408,7 @@ tools:
[target.x86_64-unknown-linux-gnu]
llvm-config = "@BUILD_ROOT@/tools/host-llvm/bin/llvm-config"
- [target.x86_64-unknown-aero-system]
+ [target.x86_64-unknown-aero]
llvm-config = "@BUILD_ROOT@/tools/host-llvm/bin/llvm-config"
EOF
- args: ['python3', '@THIS_SOURCE_DIR@/x.py', 'build', '--stage', '2', '-j', '@PARALLELISM@']
diff --git a/extra-files/rust/config.toml b/extra-files/rust/config.toml
index 40913d37e88..54f3a75dc53 100644
--- a/extra-files/rust/config.toml
+++ b/extra-files/rust/config.toml
@@ -3,10 +3,10 @@ patch-in-config = true
[build]
rustc = "@BUILD_ROOT@/tools/host-rust/bin/rustc"
-target = "x86_64-unknown-aero-system"
+target = "x86_64-unknown-aero"
rustflags = ["-C", "link-args=-no-pie"]
-[target.x86_64-unknown-aero-system]
+[target.x86_64-unknown-aero]
linker = "@BUILD_ROOT@/tools/host-gcc/bin/x86_64-aero-gcc"
[patch.crates-io]
diff --git a/patches/rust/0001-fix-bootstrap-build-target-in-x.py-and-bootstrap.patch b/patches/rust/0001-fix-bootstrap-build-target-in-x.py-and-bootstrap.patch
new file mode 100644
index 00000000000..2a474c60f55
--- /dev/null
+++ b/patches/rust/0001-fix-bootstrap-build-target-in-x.py-and-bootstrap.patch
@@ -0,0 +1,77 @@
+From 1f0ded570575781c7e8dbd0d60c57a2ec72ec987 Mon Sep 17 00:00:00 2001
+From: Anhad Singh
+Date: Wed, 18 Oct 2023 19:23:49 +1100
+Subject: [PATCH] fix(bootstrap): build target in x.py and bootstrap
+
+Signed-off-by: Anhad Singh
+---
+ src/bootstrap/bootstrap.py | 7 +++++--
+ src/bootstrap/src/core/builder.rs | 6 ++++--
+ 2 files changed, 9 insertions(+), 4 deletions(-)
+
+diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
+index 1a1125a107f..3f3171a9ddf 100644
+--- a/src/bootstrap/bootstrap.py
++++ b/src/bootstrap/bootstrap.py
+@@ -881,7 +881,7 @@ class RustBuild(object):
+ ... "debug", "bootstrap")
+ True
+ """
+- return os.path.join(self.build_dir, "bootstrap", "debug", "bootstrap")
++ return os.path.join(self.build_dir, "bootstrap", self.build, "debug", "bootstrap")
+
+ def build_bootstrap(self):
+ """Build bootstrap"""
+@@ -903,7 +903,7 @@ class RustBuild(object):
+ build_dir = os.path.join(self.build_dir, "bootstrap")
+ if self.clean and os.path.exists(build_dir):
+ shutil.rmtree(build_dir)
+- # `CARGO_BUILD_TARGET` breaks bootstrap build.
++ # `CARGO_BUILD_TARGET` and `build.target` breaks bootstrap build.
+ # See also: .
+ if "CARGO_BUILD_TARGET" in env:
+ del env["CARGO_BUILD_TARGET"]
+@@ -987,6 +987,9 @@ class RustBuild(object):
+ except KeyError:
+ pass
+
++ args.append("--target")
++ args.append(self.build)
++
+ return args
+
+ def build_triple(self):
+diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs
+index 039a87e760d..cbbbce4f515 100644
+--- a/src/bootstrap/src/core/builder.rs
++++ b/src/bootstrap/src/core/builder.rs
+@@ -1587,6 +1587,8 @@ pub fn cargo(
+ self.clear_if_dirty(&out_dir, &self.rustc(compiler));
+ }
+
++ let artifact_dir = self.out.join("bootstrap/").join(self.build.build.triple).join("debug/");
++
+ // Customize the compiler we're running. Specify the compiler to cargo
+ // as our shim and then pass it some various options used to configure
+ // how the actual compiler itself is called.
+@@ -1599,7 +1601,7 @@ pub fn cargo(
+ .env("RUSTC_STAGE", stage.to_string())
+ .env("RUSTC_SYSROOT", &sysroot)
+ .env("RUSTC_LIBDIR", &libdir)
+- .env("RUSTDOC", self.bootstrap_out.join("rustdoc"))
++ .env("RUSTDOC", artifact_dir.join("rustdoc"))
+ .env(
+ "RUSTDOC_REAL",
+ if cmd == "doc" || cmd == "rustdoc" || (cmd == "test" && want_rustdoc) {
+@@ -1613,7 +1615,7 @@ pub fn cargo(
+ // Clippy support is a hack and uses the default `cargo-clippy` in path.
+ // Don't override RUSTC so that the `cargo-clippy` in path will be run.
+ if cmd != "clippy" {
+- cargo.env("RUSTC", self.bootstrap_out.join("rustc"));
++ cargo.env("RUSTC", artifact_dir.join("rustc"));
+ }
+
+ // Dealing with rpath here is a little special, so let's go into some
+--
+2.42.0
+
diff --git a/patches/rust/rust.patch b/patches/rust/rust.patch
deleted file mode 100644
index e8d5de44a4d..00000000000
--- a/patches/rust/rust.patch
+++ /dev/null
@@ -1,741 +0,0 @@
-From be8fa0845294e187d6f41004a6967c8ce299fbbe Mon Sep 17 00:00:00 2001
-From: Andy-Python-Programmer
-Date: Fri, 17 Feb 2023 18:28:24 +1100
-Subject: [PATCH] update to latest nightly
-
-Signed-off-by: Andy-Python-Programmer
----
- Cargo.lock | 4 +-
- Cargo.toml | 1 +
- .../rustc_target/src/spec/aero_system_base.rs | 34 +++++
- compiler/rustc_target/src/spec/mod.rs | 3 +
- .../src/spec/x86_64_unknown_aero_system.rs | 19 +++
- library/std/Cargo.toml | 2 +-
- library/std/build.rs | 1 +
- library/std/src/os/aero/fs.rs | 144 ++++++++++++++++++
- library/std/src/os/aero/mod.rs | 6 +
- library/std/src/os/aero/raw.rs | 66 ++++++++
- library/std/src/os/mod.rs | 2 +
- library/std/src/os/unix/mod.rs | 2 +
- library/std/src/sys/unix/args.rs | 3 +-
- library/std/src/sys/unix/env.rs | 11 ++
- library/std/src/sys/unix/fs.rs | 5 +-
- library/std/src/sys/unix/os.rs | 34 ++++-
- library/std/src/sys/unix/thread.rs | 7 +
- library/std/src/sys/unix/thread_local_dtor.rs | 2 +-
- library/unwind/build.rs | 18 +++
- src/bootstrap/Cargo.lock | 40 ++++-
- src/bootstrap/bootstrap.py | 7 +-
- src/bootstrap/builder.rs | 6 +-
- 22 files changed, 399 insertions(+), 18 deletions(-)
- create mode 100644 compiler/rustc_target/src/spec/aero_system_base.rs
- create mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_aero_system.rs
- create mode 100644 library/std/src/os/aero/fs.rs
- create mode 100644 library/std/src/os/aero/mod.rs
- create mode 100644 library/std/src/os/aero/raw.rs
-
-diff --git a/Cargo.lock b/Cargo.lock
-index 15f051d0cff..f3548683f44 100644
---- a/Cargo.lock
-+++ b/Cargo.lock
-@@ -2326,9 +2326,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
-
- [[package]]
- name = "libc"
--version = "0.2.138"
--source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
-+version = "0.2.139"
- dependencies = [
- "rustc-std-workspace-core",
- ]
-diff --git a/Cargo.toml b/Cargo.toml
-index 15cbb2659c9..098e8227659 100644
---- a/Cargo.toml
-+++ b/Cargo.toml
-@@ -114,6 +114,7 @@ rustc-workspace-hack = { path = 'src/tools/rustc-workspace-hack' }
- rustc-std-workspace-core = { path = 'library/rustc-std-workspace-core' }
- rustc-std-workspace-alloc = { path = 'library/rustc-std-workspace-alloc' }
- rustc-std-workspace-std = { path = 'library/rustc-std-workspace-std' }
-+libc = { path = '../rust-libc' }
-
- [patch."https://github.com/rust-lang/rust-clippy"]
- clippy_lints = { path = "src/tools/clippy/clippy_lints" }
-diff --git a/compiler/rustc_target/src/spec/aero_system_base.rs b/compiler/rustc_target/src/spec/aero_system_base.rs
-new file mode 100644
-index 00000000000..1237a432e76
---- /dev/null
-+++ b/compiler/rustc_target/src/spec/aero_system_base.rs
-@@ -0,0 +1,34 @@
-+use crate::spec::{cvs, LinkArgs, LinkerFlavor, RelroLevel, TargetOptions, Cc, Lld};
-+
-+pub fn opts() -> TargetOptions {
-+ let mut args = LinkArgs::new();
-+ args.insert(
-+ LinkerFlavor::Gnu(Cc::Yes, Lld::No),
-+ vec![
-+ // We want to be able to strip as much executable code as possible
-+ // from the linker command line, and this flag indicates to the
-+ // linker that it can avoid linking in dynamic libraries that don't
-+ // actually satisfy any symbols up to that point (as with many other
-+ // resolutions the linker does). This option only applies to all
-+ // following libraries so we're sure to pass it as one of the first
-+ // arguments.
-+ "-Wl,--as-needed".into(),
-+ // Always enable NX protection when it is available
-+ "-Wl,-z,noexecstack".into(),
-+ ],
-+ );
-+
-+ TargetOptions {
-+ os: "aero".into(),
-+ dynamic_linking: true,
-+ executables: true,
-+ families: cvs!["unix"],
-+ has_rpath: true,
-+ pre_link_args: args,
-+ position_independent_executables: true,
-+ relro_level: RelroLevel::Full,
-+ has_thread_local: true,
-+ crt_static_respected: true,
-+ ..Default::default()
-+ }
-+}
-diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs
-index bc1920e3424..d4d049a8631 100644
---- a/compiler/rustc_target/src/spec/mod.rs
-+++ b/compiler/rustc_target/src/spec/mod.rs
-@@ -65,6 +65,7 @@
- mod freebsd_base;
- mod fuchsia_base;
- mod haiku_base;
-+mod aero_system_base;
- mod hermit_base;
- mod illumos_base;
- mod l4re_base;
-@@ -1105,6 +1106,8 @@ fn $module() {
- ("i686-unknown-haiku", i686_unknown_haiku),
- ("x86_64-unknown-haiku", x86_64_unknown_haiku),
-
-+ ("x86_64-unknown-aero-system", x86_64_unknown_aero_system),
-+
- ("aarch64-apple-darwin", aarch64_apple_darwin),
- ("x86_64-apple-darwin", x86_64_apple_darwin),
- ("i686-apple-darwin", i686_apple_darwin),
-diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_aero_system.rs b/compiler/rustc_target/src/spec/x86_64_unknown_aero_system.rs
-new file mode 100644
-index 00000000000..d4e4097fb4b
---- /dev/null
-+++ b/compiler/rustc_target/src/spec/x86_64_unknown_aero_system.rs
-@@ -0,0 +1,19 @@
-+use crate::spec::{LinkerFlavor, StackProbeType, Target, Cc, Lld};
-+
-+pub fn target() -> Target {
-+ let mut base = super::aero_system_base::opts();
-+ base.cpu = "x86-64".into();
-+ base.max_atomic_width = Some(64);
-+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
-+ // don't use probe-stack=inline-asm until rust-lang/rust#83139 is resolved.
-+ base.stack_probes = StackProbeType::Call;
-+
-+ Target {
-+ llvm_target: "x86_64-unknown-aero-system".into(),
-+ pointer_width: 64,
-+ data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
-+ .into(),
-+ arch: "x86_64".into(),
-+ options: base,
-+ }
-+}
-diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml
-index 349cd91c89e..aa84feaec7b 100644
---- a/library/std/Cargo.toml
-+++ b/library/std/Cargo.toml
-@@ -15,7 +15,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
- panic_unwind = { path = "../panic_unwind", optional = true }
- panic_abort = { path = "../panic_abort" }
- core = { path = "../core" }
--libc = { version = "0.2.138", default-features = false, features = ['rustc-dep-of-std'] }
-+libc = { path = "../../../rust-libc", default-features = false, features = ['rustc-dep-of-std'] }
- compiler_builtins = { version = "0.1.87" }
- profiler_builtins = { path = "../profiler_builtins", optional = true }
- unwind = { path = "../unwind" }
-diff --git a/library/std/build.rs b/library/std/build.rs
-index 8b1a06ee750..683976b2a47 100644
---- a/library/std/build.rs
-+++ b/library/std/build.rs
-@@ -24,6 +24,7 @@ fn main() {
- || target.contains("l4re")
- || target.contains("redox")
- || target.contains("haiku")
-+ || target.contains("aero")
- || target.contains("vxworks")
- || target.contains("wasm32")
- || target.contains("wasm64")
-diff --git a/library/std/src/os/aero/fs.rs b/library/std/src/os/aero/fs.rs
-new file mode 100644
-index 00000000000..a3c953ca169
---- /dev/null
-+++ b/library/std/src/os/aero/fs.rs
-@@ -0,0 +1,144 @@
-+#![stable(feature = "raw_ext", since = "1.1.0")]
-+
-+use crate::fs::Metadata;
-+use crate::sys_common::AsInner;
-+
-+#[allow(deprecated)]
-+use crate::os::aero::raw;
-+
-+/// OS-specific extensions to [`fs::Metadata`].
-+///
-+/// [`fs::Metadata`]: crate::fs::Metadata
-+#[stable(feature = "metadata_ext", since = "1.1.0")]
-+pub trait MetadataExt {
-+ /// Gain a reference to the underlying `stat` structure which contains
-+ /// the raw information returned by the OS.
-+ ///
-+ /// The contents of the returned `stat` are **not** consistent across
-+ /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
-+ /// cross-Unix abstractions contained within the raw stat.
-+ #[stable(feature = "metadata_ext", since = "1.1.0")]
-+ #[deprecated(since = "1.8.0", note = "other methods of this trait are now preferred")]
-+ #[allow(deprecated)]
-+ fn as_raw_stat(&self) -> &raw::stat;
-+
-+ #[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 {
-+ #[allow(deprecated)]
-+ fn as_raw_stat(&self) -> &raw::stat {
-+ unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) }
-+ }
-+
-+ 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_atime as i64
-+ }
-+
-+ fn st_atime_nsec(&self) -> i64 {
-+ self.as_inner().as_inner().st_atime_nsec as i64
-+ }
-+
-+ fn st_mtime(&self) -> i64 {
-+ self.as_inner().as_inner().st_mtime as i64
-+ }
-+
-+ fn st_mtime_nsec(&self) -> i64 {
-+ self.as_inner().as_inner().st_mtime_nsec as i64
-+ }
-+
-+ fn st_ctime(&self) -> i64 {
-+ self.as_inner().as_inner().st_ctime as i64
-+ }
-+
-+ fn st_ctime_nsec(&self) -> i64 {
-+ self.as_inner().as_inner().st_ctime_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
-+ }
-+}
-diff --git a/library/std/src/os/aero/mod.rs b/library/std/src/os/aero/mod.rs
-new file mode 100644
-index 00000000000..ea3291a2f18
---- /dev/null
-+++ b/library/std/src/os/aero/mod.rs
-@@ -0,0 +1,6 @@
-+//! Aero-specific definitions
-+
-+#![stable(feature = "raw_ext", since = "1.1.0")]
-+
-+pub mod fs;
-+pub mod raw;
-diff --git a/library/std/src/os/aero/raw.rs b/library/std/src/os/aero/raw.rs
-new file mode 100644
-index 00000000000..c5e56b8b7b9
---- /dev/null
-+++ b/library/std/src/os/aero/raw.rs
-@@ -0,0 +1,66 @@
-+#![stable(feature = "raw_ext", since = "1.1.0")]
-+
-+#[stable(feature = "pthread_t", since = "1.8.0")]
-+pub type pthread_t = usize; // TODO: This is completely wrong tbh
-+
-+#[stable(feature = "raw_ext", since = "1.1.0")]
-+pub type dev_t = libc::dev_t;
-+
-+#[stable(feature = "raw_ext", since = "1.1.0")]
-+pub type ino_t = libc::ino_t;
-+
-+#[stable(feature = "raw_ext", since = "1.1.0")]
-+pub type mode_t = libc::mode_t;
-+
-+#[stable(feature = "raw_ext", since = "1.1.0")]
-+pub type nlink_t = libc::nlink_t;
-+
-+#[stable(feature = "raw_ext", since = "1.1.0")]
-+pub type off_t = libc::off_t;
-+
-+#[stable(feature = "raw_ext", since = "1.1.0")]
-+pub type time_t = libc::time_t;
-+
-+#[stable(feature = "raw_ext", since = "1.1.0")]
-+pub type blkcnt_t = libc::blkcnt_t;
-+
-+#[stable(feature = "raw_ext", since = "1.1.0")]
-+pub type blksize_t = libc::blksize_t;
-+
-+#[repr(C)]
-+#[derive(Clone)]
-+#[stable(feature = "raw_ext", since = "1.1.0")]
-+pub struct stat {
-+ #[stable(feature = "raw_ext", since = "1.1.0")]
-+ pub st_dev: libc::dev_t,
-+ #[stable(feature = "raw_ext", since = "1.1.0")]
-+ pub st_ino: libc::ino_t,
-+ #[stable(feature = "raw_ext", since = "1.1.0")]
-+ pub st_mode: libc::mode_t,
-+ #[stable(feature = "raw_ext", since = "1.1.0")]
-+ pub st_nlink: libc::nlink_t,
-+ #[stable(feature = "raw_ext", since = "1.1.0")]
-+ pub st_uid: libc::uid_t,
-+ #[stable(feature = "raw_ext", since = "1.1.0")]
-+ pub st_gid: libc::gid_t,
-+ #[stable(feature = "raw_ext", since = "1.1.0")]
-+ pub st_rdev: libc::dev_t,
-+ #[stable(feature = "raw_ext", since = "1.1.0")]
-+ pub st_size: libc::off_t,
-+ #[stable(feature = "raw_ext", since = "1.1.0")]
-+ pub st_atime: libc::time_t,
-+ #[stable(feature = "raw_ext", since = "1.1.0")]
-+ pub st_atime_nsec: libc::c_long,
-+ #[stable(feature = "raw_ext", since = "1.1.0")]
-+ pub st_mtime: libc::time_t,
-+ #[stable(feature = "raw_ext", since = "1.1.0")]
-+ pub st_mtime_nsec: libc::c_long,
-+ #[stable(feature = "raw_ext", since = "1.1.0")]
-+ pub st_ctime: libc::time_t,
-+ #[stable(feature = "raw_ext", since = "1.1.0")]
-+ pub st_ctime_nsec: libc::c_long,
-+ #[stable(feature = "raw_ext", since = "1.1.0")]
-+ pub st_blksize: libc::blksize_t,
-+ #[stable(feature = "raw_ext", since = "1.1.0")]
-+ pub st_blocks: libc::blkcnt_t,
-+}
-diff --git a/library/std/src/os/mod.rs b/library/std/src/os/mod.rs
-index 42773805cdb..24158d5da87 100644
---- a/library/std/src/os/mod.rs
-+++ b/library/std/src/os/mod.rs
-@@ -133,6 +133,8 @@ pub mod windows {}
- pub mod l4re;
- #[cfg(target_os = "macos")]
- pub mod macos;
-+#[cfg(target_os = "aero")]
-+pub mod aero;
- #[cfg(target_os = "netbsd")]
- pub mod netbsd;
- #[cfg(target_os = "openbsd")]
-diff --git a/library/std/src/os/unix/mod.rs b/library/std/src/os/unix/mod.rs
-index f97fa0fb06f..9174b0da9a3 100644
---- a/library/std/src/os/unix/mod.rs
-+++ b/library/std/src/os/unix/mod.rs
-@@ -37,6 +37,8 @@
-
- #[cfg(not(doc))]
- mod platform {
-+ #[cfg(target_os = "aero")]
-+ pub use crate::os::aero::*;
- #[cfg(target_os = "android")]
- pub use crate::os::android::*;
- #[cfg(target_os = "dragonfly")]
-diff --git a/library/std/src/sys/unix/args.rs b/library/std/src/sys/unix/args.rs
-index a5ce6d5120d..3dfe759830f 100644
---- a/library/std/src/sys/unix/args.rs
-+++ b/library/std/src/sys/unix/args.rs
-@@ -69,7 +69,8 @@ fn next_back(&mut self) -> Option {
- target_os = "fuchsia",
- target_os = "redox",
- target_os = "vxworks",
-- target_os = "horizon"
-+ target_os = "horizon",
-+ target_os = "aero"
- ))]
- mod imp {
- use super::Args;
-diff --git a/library/std/src/sys/unix/env.rs b/library/std/src/sys/unix/env.rs
-index c9ba661c829..5894baf74f2 100644
---- a/library/std/src/sys/unix/env.rs
-+++ b/library/std/src/sys/unix/env.rs
-@@ -217,3 +217,14 @@ pub mod os {
- pub const EXE_SUFFIX: &str = "";
- pub const EXE_EXTENSION: &str = "";
- }
-+
-+#[cfg(target_os = "aero")]
-+pub mod os {
-+ pub const FAMILY: &str = "unix";
-+ pub const OS: &str = "aero";
-+ pub const DLL_PREFIX: &str = "lib";
-+ pub const DLL_SUFFIX: &str = ".so";
-+ pub const DLL_EXTENSION: &str = "so";
-+ pub const EXE_SUFFIX: &str = "";
-+ pub const EXE_EXTENSION: &str = "";
-+}
-diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs
-index 8e1f35d6cc9..18910365f20 100644
---- a/library/std/src/sys/unix/fs.rs
-+++ b/library/std/src/sys/unix/fs.rs
-@@ -834,7 +834,8 @@ pub fn file_type(&self) -> io::Result {
- target_os = "redox",
- target_os = "vxworks",
- target_os = "espidf",
-- target_os = "horizon"
-+ target_os = "horizon",
-+ target_os = "aero"
- ))]
- pub fn ino(&self) -> u64 {
- self.entry.d_ino as u64
-@@ -887,7 +888,7 @@ fn name_bytes(&self) -> &[u8] {
- target_os = "solaris",
- target_os = "illumos",
- target_os = "fuchsia",
-- target_os = "redox"
-+ target_os = "redox",
- )))]
- fn name_cstr(&self) -> &CStr {
- unsafe { CStr::from_ptr(self.entry.d_name.as_ptr()) }
-diff --git a/library/std/src/sys/unix/os.rs b/library/std/src/sys/unix/os.rs
-index 2f2663db607..5a4b2bc6b10 100644
---- a/library/std/src/sys/unix/os.rs
-+++ b/library/std/src/sys/unix/os.rs
-@@ -41,7 +41,7 @@
- }
-
- extern "C" {
-- #[cfg(not(any(target_os = "dragonfly", target_os = "vxworks")))]
-+ #[cfg(not(any(target_os = "dragonfly", target_os = "vxworks", target_os = "aero")))]
- #[cfg_attr(
- any(
- target_os = "linux",
-@@ -71,13 +71,13 @@
- }
-
- /// Returns the platform-specific value of errno
--#[cfg(not(any(target_os = "dragonfly", target_os = "vxworks")))]
-+#[cfg(not(any(target_os = "dragonfly", target_os = "vxworks", target_os = "aero")))]
- pub fn errno() -> i32 {
- unsafe { (*errno_location()) as i32 }
- }
-
- /// Sets the platform-specific value of errno
--#[cfg(all(not(target_os = "dragonfly"), not(target_os = "vxworks")))] // needed for readdir and syscall!
-+#[cfg(all(not(target_os = "dragonfly"), not(target_os = "vxworks"), not(target_os = "aero")))] // needed for readdir and syscall!
- #[allow(dead_code)] // but not all target cfgs actually end up using it
- pub fn set_errno(e: i32) {
- unsafe { *errno_location() = e as c_int }
-@@ -111,6 +111,29 @@ pub fn set_errno(e: i32) {
- }
- }
-
-+#[cfg(target_os = "aero")]
-+pub fn errno() -> i32 {
-+ extern "C" {
-+ #[thread_local]
-+ static __mlibc_errno: c_int;
-+ }
-+
-+ unsafe { __mlibc_errno as i32 }
-+}
-+
-+#[cfg(target_os = "aero")]
-+#[allow(dead_code)]
-+pub fn set_errno(e: i32) {
-+ extern "C" {
-+ #[thread_local]
-+ static mut __mlibc_errno: c_int;
-+ }
-+
-+ unsafe {
-+ __mlibc_errno = e;
-+ }
-+}
-+
- /// Gets a detailed string description for the given error number.
- pub fn error_string(errno: i32) -> String {
- extern "C" {
-@@ -471,6 +494,11 @@ pub fn current_exe() -> io::Result {
- if !path.is_absolute() { getcwd().map(|cwd| cwd.join(path)) } else { Ok(path) }
- }
-
-+#[cfg(target_os = "aero")]
-+pub fn current_exe() -> io::Result {
-+ unimplemented!()
-+}
-+
- pub struct Env {
- iter: vec::IntoIter<(OsString, OsString)>,
- }
-diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs
-index cc0e5929569..b952e199aa2 100644
---- a/library/std/src/sys/unix/thread.rs
-+++ b/library/std/src/sys/unix/thread.rs
-@@ -160,6 +160,13 @@ pub fn set_name(name: &CStr) {
- }
- }
-
-+ #[cfg(target_os = "aero")]
-+ pub fn set_name(name: &CStr) {
-+ unsafe {
-+ libc::pthread_setname_np(libc::pthread_self(), name.as_ptr());
-+ }
-+ }
-+
- #[cfg(target_os = "netbsd")]
- pub fn set_name(name: &CStr) {
- unsafe {
-diff --git a/library/std/src/sys/unix/thread_local_dtor.rs b/library/std/src/sys/unix/thread_local_dtor.rs
-index 236d2f2ee29..30008fc151d 100644
---- a/library/std/src/sys/unix/thread_local_dtor.rs
-+++ b/library/std/src/sys/unix/thread_local_dtor.rs
-@@ -11,7 +11,7 @@
- // Note, however, that we run on lots older linuxes, as well as cross
- // compiling from a newer linux to an older linux, so we also have a
- // fallback implementation to use as well.
--#[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "redox"))]
-+#[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "redox", target_os = "aero"))]
- pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
- use crate::mem;
- use crate::sys_common::thread_local_dtor::register_dtor_fallback;
-diff --git a/library/unwind/build.rs b/library/unwind/build.rs
-index 5c3c02fb6ad..9071008e3b9 100644
---- a/library/unwind/build.rs
-+++ b/library/unwind/build.rs
-@@ -21,5 +21,23 @@ fn main() {
- if has_unwind {
- println!("cargo:rustc-cfg=feature=\"system-llvm-libunwind\"");
- }
-+ } else if target.contains("solaris") {
-+ println!("cargo:rustc-link-lib=gcc_s");
-+ } else if target.contains("illumos") {
-+ println!("cargo:rustc-link-lib=gcc_s");
-+ } else if target.contains("dragonfly") {
-+ println!("cargo:rustc-link-lib=gcc_pic");
-+ } else if target.contains("pc-windows-gnu") {
-+ // This is handled in the target spec with late_link_args_[static|dynamic]
-+ } else if target.contains("uwp-windows-gnu") {
-+ println!("cargo:rustc-link-lib=unwind");
-+ } else if target.contains("fuchsia") {
-+ println!("cargo:rustc-link-lib=unwind");
-+ } else if target.contains("haiku") {
-+ println!("cargo:rustc-link-lib=gcc_s");
-+ } else if target.contains("redox") {
-+ // redox is handled in lib.rs
-+ } else if target.contains("aero") {
-+ println!("cargo:rustc-link-lib=gcc_s");
- }
- }
-diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock
-index 4a0ba592577..d7b4d646308 100644
---- a/src/bootstrap/Cargo.lock
-+++ b/src/bootstrap/Cargo.lock
-@@ -335,9 +335,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
-
- [[package]]
- name = "libc"
--version = "0.2.137"
--source = "registry+https://github.com/rust-lang/crates.io-index"
--checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
-+version = "0.2.139"
-
- [[package]]
- name = "linux-raw-sys"
-@@ -802,3 +800,39 @@ name = "yansi"
- version = "0.5.1"
- source = "registry+https://github.com/rust-lang/crates.io-index"
- checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"
-+
-+[[patch.unused]]
-+name = "glutin"
-+version = "0.28.0"
-+
-+[[patch.unused]]
-+name = "libloading"
-+version = "0.7.3"
-+
-+[[patch.unused]]
-+name = "mio"
-+version = "0.6.23"
-+
-+[[patch.unused]]
-+name = "mio"
-+version = "0.8.3"
-+
-+[[patch.unused]]
-+name = "nix"
-+version = "0.22.3"
-+
-+[[patch.unused]]
-+name = "num_cpus"
-+version = "1.13.0"
-+
-+[[patch.unused]]
-+name = "shared_library"
-+version = "0.1.9"
-+
-+[[patch.unused]]
-+name = "users"
-+version = "0.11.0"
-+
-+[[patch.unused]]
-+name = "winit"
-+version = "0.26.1"
-diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
-index 013d1ab525b..624c8070fca 100644
---- a/src/bootstrap/bootstrap.py
-+++ b/src/bootstrap/bootstrap.py
-@@ -717,7 +717,7 @@ class RustBuild(object):
- ... "debug", "bootstrap")
- True
- """
-- return os.path.join(self.build_dir, "bootstrap", "debug", "bootstrap")
-+ return os.path.join(self.build_dir, "bootstrap", self.build, "debug", "bootstrap")
-
- def build_bootstrap(self, color, verbose_count):
- """Build bootstrap"""
-@@ -726,7 +726,7 @@ class RustBuild(object):
- if self.clean and os.path.exists(build_dir):
- shutil.rmtree(build_dir)
- env = os.environ.copy()
-- # `CARGO_BUILD_TARGET` breaks bootstrap build.
-+ # `CARGO_BUILD_TARGET` and 'build.target' break bootstrap build.
- # See also: .
- if "CARGO_BUILD_TARGET" in env:
- del env["CARGO_BUILD_TARGET"]
-@@ -791,6 +791,9 @@ class RustBuild(object):
- elif color == "never":
- args.append("--color=never")
-
-+ args.append("--target")
-+ args.append(self.build)
-+
- # Run this from the source directory so cargo finds .cargo/config
- run(args, env=env, verbose=self.verbose, cwd=self.rust_root)
-
-diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
-index b4fc1d4f28d..7ef092488fe 100644
---- a/src/bootstrap/builder.rs
-+++ b/src/bootstrap/builder.rs
-@@ -1479,6 +1479,8 @@ pub fn cargo(
- self.clear_if_dirty(&out_dir, &self.rustc(compiler));
- }
-
-+ let artifact_dir = self.out.join("bootstrap/").join(self.build.build.triple).join("debug/");
-+
- // Customize the compiler we're running. Specify the compiler to cargo
- // as our shim and then pass it some various options used to configure
- // how the actual compiler itself is called.
-@@ -1491,7 +1493,7 @@ pub fn cargo(
- .env("RUSTC_STAGE", stage.to_string())
- .env("RUSTC_SYSROOT", &sysroot)
- .env("RUSTC_LIBDIR", &libdir)
-- .env("RUSTDOC", self.bootstrap_out.join("rustdoc"))
-+ .env("RUSTDOC", artifact_dir.join("rustdoc"))
- .env(
- "RUSTDOC_REAL",
- if cmd == "doc" || cmd == "rustdoc" || (cmd == "test" && want_rustdoc) {
-@@ -1505,7 +1507,7 @@ pub fn cargo(
- // Clippy support is a hack and uses the default `cargo-clippy` in path.
- // Don't override RUSTC so that the `cargo-clippy` in path will be run.
- if cmd != "clippy" {
-- cargo.env("RUSTC", self.bootstrap_out.join("rustc"));
-+ cargo.env("RUSTC", artifact_dir.join("rustc"));
- }
-
- // Dealing with rpath here is a little special, so let's go into some
---
-2.39.1
-
From f4add34bfe1d914e92b2a2e7f2806c96e4cda2b1 Mon Sep 17 00:00:00 2001
From: Anhad Singh
Date: Thu, 19 Oct 2023 22:00:48 +1100
Subject: [PATCH 011/112] misc(aero.py): update to the new target triple
* Update to the new target triple (`x86_64-unknown-aero-system` to
`x86_64-unknown-aero`)
Signed-off-by: Anhad Singh
---
aero.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/aero.py b/aero.py
index 98ebbbd67d0..8dfee005dbc 100755
--- a/aero.py
+++ b/aero.py
@@ -341,13 +341,13 @@ def get_mlibc(): return os.path.join("..", pkg_dir, PACKAGE_MLIBC)
command = 'build'
# TODO: handle the unbased architectures.
- cmd_args = ["--target", "x86_64-unknown-aero-system",
+ cmd_args = ["--target", "x86_64-unknown-aero",
# cargo config
"--config", f"build.rustc = '{get_rustc()}'",
- "--config", "build.target = 'x86_64-unknown-aero-system'",
+ "--config", "build.target = 'x86_64-unknown-aero'",
"--config", f"build.rustflags = ['-C', 'link-args=-no-pie -B {get_binutils()} --sysroot {get_mlibc()}', '-lc']",
- "--config", f"target.x86_64-unknown-aero-system.linker = '{get_gcc()}'",
+ "--config", f"target.x86_64-unknown-aero.linker = '{get_gcc()}'",
"-Z", "unstable-options"]
From 4cbc29e02fd20a0f544fe02f69044a2e6e357d7e Mon Sep 17 00:00:00 2001
From: Anhad Singh
Date: Fri, 20 Oct 2023 19:51:12 +1100
Subject: [PATCH 012/112] misc: cleanups and minor fixes for webkitgtk
* cleanup: remove the unused flags argument in INode::open()
* cleanup: make `flags` on `FileHandle` private and use getter and
setter functions to set the flags.
* feat: add initial netlink socket support
* feat(unix): implement get_{sockname, peername}
* fix: the ABI for `MessageHeader` was wrong, i.e, {name_len,
control_len} are supposed to be a u32 instead of a usize.
Signed-off-by: Anhad Singh
---
patches/mlibc/mlibc.patch | 183 ----------
src/Cargo.lock | 1 +
src/aero_kernel/src/drivers/pty.rs | 6 +-
src/aero_kernel/src/drivers/tty/vtty.rs | 1 -
src/aero_kernel/src/fs/devfs.rs | 8 +-
src/aero_kernel/src/fs/eventfd.rs | 47 ++-
src/aero_kernel/src/fs/file_table.rs | 27 +-
src/aero_kernel/src/fs/inode.rs | 2 +-
src/aero_kernel/src/fs/pipe.rs | 15 +-
src/aero_kernel/src/fs/ramfs.rs | 8 +-
src/aero_kernel/src/socket/mod.rs | 7 +
src/aero_kernel/src/socket/netlink.rs | 315 ++++++++++++++++++
src/aero_kernel/src/socket/tcp.rs | 8 +-
src/aero_kernel/src/socket/udp.rs | 9 +-
src/aero_kernel/src/socket/unix.rs | 37 +-
src/aero_kernel/src/syscall/fs.rs | 29 +-
src/aero_kernel/src/syscall/net.rs | 44 ++-
src/aero_kernel/src/userland/scheduler/mod.rs | 4 +
.../src/userland/scheduler/round_robin.rs | 1 +
src/aero_kernel/src/userland/task/mod.rs | 48 ++-
src/aero_syscall/Cargo.toml | 1 +
src/aero_syscall/src/lib.rs | 1 +
src/aero_syscall/src/netlink.rs | 230 +++++++++++++
src/aero_syscall/src/socket.rs | 10 +-
userland/Cargo.lock | 7 +
25 files changed, 774 insertions(+), 275 deletions(-)
delete mode 100644 patches/mlibc/mlibc.patch
create mode 100644 src/aero_kernel/src/socket/netlink.rs
create mode 100644 src/aero_syscall/src/netlink.rs
diff --git a/patches/mlibc/mlibc.patch b/patches/mlibc/mlibc.patch
deleted file mode 100644
index a72e9f7fe37..00000000000
--- a/patches/mlibc/mlibc.patch
+++ /dev/null
@@ -1,183 +0,0 @@
-From ea350e347faaa97e0499d34582ff068510809542 Mon Sep 17 00:00:00 2001
-From: Anhad Singh
-Date: Fri, 13 Oct 2023 22:50:34 +1100
-Subject: [PATCH]
-
-Signed-off-by: Anhad Singh
----
- options/glibc/generic/execinfo.cpp | 5 +++--
- options/posix/generic/posix_stdlib.cpp | 2 +-
- options/rtdl/generic/linker.cpp | 2 +-
- sysdeps/aero/generic/aero.cpp | 9 ++++++---
- sysdeps/aero/generic/filesystem.cpp | 10 ++++++++++
- sysdeps/aero/generic/signals.cpp | 19 +++++++------------
- sysdeps/aero/generic/sockets.cpp | 16 ++++++++++++++++
- sysdeps/aero/include/aero/syscall.h | 2 ++
- 8 files changed, 46 insertions(+), 19 deletions(-)
-
-diff --git a/options/glibc/generic/execinfo.cpp b/options/glibc/generic/execinfo.cpp
-index 3474615..aaf593a 100644
---- a/options/glibc/generic/execinfo.cpp
-+++ b/options/glibc/generic/execinfo.cpp
-@@ -1,9 +1,10 @@
- #include
- #include
-+#include
-
- int backtrace(void **, int) {
-- __ensure(!"Not implemented");
-- __builtin_unreachable();
-+ mlibc::infoLogger() << "backtrace: Not implemented" << frg::endlog;
-+ return 0;
- }
-
- char **backtrace_symbols(void *const *, int) {
-diff --git a/options/posix/generic/posix_stdlib.cpp b/options/posix/generic/posix_stdlib.cpp
-index 76b85dc..4b783b3 100644
---- a/options/posix/generic/posix_stdlib.cpp
-+++ b/options/posix/generic/posix_stdlib.cpp
-@@ -464,7 +464,7 @@ int grantpt(int) {
- }
-
- double strtod_l(const char *__restrict__ nptr, char ** __restrict__ endptr, locale_t) {
-- mlibc::infoLogger() << "mlibc: strtod_l ignores locale!" << frg::endlog;
-+ // mlibc::infoLogger() << "mlibc: strtod_l ignores locale!" << frg::endlog;
- return strtod(nptr, endptr);
- }
-
-diff --git a/options/rtdl/generic/linker.cpp b/options/rtdl/generic/linker.cpp
-index c604a50..eec0b7b 100644
---- a/options/rtdl/generic/linker.cpp
-+++ b/options/rtdl/generic/linker.cpp
-@@ -18,7 +18,7 @@ uintptr_t libraryBase = 0x41000000;
-
- constexpr bool verbose = false;
- constexpr bool stillSlightlyVerbose = false;
--constexpr bool logBaseAddresses = false;
-+constexpr bool logBaseAddresses = true;
- constexpr bool logRpath = false;
- constexpr bool eagerBinding = true;
-
-diff --git a/sysdeps/aero/generic/aero.cpp b/sysdeps/aero/generic/aero.cpp
-index e6bd277..a341fcf 100644
---- a/sysdeps/aero/generic/aero.cpp
-+++ b/sysdeps/aero/generic/aero.cpp
-@@ -303,10 +303,13 @@ int sys_clone(void *tcb, pid_t *tid_out, void *stack) {
- return 0;
- }
-
--void sys_thread_exit() UNIMPLEMENTED("sys_thread_exit")
-+void sys_thread_exit() {
-+ syscall(SYS_EXIT);
-+ __builtin_trap();
-+}
-
-- int sys_waitpid(pid_t pid, int *status, int flags, struct rusage *ru,
-- pid_t *ret_pid) {
-+int sys_waitpid(pid_t pid, int *status, int flags, struct rusage *ru,
-+ pid_t *ret_pid) {
- if (ru) {
- mlibc::infoLogger()
- << "mlibc: struct rusage in sys_waitpid is unsupported"
-diff --git a/sysdeps/aero/generic/filesystem.cpp b/sysdeps/aero/generic/filesystem.cpp
-index fa5a369..33a11f4 100644
---- a/sysdeps/aero/generic/filesystem.cpp
-+++ b/sysdeps/aero/generic/filesystem.cpp
-@@ -39,6 +39,16 @@ int sys_read(int fd, void *buf, size_t count, ssize_t *bytes_read) {
- return 0;
- }
-
-+int sys_fsync(int) {
-+ mlibc::infoLogger() << "\e[35mmlibc: fsync is a stub\e[39m" << frg::endlog;
-+ return 0;
-+}
-+
-+int sys_fdatasync(int) {
-+ mlibc::infoLogger() << "\e[35mmlibc: fdatasync() is a no-op\e[39m" << frg::endlog;
-+ return 0;
-+}
-+
- // clang-format off
- int sys_pwrite(int fd, const void *buffer, size_t count, off_t off,
- ssize_t *written) UNIMPLEMENTED("sys_pwrite")
-diff --git a/sysdeps/aero/generic/signals.cpp b/sysdeps/aero/generic/signals.cpp
-index a6f69ff..611db69 100644
---- a/sysdeps/aero/generic/signals.cpp
-+++ b/sysdeps/aero/generic/signals.cpp
-@@ -29,25 +29,20 @@ int sys_sigaction(int how, const struct sigaction *__restrict action,
- #endif
-
- auto sigreturn = (sc_word_t)__mlibc_signal_restore;
--
-- auto res = syscall(SYS_SIGACTION, how, (sc_word_t)action, sigreturn,
-+ auto ret = syscall(SYS_SIGACTION, how, (sc_word_t)action, sigreturn,
- (sc_word_t)old_action);
-
-- if (res < 0) {
-- return -res;
-- }
--
-+ if(int e = sc_error(ret); e)
-+ return e;
- return 0;
- }
-
- int sys_sigprocmask(int how, const sigset_t *__restrict set,
- sigset_t *__restrict retrieve) {
-- auto result = syscall(SYS_SIGPROCMASK, how, set, retrieve);
-
-- if (result < 0) {
-- return -result;
-- }
--
-- return 0;
-+ auto ret = syscall(SYS_SIGPROCMASK, how, set, retrieve);
-+ if(int e = sc_error(ret); e)
-+ return e;
-+ return 0;
- }
- } // namespace mlibc
-\ No newline at end of file
-diff --git a/sysdeps/aero/generic/sockets.cpp b/sysdeps/aero/generic/sockets.cpp
-index 0cce3c0..10af36a 100644
---- a/sysdeps/aero/generic/sockets.cpp
-+++ b/sysdeps/aero/generic/sockets.cpp
-@@ -221,6 +221,22 @@ int sys_setsockopt(int fd, int layer, int number, const void *buffer,
- }
- }
-
-+int sys_peername(int fd, struct sockaddr *addr_ptr, socklen_t max_addr_length, socklen_t *actual_length) {
-+ auto ret = syscall(SYS_GETPEERNAME, fd, addr_ptr, &max_addr_length);
-+ if (int e = sc_error(ret); e)
-+ return e;
-+ *actual_length = max_addr_length;
-+ return 0;
-+}
-+
-+int sys_sockname(int fd, struct sockaddr *addr_ptr, socklen_t max_addr_length, socklen_t *actual_length) {
-+ auto ret = syscall(SYS_GETSOCKNAME, fd, addr_ptr, &max_addr_length);
-+ if (int e = sc_error(ret); e)
-+ return e;
-+ *actual_length = max_addr_length;
-+ return 0;
-+}
-+
- int sys_shutdown(int sockfd, int how) {
- auto ret = syscall(SYS_SOCK_SHUTDOWN, sockfd, how);
- if(int e = sc_error(ret); e)
-diff --git a/sysdeps/aero/include/aero/syscall.h b/sysdeps/aero/include/aero/syscall.h
-index 3f36e4d..39c5b65 100644
---- a/sysdeps/aero/include/aero/syscall.h
-+++ b/sysdeps/aero/include/aero/syscall.h
-@@ -80,6 +80,8 @@
- #define SYS_SETSID 73
- #define SYS_GETPGID 74
- #define SYS_SOCK_SHUTDOWN 75
-+#define SYS_GETPEERNAME 76
-+#define SYS_GETSOCKNAME 77
-
- // Invalid syscall used to trigger a log error in the kernel (as a hint)
- // so, that we can implement the syscall in the kernel.
---
-2.42.0
-
diff --git a/src/Cargo.lock b/src/Cargo.lock
index 773f4b49eac..4cf67a98a94 100644
--- a/src/Cargo.lock
+++ b/src/Cargo.lock
@@ -52,6 +52,7 @@ dependencies = [
"byte_endian",
"num-derive",
"num-traits",
+ "static_assertions",
]
[[package]]
diff --git a/src/aero_kernel/src/drivers/pty.rs b/src/aero_kernel/src/drivers/pty.rs
index 9ecfb87709b..790765d49b4 100644
--- a/src/aero_kernel/src/drivers/pty.rs
+++ b/src/aero_kernel/src/drivers/pty.rs
@@ -330,11 +330,7 @@ impl devfs::Device for Ptmx {
}
impl INodeInterface for Ptmx {
- fn open(
- &self,
- _flags: aero_syscall::OpenFlags,
- _handle: Arc,
- ) -> fs::Result