Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file base_bigstring.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718open!BasemoduleBigstring0=structtypet=(char,Stdlib.Bigarray.int8_unsigned_elt,Stdlib.Bigarray.c_layout)Stdlib.Bigarray.Array1.tendmoduleArray1=structtype('a,'b,'c)t=('a,'b,'c)Stdlib.Bigarray.Array1.texternalget:('a,'b,'c)t->int->'a="%caml_ba_ref_1"externalset:('a,'b,'c)t->int->'a->unit="%caml_ba_set_1"externalunsafe_get:('a,'b,'c)t->int->'a="%caml_ba_unsafe_ref_1"externalunsafe_set:('a,'b,'c)t->int->'a->unit="%caml_ba_unsafe_set_1"externaldim:('a,'b,'c)t->int="%caml_ba_dim_1"endincludeBigstring0externalaux_create:max_mem_waiting_gc_in_bytes:int->size:int->t="bigstring_alloc"letsprintf=Printf.sprintf(* One need to use [Caml.Sys.word_size] so that its value is known at compile time *)letarch_sixtyfour=Caml.Sys.word_size=64letarch_big_endian=Caml.Sys.big_endianletnot_on_32bit=Caml.Sys.word_size>32letcreate?max_mem_waiting_gc_in_bytessize=letmax_mem_waiting_gc_in_bytes=Option.valuemax_mem_waiting_gc_in_bytes~default:(-1)in(* This check is important because [aux_create ~size:(-1)] raises [Out_of_memory], which
could be confusing during debugging. *)ifsize<0theninvalid_arg(sprintf"create: size = %d < 0"size);aux_create~max_mem_waiting_gc_in_bytes~size;;letlength=Array1.dimexternalis_mmapped:t->bool="bigstring_is_mmapped_stub"[@@noalloc]letinitn~f=lett=createninfori=0ton-1dot.{i}<-(fi)done;t;;letcheck_args~loc~pos~len(bstr:t)=ifpos<0theninvalid_arg(loc^": pos < 0");iflen<0theninvalid_arg(loc^": len < 0");letbstr_len=lengthbstrinifbstr_len<pos+lentheninvalid_arg(sprintf"Bigstring.%s: length(bstr) < pos + len"loc);;letget_opt_lenbstr~pos=function|Somelen->len|None->lengthbstr-pos;;(* Blitting *)externalunsafe_blit:src:t->src_pos:int->dst:t->dst_pos:int->len:int->unit="bigstring_blit_stub"(* Exposing the external version of get/set supports better inlining *)externalget:t->int->char="%caml_ba_ref_1"externalset:t->int->char->unit="%caml_ba_set_1"moduleBigstring_sequence=structtypenonrect=tletcreate~len=createlenletlength=lengthendmoduleBytes_sequence=structtypet=bytesletcreate~len=Bytes.createlenletlength=Bytes.lengthendincludeBlit.Make(structincludeBigstring_sequenceletunsafe_blit=unsafe_blitend)moduleFrom_bytes=Blit.Make_distinct(Bytes_sequence)(structexternalunsafe_blit:src:bytes->src_pos:int->dst:t->dst_pos:int->len:int->unit="bigstring_blit_bytes_bigstring_stub"[@@noalloc]includeBigstring_sequenceend)moduleTo_bytes=Blit.Make_distinct(Bigstring_sequence)(structexternalunsafe_blit:src:t->src_pos:int->dst:bytes->dst_pos:int->len:int->unit="bigstring_blit_bigstring_bytes_stub"[@@noalloc]includeBytes_sequenceend)moduleFrom_string=Blit.Make_distinct(structtypet=stringletlength=String.lengthend)(structexternalunsafe_blit:src:string->src_pos:int->dst:t->dst_pos:int->len:int->unit="bigstring_blit_string_bigstring_stub"[@@noalloc]includeBigstring_sequenceend)moduleTo_string=structincludeTo_bytesincludeBlit.Make_to_string(Bigstring0)(To_bytes)endletof_string=From_string.suboletof_bytes=From_bytes.suboletto_string=To_string.suboletto_bytes=To_bytes.suboletsexp_of_tt=Sexp.Atom(to_stringt)lett_of_sexp:Sexp.t->t=function|Atomstr->of_stringstr|List_assexp->Sexplib0.Sexp_conv.of_sexp_error"bigstring_of_sexp: atom needed"sexpletconcat=letappend~src~dst~dst_pos_ref=letlen=lengthsrcinletsrc_pos=0inletdst_pos=!dst_pos_refinblit~dst~dst_pos~src~src_pos~len;dst_pos_ref:=dst_pos+leninfun?seplist->matchlistwith|[]->create0|head::tail->lethead_len=lengthheadinletsep_len=Option.value_mapsep~f:length~default:0inlettail_count=List.lengthtailinletlen=head_len+(sep_len*tail_count)+List.sum(moduleInt)tail~f:lengthinletdst=createleninletdst_pos_ref=ref0inappend~src:head~dst~dst_pos_ref;List.itertail~f:(funsrc->(matchsepwith|None->()|Somesep->append~src:sep~dst~dst_pos_ref);append~src~dst~dst_pos_ref);assert(!dst_pos_ref=len);dst;;externalunsafe_memset:t->pos:int->len:int->char->unit="bigstring_memset_stub"[@@noalloc]letmemsett~pos~lenc=Ordered_collection_common.check_pos_len_exn~pos~len~total_length:(lengtht);unsafe_memsett~pos~lenc;;(* Comparison *)externalunsafe_memcmp:t->pos1:int->t->pos2:int->len:int->int="bigstring_memcmp_stub"[@@noalloc]letmemcmpt1~pos1t2~pos2~len=Ordered_collection_common.check_pos_len_exn~pos:pos1~len~total_length:(lengtht1);Ordered_collection_common.check_pos_len_exn~pos:pos2~len~total_length:(lengtht2);unsafe_memcmpt1~pos1t2~pos2~len;;letcomparet1t2=ifphys_equalt1t2then0else(letlen1=lengtht1inletlen2=lengtht2inletlen=Int.minlen1len2inmatchunsafe_memcmpt1~pos1:0t2~pos2:0~lenwith|0->iflen1<len2then-1elseiflen1>len2then1else0|n->n);;externalinternalhash_fold_bigstring:Hash.state->t->Hash.state="internalhash_fold_bigstring"[@@noalloc]let_making_sure_the_C_binding_takes_an_int(x:Hash.state)=(x:>int)lethash_fold_t=internalhash_fold_bigstringlethash=Ppx_hash_lib.Std.Hash.of_foldhash_fold_ttypet_frozen=t[@@derivingcompare,hash,sexp]letequalt1t2=ifphys_equalt1t2thentrueelse(letlen1=lengtht1inletlen2=lengtht2inInt.equallen1len2&&Int.equal(unsafe_memcmpt1~pos1:0t2~pos2:0~len:len1)0);;(* Search *)externalunsafe_find:t->char->pos:int->len:int->int="bigstring_find"[@@noalloc]letfind?(pos=0)?lenchrbstr=letlen=get_opt_lenbstr~poslenincheck_args~loc:"find"~pos~lenbstr;letres=unsafe_findbstrchr~pos~leninifres<0thenNoneelseSomeres;;(* vim: set filetype=ocaml : *)(* Binary-packing like accessors *)externalint32_of_int:int->int32="%int32_of_int"externalint32_to_int:int32->int="%int32_to_int"externalint64_of_int:int->int64="%int64_of_int"externalint64_to_int:int64->int="%int64_to_int"externalswap16:int->int="%bswap16"externalswap32:int32->int32="%bswap_int32"externalswap64:int64->int64="%bswap_int64"externalunsafe_get_16:t->int->int="%caml_bigstring_get16u"externalunsafe_get_32:t->int->int32="%caml_bigstring_get32u"externalunsafe_get_64:t->int->int64="%caml_bigstring_get64u"externalunsafe_set_16:t->int->int->unit="%caml_bigstring_set16u"externalunsafe_set_32:t->int->int32->unit="%caml_bigstring_set32u"externalunsafe_set_64:t->int->int64->unit="%caml_bigstring_set64u"letget_16(t:t)(pos:int):int=check_args~loc:"get_16"~pos~len:2t;unsafe_get_16tpos;;letget_32(t:t)(pos:int):int32=check_args~loc:"get_32"~pos~len:4t;unsafe_get_32tpos;;letget_64(t:t)(pos:int):int64=check_args~loc:"get_64"~pos~len:8t;unsafe_get_64tpos;;(* Assumes [v] is a valid 16-bit integer, because all call sites check this before
performing any operations on [t]. *)letset_16(t:t)(pos:int)(v:int):unit=check_args~loc:"set_16"~pos~len:2t;unsafe_set_16tposv;;letset_32(t:t)(pos:int)(v:int32):unit=check_args~loc:"set_32"~pos~len:4t;unsafe_set_32tposv;;letset_64(t:t)(pos:int)(v:int64):unit=check_args~loc:"set_64"~pos~len:8t;unsafe_set_64tposv;;letsign_extend_16u=(ulsl(Int.num_bits-16))asr(Int.num_bits-16)letcheck_valid_uint16x~loc=ifx<0||x>0xFFFFtheninvalid_arg(sprintf"%s: %d is not a valid unsigned 16-bit integer"locx);;letcheck_valid_int16x~loc=ifx<-0x8000||x>0x7FFFtheninvalid_arg(sprintf"%s: %d is not a valid (signed) 16-bit integer"locx);;letcheck_valid_uint8x~loc=ifx<0||x>0xFFtheninvalid_arg(sprintf"%s: %d is not a valid unsigned 8-bit integer"locx);;letcheck_valid_int8x~loc=ifx<-0x80||x>0x7Ftheninvalid_arg(sprintf"%s: %d is not a valid (signed) 8-bit integer"locx);;letcheck_valid_int32=ifnotarch_sixtyfourthenfun_~loc:_->()elsefunx~loc->ifx>=-1lsl31&&x<1lsl31then()elseinvalid_arg(sprintf"%s: %d is not a valid (signed) 32-bit integer"locx);;letcheck_valid_uint32=ifnotarch_sixtyfourthenfunx~loc->ifx>=0then()elseinvalid_arg(sprintf"%s: %d is not a valid unsigned 32-bit integer"locx)elsefunx~loc->ifx>=0&&x<1lsl32then()elseinvalid_arg(sprintf"%s: %d is not a valid unsigned 32-bit integer"locx);;letcheck_valid_uint64x~loc=ifx>=0then()elseinvalid_arg(sprintf"%s: %d is not a valid unsigned 64-bit integer"locx);;letunsafe_read_int16t~pos=sign_extend_16(unsafe_get_16tpos)letunsafe_read_int16_swapt~pos=sign_extend_16(swap16(unsafe_get_16tpos))letunsafe_write_int16t~posx=unsafe_set_16tposxletunsafe_write_int16_swapt~posx=unsafe_set_16tpos(swap16x)letread_int16t~pos=sign_extend_16(get_16tpos)letread_int16_swapt~pos=sign_extend_16(swap16(get_16tpos))letwrite_int16t~posx=check_valid_int16x~loc:"Bigstring.write_int16";set_16tposx;;letwrite_int16_swapt~posx=(* Omit "_swap" from the error message it's bi-endian. *)check_valid_int16x~loc:"Bigstring.write_int16";set_16tpos(swap16x);;letunsafe_read_uint16t~pos=unsafe_get_16tposletunsafe_read_uint16_swapt~pos=swap16(unsafe_get_16tpos)letunsafe_write_uint16t~posx=unsafe_set_16tposxletunsafe_write_uint16_swapt~posx=unsafe_set_16tpos(swap16x)letread_uint16t~pos=get_16tposletread_uint16_swapt~pos=swap16(get_16tpos)letwrite_uint16t~posx=check_valid_uint16x~loc:"Bigstring.write_uint16";set_16tposx;;letwrite_uint16_swapt~posx=(* Omit "_swap" from the error message it's bi-endian. *)check_valid_uint16x~loc:"Bigstring.write_uint16";set_16tpos(swap16x);;letunsafe_read_int32_intt~pos=int32_to_int(unsafe_get_32tpos)letunsafe_read_int32_int_swapt~pos=int32_to_int(swap32(unsafe_get_32tpos))letunsafe_read_int32t~pos=unsafe_get_32tposletunsafe_read_int32_swapt~pos=swap32(unsafe_get_32tpos)letunsafe_write_int32t~posx=unsafe_set_32tposxletunsafe_write_int32_swapt~posx=unsafe_set_32tpos(swap32x)letunsafe_write_int32_intt~posx=unsafe_set_32tpos(int32_of_intx)letunsafe_write_int32_int_swapt~posx=unsafe_set_32tpos(swap32(int32_of_intx))letread_int32_intt~pos=int32_to_int(get_32tpos)letread_int32_int_swapt~pos=int32_to_int(swap32(get_32tpos))letread_int32t~pos=get_32tposletread_int32_swapt~pos=swap32(get_32tpos)letwrite_int32t~posx=set_32tposxletwrite_int32_swapt~posx=set_32tpos(swap32x)letwrite_int32_intt~posx=check_valid_int32x~loc:"Bigstring.write_int32_int";set_32tpos(int32_of_intx);;letwrite_int32_int_swapt~posx=(* Omit "_swap" from the error message it's bi-endian. *)check_valid_int32x~loc:"Bigstring.write_int32_int";set_32tpos(swap32(int32_of_intx));;letunsafe_read_int64_intt~pos=int64_to_int(unsafe_get_64tpos)letunsafe_read_int64_int_swapt~pos=int64_to_int(swap64(unsafe_get_64tpos))letunsafe_read_int64t~pos=unsafe_get_64tposletunsafe_read_int64_swapt~pos=swap64(unsafe_get_64tpos)letunsafe_write_int64t~posx=unsafe_set_64tposxletunsafe_write_int64_swapt~posx=unsafe_set_64tpos(swap64x)letunsafe_write_int64_intt~posx=unsafe_set_64tpos(int64_of_intx)letunsafe_write_int64_int_swapt~posx=unsafe_set_64tpos(swap64(int64_of_intx))letread_int64_intt~pos=int64_to_int(get_64tpos)letread_int64_int_swapt~pos=int64_to_int(swap64(get_64tpos))letread_int64t~pos=get_64tposletread_int64_swapt~pos=swap64(get_64tpos)letwrite_int64t~posx=set_64tposxletwrite_int64_swapt~posx=set_64tpos(swap64x)letwrite_int64_intt~posx=set_64tpos(int64_of_intx)letwrite_int64_int_swapt~posx=set_64tpos(swap64(int64_of_intx))letunsafe_get_int16_be=ifarch_big_endianthenunsafe_read_int16elseunsafe_read_int16_swap;;letunsafe_get_int16_le=ifarch_big_endianthenunsafe_read_int16_swapelseunsafe_read_int16;;letunsafe_get_uint16_be=ifarch_big_endianthenunsafe_read_uint16elseunsafe_read_uint16_swap;;letunsafe_get_uint16_le=ifarch_big_endianthenunsafe_read_uint16_swapelseunsafe_read_uint16;;letget_int16_be=ifarch_big_endianthenread_int16elseread_int16_swapletget_int16_le=ifarch_big_endianthenread_int16_swapelseread_int16letget_uint16_be=ifarch_big_endianthenread_uint16elseread_uint16_swapletget_uint16_le=ifarch_big_endianthenread_uint16_swapelseread_uint16letunsafe_set_int16_be=ifarch_big_endianthenunsafe_write_int16elseunsafe_write_int16_swap;;letunsafe_set_int16_le=ifarch_big_endianthenunsafe_write_int16_swapelseunsafe_write_int16;;letunsafe_set_uint16_be=ifarch_big_endianthenunsafe_write_uint16elseunsafe_write_uint16_swap;;letunsafe_set_uint16_le=ifarch_big_endianthenunsafe_write_uint16_swapelseunsafe_write_uint16;;letset_int16_be=ifarch_big_endianthenwrite_int16elsewrite_int16_swapletset_int16_le=ifarch_big_endianthenwrite_int16_swapelsewrite_int16letset_uint16_be=ifarch_big_endianthenwrite_uint16elsewrite_uint16_swapletset_uint16_le=ifarch_big_endianthenwrite_uint16_swapelsewrite_uint16letunsafe_get_int32_t_be=ifarch_big_endianthenunsafe_read_int32elseunsafe_read_int32_swap;;letunsafe_get_int32_t_le=ifarch_big_endianthenunsafe_read_int32_swapelseunsafe_read_int32;;letunsafe_set_int32_t_be=ifarch_big_endianthenunsafe_write_int32elseunsafe_write_int32_swap;;letunsafe_set_int32_t_le=ifarch_big_endianthenunsafe_write_int32_swapelseunsafe_write_int32;;letget_int32_t_be=ifarch_big_endianthenread_int32elseread_int32_swapletget_int32_t_le=ifarch_big_endianthenread_int32_swapelseread_int32letset_int32_t_be=ifarch_big_endianthenwrite_int32elsewrite_int32_swapletset_int32_t_le=ifarch_big_endianthenwrite_int32_swapelsewrite_int32letunsafe_get_int32_be=ifarch_big_endianthenunsafe_read_int32_intelseunsafe_read_int32_int_swap;;letunsafe_get_int32_le=ifarch_big_endianthenunsafe_read_int32_int_swapelseunsafe_read_int32_int;;letunsafe_set_int32_be=ifarch_big_endianthenunsafe_write_int32_intelseunsafe_write_int32_int_swap;;letunsafe_set_int32_le=ifarch_big_endianthenunsafe_write_int32_int_swapelseunsafe_write_int32_int;;letget_int32_be=ifarch_big_endianthenread_int32_intelseread_int32_int_swapletget_int32_le=ifarch_big_endianthenread_int32_int_swapelseread_int32_intletset_int32_be=ifarch_big_endianthenwrite_int32_intelsewrite_int32_int_swapletset_int32_le=ifarch_big_endianthenwrite_int32_int_swapelsewrite_int32_intletunsafe_get_int64_be_trunc=ifarch_big_endianthenunsafe_read_int64_intelseunsafe_read_int64_int_swap;;letunsafe_get_int64_le_trunc=ifarch_big_endianthenunsafe_read_int64_int_swapelseunsafe_read_int64_int;;letunsafe_set_int64_be=ifarch_big_endianthenunsafe_write_int64_intelseunsafe_write_int64_int_swap;;letunsafe_set_int64_le=ifarch_big_endianthenunsafe_write_int64_int_swapelseunsafe_write_int64_int;;letget_int64_be_trunc=ifarch_big_endianthenread_int64_intelseread_int64_int_swapletget_int64_le_trunc=ifarch_big_endianthenread_int64_int_swapelseread_int64_intletset_int64_be=ifarch_big_endianthenwrite_int64_intelsewrite_int64_int_swapletset_int64_le=ifarch_big_endianthenwrite_int64_int_swapelsewrite_int64_intletunsafe_get_int64_t_be=ifarch_big_endianthenunsafe_read_int64elseunsafe_read_int64_swap;;letunsafe_get_int64_t_le=ifarch_big_endianthenunsafe_read_int64_swapelseunsafe_read_int64;;letunsafe_set_int64_t_be=ifarch_big_endianthenunsafe_write_int64elseunsafe_write_int64_swap;;letunsafe_set_int64_t_le=ifarch_big_endianthenunsafe_write_int64_swapelseunsafe_write_int64;;letget_int64_t_be=ifarch_big_endianthenread_int64elseread_int64_swapletget_int64_t_le=ifarch_big_endianthenread_int64_swapelseread_int64letset_int64_t_be=ifarch_big_endianthenwrite_int64elsewrite_int64_swapletset_int64_t_le=ifarch_big_endianthenwrite_int64_swapelsewrite_int64letint64_conv_error()=failwith"unsafe_read_int64: value cannot be represented unboxed!";;letuint64_conv_error()=failwith"unsafe_read_uint64: value cannot be represented unboxed!";;(* [Poly] is required so that we can compare unboxed int64 *)letint64_to_int_exnn=ifarch_sixtyfourthenifPoly.(n>=-0x4000_0000_0000_0000L&&n<0x4000_0000_0000_0000L)thenint64_to_intnelseint64_conv_error()elseifPoly.(n>=-0x0000_0000_4000_0000L&&n<0x0000_0000_4000_0000L)thenint64_to_intnelseint64_conv_error();;letuint64_to_int_exnn=ifarch_sixtyfourthenifPoly.(n>=0L&&n<0x4000_0000_0000_0000L)thenint64_to_intnelseuint64_conv_error()elseifPoly.(n>=0L&&n<0x0000_0000_4000_0000L)thenint64_to_intnelseuint64_conv_error();;letunsafe_get_int64_be_exnt~pos=int64_to_int_exn(unsafe_get_int64_t_bet~pos)letunsafe_get_int64_le_exnt~pos=int64_to_int_exn(unsafe_get_int64_t_let~pos)letget_int64_be_exnt~pos=int64_to_int_exn(get_int64_t_bet~pos)letget_int64_le_exnt~pos=int64_to_int_exn(get_int64_t_let~pos)letunsafe_get_uint64_be_exnt~pos=uint64_to_int_exn(unsafe_get_int64_t_bet~pos)letunsafe_get_uint64_le_exnt~pos=uint64_to_int_exn(unsafe_get_int64_t_let~pos)letget_uint64_be_exnt~pos=uint64_to_int_exn(get_int64_t_bet~pos)letget_uint64_le_exnt~pos=uint64_to_int_exn(get_int64_t_let~pos)letunsafe_set_uint64_be=unsafe_set_int64_beletunsafe_set_uint64_le=unsafe_set_int64_leletset_uint64_bet~posn=check_valid_uint64~loc:"Bigstring.set_uint64_be"n;set_int64_bet~posn;;letset_uint64_let~posn=check_valid_uint64~loc:"Bigstring.set_uint64_le"n;set_int64_let~posn;;(* Type annotations on the [t]s are important here: in order for the compiler to generate
optimized code, it needs to know the fully instantiated type of the bigarray. This is
because the type of the bigarray encodes the element kind and the layout of the
bigarray. Without the annotation the compiler generates a C call to the generic access
functions. *)letunsafe_set_uint8(t:t)~posn=Array1.unsafe_settpos(Char.unsafe_of_intn)letunsafe_set_int8(t:t)~posn=(* in all the set functions where there are these tests, it looks like the test could be
removed, since they are only changing the values of the bytes that are not
written. *)letn=ifn<0thenn+256elseninArray1.unsafe_settpos(Char.unsafe_of_intn);;letunsafe_get_uint8(t:t)~pos=Char.to_int(Array1.unsafe_gettpos)letunsafe_get_int8(t:t)~pos=letn=Char.to_int(Array1.unsafe_gettpos)inifn>=128thenn-256elsen;;letset_uint8(t:t)~posn=check_valid_uint8~loc:"Bigstring.set_uint8"n;Array1.settpos(Char.unsafe_of_intn);;letset_int8(t:t)~posn=check_valid_int8~loc:"Bigstring.set_int8"n;letn=ifn<0thenn+256elseninArray1.settpos(Char.unsafe_of_intn);;letget_uint8(t:t)~pos=Char.to_int(Array1.gettpos)letget_int8(t:t)~pos=letn=Char.to_int(Array1.gettpos)inifn>=128thenn-256elsen;;letunsafe_set_uint32_let~posn=letn=ifnot_on_32bit&&n>=1lsl31thenn-(1lsl32)elseninunsafe_set_int32_let~posn;;letunsafe_set_uint32_bet~posn=letn=ifnot_on_32bit&&n>=1lsl31thenn-(1lsl32)elseninunsafe_set_int32_bet~posn;;letunsafe_get_uint32_let~pos=letn=unsafe_get_int32_let~posinifnot_on_32bit&&n<0thenn+(1lsl32)elsen;;letunsafe_get_uint32_bet~pos=letn=unsafe_get_int32_bet~posinifnot_on_32bit&&n<0thenn+(1lsl32)elsen;;letset_uint32_let~posn=check_valid_uint32~loc:"Bigstring.set_uint32_le"n;letn=ifnot_on_32bit&&n>=1lsl31thenn-(1lsl32)elseninset_int32_let~posn;;letset_uint32_bet~posn=check_valid_uint32~loc:"Bigstring.set_uint32_be"n;letn=ifnot_on_32bit&&n>=1lsl31thenn-(1lsl32)elseninset_int32_bet~posn;;letget_uint32_let~pos=letn=get_int32_let~posinifnot_on_32bit&&n<0thenn+(1lsl32)elsen;;letget_uint32_bet~pos=letn=get_int32_bet~posinifnot_on_32bit&&n<0thenn+(1lsl32)elsen;;modulePrivate=structletsign_extend_16=sign_extend_16end