1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426open!ImportmoduleUnix=Core_unixletconcat=String.concatletlogstringasexp_of_a=Printf.eprintf"%s\n%!"(Sexp.to_string_hum([%sexp_of:string*a](string,a)));;;moduleMake()=structletcheck_invariant=reftrueletshow_messages=reftrueopenIobuftypenonrec('d,'w)t=('d,'w)Hexdump.t[@@derivingsexp_of]typenonrecseek=seek[@@derivingsexp_of]typenonrecno_seek=no_seek[@@derivingsexp_of]moduletypeBound=BoundmoduleWindow=WindowmoduleLimits=LimitsmoduleDebug=DebugmoduleHexdump=Hexdumpletinvariant=invariantletdebugnametsargsexp_of_argsexp_of_resultf=letprefix="Iobuf."inif!show_messagesthenlog(concat[prefix;name])argsexp_of_arg;if!check_invariantthenList.iterts~f:(invariantignoreignore);letresult_or_exn=Result.try_withfinif!show_messagesthenlog(concat[prefix;name;" result"])result_or_exn([%sexp_of:(result,exn)Result.t]);if!check_invariantthenList.iterts~f:(invariantignoreignore);Result.ok_exnresult_or_exn;;;letdebug_blitname~src~dstasexp_of_asexp_of_retf=debugname[src](dst,a)[%sexp_of:(_,_)t*a][%sexp_of:ret](fun()->(* Check dst's invariant separately because it has a different type. *)letfinally()=if!check_invarianttheninvariantignoreignoredstinfinally();protect~finally~f);;letread_onlyt=debug"read_only"[t]()sexp_of_unit[%sexp_of:(_,_)t](fun()->read_onlyt)letno_seekt=debug"no_seek"[t]()sexp_of_unit[%sexp_of:(_,_)t](fun()->no_seekt)letcreate~len=debug"create"[](`lenlen)([%sexp_of:[`lenofint]])([%sexp_of:(_,_)t])(fun()->lett=create~leninif!check_invarianttheninvariantignoreignoret;t);;letcapacityt=debug"capacity"[t]t[%sexp_of:(_,_)t]sexp_of_int(fun()->capacityt);;letof_bigstring?pos?lenbigstring=debug"of_bigstring"[](`pospos,`lenlen,`bigstring_len(Bigstring.lengthbigstring))([%sexp_of:([`posofintoption]*[`lenofintoption]*[`bigstring_lenofint])])([%sexp_of:(_,_)t])(fun()->lett=of_bigstring?pos?lenbigstringinif!check_invarianttheninvariantignoreignoret;t);;letlengtht=debug"length"[t]t[%sexp_of:(_,_)t]sexp_of_int(fun()->lengtht);;letis_emptyt=debug"is_empty"[t]t[%sexp_of:(_,_)t]sexp_of_bool(fun()->is_emptyt);;moduleBound(Bound:Bound)(Name:sigvalname:stringend)=structtypet=Bound.t[@@derivingcompare,sexp_of]letwindowiobuf=debug(Name.name^".window")[iobuf]()sexp_of_unitBound.sexp_of_t(fun()->Bound.windowiobuf)letrestoretiobuf=debug(Name.name^".restore")[iobuf]tBound.sexp_of_tsexp_of_unit(fun()->Bound.restoretiobuf)letlimitiobuf=debug(Name.name^".limit")[iobuf]()sexp_of_unitBound.sexp_of_t(fun()->Bound.limitiobuf)endmoduleLo_bound=Bound(Lo_bound)(structletname="Lo_bound"end)moduleHi_bound=Bound(Hi_bound)(structletname="Hi_bound"end)letrewindt=debug"rewind"[t]t[%sexp_of:(_,_)t]sexp_of_unit(fun()->rewindt);;letresett=debug"reset"[t]t[%sexp_of:(_,_)t]sexp_of_unit(fun()->resett);;letflip_lot=debug"flip_lo"[t]t[%sexp_of:(_,_)t]sexp_of_unit(fun()->flip_lot);;letbounded_flip_lotlo_min=debug"bounded_flip_lo"[t]lo_minLo_bound.sexp_of_tsexp_of_unit(fun()->bounded_flip_lotlo_min);;letcompactt=debug"compact"[t]t[%sexp_of:(_,_)t]sexp_of_unit(fun()->compactt);;letbounded_compacttlo_minhi_max=debug"bounded_compact"[t](lo_min,hi_max)[%sexp_of:Lo_bound.t*Hi_bound.t]sexp_of_unit(fun()->bounded_compacttlo_minhi_max)letflip_hit=debug"flip_hi"[t]()[%sexp_of:unit]sexp_of_unit(fun()->flip_hit);;letbounded_flip_hithi_max=debug"bounded_flip_hi"[t]hi_maxHi_bound.sexp_of_tsexp_of_unit(fun()->bounded_flip_hithi_max);;letsub_shared?pos?lent=debug"sub_shared"[t](`pospos,`lenlen)[%sexp_of:[`posofintoption]*[`lenofintoption]][%sexp_of:(_,_)t](fun()->sub_shared?pos?lent);;letset_bounds_and_buffer_sub~pos~len~src~dst=debug"sub"[src](`pospos,`lenlen)[%sexp_of:[`posofint]*[`lenofint]]sexp_of_unit(fun()->set_bounds_and_buffer_sub~pos~len~src~dst);;letset_bounds_and_buffer~src~dst=debug"copy"[src]src[%sexp_of:(_,_)t]sexp_of_unit(fun()->set_bounds_and_buffer~src~dst);;letnarrowt=debug"narrow"[t]t[%sexp_of:(_,_)t]sexp_of_unit(fun()->narrowt);;letnarrow_lot=debug"narrow_lo"[t]t[%sexp_of:(_,_)t]sexp_of_unit(fun()->narrow_lot);;letnarrow_hit=debug"narrow_hi"[t]t[%sexp_of:(_,_)t]sexp_of_unit(fun()->narrow_hit);;letresizet~len=debug"resize"[t](`lenlen)[%sexp_of:[`lenofint]]sexp_of_unit(fun()->resizet~len);;letunsafe_resizet~len=debug"unsafe_resize"[t](`lenlen)[%sexp_of:[`lenofint]]sexp_of_unit(fun()->unsafe_resizet~len);;letprotect_window_and_boundst~f=debug"protect_window_and_bounds"[t]t[%sexp_of:(_,_)t][%sexp_of:_](fun()->protect_window_and_boundst~f);;letprotect_window_and_bounds_1tx~f=debug"protect_window_and_bounds_1"[t]t[%sexp_of:(_,_)t][%sexp_of:_](fun()->protect_window_and_bounds_1tx~f);;letof_strings=debug"of_string"[]s[%sexp_of:string][%sexp_of:(_,_)t](fun()->lett=of_stringsinif!check_invarianttheninvariantignoreignoret;t);;letof_bytess=debug"of_bytes"[]s[%sexp_of:Bytes.t][%sexp_of:(_,_)t](fun()->lett=of_bytessinif!check_invarianttheninvariantignoreignoret;t);;letto_string?lent=debug"to_string"[t](`lenlen)[%sexp_of:[`lenofintoption]][%sexp_of:string](fun()->to_string?lent);;letto_string_hum?max_linest=debug"to_string_hum"[t](`max_linesmax_lines)[%sexp_of:[`max_linesofintoption]][%sexp_of:string](fun()->to_string_hum?max_linest)letto_bytest=debug"to_bytes"[t]t[%sexp_of:(_,_)t][%sexp_of:Bytes.t](fun()->to_bytest);;letadvanceti=debug"advance"[t]isexp_of_intsexp_of_unit(fun()->advanceti)letunsafe_advanceti=debug"unsafe_advance"[t]isexp_of_intsexp_of_unit(fun()->unsafe_advanceti)moduleConsume_blit_debug=structmoduletypeTo=Iobuf_intf.Consuming_blitwithtypesrc:=Consume.srcmoduletypeTo_string=sigvalsubo:?len:int->Consume.src->stringvalsub:Consume.src->len:int->stringendmoduleTo(To:sigincludeTovalsexp_of_dst:dst->Sexp.tvalmodule_name:stringend)=structletblito~src?src_len~dst?dst_pos()=debug(To.module_name^".blito")[src](src_len,dst,dst_pos)[%sexp_of:intoption*To.dst*intoption]sexp_of_unit(To.blito~src?src_len~dst?dst_pos)letblit~src~dst~dst_pos~len=debug(To.module_name^".blit")[src](dst,dst_pos,len)[%sexp_of:To.dst*int*int]sexp_of_unit(fun()->To.blit~src~len~dst~dst_pos)letunsafe_blit~src~dst~dst_pos~len=debug(To.module_name^".unsafe_blit")[src](dst,dst_pos,len)[%sexp_of:To.dst*int*int]sexp_of_unit(fun()->To.unsafe_blit~src~len~dst~dst_pos)letsubsrc~len=debug(To.module_name^".sub")[src]len[%sexp_of:int]To.sexp_of_dst(fun()->To.subsrc~len)letsubo?lensrc=debug(To.module_name^".subo")[src]len[%sexp_of:intoption]To.sexp_of_dst(fun()->To.subo?lensrc)endmoduleMake(C:sigmoduleTo_bytes:Towithtypedst:=Bytes.tmoduleTo_bigstring:Towithtypedst:=bigstringmoduleTo_string:To_stringvalmodule_name:stringend)=structmoduleTo_bytes=To(structtypedst=Bytes.t[@@derivingsexp_of]includeC.To_bytesletmodule_name=C.module_name^".To_bytes"end)moduleTo_bigstring=To(structtypedst=bigstring[@@derivingsexp_of]includeC.To_bigstringletmodule_name=C.module_name^".To_bigstring"end)moduleTo_string=structincludeTo_bytesletsubsrc~len=debug(C.module_name^".To_string.sub")[src]len[%sexp_of:int]sexp_of_string(fun()->C.To_string.subsrc~len)letsubo?lensrc=debug(C.module_name^".To_string.subo")[src]len[%sexp_of:intoption]sexp_of_string(fun()->C.To_string.subo?lensrc)endtypesrc=Consume.srcendendmoduleConsume=structletdnamefsexp_of_resultt=debug("Consume."^name)[t]t[%sexp_of:(_,_)t]sexp_of_result(fun()->ft);;openConsumeincludeConsume_blit_debug.Make(structincludeConsumeletmodule_name="Consume"end)typenonrec('a,'d,'w)t=('a,'d,'w)tletchart=d"char"charsexp_of_chartletint8t=d"int8"int8sexp_of_inttletint16_bet=d"int16_be"int16_besexp_of_inttletint16_let=d"int16_le"int16_lesexp_of_inttletint32_bet=d"int32_be"int32_besexp_of_inttletint32_let=d"int32_le"int32_lesexp_of_inttletuint8t=d"uint8"uint8sexp_of_inttletuint16_bet=d"uint16_be"uint16_besexp_of_inttletuint16_let=d"uint16_le"uint16_lesexp_of_inttletuint32_bet=d"uint32_be"uint32_besexp_of_inttletuint32_let=d"uint32_le"uint32_lesexp_of_inttletint64_be_exnt=d"int64_be_exn"int64_be_exnsexp_of_inttletint64_le_exnt=d"int64_le_exn"int64_le_exnsexp_of_inttletuint64_be_exnt=d"uint64_be_exn"uint64_be_exnsexp_of_inttletuint64_le_exnt=d"uint64_le_exn"uint64_le_exnsexp_of_inttletint64_t_bet=d"int64_t_be"int64_t_besexp_of_int64tletint64_t_let=d"int64_t_le"int64_t_lesexp_of_int64tletint64_be_trunct=d"int64_be_trunc"int64_be_truncsexp_of_inttletint64_le_trunct=d"int64_le_trunc"int64_le_truncsexp_of_inttlettail_padded_fixed_string~padding~lent=debug"Consume.tail_padded_fixed_string"[t](`paddingpadding,`lenlen)[%sexp_of:[`paddingofchar]*[`lenofint]]sexp_of_string(fun()->tail_padded_fixed_string~padding~lent)lethead_padded_fixed_string~padding~lent=debug"Consume.head_padded_fixed_string"[t](`paddingpadding,`lenlen)[%sexp_of:[`paddingofchar]*[`lenofint]]sexp_of_string(fun()->head_padded_fixed_string~padding~lent)letbytes~str_pos~lent=debug"Consume.bytes"[t]()(fun()->[%sexp{str_pos:int;len:int}])sexp_of_bytes(fun()->bytes~str_pos~lent)letstring~str_pos~lent=debug"Consume.string"[t]()(fun()->[%sexp{str_pos:int;len:int}])sexp_of_string(fun()->string~str_pos~lent)letbigstring~str_pos~lent=debug"Consume.bigstring"[t]()(fun()->[%sexp{str_pos:int;len:int}])sexp_of_bigstring(fun()->bigstring~str_pos~lent)letbyteso?str_pos?lent=debug"Consume.byteso"[t]()(fun()->[%sexp{str_pos:intoption;len:intoption}])sexp_of_bytes(fun()->byteso?str_pos?lent)letstringo?str_pos?lent=debug"Consume.stringo"[t]()(fun()->[%sexp{str_pos:intoption;len:intoption}])sexp_of_string(fun()->stringo?str_pos?lent)letbigstringo?str_pos?lent=debug"Consume.bigstringo"[t]()(fun()->[%sexp{str_pos:intoption;len:intoption}])sexp_of_bigstring(fun()->bigstringo?str_pos?lent)letbin_protreadert=debug"Consume.bin_prot"[t]()[%sexp_of:unit][%sexp_of:_](fun()->bin_protreadert)endmoduleFill=structletdnamefsexp_of_argtarg=debug("Fill."^name)[t]argsexp_of_argsexp_of_unit(fun()->ftarg);;openFilltypenonrec('a,'d,'w)t=('a,'d,'w)tletchart=d"char"charsexp_of_chartletint8_trunct=d"int8_trunc"int8_truncsexp_of_inttletint16_be_trunct=d"int16_be_trunc"int16_be_truncsexp_of_inttletint16_le_trunct=d"int16_le_trunc"int16_le_truncsexp_of_inttletint32_be_trunct=d"int32_be_trunc"int32_be_truncsexp_of_inttletint32_le_trunct=d"int32_le_trunc"int32_le_truncsexp_of_inttletuint8_trunct=d"uint8_trunc"uint8_truncsexp_of_inttletuint16_be_trunct=d"uint16_be_trunc"uint16_be_truncsexp_of_inttletuint16_le_trunct=d"uint16_le_trunc"uint16_le_truncsexp_of_inttletuint32_be_trunct=d"uint32_be_trunc"uint32_be_truncsexp_of_inttletuint32_le_trunct=d"uint32_le_trunc"uint32_le_truncsexp_of_inttletint64_bet=d"int64_be"int64_besexp_of_inttletint64_let=d"int64_le"int64_lesexp_of_inttletuint64_be_trunct=d"uint64_be_trunc"uint64_be_truncsexp_of_inttletuint64_le_trunct=d"uint64_le_trunc"uint64_le_truncsexp_of_inttletint64_t_bet=d"int64_t_be"int64_t_besexp_of_int64tletint64_t_let=d"int64_t_le"int64_t_lesexp_of_int64tletdecimalt=d"decimal"decimalsexp_of_inttlettail_padded_fixed_string~padding~lentstr=debug"Fill.tail_padded_fixed_string"[t](`paddingpadding,`lenlen,str)[%sexp_of:[`paddingofchar]*[`lenofint]*string]sexp_of_unit(fun()->tail_padded_fixed_string~padding~lentstr)lethead_padded_fixed_string~padding~lentstr=debug"Fill.head_padded_fixed_string"[t](`paddingpadding,`lenlen,str)[%sexp_of:[`paddingofchar]*[`lenofint]*string]sexp_of_unit(fun()->head_padded_fixed_string~padding~lentstr)letbytes~str_pos~lentstr=debug"Fill.bytes"[t](`str_posstr_pos,`lenlen,str)[%sexp_of:[`str_posofint]*[`lenofint]*bytes]sexp_of_unit(fun()->bytes~str_pos~lentstr)letstring~str_pos~lentstr=debug"Fill.string"[t](`str_posstr_pos,`lenlen,str)[%sexp_of:[`str_posofint]*[`lenofint]*string]sexp_of_unit(fun()->string~str_pos~lentstr)letbigstring~str_pos~lentstr=debug"Fill.bigstring"[t](`str_posstr_pos,`lenlen,str)[%sexp_of:[`str_posofint]*[`lenofint]*bigstring]sexp_of_unit(fun()->bigstring~str_pos~lentstr)letstringo?str_pos?lentstr=debug"Fill.stringo"[t](`str_posstr_pos,`lenlen,str)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*string]sexp_of_unit(fun()->stringo?str_pos?lentstr)letbyteso?str_pos?lentstr=debug"Fill.byteso"[t](`str_posstr_pos,`lenlen,str)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*bytes]sexp_of_unit(fun()->byteso?str_pos?lentstr)letbigstringo?str_pos?lentstr=debug"Fill.bigstringo"[t](`str_posstr_pos,`lenlen,str)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*bigstring]sexp_of_unit(fun()->bigstringo?str_pos?lentstr)letbin_protwriterta=debug"Fill.bin_prot"[t]()[%sexp_of:_][%sexp_of:unit](fun()->bin_protwriterta)endmodulePeek_blit_debug=structmoduletypeTo=Core_kernel.Blit.S_distinctwithtypesrc:=Peek.srcmoduletypeTo_string=sigvalsub:(Peek.src,string)Base.Blit.subvalsubo:(Peek.src,string)Base.Blit.suboendmoduleTo(To:sigincludeTovalsexp_of_dst:dst->Sexp.tvalmodule_name:stringend)=structletblito~src?src_pos?src_len~dst?dst_pos()=debug(To.module_name^".blito")[src](src_pos,src_len,dst,dst_pos)[%sexp_of:intoption*intoption*To.dst*intoption]sexp_of_unit(To.blito~src?src_pos?src_len~dst?dst_pos)letblit~src~src_pos~dst~dst_pos~len=debug(To.module_name^".blit")[src](src_pos,dst,dst_pos,len)[%sexp_of:int*To.dst*int*int]sexp_of_unit(fun()->To.blit~src~src_pos~dst~dst_pos~len)letunsafe_blit~src~src_pos~dst~dst_pos~len=debug(To.module_name^".unsafe_blit")[src](src_pos,dst,dst_pos,len)[%sexp_of:int*To.dst*int*int]sexp_of_unit(fun()->To.unsafe_blit~src~src_pos~dst~dst_pos~len)letsubsrc~pos~len=debug(To.module_name^".sub")[src](pos,len)[%sexp_of:int*int]To.sexp_of_dst(fun()->To.subsrc~pos~len)letsubo?pos?lensrc=debug(To.module_name^".subo")[src](pos,len)[%sexp_of:intoption*intoption]To.sexp_of_dst(fun()->To.subo?pos?lensrc)endmoduleMake(C:sigmoduleTo_bytes:Towithtypedst:=Bytes.tmoduleTo_bigstring:Towithtypedst:=bigstringmoduleTo_string:To_stringvalmodule_name:stringend)=structtypesrc=Peek.srcmoduleTo_bytes=To(structtypedst=Bytes.t[@@derivingsexp_of]includeC.To_bytesletmodule_name=C.module_name^".To_bytes"end)moduleTo_bigstring=To(structtypedst=bigstring[@@derivingsexp_of]includeC.To_bigstringletmodule_name=C.module_name^".To_bigstring"end)moduleTo_string=structincludeTo_bytesletsubsrc~pos~len=debug(C.module_name^".To_string.sub")[src](pos,len)[%sexp_of:int*int]sexp_of_string(fun()->C.To_string.subsrc~pos~len)letsubo?pos?lensrc=debug(C.module_name^".To_string.subo")[src](pos,len)[%sexp_of:intoption*intoption]sexp_of_string(fun()->C.To_string.subo?pos?lensrc)endendendmodulePeek=structletdnamefsexp_of_resultt~pos=debug("Peek."^name)[t](`pospos)[%sexp_of:[`posofint]]sexp_of_result(fun()->ft~pos);;openPeekincludePeek_blit_debug.Make(structincludePeekletmodule_name="Peek"end)typenonrec('a,'d,'w)t=('a,'d,'w)tletchart=d"char"charsexp_of_chartletint8t=d"int8"int8sexp_of_inttletint16_bet=d"int16_be"int16_besexp_of_inttletint16_let=d"int16_le"int16_lesexp_of_inttletint32_bet=d"int32_be"int32_besexp_of_inttletint32_let=d"int32_le"int32_lesexp_of_inttletuint8t=d"uint8"uint8sexp_of_inttletuint16_bet=d"uint16_be"uint16_besexp_of_inttletuint16_let=d"uint16_le"uint16_lesexp_of_inttletuint32_bet=d"uint32_be"uint32_besexp_of_inttletuint32_let=d"uint32_le"uint32_lesexp_of_inttletint64_be_exnt=d"int64_be_exn"int64_be_exnsexp_of_inttletint64_le_exnt=d"int64_le_exn"int64_le_exnsexp_of_inttletuint64_be_exnt=d"uint64_be_exn"uint64_be_exnsexp_of_inttletuint64_le_exnt=d"uint64_le_exn"uint64_le_exnsexp_of_inttletint64_t_bet=d"int64_t_be"int64_t_besexp_of_int64tletint64_t_let=d"int64_t_le"int64_t_lesexp_of_int64tletint64_be_trunct=d"int64_be_trunc"int64_be_truncsexp_of_inttletint64_le_trunct=d"int64_le_trunc"int64_le_truncsexp_of_inttlettail_padded_fixed_string~padding~lent~pos=debug"Peek.tail_padded_fixed_string"[t](`paddingpadding,`lenlen,`pospos)[%sexp_of:[`paddingofchar]*[`lenofint]*[`posofint]]sexp_of_string(fun()->tail_padded_fixed_string~padding~lent~pos)lethead_padded_fixed_string~padding~lent~pos=debug"Peek.head_padded_fixed_string"[t](`paddingpadding,`lenlen,`pospos)[%sexp_of:[`paddingofchar]*[`lenofint]*[`posofint]]sexp_of_string(fun()->head_padded_fixed_string~padding~lent~pos)letbytes~str_pos~lent~pos=debug"Peek.bytes"[t](`str_posstr_pos,`lenlen,`pospos)[%sexp_of:[`str_posofint]*[`lenofint]*[`posofint]]sexp_of_bytes(fun()->bytes~str_pos~lent~pos)letstring~str_pos~lent~pos=debug"Peek.string"[t](`str_posstr_pos,`lenlen,`pospos)[%sexp_of:[`str_posofint]*[`lenofint]*[`posofint]]sexp_of_string(fun()->string~str_pos~lent~pos)letbigstring~str_pos~lent~pos=debug"Peek.bigstring"[t](`str_posstr_pos,`lenlen,`pospos)[%sexp_of:[`str_posofint]*[`lenofint]*[`posofint]]sexp_of_bigstring(fun()->bigstring~str_pos~lent~pos)letbyteso?str_pos?lent~pos=debug"Peek.byteso"[t](`str_posstr_pos,`lenlen,`pospos)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*[`posofint]]sexp_of_bytes(fun()->byteso?str_pos?lent~pos)letstringo?str_pos?lent~pos=debug"Peek.stringo"[t](`str_posstr_pos,`lenlen,`pospos)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*[`posofint]]sexp_of_string(fun()->stringo?str_pos?lent~pos)letbigstringo?str_pos?lent~pos=debug"Peek.bigstringo"[t](`str_posstr_pos,`lenlen,`pospos)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*[`posofint]]sexp_of_bigstring(fun()->bigstringo?str_pos?lent~pos)letbin_protreadert~pos=debug"Consume.bin_prot"[t](`pospos)[%sexp_of:[`posofint]][%sexp_of:_](fun()->bin_protreadert~pos)letindext?pos?lenc=debug"Peek.index"[t](`pospos,`lenlen,`cc)[%sexp_of:[`posofintoption]*[`lenofintoption]*[`cofchar]][%sexp_of:intoption](fun()->indext?pos?lenc)endmodulePoke=structletdnamefsexp_of_argt~posarg=debug("Poke."^name)[t](`pospos,arg)(Tuple.T2.sexp_of_t[%sexp_of:[`posofint]]sexp_of_arg)sexp_of_unit(fun()->ft~posarg);;openPoketypenonrec('a,'d,'w)t=('a,'d,'w)tletchart=d"char"charsexp_of_chartletint8_trunct=d"int8_trunc"int8_truncsexp_of_inttletint16_be_trunct=d"int16_be_trunc"int16_be_truncsexp_of_inttletint16_le_trunct=d"int16_le_trunc"int16_le_truncsexp_of_inttletint32_be_trunct=d"int32_be_trunc"int32_be_truncsexp_of_inttletint32_le_trunct=d"int32_le_trunc"int32_le_truncsexp_of_inttletuint8_trunct=d"uint8_trunc"uint8_truncsexp_of_inttletuint16_be_trunct=d"uint16_be_trunc"uint16_be_truncsexp_of_inttletuint16_le_trunct=d"uint16_le_trunc"uint16_le_truncsexp_of_inttletuint32_be_trunct=d"uint32_be_trunc"uint32_be_truncsexp_of_inttletuint32_le_trunct=d"uint32_le_trunc"uint32_le_truncsexp_of_inttletint64_bet=d"int64_be"int64_besexp_of_inttletint64_let=d"int64_le"int64_lesexp_of_inttletuint64_be_trunct=d"uint64_be_trunc"uint64_be_truncsexp_of_inttletuint64_le_trunct=d"uint64_le_trunc"uint64_le_truncsexp_of_inttletint64_t_bet=d"int64_t_be"int64_t_besexp_of_int64tletint64_t_let=d"int64_t_le"int64_t_lesexp_of_int64tletdecimalt~posarg=debug"Poke.decimal"[t](`pospos,arg)[%sexp_of:[`posofint]*int]sexp_of_int(fun()->decimalt~posarg)lettail_padded_fixed_string~padding~lent~posstr=debug"Poke.tail_padded_fixed_string"[t](`paddingpadding,`lenlen,`pospos,str)[%sexp_of:[`paddingofchar]*[`lenofint]*[`posofint]*string]sexp_of_unit(fun()->tail_padded_fixed_string~padding~lent~posstr)lethead_padded_fixed_string~padding~lent~posstr=debug"Poke.head_padded_fixed_string"[t](`paddingpadding,`lenlen,`pospos,str)[%sexp_of:[`paddingofchar]*[`lenofint]*[`posofint]*string]sexp_of_unit(fun()->head_padded_fixed_string~padding~lent~posstr)letbytes~str_pos~lent~posstr=debug"Poke.bytes"[t](`str_posstr_pos,`lenlen,`pospos,str)[%sexp_of:[`str_posofint]*[`lenofint]*[`posofint]*bytes]sexp_of_unit(fun()->bytes~str_pos~lent~posstr)letstring~str_pos~lent~posstr=debug"Poke.string"[t](`str_posstr_pos,`lenlen,`pospos,str)[%sexp_of:[`str_posofint]*[`lenofint]*[`posofint]*string]sexp_of_unit(fun()->string~str_pos~lent~posstr)letbigstring~str_pos~lent~posstr=debug"Poke.bigstring"[t](`str_posstr_pos,`lenlen,`pospos,str)[%sexp_of:[`str_posofint]*[`lenofint]*[`posofint]*bigstring]sexp_of_unit(fun()->bigstring~str_pos~lent~posstr)letbyteso?str_pos?lent~posstr=debug"Poke.byteso"[t](`str_posstr_pos,`lenlen,`pospos,str)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*[`posofint]*bytes]sexp_of_unit(fun()->byteso?str_pos?lent~posstr)letstringo?str_pos?lent~posstr=debug"Poke.stringo"[t](`str_posstr_pos,`lenlen,`pospos,str)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*[`posofint]*string]sexp_of_unit(fun()->stringo?str_pos?lent~posstr)letbigstringo?str_pos?lent~posstr=debug"Poke.bigstringo"[t](`str_posstr_pos,`lenlen,`pospos,str)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*[`posofint]*bigstring]sexp_of_unit(fun()->bigstringo?str_pos?lent~posstr)letbin_protwritert~posa=debug"Poke.bin_prot"[t](`pospos)[%sexp_of:[`posofint]][%sexp_of:unit](fun()->bin_protwriterta~pos)endletconsume_bin_prottr=debug"consume_bin_prot"[t]t[%sexp_of:(_,_)t][%sexp_of:_Or_error.t](fun()->consume_bin_prottr);;letbin_prot_length_prefix_bytes=bin_prot_length_prefix_bytesletfill_bin_prottwa=debug"fill_bin_prot"[t]t[%sexp_of:(_,_)t][%sexp_of:unitOr_error.t](fun()->fill_bin_prottwa);;moduleBlit=structopenBlittype'rwt_no_seek='rwBlit.t_no_seekletunsafe_blit~src~src_pos~dst~dst_pos~len=debug_blit"Blit.unsafe_blit"~src~dst(`src_possrc_pos,`dst_posdst_pos,`lenlen)([%sexp_of:[`src_posofint]*[`dst_posofint]*[`lenofint]])([%sexp_of:unit])(fun()->unsafe_blit~src~src_pos~dst~dst_pos~len);;letblit~src~src_pos~dst~dst_pos~len=debug_blit"Blit.blit"~src~dst(`src_possrc_pos,`dst_posdst_pos,`lenlen)([%sexp_of:[`src_posofint]*[`dst_posofint]*[`lenofint]])([%sexp_of:unit])(fun()->blit~src~src_pos~dst~dst_pos~len);;letblito~src?src_pos?src_len~dst?dst_pos()=debug_blit"Blit.blito"~src~dst(`src_possrc_pos,`src_lensrc_len,`dst_posdst_pos)([%sexp_of:[`src_posofintoption]*[`src_lenofintoption]*[`dst_posofintoption]])([%sexp_of:unit])(fun()->blito~src?src_pos?src_len~dst?dst_pos());;letsubt~pos~len=debug"Blit.sub"[t](`pospos,`lenlen)([%sexp_of:[`posofint]*[`lenofint]])([%sexp_of:(_,_)t])(fun()->lett=subt~pos~leninif!check_invarianttheninvariantignoreignoret;t);;letsubo?pos?lent=debug"Blit.subo"[t](`pospos,`lenlen)([%sexp_of:[`posofintoption]*[`lenofintoption]])([%sexp_of:(_,_)t])(fun()->lett=subo?pos?lentinif!check_invarianttheninvariantignoreignoret;t);;endmoduleBlit_consume=structopenBlit_consumeletunsafe_blit~src~dst~dst_pos~len=debug_blit"Blit_consume.unsafe_blit"~src~dst(`dst_posdst_pos,`lenlen)([%sexp_of:[`dst_posofint]*[`lenofint]])([%sexp_of:unit])(fun()->unsafe_blit~src~dst~dst_pos~len);;letblit~src~dst~dst_pos~len=debug_blit"Blit_consume.blit"~src~dst(`dst_posdst_pos,`lenlen)([%sexp_of:[`dst_posofint]*[`lenofint]])([%sexp_of:unit])(fun()->blit~src~dst~dst_pos~len);;letblito~src?src_len~dst?dst_pos()=debug_blit"Blit_consume.blito"~src~dst(`src_lensrc_len,`dst_posdst_pos)([%sexp_of:[`src_lenofintoption]*[`dst_posofintoption]])([%sexp_of:unit])(fun()->blito~src?src_len~dst?dst_pos());;letsubt~len=debug"Blit_consume.sub"[t](`lenlen)([%sexp_of:[`lenofint]])([%sexp_of:(_,_)t])(fun()->lett=subt~leninif!check_invarianttheninvariantignoreignoret;t);;letsubo?lent=debug"Blit_consume.subo"[t](`lenlen)([%sexp_of:[`lenofintoption]])([%sexp_of:(_,_)t])(fun()->lett=subo?lentinif!check_invarianttheninvariantignoreignoret;t);;endmoduleBlit_fill=structopenBlit_fillletunsafe_blit~src~src_pos~dst~len=debug_blit"Blit_fill.unsafe_blit"~src~dst(`src_possrc_pos,`lenlen)([%sexp_of:[`src_posofint]*[`lenofint]])([%sexp_of:unit])(fun()->unsafe_blit~src~src_pos~dst~len);;letblit~src~src_pos~dst~len=debug_blit"Blit_fill.blit"~src~dst(`src_possrc_pos,`lenlen)([%sexp_of:[`src_posofint]*[`lenofint]])([%sexp_of:unit])(fun()->blit~src~src_pos~dst~len);;letblito~src?src_pos?src_len~dst()=debug_blit"Blit_fill.blito"~src~dst(`src_possrc_pos,`src_lensrc_len)([%sexp_of:[`src_posofintoption]*[`src_lenofintoption]])([%sexp_of:unit])(fun()->blito~src?src_pos?src_len~dst());;endmoduleBlit_consume_and_fill=structopenBlit_consume_and_fillletunsafe_blit~src~dst~len=debug_blit"Blit_consume_and_fill.unsafe_blit"~src~dst(`lenlen)([%sexp_of:[`lenofint]])([%sexp_of:unit])(fun()->unsafe_blit~src~dst~len);;letblit~src~dst~len=debug_blit"Blit_consume_and_fill.blit"~src~dst(`lenlen)([%sexp_of:[`lenofint]])([%sexp_of:unit])(fun()->blit~src~dst~len);;letblito~src?src_len~dst()=debug_blit"Blit_consume_and_fill.blito"~src~dst(`src_lensrc_len)([%sexp_of:[`src_lenofintoption]])([%sexp_of:unit])(fun()->blito~src?src_len~dst());;endmoduleExpert=structletbuf=Expert.buflethi_max=Expert.hi_maxlethi=Expert.hiletlo=Expert.loletlo_min=Expert.lo_minletto_bigstring_shared?pos?lent=debug"to_bigstring_shared"[t](`pospos,`lenlen)[%sexp_of:[`posofintoption]*[`lenofintoption]][%sexp_of:Bigstring.t](fun()->Expert.to_bigstring_shared?pos?lent);;letto_iovec_shared?pos?lent=debug"to_iovec_shared"[t](`pospos,`lenlen)[%sexp_of:[`posofintoption]*[`lenofintoption]][%sexp_of:Bigstring.tUnix.IOVec.t](fun()->Expert.to_iovec_shared?pos?lent);;letreinitialize_of_bigstringt~pos~lenbuf=debug"reinitialize_of_bigstring"[t](`pospos,`lenlen)[%sexp_of:[`posofint]*[`lenofint]]sexp_of_unit(fun()->Expert.reinitialize_of_bigstringt~pos~lenbuf);;letset_bounds_and_buffer_sub~pos~len~src~dst=debug"sub"[src](`pospos,`lenlen)[%sexp_of:[`posofint]*[`lenofint]]sexp_of_unit(fun()->Expert.set_bounds_and_buffer_sub~pos~len~src~dst);;letset_bounds_and_buffer~src~dst=debug"copy"[src]src[%sexp_of:(_,_)t]sexp_of_unit(fun()->Expert.set_bounds_and_buffer~src~dst);;endtypenonrecok_or_eof=ok_or_eof=Ok|Eof[@@derivingcompare,sexp_of]moduleFile_descr=Unix.File_descrmoduleIn_channel=structincludeIn_channelletsexp_of_tt=File_descr.sexp_of_t(Unix.descr_of_in_channelt)endmoduleOut_channel=structincludeOut_channelletsexp_of_tt=File_descr.sexp_of_t(Unix.descr_of_out_channelt)endletinputtch=debug"input"[t]ch([%sexp_of:In_channel.t])([%sexp_of:ok_or_eof])(fun()->inputtch);;letreadtfd=debug"read"[t]fd([%sexp_of:File_descr.t])([%sexp_of:ok_or_eof])(fun()->readtfd);;letread_assume_fd_is_nonblockingtfd=debug"read_assume_fd_is_nonblocking"[t]fd([%sexp_of:File_descr.t])([%sexp_of:Syscall_result.Unit.t])(fun()->read_assume_fd_is_nonblockingtfd);;letpread_assume_fd_is_nonblockingtfd~offset=debug"pread_assume_fd_is_nonblocking"[t](fd,`offsetoffset)([%sexp_of:File_descr.t*[`offsetofint]])([%sexp_of:unit])(fun()->pread_assume_fd_is_nonblockingtfd~offset);;letrecvfrom_assume_fd_is_nonblockingtfd=debug"recvfrom_assume_fd_is_nonblocking"[t]fd([%sexp_of:File_descr.t])([%sexp_of:Unix.sockaddr])(fun()->recvfrom_assume_fd_is_nonblockingtfd);;moduleRecvmmsg_context=Recvmmsg_contextletrecvmmsg_assume_fd_is_nonblocking=Or_error.maprecvmmsg_assume_fd_is_nonblocking~f:(funrecvmmsgfdcontext->debug"recvmmsg_assume_fd_is_nonblocking"[]fd[%sexp_of:File_descr.t][%sexp_of:Unix.Syscall_result.Int.t](fun()->recvmmsgfdcontext));;letsend_nonblocking_no_sigpipe()=Or_error.map(send_nonblocking_no_sigpipe())~f:(funsend->funtfd->debug"send_nonblocking_no_sigpipe"[t](fd,t)([%sexp_of:File_descr.t*(_,_)t])([%sexp_of:Syscall_result.Unit.t])(fun()->sendtfd));;letsendto_nonblocking_no_sigpipe()=Or_error.map(sendto_nonblocking_no_sigpipe())~f:(funsendto->funtfdaddr->debug"sendto_nonblocking_no_sigpipe"[t](fd,addr)[%sexp_of:File_descr.t*Unix.sockaddr][%sexp_of:Syscall_result.Unit.t](fun()->sendtotfdaddr))letoutputtch=debug"output"[t]ch([%sexp_of:Out_channel.t])([%sexp_of:unit])(fun()->outputtch);;letwritetfd=debug"write"[t]fd([%sexp_of:File_descr.t])([%sexp_of:unit])(fun()->writetfd);;letwrite_assume_fd_is_nonblockingtfd=debug"write_assume_fd_is_nonblocking"[t](fd,t)([%sexp_of:File_descr.t*(_,_)t])([%sexp_of:unit])(fun()->write_assume_fd_is_nonblockingtfd);;letpwrite_assume_fd_is_nonblockingtfd~offset=debug"pwrite_assume_fd_is_nonblocking"[t](fd,t,`offsetoffset)([%sexp_of:File_descr.t*(_,_)t*[`offsetofint]])([%sexp_of:unit])(fun()->pwrite_assume_fd_is_nonblockingtfd~offset);;moduleUnsafe=structopenUnsafe(* Sorry, these are almost textual copies of the functions above. For test purposes,
it might be possible to functorize some of this. *)moduleConsume=structletdnamefsexp_of_resultt=debug("Unsafe.Consume."^name)[t]t[%sexp_of:(_,_)t]sexp_of_result(fun()->ft);;openConsumeincludeConsume_blit_debug.Make(structincludeConsumeletmodule_name="Unsafe.Consume"end)typenonrec('a,'d,'w)t=('a,'d,'w)tletchart=d"char"charsexp_of_chartletint8t=d"int8"int8sexp_of_inttletint16_bet=d"int16_be"int16_besexp_of_inttletint16_let=d"int16_le"int16_lesexp_of_inttletint32_bet=d"int32_be"int32_besexp_of_inttletint32_let=d"int32_le"int32_lesexp_of_inttletuint8t=d"uint8"uint8sexp_of_inttletuint16_bet=d"uint16_be"uint16_besexp_of_inttletuint16_let=d"uint16_le"uint16_lesexp_of_inttletuint32_bet=d"uint32_be"uint32_besexp_of_inttletuint32_let=d"uint32_le"uint32_lesexp_of_inttletint64_be_exnt=d"int64_be_exn"int64_be_exnsexp_of_inttletint64_le_exnt=d"int64_le_exn"int64_le_exnsexp_of_inttletuint64_be_exnt=d"uint64_be_exn"uint64_be_exnsexp_of_inttletuint64_le_exnt=d"uint64_le_exn"uint64_le_exnsexp_of_inttletint64_t_bet=d"int64_t_be"int64_t_besexp_of_int64tletint64_t_let=d"int64_t_le"int64_t_lesexp_of_int64tletint64_be_trunct=d"int64_be_trunc"int64_be_truncsexp_of_inttletint64_le_trunct=d"int64_le_trunc"int64_le_truncsexp_of_inttlettail_padded_fixed_string~padding~lent=debug"Unsafe.Consume.tail_padded_fixed_string"[t](`paddingpadding,`lenlen)[%sexp_of:[`paddingofchar]*[`lenofint]]sexp_of_string(fun()->tail_padded_fixed_string~padding~lent)lethead_padded_fixed_string~padding~lent=debug"Unsafe.Consume.head_padded_fixed_string"[t](`paddingpadding,`lenlen)[%sexp_of:[`paddingofchar]*[`lenofint]]sexp_of_string(fun()->head_padded_fixed_string~padding~lent)letbytes~str_pos~lent=debug"Unsafe.Consume.bytes"[t](`str_posstr_pos,`lenlen)[%sexp_of:[`str_posofint]*[`lenofint]]sexp_of_bytes(fun()->bytes~str_pos~lent)letstring~str_pos~lent=debug"Unsafe.Consume.string"[t](`str_posstr_pos,`lenlen)[%sexp_of:[`str_posofint]*[`lenofint]]sexp_of_string(fun()->string~str_pos~lent)letbigstring~str_pos~lent=debug"Unsafe.Consume.bigstring"[t](`str_posstr_pos,`lenlen)[%sexp_of:[`str_posofint]*[`lenofint]]sexp_of_bigstring(fun()->bigstring~str_pos~lent)letbyteso?str_pos?lent=debug"Unsafe.Consume.byteso"[t](`str_posstr_pos,`lenlen)[%sexp_of:[`str_posofintoption]*[`lenofintoption]]sexp_of_bytes(fun()->byteso?str_pos?lent)letstringo?str_pos?lent=debug"Unsafe.Consume.stringo"[t](`str_posstr_pos,`lenlen)[%sexp_of:[`str_posofintoption]*[`lenofintoption]]sexp_of_string(fun()->stringo?str_pos?lent)letbigstringo?str_pos?lent=debug"Unsafe.Consume.bigstringo"[t](`str_posstr_pos,`lenlen)[%sexp_of:[`str_posofintoption]*[`lenofintoption]]sexp_of_bigstring(fun()->bigstringo?str_pos?lent)letbin_protreadert=debug"Unsafe.Consume.bin_prot"[t]()[%sexp_of:unit][%sexp_of:_](fun()->bin_protreadert)endmoduleFill=structletdnamefsexp_of_argtarg=debug("Unsafe.Fill."^name)[t]argsexp_of_argsexp_of_unit(fun()->ftarg);;openFilltypenonrec('a,'d,'w)t=('a,'d,'w)tletchart=d"char"charsexp_of_chartletint8_trunct=d"int8_trunc"int8_truncsexp_of_inttletint16_be_trunct=d"int16_be_trunc"int16_be_truncsexp_of_inttletint16_le_trunct=d"int16_le_trunc"int16_le_truncsexp_of_inttletint32_be_trunct=d"int32_be_trunc"int32_be_truncsexp_of_inttletint32_le_trunct=d"int32_le_trunc"int32_le_truncsexp_of_inttletuint8_trunct=d"uint8_trunc"uint8_truncsexp_of_inttletuint16_be_trunct=d"uint16_be_trunc"uint16_be_truncsexp_of_inttletuint16_le_trunct=d"uint16_le_trunc"uint16_le_truncsexp_of_inttletuint32_be_trunct=d"uint32_be_trunc"uint32_be_truncsexp_of_inttletuint32_le_trunct=d"uint32_le_trunc"uint32_le_truncsexp_of_inttletint64_bet=d"int64_be"int64_besexp_of_inttletint64_let=d"int64_le"int64_lesexp_of_inttletuint64_be_trunct=d"uint64_be_trunc"uint64_be_truncsexp_of_inttletuint64_le_trunct=d"uint64_le_trunc"uint64_le_truncsexp_of_inttletint64_t_bet=d"int64_t_be"int64_t_besexp_of_int64tletint64_t_let=d"int64_t_le"int64_t_lesexp_of_int64tletdecimalt=d"decimal"decimalsexp_of_inttlettail_padded_fixed_string~padding~lentstr=debug"Unsafe.Fill.tail_padded_fixed_string"[t](`paddingpadding,`lenlen,str)[%sexp_of:[`paddingofchar]*[`lenofint]*string]sexp_of_unit(fun()->tail_padded_fixed_string~padding~lentstr)lethead_padded_fixed_string~padding~lentstr=debug"Unsafe.Fill.head_padded_fixed_string"[t](`paddingpadding,`lenlen,str)[%sexp_of:[`paddingofchar]*[`lenofint]*string]sexp_of_unit(fun()->head_padded_fixed_string~padding~lentstr)letbytes~str_pos~lentstr=debug"Unsafe.Fill.bytes"[t](`str_posstr_pos,`lenlen,str)[%sexp_of:[`str_posofint]*[`lenofint]*bytes]sexp_of_unit(fun()->bytes~str_pos~lentstr)letstring~str_pos~lentstr=debug"Unsafe.Fill.string"[t](`str_posstr_pos,`lenlen,str)[%sexp_of:[`str_posofint]*[`lenofint]*string]sexp_of_unit(fun()->string~str_pos~lentstr)letbigstring~str_pos~lentstr=debug"Unsafe.Fill.bigstring"[t](`str_posstr_pos,`lenlen,str)[%sexp_of:[`str_posofint]*[`lenofint]*bigstring]sexp_of_unit(fun()->bigstring~str_pos~lentstr)letbyteso?str_pos?lentstr=debug"Unsafe.Fill.byteso"[t](`str_posstr_pos,`lenlen,str)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*bytes]sexp_of_unit(fun()->byteso?str_pos?lentstr)letstringo?str_pos?lentstr=debug"Unsafe.Fill.stringo"[t](`str_posstr_pos,`lenlen,str)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*string]sexp_of_unit(fun()->stringo?str_pos?lentstr)letbigstringo?str_pos?lentstr=debug"Unsafe.Fill.bigstringo"[t](`str_posstr_pos,`lenlen,str)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*bigstring]sexp_of_unit(fun()->bigstringo?str_pos?lentstr)letbin_protwriterta=debug"Unsafe.Fill.bin_prot"[t]()[%sexp_of:_][%sexp_of:unit](fun()->bin_protwriterta)endmodulePeek=structletdnamefsexp_of_resultt~pos=debug("Unsafe.Peek."^name)[t](`pospos)[%sexp_of:[`posofint]]sexp_of_result(fun()->ft~pos);;openPeekincludePeek_blit_debug.Make(structincludePeekletmodule_name="Unsafe.Peek"end)typenonrec('a,'d,'w)t=('a,'d,'w)tletchart=d"char"charsexp_of_chartletint8t=d"int8"int8sexp_of_inttletint16_bet=d"int16_be"int16_besexp_of_inttletint16_let=d"int16_le"int16_lesexp_of_inttletint32_bet=d"int32_be"int32_besexp_of_inttletint32_let=d"int32_le"int32_lesexp_of_inttletuint8t=d"uint8"uint8sexp_of_inttletuint16_bet=d"uint16_be"uint16_besexp_of_inttletuint16_let=d"uint16_le"uint16_lesexp_of_inttletuint32_bet=d"uint32_be"uint32_besexp_of_inttletuint32_let=d"uint32_le"uint32_lesexp_of_inttletint64_be_exnt=d"int64_be_exn"int64_be_exnsexp_of_inttletint64_le_exnt=d"int64_le_exn"int64_le_exnsexp_of_inttletuint64_be_exnt=d"uint64_be_exn"uint64_be_exnsexp_of_inttletuint64_le_exnt=d"uint64_le_exn"uint64_le_exnsexp_of_inttletint64_t_bet=d"int64_t_be"int64_t_besexp_of_int64tletint64_t_let=d"int64_t_le"int64_t_lesexp_of_int64tletint64_be_trunct=d"int64_be_trunc"int64_be_truncsexp_of_inttletint64_le_trunct=d"int64_le_trunc"int64_le_truncsexp_of_inttlettail_padded_fixed_string~padding~lent~pos=debug"Unsafe.Peek.tail_padded_fixed_string"[t](`paddingpadding,`lenlen,`pospos)[%sexp_of:[`paddingofchar]*[`lenofint]*[`posofint]]sexp_of_string(fun()->tail_padded_fixed_string~padding~lent~pos)lethead_padded_fixed_string~padding~lent~pos=debug"Unsafe.Peek.head_padded_fixed_string"[t](`paddingpadding,`lenlen,`pospos)[%sexp_of:[`paddingofchar]*[`lenofint]*[`posofint]]sexp_of_string(fun()->head_padded_fixed_string~padding~lent~pos)letbytes~str_pos~lent~pos=debug"Unsafe.Peek.bytes"[t](`str_posstr_pos,`lenlen,`pospos)[%sexp_of:[`str_posofint]*[`lenofint]*[`posofint]]sexp_of_bytes(fun()->bytes~str_pos~lent~pos)letstring~str_pos~lent~pos=debug"Unsafe.Peek.string"[t](`str_posstr_pos,`lenlen,`pospos)[%sexp_of:[`str_posofint]*[`lenofint]*[`posofint]]sexp_of_string(fun()->string~str_pos~lent~pos)letbigstring~str_pos~lent~pos=debug"Unsafe.Peek.bigstring"[t](`str_posstr_pos,`lenlen,`pospos)[%sexp_of:[`str_posofint]*[`lenofint]*[`posofint]]sexp_of_bigstring(fun()->bigstring~str_pos~lent~pos)letbyteso?str_pos?lent~pos=debug"Unsafe.Peek.byteso"[t](`str_posstr_pos,`lenlen,`pospos)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*[`posofint]]sexp_of_bytes(fun()->byteso?str_pos?lent~pos)letstringo?str_pos?lent~pos=debug"Unsafe.Peek.stringo"[t](`str_posstr_pos,`lenlen,`pospos)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*[`posofint]]sexp_of_string(fun()->stringo?str_pos?lent~pos)letbigstringo?str_pos?lent~pos=debug"Unsafe.Peek.bigstringo"[t](`str_posstr_pos,`lenlen,`pospos)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*[`posofint]]sexp_of_bigstring(fun()->bigstringo?str_pos?lent~pos)letbin_protreadert~pos=debug"Unsafe.Consume.bin_prot"[t](`pospos)[%sexp_of:[`posofint]][%sexp_of:_](fun()->bin_protreadert~pos)letindext?pos?lenc=debug"Unsafe.Peek.index"[t](`pospos,`lenlen,`cc)[%sexp_of:[`posofintoption]*[`lenofintoption]*[`cofchar]][%sexp_of:intoption](fun()->indext?pos?lenc)endmodulePoke=structletdnamefsexp_of_argt~posarg=debug("Unsafe.Poke."^name)[t](`pospos,arg)(Tuple.T2.sexp_of_t[%sexp_of:[`posofint]]sexp_of_arg)sexp_of_unit(fun()->ft~posarg);;openPoketypenonrec('a,'d,'w)t=('a,'d,'w)tletchart=d"char"charsexp_of_chartletint8_trunct=d"int8_trunc"int8_truncsexp_of_inttletint16_be_trunct=d"int16_be_trunc"int16_be_truncsexp_of_inttletint16_le_trunct=d"int16_le_trunc"int16_le_truncsexp_of_inttletint32_be_trunct=d"int32_be_trunc"int32_be_truncsexp_of_inttletint32_le_trunct=d"int32_le_trunc"int32_le_truncsexp_of_inttletuint8_trunct=d"uint8_trunc"uint8_truncsexp_of_inttletuint16_be_trunct=d"uint16_be_trunc"uint16_be_truncsexp_of_inttletuint16_le_trunct=d"uint16_le_trunc"uint16_le_truncsexp_of_inttletuint32_be_trunct=d"uint32_be_trunc"uint32_be_truncsexp_of_inttletuint32_le_trunct=d"uint32_le_trunc"uint32_le_truncsexp_of_inttletint64_bet=d"int64_be"int64_besexp_of_inttletint64_let=d"int64_le"int64_lesexp_of_inttletuint64_be_trunct=d"uint64_be_trunc"uint64_be_truncsexp_of_inttletuint64_le_trunct=d"uint64_le_trunc"uint64_le_truncsexp_of_inttletint64_t_bet=d"int64_t_be"int64_t_besexp_of_int64tletint64_t_let=d"int64_t_le"int64_t_lesexp_of_int64tletdecimalt~posarg=debug"Unsafe.Poke.decimal"[t](`pospos,arg)[%sexp_of:[`posofint]*int]sexp_of_int(fun()->decimalt~posarg)lettail_padded_fixed_string~padding~lent~posstr=debug"Unsafe.Poke.tail_padded_fixed_string"[t](`paddingpadding,`lenlen,`pospos,str)[%sexp_of:[`paddingofchar]*[`lenofint]*[`posofint]*string]sexp_of_unit(fun()->tail_padded_fixed_string~padding~lent~posstr)lethead_padded_fixed_string~padding~lent~posstr=debug"Unsafe.Poke.head_padded_fixed_string"[t](`paddingpadding,`lenlen,`pospos,str)[%sexp_of:[`paddingofchar]*[`lenofint]*[`posofint]*string]sexp_of_unit(fun()->head_padded_fixed_string~padding~lent~posstr)letbytes~str_pos~lent~posstr=debug"Unsafe.Poke.bytes"[t](`str_posstr_pos,`lenlen,`pospos,str)[%sexp_of:[`str_posofint]*[`lenofint]*[`posofint]*bytes]sexp_of_unit(fun()->bytes~str_pos~lent~posstr)letstring~str_pos~lent~posstr=debug"Unsafe.Poke.string"[t](`str_posstr_pos,`lenlen,`pospos,str)[%sexp_of:[`str_posofint]*[`lenofint]*[`posofint]*string]sexp_of_unit(fun()->string~str_pos~lent~posstr)letbigstring~str_pos~lent~posstr=debug"Unsafe.Poke.bigstring"[t](`str_posstr_pos,`lenlen,`pospos,str)[%sexp_of:[`str_posofint]*[`lenofint]*[`posofint]*bigstring]sexp_of_unit(fun()->bigstring~str_pos~lent~posstr)letbyteso?str_pos?lent~posstr=debug"Unsafe.Poke.byteso"[t](`str_posstr_pos,`lenlen,`pospos,str)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*[`posofint]*bytes]sexp_of_unit(fun()->byteso?str_pos?lent~posstr)letstringo?str_pos?lent~posstr=debug"Unsafe.Poke.stringo"[t](`str_posstr_pos,`lenlen,`pospos,str)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*[`posofint]*string]sexp_of_unit(fun()->stringo?str_pos?lent~posstr)letbigstringo?str_pos?lent~posstr=debug"Unsafe.Poke.bigstringo"[t](`str_posstr_pos,`lenlen,`pospos,str)[%sexp_of:[`str_posofintoption]*[`lenofintoption]*[`posofint]*bigstring]sexp_of_unit(fun()->bigstringo?str_pos?lent~posstr)letbin_protwritert~posa=debug"Unsafe.Poke.bin_prot"[t](`pospos)[%sexp_of:[`posofint]][%sexp_of:unit](fun()->bin_protwriterta~pos)endendend