Skip to content

Commit

Permalink
Add Assert_mixed_block_layout_v1 macro (#2647)
Browse files Browse the repository at this point in the history
* Add Assert_mixed_block_layout_v1 macro

* Add note about hack

* add macro for runtime 4 as well
  • Loading branch information
ncik-roberts authored Jun 4, 2024
1 parent 771f0bc commit e2f6516
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ocaml/runtime/caml/mlvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,22 @@ CAMLextern value caml_atom(tag_t);

CAMLextern value caml_set_oo_id(value obj);

/* Users write this to assert that the ensuing C code is sensitive
to the current layout of mixed blocks in a way that's subject
to change in future compiler releases. We'll bump the version
number when we make a breaking change. For example, we currently
don't pack int32's efficiently, and we will want to someday.
Users can write:
Assert_mixed_block_layout_v1;
(Hack: we define using _Static_assert rather than just an empty
definition so that users can write a semicolon, which is treated
better by C formatters.)
*/
#define Assert_mixed_block_layout_v1 _Static_assert(1, "")

/* Header for out-of-heap blocks. */

#define Caml_out_of_heap_header_with_reserved(wosize, tag, reserved) \
Expand Down
16 changes: 16 additions & 0 deletions ocaml/runtime4/caml/mlvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,22 @@ extern value caml_global_data;

CAMLextern value caml_set_oo_id(value obj);

/* Users write this to assert that the ensuing C code is sensitive
to the current layout of mixed blocks in a way that's subject
to change in future compiler releases. We'll bump the version
number when we make a breaking change. For example, we currently
don't pack int32's efficiently, and we will want to someday.
Users can write:
Assert_mixed_block_layout_v1;
(Hack: we define using _Static_assert rather than just an empty
definition so that users can write a semicolon, which is treated
better by C formatters.)
*/
#define Assert_mixed_block_layout_v1 _Static_assert(1, "")

/* Header for out-of-heap blocks. */

#define Caml_out_of_heap_header(wosize, tag) \
Expand Down

0 comments on commit e2f6516

Please sign in to comment.