lib.rs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 = "powerpc64")]
  23. pub type c_char = super::c_uchar;
  24. #[cfg(bpf_target_arch = "riscv64")]
  25. pub type c_char = super::c_uchar;
  26. #[cfg(bpf_target_arch = "s390x")]
  27. pub type c_char = super::c_uchar;
  28. #[cfg(bpf_target_arch = "x86_64")]
  29. pub type c_char = super::c_schar;
  30. }
  31. #[cfg(any(
  32. target_arch = "aarch64",
  33. target_arch = "arm",
  34. target_arch = "asmjs",
  35. target_arch = "wasm32",
  36. target_arch = "wasm64",
  37. target_arch = "powerpc",
  38. target_arch = "powerpc64",
  39. target_arch = "s390x",
  40. target_arch = "riscv32",
  41. target_arch = "riscv64"
  42. ))]
  43. mod ad {
  44. pub type c_char = super::c_uchar;
  45. pub type c_int = i32;
  46. pub type c_uint = u32;
  47. }
  48. #[cfg(any(
  49. target_arch = "mips",
  50. target_arch = "mips64",
  51. target_arch = "sparc64",
  52. target_arch = "x86",
  53. target_arch = "x86_64",
  54. target_arch = "nvptx",
  55. target_arch = "nvptx64",
  56. target_arch = "xtensa"
  57. ))]
  58. mod ad {
  59. pub type c_char = super::c_schar;
  60. pub type c_int = i32;
  61. pub type c_uint = u32;
  62. }
  63. #[cfg(target_arch = "msp430")]
  64. mod ad {
  65. pub type c_char = super::c_uchar;
  66. pub type c_int = i16;
  67. pub type c_uint = u16;
  68. }
  69. // NOTE c_{,u}long definitions come from libc v0.2.3
  70. #[cfg(not(any(windows, target_os = "redox", target_os = "solaris")))]
  71. mod od {
  72. #[cfg(any(target_pointer_width = "16", target_pointer_width = "32"))]
  73. pub type c_long = i32;
  74. #[cfg(any(target_pointer_width = "16", target_pointer_width = "32"))]
  75. pub type c_ulong = u32;
  76. #[cfg(target_pointer_width = "64")]
  77. pub type c_long = i64;
  78. #[cfg(target_pointer_width = "64")]
  79. pub type c_ulong = u64;
  80. }
  81. #[cfg(windows)]
  82. mod od {
  83. pub type c_long = i32;
  84. pub type c_ulong = u32;
  85. }
  86. #[cfg(any(target_os = "redox", target_os = "solaris"))]
  87. mod od {
  88. pub type c_long = i64;
  89. pub type c_ulong = u64;
  90. }
  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;