Skip to content

Commit 29891d1

Browse files
ZR233equation314SiyuanSun0736AsakuraMizu
authored
feat(starry): add test (#13)
* Publish v0.1.0 to crates.io * Fix broken links in README * Bump to v0.1.1 * add UrandomDev (#2) * Bump to v0.1.2 * feat: iofn * refactor: project structure, enhance basic traits * style: parameter name consistency * feat: probe maybe_uninit_slice * style: format code * feat: add BufWriter and LineWriter * docs: update README.md "Features" section for buffered * chore: remove BufReader::seek_relative * test: add unit tests * feat: IoBuf * ci: drop nightly-2025-05-20 * build: bump version to 0.3.0-pre.0 * chore: typo * feat: add utils * chore: explicit result type * refactor: reimplement BufReader * refactor: redesign IoBuf, add IoBufMut back * build: bump to 0.3.0-pre.1 * feat: add StarryOS build and run commands with configuration management * feat: add default AX_IP and AX_GW environment variables to build_env * feat: update axio version and refactor manifest directory handling in build process * feat: update axio repository branch to dev2 in repos.csv * Remove subtree components/axio before force re-add * feat: update axio and axpoll dependencies in Cargo.toml and Cargo.lock * feat: update axio repository branch to main in repos.csv * feat: add description for axfs_crates in repos.csv * feat: update axfs crates to version 0.1.2 and adjust workspace configuration * feat: update axerrno dependency to version 0.2 in multiple Cargo.toml files and improve error handling in memory allocation * fix(starry): map axfs/axnet to ng only for starry kernel * fix(axcpu): make aarch64 exception table PIE-safe * feat: add dynamic platform (plat-dyn) support in Arceos configuration and build arguments * feat: update dynamic platform support and improve test configurations --------- Co-authored-by: Yuekai Jia <equation618@gmail.com> Co-authored-by: Wanderlust <100674758+879650736@users.noreply.github.com> Co-authored-by: 朝倉水希 <asakuramizu111@gmail.com>
1 parent 9cdf2cc commit 29891d1

34 files changed

Lines changed: 4516 additions & 129 deletions

.github/workflows/check.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
ci:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
rust-toolchain:
12+
- nightly
13+
- nightly-2025-12-12
14+
- stable
15+
env:
16+
RUSTC_BOOTSTRAP: "${{ matrix.rust-toolchain == 'stable' && '1' || '' }}"
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: dtolnay/rust-toolchain@nightly
20+
with:
21+
toolchain: ${{ matrix.rust-toolchain }}
22+
components: rust-src, clippy, rustfmt
23+
- name: Check rust version
24+
run: rustc --version --verbose
25+
- name: Check code format
26+
run: cargo fmt --all --check
27+
28+
- uses: taiki-e/install-action@cargo-hack
29+
- name: Clippy
30+
run: cargo hack clippy --feature-powerset
31+
- name: Unit test
32+
run: cargo hack test --feature-powerset -- --nocapture
33+
34+
doc:
35+
runs-on: ubuntu-latest
36+
strategy:
37+
fail-fast: false
38+
permissions:
39+
contents: write
40+
env:
41+
default-branch: ${{ format('refs/heads/{0}', github.event.repository.default_branch) }}
42+
RUSTDOCFLAGS: -D rustdoc::broken_intra_doc_links -D missing-docs
43+
steps:
44+
- uses: actions/checkout@v4
45+
- uses: dtolnay/rust-toolchain@nightly
46+
- name: Build docs
47+
continue-on-error: ${{ github.ref != env.default-branch && github.event_name != 'pull_request' }}
48+
run: |
49+
cargo doc --no-deps --all-features
50+
printf '<meta http-equiv="refresh" content="0;url=%s/index.html">' $(cargo tree | head -1 | cut -d' ' -f1) > target/doc/index.html
51+
- name: Deploy to Github Pages
52+
if: ${{ github.ref == env.default-branch }}
53+
uses: JamesIves/github-pages-deploy-action@v4
54+
with:
55+
single-commit: true
56+
branch: gh-pages
57+
folder: target/doc

.github/workflows/docs.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "axio"
3-
version = "0.2.1"
3+
version = "0.3.0-pre.1"
44
edition = "2024"
55
authors = ["Yuekai Jia <equation618@gmail.com>"]
66
description = "`std::io` for `no_std` environment"
@@ -12,9 +12,8 @@ keywords = ["arceos", "io", "no-std"]
1212
categories = ["no-std"]
1313

1414
[features]
15-
default = []
1615
alloc = []
17-
continue-on-interrupt = []
16+
default = []
1817

1918
[dependencies]
2019
axerrno = "0.2"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Crates.io](https://img.shields.io/crates/v/axio)](https://crates.io/crates/axio)
44
[![Docs.rs](https://docs.rs/axio/badge.svg)](https://docs.rs/axio)
5-
[![CI](https://github.com/arceos-org/axio/actions/workflows/check.yml/badge.svg?branch=main)](https://github.com/arceos-org/axio/actions/workflows/check.yml)
5+
[![CI](https://github.com/arceos-org/axio/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/arceos-org/axio/actions/workflows/ci.yml)
66

77
[`std::io`][1] for `no_std` environment.
88

build.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::{env, fs, path::PathBuf};
2-
31
fn main() {
42
autocfg::rerun_path("build.rs");
53

@@ -27,16 +25,4 @@ fn main() {
2725
if ac.probe_raw(code).is_ok() {
2826
autocfg::emit("maybe_uninit_slice");
2927
}
30-
31-
let buf_size = env::var("AXIO_DEFAULT_BUF_SIZE")
32-
.map(|v| v.parse::<usize>().expect("Invalid AXIO_DEFAULT_BUF_SIZE"))
33-
.unwrap_or(1024 * 2);
34-
fs::write(
35-
PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("config.rs"),
36-
format!(
37-
"/// Default buffer size for I/O operations.\npub const DEFAULT_BUF_SIZE: usize = {};",
38-
buf_size
39-
),
40-
)
41-
.expect("Failed to write config file");
4228
}

src/buffered/bufreader/buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl Buffer {
5454

5555
#[inline]
5656
pub fn buffer(&self) -> &[u8] {
57-
// SAFETY: self.pos and self.filled are valid, and self.filled >= self.pos, and
57+
// SAFETY: self.pos and self.filled are valid, and self.filled => self.pos, and
5858
// that region is initialized because those are all invariants of this type.
5959
unsafe {
6060
self.buf

src/buffered/bufreader/mod.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use core::{fmt, io::BorrowedCursor};
77
use self::buffer::Buffer;
88
#[cfg(feature = "alloc")]
99
use crate::Error;
10-
use crate::{BufRead, DEFAULT_BUF_SIZE, Read, Result, Seek, SeekFrom};
10+
use crate::{BufRead, DEFAULT_BUF_SIZE, IoBuf, Read, Result, Seek, SeekFrom};
1111

1212
/// The `BufReader<R>` struct adds buffering to any reader.
1313
///
@@ -83,6 +83,11 @@ impl<R: ?Sized> BufReader<R> {
8383
pub(crate) fn discard_buffer(&mut self) {
8484
self.buf.discard_buffer()
8585
}
86+
87+
#[inline]
88+
pub(crate) fn consume(&mut self, amt: usize) {
89+
self.buf.consume(amt)
90+
}
8691
}
8792

8893
impl<R: Read + ?Sized> BufReader<R> {
@@ -338,3 +343,10 @@ impl<R: ?Sized + Seek> Seek for BufReader<R> {
338343
self.seek(SeekFrom::Current(offset)).map(drop)
339344
}
340345
}
346+
347+
impl<R: ?Sized + IoBuf> IoBuf for BufReader<R> {
348+
#[inline]
349+
fn remaining(&self) -> usize {
350+
self.inner.remaining() + self.buf.filled() - self.buf.pos()
351+
}
352+
}

src/buffered/bufwriter/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use core::{fmt, mem::ManuallyDrop, ptr};
22

3-
use crate::{DEFAULT_BUF_SIZE, Error, IntoInnerError, Result, Seek, SeekFrom, Write};
3+
use crate::{DEFAULT_BUF_SIZE, Error, IntoInnerError, IoBufMut, Result, Seek, SeekFrom, Write};
44

55
#[cfg(feature = "alloc")]
66
type Buffer = alloc::vec::Vec<u8>;
@@ -139,6 +139,10 @@ impl<W: ?Sized + Write> BufWriter<W> {
139139
self.buf.capacity()
140140
}
141141

142+
pub(crate) fn buffer_mut(&mut self) -> &mut Buffer {
143+
&mut self.buf
144+
}
145+
142146
/// Send data in our local buffer into the inner writer, looping as
143147
/// necessary until either it's all been sent or an error occurs.
144148
///
@@ -384,3 +388,10 @@ impl<W: ?Sized + Write> Drop for BufWriter<W> {
384388
}
385389
}
386390
}
391+
392+
impl<W: ?Sized + Write + IoBufMut> IoBufMut for BufWriter<W> {
393+
#[inline]
394+
fn remaining_mut(&self) -> usize {
395+
self.inner.remaining_mut().saturating_sub(self.buf.len())
396+
}
397+
}

src/buffered/linewriter/mod.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ mod shim;
33
use core::fmt;
44

55
use self::shim::LineWriterShim;
6-
use crate::{BufWriter, IntoInnerError, Result, Write};
7-
8-
/// Wraps a writer and buffers output to it, flushing whenever a newline
9-
/// (`0x0a`, `'\n'`) is detected.
10-
///
6+
use crate::{BufWriter, IntoInnerError, IoBufMut, Result, Write};
117
/// The [`BufWriter`] struct wraps a writer and buffers its output.
128
/// But it only does this batched write when it goes out of scope, or when the
139
/// internal buffer is full. Sometimes, you'd prefer to write each line as it's
@@ -101,3 +97,10 @@ impl<W: ?Sized + Write + fmt::Debug> fmt::Debug for LineWriter<W> {
10197
.finish_non_exhaustive()
10298
}
10399
}
100+
101+
impl<W: ?Sized + Write + IoBufMut> IoBufMut for LineWriter<W> {
102+
#[inline]
103+
fn remaining_mut(&self) -> usize {
104+
self.inner.remaining_mut()
105+
}
106+
}

0 commit comments

Comments
 (0)