Skip to content

Commit dc77410

Browse files
charliekclaude
andcommitted
fix: make render-state enum reads signedness-agnostic across platforms
The bump commit assumed GHOSTTY_ENUM_TYPED uniformly emits `: int`; in reality only Apple clang enables the c_fixed_enum extension in default C mode, so on Linux bindgen still infers c_uint for the non-negative render-state enums and the c_int-shaped read_enum plumbing failed to compile (three E0308s, caught by the shed Linux verification before CI). The ABI is a 4-byte write either way: keep the c_int read and cast at the alias boundary with `as _`, which is correct under either signedness, and document the divergence on read_enum. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VVNzooL9ww3TgdMo1UABzb
1 parent 2f190cf commit dc77410

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

crates/roost-vt/src/render_state.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,8 @@ impl RenderState {
333333
let style = self
334334
.read_enum(sys::GhosttyRenderStateData_GHOSTTY_RENDER_STATE_DATA_CURSOR_VISUAL_STYLE)
335335
.unwrap_or(
336-
sys::GhosttyRenderStateCursorVisualStyle_GHOSTTY_RENDER_STATE_CURSOR_VISUAL_STYLE_BLOCK,
336+
sys::GhosttyRenderStateCursorVisualStyle_GHOSTTY_RENDER_STATE_CURSOR_VISUAL_STYLE_BLOCK
337+
as _,
337338
);
338339

339340
let cursor_has_color = self
@@ -351,7 +352,7 @@ impl RenderState {
351352
wide_tail,
352353
visible,
353354
blinking,
354-
visual_style: CursorVisualStyle::from_raw(style),
355+
visual_style: CursorVisualStyle::from_raw(style as _),
355356
color,
356357
})
357358
}
@@ -411,7 +412,7 @@ impl RenderState {
411412
/// Global dirty state. Pure read — clears nothing.
412413
pub fn dirty(&self) -> Result<Dirty> {
413414
let raw = self.read_enum(sys::GhosttyRenderStateData_GHOSTTY_RENDER_STATE_DATA_DIRTY)?;
414-
Ok(Dirty::from_raw(raw))
415+
Ok(Dirty::from_raw(raw as _))
415416
}
416417

417418
/// Raise the global dirty state to `Full`, forcing the next
@@ -737,8 +738,13 @@ impl RenderState {
737738
}
738739

739740
/// Read a data key whose documented output type is one of
740-
/// libghostty's `GHOSTTY_ENUM_TYPED` enums — explicitly `int` at the
741-
/// ABI, so the out-parameter must be `c_int`-shaped, not `u32`.
741+
/// libghostty's `GHOSTTY_ENUM_TYPED` enums. The ABI is a 4-byte
742+
/// write either way, but the Rust-side alias signedness is
743+
/// platform-dependent: Apple clang honors the header's
744+
/// `c_fixed_enum` `: int` (bindgen emits `c_int`) while Linux clang
745+
/// in default C mode expands the macro empty (bindgen infers
746+
/// `c_uint` for non-negative enums). Read as `c_int` and let call
747+
/// sites `as _` into the alias type, never assume one signedness.
742748
fn read_enum(&self, data: sys::GhosttyRenderStateData) -> Result<std::os::raw::c_int> {
743749
let mut out: std::os::raw::c_int = 0;
744750
// SAFETY: handle non-null; out is local.

0 commit comments

Comments
 (0)