diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3c15efd3b..06c73bc6c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,12 +5,41 @@ on: - main concurrency: dev-${{ github.ref }} jobs: - windows: + build-windows: name: Build uses: ./.github/workflows/ci-windows.yml - linux: + build-linux: name: Build uses: ./.github/workflows/ci-linux.yml - mac: + build-mac: name: Build uses: ./.github/workflows/ci-mac.yml + housekeep: + name: Housekeep + runs-on: ubuntu-latest + steps: + - name: Update PRs + run: | + import { Octokit } from 'octokit'; + + const octokit = new Octokit({ auth: '${{ secrets.GITHUB_TOKEN }}' }); + const owner = '${{ github.event.repository.owner.login }}'; + const repo = '${{ github.event.repository.name }}'; + const resp = await octokit.request('GET /repos/{owner}/{repo}/pulls', { + owner, + repo, + base: '${{ github.ref_name }}', + sort: 'updated', + direction: 'desc', + per_page: 100, + }); + + for (const pull of resp.data) { + await octokit.request('POST /repos/{owner}/{repo}/issues/{issue_number}/labels', { + owner, + repo, + issue_number: pull.number, + labels: ['B-out-of-date'], + }); + } + shell: node --input-type=module {0} diff --git a/src/kernel/src/errno.rs b/src/kernel/src/errno.rs index c569feb12..87d404f65 100644 --- a/src/kernel/src/errno.rs +++ b/src/kernel/src/errno.rs @@ -14,7 +14,7 @@ macro_rules! error_numbers { }; )* - pub fn strerror_impl(num: NonZeroI32) -> &'static str { + fn strerror_impl(num: NonZeroI32) -> &'static str { match num { $( $name => $desc, )* _ => todo!("strerror {num}", num = num.get()), diff --git a/src/kernel/src/signal/mod.rs b/src/kernel/src/signal/mod.rs index 5fc06c878..9b32b2a04 100644 --- a/src/kernel/src/signal/mod.rs +++ b/src/kernel/src/signal/mod.rs @@ -11,7 +11,7 @@ mod set; pub struct Signal(NonZeroI32); impl Signal { - pub fn new(raw: i32) -> Option { + pub const fn new(raw: i32) -> Option { match raw { 1..=SIG_MAXSIG => Some(Signal(unsafe { NonZeroI32::new_unchecked(raw) })), _ => None, @@ -27,13 +27,13 @@ macro_rules! signals { ($($name:ident($num:expr),)*) => { $( #[allow(dead_code)] - pub const $name: Signal = Signal(unsafe { - assert!($num > 0 && $num <= SIG_MAXSIG); - NonZeroI32::new_unchecked($num) - }); + pub const $name: Signal = match Signal::new($num) { + Some(sig) => sig, + None => panic!(), + }; )* - pub fn strsignal_impl(sig: Signal) -> Cow<'static, str> { + fn strsignal_impl(sig: Signal) -> Cow<'static, str> { match sig.0.get() { $( $num => Cow::Borrowed(stringify!($name)), )* _ => format!("{sig}", sig = sig.get()).into(), @@ -43,8 +43,8 @@ macro_rules! signals { } // List of PS4 signals. The value must be the same as PS4 kernel. -#[rustfmt::skip] -signals!( + +signals! { SIGHUP(1), SIGINT(2), SIGQUIT(3), @@ -78,7 +78,7 @@ signals!( SIGUSR2(31), SIGTHR(32), SIGNONE(128), -); +} pub fn strsignal(sig: Signal) -> Cow<'static, str> { // This function is generated inside the macro `signals!`. @@ -109,10 +109,9 @@ impl Iterator for SignalIter { type Item = Signal; fn next(&mut self) -> Option { - if self.current <= SIG_MAXSIG { - let signal = Signal(unsafe { NonZeroI32::new_unchecked(self.current) }); + if let Some(sig) = Signal::new(self.current) { self.current += 1; - Some(signal) + Some(sig) } else { None } diff --git a/src/kernel/src/signal/set.rs b/src/kernel/src/signal/set.rs index e9bef9cb8..0d52a2266 100644 --- a/src/kernel/src/signal/set.rs +++ b/src/kernel/src/signal/set.rs @@ -33,7 +33,7 @@ impl SignalSet { /// An implementation of `_SIG_WORD`. fn word(s: Signal) -> usize { // This is safe because `Signal` is guaranteed to be non-negative. - unsafe { (Self::idx(s) >> 5).try_into().unwrap_unchecked() } + unsafe { (Self::idx(s) >> 5).try_into().unwrap() } } /// An implementation of `_SIG_BIT`.