1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
// Copyright (c) 2020 Xu Shaohua <shaohua@biofan.org>. All rights reserved. // Use of this source is governed by General Public License that can be found // in the LICENSE file. /// Error No. pub type Errno = i32; /// Syscall No. pub type Sysno = usize; pub const MAX_ERRNO: Errno = 4095; #[inline(always)] pub fn check_errno(ret: usize) -> Result<usize, Errno> { let reti = ret as isize; if reti < 0 && reti >= (-MAX_ERRNO) as isize { let reti = (-reti) as Errno; Err(reti) } else { Ok(ret) } }