1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677(** Extraction of [Stdlib.Sys.Immediate64] for pre-4.10 compatibility.
[Immediate64] was originally authored by Jeremie Dimino <jeremie@dimino.org>,
and is licensed along with the OCaml compiler system under LGPLv2. See the
{{:https://github.com/ocaml/ocaml/blob/trunk/LICENSE} compiler license} for
details.
For soundness of the [@@immediate64] annotation, we ensure to use the boxed
representation only when not on 64-bit platforms, but we need to use The
Force to convince the type system of this fact. *)moduleImmediate64=structmoduletypeNon_immediate=sigtypetendmoduletypeImmediate=sigtypet[@@immediate]endmoduleMake(Immediate:Immediate)(Non_immediate:Non_immediate)=structtypet[@@immediate64]type'arepr=|Immediate:Immediate.trepr|Non_immediate:Non_immediate.treprexternalmagic:_repr->trepr="%identity"letrepr=ifSys.word_size=64thenmagicImmediateelsemagicNon_immediateendendmoduleConditional=structtype('t,'u,'v)t=|True:('t,'t,_)t(** therefore ['t] = ['u] *)|False:('t,_,'t)t(** therefore ['t] = ['v] *)endmoduleOptint=structincludeImmediate64.Make(Optint_native)(Optint_emul)moduletypeS=Integer_interface.Swithtypet:=tletimpl:(moduleS)=matchreprwith|Immediate->(moduleOptint_native:S)|Non_immediate->(moduleOptint_emul:S)include(valimpl:S)letis_immediate:(t,int,int32)Conditional.t=matchreprwith|Immediate->True|Non_immediate->FalseendmoduleInt63=structincludeImmediate64.Make(Int63_native)(Int63_emul)moduletypeS=Integer_interface.Swithtypet:=tletimpl:(moduleS)=matchreprwith|Immediate->(moduleInt63_native:S)|Non_immediate->(moduleInt63_emul:S)include(valimpl:S)moduleBoxed=Int63_emulletis_immediate:(t,int,Boxed.t)Conditional.t=matchreprwith|Immediate->True|Non_immediate->FalseendincludeOptint