123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263open!Baseopen!Import(* We don't use [Ocaml_intrinsics.Native_pointer] because we want this library to be JSOO-
compatible. JS will only use the sequential scheduler, which doesn't need stack
pointers, and thus we can implement the primitives below by simply raising, as they
should never be called. *)type'at=nativeint#externalunsafe_of_value:'a@localonce->'at@once@@portable="parallel_stack_pointer_unsupported""caml_native_pointer_of_value"[@@noalloc][@@builtin][@@no_effects][@@no_coeffects]externalunsafe_to_value:'at->'a@@portable="parallel_stack_pointer_unsupported""caml_native_pointer_to_value"[@@noalloc][@@builtin][@@no_effects][@@no_coeffects]letnull()=Nativeint_u.zeroletequal=Nativeint_u.equallet%template[@inline]unsafe_with_value(typea)(a:a)~f=exclave_(* Safe because [opaque_identity] does not look at [a]. *)leta=Obj.magic_manyainletres=f(unsafe_of_valuea)in(* Ensure that [a] is still live. *)let_:a=Sys.opaque_identityainres[@@kindk=(value,value&value)];;let%template[@inline]uset~f=exclave_f(ifequalt(null())thenNoneelseSome(unsafe_to_valuet))[@@kindk=(value,word&value&value)];;moduleImm=structtype'aptr='attype'at=intletnull=0externalof_i64:int64#->'at@@portable="%reinterpret_unboxed_int64_as_tagged_int63"let[@inline]of_ptrptr=of_i64(Int64_u.unbox(Nativeint_u.to_int64ptr))externalto_ptr:'at->'aptr@@portable="parallel_stack_pointer_unsupported""caml_ext_pointer_as_native_pointer"[@@noalloc][@@builtin][@@no_effects][@@no_coeffects]end