123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057(** ExtUnix
These functions are thin wrappers for underlying system API, consult
the corresponding man pages and/or system documentation for details.
*)(** [Not_available "symbol"] may be raised by functions in {!ExtUnix.All}
if the wrapped C function or constant is not available on this platform.
{!ExtUnix.Specific} includes only functions available on the current
platform and will not raise [Not_available].
Note that libc wrappers underlying {!ExtUnix.Specific} functions may still raise
[ENOSYS] (Not implemented) error even though the function is available. *)exceptionNot_availableofstringlet()=Callback.register_exception"ExtUnix.Not_available"(Not_available"")(** type of bigarray used by BA submodules that read from files into
bigarrays or write bigarrays into files. The only constraint here
is [Bigarray.c_layout].
Naming: "bigarray with C layout" -> "carray". *)type('a,'b)carray=('a,'b,Bigarray.c_layout)Bigarray.Array1.t(** type of bigarray used by BA submodules that work with endianness
and memory. Constraints are:
+ [Bigarray.c_layout],
+ bigarray contains 8-bit integers.
Naming: "bigarray with C layout and 8-bit elements" -> "carray8". *)type'acarray8=('a,Bigarray.int8_unsigned_elt,Bigarray.c_layout)Bigarray.Array1.ttypeopen_flag=Unix.open_flag(*
= O_RDONLY | O_WRONLY | O_RDWR | O_NONBLOCK | O_APPEND | O_CREAT
| O_TRUNC | O_EXCL | O_NOCTTY | O_DSYNC | O_SYNC | O_RSYNC
| O_SHARE_DELETE | O_CLOEXEC
*)[%%haveEVENTFDexternaleventfd:int->Unix.file_descr="caml_extunix_eventfd"externaleventfd_read:Unix.file_descr->int64="caml_extunix_eventfd_read"externaleventfd_write:Unix.file_descr->int64->unit="caml_extunix_eventfd_write"][%%haveSYSLOGmoduleSyslog:sigtypeoptions=LOG_PID|LOG_CONS|LOG_NDELAY|LOG_ODELAY|LOG_NOWAITtypefacility=LOG_KERN|LOG_USER|LOG_MAIL|LOG_NEWS|LOG_UUCP|LOG_DAEMON|LOG_AUTH|LOG_CRON|LOG_LPR|LOG_LOCAL0|LOG_LOCAL1|LOG_LOCAL2|LOG_LOCAL3|LOG_LOCAL4|LOG_LOCAL5|LOG_LOCAL6|LOG_LOCAL7typelevel=LOG_EMERG|LOG_ALERT|LOG_CRIT|LOG_ERR|LOG_WARNING|LOG_NOTICE|LOG_INFO|LOG_DEBUGvalsetlogmask:levellist->levellistvalopenlog:?ident:string->optionslist->facility->unitvalcloselog:unit->unitvalsyslog:?facility:facility->level->('a,unit,string,unit)format4->'avallog_upto:level->levellistend=structtypeoptions=LOG_PID|LOG_CONS|LOG_NDELAY|LOG_ODELAY|LOG_NOWAITtypefacility=LOG_KERN|LOG_USER|LOG_MAIL|LOG_NEWS|LOG_UUCP|LOG_DAEMON|LOG_AUTH|LOG_CRON|LOG_LPR|LOG_LOCAL0|LOG_LOCAL1|LOG_LOCAL2|LOG_LOCAL3|LOG_LOCAL4|LOG_LOCAL5|LOG_LOCAL6|LOG_LOCAL7typelevel=LOG_EMERG|LOG_ALERT|LOG_CRIT|LOG_ERR|LOG_WARNING|LOG_NOTICE|LOG_INFO|LOG_DEBUGexternalsetlogmask:levellist->levellist="caml_extunix_setlogmask"externalopenlog:?ident:string->optionslist->facility->unit="caml_extunix_openlog"externalcloselog:unit->unit="caml_extunix_closelog"externalext_syslog:facilityoption->level->string->unit="caml_extunix_syslog"letsyslog?facilitylvl=Printf.ksprintf(ext_syslogfacilitylvl)letlog_uptolvl=letrecf=function|[]->assertfalse|x::xs->ifx=lvlthenx::xselsefxsinf[LOG_DEBUG;LOG_INFO;LOG_NOTICE;LOG_WARNING;LOG_ERR;LOG_CRIT;LOG_ALERT;LOG_EMERG]end][%%haveUNAME(** @author Sylvain Le Gall <sylvain@le-gall.net> *)moduleUname=structtypet={sysname:string;nodename:string;release:string;version:string;machine:string;}letto_stringt=String.concat" "[t.sysname;t.nodename;t.release;t.version;t.machine]endexternaluname:unit->Uname.t="caml_extunix_uname"](** {2 Filesystem} *)[%%haveFSYNC(** synchronize a file's in-core state with storage device *)externalfsync:Unix.file_descr->unit="caml_extunix_fsync"][%%haveFDATASYNCexternalfdatasync:Unix.file_descr->unit="caml_extunix_fdatasync"][%%haveSYNC(** causes all buffered modifications to file metadata and data to be written to the underlying file systems *)externalsync:unit->unit="caml_extunix_sync"][%%haveSYNCFS(** like {!sync}, but synchronizes just the file system containing file referred to by the open file descriptor [fd] *)externalsyncfs:Unix.file_descr->unit="caml_extunix_syncfs"][%%haveDIRFDexternaldirfd:Unix.dir_handle->Unix.file_descr="caml_extunix_dirfd"][%%have(STATVFS,FSTATVFS)(** file system flags *)typest_flag=|ST_RDONLY(** Mount read-only. *)|ST_NOSUID(** Ignore suid and sgid bits. *)|ST_NODEV(** Disallow access to device special files. *)|ST_NOEXEC(** Disallow program execution. *)|ST_SYNCHRONOUS(** Writes are synced at once. *)|ST_MANDLOCK(** Allow mandatory locks on an FS. *)|ST_WRITE(** Write on file/directory/symlink. *)|ST_APPEND(** Append-only file. *)|ST_IMMUTABLE(** Immutable file. *)|ST_NOATIME(** Do not update access times. *)|ST_NODIRATIME(** Do not update directory access times. *)|ST_RELATIME(** Update atime relative to mtime/ctime. *)typestatvfs={f_bsize:int;(** file system block size *)f_blocks:int64;(** size of file system in blocks *)f_bfree:int64;(** free blocks *)f_bavail:int64;(** free blocks for unprivileged users *)f_files:int64;(** inodes *)f_ffree:int64;(** free inodes *)f_favail:int64;(** free inodes for unprivileged users *)f_fsid:int64;(** file system ID *)f_flag:int;(** mount flags (raw value) *)f_flags:st_flaglist;(** mount flags (decoded) *)f_namemax:int;(** maximum filename length *)}][%%haveSTATVFS(** On Windows, [statvfs root] is emulated. [root] must be the root
directory of the volume to be described. A trailing backslash is
required. The [f_flag] and [f_fsid] fields are retrieved from a
call to [GetVolumeInformation]. Filesystem flags are provided raw
in [f_flag], and only [FILE_READ_ONLY_VOLUME] is mapped to
[ST_RDONLY] in [f_flags]. *)externalstatvfs:string->statvfs="caml_extunix_statvfs"][%%haveFSTATVFSexternalfstatvfs:Unix.file_descr->statvfs="caml_extunix_fstatvfs"][%%haveATFILE(*
external at_fdcwd : unit -> Unix.file_descr
(** Pseudo file descriptor denoting current directory *)
let at_fdcwd = at_fdcwd ()
*)typeat_flag=AT_EACCESS|AT_SYMLINK_NOFOLLOW|AT_REMOVEDIR|AT_SYMLINK_FOLLOW|AT_NO_AUTOMOUNTexternalopenat:Unix.file_descr->string->open_flaglist->Unix.file_perm->Unix.file_descr="caml_extunix_openat"(** Supported flags : [AT_SYMLINK_NOFOLLOW AT_NO_AUTOMOUNT] *)externalfstatat:Unix.file_descr->string->at_flaglist->Unix.stats="caml_extunix_fstatat"(** Supported flags : [AT_REMOVEDIR] *)externalunlinkat:Unix.file_descr->string->at_flaglist->unit="caml_extunix_unlinkat"externalrenameat:Unix.file_descr->string->Unix.file_descr->string->unit="caml_extunix_renameat"externalmkdirat:Unix.file_descr->string->int->unit="caml_extunix_mkdirat"(** Supported flags : [AT_SYMLINK_FOLLOW] *)externallinkat:Unix.file_descr->string->Unix.file_descr->string->at_flaglist->unit="caml_extunix_linkat"externalsymlinkat:string->Unix.file_descr->string->unit="caml_extunix_symlinkat"externalreadlinkat:Unix.file_descr->string->string="caml_extunix_readlinkat"externalfchownat:Unix.file_descr->string->int->int->at_flaglist->unit="caml_extunix_fchownat"externalfchmodat:Unix.file_descr->string->int->at_flaglist->unit="caml_extunix_fchmodat"][%%haveRENAMEAT2typerename_flag=RENAME_EXCHANGE|RENAME_NOREPLACE|RENAME_WHITEOUT[@haveRENAME_WHITEOUT]externalrenameat2:Unix.file_descr->string->Unix.file_descr->string->rename_flaglist->unit="caml_extunix_renameat2"](** @raise Not_available if OS does not represent file descriptors as numbers *)letint_of_file_descr:Unix.file_descr->int=ifObj.is_block(Obj.reprUnix.stdin)thenfun_->raise(Not_available"int_of_file_descr")elseObj.magic(** @raise Not_available if OS does not represent file descriptors as numbers *)letfile_descr_of_int:int->Unix.file_descr=ifObj.is_block(Obj.reprUnix.stdin)thenfun_->raise(Not_available"file_descr_of_int")elseObj.magic[%%haveFCNTL(** @return whether file descriptor is open *)externalis_open_descr:Unix.file_descr->bool="caml_extunix_is_open_descr"][%%haveREALPATH(** [realpath path]
@return the canonicalized absolute pathname of [path]
*)externalrealpath:string->string="caml_extunix_realpath"letrealpathp=ifnot(Sys.win32)thenrealpathpelseletcleanupp=(* Remove any \\?\ prefix. *)ifString.lengthp<=4thenpelseifp.[0]='\\'&&p.[1]='\\'&&p.[2]='?'&&p.[3]='\\'then(String.subp4(String.lengthp-4))elsepintrycleanup(realpathp)with|(Unix.Unix_error(EACCES,_,_))ase->(* On Windows this can happen on *files* on which you don't have
access. POSIX realpath(3) works in this case, we emulate this. *)tryletdir=cleanup(realpath(Filename.dirnamep))inFilename.concatdir(Filename.basenamep)with_->raisee][%%haveFADVISE(** {3 posix_fadvise}
@author Sylvain Le Gall *)(** access pattern *)typeadvice=|POSIX_FADV_NORMAL(** Indicates that the application has no advice to
give about its access pattern for the specified
data. *)|POSIX_FADV_SEQUENTIAL(** The application expects to access the specified
data sequentially. *)|POSIX_FADV_RANDOM(** The specified data will be accessed in random
order. *)|POSIX_FADV_NOREUSE(** The specified data will be accessed only once. *)|POSIX_FADV_WILLNEED(** The specified data will be accessed in the near
future. *)|POSIX_FADV_DONTNEED(** The specified data will not be accessed in the
near future. *)(** predeclare an access pattern for file data *)externalfadvise:Unix.file_descr->int->int->advice->unit="caml_extunix_fadvise"][%%haveFALLOCATE(** {3 posix_fallocate} *)(** Allocate disk space for file
@author Sylvain Le Gall
*)(** [fallocate fd off len] allocates disk space to ensure that subsequent writes
between [off] and [off + len] in [fd] will not fail because of lack of disk
space. The file size is modified if [off + len] is bigger than the current size.
*)externalfallocate:Unix.file_descr->int->int->unit="caml_extunix_fallocate"][%%havePREAD(** {3 pread}
@author Goswin von Brederlow *)(** [all_pread fd off buf ofs len] reads up to [len] bytes from file
descriptor [fd] at offset [off] (from the start of the file) into
the string [buf] at offset [ofs]. The file offset is not changed.
[all_pread] repeats the read operation until all characters have
been read or an error occurs. Returns less than the number of
characters requested on EAGAIN, EWOULDBLOCK or End-of-file but
only ever returns 0 on End-of-file. Continues the read operation
on EINTR. Raises an Unix.Unix_error exception in all other
cases. *)externalunsafe_all_pread:Unix.file_descr->int->Bytes.t->int->int->int="caml_extunix_all_pread"letall_preadfdoffbufofslen=ifoff<0||ofs<0||len<0||ofs>Bytes.lengthbuf-lentheninvalid_arg"ExtUnix.all_pread"elseunsafe_all_preadfdoffbufofslen(** [single_pread fd off buf ifs len] reads up to [len] bytes from
file descriptor [fd] at offset [off] (from the start of the file)
into the string [buf] at offset [ofs]. The file offset is not
changed.
[single_pread] attempts to read only once. Returns the number of
characters read or raises an Unix.Unix_error exception. *)externalunsafe_single_pread:Unix.file_descr->int->Bytes.t->int->int->int="caml_extunix_single_pread"letsingle_preadfdoffbufofslen=ifoff<0||ofs<0||len<0||ofs>Bytes.lengthbuf-lentheninvalid_arg"ExtUnix.single_pread"elseunsafe_single_preadfdoffbufofslen(** [pread fd off buf ofs len] reads up to [len] bytes from file
descriptor [fd] at offset [off] (from the start of the file) into
the string [buf] at offset [ofs]. The file offset is not changed.
[pread] repeats the read operation until all characters have
been read or an error occurs. Raises an Unix.Unix_error exception
if 0 characters could be read before an error occurs. Continues
the read operation on EINTR. Returns the number of characters
written in all other cases. *)externalunsafe_pread:Unix.file_descr->int->Bytes.t->int->int->int="caml_extunix_pread"letpreadfdoffbufofslen=ifoff<0||ofs<0||len<0||ofs>Bytes.lengthbuf-lentheninvalid_arg"ExtUnix.pread"elseunsafe_preadfdoffbufofslen(** [intr_pread fd off buf ofs len] reads up to [len] bytes from file
descriptor [fd] at offset [off] (from the start of the file) into
the string [buf] at offset [ofs]. The file offset is not changed.
[intr_pread] repeats the read operation until all characters have
been read or an error occurs. Raises an Unix.Unix_error exception
if 0 characters could be read before an error occurs. Does NOT
continue on EINTR. Returns the number of characters written in all
other cases. *)externalunsafe_intr_pread:Unix.file_descr->int->Bytes.t->int->int->int="caml_extunix_intr_pread"letintr_preadfdoffbufofslen=ifoff<0||ofs<0||len<0||ofs>Bytes.lengthbuf-lentheninvalid_arg"ExtUnix.intr_pread"elseunsafe_intr_preadfdoffbufofslen][%%havePWRITE(** {3 pwrite}
@author Goswin von Brederlow *)(** [all_pwrite fd off buf ofs len] writes up to [len] bytes from file
descriptor [fd] at offset [off] (from the start of the file) into
the string [buf] at offset [ofs]. The file offset is not changed.
[all_pwrite] repeats the write operation until all characters have
been written or an error occurs. Returns less than the number of
characters requested on EAGAIN, EWOULDBLOCK but never 0. Continues
the write operation on EINTR. Raises an Unix.Unix_error exception
in all other cases. *)externalunsafe_all_pwrite:Unix.file_descr->int->string->int->int->int="caml_extunix_all_pwrite"letall_pwritefdoffbufofslen=ifoff<0||ofs<0||len<0||ofs>String.lengthbuf-lentheninvalid_arg"ExtUnix.all_pwrite"elseunsafe_all_pwritefdoffbufofslen(** [single_pwrite fd off buf ofs len] writes up to [len] bytes from
file descriptor [fd] at offset [off] (from the start of the file)
into the string [buf] at offset [ofs]. The file offset is not
changed.
[single_pwrite] attempts to write only once. Returns the number of
characters written or raises an Unix.Unix_error exception. *)externalunsafe_single_pwrite:Unix.file_descr->int->string->int->int->int="caml_extunix_single_pwrite"letsingle_pwritefdoffbufofslen=ifoff<0||ofs<0||len<0||ofs>String.lengthbuf-lentheninvalid_arg"ExtUnix.single_pwrite"elseunsafe_single_pwritefdoffbufofslen(** [pwrite fd off buf ofs len] writes up to [len] bytes from file
descriptor [fd] at offset [off] (from the start of the file) into
the string [buf] at offset [ofs]. The file offset is not changed.
[pwrite] repeats the write operation until all characters have
been written or an error occurs. Raises an Unix.Unix_error exception
if 0 characters could be written before an error occurs. Continues
the write operation on EINTR. Returns the number of characters
written in all other cases. *)externalunsafe_pwrite:Unix.file_descr->int->string->int->int->int="caml_extunix_pwrite"letpwritefdoffbufofslen=ifoff<0||ofs<0||len<0||ofs>String.lengthbuf-lentheninvalid_arg"ExtUnix.pwrite"elseunsafe_pwritefdoffbufofslen(** [intr_pwrite fd off buf ofs len] writes up to [len] bytes from
file descriptor [fd] at offset [off] (from the start of the file)
into the string [buf] at offset [ofs]. The file offset is not
changed.
[intr_pwrite] repeats the write operation until all characters have
been written or an error occurs. Raises an Unix.Unix_error exception
if 0 characters could be written before an error occurs. Does NOT
continue on EINTR. Returns the number of characters written in all
other cases. *)externalunsafe_intr_pwrite:Unix.file_descr->int->string->int->int->int="caml_extunix_intr_pwrite"letintr_pwritefdoffbufofslen=ifoff<0||ofs<0||len<0||ofs>String.lengthbuf-lentheninvalid_arg"ExtUnix.intr_pwrite"elseunsafe_intr_pwritefdoffbufofslen][%%haveREAD(** {3 read}
@author Goswin von Brederlow *)(** [all_read fd buf ofs len] reads up to [len] bytes from file
descriptor [fd] into the string [buf] at offset [ofs].
[all_read] repeats the read operation until all characters have
been read or an error occurs. Returns less than the number of
characters requested on EAGAIN, EWOULDBLOCK or End-of-file but
only ever returns 0 on End-of-file. Continues the read operation
on EINTR. Raises an Unix.Unix_error exception in all other
cases. *)externalunsafe_all_read:Unix.file_descr->Bytes.t->int->int->int="caml_extunix_all_read"letall_readfdbufofslen=ifofs<0||len<0||ofs>Bytes.lengthbuf-lentheninvalid_arg"ExtUnix.all_read"elseunsafe_all_readfdbufofslen(** [single_read fd buf ifs len] reads up to [len] bytes from file
descriptor [fd] into the string [buf] at offset [ofs].
[single_read] attempts to read only once. Returns the number of
characters read or raises an Unix.Unix_error exception. *)externalunsafe_single_read:Unix.file_descr->Bytes.t->int->int->int="caml_extunix_single_read"letsingle_readfdbufofslen=ifofs<0||len<0||ofs>Bytes.lengthbuf-lentheninvalid_arg"ExtUnix.single_read"elseunsafe_single_readfdbufofslen(** [read fd buf ofs len] reads up to [len] bytes from file descriptor
[fd] into the string [buf] at offset [ofs].
[read] repeats the read operation until all characters have
been read or an error occurs. Raises an Unix.Unix_error exception
if 0 characters could be read before an error occurs. Continues
the read operation on EINTR. Returns the number of characters
written in all other cases. *)externalunsafe_read:Unix.file_descr->Bytes.t->int->int->int="caml_extunix_read"letreadfdbufofslen=ifofs<0||len<0||ofs>Bytes.lengthbuf-lentheninvalid_arg"ExtUnix.read"elseunsafe_readfdbufofslen(** [intr_read fd buf ofs len] reads up to [len] bytes from file
descriptor [fd] into the string [buf] at offset [ofs].
[intr_read] repeats the read operation until all characters have
been read or an error occurs. Raises an Unix.Unix_error exception
if 0 characters could be read before an error occurs. Does NOT
continue on EINTR. Returns the number of characters written in all
other cases. *)externalunsafe_intr_read:Unix.file_descr->Bytes.t->int->int->int="caml_extunix_intr_read"letintr_readfdbufofslen=ifofs<0||len<0||ofs>Bytes.lengthbuf-lentheninvalid_arg"ExtUnix.intr_read"elseunsafe_intr_readfdbufofslen][%%haveWRITE(** {3 write}
@author Goswin von Brederlow *)(** [all_write fd buf ofs len] writes up to [len] bytes from file
descriptor [fd] into the string [buf] at offset [ofs].
[all_write] repeats the write operation until all characters have
been written or an error occurs. Returns less than the number of
characters requested on EAGAIN, EWOULDBLOCK but never 0. Continues
the write operation on EINTR. Raises an Unix.Unix_error exception
in all other cases. *)externalunsafe_all_write:Unix.file_descr->string->int->int->int="caml_extunix_all_write"letall_writefdbufofslen=ifofs<0||len<0||ofs>String.lengthbuf-lentheninvalid_arg"ExtUnix.all_write"elseunsafe_all_writefdbufofslen(** [single_write fd buf ofs len] writes up to [len] bytes from file
descriptor [fd] into the string [buf] at offset [ofs].
[single_write] attempts to write only once. Returns the number of
characters written or raises an Unix.Unix_error exception. *)externalunsafe_single_write:Unix.file_descr->string->int->int->int="caml_extunix_single_write"letsingle_writefdbufofslen=ifofs<0||len<0||ofs>String.lengthbuf-lentheninvalid_arg"ExtUnix.single_write"elseunsafe_single_writefdbufofslen(** [write fd buf ofs len] writes up to [len] bytes from file
descriptor [fd] into the string [buf] at offset [ofs].
[write] repeats the write operation until all characters have
been written or an error occurs. Raises an Unix.Unix_error exception
if 0 characters could be written before an error occurs. Continues
the write operation on EINTR. Returns the number of characters
written in all other cases. *)externalunsafe_write:Unix.file_descr->string->int->int->int="caml_extunix_write"letwritefdbufofslen=ifofs<0||len<0||ofs>String.lengthbuf-lentheninvalid_arg"ExtUnix.write"elseunsafe_writefdbufofslen(** [intr_write fd buf ofs len] writes up to [len] bytes from file
descriptor [fd] into the string [buf] at offset [ofs].
[intr_write] repeats the write operation until all characters have
been written or an error occurs. Raises an Unix.Unix_error exception
if 0 characters could be written before an error occurs. Does NOT
continue on EINTR. Returns the number of characters written in all
other cases. *)externalunsafe_intr_write:Unix.file_descr->string->int->int->int="caml_extunix_intr_write"letintr_writefdbufofslen=ifofs<0||len<0||ofs>String.lengthbuf-lentheninvalid_arg"ExtUnix.intr_write"elseunsafe_intr_writefdbufofslen](** {2 File operations on large files} *)(** File operations on large files. This sub-module provides 64-bit
variants of the functions [ExtUnix.fadvise] (for predeclaring an
access pattern for file data), [ExtUnix.fallocate] (for allocating
disk space for a file), [ExtUnix.all_pread], [ExtUnix.single_pread],
[ExtUnix.pread], [ExtUnix.intr_pread], [ExtUnix.all_pwrite],
[ExtUnix.single_pwrite], [ExtUnix.pwrite] and [ExtUnix.intr_pwrite]
(for reading from or writing to a file descriptor at a given
offset). These alternate functions represent positions and sizes
by 64-bit integers (type int64) instead of regular integers
(type int), thus allowing operating on files whose sizes are
greater than max_int. *)moduleLargeFile=struct[%%haveFADVISEexternalfadvise:Unix.file_descr->int64->int64->advice->unit="caml_extunix_fadvise64"][%%haveFALLOCATEexternalfallocate:Unix.file_descr->int64->int64->unit="caml_extunix_fallocate64"][%%havePREADexternalunsafe_all_pread:Unix.file_descr->int64->Bytes.t->int->int->int="caml_extunix_all_pread64"letall_preadfdoffbufofslen=ifoff<Int64.zerotheninvalid_arg"ExtUnix.LargeFile.all_pread"elseunsafe_all_preadfdoffbufofslenexternalunsafe_single_pread:Unix.file_descr->int64->Bytes.t->int->int->int="caml_extunix_single_pread64"letsingle_preadfdoffbufofslen=ifoff<Int64.zerotheninvalid_arg"ExtUnix.LargeFile.single_pread"elseunsafe_single_preadfdoffbufofslenexternalunsafe_pread:Unix.file_descr->int64->Bytes.t->int->int->int="caml_extunix_pread64"letpreadfdoffbufofslen=ifoff<Int64.zerotheninvalid_arg"ExtUnix.LargeFile.pread"elseunsafe_preadfdoffbufofslenexternalunsafe_intr_pread:Unix.file_descr->int64->Bytes.t->int->int->int="caml_extunix_intr_pread64"letintr_preadfdoffbufofslen=ifoff<Int64.zerotheninvalid_arg"ExtUnix.LargeFile.intr_pread"elseunsafe_intr_preadfdoffbufofslen][%%havePWRITEexternalunsafe_all_pwrite:Unix.file_descr->int64->string->int->int->int="caml_extunix_all_pwrite64"letall_pwritefdoffbufofslen=ifoff<Int64.zerotheninvalid_arg"ExtUnix.LargeFile.all_pwrite"elseunsafe_all_pwritefdoffbufofslenexternalunsafe_single_pwrite:Unix.file_descr->int64->string->int->int->int="caml_extunix_single_pwrite64"letsingle_pwritefdoffbufofslen=ifoff<Int64.zerotheninvalid_arg"ExtUnix.LargeFile.single_pwrite"elseunsafe_single_pwritefdoffbufofslenexternalunsafe_pwrite:Unix.file_descr->int64->string->int->int->int="caml_extunix_pwrite64"letpwritefdoffbufofslen=ifoff<Int64.zerotheninvalid_arg"ExtUnix.LargeFile.pwrite"elseunsafe_pwritefdoffbufofslenexternalunsafe_intr_pwrite:Unix.file_descr->int64->string->int->int->int="caml_extunix_intr_pwrite64"letintr_pwritefdoffbufofslen=ifoff<Int64.zerotheninvalid_arg"ExtUnix.LargeFile.intr_pwrite"elseunsafe_intr_pwritefdoffbufofslen](** {2 Bigarray variants} *)(** *)moduleBA=struct[%%havePREADexternalunsafe_all_pread:Unix.file_descr->int64->('a,'b)carray->int="caml_extunixba_all_pread64"letall_preadfdoffbuf=ifoff<Int64.zerotheninvalid_arg"ExtUnix.LargeFile.all_pread"elseunsafe_all_preadfdoffbufexternalunsafe_single_pread:Unix.file_descr->int64->('a,'b)carray->int="caml_extunixba_single_pread64"letsingle_preadfdoffbuf=ifoff<Int64.zerotheninvalid_arg"ExtUnix.LargeFile.single_pread"elseunsafe_single_preadfdoffbufexternalunsafe_pread:Unix.file_descr->int64->('a,'b)carray->int="caml_extunixba_pread64"letpreadfdoffbuf=ifoff<Int64.zerotheninvalid_arg"ExtUnix.LargeFile.pread"elseunsafe_preadfdoffbufexternalunsafe_intr_pread:Unix.file_descr->int64->('a,'b)carray->int="caml_extunixba_intr_pread64"letintr_preadfdoffbuf=ifoff<Int64.zerotheninvalid_arg"ExtUnix.LargeFile.intr_pread"elseunsafe_intr_preadfdoffbuf][%%havePWRITEexternalunsafe_all_pwrite:Unix.file_descr->int64->('a,'b)carray->int="caml_extunixba_all_pwrite64"letall_pwritefdoffbuf=ifoff<Int64.zerotheninvalid_arg"ExtUnix.LargeFile.all_pwrite"elseunsafe_all_pwritefdoffbufexternalunsafe_single_pwrite:Unix.file_descr->int64->('a,'b)carray->int="caml_extunixba_single_pwrite64"letsingle_pwritefdoffbuf=ifoff<Int64.zerotheninvalid_arg"ExtUnix.LargeFile.single_pwrite"elseunsafe_single_pwritefdoffbufexternalunsafe_pwrite:Unix.file_descr->int64->('a,'b)carray->int="caml_extunixba_pwrite64"letpwritefdoffbuf=ifoff<Int64.zerotheninvalid_arg"ExtUnix.LargeFile.pwrite"elseunsafe_pwritefdoffbufexternalunsafe_intr_pwrite:Unix.file_descr->int64->('a,'b)carray->int="caml_extunixba_intr_pwrite64"letintr_pwritefdoffbuf=ifoff<Int64.zerotheninvalid_arg"ExtUnix.LargeFile.intr_pwrite"elseunsafe_intr_pwritefdoffbuf]end(* module BA *)end(* module LargeFile *)[%%haveMOUNT(** {3 mount system call} *)typemount_flag=|MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS|MS_REMOUNT|MS_MANDLOCK|MS_DIRSYNC|MS_NOATIME|MS_NODIRATIME|MS_BIND|MS_MOVE|MS_REC|MS_SILENT|MS_POSIXACL|MS_UNBINDABLE|MS_PRIVATE|MS_SLAVE|MS_SHARED|MS_RELATIME|MS_KERNMOUNT|MS_I_VERSION|MS_STRICTATIME|MS_NOUSERexternalmount:source:string->target:string->fstype:string->mount_flaglist->data:string->unit="caml_extunix_mount"typeumount2_flag=|MNT_FORCE|MNT_DETACH|MNT_EXPIRE|UMOUNT_NOFOLLOWexternalumount2:string->umount2_flaglist->unit="caml_extunix_umount2"][%%haveCHROOT(** {3 chroot system call} *)externalchroot:string->unit="caml_extunix_chroot"](** {2 namespace} *)[%%haveUNSHAREtypeclone_flag=|CLONE_FS|CLONE_FILES|CLONE_NEWNS|CLONE_SYSVSEM|CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWUSER|CLONE_NEWPID|CLONE_NEWNETexternalunshare:clone_flaglist->unit="caml_extunix_unshare"](** {2 ioctl} *)(** Control the underlying device parameters of special files *)moduleIoctl=struct[%%haveSIOCGIFCONF(** [siocgifconf sock], where [sock] is any socket, e.g. [socket PF_INET SOCK_DGRAM 0]
@return the list of interfaces and corresponding addresses ({b FIXME max 32}) ({b may change}) *)externalsiocgifconf:sock:Unix.file_descr->(string*string)list="caml_extunix_ioctl_siocgifconf"][%%haveTTY_IOCTL(** Enable RTS/CTS (hardware) flow control. See CRTSCTS in tcsetattr(3).
{b FIXME this is likely to disappear when separate interface for [tcsetattr] and [tcgetattr] gets implemented} *)externalcrtscts:Unix.file_descr->int="caml_extunix_crtscts"(** Get the status of modem bits. See TIOCMGET in tty_ioctl(4). *)externaltiocmget:Unix.file_descr->int="caml_extunix_ioctl_TIOCMGET"(** Set the status of modem bits. See TIOCMSET in tty_ioctl(4). *)externaltiocmset:Unix.file_descr->int->unit="caml_extunix_ioctl_TIOCMSET"(** Clear the indicated modem bits. See TIOCMBIC in tty_ioctl(4). *)externaltiocmbic:Unix.file_descr->int->unit="caml_extunix_ioctl_TIOCMBIC"(** Set the indicated modem bits. See TIOCMBIS in tty_ioctl(4). *)externaltiocmbis:Unix.file_descr->int->unit="caml_extunix_ioctl_TIOCMBIS"(** [tiocgwinsz fd] returns a tuple [(cols, rows, xpixel, ypixel)] representing
the size of the character device. [cols] is the number of character columns,
[rows] is the number of character rows, [xpixel] is width of the device in
pixels, and [ypixel] is the height of the device in pixels. *)externaltiocgwinsz:Unix.file_descr->(int*int*int*int)="caml_extunix_ioctl_TIOCGWINSZ"]end(* module Ioctl *)(** {2 Miscellaneous} *)[%%haveTTYNAME(** @return name of terminal *)externalttyname:Unix.file_descr->string="caml_extunix_ttyname"][%%haveCTERMID(** Get controlling terminal name *)externalctermid:unit->string="caml_extunix_ctermid"][%%haveGETTID(** @return thread id *)externalgettid:unit->int="caml_extunix_gettid"][%%havePGID(** [setpgid pid pgid] sets the process group of the process specified by [pid] to [pgid].
If [pid] is zero, then the process ID of the calling process is used. If
[pgid] is zero, then the PGID of the process specified by [pid] is made the same as its process ID. *)externalsetpgid:int->int->unit="caml_extunix_setpgid"(** [getpgid pid] returns the PGID of the process specified by [pid].
If [pid] is zero, the process ID of the calling process is used. *)externalgetpgid:int->int="caml_extunix_getpgid"(** [getsid pid] returns the session ID of the process specified by [pid].
If [pid] is zero, the process ID of the calling process is used. *)externalgetsid:int->int="caml_extunix_getsid"][%%haveSETREUID(** [setreuid ruid euid] sets real and effective user IDs of the calling process.
Supplying a value of -1 for either the real or effective user ID forces the system to leave that ID unchanged.
*)externalsetreuid:int->int->unit="caml_extunix_setreuid"(** [setregid rgid egid] sets real and effective group IDs of the calling process.
Supplying a value of -1 for either the real or effective group ID forces the system to leave that ID unchanged.
*)externalsetregid:int->int->unit="caml_extunix_setregid"][%%haveSETRESUID(** [setresuid ruid euid suid] sets real, effective and saved user IDs of the calling process.
Supplying a value of -1 for either the real or effective user ID forces the system to leave that ID unchanged.
*)externalsetresuid:int->int->int->unit="caml_extunix_setresuid"(** [setresgid rgid egid sgid] sets real, effective and saved group IDs of the calling process.
Supplying a value of -1 for either the real or effective group ID forces the system to leave that ID unchanged.
*)externalsetresgid:int->int->int->unit="caml_extunix_setresgid"][%%haveTCPGRPexternaltcgetpgrp:Unix.file_descr->int="caml_extunix_tcgetpgrp"externaltcsetpgrp:Unix.file_descr->int->unit="caml_extunix_tcsetpgrp"](** Exit process without running any [at_exit] hooks (implemented in Pervasives) *)externalsys_exit:int->'a="caml_sys_exit"[%%haveSYSINFO(** NB all memory fields in this structure are the multiplies of [mem_unit] bytes *)typesysinfo={uptime:int;(** Seconds since boot *)loads:(float*float*float);(** 1, 5, and 15 minute load averages *)totalram:int;(** Total usable main memory size *)freeram:int;(** Available memory size *)sharedram:int;(** Amount of shared memory *)bufferram:int;(** Memory used by buffers *)totalswap:int;(** Total swap space size *)freeswap:int;(** swap space still available *)procs:int;(** Number of current processes *)totalhigh:int;(** Total high memory size *)freehigh:int;(** Available high memory size *)mem_unit:int;(** Memory unit size in bytes *)}(** @return overall system statistics *)externalsysinfo:unit->sysinfo="caml_extunix_sysinfo"(** @return seconds since boot *)externaluptime:unit->int="caml_extunix_uptime"](** {2 Network} *)[%%haveIFADDRS(** @return the list of [AF_INET] and [AF_INET6] interfaces and corresponding addresses ({b may change}) *)externalgetifaddrs:unit->(string*string)list="caml_extunix_getifaddrs"][%%haveSOCKOPT(**/**)typesocket_int_option_=|TCP_KEEPCNT_|TCP_KEEPIDLE_|TCP_KEEPINTVL_|SO_REUSEPORT_|SO_ATTACH_BPF_|SO_ATTACH_REUSEPORT_EBPF_|SO_DETACH_FILTER_|SO_DETACH_BPF_|SO_LOCK_FILTER_letstring_of_socket_int_option_=function|TCP_KEEPCNT_->"TCP_KEEPCNT"|TCP_KEEPIDLE_->"TCP_KEEPIDLE"|TCP_KEEPINTVL_->"TCP_KEEPINTVL"|SO_REUSEPORT_->"SO_REUSEPORT"|SO_ATTACH_BPF_->"SO_ATTACH_BPF"|SO_ATTACH_REUSEPORT_EBPF_->"SO_ATTACH_REUSEPORT_EBPF"|SO_DETACH_FILTER_->"SO_DETACH_FILTER"|SO_DETACH_BPF_->"SO_DETACH_BPF"|SO_LOCK_FILTER_->"SO_LOCK_FILTER"externalsetsockopt_int:Unix.file_descr->socket_int_option_->int->unit="caml_extunix_setsockopt_int"externalgetsockopt_int:Unix.file_descr->socket_int_option_->int="caml_extunix_getsockopt_int"externalhave_sockopt_int:socket_int_option_->bool="caml_extunix_have_sockopt"letsetsockopt_intsockoptv=trysetsockopt_intsockoptvwithNot_found->raise(Not_available("setsockopt "^string_of_socket_int_option_opt))letgetsockopt_intsockopt=trygetsockopt_intsockoptwithNot_found->raise(Not_available("getsockopt "^string_of_socket_int_option_opt))(**/**)(** Extra socket options with integer value not covered in {!Unix} module.
NB: Not all options available on all platforms, use {!have_sockopt_int} to check at runtime
(even when function is defined in [Specific] module).
*)typesocket_int_option=|TCP_KEEPCNT(** The maximum number of keepalive probes TCP should send before dropping the connection *)|TCP_KEEPIDLE(** The time (in seconds) the connection needs to remain idle before TCP starts sending
keepalive probes, if the socket option [SO_KEEPALIVE] has been set on this socket.
On Apple systems, [TCP_KEEPIDLE] is an alias to [TCP_KEEPALIVE]. *)|TCP_KEEPINTVL(** The time (in seconds) between individual keepalive probes *)|SO_ATTACH_BPF(** file descriptor returned by the bpf(2), with program of type [BPF_PROG_TYPE_SOCKET_FILTER] *)|SO_ATTACH_REUSEPORT_EBPF(** same as for SO_ATTACH_BPF *)typesocket_bool_option=|SO_REUSEPORT(** Permits multiple AF_INET or AF_INET6 sockets to be bound to an identical socket address. *)|SO_LOCK_FILTER(** Prevent changing the filters associated with the socket *)typesocket_unit_option=|SO_DETACH_FILTER(** Remove classic or extended BPF program attached to a socket *)|SO_DETACH_BPF(** same *)(**/**)letmake_socket_int_option=function|TCP_KEEPCNT->TCP_KEEPCNT_|TCP_KEEPIDLE->TCP_KEEPIDLE_|TCP_KEEPINTVL->TCP_KEEPINTVL_|SO_ATTACH_BPF->SO_ATTACH_BPF_|SO_ATTACH_REUSEPORT_EBPF->SO_ATTACH_REUSEPORT_EBPF_letmake_socket_bool_option=function|SO_REUSEPORT->SO_REUSEPORT_|SO_LOCK_FILTER->SO_LOCK_FILTER_letmake_socket_unit_option=function|SO_DETACH_FILTER->SO_DETACH_FILTER_|SO_DETACH_BPF->SO_DETACH_BPF_(**/**)lethave_sockopt_unitx=have_sockopt_int(make_socket_unit_optionx)lethave_sockopt_boolx=have_sockopt_int(make_socket_bool_optionx)lethave_sockopt_intx=have_sockopt_int(make_socket_int_optionx)(** Obsolete, compatibility, use {!have_sockopt_int}.
@deprecated *)lethave_sockopt[@deprecated"Obsolete, compatibility, use have_sockopt_int."]=have_sockopt_int(** Set the option without value on the given socket *)letsetsockopt_unitsockopt=setsockopt_intsock(make_socket_unit_optionopt)0(** Set a boolean-valued option in the given socket *)letsetsockoptsockoptv=setsockopt_intsock(make_socket_bool_optionopt)(ifvthen1else0)(** Get the current value for the boolean-valued option in the given socket *)letgetsockoptsockopt=0<>getsockopt_intsock(make_socket_bool_optionopt)(** Set an integer-valued option in the given socket *)letsetsockopt_intsockoptv=setsockopt_intsock(make_socket_int_optionopt)v(** Get the current value for the integer-valued option in the given socket *)letgetsockopt_intsockopt=getsockopt_intsock(make_socket_int_optionopt)][%%havePOLLmodulePoll:sigtypet=privateint(** [is_set flags flag]
@return whether [flag] is set in [flags] *)valis_set:t->t->bool(** [is_inter flags1 flags2]
@return whether [flags1] and [flags2] have non-empty intersection *)valis_inter:t->t->bool(** @return intersection of two flags (AND) *)valinter:t->t->t(** @return union of two flags (OR) *)valunion:t->t->t(** @return union of several flags (OR) *)valjoin:tlist->t(** equivalent to [union] *)val(+):t->t->tvalpollin:tvalpollpri:tvalpollout:tvalpollerr:tvalpollhup:tvalpollnval:t(** may not be present on all platforms (=0) *)valpollrdhup:t(** no poll flags (=0) *)valnone:tend=structtypet=intexternalpoll_constants:unit->(int*int*int*int*int*int*int)="caml_extunix_poll_constants"let(pollin,pollpri,pollout,pollerr,pollhup,pollnval,pollrdhup)=trypoll_constants()withNot_available_->(0,0,0,0,0,0,0)letnone=0letis_setxsx=xslandx=xletinterxy=xlandyletis_interxy=xlandy<>0letunionab=alorblet(+)=unionletjoin=List.fold_left(lor)0endexternalpoll:(Unix.file_descr*Poll.t)array->int->float->(Unix.file_descr*Poll.t)list="caml_extunix_poll"letpolla?(n=Array.lengtha)t=pollant][%%haveSIGNALFD(** {2 signalfd} *)(** OCaml bindings for signalfd(2) and related functions
@author Kaustuv Chaudhuri <kaustuv.chaudhuri@inria.fr>
*)(******************************************************************************)(* signalfd bindings *)(* *)(* NO COPYRIGHT -- RELEASED INTO THE PUBLIC DOMAIN *)(* *)(* Author: Kaustuv Chaudhuri <kaustuv.chaudhuri@inria.fr> *)(******************************************************************************)(** [signalfd ?fd sigs flags ()]
If the first optional argument is omitted, then a new file descriptor is allocated.
Otherwise, the given file descriptor is modified (in which case it
must have been created with [signalfd] previously). When you are
done with the fd, remember to {!Unix.close} it. Do not forget
to block [sigs] with {!Unix.sigprocmask} to prevent signal handling
according to default dispositions.
*)externalsignalfd:?fd:Unix.file_descr->sigs:intlist->flags:intlist->unit->Unix.file_descr="caml_extunix_signalfd"(** This type represents signal information that is read(2) from the
signalfd. *)typessi(** Blocking read(2) on a signalfd. Has undefined behaviour on
non-signalfds. Every successful read consumes a pending signal. *)externalsignalfd_read:Unix.file_descr->ssi="caml_extunix_signalfd_read"(** {3 Functions to query the signal information structure.} *)(** Get the signal value. This form is compatible with the signal
values defined in the standard {!Sys} module.
See signalfd(2) for the details of the remaining functions. Most
of these integers are actually unsigned. *)externalssi_signo_sys:ssi->int="caml_extunix_ssi_signo_sys"externalssi_signo:ssi->int32="caml_extunix_ssi_signo"externalssi_errno:ssi->int32="caml_extunix_ssi_errno"externalssi_code:ssi->int32="caml_extunix_ssi_code"externalssi_pid:ssi->int32="caml_extunix_ssi_pid"externalssi_uid:ssi->int32="caml_extunix_ssi_uid"externalssi_fd:ssi->Unix.file_descr="caml_extunix_ssi_fd"externalssi_tid:ssi->int32="caml_extunix_ssi_tid"externalssi_band:ssi->int32="caml_extunix_ssi_band"externalssi_overrun:ssi->int32="caml_extunix_ssi_overrun"externalssi_trapno:ssi->int32="caml_extunix_ssi_trapno"externalssi_status:ssi->int32="caml_extunix_ssi_status"externalssi_int:ssi->int32="caml_extunix_ssi_int"externalssi_ptr:ssi->int64="caml_extunix_ssi_ptr"externalssi_utime:ssi->int64="caml_extunix_ssi_utime"externalssi_stime:ssi->int64="caml_extunix_ssi_stime"externalssi_addr:ssi->int64="caml_extunix_ssi_addr"][%%haveRESOURCE(**
{2 POSIX resource operations}
@author Sylvain Le Gall <sylvain@le-gall.net>
*)(** priority target *)typewhich_prio_t=|PRIO_PROCESSofint(** Priority for a process id *)|PRIO_PGRPofint(** Priority for a process group id *)|PRIO_USERofint(** Priority for a user id *)typepriority=inttyperesource=|RLIMIT_CORE(** Limit on size of core dump file. *)|RLIMIT_CPU(** Limit on CPU time per process. *)|RLIMIT_DATA(** Limit on data segment size. *)|RLIMIT_FSIZE(** Limit on file size. *)|RLIMIT_NOFILE(** Limit on number of open files. *)|RLIMIT_STACK(** Limit on stack size. *)|RLIMIT_AS(** Limit on address space size. *)(** get resource name *)letstring_of_resource=function|RLIMIT_CORE->"RLIMIT_CORE"|RLIMIT_CPU->"RLIMIT_CPU"|RLIMIT_DATA->"RLIMIT_DATA"|RLIMIT_FSIZE->"RLIMIT_FSIZE"|RLIMIT_NOFILE->"RLIMIT_NOFILE"|RLIMIT_STACK->"RLIMIT_STACK"|RLIMIT_AS->"RLIMIT_AS"(** Limits *)moduleRlimit=structtypet=int64option(** [Some limit] is fixed limit, [None] is RLIM_INFINITY *)letstring_of_bytesn=letsz,acc=List.fold_left(fun(sz,acc)e->letq=Int64.divsz1024Linletr=Int64.remsz1024Linletacc=ifr<>0LthenPrintf.sprintf"%Ld %s"re::accelseaccin(q,acc))(n,[])["B";"KB";"MB";"GB"]inletacc=ifsz<>0LthenPrintf.sprintf"%Ld TB"sz::accelseaccinmatchaccwith|[]->"0 B"|_->String.concat" "accletto_string?r=function|None->"infinity"|Somel->matchrwith|None->Int64.to_stringl|SomeRLIMIT_CORE|SomeRLIMIT_DATA|SomeRLIMIT_FSIZE|SomeRLIMIT_STACK|SomeRLIMIT_AS->string_of_bytesl|SomeRLIMIT_NOFILE->Int64.to_stringl|SomeRLIMIT_CPU->Printf.sprintf"%Ld s"lletcomparel1l2=matchl1,l2with|Somel1,Somel2->Int64.comparel1l2|None,None->0|Some_,None->-1|None,Some_->1leteql1l2=comparel1l2=0letgtl1l2=comparel1l2>0letgel1l2=comparel1l2>=0letltl1l2=comparel1l2<0letlel1l2=comparel1l2<=0end(* Rlimit *)(** Get nice value *)externalgetpriority:which_prio_t->priority="caml_extunix_getpriority"(** Set nice value *)externalsetpriority:which_prio_t->priority->unit="caml_extunix_setpriority"(** Get maximum resource consumption.
@return [(soft,hard)] limits *)externalgetrlimit:resource->Rlimit.t*Rlimit.t="caml_extunix_getrlimit"(** Set maximum resource consumption *)externalsetrlimit:resource->soft:Rlimit.t->hard:Rlimit.t->unit="caml_extunix_setrlimit"(* let unlimit_soft r = let (_,hard) = getrlimit r in setrlimit r ~soft:hard ~hard *)(** [getrusage] is not implemented because the only meaningful information it
provides are [ru_utime] and [ru_stime] which can be accessed through
[Unix.times].
*)](** {2 Memory management} *)[%%haveMLOCKALL(** mlockall flag *)typemlockall_flag=MCL_CURRENT|MCL_FUTURE(** Lock all pages mapped into the address space of the calling process. *)externalmlockall:mlockall_flaglist->unit="caml_extunix_mlockall"(** Unlock all pages mapped into the address space of the calling process. *)externalmunlockall:unit->unit="caml_extunix_munlockall"][%%haveMEMALIGN(** [memalign alignment size] creates a {!Bigarray.Array1.t} of [size] bytes,
which data is aligned to [alignment] (must be a power of 2)
@author Goswin von Brederlow
*)externalmemalign:int->int->Bigarray.int8_unsigned_eltcarray8="caml_extunix_memalign"](** {2 Time conversion} *)[%%haveSTRPTIME(** This function is the converse of the {!strftime} function.
[strptime fmt data] convert a string containing time information [data]
into a [tm] struct according to the format specified by [fmt]. *)externalstrptime:string->string->Unix.tm="caml_extunix_strptime"][%%haveSTRTIME(** Return the ascii representation of a given [tm] argument. The
ascii time is returned in the form of a string like
'Wed Jun 30, 21:21:21 2005\n' *)externalasctime:Unix.tm->string="caml_extunix_asctime"(** This functions is the converse of the {!strptime} function.
[strftime fmt data] converts a [tm] structure [data] into a string
according to the format specified by [fmt]. *)externalstrftime:string->Unix.tm->string="caml_extunix_strftime"(** [tzname isdst]
@param isdst specifies whether daylight saving is in effect
@return abbreviated name of the current timezone
*)externaltzname:bool->string="caml_extunix_tzname"][%%haveTIMEZONE(** @return timezone (seconds West of UTC) and daylight (whether there is time during
the year when daylight saving time applies in this timezone) *)externaltimezone:unit->int*bool="caml_extunix_timezone"][%%haveTIMEGM(** Inverse of [Unix.gmtime] *)externaltimegm:Unix.tm->float="caml_extunix_timegm"][%%havePTS(**
{2 Pseudo terminal management}
@author Niki Yoshiuchi <aplusbi@gmail.com>
*)(** This function opens a pseudo-terminal device. *)externalposix_openpt:open_flaglist->Unix.file_descr="caml_extunix_posix_openpt"(** This function grants access to the slave pseudo-terminal. *)externalgrantpt:Unix.file_descr->unit="caml_extunix_grantpt"(** This function unlock a pseudo-terminal master/slave pair. *)externalunlockpt:Unix.file_descr->unit="caml_extunix_unlockpt"(** This function get the name of the slave pseudo-terminal. *)externalptsname:Unix.file_descr->string="caml_extunix_ptsname"](** {2 Application self-debugging and diagnostics} *)[%%haveEXECINFO(** @return a backtrace for the calling program
{b NB} native function [backtrace] may fail to unwind the OCaml callstack
correctly or even segfault. Do not use lightly.
See {{:https://forge.ocamlcore.org/tracker/index.php?func=detail&aid=1290}bug #1290},
{{:http://caml.inria.fr/mantis/view.php?id=5334}PR#5344}
and {{:http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=637360}Debian bug #637380} for details.
*)externalbacktrace:unit->stringarray="caml_extunix_backtrace"][%%haveMALLOC_STATS(** Print brief heap summary statistics on stderr *)externalmalloc_stats:unit->unit="caml_extunix_malloc_stats"][%%haveMALLOC_INFO(** @return the information about state of allocator *)externalmalloc_info:unit->string="caml_extunix_malloc_info"][%%haveMCHECKexternalmtrace:unit->unit="caml_extunix_mtrace"externalmuntrace:unit->unit="caml_extunix_muntrace"][%%havePTRACEexternalptrace_traceme:unit->unit="caml_extunix_ptrace_traceme"externalptrace_peekdata:int->nativeint->nativeint="caml_extunix_ptrace_peekdata"externalptrace_peektext:int->nativeint->nativeint="caml_extunix_ptrace_peektext"typeptrace_request=|PTRACE_ATTACH|PTRACE_DETACHexternalptrace:int->ptrace_request->unit="caml_extunix_ptrace"](** {2 Environment manipulation} *)[%%haveSETENV(** [setenv name value overwrite] adds the variable [name] to the environment with the value [value], if [name]
does not already exist or [overwrite] is true *)externalsetenv:string->string->bool->unit="caml_extunix_setenv"(** [unsetenv name] removes variable [name] from the environment. If [name] does not exist in the environment, then the function
succeeds, and the environment is unchanged. *)externalunsetenv:string->unit="caml_extunix_unsetenv"][%%haveCLEARENV(** Clear the environment of all name-value pairs *)externalclearenv:unit->unit="caml_extunix_clearenv"](** {2 Temporary directories} *)[%%haveMKDTEMP(** [mkdtemp template] creates a unique temporary directory (with permissions 0700).
Last six characters of [template] must be "XXXXXX". *)externalmkdtemp:string->string="caml_extunix_mkdtemp"][%%haveMKSTEMPS(**/**)(** internal use only *)externalinternal_mkstemps:bytes->int->Unix.file_descr="caml_extunix_internal_mkstemps"(**/**)(** [mkstemp ?(suffix="") prefix] generates a unique temporary
filename in the form [prefix]XXXXXX[suffix], creates and opens the
file, and returns an open file descriptor and name for the
file. *)letmkstemp?(suffix="")prefix=lets=Bytes.of_string(prefix^"XXXXXX"^suffix)inletfd=internal_mkstempss(String.lengthsuffix)in(fd,Bytes.to_strings)][%%haveMKOSTEMPS(**/**)(** internal use only *)externalinternal_mkostemps:bytes->int->open_flaglist->Unix.file_descr="caml_extunix_internal_mkostemps"(**/**)(** [mkostemp ?(suffix="") ?(flags=[]) prefix] generates a unique temporary
filename in the form [prefix]XXXXXX[suffix], creates and opens the
file with [flags], and returns an open file descriptor and name
for the file. *)letmkostemp?(suffix="")?(flags=[])prefix=lets=Bytes.of_string(prefix^"XXXXXX"^suffix)inletfd=internal_mkostempss(String.lengthsuffix)flagsin(fd,Bytes.to_strings)](** {2 Byte order conversion} *)(** {2 big endian functions}
@author Goswin von Brederlow *)moduleBigEndian=struct[%%haveENDIAN(** Conversion functions from host to big endian byte order and back *)(** Conversion of 16bit integers *)(** [uint16_from_host u16] converts an unsigned 16bit integer from host to
big endian byte order *)externaluint16_from_host:int->int="caml_extunix_htobe16"[@@noalloc](** [int16_from_host i16] converts a signed 16bit integer from host to
big endian byte order *)externalint16_from_host:int->int="caml_extunix_htobe16_signed"[@@noalloc](** [uint16_to_host u16] converts an unsigned 16bit integer from big
endian to host byte order *)externaluint16_to_host:int->int="caml_extunix_be16toh"[@@noalloc](** [int16_to_host i16] converts a signed 16bit integer from big
endian to host byte order *)externalint16_to_host:int->int="caml_extunix_be16toh_signed"[@@noalloc](** Conversion of 31bit integeres
On 64bit platforms this actualy converts 32bit integers without
the need to allocate a new int32. On 32bit platforms it produces
garbage. For use on 64bit platforms only! *)(** [uint31_from_host u31] converts an unsigned 31bit integer from
host to big endian byte order *)externaluint31_from_host:int->int="caml_extunix_htobe31"[@@noalloc](** [int31_from_host i31] converts a signed 31bit integer from host to
big endian byte order *)externalint31_from_host:int->int="caml_extunix_htobe31_signed"[@@noalloc](** [uint31_to_host u31] converts an unsigned 31bit integer from big
endian to host byte order *)externaluint31_to_host:int->int="caml_extunix_be31toh"[@@noalloc](** [int31_to_host i31] converts a signed 31bit integer from big
endian to host byte order *)externalint31_to_host:int->int="caml_extunix_be31toh_signed"[@@noalloc](** Conversion of 32bit integers *)(** [int32_from_host int32] converts a 32bit integer from host to big
endian byte order *)externalint32_from_host:int32->int32="caml_extunix_htobe32"(** [int32_to_host int32] converts a 32bit integer from big endian to
host byte order *)externalint32_to_host:int32->int32="caml_extunix_be32toh"(** Conversion of 64bit integers *)(** [int64_from_host int64] converts a 64bit integer from host to big
endian byte order *)externalint64_from_host:int64->int64="caml_extunix_htobe64"(** [int64_to_host int64] converts a 64bit integer from big endian to
host byte order *)externalint64_to_host:int64->int64="caml_extunix_be64toh"(** [unsafe_get_X str off] extract integer of type [X] from string
[str] starting at offset [off]. Unsigned types are 0 extended
and signed types are sign extended to fill the ocaml type.
Bounds checking is not performed. Use with caution and only when
the program logic guarantees that the access is within bounds.
Note: The 31bit functions extract a 32bit integer and return it
as ocaml int. On 32bit platforms this can overflow as ocaml
integers are 31bit signed there. No error is reported if this
occurs. Use with care.
Note: The same applies to 63bit functions.
*)externalunsafe_get_uint8:string->int->int="caml_extunix_get_u8"[@@noalloc]externalunsafe_get_int8:string->int->int="caml_extunix_get_s8"[@@noalloc]externalunsafe_get_uint16:string->int->int="caml_extunix_get_bu16"[@@noalloc]externalunsafe_get_int16:string->int->int="caml_extunix_get_bs16"[@@noalloc]externalunsafe_get_uint31:string->int->int="caml_extunix_get_bu31"[@@noalloc]externalunsafe_get_int31:string->int->int="caml_extunix_get_bs31"[@@noalloc]externalunsafe_get_int32:string->int->int32="caml_extunix_get_bs32"externalunsafe_get_uint63:string->int->int="caml_extunix_get_bu63"[@@noalloc]externalunsafe_get_int63:string->int->int="caml_extunix_get_bs63"[@@noalloc]externalunsafe_get_int64:string->int->int64="caml_extunix_get_bs64"(** [get_X str off] same as [unsafe_get_X] but with bounds checking. *)letget_uint8stroff=ifoff<0||off>=String.lengthstrthenraise(Invalid_argument"index out of bounds");unsafe_get_uint8stroffletget_int8stroff=ifoff<0||off>=String.lengthstrthenraise(Invalid_argument"index out of bounds");unsafe_get_int8stroffletget_uint16stroff=ifoff<0||off>String.lengthstr-2thenraise(Invalid_argument"index out of bounds");unsafe_get_uint16stroffletget_int16stroff=ifoff<0||off>String.lengthstr-2thenraise(Invalid_argument"index out of bounds");unsafe_get_int16stroffletget_uint31stroff=ifoff<0||off>String.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_get_uint31stroffletget_int31stroff=ifoff<0||off>String.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_get_int31stroffletget_int32stroff=ifoff<0||off>String.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_get_int32stroffletget_uint63stroff=ifoff<0||off>String.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_get_uint63stroffletget_int63stroff=ifoff<0||off>String.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_get_int63stroffletget_int64stroff=ifoff<0||off>String.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_get_int64stroff(** [unsafe_set_X buf off v] stores the integer [v] as type [X] in
the buffer [buf] starting at offset [off]. Bounds checking is not
performed. Use with caution and only when the program logic
guarantees that the access is within bounds.
Note: The 31bit functions store an ocaml int as 32bit
integer. On 32bit platforms ocaml integers are 31bit signed and
will be sign extended to 32bit first. Use with care.
Note: The same applies to 63bit functions.
*)externalunsafe_set_uint8:Bytes.t->int->int->unit="caml_extunix_set_8"[@@noalloc]externalunsafe_set_int8:Bytes.t->int->int->unit="caml_extunix_set_8"[@@noalloc]externalunsafe_set_uint16:Bytes.t->int->int->unit="caml_extunix_set_b16"[@@noalloc]externalunsafe_set_int16:Bytes.t->int->int->unit="caml_extunix_set_b16"[@@noalloc]externalunsafe_set_uint31:Bytes.t->int->int->unit="caml_extunix_set_b31"[@@noalloc]externalunsafe_set_int31:Bytes.t->int->int->unit="caml_extunix_set_b31"[@@noalloc]externalunsafe_set_int32:Bytes.t->int->int32->unit="caml_extunix_set_b32"[@@noalloc]externalunsafe_set_uint63:Bytes.t->int->int->unit="caml_extunix_set_b63"[@@noalloc]externalunsafe_set_int63:Bytes.t->int->int->unit="caml_extunix_set_b63"[@@noalloc]externalunsafe_set_int64:Bytes.t->int->int64->unit="caml_extunix_set_b64"[@@noalloc](** [set_X buf off v] same as [unsafe_set_X] but with bounds checking. *)letset_uint8stroffv=ifoff<0||off>=Bytes.lengthstrthenraise(Invalid_argument"index out of bounds");unsafe_set_uint8stroffvletset_int8stroffv=ifoff<0||off>=Bytes.lengthstrthenraise(Invalid_argument"index out of bounds");unsafe_set_int8stroffvletset_uint16stroffv=ifoff<0||off>Bytes.lengthstr-2thenraise(Invalid_argument"index out of bounds");unsafe_set_uint16stroffvletset_int16stroffv=ifoff<0||off>Bytes.lengthstr-2thenraise(Invalid_argument"index out of bounds");unsafe_set_int16stroffvletset_uint31stroffv=ifoff<0||off>Bytes.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_set_uint31stroffvletset_int31stroffv=ifoff<0||off>Bytes.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_set_int31stroffvletset_int32stroffv=ifoff<0||off>Bytes.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_set_int32stroffvletset_uint63stroffv=ifoff<0||off>Bytes.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_set_uint63stroffvletset_int63stroffv=ifoff<0||off>Bytes.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_set_int63stroffvletset_int64stroffv=ifoff<0||off>Bytes.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_set_int64stroffv]end(** {2 little endian functions}
@author Goswin von Brederlow *)moduleLittleEndian=struct[%%haveENDIAN(** Conversion functions from host to little endian byte order and back *)(** Conversion of 16bit integers *)(** [uint16_from_host u16] converts an unsigned 16bit integer from host to
little endian byte order *)externaluint16_from_host:int->int="caml_extunix_htole16"[@@noalloc](** [int16_from_host i16] converts a signed 16bit integer from host to
little endian byte order *)externalint16_from_host:int->int="caml_extunix_htole16_signed"[@@noalloc](** [uint16_to_host u16] converts an unsigned 16bit integer from little
endian to host byte order *)externaluint16_to_host:int->int="caml_extunix_le16toh"[@@noalloc](** [int16_to_host i16] converts a signed 16bit integer from little
endian to host byte order *)externalint16_to_host:int->int="caml_extunix_le16toh_signed"[@@noalloc](** Conversion of 31bit integeres
On 64bit platforms this actualy converts 32bit integers without
the need to allocate a new int32. On 32bit platforms it produces
garbage. For use on 64bit platforms only! *)(** [uint31_from_host u31] converts an unsigned 31bit integer from
host to little endian byte order *)externaluint31_from_host:int->int="caml_extunix_htole31"[@@noalloc](** [int31_from_host i31] converts a signed 31bit integer from host to
little endian byte order *)externalint31_from_host:int->int="caml_extunix_htole31_signed"[@@noalloc](** [uint31_to_host u31] converts an unsigned 31bit integer from little
endian to host byte order *)externaluint31_to_host:int->int="caml_extunix_le31toh"[@@noalloc](** [int31_to_host i31] converts a signed 31bit integer from little
endian to host byte order *)externalint31_to_host:int->int="caml_extunix_le31toh_signed"[@@noalloc](** Conversion of 32bit integers *)(** [int32_from_host int32] converts a 32bit integer from host to little
endian byte order *)externalint32_from_host:int32->int32="caml_extunix_htole32"(** [int32_to_host int32] converts a 32bit integer from little endian to
host byte order *)externalint32_to_host:int32->int32="caml_extunix_le32toh"(** Conversion of 64bit integers *)(** [int64_from_host int64] converts a 64bit integer from host to little
endian byte order *)externalint64_from_host:int64->int64="caml_extunix_htole64"(** [int64_to_host int64] converts a 64bit integer from little endian to
host byte order *)externalint64_to_host:int64->int64="caml_extunix_le64toh"(** [unsafe_get_X str off] extract integer of type [X] from string
[str] starting at offset [off]. Unsigned types are 0 extended
and signed types are sign extended to fill the ocaml type.
Bounds checking is not performed. Use with caution and only when
the program logic guarantees that the access is within bounds.
Note: The 31bit functions extract a 32bit integer and return it
as ocaml int. On 32bit platforms this can overflow as ocaml
integers are 31bit signed there. No error is reported if this
occurs. Use with care. *)externalunsafe_get_uint8:string->int->int="caml_extunix_get_u8"[@@noalloc]externalunsafe_get_int8:string->int->int="caml_extunix_get_s8"[@@noalloc]externalunsafe_get_uint16:string->int->int="caml_extunix_get_lu16"[@@noalloc]externalunsafe_get_int16:string->int->int="caml_extunix_get_ls16"[@@noalloc]externalunsafe_get_uint31:string->int->int="caml_extunix_get_lu31"[@@noalloc]externalunsafe_get_int31:string->int->int="caml_extunix_get_ls31"[@@noalloc]externalunsafe_get_int32:string->int->int32="caml_extunix_get_ls32"externalunsafe_get_uint63:string->int->int="caml_extunix_get_lu63"[@@noalloc]externalunsafe_get_int63:string->int->int="caml_extunix_get_ls63"[@@noalloc]externalunsafe_get_int64:string->int->int64="caml_extunix_get_ls64"(** [get_X str off] same as [unsafe_get_X] but with bounds checking. *)letget_uint8stroff=ifoff<0||off>=String.lengthstrthenraise(Invalid_argument"index out of bounds");unsafe_get_uint8stroffletget_int8stroff=ifoff<0||off>=String.lengthstrthenraise(Invalid_argument"index out of bounds");unsafe_get_int8stroffletget_uint16stroff=ifoff<0||off>String.lengthstr-2thenraise(Invalid_argument"index out of bounds");unsafe_get_uint16stroffletget_int16stroff=ifoff<0||off>String.lengthstr-2thenraise(Invalid_argument"index out of bounds");unsafe_get_int16stroffletget_uint31stroff=ifoff<0||off>String.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_get_uint31stroffletget_int31stroff=ifoff<0||off>String.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_get_int31stroffletget_int32stroff=ifoff<0||off>String.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_get_int32stroffletget_uint63stroff=ifoff<0||off>String.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_get_uint63stroffletget_int63stroff=ifoff<0||off>String.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_get_int63stroffletget_int64stroff=ifoff<0||off>String.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_get_int64stroff(** [unsafe_set_X buf off v] stores the integer [v] as type [X] in
the buffer [buf] starting at offset [off]. Bounds checking is not
performed. Use with caution and only when the program logic
guarantees that the access is within bounds.
Note: The 31bit functions store an ocaml int as 32bit
integer. On 32bit platforms ocaml integers are 31bit signed and
will be sign extended to 32bit first. Use with care. *)externalunsafe_set_uint8:Bytes.t->int->int->unit="caml_extunix_set_8"[@@noalloc]externalunsafe_set_int8:Bytes.t->int->int->unit="caml_extunix_set_8"[@@noalloc]externalunsafe_set_uint16:Bytes.t->int->int->unit="caml_extunix_set_l16"[@@noalloc]externalunsafe_set_int16:Bytes.t->int->int->unit="caml_extunix_set_l16"[@@noalloc]externalunsafe_set_uint31:Bytes.t->int->int->unit="caml_extunix_set_l31"[@@noalloc]externalunsafe_set_int31:Bytes.t->int->int->unit="caml_extunix_set_l31"[@@noalloc]externalunsafe_set_int32:Bytes.t->int->int32->unit="caml_extunix_set_l32"[@@noalloc]externalunsafe_set_uint63:Bytes.t->int->int->unit="caml_extunix_set_l63"[@@noalloc]externalunsafe_set_int63:Bytes.t->int->int->unit="caml_extunix_set_l63"[@@noalloc]externalunsafe_set_int64:Bytes.t->int->int64->unit="caml_extunix_set_l64"[@@noalloc](** [set_X buf off v] same as [unsafe_set_X] but with bounds checking. *)letset_uint8stroffv=ifoff<0||off>=Bytes.lengthstrthenraise(Invalid_argument"index out of bounds");unsafe_set_uint8stroffvletset_int8stroffv=ifoff<0||off>=Bytes.lengthstrthenraise(Invalid_argument"index out of bounds");unsafe_set_int8stroffvletset_uint16stroffv=ifoff<0||off>Bytes.lengthstr-2thenraise(Invalid_argument"index out of bounds");unsafe_set_uint16stroffvletset_int16stroffv=ifoff<0||off>Bytes.lengthstr-2thenraise(Invalid_argument"index out of bounds");unsafe_set_int16stroffvletset_uint31stroffv=ifoff<0||off>Bytes.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_set_uint31stroffvletset_int31stroffv=ifoff<0||off>Bytes.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_set_int31stroffvletset_int32stroffv=ifoff<0||off>Bytes.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_set_int32stroffvletset_uint63stroffv=ifoff<0||off>Bytes.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_set_uint63stroffvletset_int63stroffv=ifoff<0||off>Bytes.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_set_int63stroffvletset_int64stroffv=ifoff<0||off>Bytes.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_set_int64stroffv]end(** {2 host endian functions}
@author Goswin von Brederlow *)moduleHostEndian=struct(** [unsafe_get_X str off] extract integer of type [X] from string
[str] starting at offset [off]. Unsigned types are 0 extended
and signed types are sign extended to fill the ocaml type.
Bounds checking is not performed. Use with caution and only when
the program logic guarantees that the access is within bounds.
Note: The 31bit functions extract a 32bit integer and return it
as ocaml int. On 32bit platforms this can overflow as ocaml
integers are 31bit signed there. No error is reported if this
occurs. Use with care.
Note: The same applies to 63bit functions.
*)externalunsafe_get_uint8:string->int->int="caml_extunix_get_u8"[@@noalloc]externalunsafe_get_int8:string->int->int="caml_extunix_get_s8"[@@noalloc]externalunsafe_get_uint16:string->int->int="caml_extunix_get_hu16"[@@noalloc]externalunsafe_get_int16:string->int->int="caml_extunix_get_hs16"[@@noalloc]externalunsafe_get_uint31:string->int->int="caml_extunix_get_hu31"[@@noalloc]externalunsafe_get_int31:string->int->int="caml_extunix_get_hs31"[@@noalloc]externalunsafe_get_int32:string->int->int32="caml_extunix_get_hs32"externalunsafe_get_uint63:string->int->int="caml_extunix_get_hu63"[@@noalloc]externalunsafe_get_int63:string->int->int="caml_extunix_get_hs63"[@@noalloc]externalunsafe_get_int64:string->int->int64="caml_extunix_get_hs64"(** [get_X str off] same as [unsafe_get_X] but with bounds checking. *)letget_uint8stroff=ifoff<0||off>=String.lengthstrthenraise(Invalid_argument"index out of bounds");unsafe_get_uint8stroffletget_int8stroff=ifoff<0||off>=String.lengthstrthenraise(Invalid_argument"index out of bounds");unsafe_get_int8stroffletget_uint16stroff=ifoff<0||off>String.lengthstr-2thenraise(Invalid_argument"index out of bounds");unsafe_get_uint16stroffletget_int16stroff=ifoff<0||off>String.lengthstr-2thenraise(Invalid_argument"index out of bounds");unsafe_get_int16stroffletget_uint31stroff=ifoff<0||off>String.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_get_uint31stroffletget_int31stroff=ifoff<0||off>String.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_get_int31stroffletget_int32stroff=ifoff<0||off>String.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_get_int32stroffletget_uint63stroff=ifoff<0||off>String.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_get_uint63stroffletget_int63stroff=ifoff<0||off>String.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_get_int63stroffletget_int64stroff=ifoff<0||off>String.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_get_int64stroff(** [unsafe_set_X buf off v] stores the integer [v] as type [X] in
the buffer [buf] starting at offset [off]. Bounds checking is not
performed. Use with caution and only when the program logic
guarantees that the access is within bounds.
Note: The 31bit functions store an ocaml int as 32bit
integer. On 32bit platforms ocaml integers are 31bit signed and
will be sign extended to 32bit first. Use with care.
Note: The same applies to 63bit functions.
*)externalunsafe_set_uint8:Bytes.t->int->int->unit="caml_extunix_set_8"[@@noalloc]externalunsafe_set_int8:Bytes.t->int->int->unit="caml_extunix_set_8"[@@noalloc]externalunsafe_set_uint16:Bytes.t->int->int->unit="caml_extunix_set_h16"[@@noalloc]externalunsafe_set_int16:Bytes.t->int->int->unit="caml_extunix_set_h16"[@@noalloc]externalunsafe_set_uint31:Bytes.t->int->int->unit="caml_extunix_set_h31"[@@noalloc]externalunsafe_set_int31:Bytes.t->int->int->unit="caml_extunix_set_h31"[@@noalloc]externalunsafe_set_int32:Bytes.t->int->int32->unit="caml_extunix_set_h32"[@@noalloc]externalunsafe_set_uint63:Bytes.t->int->int->unit="caml_extunix_set_h63"[@@noalloc]externalunsafe_set_int63:Bytes.t->int->int->unit="caml_extunix_set_h63"[@@noalloc]externalunsafe_set_int64:Bytes.t->int->int64->unit="caml_extunix_set_h64"[@@noalloc](** [set_X buf off v] same as [unsafe_set_X] but with bounds checking. *)letset_uint8stroffv=ifoff<0||off>=Bytes.lengthstrthenraise(Invalid_argument"index out of bounds");unsafe_set_uint8stroffvletset_int8stroffv=ifoff<0||off>=Bytes.lengthstrthenraise(Invalid_argument"index out of bounds");unsafe_set_int8stroffvletset_uint16stroffv=ifoff<0||off>Bytes.lengthstr-2thenraise(Invalid_argument"index out of bounds");unsafe_set_uint16stroffvletset_int16stroffv=ifoff<0||off>Bytes.lengthstr-2thenraise(Invalid_argument"index out of bounds");unsafe_set_int16stroffvletset_uint31stroffv=ifoff<0||off>Bytes.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_set_uint31stroffvletset_int31stroffv=ifoff<0||off>Bytes.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_set_int31stroffvletset_int32stroffv=ifoff<0||off>Bytes.lengthstr-4thenraise(Invalid_argument"index out of bounds");unsafe_set_int32stroffvletset_uint63stroffv=ifoff<0||off>Bytes.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_set_uint63stroffvletset_int63stroffv=ifoff<0||off>Bytes.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_set_int63stroffvletset_int64stroffv=ifoff<0||off>Bytes.lengthstr-8thenraise(Invalid_argument"index out of bounds");unsafe_set_int64stroffvend[%%haveREAD_CREDENTIALS(** {2 read_credentials }
@author Andre Nathan *)(** Reads sender credentials from a file descriptor, returning a 3-element
tuple containing the sender process' PID, UID and GID. *)externalread_credentials:Unix.file_descr->int*int*int="caml_extunix_read_credentials"][%%haveFEXECVE(** {2 fexecve }
@author Andre Nathan *)(** [fexecve fd args env] executes the program in file represented by
file descriptor [fd] with arguments [args] and environment
variables given by [env]. As with the [execv*] functions, on
success [fexecve] never returns; the current process is replaced
by the new one.
*)externalfexecve:Unix.file_descr->stringarray->stringarray->'a="caml_extunix_fexecve"][%%haveSENDMSG(** {2 sendmsg / recvmsg }
@author Andre Nathan *)(** Send a message and optionally a file descriptor through a socket. Passing
file descriptors requires UNIX domain sockets and a non-empty message. *)externalsendmsg:Unix.file_descr->?sendfd:Unix.file_descr->string->unit="caml_extunix_sendmsg"(** Recieve a message and possibly a file descriptor from a socket. *)externalrecvmsg_fd:Unix.file_descr->Unix.file_descroption*string="caml_extunix_recvmsg"(** [sendfd sock fd] sends a file descriptor [fd] through a UNIX domain socket [sock].
This will send a sentinel message at the same time, otherwise {!sendmsg} will not pass the file descriptor. *)letsendfd~sock~fd=sendmsgsock~sendfd:fd"\001"(** Receive a file descriptor sent through a UNIX domain socket, ignoring the message. *)letrecvfdfd=matchrecvmsg_fdfdwith|(Somerecvfd,_)->recvfd|_->raise(Unix.Unix_error(Unix.EINVAL,"recvfd","no descriptor"))(** Receive a message sent through a UNIX domain socket. Raises
Recvfd(fd, msg) if a file descriptor is recieved. *)exceptionRecvfdofUnix.file_descr*stringletrecvmsgfd=matchrecvmsg_fdfdwith|(None,msg)->msg|(Somefd,msg)->raise(Recvfd(fd,msg))(** Receive a message sent through a UNIX domain socket. Closes and
ignores file descriptors. *)letrecvmsg_nofdfd=matchrecvmsg_fdfdwith|(Somefd,msg)->Unix.closefd;msg|(None,msg)->msg][%%haveSYSCONF(** {2 sysconf}
@author Roman Vorobets *)(** name of the variable *)typesysconf_name=|ARG_MAX(** The maximum length of the arguments to the exec(3)
family of functions. *)|CHILD_MAX(** The max number of simultaneous processes per user
ID. *)|HOST_NAME_MAX(** Max length of a hostname, not including the
terminating null byte, as returned by
gethostname(2). *)|LOGIN_NAME_MAX(** Maximum length of a login name, including the
terminating null byte. *)|CLK_TCK(** The number of clock ticks per second. *)|OPEN_MAX(** The maximum number of files that a process can
have open at any time. *)|PAGESIZE(** Size of a page in bytes. *)|RE_DUP_MAX(** The number of repeated occurrences of a BRE
permitted by regexec(3) and regcomp(3). *)|STREAM_MAX(** The maximum number of streams that a process can
have open at any time. *)|SYMLOOP_MAX(** The maximum number of symbolic links seen in a
pathname before resolution returns ELOOP. *)|TTY_NAME_MAX(** The maximum length of terminal device name,
including the terminating null byte. *)|TZNAME_MAX(** The maximum number of bytes in a timezone name. *)|POSIX_VERSION(** Indicates the year and month the POSIX.1 standard
was approved in the format YYYYMML; the value
199009L indicates the Sept. 1990 revision. *)|LINE_MAX(** The maximum length of a utility's input line,
either from standard input or from a file. This
includes space for a trailing newline. *)|POSIX2_VERSION(** Indicates the version of the POSIX.2 standard in
the format of YYYYMML. *)|PHYS_PAGES(** The number of pages of physical memory. Note that
it is possible for the product of this value and the
value of [PAGE_SIZE] to overflow. Non-standard, may be not available *)|AVPHYS_PAGES(** The number of currently available pages of physical memory. Non-standard, may be not available *)|NPROCESSORS_CONF(** The number of processors configured. Non-standard, may be not available *)|NPROCESSORS_ONLN(** The number of processors currently online (available). Non-standard, may be not available *)externalsysconf:sysconf_name->int64="caml_extunix_sysconf"(** get configuration information at runtime, may raise [Not_available] for non-standard options (see above)
even in [Specific] module *)letsysconfsc=trysysconfscwithNot_found->raise(Not_available"sysconf")][%%have(SPLICE,TEE,VMSPLICE)(**
{2 splice}
@author Pierre Chambart <pierre.chambart@ocamlpro.com>
*)(** splice functions flags *)typesplice_flag=|SPLICE_F_MOVE(** Attempt to move pages instead of copying. Only a hint
to the kernel *)|SPLICE_F_NONBLOCK(** Do not block on I/O *)|SPLICE_F_MORE(** Announce that more data will be coming. Hint used by
sockets *)|SPLICE_F_GIFT(** The user pages are a gift to the kernel. The
application may not modify this memory ever, or page
cache and on-disk data may differ. Gifting pages to
the kernel means that a subsequent splice(2)
SPLICE_F_MOVE can successfully move the pages; if
this flag is not specified, then a subsequent
splice(2) SPLICE_F_MOVE must copy the pages. Data
must also be properly page aligned, both in memory
and length.
Only use for [vmsplice]. *)][%%haveSPLICE(** [splice fd_in off_in fd_out off_out len flags] moves data between two file
descriptors without copying between kernel address space and user address
space. It transfers up to [len] bytes of data from the file descriptor
[fd_in] to the file descriptor [fd_out], where one of the descriptors
must refer to a pipe.
If [fd_in] refers to a pipe, then [off_in] must be [None]. If [fd_in] does
not refer to a pipe and [off_in] is [None], then bytes are read from [fd_in]
starting from the current file offset, and the current file offset is
adjusted appropriately. If [fd_in] does not refer to a pipe and [off_in]
is [Some n], then [n] mspecifies the starting offset from which bytes will
be read from [fd_in]; in this case, the current file offset of [fd_in] is not
changed. Analogous statements apply for [fd_out] and [off_out].
@return the number of bytes spliced to or from the pipe. A return value of 0
means that there was no data to transfer, and it would not make sense to
block, because there are no writers connected to the write end of the pipe
referred to by fd_in.
*)externalsplice:Unix.file_descr->intoption->Unix.file_descr->intoption->int->splice_flaglist->int="caml_extunix_splice_bytecode""caml_extunix_splice"][%%haveTEE(** [tee fd_in fd_out len flags] duplicates up to [len] bytes of data from the
pipe [fd_in] to the pipe [fd_out]. It does not consume the data that is
duplicated from [fd_in]; therefore, that data can be copied by a subsequent
splice.
@return the number of bytes that were duplicated between the input and
output. A return value of 0 means that there was no data to transfer, and
it would not make sense to block, because there are no writers connected
to the write end of the pipe referred to by fd_in.
*)externaltee:Unix.file_descr->Unix.file_descr->int->splice_flaglist->int="caml_extunix_tee"](** {2 Bigarray variants} *)(** *)moduleBA=struct[%%havePREAD(** {2 pread}
@author Goswin von Brederlow *)(** [all_pread fd off buf] reads up to [size of buf] bytes from file
descriptor [fd] at offset [off] (from the start of the file) into
the buffer [buf]. The file offset is not changed.
[all_pread] repeats the read operation until all characters have
been read or an error occurs. Returns less than the number of
characters requested on EAGAIN, EWOULDBLOCK or End-of-file but
only ever returns 0 on End-of-file. Continues the read operation
on EINTR. Raises an Unix.Unix_error exception in all other
cases. *)externalunsafe_all_pread:Unix.file_descr->int->('a,'b)carray->int="caml_extunixba_all_pread"letall_preadfdoffbuf=ifoff<0theninvalid_arg"ExtUnix.all_pread"elseunsafe_all_preadfdoffbuf(** [single_pread fd off buf] reads up to [size of buf] bytes from file
descriptor [fd] at offset [off] (from the start of the file) into
the buffer [buf]. The file offset is not changed.
[single_pread] attempts to read only once. Returns the number of
characters read or raises an Unix.Unix_error exception. Unlike the
string variant of the same name there is no limit on the number of
characters read. *)externalunsafe_single_pread:Unix.file_descr->int->('a,'b)carray->int="caml_extunixba_single_pread"letsingle_preadfdoffbuf=ifoff<0theninvalid_arg"ExtUnix.single_pread"elseunsafe_single_preadfdoffbuf(** [pread fd off buf] reads up to [size of buf] bytes from file
descriptor [fd] at offset [off] (from the start of the file) into
the buffer [buf]. The file offset is not changed.
[pread] repeats the read operation until all characters have
been read or an error occurs. Raises an Unix.Unix_error exception
if 0 characters could be read before an error occurs. Continues
the read operation on EINTR. Returns the number of characters
written in all other cases. *)externalunsafe_pread:Unix.file_descr->int->('a,'b)carray->int="caml_extunixba_pread"letpreadfdoffbuf=ifoff<0theninvalid_arg"ExtUnix.pread"elseunsafe_preadfdoffbuf(** [intr_pread fd off buf] reads up to [size of buf] bytes from file
descriptor [fd] at offset [off] (from the start of the file) into
the buffer [buf]. The file offset is not changed.
[intr_pread] repeats the read operation until all characters have
been read or an error occurs. Raises an Unix.Unix_error exception
if 0 characters could be read before an error occurs. Does NOT
continue on EINTR. Returns the number of characters written in all
other cases. *)externalunsafe_intr_pread:Unix.file_descr->int->('a,'b)carray->int="caml_extunixba_intr_pread"letintr_preadfdoffbuf=ifoff<0theninvalid_arg"ExtUnix.intr_pread"elseunsafe_intr_preadfdoffbuf][%%havePWRITE(** {2 pwrite}
@author Goswin von Brederlow *)(** [all_pwrite fd off buf] writes up to [size of buf] bytes from file
descriptor [fd] at offset [off] (from the start of the file) into
the buffer [buf]. The file offset is not changed.
[all_pwrite] repeats the write operation until all characters have
been written or an error occurs. Returns less than the number of
characters requested on EAGAIN, EWOULDBLOCK but never 0. Continues
the write operation on EINTR. Raises an Unix.Unix_error exception
in all other cases. *)externalunsafe_all_pwrite:Unix.file_descr->int->('a,'b)carray->int="caml_extunixba_all_pwrite"letall_pwritefdoffbuf=ifoff<0theninvalid_arg"ExtUnix.all_pwrite"elseunsafe_all_pwritefdoffbuf(** [single_pwrite fd off buf] writes up to [size of buf] bytes from file
descriptor [fd] at offset [off] (from the start of the file) into
the buffer [buf]. The file offset is not changed.
[single_pwrite] attempts to write only once. Returns the number of
characters written or raises an Unix.Unix_error exception. Unlike
the string variant of the same name there is no limit on the
number of characters written. *)externalunsafe_single_pwrite:Unix.file_descr->int->('a,'b)carray->int="caml_extunixba_single_pwrite"letsingle_pwritefdoffbuf=ifoff<0theninvalid_arg"ExtUnix.single_pwrite"elseunsafe_single_pwritefdoffbuf(** [pwrite fd off buf] writes up to [size of buf] bytes from file
descriptor [fd] at offset [off] (from the start of the file) into
the buffer [buf]. The file offset is not changed.
[pwrite] repeats the write operation until all characters have
been written or an error occurs. Raises an Unix.Unix_error exception
if 0 characters could be written before an error occurs. Continues
the write operation on EINTR. Returns the number of characters
written in all other cases. *)externalunsafe_pwrite:Unix.file_descr->int->('a,'b)carray->int="caml_extunixba_pwrite"letpwritefdoffbuf=ifoff<0theninvalid_arg"ExtUnix.pwrite"elseunsafe_pwritefdoffbuf(** [intr_pwrite fd off buf] writes up to [size of buf] bytes from file
descriptor [fd] at offset [off] (from the start of the file) into
the buffer [buf]. The file offset is not changed.
[intr_pwrite] repeats the write operation until all characters have
been written or an error occurs. Raises an Unix.Unix_error exception
if 0 characters could be written before an error occurs. Does NOT
continue on EINTR. Returns the number of characters written in all
other cases. *)externalunsafe_intr_pwrite:Unix.file_descr->int->('a,'b)carray->int="caml_extunixba_intr_pwrite"letintr_pwritefdoffbuf=ifoff<0theninvalid_arg"ExtUnix.intr_pwrite"elseunsafe_intr_pwritefdoffbuf][%%haveREAD(** {2 read}
@author Goswin von Brederlow *)(** [all_read fd buf] reads up to [size of buf] bytes from file
descriptor [fd] into the buffer [buf].
[all_read] repeats the read operation until all characters have
been read or an error occurs. Returns less than the number of
characters requested on EAGAIN, EWOULDBLOCK or End-of-file but
only ever returns 0 on End-of-file. Continues the read operation
on EINTR. Raises an Unix.Unix_error exception in all other
cases. *)externalall_read:Unix.file_descr->('a,'b)carray->int="caml_extunixba_all_read"(** [single_read fd buf] reads up to [size of buf] bytes from file
descriptor [fd] into the buffer [buf].
[single_read] attempts to read only once. Returns the number of
characters read or raises an Unix.Unix_error exception. Unlike the
string variant of the same name there is no limit on the number of
characters read. *)externalsingle_read:Unix.file_descr->('a,'b)carray->int="caml_extunixba_single_read"(** [read fd buf] reads up to [size of buf] bytes from file descriptor
[fd] into the buffer [buf].
[read] repeats the read operation until all characters have
been read or an error occurs. Raises an Unix.Unix_error exception
if 0 characters could be read before an error occurs. Continues
the read operation on EINTR. Returns the number of characters
written in all other cases. *)externalread:Unix.file_descr->('a,'b)carray->int="caml_extunixba_read"(** [intr_read fd buf] reads up to [size of buf] bytes from file
descriptor [fd] into the buffer [buf].
[intr_read] repeats the read operation until all characters have
been read or an error occurs. Raises an Unix.Unix_error exception
if 0 characters could be read before an error occurs. Does NOT
continue on EINTR. Returns the number of characters written in all
other cases. *)externalintr_read:Unix.file_descr->('a,'b)carray->int="caml_extunixba_intr_read"][%%haveWRITE(** {2 write}
@author Goswin von Brederlow *)(** [all_write fd buf] writes up to [size of buf] bytes from file
descriptor [fd] into the buffer [buf].
[all_write] repeats the write operation until all characters have
been written or an error occurs. Returns less than the number of
characters requested on EAGAIN, EWOULDBLOCK but never 0. Continues
the write operation on EINTR. Raises an Unix.Unix_error exception
in all other cases. *)externalall_write:Unix.file_descr->('a,'b)carray->int="caml_extunixba_all_write"(** [single_write fd buf] writes up to [size of buf] bytes from file
descriptor [fd] into the buffer [buf].
[single_write] attempts to write only once. Returns the number of
characters written or raises an Unix.Unix_error exception. Unlike
the string variant of the same name there is no limit on the
number of characters written. *)externalsingle_write:Unix.file_descr->('a,'b)carray->int="caml_extunixba_single_write"(** [write fd buf] writes up to [size of buf] bytes from file
descriptor [fd] into the buffer [buf].
[write] repeats the write operation until all characters have
been written or an error occurs. Raises an Unix.Unix_error exception
if 0 characters could be written before an error occurs. Continues
the write operation on EINTR. Returns the number of characters
written in all other cases. *)externalwrite:Unix.file_descr->('a,'b)carray->int="caml_extunixba_write"(** [intr_write fd buf] writes up to [size of buf] bytes from file
descriptor [fd] into the buffer [buf].
[intr_write] repeats the write operation until all characters have
been written or an error occurs. Raises an Unix.Unix_error exception
if 0 characters could be written before an error occurs. Does NOT
continue on EINTR. Returns the number of characters written in all
other cases. *)externalintr_write:Unix.file_descr->('a,'b)carray->int="caml_extunixba_intr_write"](** {2 Byte order conversion} *)(** {2 big endian functions}
@author Goswin von Brederlow *)moduleBigEndian=struct[%%haveENDIAN(** [unsafe_get_X buf off] extract integer of type [X] from a
buffer [buf] starting at offset [off]. Unsigned types are 0
extended and signed types are sign extended to fill the ocaml
type. Bounds checking is not performed. Use with caution and
only when the program logic guarantees that the access is within
bounds.
Note: The 31bit functions extract a 32bit integer and return it
as ocaml int. On 32bit platforms this can overflow as ocaml
integers are 31bit signed there. No error is reported if this
occurs. Use with care.
Note: The same applies to 63bit functions.
*)externalunsafe_get_uint8:'acarray8->int->int="caml_extunixba_get_u8"[@@noalloc]externalunsafe_get_int8:'acarray8->int->int="caml_extunixba_get_s8"[@@noalloc]externalunsafe_get_uint16:'acarray8->int->int="caml_extunixba_get_bu16"[@@noalloc]externalunsafe_get_int16:'acarray8->int->int="caml_extunixba_get_bs16"[@@noalloc]externalunsafe_get_uint31:'acarray8->int->int="caml_extunixba_get_bu31"[@@noalloc]externalunsafe_get_int31:'acarray8->int->int="caml_extunixba_get_bs31"[@@noalloc]externalunsafe_get_int32:'acarray8->int->int32="caml_extunixba_get_bs32"externalunsafe_get_uint63:'acarray8->int->int="caml_extunixba_get_bu63"[@@noalloc]externalunsafe_get_int63:'acarray8->int->int="caml_extunixba_get_bs63"[@@noalloc]externalunsafe_get_int64:'acarray8->int->int64="caml_extunixba_get_bs64"(** [get_X buf off] same as [unsafe_get_X] but with bounds checking. *)letget_uint8bufoff=ifoff<0||off>=Bigarray.Array1.dimbufthenraise(Invalid_argument"index out of bounds");unsafe_get_uint8bufoffletget_int8bufoff=ifoff<0||off>=Bigarray.Array1.dimbufthenraise(Invalid_argument"index out of bounds");unsafe_get_int8bufoffletget_uint16bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-2thenraise(Invalid_argument"index out of bounds");unsafe_get_uint16bufoffletget_int16bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-2thenraise(Invalid_argument"index out of bounds");unsafe_get_int16bufoffletget_uint31bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_get_uint31bufoffletget_int31bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_get_int31bufoffletget_int32bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_get_int32bufoffletget_uint63bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_get_uint63bufoffletget_int63bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_get_int63bufoffletget_int64bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_get_int64bufoff(** [unsafe_set_X buf off v] stores the integer [v] as type [X] in a
buffer [buf] starting at offset [off]. Bounds checking is not
performed. Use with caution and only when the program logic
guarantees that the access is within bounds.
Note: The 31bit functions store an ocaml int as 32bit
integer. On 32bit platforms ocaml integers are 31bit signed and
will be sign extended to 32bit first. Use with care.
Note: The same applies to 63bit function.
*)externalunsafe_set_uint8:'acarray8->int->int->unit="caml_extunixba_set_8"[@@noalloc]externalunsafe_set_int8:'acarray8->int->int->unit="caml_extunixba_set_8"[@@noalloc]externalunsafe_set_uint16:'acarray8->int->int->unit="caml_extunixba_set_b16"[@@noalloc]externalunsafe_set_int16:'acarray8->int->int->unit="caml_extunixba_set_b16"[@@noalloc]externalunsafe_set_uint31:'acarray8->int->int->unit="caml_extunixba_set_b31"[@@noalloc]externalunsafe_set_int31:'acarray8->int->int->unit="caml_extunixba_set_b31"[@@noalloc]externalunsafe_set_int32:'acarray8->int->int32->unit="caml_extunixba_set_b32"[@@noalloc]externalunsafe_set_uint63:'acarray8->int->int->unit="caml_extunixba_set_b63"[@@noalloc]externalunsafe_set_int63:'acarray8->int->int->unit="caml_extunixba_set_b63"[@@noalloc]externalunsafe_set_int64:'acarray8->int->int64->unit="caml_extunixba_set_b64"[@@noalloc](** [set_X buf off v] same as [unsafe_set_X] but with bounds checking. *)letset_uint8bufoffv=ifoff<0||off>=Bigarray.Array1.dimbufthenraise(Invalid_argument"index out of bounds");unsafe_set_uint8bufoffvletset_int8bufoffv=ifoff<0||off>=Bigarray.Array1.dimbufthenraise(Invalid_argument"index out of bounds");unsafe_set_int8bufoffvletset_uint16bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-2thenraise(Invalid_argument"index out of bounds");unsafe_set_uint16bufoffvletset_int16bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-2thenraise(Invalid_argument"index out of bounds");unsafe_set_int16bufoffvletset_uint31bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_set_uint31bufoffvletset_int31bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_set_int31bufoffvletset_int32bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_set_int32bufoffvletset_uint63bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_set_uint63bufoffvletset_int63bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_set_int63bufoffvletset_int64bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_set_int64bufoffv]end(* module BigEndian *)(** {2 little endian functions}
@author Goswin von Brederlow *)moduleLittleEndian=struct[%%haveENDIAN(** [unsafe_get_X buf off] extract integer of type [X] from a
buffer [buf] starting at offset [off]. Unsigned types are 0
extended and signed types are sign extended to fill the ocaml
type. Bounds checking is not performed. Use with caution and
only when the program logic guarantees that the access is within
bounds.
Note: The 31bit functions extract a 32bit integer and return it
as ocaml int. On 32bit platforms this can overflow as ocaml
integers are 31bit signed there. No error is reported if this
occurs. Use with care.
Note: The same applies to 63bit functions.
*)externalunsafe_get_uint8:'acarray8->int->int="caml_extunixba_get_u8"[@@noalloc]externalunsafe_get_int8:'acarray8->int->int="caml_extunixba_get_s8"[@@noalloc]externalunsafe_get_uint16:'acarray8->int->int="caml_extunixba_get_lu16"[@@noalloc]externalunsafe_get_int16:'acarray8->int->int="caml_extunixba_get_ls16"[@@noalloc]externalunsafe_get_uint31:'acarray8->int->int="caml_extunixba_get_lu31"[@@noalloc]externalunsafe_get_int31:'acarray8->int->int="caml_extunixba_get_ls31"[@@noalloc]externalunsafe_get_int32:'acarray8->int->int32="caml_extunixba_get_ls32"externalunsafe_get_uint63:'acarray8->int->int="caml_extunixba_get_lu63"[@@noalloc]externalunsafe_get_int63:'acarray8->int->int="caml_extunixba_get_ls63"[@@noalloc]externalunsafe_get_int64:'acarray8->int->int64="caml_extunixba_get_ls64"(** [get_X buf off] same as [unsafe_get_X] but with bounds checking. *)letget_uint8bufoff=ifoff<0||off>=Bigarray.Array1.dimbufthenraise(Invalid_argument"index out of bounds");unsafe_get_uint8bufoffletget_int8bufoff=ifoff<0||off>=Bigarray.Array1.dimbufthenraise(Invalid_argument"index out of bounds");unsafe_get_int8bufoffletget_uint16bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-2thenraise(Invalid_argument"index out of bounds");unsafe_get_uint16bufoffletget_int16bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-2thenraise(Invalid_argument"index out of bounds");unsafe_get_int16bufoffletget_uint31bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_get_uint31bufoffletget_int31bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_get_int31bufoffletget_int32bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_get_int32bufoffletget_uint63bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_get_uint63bufoffletget_int63bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_get_int63bufoffletget_int64bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_get_int64bufoff(** [unsafe_set_X buf off v] stores the integer [v] as type [X] in a
buffer [buf] starting at offset [off]. Bounds checking is not
performed. Use with caution and only when the program logic
guarantees that the access is within bounds.
Note: The 31bit functions store an ocaml int as 32bit
integer. On 32bit platforms ocaml integers are 31bit signed and
will be sign extended to 32bit first. Use with care.
Note: The same applies to 63bit functions.
*)externalunsafe_set_uint8:'acarray8->int->int->unit="caml_extunixba_set_8"[@@noalloc]externalunsafe_set_int8:'acarray8->int->int->unit="caml_extunixba_set_8"[@@noalloc]externalunsafe_set_uint16:'acarray8->int->int->unit="caml_extunixba_set_l16"[@@noalloc]externalunsafe_set_int16:'acarray8->int->int->unit="caml_extunixba_set_l16"[@@noalloc]externalunsafe_set_uint31:'acarray8->int->int->unit="caml_extunixba_set_l31"[@@noalloc]externalunsafe_set_int31:'acarray8->int->int->unit="caml_extunixba_set_l31"[@@noalloc]externalunsafe_set_int32:'acarray8->int->int32->unit="caml_extunixba_set_l32"[@@noalloc]externalunsafe_set_uint63:'acarray8->int->int->unit="caml_extunixba_set_l63"[@@noalloc]externalunsafe_set_int63:'acarray8->int->int->unit="caml_extunixba_set_l63"[@@noalloc]externalunsafe_set_int64:'acarray8->int->int64->unit="caml_extunixba_set_l64"[@@noalloc](** [set_X buf off v] same as [unsafe_set_X] but with bounds checking. *)letset_uint8bufoffv=ifoff<0||off>=Bigarray.Array1.dimbufthenraise(Invalid_argument"index out of bounds");unsafe_set_uint8bufoffvletset_int8bufoffv=ifoff<0||off>=Bigarray.Array1.dimbufthenraise(Invalid_argument"index out of bounds");unsafe_set_int8bufoffvletset_uint16bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-2thenraise(Invalid_argument"index out of bounds");unsafe_set_uint16bufoffvletset_int16bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-2thenraise(Invalid_argument"index out of bounds");unsafe_set_int16bufoffvletset_uint31bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_set_uint31bufoffvletset_int31bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_set_int31bufoffvletset_int32bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_set_int32bufoffvletset_uint63bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_set_uint63bufoffvletset_int63bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_set_int63bufoffvletset_int64bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_set_int64bufoffv]end(* module LittleEndian *)(** {2 host endian functions}
@author Goswin von Brederlow *)moduleHostEndian=struct(** [unsafe_get_X buf off] extract integer of type [X] from a
buffer [buf] starting at offset [off]. Unsigned types are 0
extended and signed types are sign extended to fill the ocaml
type. Bounds checking is not performed. Use with caution and
only when the program logic guarantees that the access is within
bounds.
Note: The 31bit functions extract a 32bit integer and return it
as ocaml int. On 32bit platforms this can overflow as ocaml
integers are 31bit signed there. No error is reported if this
occurs. Use with care.
Note: The same applies to 63bit functions.
*)externalunsafe_get_uint8:'acarray8->int->int="caml_extunixba_get_u8"[@@noalloc]externalunsafe_get_int8:'acarray8->int->int="caml_extunixba_get_s8"[@@noalloc]externalunsafe_get_uint16:'acarray8->int->int="caml_extunixba_get_hu16"[@@noalloc]externalunsafe_get_int16:'acarray8->int->int="caml_extunixba_get_hs16"[@@noalloc]externalunsafe_get_uint31:'acarray8->int->int="caml_extunixba_get_hu31"[@@noalloc]externalunsafe_get_int31:'acarray8->int->int="caml_extunixba_get_hs31"[@@noalloc]externalunsafe_get_int32:'acarray8->int->int32="caml_extunixba_get_hs32"externalunsafe_get_uint63:'acarray8->int->int="caml_extunixba_get_hu63"[@@noalloc]externalunsafe_get_int63:'acarray8->int->int="caml_extunixba_get_hs63"[@@noalloc]externalunsafe_get_int64:'acarray8->int->int64="caml_extunixba_get_hs64"(** [get_X buf off] same as [unsafe_get_X] but with bounds checking. *)letget_uint8bufoff=ifoff<0||off>=Bigarray.Array1.dimbufthenraise(Invalid_argument"index out of bounds");unsafe_get_uint8bufoffletget_int8bufoff=ifoff<0||off>=Bigarray.Array1.dimbufthenraise(Invalid_argument"index out of bounds");unsafe_get_int8bufoffletget_uint16bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-2thenraise(Invalid_argument"index out of bounds");unsafe_get_uint16bufoffletget_int16bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-2thenraise(Invalid_argument"index out of bounds");unsafe_get_int16bufoffletget_uint31bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_get_uint31bufoffletget_int31bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_get_int31bufoffletget_int32bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_get_int32bufoffletget_uint63bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_get_uint63bufoffletget_int63bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_get_int63bufoffletget_int64bufoff=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_get_int64bufoff(** [unsafe_set_X buf off v] stores the integer [v] as type [X] in a
buffer [buf] starting at offset [off]. Bounds checking is not
performed. Use with caution and only when the program logic
guarantees that the access is within bounds.
Note: The 31bit functions store an ocaml int as 32bit
integer. On 32bit platforms ocaml integers are 31bit signed and
will be sign extended to 32bit first. Use with care.
Note: The same applies to 63bit functions.
*)externalunsafe_set_uint8:'acarray8->int->int->unit="caml_extunixba_set_8"[@@noalloc]externalunsafe_set_int8:'acarray8->int->int->unit="caml_extunixba_set_8"[@@noalloc]externalunsafe_set_uint16:'acarray8->int->int->unit="caml_extunixba_set_h16"[@@noalloc]externalunsafe_set_int16:'acarray8->int->int->unit="caml_extunixba_set_h16"[@@noalloc]externalunsafe_set_uint31:'acarray8->int->int->unit="caml_extunixba_set_h31"[@@noalloc]externalunsafe_set_int31:'acarray8->int->int->unit="caml_extunixba_set_h31"[@@noalloc]externalunsafe_set_int32:'acarray8->int->int32->unit="caml_extunixba_set_h32"[@@noalloc]externalunsafe_set_uint63:'acarray8->int->int->unit="caml_extunixba_set_h63"[@@noalloc]externalunsafe_set_int63:'acarray8->int->int->unit="caml_extunixba_set_h63"[@@noalloc]externalunsafe_set_int64:'acarray8->int->int64->unit="caml_extunixba_set_h64"[@@noalloc](** [set_X buf off v] same as [unsafe_set_X] but with bounds checking. *)letset_uint8bufoffv=ifoff<0||off>=Bigarray.Array1.dimbufthenraise(Invalid_argument"index out of bounds");unsafe_set_uint8bufoffvletset_int8bufoffv=ifoff<0||off>=Bigarray.Array1.dimbufthenraise(Invalid_argument"index out of bounds");unsafe_set_int8bufoffvletset_uint16bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-2thenraise(Invalid_argument"index out of bounds");unsafe_set_uint16bufoffvletset_int16bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-2thenraise(Invalid_argument"index out of bounds");unsafe_set_int16bufoffvletset_uint31bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_set_uint31bufoffvletset_int31bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_set_int31bufoffvletset_int32bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-4thenraise(Invalid_argument"index out of bounds");unsafe_set_int32bufoffvletset_uint63bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_set_uint63bufoffvletset_int63bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_set_int63bufoffvletset_int64bufoffv=ifoff<0||off>Bigarray.Array1.dimbuf-8thenraise(Invalid_argument"index out of bounds");unsafe_set_int64bufoffvend(* module HostEndian *)(** [unsafe_get_substr buf off len] extracts the substring from buffer
[buf] starting at offset [off] and length [len]. Bounds checking
is not performed. Use with caution and only when the program logic
guarantees that the access is within bounds.*)externalunsafe_get_substr:'acarray8->int->int->string="caml_extunixba_get_substr"(** [get_substr buf off len] same as [unsafe_get_substr] but with
bounds checking. *)letget_substrbufofflen=ifoff<0||len<0||off>Bigarray.Array1.dimbuf-lenthenraise(Invalid_argument"index out of bounds");unsafe_get_substrbufofflen(** [unsafe_set_substr buf off str] stores the string in buffer [buf]
starting at offset [off]. Bounds checking is not performed. Use
with caution and only when the program logic guarantees that the
access is within bounds.*)externalunsafe_set_substr:'acarray8->int->string->unit="caml_extunixba_set_substr"(** [set_substr buf off str] same as [unsafe_set_substr] but with
bounds checking. *)letset_substrbufoffstr=ifoff<0||off>Bigarray.Array1.dimbuf-String.lengthstrthenraise(Invalid_argument"index out of bounds");unsafe_set_substrbufoffstr[%%haveVMSPLICE(**
{2 splice}
@author Pierre Chambart <pierre.chambart@ocamlpro.com>
*)(** I/O vector. Used to send multiple data using a single system call *)type'aiov={iov_buf:'acarray8;iov_off:int;iov_len:int;}(** [vmsplice fd iovs flags] sends the data described by [iovs] to the pipe [fd]
@return the number of bytes transferred to the pipe. *)externalvmsplice:Unix.file_descr->'aiovarray->splice_flaglist->int="caml_extunixba_vmsplice"]end(* module BA *)[%%haveWAIT4(**
{2 wait4}
@author Filipe Marques <filipe.s.marques@tecnico.ulisboa.pt>
*)(** Resource usage statistics.
This type represents resource utilization metrics for a process.
Only relevant resource usage fields are included. *)typerusage={ru_utime:float;(** User CPU time in seconds *)ru_stime:float;(** System CPU time in seconds *)ru_maxrss:int64;(** Maximum resident size in kilobytes *)}(** [wait4 flags pid] waits for a child process to change state.
It returns a tuple [(pid, status, usage)], where:
- [pid] is the process ID of the child.
- [status] is the process exit status.
- [usage] contains resource usage statistics of the terminated process.
@param flags A list of wait options (e.g., [Unix.WNOHANG] to return immediately if no child has exited).
@param pid The process ID of the child to wait for, or [-1] to wait for any child process.
@return A tuple [(pid, status, usage)], where:
- [pid] is the terminated child's process ID.
- [status] is the exit status of the child process.
- [usage] contains CPU and memory usage statistics.
@raise Unix.Unix_error if the system call fails.
*)externalwait4:Unix.wait_flaglist->int->int*Unix.process_status*rusage="caml_extunix_wait4"](* NB Should be after all 'external' definitions *)(** {2 Meta} *)[%%show_me_the_money[@@@ocaml.doc{|
[have name]
@return indication whether function [name] is available
- [Some true] if available
- [Some false] if not available
- [None] if not known
e.g. [have "eventfd"]|}]](* vim: ft=ocaml
*)