lib.rs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //! Type aliases to C types like c_int for use with bindgen
  2. //!
  3. //! # MSRV
  4. //!
  5. //! This crate is guaranteed to compile on stable Rust 1.30.0 and up. It *might* compile with older
  6. //! versions but that may change in any new patch release.
  7. #![no_std]
  8. #![allow(non_camel_case_types)]
  9. #![deny(warnings)]
  10. // AD = Architecture dependent
  11. pub use ad::*;
  12. // OD = OS dependent
  13. pub use od::*;
  14. // PWD = Pointer Width Dependent
  15. pub use pwd::*;
  16. #[cfg(any(target_arch = "bpf"))]
  17. mod ad {
  18. pub type c_int = i32;
  19. pub type c_uint = u32;
  20. #[cfg(bpf_target_arch = "aarch64")]
  21. pub type c_char = super::c_uchar;
  22. #[cfg(any(bpf_target_arch = "x86", bpf_target_arch = "x86_64"))]
  23. pub type c_char = super::c_schar;
  24. #[cfg(all(not(bpf_target_arch), host_arch = "aarch64"))]
  25. pub type c_char = super::c_uchar;
  26. }
  27. #[cfg(any(
  28. target_arch = "aarch64",
  29. target_arch = "arm",
  30. target_arch = "asmjs",
  31. target_arch = "wasm32",
  32. target_arch = "wasm64",
  33. target_arch = "powerpc",
  34. target_arch = "powerpc64",
  35. target_arch = "s390x",
  36. target_arch = "riscv32",
  37. target_arch = "riscv64"
  38. ))]
  39. mod ad {
  40. pub type c_char = ::c_uchar;
  41. pub type c_int = i32;
  42. pub type c_uint = u32;
  43. }
  44. #[cfg(any(
  45. target_arch = "mips",
  46. target_arch = "mips64",
  47. target_arch = "sparc64",
  48. target_arch = "x86",
  49. target_arch = "x86_64",
  50. target_arch = "nvptx",
  51. target_arch = "nvptx64",
  52. target_arch = "xtensa"
  53. ))]
  54. mod ad {
  55. pub type c_char = ::c_schar;
  56. pub type c_int = i32;
  57. pub type c_uint = u32;
  58. }
  59. #[cfg(target_arch = "msp430")]
  60. mod ad {
  61. pub type c_char = ::c_uchar;
  62. pub type c_int = i16;
  63. pub type c_uint = u16;
  64. }
  65. // NOTE c_{,u}long definitions come from libc v0.2.3
  66. #[cfg(not(any(windows, target_os = "redox", target_os = "solaris")))]
  67. mod od {
  68. #[cfg(any(target_pointer_width = "16", target_pointer_width = "32"))]
  69. pub type c_long = i32;
  70. #[cfg(any(target_pointer_width = "16", target_pointer_width = "32"))]
  71. pub type c_ulong = u32;
  72. #[cfg(target_pointer_width = "64")]
  73. pub type c_long = i64;
  74. #[cfg(target_pointer_width = "64")]
  75. pub type c_ulong = u64;
  76. }
  77. #[cfg(windows)]
  78. mod od {
  79. pub type c_long = i32;
  80. pub type c_ulong = u32;
  81. }
  82. #[cfg(any(target_os = "redox", target_os = "solaris"))]
  83. mod od {
  84. pub type c_long = i64;
  85. pub type c_ulong = u64;
  86. }
  87. #[cfg(target_pointer_width = "32")]
  88. mod pwd {}
  89. #[cfg(target_pointer_width = "64")]
  90. mod pwd {}
  91. pub type int8_t = i8;
  92. pub type int16_t = i16;
  93. pub type int32_t = i32;
  94. pub type int64_t = i64;
  95. pub type uint8_t = u8;
  96. pub type uint16_t = u16;
  97. pub type uint32_t = u32;
  98. pub type uint64_t = u64;
  99. pub type c_schar = i8;
  100. pub type c_short = i16;
  101. pub type c_longlong = i64;
  102. pub type c_uchar = u8;
  103. pub type c_ushort = u16;
  104. pub type c_ulonglong = u64;
  105. pub type c_float = f32;
  106. pub type c_double = f64;
  107. pub type intmax_t = i64;
  108. pub type uintmax_t = u64;
  109. pub type size_t = usize;
  110. pub type ptrdiff_t = isize;
  111. pub type intptr_t = isize;
  112. pub type uintptr_t = usize;
  113. pub type ssize_t = isize;
  114. pub type c_void = core::ffi::c_void;