Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use extern instead of caml/threads.h #140

Merged
merged 1 commit into from
Jul 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src-c/native/stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@
return Val_unit; \
}
#else
#include <caml/threads.h>
/* XXX(dinosaure): even if they are not defined (only defined by
* [caml/threads.h]), they exists without [threads.cmxa]. For compatibility
* reason, we keep a protection when we compile for Solo5/ocaml-freestanding
* but for the rest, these functions should be available in any cases.
*
* In some cases (Solo5 or Esperanto), [caml/threads.h] is not available but
* these functions still exist!
*/

extern void caml_enter_blocking_section (void);
extern void caml_leave_blocking_section (void);

#define __define_ba_update(name) \
CAMLprim value \
Expand All @@ -48,9 +58,9 @@
uint32_t len_ = Long_val (len); \
struct name ## _ctx ctx_; \
memcpy(&ctx_, Bytes_val(ctx), sizeof(struct name ## _ctx)); \
caml_release_runtime_system(); \
caml_enter_blocking_section(); \
digestif_ ## name ## _update (&ctx_, off_, len_); \
caml_acquire_runtime_system(); \
caml_leave_blocking_section(); \
memcpy(Bytes_val(ctx), &ctx_, sizeof(struct name ## _ctx)); \
CAMLreturn (Val_unit); \
}
Expand All @@ -64,9 +74,9 @@
uint32_t len_ = Long_val (len); \
struct sha3_ctx ctx_; \
memcpy(&ctx_, Bytes_val(ctx), sizeof(struct sha3_ctx)); \
caml_release_runtime_system(); \
caml_enter_blocking_section(); \
digestif_sha3_update (&ctx_, off_, len_); \
caml_acquire_runtime_system(); \
caml_leave_blocking_section(); \
memcpy(Bytes_val(ctx), &ctx_, sizeof(struct sha3_ctx)); \
CAMLreturn (Val_unit); \
}
Expand Down