4
0

lib.rs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. #[cfg(target_arch = "bpf")]
  15. mod ad {
  16. pub type c_int = i32;
  17. pub type c_uint = u32;
  18. #[cfg(bpf_target_arch = "arm")]
  19. pub type c_char = super::c_uchar;
  20. #[cfg(bpf_target_arch = "aarch64")]
  21. pub type c_char = super::c_uchar;
  22. #[cfg(bpf_target_arch = "riscv64")]
  23. pub type c_char = super::c_uchar;
  24. #[cfg(any(bpf_target_arch = "x86", bpf_target_arch = "x86_64"))]
  25. pub type c_char = super::c_schar;
  26. #[cfg(all(not(bpf_target_arch), host_arch = "aarch64"))]
  27. pub type c_char = super::c_uchar;
  28. }
  29. #[cfg(any(
  30. target_arch = "aarch64",
  31. target_arch = "arm",
  32. target_arch = "asmjs",
  33. target_arch = "wasm32",
  34. target_arch = "wasm64",
  35. target_arch = "powerpc",
  36. target_arch = "powerpc64",
  37. target_arch = "s390x",
  38. target_arch = "riscv32",
  39. target_arch = "riscv64"
  40. ))]
  41. mod ad {
  42. pub type c_char = super::c_uchar;
  43. pub type c_int = i32;
  44. pub type c_uint = u32;
  45. }
  46. #[cfg(any(
  47. target_arch = "mips",
  48. target_arch = "mips64",
  49. target_arch = "sparc64",
  50. target_arch = "x86",
  51. target_arch = "x86_64",
  52. target_arch = "nvptx",
  53. target_arch = "nvptx64",
  54. target_arch = "xtensa"
  55. ))]
  56. mod ad {
  57. pub type c_char = super::c_schar;
  58. pub type c_int = i32;
  59. pub type c_uint = u32;
  60. }
  61. #[cfg(target_arch = "msp430")]
  62. mod ad {
  63. pub type c_char = super::c_uchar;
  64. pub type c_int = i16;
  65. pub type c_uint = u16;
  66. }
  67. // NOTE c_{,u}long definitions come from libc v0.2.3
  68. #[cfg(not(any(windows, target_os = "redox", target_os = "solaris")))]
  69. mod od {
  70. #[cfg(any(target_pointer_width = "16", target_pointer_width = "32"))]
  71. pub type c_long = i32;
  72. #[cfg(any(target_pointer_width = "16", target_pointer_width = "32"))]
  73. pub type c_ulong = u32;
  74. #[cfg(target_pointer_width = "64")]
  75. pub type c_long = i64;
  76. #[cfg(target_pointer_width = "64")]
  77. pub type c_ulong = u64;
  78. }
  79. #[cfg(windows)]
  80. mod od {
  81. pub type c_long = i32;
  82. pub type c_ulong = u32;
  83. }
  84. #[cfg(any(target_os = "redox", target_os = "solaris"))]
  85. mod od {
  86. pub type c_long = i64;
  87. pub type c_ulong = u64;
  88. }
  89. pub type int8_t = i8;
  90. pub type int16_t = i16;
  91. pub type int32_t = i32;
  92. pub type int64_t = i64;
  93. pub type uint8_t = u8;
  94. pub type uint16_t = u16;
  95. pub type uint32_t = u32;
  96. pub type uint64_t = u64;
  97. pub type c_schar = i8;
  98. pub type c_short = i16;
  99. pub type c_longlong = i64;
  100. pub type c_uchar = u8;
  101. pub type c_ushort = u16;
  102. pub type c_ulonglong = u64;
  103. pub type c_float = f32;
  104. pub type c_double = f64;
  105. pub type intmax_t = i64;
  106. pub type uintmax_t = u64;
  107. pub type size_t = usize;
  108. pub type ptrdiff_t = isize;
  109. pub type intptr_t = isize;
  110. pub type uintptr_t = usize;
  111. pub type ssize_t = isize;
  112. pub type c_void = core::ffi::c_void;