mod.rs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. use crate::{
  2. header::{ctype, errno::*, stdlib::*},
  3. platform::{self, types::*},
  4. };
  5. #[no_mangle]
  6. pub extern "C" fn imaxabs(i: intmax_t) -> intmax_t {
  7. i.abs()
  8. }
  9. #[no_mangle]
  10. #[repr(C)]
  11. pub struct imaxdiv_t {
  12. quot: intmax_t,
  13. rem: intmax_t,
  14. }
  15. #[no_mangle]
  16. pub extern "C" fn imaxdiv(i: intmax_t, j: intmax_t) -> imaxdiv_t {
  17. imaxdiv_t {
  18. quot: i / j,
  19. rem: i % j,
  20. }
  21. }
  22. #[no_mangle]
  23. pub unsafe extern "C" fn strtoimax(
  24. s: *const c_char,
  25. endptr: *mut *mut c_char,
  26. base: c_int,
  27. ) -> intmax_t {
  28. strto_impl!(
  29. intmax_t,
  30. false,
  31. intmax_t::max_value(),
  32. intmax_t::min_value(),
  33. s,
  34. endptr,
  35. base
  36. )
  37. }
  38. #[no_mangle]
  39. pub unsafe extern "C" fn strtoumax(
  40. s: *const c_char,
  41. endptr: *mut *mut c_char,
  42. base: c_int,
  43. ) -> uintmax_t {
  44. strto_impl!(
  45. uintmax_t,
  46. false,
  47. uintmax_t::max_value(),
  48. uintmax_t::min_value(),
  49. s,
  50. endptr,
  51. base
  52. )
  53. }
  54. #[allow(unused)]
  55. // #[no_mangle]
  56. pub extern "C" fn wcstoimax(
  57. nptr: *const wchar_t,
  58. endptr: *mut *mut wchar_t,
  59. base: c_int,
  60. ) -> intmax_t {
  61. unimplemented!();
  62. }
  63. #[allow(unused)]
  64. // #[no_mangle]
  65. pub extern "C" fn wcstoumax(
  66. nptr: *const wchar_t,
  67. endptr: *mut *mut wchar_t,
  68. base: c_int,
  69. ) -> uintmax_t {
  70. unimplemented!();
  71. }