The unpac monorepo manager self-hosting as a monorepo using unpac

Merge pull request #140 from mirage/fix-no-threads

Use extern instead of caml/threads.h

authored by dinosaure.tngl.sh and committed by

GitHub b7ed2a2b b21df58a

+15 -5
+15 -5
vendor/opam/digestif/src-c/native/stubs.c
··· 37 37 return Val_unit; \ 38 38 } 39 39 #else 40 - #include <caml/threads.h> 40 + /* XXX(dinosaure): even if they are not defined (only defined by 41 + * [caml/threads.h]), they exists without [threads.cmxa]. For compatibility 42 + * reason, we keep a protection when we compile for Solo5/ocaml-freestanding 43 + * but for the rest, these functions should be available in any cases. 44 + * 45 + * In some cases (Solo5 or Esperanto), [caml/threads.h] is not available but 46 + * these functions still exist! 47 + */ 48 + 49 + extern void caml_enter_blocking_section (void); 50 + extern void caml_leave_blocking_section (void); 41 51 42 52 #define __define_ba_update(name) \ 43 53 CAMLprim value \ ··· 48 58 uint32_t len_ = Long_val (len); \ 49 59 struct name ## _ctx ctx_; \ 50 60 memcpy(&ctx_, Bytes_val(ctx), sizeof(struct name ## _ctx)); \ 51 - caml_release_runtime_system(); \ 61 + caml_enter_blocking_section(); \ 52 62 digestif_ ## name ## _update (&ctx_, off_, len_); \ 53 - caml_acquire_runtime_system(); \ 63 + caml_leave_blocking_section(); \ 54 64 memcpy(Bytes_val(ctx), &ctx_, sizeof(struct name ## _ctx)); \ 55 65 CAMLreturn (Val_unit); \ 56 66 } ··· 64 74 uint32_t len_ = Long_val (len); \ 65 75 struct sha3_ctx ctx_; \ 66 76 memcpy(&ctx_, Bytes_val(ctx), sizeof(struct sha3_ctx)); \ 67 - caml_release_runtime_system(); \ 77 + caml_enter_blocking_section(); \ 68 78 digestif_sha3_update (&ctx_, off_, len_); \ 69 - caml_acquire_runtime_system(); \ 79 + caml_leave_blocking_section(); \ 70 80 memcpy(Bytes_val(ctx), &ctx_, sizeof(struct sha3_ctx)); \ 71 81 CAMLreturn (Val_unit); \ 72 82 }