Skip to content

Commit

Permalink
fix: ship custom cty that always assumes target_os = "windows"
Browse files Browse the repository at this point in the history
  • Loading branch information
oberrich committed Jan 13, 2025
1 parent 4857f47 commit a0f1505
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
$paths = @(
"$env:USERPROFILE\\.cargo\\bin", # Rust
"$env:ProgramFiles\\Git\\cmd", # Git
"$env:ProgramFiles\\Git\\bin", # Bash
"$env:ProgramFiles\\Git\\bin" # Bash
)

function Log { param([string]$Message, [string]$Level = "INFO")
Expand Down
2 changes: 1 addition & 1 deletion deps/phnt-nightly
Submodule phnt-nightly updated 1 files
+91 −61 smbios.h
2 changes: 1 addition & 1 deletion src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ mod regen {
.type_alias("NTSTATUS")
.opaque_type("std::.*")
.use_core()
.ctypes_prefix("::core::ffi")
.ctypes_prefix("crate::cty")
.parse_callbacks(Box::new(ProcessComments))
.default_enum_style(bindgen::EnumVariation::Rust {
non_exhaustive: true,
Expand Down
27 changes: 27 additions & 0 deletions src/cty/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

/// A `cty` implementation that always assumes `target_os = "windows"`.
/// Forked from `::core::ffi`
pub type c_void = ::core::ffi::c_void;


pub type c_char = i8; // Windows specific
pub type c_schar = i8;
pub type c_uchar = u8;
pub type c_short = i16;
pub type c_ushort = u16;

pub type c_int = i32; // Windows specific
pub type c_uint = u32; // Windows specific

pub type c_long = i32; // Windows specific
pub type c_ulong = u32; // Windows specific

pub type c_longlong = i64;
pub type c_ulonglong = u64;

pub type c_float = f32;
pub type c_double = f64;

pub type c_size_t = usize;
pub type c_ssize_t = isize;
pub type c_ptrdiff_t = isize;
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
// SOFTWARE.
//
#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![doc = include_str!("../README.md")]
#![allow(
warnings,
unused,
Expand All @@ -31,6 +29,12 @@
non_upper_case_globals
)]

#![cfg_attr(docsrs, feature(doc_cfg))]
#![doc = include_str!("../README.md")]

/// Re-export custom `cty` implementation for Windows headers
pub mod cty;

/// Bindings for `phnt` (nightly) generated by `bindgen`
pub mod ffi {
// use vendored bindings
Expand Down

0 comments on commit a0f1505

Please sign in to comment.