ZJIT: Fix binding to INVALID_SHAPE_ID under -std=c99 -pedantic

```
  /src/jit.c:19:5: error: ISO C restricts enumerator values to range of 'int' (4294967295 is too large) [-Werror,-Wpedantic]
     19 |     RB_INVALID_SHAPE_ID = INVALID_SHAPE_ID,
        |     ^                     ~~~~~~~~~~~~~~~~
```
This commit is contained in:
Alan Wu 2025-10-19 15:11:39 -04:00
parent 193b299b8d
commit 35c2230734
Notes: git 2025-10-21 20:49:31 +00:00
5 changed files with 8 additions and 8 deletions

5
jit.c
View File

@ -22,6 +22,11 @@ enum robject_offsets {
ROBJECT_OFFSET_AS_ARY = offsetof(struct RObject, as.ary),
};
// Manually bound in rust since this is out-of-range of `int`,
// so this can't be in a `enum`, and we avoid `static const`
// to avoid allocating storage for the constant.
const shape_id_t rb_invalid_shape_id = INVALID_SHAPE_ID;
unsigned int
rb_iseq_encoded_size(const rb_iseq_t *iseq)
{

4
zjit.c
View File

@ -235,10 +235,6 @@ rb_zjit_print_exception(void)
rb_warn("Ruby error: %"PRIsVALUE"", rb_funcall(exception, rb_intern("full_message"), 0));
}
enum zjit_exported_constants {
RB_INVALID_SHAPE_ID = INVALID_SHAPE_ID,
};
bool
rb_zjit_singleton_class_p(VALUE klass)
{

View File

@ -100,6 +100,7 @@ fn main() {
.allowlist_function("rb_shape_id_offset")
.allowlist_function("rb_shape_get_iv_index")
.allowlist_function("rb_shape_transition_add_ivar_no_warnings")
.allowlist_var("rb_invalid_shape_id")
.allowlist_var("SHAPE_ID_NUM_BITS")
.allowlist_function("rb_obj_is_kind_of")
.allowlist_function("rb_obj_frozen_p")
@ -295,7 +296,6 @@ fn main() {
.allowlist_function("rb_zjit_insn_leaf")
.allowlist_type("robject_offsets")
.allowlist_type("rstring_offsets")
.allowlist_type("zjit_exported_constants")
.allowlist_function("rb_assert_holding_vm_lock")
.allowlist_function("rb_jit_shape_too_complex_p")
.allowlist_function("rb_jit_multi_ractor_p")

View File

@ -273,7 +273,7 @@ pub type IseqPtr = *const rb_iseq_t;
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct ShapeId(pub u32);
pub const INVALID_SHAPE_ID: ShapeId = ShapeId(RB_INVALID_SHAPE_ID);
pub const INVALID_SHAPE_ID: ShapeId = ShapeId(rb_invalid_shape_id);
impl ShapeId {
pub fn is_valid(self) -> bool {

View File

@ -730,11 +730,10 @@ pub const DEFINED_REF: defined_type = 15;
pub const DEFINED_FUNC: defined_type = 16;
pub const DEFINED_CONST_FROM: defined_type = 17;
pub type defined_type = u32;
pub const RB_INVALID_SHAPE_ID: zjit_exported_constants = 4294967295;
pub type zjit_exported_constants = u32;
pub const ROBJECT_OFFSET_AS_HEAP_FIELDS: robject_offsets = 16;
pub const ROBJECT_OFFSET_AS_ARY: robject_offsets = 16;
pub type robject_offsets = u32;
pub const rb_invalid_shape_id: shape_id_t = 4294967295;
pub type rb_iseq_param_keyword_struct = rb_iseq_constant_body__bindgen_ty_1_rb_iseq_param_keyword;
unsafe extern "C" {
pub fn ruby_xfree(ptr: *mut ::std::os::raw::c_void);