Skip to content

Commit

Permalink
flambda-backend: Add Assert_mixed_block_layout_v1 macro (ocaml-flambd…
Browse files Browse the repository at this point in the history
…a#2647)

* 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 71d7a55 commit e055226
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions 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 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 e055226

Please sign in to comment.