diff --git a/rules/errno/src.c b/rules/errno/src.c index 0e32ea0e..97ad40ce 100644 --- a/rules/errno/src.c +++ b/rules/errno/src.c @@ -4,3 +4,160 @@ #include int *f1(void) { return cpp2rust_errno(); } + +int f2(void) { return E2BIG; } +int f3(void) { return EACCES; } +int f4(void) { return EADDRINUSE; } +int f5(void) { return EADDRNOTAVAIL; } +int f6(void) { return EAFNOSUPPORT; } +int f7(void) { return EAGAIN; } +int f8(void) { return EALREADY; } +int f9(void) { return EBADF; } +int f10(void) { return EBADMSG; } +int f11(void) { return EBUSY; } +int f12(void) { return ECANCELED; } +int f13(void) { return ECHILD; } +int f14(void) { return ECONNABORTED; } +int f15(void) { return ECONNREFUSED; } +int f16(void) { return ECONNRESET; } +int f17(void) { return EDEADLK; } +int f18(void) { return EDESTADDRREQ; } +int f19(void) { return EDOM; } +int f20(void) { return EDQUOT; } +int f21(void) { return EEXIST; } +int f22(void) { return EFAULT; } +int f23(void) { return EFBIG; } +int f24(void) { return EHOSTDOWN; } +int f25(void) { return EHOSTUNREACH; } +int f26(void) { return EIDRM; } +int f27(void) { return EILSEQ; } +int f28(void) { return EINPROGRESS; } +int f29(void) { return EINTR; } +int f30(void) { return EINVAL; } +int f31(void) { return EIO; } +int f32(void) { return EISCONN; } +int f33(void) { return EISDIR; } +int f34(void) { return ELOOP; } +int f35(void) { return EMFILE; } +int f36(void) { return EMLINK; } +int f37(void) { return EMSGSIZE; } +int f38(void) { return EMULTIHOP; } +int f39(void) { return ENAMETOOLONG; } +int f40(void) { return ENETDOWN; } +int f41(void) { return ENETRESET; } +int f42(void) { return ENETUNREACH; } +int f43(void) { return ENFILE; } +int f44(void) { return ENOBUFS; } +int f45(void) { return ENODATA; } +int f46(void) { return ENODEV; } +int f47(void) { return ENOENT; } +int f48(void) { return ENOEXEC; } +int f49(void) { return ENOLCK; } +int f50(void) { return ENOLINK; } +int f51(void) { return ENOMEM; } +int f52(void) { return ENOMSG; } +int f53(void) { return ENOPROTOOPT; } +int f54(void) { return ENOSPC; } +int f55(void) { return ENOSR; } +int f56(void) { return ENOSTR; } +int f57(void) { return ENOSYS; } +int f58(void) { return ENOTCONN; } +int f59(void) { return ENOTDIR; } +int f60(void) { return ENOTEMPTY; } +int f61(void) { return ENOTRECOVERABLE; } +int f62(void) { return ENOTSOCK; } +int f63(void) { return ENOTSUP; } +int f64(void) { return ENOTBLK; } +int f65(void) { return ENOTTY; } +int f66(void) { return ENXIO; } +int f67(void) { return EOPNOTSUPP; } +int f68(void) { return EOVERFLOW; } +int f69(void) { return EOWNERDEAD; } +int f70(void) { return EPERM; } +int f71(void) { return EPFNOSUPPORT; } +int f72(void) { return EPIPE; } +int f73(void) { return EPROTO; } +int f74(void) { return EPROTONOSUPPORT; } +int f75(void) { return EPROTOTYPE; } +int f76(void) { return ERANGE; } +int f77(void) { return EREMOTE; } +int f78(void) { return EROFS; } +int f79(void) { return ESHUTDOWN; } +int f80(void) { return ESOCKTNOSUPPORT; } +int f81(void) { return ESPIPE; } +int f82(void) { return ESRCH; } +int f83(void) { return ESTALE; } +int f84(void) { return ETIME; } +int f85(void) { return ETIMEDOUT; } +int f86(void) { return ETOOMANYREFS; } +int f87(void) { return ETXTBSY; } +int f88(void) { return EUSERS; } +int f89(void) { return EWOULDBLOCK; } +int f90(void) { return EXDEV; } + +#if defined(__linux__) +int f91(void) { return EADV; } +int f92(void) { return EBADE; } +int f93(void) { return EBADFD; } +int f94(void) { return EBADR; } +int f95(void) { return EBADRQC; } +int f96(void) { return EBADSLT; } +int f97(void) { return EBFONT; } +int f98(void) { return ECHRNG; } +int f99(void) { return ECOMM; } +int f100(void) { return EDEADLOCK; } +int f101(void) { return EDOTDOT; } +int f102(void) { return EHWPOISON; } +int f103(void) { return EISNAM; } +int f104(void) { return EKEYEXPIRED; } +int f105(void) { return EKEYREJECTED; } +int f106(void) { return EKEYREVOKED; } +int f107(void) { return EL2HLT; } +int f108(void) { return EL2NSYNC; } +int f109(void) { return EL3HLT; } +int f110(void) { return EL3RST; } +int f111(void) { return ELIBACC; } +int f112(void) { return ELIBBAD; } +int f113(void) { return ELIBEXEC; } +int f114(void) { return ELIBMAX; } +int f115(void) { return ELIBSCN; } +int f116(void) { return ELNRNG; } +int f117(void) { return EMEDIUMTYPE; } +int f118(void) { return ENAVAIL; } +int f119(void) { return ENOANO; } +int f120(void) { return ENOCSI; } +int f121(void) { return ENOKEY; } +int f122(void) { return ENOMEDIUM; } +int f123(void) { return ENONET; } +int f124(void) { return ENOPKG; } +int f125(void) { return ENOTNAM; } +int f126(void) { return ENOTUNIQ; } +int f127(void) { return EREMCHG; } +int f128(void) { return EREMOTEIO; } +int f129(void) { return ERESTART; } +int f130(void) { return ERFKILL; } +int f131(void) { return ESRMNT; } +int f132(void) { return ESTRPIPE; } +int f133(void) { return EUCLEAN; } +int f134(void) { return EUNATCH; } +int f135(void) { return EXFULL; } +#elif defined(__APPLE__) +int f136(void) { return EAUTH; } +int f137(void) { return EBADARCH; } +int f138(void) { return EBADEXEC; } +int f139(void) { return EBADMACHO; } +int f140(void) { return EBADRPC; } +int f141(void) { return EDEVERR; } +int f142(void) { return EFTYPE; } +int f143(void) { return ENEEDAUTH; } +int f144(void) { return ENOATTR; } +int f145(void) { return ENOPOLICY; } +int f146(void) { return EPROCLIM; } +int f147(void) { return EPROCUNAVAIL; } +int f148(void) { return EPROGMISMATCH; } +int f149(void) { return EPROGUNAVAIL; } +int f150(void) { return EPWROFF; } +int f151(void) { return EQFULL; } +int f152(void) { return ERPCMISMATCH; } +int f153(void) { return ESHLIBVERS; } +#endif diff --git a/rules/errno/tgt_unsafe.rs b/rules/errno/tgt_unsafe.rs index 1e2cc13f..8e59637e 100644 --- a/rules/errno/tgt_unsafe.rs +++ b/rules/errno/tgt_unsafe.rs @@ -4,3 +4,674 @@ unsafe fn f1() -> *mut i32 { libcc2rs::cpp2rust_errno_unsafe() } + +unsafe fn f2() -> i32 { + libc::E2BIG +} + +unsafe fn f3() -> i32 { + libc::EACCES +} + +unsafe fn f4() -> i32 { + libc::EADDRINUSE +} + +unsafe fn f5() -> i32 { + libc::EADDRNOTAVAIL +} + +unsafe fn f6() -> i32 { + libc::EAFNOSUPPORT +} + +unsafe fn f7() -> i32 { + libc::EAGAIN +} + +unsafe fn f8() -> i32 { + libc::EALREADY +} + +unsafe fn f9() -> i32 { + libc::EBADF +} + +unsafe fn f10() -> i32 { + libc::EBADMSG +} + +unsafe fn f11() -> i32 { + libc::EBUSY +} + +unsafe fn f12() -> i32 { + libc::ECANCELED +} + +unsafe fn f13() -> i32 { + libc::ECHILD +} + +unsafe fn f14() -> i32 { + libc::ECONNABORTED +} + +unsafe fn f15() -> i32 { + libc::ECONNREFUSED +} + +unsafe fn f16() -> i32 { + libc::ECONNRESET +} + +unsafe fn f17() -> i32 { + libc::EDEADLK +} + +unsafe fn f18() -> i32 { + libc::EDESTADDRREQ +} + +unsafe fn f19() -> i32 { + libc::EDOM +} + +unsafe fn f20() -> i32 { + libc::EDQUOT +} + +unsafe fn f21() -> i32 { + libc::EEXIST +} + +unsafe fn f22() -> i32 { + libc::EFAULT +} + +unsafe fn f23() -> i32 { + libc::EFBIG +} + +unsafe fn f24() -> i32 { + libc::EHOSTDOWN +} + +unsafe fn f25() -> i32 { + libc::EHOSTUNREACH +} + +unsafe fn f26() -> i32 { + libc::EIDRM +} + +unsafe fn f27() -> i32 { + libc::EILSEQ +} + +unsafe fn f28() -> i32 { + libc::EINPROGRESS +} + +unsafe fn f29() -> i32 { + libc::EINTR +} + +unsafe fn f30() -> i32 { + libc::EINVAL +} + +unsafe fn f31() -> i32 { + libc::EIO +} + +unsafe fn f32() -> i32 { + libc::EISCONN +} + +unsafe fn f33() -> i32 { + libc::EISDIR +} + +unsafe fn f34() -> i32 { + libc::ELOOP +} + +unsafe fn f35() -> i32 { + libc::EMFILE +} + +unsafe fn f36() -> i32 { + libc::EMLINK +} + +unsafe fn f37() -> i32 { + libc::EMSGSIZE +} + +unsafe fn f38() -> i32 { + libc::EMULTIHOP +} + +unsafe fn f39() -> i32 { + libc::ENAMETOOLONG +} + +unsafe fn f40() -> i32 { + libc::ENETDOWN +} + +unsafe fn f41() -> i32 { + libc::ENETRESET +} + +unsafe fn f42() -> i32 { + libc::ENETUNREACH +} + +unsafe fn f43() -> i32 { + libc::ENFILE +} + +unsafe fn f44() -> i32 { + libc::ENOBUFS +} + +unsafe fn f45() -> i32 { + libc::ENODATA +} + +unsafe fn f46() -> i32 { + libc::ENODEV +} + +unsafe fn f47() -> i32 { + libc::ENOENT +} + +unsafe fn f48() -> i32 { + libc::ENOEXEC +} + +unsafe fn f49() -> i32 { + libc::ENOLCK +} + +unsafe fn f50() -> i32 { + libc::ENOLINK +} + +unsafe fn f51() -> i32 { + libc::ENOMEM +} + +unsafe fn f52() -> i32 { + libc::ENOMSG +} + +unsafe fn f53() -> i32 { + libc::ENOPROTOOPT +} + +unsafe fn f54() -> i32 { + libc::ENOSPC +} + +unsafe fn f55() -> i32 { + libc::ENOSR +} + +unsafe fn f56() -> i32 { + libc::ENOSTR +} + +unsafe fn f57() -> i32 { + libc::ENOSYS +} + +unsafe fn f58() -> i32 { + libc::ENOTCONN +} + +unsafe fn f59() -> i32 { + libc::ENOTDIR +} + +unsafe fn f60() -> i32 { + libc::ENOTEMPTY +} + +unsafe fn f61() -> i32 { + libc::ENOTRECOVERABLE +} + +unsafe fn f62() -> i32 { + libc::ENOTSOCK +} + +unsafe fn f63() -> i32 { + libc::ENOTSUP +} + +unsafe fn f64() -> i32 { + libc::ENOTBLK +} + +unsafe fn f65() -> i32 { + libc::ENOTTY +} + +unsafe fn f66() -> i32 { + libc::ENXIO +} + +unsafe fn f67() -> i32 { + libc::EOPNOTSUPP +} + +unsafe fn f68() -> i32 { + libc::EOVERFLOW +} + +unsafe fn f69() -> i32 { + libc::EOWNERDEAD +} + +unsafe fn f70() -> i32 { + libc::EPERM +} + +unsafe fn f71() -> i32 { + libc::EPFNOSUPPORT +} + +unsafe fn f72() -> i32 { + libc::EPIPE +} + +unsafe fn f73() -> i32 { + libc::EPROTO +} + +unsafe fn f74() -> i32 { + libc::EPROTONOSUPPORT +} + +unsafe fn f75() -> i32 { + libc::EPROTOTYPE +} + +unsafe fn f76() -> i32 { + libc::ERANGE +} + +unsafe fn f77() -> i32 { + libc::EREMOTE +} + +unsafe fn f78() -> i32 { + libc::EROFS +} + +unsafe fn f79() -> i32 { + libc::ESHUTDOWN +} + +unsafe fn f80() -> i32 { + libc::ESOCKTNOSUPPORT +} + +unsafe fn f81() -> i32 { + libc::ESPIPE +} + +unsafe fn f82() -> i32 { + libc::ESRCH +} + +unsafe fn f83() -> i32 { + libc::ESTALE +} + +unsafe fn f84() -> i32 { + libc::ETIME +} + +unsafe fn f85() -> i32 { + libc::ETIMEDOUT +} + +unsafe fn f86() -> i32 { + libc::ETOOMANYREFS +} + +unsafe fn f87() -> i32 { + libc::ETXTBSY +} + +unsafe fn f88() -> i32 { + libc::EUSERS +} + +unsafe fn f89() -> i32 { + libc::EWOULDBLOCK +} + +unsafe fn f90() -> i32 { + libc::EXDEV +} + +#[cfg(target_os = "linux")] +unsafe fn f91() -> i32 { + libc::EADV +} + +#[cfg(target_os = "linux")] +unsafe fn f92() -> i32 { + libc::EBADE +} + +#[cfg(target_os = "linux")] +unsafe fn f93() -> i32 { + libc::EBADFD +} + +#[cfg(target_os = "linux")] +unsafe fn f94() -> i32 { + libc::EBADR +} + +#[cfg(target_os = "linux")] +unsafe fn f95() -> i32 { + libc::EBADRQC +} + +#[cfg(target_os = "linux")] +unsafe fn f96() -> i32 { + libc::EBADSLT +} + +#[cfg(target_os = "linux")] +unsafe fn f97() -> i32 { + libc::EBFONT +} + +#[cfg(target_os = "linux")] +unsafe fn f98() -> i32 { + libc::ECHRNG +} + +#[cfg(target_os = "linux")] +unsafe fn f99() -> i32 { + libc::ECOMM +} + +#[cfg(target_os = "linux")] +unsafe fn f100() -> i32 { + libc::EDEADLOCK +} + +#[cfg(target_os = "linux")] +unsafe fn f101() -> i32 { + libc::EDOTDOT +} + +#[cfg(target_os = "linux")] +unsafe fn f102() -> i32 { + libc::EHWPOISON +} + +#[cfg(target_os = "linux")] +unsafe fn f103() -> i32 { + libc::EISNAM +} + +#[cfg(target_os = "linux")] +unsafe fn f104() -> i32 { + libc::EKEYEXPIRED +} + +#[cfg(target_os = "linux")] +unsafe fn f105() -> i32 { + libc::EKEYREJECTED +} + +#[cfg(target_os = "linux")] +unsafe fn f106() -> i32 { + libc::EKEYREVOKED +} + +#[cfg(target_os = "linux")] +unsafe fn f107() -> i32 { + libc::EL2HLT +} + +#[cfg(target_os = "linux")] +unsafe fn f108() -> i32 { + libc::EL2NSYNC +} + +#[cfg(target_os = "linux")] +unsafe fn f109() -> i32 { + libc::EL3HLT +} + +#[cfg(target_os = "linux")] +unsafe fn f110() -> i32 { + libc::EL3RST +} + +#[cfg(target_os = "linux")] +unsafe fn f111() -> i32 { + libc::ELIBACC +} + +#[cfg(target_os = "linux")] +unsafe fn f112() -> i32 { + libc::ELIBBAD +} + +#[cfg(target_os = "linux")] +unsafe fn f113() -> i32 { + libc::ELIBEXEC +} + +#[cfg(target_os = "linux")] +unsafe fn f114() -> i32 { + libc::ELIBMAX +} + +#[cfg(target_os = "linux")] +unsafe fn f115() -> i32 { + libc::ELIBSCN +} + +#[cfg(target_os = "linux")] +unsafe fn f116() -> i32 { + libc::ELNRNG +} + +#[cfg(target_os = "linux")] +unsafe fn f117() -> i32 { + libc::EMEDIUMTYPE +} + +#[cfg(target_os = "linux")] +unsafe fn f118() -> i32 { + libc::ENAVAIL +} + +#[cfg(target_os = "linux")] +unsafe fn f119() -> i32 { + libc::ENOANO +} + +#[cfg(target_os = "linux")] +unsafe fn f120() -> i32 { + libc::ENOCSI +} + +#[cfg(target_os = "linux")] +unsafe fn f121() -> i32 { + libc::ENOKEY +} + +#[cfg(target_os = "linux")] +unsafe fn f122() -> i32 { + libc::ENOMEDIUM +} + +#[cfg(target_os = "linux")] +unsafe fn f123() -> i32 { + libc::ENONET +} + +#[cfg(target_os = "linux")] +unsafe fn f124() -> i32 { + libc::ENOPKG +} + +#[cfg(target_os = "linux")] +unsafe fn f125() -> i32 { + libc::ENOTNAM +} + +#[cfg(target_os = "linux")] +unsafe fn f126() -> i32 { + libc::ENOTUNIQ +} + +#[cfg(target_os = "linux")] +unsafe fn f127() -> i32 { + libc::EREMCHG +} + +#[cfg(target_os = "linux")] +unsafe fn f128() -> i32 { + libc::EREMOTEIO +} + +#[cfg(target_os = "linux")] +unsafe fn f129() -> i32 { + libc::ERESTART +} + +#[cfg(target_os = "linux")] +unsafe fn f130() -> i32 { + libc::ERFKILL +} + +#[cfg(target_os = "linux")] +unsafe fn f131() -> i32 { + libc::ESRMNT +} + +#[cfg(target_os = "linux")] +unsafe fn f132() -> i32 { + libc::ESTRPIPE +} + +#[cfg(target_os = "linux")] +unsafe fn f133() -> i32 { + libc::EUCLEAN +} + +#[cfg(target_os = "linux")] +unsafe fn f134() -> i32 { + libc::EUNATCH +} + +#[cfg(target_os = "linux")] +unsafe fn f135() -> i32 { + libc::EXFULL +} + +#[cfg(target_os = "macos")] +unsafe fn f136() -> i32 { + libc::EAUTH +} + +#[cfg(target_os = "macos")] +unsafe fn f137() -> i32 { + libc::EBADARCH +} + +#[cfg(target_os = "macos")] +unsafe fn f138() -> i32 { + libc::EBADEXEC +} + +#[cfg(target_os = "macos")] +unsafe fn f139() -> i32 { + libc::EBADMACHO +} + +#[cfg(target_os = "macos")] +unsafe fn f140() -> i32 { + libc::EBADRPC +} + +#[cfg(target_os = "macos")] +unsafe fn f141() -> i32 { + libc::EDEVERR +} + +#[cfg(target_os = "macos")] +unsafe fn f142() -> i32 { + libc::EFTYPE +} + +#[cfg(target_os = "macos")] +unsafe fn f143() -> i32 { + libc::ENEEDAUTH +} + +#[cfg(target_os = "macos")] +unsafe fn f144() -> i32 { + libc::ENOATTR +} + +#[cfg(target_os = "macos")] +unsafe fn f145() -> i32 { + libc::ENOPOLICY +} + +#[cfg(target_os = "macos")] +unsafe fn f146() -> i32 { + libc::EPROCLIM +} + +#[cfg(target_os = "macos")] +unsafe fn f147() -> i32 { + libc::EPROCUNAVAIL +} + +#[cfg(target_os = "macos")] +unsafe fn f148() -> i32 { + libc::EPROGMISMATCH +} + +#[cfg(target_os = "macos")] +unsafe fn f149() -> i32 { + libc::EPROGUNAVAIL +} + +#[cfg(target_os = "macos")] +unsafe fn f150() -> i32 { + libc::EPWROFF +} + +#[cfg(target_os = "macos")] +unsafe fn f151() -> i32 { + libc::EQFULL +} + +#[cfg(target_os = "macos")] +unsafe fn f152() -> i32 { + libc::ERPCMISMATCH +} + +#[cfg(target_os = "macos")] +unsafe fn f153() -> i32 { + libc::ESHLIBVERS +} diff --git a/tests/unit/out/refcount/errno.rs b/tests/unit/out/refcount/errno.rs index 5960da10..a326cca0 100644 --- a/tests/unit/out/refcount/errno.rs +++ b/tests/unit/out/refcount/errno.rs @@ -46,7 +46,7 @@ pub fn test_errno_from_fseek_2() { }, )); assert!(((((*r.borrow()) == -1_i32) as i32) != 0)); - assert!(((((libcc2rs::cpp2rust_errno().read()) == 29) as i32) != 0)); + assert!(((((libcc2rs::cpp2rust_errno().read()) == libc::ESPIPE) as i32) != 0)); libcc2rs::cpp2rust_errno().write(0); } pub fn main() { diff --git a/tests/unit/out/unsafe/errno.rs b/tests/unit/out/unsafe/errno.rs index 0e36fbbb..41eda988 100644 --- a/tests/unit/out/unsafe/errno.rs +++ b/tests/unit/out/unsafe/errno.rs @@ -28,7 +28,7 @@ pub unsafe fn test_errno_from_fseek_2() { (*libcc2rs::cpp2rust_errno_unsafe()) = 0; let mut r: i32 = libc::fseek(libcc2rs::stdin_unsafe(), 0_i64 as ::libc::c_long, 0); assert!(((((r) == (-1_i32)) as i32) != 0)); - assert!(((((*libcc2rs::cpp2rust_errno_unsafe()) == (29)) as i32) != 0)); + assert!(((((*libcc2rs::cpp2rust_errno_unsafe()) == (libc::ESPIPE)) as i32) != 0)); (*libcc2rs::cpp2rust_errno_unsafe()) = 0; } pub fn main() {