map.c 283 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317
  1. /*
  2. * This file was automatically generated by create-native-map from ../mcs/class/lib/net_4_x/Mono.Posix.dll.
  3. *
  4. * DO NOT MODIFY.
  5. */
  6. #ifdef HAVE_CONFIG_H
  7. #include <config.h>
  8. #endif /* ndef HAVE_CONFIG_H */
  9. #include <stdlib.h>
  10. #include <string.h>
  11. /*
  12. * Implementation Macros
  13. */
  14. #ifndef _GNU_SOURCE
  15. #define _GNU_SOURCE
  16. #endif /* ndef _GNU_SOURCE */
  17. #ifndef _XOPEN_SOURCE
  18. #define _XOPEN_SOURCE
  19. #endif /* ndef _XOPEN_SOURCE */
  20. /*
  21. * Implementation Includes
  22. */
  23. #include <sys/types.h>
  24. #include <sys/stat.h>
  25. #ifdef HAVE_NETINET_IN_H
  26. #include <netinet/in.h>
  27. #endif /* ndef HAVE_NETINET_IN_H */
  28. #ifdef HAVE_SYS_TIME_H
  29. #include <sys/time.h>
  30. #endif /* ndef HAVE_SYS_TIME_H */
  31. #ifdef HAVE_SYS_POLL_H
  32. #include <sys/poll.h>
  33. #endif /* ndef HAVE_SYS_POLL_H */
  34. #ifdef HAVE_SYS_WAIT_H
  35. #include <sys/wait.h>
  36. #endif /* ndef HAVE_SYS_WAIT_H */
  37. #ifdef HAVE_SYS_STATVFS_H
  38. #include <sys/statvfs.h>
  39. #endif /* ndef HAVE_SYS_STATVFS_H */
  40. #ifdef HAVE_SYS_XATTR_H
  41. #include <sys/xattr.h>
  42. #endif /* ndef HAVE_SYS_XATTR_H */
  43. #ifdef HAVE_SYS_MMAN_H
  44. #include <sys/mman.h>
  45. #endif /* ndef HAVE_SYS_MMAN_H */
  46. #ifdef HAVE_SYS_SOCKET_H
  47. #include <sys/socket.h>
  48. #endif /* ndef HAVE_SYS_SOCKET_H */
  49. #ifdef HAVE_SYS_UIO_H
  50. #include <sys/uio.h>
  51. #endif /* ndef HAVE_SYS_UIO_H */
  52. #ifdef HAVE_UNISTD_H
  53. #include <unistd.h>
  54. #endif /* ndef HAVE_UNISTD_H */
  55. #include <fcntl.h>
  56. #include <signal.h>
  57. #ifdef HAVE_POLL_H
  58. #include <poll.h>
  59. #endif /* ndef HAVE_POLL_H */
  60. #ifdef HAVE_GRP_H
  61. #include <grp.h>
  62. #endif /* ndef HAVE_GRP_H */
  63. #include <errno.h>
  64. #ifdef HAVE_SYSLOG_H
  65. #include <syslog.h>
  66. #endif /* ndef HAVE_SYSLOG_H */
  67. #ifdef HAVE_DIRENT_H
  68. #include <dirent.h>
  69. #endif /* ndef HAVE_DIRENT_H */
  70. #ifdef HAVE_UTIME_H
  71. #include <utime.h>
  72. #endif /* ndef HAVE_UTIME_H */
  73. #include <time.h>
  74. #include "mph.h"
  75. #include "map.h"
  76. #include <errno.h> /* errno, EOVERFLOW */
  77. #include <glib.h> /* g* types, g_assert_not_reached() */
  78. #if defined (G_MININT8)
  79. #define CNM_MININT8 G_MININT8
  80. #else
  81. #define CNM_MININT8 (-128)
  82. #endif
  83. #if defined (G_MAXINT8)
  84. #define CNM_MAXINT8 G_MAXINT8
  85. #else
  86. #define CNM_MAXINT8 (127)
  87. #endif
  88. #if defined (G_MAXUINT8)
  89. #define CNM_MAXUINT8 G_MAXUINT8
  90. #else
  91. #define CNM_MAXUINT8 (255)
  92. #endif
  93. #if defined (G_MININT16)
  94. #define CNM_MININT16 G_MININT16
  95. #else
  96. #define CNM_MININT16 (-32768)
  97. #endif
  98. #if defined (G_MAXINT16)
  99. #define CNM_MAXINT16 G_MAXINT16
  100. #else
  101. #define CNM_MAXINT16 (32767)
  102. #endif
  103. #if defined (G_MAXUINT16)
  104. #define CNM_MAXUINT16 G_MAXUINT16
  105. #else
  106. #define CNM_MAXUINT16 (65535)
  107. #endif
  108. #if defined (G_MININT32)
  109. #define CNM_MININT32 G_MININT32
  110. #else
  111. #define CNM_MININT32 (-2147483648)
  112. #endif
  113. #if defined (G_MAXINT32)
  114. #define CNM_MAXINT32 G_MAXINT32
  115. #else
  116. #define CNM_MAXINT32 (2147483647)
  117. #endif
  118. #if defined (G_MAXUINT32)
  119. #define CNM_MAXUINT32 G_MAXUINT32
  120. #else
  121. #define CNM_MAXUINT32 (4294967295U)
  122. #endif
  123. #if defined (G_MININT64)
  124. #define CNM_MININT64 G_MININT64
  125. #else
  126. #define CNM_MININT64 (-9223372036854775808LL)
  127. #endif
  128. #if defined (G_MAXINT64)
  129. #define CNM_MAXINT64 G_MAXINT64
  130. #else
  131. #define CNM_MAXINT64 (9223372036854775807LL)
  132. #endif
  133. #if defined (G_MAXUINT64)
  134. #define CNM_MAXUINT64 G_MAXUINT64
  135. #else
  136. #define CNM_MAXUINT64 (18446744073709551615ULL)
  137. #endif
  138. /* returns TRUE if @type is an unsigned type */
  139. #define _cnm_integral_type_is_unsigned(type) \
  140. (sizeof(type) == sizeof(gint8) \
  141. ? (((type)-1) > CNM_MAXINT8) \
  142. : sizeof(type) == sizeof(gint16) \
  143. ? (((type)-1) > CNM_MAXINT16) \
  144. : sizeof(type) == sizeof(gint32) \
  145. ? (((type)-1) > CNM_MAXINT32) \
  146. : sizeof(type) == sizeof(gint64) \
  147. ? (((type)-1) > CNM_MAXINT64) \
  148. : (g_assert_not_reached (), 0))
  149. /* returns the minimum value of @type as a gint64 */
  150. #define _cnm_integral_type_min(type) \
  151. (_cnm_integral_type_is_unsigned (type) \
  152. ? 0 \
  153. : sizeof(type) == sizeof(gint8) \
  154. ? CNM_MININT8 \
  155. : sizeof(type) == sizeof(gint16) \
  156. ? CNM_MININT16 \
  157. : sizeof(type) == sizeof(gint32) \
  158. ? CNM_MININT32 \
  159. : sizeof(type) == sizeof(gint64) \
  160. ? CNM_MININT64 \
  161. : (g_assert_not_reached (), 0))
  162. /* returns the maximum value of @type as a guint64 */
  163. #define _cnm_integral_type_max(type) \
  164. (_cnm_integral_type_is_unsigned (type) \
  165. ? sizeof(type) == sizeof(gint8) \
  166. ? CNM_MAXUINT8 \
  167. : sizeof(type) == sizeof(gint16) \
  168. ? CNM_MAXUINT16 \
  169. : sizeof(type) == sizeof(gint32) \
  170. ? CNM_MAXUINT32 \
  171. : sizeof(type) == sizeof(gint64) \
  172. ? CNM_MAXUINT64 \
  173. : (g_assert_not_reached (), 0) \
  174. : sizeof(type) == sizeof(gint8) \
  175. ? CNM_MAXINT8 \
  176. : sizeof(type) == sizeof(gint16) \
  177. ? CNM_MAXINT16 \
  178. : sizeof(type) == sizeof(gint32) \
  179. ? CNM_MAXINT32 \
  180. : sizeof(type) == sizeof(gint64) \
  181. ? CNM_MAXINT64 \
  182. : (g_assert_not_reached (), 0))
  183. #ifdef _CNM_DUMP
  184. #define _cnm_dump(to_t,from) \
  185. printf ("# %s -> %s: uns=%i; min=%llx; max=%llx; value=%llx; lt=%i; l0=%i; gt=%i; e=%i\n", \
  186. #from, #to_t, \
  187. (int) _cnm_integral_type_is_unsigned (to_t), \
  188. (gint64) (_cnm_integral_type_min (to_t)), \
  189. (gint64) (_cnm_integral_type_max (to_t)), \
  190. (gint64) (from), \
  191. (((gint64) _cnm_integral_type_min (to_t)) <= (gint64) from), \
  192. (from < 0), \
  193. (((guint64) from) <= (guint64) _cnm_integral_type_max (to_t)), \
  194. !((int) _cnm_integral_type_is_unsigned (to_t) \
  195. ? ((0 <= from) && \
  196. ((guint64) from <= (guint64) _cnm_integral_type_max (to_t))) \
  197. : ((gint64) _cnm_integral_type_min(to_t) <= (gint64) from && \
  198. (guint64) from <= (guint64) _cnm_integral_type_max (to_t))) \
  199. )
  200. #else /* ndef _CNM_DUMP */
  201. #define _cnm_dump(to_t, from) do {} while (0)
  202. #endif /* def _CNM_DUMP */
  203. #ifdef DEBUG
  204. #define _cnm_return_val_if_overflow(to_t,from,val) G_STMT_START { \
  205. int uns = _cnm_integral_type_is_unsigned (to_t); \
  206. gint64 min = (gint64) _cnm_integral_type_min (to_t); \
  207. guint64 max = (guint64) _cnm_integral_type_max (to_t); \
  208. gint64 sf = (gint64) from; \
  209. guint64 uf = (guint64) from; \
  210. if (!(uns ? ((0 <= from) && (uf <= max)) \
  211. : (min <= sf && (from < 0 || uf <= max)))) { \
  212. _cnm_dump(to_t, from); \
  213. errno = EOVERFLOW; \
  214. return (val); \
  215. } \
  216. } G_STMT_END
  217. #else /* !def DEBUG */
  218. /* don't do any overflow checking */
  219. #define _cnm_return_val_if_overflow(to_t,from,val) G_STMT_START { \
  220. } G_STMT_END
  221. #endif /* def DEBUG */
  222. int Mono_Posix_FromAccessModes (int x, int *r)
  223. {
  224. *r = 0;
  225. if ((x & Mono_Posix_AccessModes_F_OK) == Mono_Posix_AccessModes_F_OK)
  226. #ifdef F_OK
  227. *r |= F_OK;
  228. #else /* def F_OK */
  229. {errno = EINVAL; return -1;}
  230. #endif /* ndef F_OK */
  231. if ((x & Mono_Posix_AccessModes_R_OK) == Mono_Posix_AccessModes_R_OK)
  232. #ifdef R_OK
  233. *r |= R_OK;
  234. #else /* def R_OK */
  235. {errno = EINVAL; return -1;}
  236. #endif /* ndef R_OK */
  237. if ((x & Mono_Posix_AccessModes_W_OK) == Mono_Posix_AccessModes_W_OK)
  238. #ifdef W_OK
  239. *r |= W_OK;
  240. #else /* def W_OK */
  241. {errno = EINVAL; return -1;}
  242. #endif /* ndef W_OK */
  243. if ((x & Mono_Posix_AccessModes_X_OK) == Mono_Posix_AccessModes_X_OK)
  244. #ifdef X_OK
  245. *r |= X_OK;
  246. #else /* def X_OK */
  247. {errno = EINVAL; return -1;}
  248. #endif /* ndef X_OK */
  249. if (x == 0)
  250. return 0;
  251. return 0;
  252. }
  253. int Mono_Posix_ToAccessModes (int x, int *r)
  254. {
  255. *r = 0;
  256. if (x == 0)
  257. return 0;
  258. #ifdef F_OK
  259. if ((x & F_OK) == F_OK)
  260. *r |= Mono_Posix_AccessModes_F_OK;
  261. #endif /* ndef F_OK */
  262. #ifdef R_OK
  263. if ((x & R_OK) == R_OK)
  264. *r |= Mono_Posix_AccessModes_R_OK;
  265. #endif /* ndef R_OK */
  266. #ifdef W_OK
  267. if ((x & W_OK) == W_OK)
  268. *r |= Mono_Posix_AccessModes_W_OK;
  269. #endif /* ndef W_OK */
  270. #ifdef X_OK
  271. if ((x & X_OK) == X_OK)
  272. *r |= Mono_Posix_AccessModes_X_OK;
  273. #endif /* ndef X_OK */
  274. return 0;
  275. }
  276. int Mono_Posix_FromAtFlags (int x, int *r)
  277. {
  278. *r = 0;
  279. if ((x & Mono_Posix_AtFlags_AT_EMPTY_PATH) == Mono_Posix_AtFlags_AT_EMPTY_PATH)
  280. #ifdef AT_EMPTY_PATH
  281. *r |= AT_EMPTY_PATH;
  282. #else /* def AT_EMPTY_PATH */
  283. {errno = EINVAL; return -1;}
  284. #endif /* ndef AT_EMPTY_PATH */
  285. if ((x & Mono_Posix_AtFlags_AT_NO_AUTOMOUNT) == Mono_Posix_AtFlags_AT_NO_AUTOMOUNT)
  286. #ifdef AT_NO_AUTOMOUNT
  287. *r |= AT_NO_AUTOMOUNT;
  288. #else /* def AT_NO_AUTOMOUNT */
  289. {errno = EINVAL; return -1;}
  290. #endif /* ndef AT_NO_AUTOMOUNT */
  291. if ((x & Mono_Posix_AtFlags_AT_REMOVEDIR) == Mono_Posix_AtFlags_AT_REMOVEDIR)
  292. #ifdef AT_REMOVEDIR
  293. *r |= AT_REMOVEDIR;
  294. #else /* def AT_REMOVEDIR */
  295. {errno = EINVAL; return -1;}
  296. #endif /* ndef AT_REMOVEDIR */
  297. if ((x & Mono_Posix_AtFlags_AT_SYMLINK_FOLLOW) == Mono_Posix_AtFlags_AT_SYMLINK_FOLLOW)
  298. #ifdef AT_SYMLINK_FOLLOW
  299. *r |= AT_SYMLINK_FOLLOW;
  300. #else /* def AT_SYMLINK_FOLLOW */
  301. {errno = EINVAL; return -1;}
  302. #endif /* ndef AT_SYMLINK_FOLLOW */
  303. if ((x & Mono_Posix_AtFlags_AT_SYMLINK_NOFOLLOW) == Mono_Posix_AtFlags_AT_SYMLINK_NOFOLLOW)
  304. #ifdef AT_SYMLINK_NOFOLLOW
  305. *r |= AT_SYMLINK_NOFOLLOW;
  306. #else /* def AT_SYMLINK_NOFOLLOW */
  307. {errno = EINVAL; return -1;}
  308. #endif /* ndef AT_SYMLINK_NOFOLLOW */
  309. if (x == 0)
  310. return 0;
  311. return 0;
  312. }
  313. int Mono_Posix_ToAtFlags (int x, int *r)
  314. {
  315. *r = 0;
  316. if (x == 0)
  317. return 0;
  318. #ifdef AT_EMPTY_PATH
  319. if ((x & AT_EMPTY_PATH) == AT_EMPTY_PATH)
  320. *r |= Mono_Posix_AtFlags_AT_EMPTY_PATH;
  321. #endif /* ndef AT_EMPTY_PATH */
  322. #ifdef AT_NO_AUTOMOUNT
  323. if ((x & AT_NO_AUTOMOUNT) == AT_NO_AUTOMOUNT)
  324. *r |= Mono_Posix_AtFlags_AT_NO_AUTOMOUNT;
  325. #endif /* ndef AT_NO_AUTOMOUNT */
  326. #ifdef AT_REMOVEDIR
  327. if ((x & AT_REMOVEDIR) == AT_REMOVEDIR)
  328. *r |= Mono_Posix_AtFlags_AT_REMOVEDIR;
  329. #endif /* ndef AT_REMOVEDIR */
  330. #ifdef AT_SYMLINK_FOLLOW
  331. if ((x & AT_SYMLINK_FOLLOW) == AT_SYMLINK_FOLLOW)
  332. *r |= Mono_Posix_AtFlags_AT_SYMLINK_FOLLOW;
  333. #endif /* ndef AT_SYMLINK_FOLLOW */
  334. #ifdef AT_SYMLINK_NOFOLLOW
  335. if ((x & AT_SYMLINK_NOFOLLOW) == AT_SYMLINK_NOFOLLOW)
  336. *r |= Mono_Posix_AtFlags_AT_SYMLINK_NOFOLLOW;
  337. #endif /* ndef AT_SYMLINK_NOFOLLOW */
  338. return 0;
  339. }
  340. #ifdef HAVE_STRUCT_CMSGHDR
  341. int
  342. Mono_Posix_FromCmsghdr (struct Mono_Posix_Cmsghdr *from, struct cmsghdr *to)
  343. {
  344. _cnm_return_val_if_overflow (gint64, from->cmsg_len, -1);
  345. memset (to, 0, sizeof(*to));
  346. to->cmsg_len = from->cmsg_len;
  347. if (Mono_Posix_FromUnixSocketProtocol (from->cmsg_level, &to->cmsg_level) != 0) {
  348. return -1;
  349. }
  350. if (Mono_Posix_FromUnixSocketControlMessage (from->cmsg_type, &to->cmsg_type) != 0) {
  351. return -1;
  352. }
  353. return 0;
  354. }
  355. #endif /* ndef HAVE_STRUCT_CMSGHDR */
  356. #ifdef HAVE_STRUCT_CMSGHDR
  357. int
  358. Mono_Posix_ToCmsghdr (struct cmsghdr *from, struct Mono_Posix_Cmsghdr *to)
  359. {
  360. _cnm_return_val_if_overflow (gint64, from->cmsg_len, -1);
  361. memset (to, 0, sizeof(*to));
  362. to->cmsg_len = from->cmsg_len;
  363. if (Mono_Posix_ToUnixSocketProtocol (from->cmsg_level, &to->cmsg_level) != 0) {
  364. return -1;
  365. }
  366. if (Mono_Posix_ToUnixSocketControlMessage (from->cmsg_type, &to->cmsg_type) != 0) {
  367. return -1;
  368. }
  369. return 0;
  370. }
  371. #endif /* ndef HAVE_STRUCT_CMSGHDR */
  372. int Mono_Posix_FromConfstrName (int x, int *r)
  373. {
  374. *r = 0;
  375. if (x == Mono_Posix_ConfstrName__CS_GNU_LIBC_VERSION)
  376. #ifdef _CS_GNU_LIBC_VERSION
  377. {*r = _CS_GNU_LIBC_VERSION; return 0;}
  378. #else /* def _CS_GNU_LIBC_VERSION */
  379. {errno = EINVAL; return -1;}
  380. #endif /* ndef _CS_GNU_LIBC_VERSION */
  381. if (x == Mono_Posix_ConfstrName__CS_GNU_LIBPTHREAD_VERSION)
  382. #ifdef _CS_GNU_LIBPTHREAD_VERSION
  383. {*r = _CS_GNU_LIBPTHREAD_VERSION; return 0;}
  384. #else /* def _CS_GNU_LIBPTHREAD_VERSION */
  385. {errno = EINVAL; return -1;}
  386. #endif /* ndef _CS_GNU_LIBPTHREAD_VERSION */
  387. if (x == Mono_Posix_ConfstrName__CS_LFS64_CFLAGS)
  388. #ifdef _CS_LFS64_CFLAGS
  389. {*r = _CS_LFS64_CFLAGS; return 0;}
  390. #else /* def _CS_LFS64_CFLAGS */
  391. {errno = EINVAL; return -1;}
  392. #endif /* ndef _CS_LFS64_CFLAGS */
  393. if (x == Mono_Posix_ConfstrName__CS_LFS64_LDFLAGS)
  394. #ifdef _CS_LFS64_LDFLAGS
  395. {*r = _CS_LFS64_LDFLAGS; return 0;}
  396. #else /* def _CS_LFS64_LDFLAGS */
  397. {errno = EINVAL; return -1;}
  398. #endif /* ndef _CS_LFS64_LDFLAGS */
  399. if (x == Mono_Posix_ConfstrName__CS_LFS64_LIBS)
  400. #ifdef _CS_LFS64_LIBS
  401. {*r = _CS_LFS64_LIBS; return 0;}
  402. #else /* def _CS_LFS64_LIBS */
  403. {errno = EINVAL; return -1;}
  404. #endif /* ndef _CS_LFS64_LIBS */
  405. if (x == Mono_Posix_ConfstrName__CS_LFS64_LINTFLAGS)
  406. #ifdef _CS_LFS64_LINTFLAGS
  407. {*r = _CS_LFS64_LINTFLAGS; return 0;}
  408. #else /* def _CS_LFS64_LINTFLAGS */
  409. {errno = EINVAL; return -1;}
  410. #endif /* ndef _CS_LFS64_LINTFLAGS */
  411. if (x == Mono_Posix_ConfstrName__CS_LFS_CFLAGS)
  412. #ifdef _CS_LFS_CFLAGS
  413. {*r = _CS_LFS_CFLAGS; return 0;}
  414. #else /* def _CS_LFS_CFLAGS */
  415. {errno = EINVAL; return -1;}
  416. #endif /* ndef _CS_LFS_CFLAGS */
  417. if (x == Mono_Posix_ConfstrName__CS_LFS_LDFLAGS)
  418. #ifdef _CS_LFS_LDFLAGS
  419. {*r = _CS_LFS_LDFLAGS; return 0;}
  420. #else /* def _CS_LFS_LDFLAGS */
  421. {errno = EINVAL; return -1;}
  422. #endif /* ndef _CS_LFS_LDFLAGS */
  423. if (x == Mono_Posix_ConfstrName__CS_LFS_LIBS)
  424. #ifdef _CS_LFS_LIBS
  425. {*r = _CS_LFS_LIBS; return 0;}
  426. #else /* def _CS_LFS_LIBS */
  427. {errno = EINVAL; return -1;}
  428. #endif /* ndef _CS_LFS_LIBS */
  429. if (x == Mono_Posix_ConfstrName__CS_LFS_LINTFLAGS)
  430. #ifdef _CS_LFS_LINTFLAGS
  431. {*r = _CS_LFS_LINTFLAGS; return 0;}
  432. #else /* def _CS_LFS_LINTFLAGS */
  433. {errno = EINVAL; return -1;}
  434. #endif /* ndef _CS_LFS_LINTFLAGS */
  435. if (x == Mono_Posix_ConfstrName__CS_PATH)
  436. #ifdef _CS_PATH
  437. {*r = _CS_PATH; return 0;}
  438. #else /* def _CS_PATH */
  439. {errno = EINVAL; return -1;}
  440. #endif /* ndef _CS_PATH */
  441. if (x == Mono_Posix_ConfstrName__CS_POSIX_V6_ILP32_OFF32_CFLAGS)
  442. #ifdef _CS_POSIX_V6_ILP32_OFF32_CFLAGS
  443. {*r = _CS_POSIX_V6_ILP32_OFF32_CFLAGS; return 0;}
  444. #else /* def _CS_POSIX_V6_ILP32_OFF32_CFLAGS */
  445. {errno = EINVAL; return -1;}
  446. #endif /* ndef _CS_POSIX_V6_ILP32_OFF32_CFLAGS */
  447. if (x == Mono_Posix_ConfstrName__CS_POSIX_V6_ILP32_OFF32_LDFLAGS)
  448. #ifdef _CS_POSIX_V6_ILP32_OFF32_LDFLAGS
  449. {*r = _CS_POSIX_V6_ILP32_OFF32_LDFLAGS; return 0;}
  450. #else /* def _CS_POSIX_V6_ILP32_OFF32_LDFLAGS */
  451. {errno = EINVAL; return -1;}
  452. #endif /* ndef _CS_POSIX_V6_ILP32_OFF32_LDFLAGS */
  453. if (x == Mono_Posix_ConfstrName__CS_POSIX_V6_ILP32_OFF32_LIBS)
  454. #ifdef _CS_POSIX_V6_ILP32_OFF32_LIBS
  455. {*r = _CS_POSIX_V6_ILP32_OFF32_LIBS; return 0;}
  456. #else /* def _CS_POSIX_V6_ILP32_OFF32_LIBS */
  457. {errno = EINVAL; return -1;}
  458. #endif /* ndef _CS_POSIX_V6_ILP32_OFF32_LIBS */
  459. if (x == Mono_Posix_ConfstrName__CS_POSIX_V6_ILP32_OFF32_LINTFLAGS)
  460. #ifdef _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS
  461. {*r = _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS; return 0;}
  462. #else /* def _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS */
  463. {errno = EINVAL; return -1;}
  464. #endif /* ndef _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS */
  465. if (x == Mono_Posix_ConfstrName__CS_POSIX_V6_ILP32_OFFBIG_CFLAGS)
  466. #ifdef _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS
  467. {*r = _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS; return 0;}
  468. #else /* def _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS */
  469. {errno = EINVAL; return -1;}
  470. #endif /* ndef _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS */
  471. if (x == Mono_Posix_ConfstrName__CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS)
  472. #ifdef _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS
  473. {*r = _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS; return 0;}
  474. #else /* def _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS */
  475. {errno = EINVAL; return -1;}
  476. #endif /* ndef _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS */
  477. if (x == Mono_Posix_ConfstrName__CS_POSIX_V6_ILP32_OFFBIG_LIBS)
  478. #ifdef _CS_POSIX_V6_ILP32_OFFBIG_LIBS
  479. {*r = _CS_POSIX_V6_ILP32_OFFBIG_LIBS; return 0;}
  480. #else /* def _CS_POSIX_V6_ILP32_OFFBIG_LIBS */
  481. {errno = EINVAL; return -1;}
  482. #endif /* ndef _CS_POSIX_V6_ILP32_OFFBIG_LIBS */
  483. if (x == Mono_Posix_ConfstrName__CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS)
  484. #ifdef _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS
  485. {*r = _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS; return 0;}
  486. #else /* def _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS */
  487. {errno = EINVAL; return -1;}
  488. #endif /* ndef _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS */
  489. if (x == Mono_Posix_ConfstrName__CS_POSIX_V6_LP64_OFF64_CFLAGS)
  490. #ifdef _CS_POSIX_V6_LP64_OFF64_CFLAGS
  491. {*r = _CS_POSIX_V6_LP64_OFF64_CFLAGS; return 0;}
  492. #else /* def _CS_POSIX_V6_LP64_OFF64_CFLAGS */
  493. {errno = EINVAL; return -1;}
  494. #endif /* ndef _CS_POSIX_V6_LP64_OFF64_CFLAGS */
  495. if (x == Mono_Posix_ConfstrName__CS_POSIX_V6_LP64_OFF64_LDFLAGS)
  496. #ifdef _CS_POSIX_V6_LP64_OFF64_LDFLAGS
  497. {*r = _CS_POSIX_V6_LP64_OFF64_LDFLAGS; return 0;}
  498. #else /* def _CS_POSIX_V6_LP64_OFF64_LDFLAGS */
  499. {errno = EINVAL; return -1;}
  500. #endif /* ndef _CS_POSIX_V6_LP64_OFF64_LDFLAGS */
  501. if (x == Mono_Posix_ConfstrName__CS_POSIX_V6_LP64_OFF64_LIBS)
  502. #ifdef _CS_POSIX_V6_LP64_OFF64_LIBS
  503. {*r = _CS_POSIX_V6_LP64_OFF64_LIBS; return 0;}
  504. #else /* def _CS_POSIX_V6_LP64_OFF64_LIBS */
  505. {errno = EINVAL; return -1;}
  506. #endif /* ndef _CS_POSIX_V6_LP64_OFF64_LIBS */
  507. if (x == Mono_Posix_ConfstrName__CS_POSIX_V6_LP64_OFF64_LINTFLAGS)
  508. #ifdef _CS_POSIX_V6_LP64_OFF64_LINTFLAGS
  509. {*r = _CS_POSIX_V6_LP64_OFF64_LINTFLAGS; return 0;}
  510. #else /* def _CS_POSIX_V6_LP64_OFF64_LINTFLAGS */
  511. {errno = EINVAL; return -1;}
  512. #endif /* ndef _CS_POSIX_V6_LP64_OFF64_LINTFLAGS */
  513. if (x == Mono_Posix_ConfstrName__CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS)
  514. #ifdef _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS
  515. {*r = _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS; return 0;}
  516. #else /* def _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS */
  517. {errno = EINVAL; return -1;}
  518. #endif /* ndef _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS */
  519. if (x == Mono_Posix_ConfstrName__CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS)
  520. #ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
  521. {*r = _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS; return 0;}
  522. #else /* def _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS */
  523. {errno = EINVAL; return -1;}
  524. #endif /* ndef _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS */
  525. if (x == Mono_Posix_ConfstrName__CS_POSIX_V6_LPBIG_OFFBIG_LIBS)
  526. #ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LIBS
  527. {*r = _CS_POSIX_V6_LPBIG_OFFBIG_LIBS; return 0;}
  528. #else /* def _CS_POSIX_V6_LPBIG_OFFBIG_LIBS */
  529. {errno = EINVAL; return -1;}
  530. #endif /* ndef _CS_POSIX_V6_LPBIG_OFFBIG_LIBS */
  531. if (x == Mono_Posix_ConfstrName__CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS)
  532. #ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS
  533. {*r = _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS; return 0;}
  534. #else /* def _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS */
  535. {errno = EINVAL; return -1;}
  536. #endif /* ndef _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS */
  537. if (x == Mono_Posix_ConfstrName__CS_V6_WIDTH_RESTRICTED_ENVS)
  538. #ifdef _CS_V6_WIDTH_RESTRICTED_ENVS
  539. {*r = _CS_V6_WIDTH_RESTRICTED_ENVS; return 0;}
  540. #else /* def _CS_V6_WIDTH_RESTRICTED_ENVS */
  541. {errno = EINVAL; return -1;}
  542. #endif /* ndef _CS_V6_WIDTH_RESTRICTED_ENVS */
  543. if (x == Mono_Posix_ConfstrName__CS_XBS5_ILP32_OFF32_CFLAGS)
  544. #ifdef _CS_XBS5_ILP32_OFF32_CFLAGS
  545. {*r = _CS_XBS5_ILP32_OFF32_CFLAGS; return 0;}
  546. #else /* def _CS_XBS5_ILP32_OFF32_CFLAGS */
  547. {errno = EINVAL; return -1;}
  548. #endif /* ndef _CS_XBS5_ILP32_OFF32_CFLAGS */
  549. if (x == Mono_Posix_ConfstrName__CS_XBS5_ILP32_OFF32_LDFLAGS)
  550. #ifdef _CS_XBS5_ILP32_OFF32_LDFLAGS
  551. {*r = _CS_XBS5_ILP32_OFF32_LDFLAGS; return 0;}
  552. #else /* def _CS_XBS5_ILP32_OFF32_LDFLAGS */
  553. {errno = EINVAL; return -1;}
  554. #endif /* ndef _CS_XBS5_ILP32_OFF32_LDFLAGS */
  555. if (x == Mono_Posix_ConfstrName__CS_XBS5_ILP32_OFF32_LIBS)
  556. #ifdef _CS_XBS5_ILP32_OFF32_LIBS
  557. {*r = _CS_XBS5_ILP32_OFF32_LIBS; return 0;}
  558. #else /* def _CS_XBS5_ILP32_OFF32_LIBS */
  559. {errno = EINVAL; return -1;}
  560. #endif /* ndef _CS_XBS5_ILP32_OFF32_LIBS */
  561. if (x == Mono_Posix_ConfstrName__CS_XBS5_ILP32_OFF32_LINTFLAGS)
  562. #ifdef _CS_XBS5_ILP32_OFF32_LINTFLAGS
  563. {*r = _CS_XBS5_ILP32_OFF32_LINTFLAGS; return 0;}
  564. #else /* def _CS_XBS5_ILP32_OFF32_LINTFLAGS */
  565. {errno = EINVAL; return -1;}
  566. #endif /* ndef _CS_XBS5_ILP32_OFF32_LINTFLAGS */
  567. if (x == Mono_Posix_ConfstrName__CS_XBS5_ILP32_OFFBIG_CFLAGS)
  568. #ifdef _CS_XBS5_ILP32_OFFBIG_CFLAGS
  569. {*r = _CS_XBS5_ILP32_OFFBIG_CFLAGS; return 0;}
  570. #else /* def _CS_XBS5_ILP32_OFFBIG_CFLAGS */
  571. {errno = EINVAL; return -1;}
  572. #endif /* ndef _CS_XBS5_ILP32_OFFBIG_CFLAGS */
  573. if (x == Mono_Posix_ConfstrName__CS_XBS5_ILP32_OFFBIG_LDFLAGS)
  574. #ifdef _CS_XBS5_ILP32_OFFBIG_LDFLAGS
  575. {*r = _CS_XBS5_ILP32_OFFBIG_LDFLAGS; return 0;}
  576. #else /* def _CS_XBS5_ILP32_OFFBIG_LDFLAGS */
  577. {errno = EINVAL; return -1;}
  578. #endif /* ndef _CS_XBS5_ILP32_OFFBIG_LDFLAGS */
  579. if (x == Mono_Posix_ConfstrName__CS_XBS5_ILP32_OFFBIG_LIBS)
  580. #ifdef _CS_XBS5_ILP32_OFFBIG_LIBS
  581. {*r = _CS_XBS5_ILP32_OFFBIG_LIBS; return 0;}
  582. #else /* def _CS_XBS5_ILP32_OFFBIG_LIBS */
  583. {errno = EINVAL; return -1;}
  584. #endif /* ndef _CS_XBS5_ILP32_OFFBIG_LIBS */
  585. if (x == Mono_Posix_ConfstrName__CS_XBS5_ILP32_OFFBIG_LINTFLAGS)
  586. #ifdef _CS_XBS5_ILP32_OFFBIG_LINTFLAGS
  587. {*r = _CS_XBS5_ILP32_OFFBIG_LINTFLAGS; return 0;}
  588. #else /* def _CS_XBS5_ILP32_OFFBIG_LINTFLAGS */
  589. {errno = EINVAL; return -1;}
  590. #endif /* ndef _CS_XBS5_ILP32_OFFBIG_LINTFLAGS */
  591. if (x == Mono_Posix_ConfstrName__CS_XBS5_LP64_OFF64_CFLAGS)
  592. #ifdef _CS_XBS5_LP64_OFF64_CFLAGS
  593. {*r = _CS_XBS5_LP64_OFF64_CFLAGS; return 0;}
  594. #else /* def _CS_XBS5_LP64_OFF64_CFLAGS */
  595. {errno = EINVAL; return -1;}
  596. #endif /* ndef _CS_XBS5_LP64_OFF64_CFLAGS */
  597. if (x == Mono_Posix_ConfstrName__CS_XBS5_LP64_OFF64_LDFLAGS)
  598. #ifdef _CS_XBS5_LP64_OFF64_LDFLAGS
  599. {*r = _CS_XBS5_LP64_OFF64_LDFLAGS; return 0;}
  600. #else /* def _CS_XBS5_LP64_OFF64_LDFLAGS */
  601. {errno = EINVAL; return -1;}
  602. #endif /* ndef _CS_XBS5_LP64_OFF64_LDFLAGS */
  603. if (x == Mono_Posix_ConfstrName__CS_XBS5_LP64_OFF64_LIBS)
  604. #ifdef _CS_XBS5_LP64_OFF64_LIBS
  605. {*r = _CS_XBS5_LP64_OFF64_LIBS; return 0;}
  606. #else /* def _CS_XBS5_LP64_OFF64_LIBS */
  607. {errno = EINVAL; return -1;}
  608. #endif /* ndef _CS_XBS5_LP64_OFF64_LIBS */
  609. if (x == Mono_Posix_ConfstrName__CS_XBS5_LP64_OFF64_LINTFLAGS)
  610. #ifdef _CS_XBS5_LP64_OFF64_LINTFLAGS
  611. {*r = _CS_XBS5_LP64_OFF64_LINTFLAGS; return 0;}
  612. #else /* def _CS_XBS5_LP64_OFF64_LINTFLAGS */
  613. {errno = EINVAL; return -1;}
  614. #endif /* ndef _CS_XBS5_LP64_OFF64_LINTFLAGS */
  615. if (x == Mono_Posix_ConfstrName__CS_XBS5_LPBIG_OFFBIG_CFLAGS)
  616. #ifdef _CS_XBS5_LPBIG_OFFBIG_CFLAGS
  617. {*r = _CS_XBS5_LPBIG_OFFBIG_CFLAGS; return 0;}
  618. #else /* def _CS_XBS5_LPBIG_OFFBIG_CFLAGS */
  619. {errno = EINVAL; return -1;}
  620. #endif /* ndef _CS_XBS5_LPBIG_OFFBIG_CFLAGS */
  621. if (x == Mono_Posix_ConfstrName__CS_XBS5_LPBIG_OFFBIG_LDFLAGS)
  622. #ifdef _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
  623. {*r = _CS_XBS5_LPBIG_OFFBIG_LDFLAGS; return 0;}
  624. #else /* def _CS_XBS5_LPBIG_OFFBIG_LDFLAGS */
  625. {errno = EINVAL; return -1;}
  626. #endif /* ndef _CS_XBS5_LPBIG_OFFBIG_LDFLAGS */
  627. if (x == Mono_Posix_ConfstrName__CS_XBS5_LPBIG_OFFBIG_LIBS)
  628. #ifdef _CS_XBS5_LPBIG_OFFBIG_LIBS
  629. {*r = _CS_XBS5_LPBIG_OFFBIG_LIBS; return 0;}
  630. #else /* def _CS_XBS5_LPBIG_OFFBIG_LIBS */
  631. {errno = EINVAL; return -1;}
  632. #endif /* ndef _CS_XBS5_LPBIG_OFFBIG_LIBS */
  633. if (x == Mono_Posix_ConfstrName__CS_XBS5_LPBIG_OFFBIG_LINTFLAGS)
  634. #ifdef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
  635. {*r = _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS; return 0;}
  636. #else /* def _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS */
  637. {errno = EINVAL; return -1;}
  638. #endif /* ndef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS */
  639. if (x == 0)
  640. return 0;
  641. errno = EINVAL; return -1;
  642. }
  643. int Mono_Posix_ToConfstrName (int x, int *r)
  644. {
  645. *r = 0;
  646. if (x == 0)
  647. return 0;
  648. #ifdef _CS_GNU_LIBC_VERSION
  649. if (x == _CS_GNU_LIBC_VERSION)
  650. {*r = Mono_Posix_ConfstrName__CS_GNU_LIBC_VERSION; return 0;}
  651. #endif /* ndef _CS_GNU_LIBC_VERSION */
  652. #ifdef _CS_GNU_LIBPTHREAD_VERSION
  653. if (x == _CS_GNU_LIBPTHREAD_VERSION)
  654. {*r = Mono_Posix_ConfstrName__CS_GNU_LIBPTHREAD_VERSION; return 0;}
  655. #endif /* ndef _CS_GNU_LIBPTHREAD_VERSION */
  656. #ifdef _CS_LFS64_CFLAGS
  657. if (x == _CS_LFS64_CFLAGS)
  658. {*r = Mono_Posix_ConfstrName__CS_LFS64_CFLAGS; return 0;}
  659. #endif /* ndef _CS_LFS64_CFLAGS */
  660. #ifdef _CS_LFS64_LDFLAGS
  661. if (x == _CS_LFS64_LDFLAGS)
  662. {*r = Mono_Posix_ConfstrName__CS_LFS64_LDFLAGS; return 0;}
  663. #endif /* ndef _CS_LFS64_LDFLAGS */
  664. #ifdef _CS_LFS64_LIBS
  665. if (x == _CS_LFS64_LIBS)
  666. {*r = Mono_Posix_ConfstrName__CS_LFS64_LIBS; return 0;}
  667. #endif /* ndef _CS_LFS64_LIBS */
  668. #ifdef _CS_LFS64_LINTFLAGS
  669. if (x == _CS_LFS64_LINTFLAGS)
  670. {*r = Mono_Posix_ConfstrName__CS_LFS64_LINTFLAGS; return 0;}
  671. #endif /* ndef _CS_LFS64_LINTFLAGS */
  672. #ifdef _CS_LFS_CFLAGS
  673. if (x == _CS_LFS_CFLAGS)
  674. {*r = Mono_Posix_ConfstrName__CS_LFS_CFLAGS; return 0;}
  675. #endif /* ndef _CS_LFS_CFLAGS */
  676. #ifdef _CS_LFS_LDFLAGS
  677. if (x == _CS_LFS_LDFLAGS)
  678. {*r = Mono_Posix_ConfstrName__CS_LFS_LDFLAGS; return 0;}
  679. #endif /* ndef _CS_LFS_LDFLAGS */
  680. #ifdef _CS_LFS_LIBS
  681. if (x == _CS_LFS_LIBS)
  682. {*r = Mono_Posix_ConfstrName__CS_LFS_LIBS; return 0;}
  683. #endif /* ndef _CS_LFS_LIBS */
  684. #ifdef _CS_LFS_LINTFLAGS
  685. if (x == _CS_LFS_LINTFLAGS)
  686. {*r = Mono_Posix_ConfstrName__CS_LFS_LINTFLAGS; return 0;}
  687. #endif /* ndef _CS_LFS_LINTFLAGS */
  688. #ifdef _CS_PATH
  689. if (x == _CS_PATH)
  690. {*r = Mono_Posix_ConfstrName__CS_PATH; return 0;}
  691. #endif /* ndef _CS_PATH */
  692. #ifdef _CS_POSIX_V6_ILP32_OFF32_CFLAGS
  693. if (x == _CS_POSIX_V6_ILP32_OFF32_CFLAGS)
  694. {*r = Mono_Posix_ConfstrName__CS_POSIX_V6_ILP32_OFF32_CFLAGS; return 0;}
  695. #endif /* ndef _CS_POSIX_V6_ILP32_OFF32_CFLAGS */
  696. #ifdef _CS_POSIX_V6_ILP32_OFF32_LDFLAGS
  697. if (x == _CS_POSIX_V6_ILP32_OFF32_LDFLAGS)
  698. {*r = Mono_Posix_ConfstrName__CS_POSIX_V6_ILP32_OFF32_LDFLAGS; return 0;}
  699. #endif /* ndef _CS_POSIX_V6_ILP32_OFF32_LDFLAGS */
  700. #ifdef _CS_POSIX_V6_ILP32_OFF32_LIBS
  701. if (x == _CS_POSIX_V6_ILP32_OFF32_LIBS)
  702. {*r = Mono_Posix_ConfstrName__CS_POSIX_V6_ILP32_OFF32_LIBS; return 0;}
  703. #endif /* ndef _CS_POSIX_V6_ILP32_OFF32_LIBS */
  704. #ifdef _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS
  705. if (x == _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS)
  706. {*r = Mono_Posix_ConfstrName__CS_POSIX_V6_ILP32_OFF32_LINTFLAGS; return 0;}
  707. #endif /* ndef _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS */
  708. #ifdef _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS
  709. if (x == _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS)
  710. {*r = Mono_Posix_ConfstrName__CS_POSIX_V6_ILP32_OFFBIG_CFLAGS; return 0;}
  711. #endif /* ndef _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS */
  712. #ifdef _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS
  713. if (x == _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS)
  714. {*r = Mono_Posix_ConfstrName__CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS; return 0;}
  715. #endif /* ndef _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS */
  716. #ifdef _CS_POSIX_V6_ILP32_OFFBIG_LIBS
  717. if (x == _CS_POSIX_V6_ILP32_OFFBIG_LIBS)
  718. {*r = Mono_Posix_ConfstrName__CS_POSIX_V6_ILP32_OFFBIG_LIBS; return 0;}
  719. #endif /* ndef _CS_POSIX_V6_ILP32_OFFBIG_LIBS */
  720. #ifdef _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS
  721. if (x == _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS)
  722. {*r = Mono_Posix_ConfstrName__CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS; return 0;}
  723. #endif /* ndef _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS */
  724. #ifdef _CS_POSIX_V6_LP64_OFF64_CFLAGS
  725. if (x == _CS_POSIX_V6_LP64_OFF64_CFLAGS)
  726. {*r = Mono_Posix_ConfstrName__CS_POSIX_V6_LP64_OFF64_CFLAGS; return 0;}
  727. #endif /* ndef _CS_POSIX_V6_LP64_OFF64_CFLAGS */
  728. #ifdef _CS_POSIX_V6_LP64_OFF64_LDFLAGS
  729. if (x == _CS_POSIX_V6_LP64_OFF64_LDFLAGS)
  730. {*r = Mono_Posix_ConfstrName__CS_POSIX_V6_LP64_OFF64_LDFLAGS; return 0;}
  731. #endif /* ndef _CS_POSIX_V6_LP64_OFF64_LDFLAGS */
  732. #ifdef _CS_POSIX_V6_LP64_OFF64_LIBS
  733. if (x == _CS_POSIX_V6_LP64_OFF64_LIBS)
  734. {*r = Mono_Posix_ConfstrName__CS_POSIX_V6_LP64_OFF64_LIBS; return 0;}
  735. #endif /* ndef _CS_POSIX_V6_LP64_OFF64_LIBS */
  736. #ifdef _CS_POSIX_V6_LP64_OFF64_LINTFLAGS
  737. if (x == _CS_POSIX_V6_LP64_OFF64_LINTFLAGS)
  738. {*r = Mono_Posix_ConfstrName__CS_POSIX_V6_LP64_OFF64_LINTFLAGS; return 0;}
  739. #endif /* ndef _CS_POSIX_V6_LP64_OFF64_LINTFLAGS */
  740. #ifdef _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS
  741. if (x == _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS)
  742. {*r = Mono_Posix_ConfstrName__CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS; return 0;}
  743. #endif /* ndef _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS */
  744. #ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
  745. if (x == _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS)
  746. {*r = Mono_Posix_ConfstrName__CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS; return 0;}
  747. #endif /* ndef _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS */
  748. #ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LIBS
  749. if (x == _CS_POSIX_V6_LPBIG_OFFBIG_LIBS)
  750. {*r = Mono_Posix_ConfstrName__CS_POSIX_V6_LPBIG_OFFBIG_LIBS; return 0;}
  751. #endif /* ndef _CS_POSIX_V6_LPBIG_OFFBIG_LIBS */
  752. #ifdef _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS
  753. if (x == _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS)
  754. {*r = Mono_Posix_ConfstrName__CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS; return 0;}
  755. #endif /* ndef _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS */
  756. #ifdef _CS_V6_WIDTH_RESTRICTED_ENVS
  757. if (x == _CS_V6_WIDTH_RESTRICTED_ENVS)
  758. {*r = Mono_Posix_ConfstrName__CS_V6_WIDTH_RESTRICTED_ENVS; return 0;}
  759. #endif /* ndef _CS_V6_WIDTH_RESTRICTED_ENVS */
  760. #ifdef _CS_XBS5_ILP32_OFF32_CFLAGS
  761. if (x == _CS_XBS5_ILP32_OFF32_CFLAGS)
  762. {*r = Mono_Posix_ConfstrName__CS_XBS5_ILP32_OFF32_CFLAGS; return 0;}
  763. #endif /* ndef _CS_XBS5_ILP32_OFF32_CFLAGS */
  764. #ifdef _CS_XBS5_ILP32_OFF32_LDFLAGS
  765. if (x == _CS_XBS5_ILP32_OFF32_LDFLAGS)
  766. {*r = Mono_Posix_ConfstrName__CS_XBS5_ILP32_OFF32_LDFLAGS; return 0;}
  767. #endif /* ndef _CS_XBS5_ILP32_OFF32_LDFLAGS */
  768. #ifdef _CS_XBS5_ILP32_OFF32_LIBS
  769. if (x == _CS_XBS5_ILP32_OFF32_LIBS)
  770. {*r = Mono_Posix_ConfstrName__CS_XBS5_ILP32_OFF32_LIBS; return 0;}
  771. #endif /* ndef _CS_XBS5_ILP32_OFF32_LIBS */
  772. #ifdef _CS_XBS5_ILP32_OFF32_LINTFLAGS
  773. if (x == _CS_XBS5_ILP32_OFF32_LINTFLAGS)
  774. {*r = Mono_Posix_ConfstrName__CS_XBS5_ILP32_OFF32_LINTFLAGS; return 0;}
  775. #endif /* ndef _CS_XBS5_ILP32_OFF32_LINTFLAGS */
  776. #ifdef _CS_XBS5_ILP32_OFFBIG_CFLAGS
  777. if (x == _CS_XBS5_ILP32_OFFBIG_CFLAGS)
  778. {*r = Mono_Posix_ConfstrName__CS_XBS5_ILP32_OFFBIG_CFLAGS; return 0;}
  779. #endif /* ndef _CS_XBS5_ILP32_OFFBIG_CFLAGS */
  780. #ifdef _CS_XBS5_ILP32_OFFBIG_LDFLAGS
  781. if (x == _CS_XBS5_ILP32_OFFBIG_LDFLAGS)
  782. {*r = Mono_Posix_ConfstrName__CS_XBS5_ILP32_OFFBIG_LDFLAGS; return 0;}
  783. #endif /* ndef _CS_XBS5_ILP32_OFFBIG_LDFLAGS */
  784. #ifdef _CS_XBS5_ILP32_OFFBIG_LIBS
  785. if (x == _CS_XBS5_ILP32_OFFBIG_LIBS)
  786. {*r = Mono_Posix_ConfstrName__CS_XBS5_ILP32_OFFBIG_LIBS; return 0;}
  787. #endif /* ndef _CS_XBS5_ILP32_OFFBIG_LIBS */
  788. #ifdef _CS_XBS5_ILP32_OFFBIG_LINTFLAGS
  789. if (x == _CS_XBS5_ILP32_OFFBIG_LINTFLAGS)
  790. {*r = Mono_Posix_ConfstrName__CS_XBS5_ILP32_OFFBIG_LINTFLAGS; return 0;}
  791. #endif /* ndef _CS_XBS5_ILP32_OFFBIG_LINTFLAGS */
  792. #ifdef _CS_XBS5_LP64_OFF64_CFLAGS
  793. if (x == _CS_XBS5_LP64_OFF64_CFLAGS)
  794. {*r = Mono_Posix_ConfstrName__CS_XBS5_LP64_OFF64_CFLAGS; return 0;}
  795. #endif /* ndef _CS_XBS5_LP64_OFF64_CFLAGS */
  796. #ifdef _CS_XBS5_LP64_OFF64_LDFLAGS
  797. if (x == _CS_XBS5_LP64_OFF64_LDFLAGS)
  798. {*r = Mono_Posix_ConfstrName__CS_XBS5_LP64_OFF64_LDFLAGS; return 0;}
  799. #endif /* ndef _CS_XBS5_LP64_OFF64_LDFLAGS */
  800. #ifdef _CS_XBS5_LP64_OFF64_LIBS
  801. if (x == _CS_XBS5_LP64_OFF64_LIBS)
  802. {*r = Mono_Posix_ConfstrName__CS_XBS5_LP64_OFF64_LIBS; return 0;}
  803. #endif /* ndef _CS_XBS5_LP64_OFF64_LIBS */
  804. #ifdef _CS_XBS5_LP64_OFF64_LINTFLAGS
  805. if (x == _CS_XBS5_LP64_OFF64_LINTFLAGS)
  806. {*r = Mono_Posix_ConfstrName__CS_XBS5_LP64_OFF64_LINTFLAGS; return 0;}
  807. #endif /* ndef _CS_XBS5_LP64_OFF64_LINTFLAGS */
  808. #ifdef _CS_XBS5_LPBIG_OFFBIG_CFLAGS
  809. if (x == _CS_XBS5_LPBIG_OFFBIG_CFLAGS)
  810. {*r = Mono_Posix_ConfstrName__CS_XBS5_LPBIG_OFFBIG_CFLAGS; return 0;}
  811. #endif /* ndef _CS_XBS5_LPBIG_OFFBIG_CFLAGS */
  812. #ifdef _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
  813. if (x == _CS_XBS5_LPBIG_OFFBIG_LDFLAGS)
  814. {*r = Mono_Posix_ConfstrName__CS_XBS5_LPBIG_OFFBIG_LDFLAGS; return 0;}
  815. #endif /* ndef _CS_XBS5_LPBIG_OFFBIG_LDFLAGS */
  816. #ifdef _CS_XBS5_LPBIG_OFFBIG_LIBS
  817. if (x == _CS_XBS5_LPBIG_OFFBIG_LIBS)
  818. {*r = Mono_Posix_ConfstrName__CS_XBS5_LPBIG_OFFBIG_LIBS; return 0;}
  819. #endif /* ndef _CS_XBS5_LPBIG_OFFBIG_LIBS */
  820. #ifdef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
  821. if (x == _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS)
  822. {*r = Mono_Posix_ConfstrName__CS_XBS5_LPBIG_OFFBIG_LINTFLAGS; return 0;}
  823. #endif /* ndef _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS */
  824. errno = EINVAL; return -1;
  825. }
  826. int Mono_Posix_FromDirectoryNotifyFlags (int x, int *r)
  827. {
  828. *r = 0;
  829. if ((x & Mono_Posix_DirectoryNotifyFlags_DN_ACCESS) == Mono_Posix_DirectoryNotifyFlags_DN_ACCESS)
  830. #ifdef DN_ACCESS
  831. *r |= DN_ACCESS;
  832. #else /* def DN_ACCESS */
  833. {errno = EINVAL; return -1;}
  834. #endif /* ndef DN_ACCESS */
  835. if ((x & Mono_Posix_DirectoryNotifyFlags_DN_ATTRIB) == Mono_Posix_DirectoryNotifyFlags_DN_ATTRIB)
  836. #ifdef DN_ATTRIB
  837. *r |= DN_ATTRIB;
  838. #else /* def DN_ATTRIB */
  839. {errno = EINVAL; return -1;}
  840. #endif /* ndef DN_ATTRIB */
  841. if ((x & Mono_Posix_DirectoryNotifyFlags_DN_CREATE) == Mono_Posix_DirectoryNotifyFlags_DN_CREATE)
  842. #ifdef DN_CREATE
  843. *r |= DN_CREATE;
  844. #else /* def DN_CREATE */
  845. {errno = EINVAL; return -1;}
  846. #endif /* ndef DN_CREATE */
  847. if ((x & Mono_Posix_DirectoryNotifyFlags_DN_DELETE) == Mono_Posix_DirectoryNotifyFlags_DN_DELETE)
  848. #ifdef DN_DELETE
  849. *r |= DN_DELETE;
  850. #else /* def DN_DELETE */
  851. {errno = EINVAL; return -1;}
  852. #endif /* ndef DN_DELETE */
  853. if ((x & Mono_Posix_DirectoryNotifyFlags_DN_MODIFY) == Mono_Posix_DirectoryNotifyFlags_DN_MODIFY)
  854. #ifdef DN_MODIFY
  855. *r |= DN_MODIFY;
  856. #else /* def DN_MODIFY */
  857. {errno = EINVAL; return -1;}
  858. #endif /* ndef DN_MODIFY */
  859. if ((x & Mono_Posix_DirectoryNotifyFlags_DN_MULTISHOT) == Mono_Posix_DirectoryNotifyFlags_DN_MULTISHOT)
  860. #ifdef DN_MULTISHOT
  861. *r |= DN_MULTISHOT;
  862. #else /* def DN_MULTISHOT */
  863. {errno = EINVAL; return -1;}
  864. #endif /* ndef DN_MULTISHOT */
  865. if ((x & Mono_Posix_DirectoryNotifyFlags_DN_RENAME) == Mono_Posix_DirectoryNotifyFlags_DN_RENAME)
  866. #ifdef DN_RENAME
  867. *r |= DN_RENAME;
  868. #else /* def DN_RENAME */
  869. {errno = EINVAL; return -1;}
  870. #endif /* ndef DN_RENAME */
  871. if (x == 0)
  872. return 0;
  873. return 0;
  874. }
  875. int Mono_Posix_ToDirectoryNotifyFlags (int x, int *r)
  876. {
  877. *r = 0;
  878. if (x == 0)
  879. return 0;
  880. #ifdef DN_ACCESS
  881. if ((x & DN_ACCESS) == DN_ACCESS)
  882. *r |= Mono_Posix_DirectoryNotifyFlags_DN_ACCESS;
  883. #endif /* ndef DN_ACCESS */
  884. #ifdef DN_ATTRIB
  885. if ((x & DN_ATTRIB) == DN_ATTRIB)
  886. *r |= Mono_Posix_DirectoryNotifyFlags_DN_ATTRIB;
  887. #endif /* ndef DN_ATTRIB */
  888. #ifdef DN_CREATE
  889. if ((x & DN_CREATE) == DN_CREATE)
  890. *r |= Mono_Posix_DirectoryNotifyFlags_DN_CREATE;
  891. #endif /* ndef DN_CREATE */
  892. #ifdef DN_DELETE
  893. if ((x & DN_DELETE) == DN_DELETE)
  894. *r |= Mono_Posix_DirectoryNotifyFlags_DN_DELETE;
  895. #endif /* ndef DN_DELETE */
  896. #ifdef DN_MODIFY
  897. if ((x & DN_MODIFY) == DN_MODIFY)
  898. *r |= Mono_Posix_DirectoryNotifyFlags_DN_MODIFY;
  899. #endif /* ndef DN_MODIFY */
  900. #ifdef DN_MULTISHOT
  901. if ((x & DN_MULTISHOT) == DN_MULTISHOT)
  902. *r |= Mono_Posix_DirectoryNotifyFlags_DN_MULTISHOT;
  903. #endif /* ndef DN_MULTISHOT */
  904. #ifdef DN_RENAME
  905. if ((x & DN_RENAME) == DN_RENAME)
  906. *r |= Mono_Posix_DirectoryNotifyFlags_DN_RENAME;
  907. #endif /* ndef DN_RENAME */
  908. return 0;
  909. }
  910. int Mono_Posix_FromEpollEvents (unsigned int x, unsigned int *r)
  911. {
  912. *r = 0;
  913. if ((x & Mono_Posix_EpollEvents_EPOLLERR) == Mono_Posix_EpollEvents_EPOLLERR)
  914. #ifdef EPOLLERR
  915. *r |= EPOLLERR;
  916. #else /* def EPOLLERR */
  917. {errno = EINVAL; return -1;}
  918. #endif /* ndef EPOLLERR */
  919. if ((x & Mono_Posix_EpollEvents_EPOLLET) == Mono_Posix_EpollEvents_EPOLLET)
  920. #ifdef EPOLLET
  921. *r |= EPOLLET;
  922. #else /* def EPOLLET */
  923. {errno = EINVAL; return -1;}
  924. #endif /* ndef EPOLLET */
  925. if ((x & Mono_Posix_EpollEvents_EPOLLHUP) == Mono_Posix_EpollEvents_EPOLLHUP)
  926. #ifdef EPOLLHUP
  927. *r |= EPOLLHUP;
  928. #else /* def EPOLLHUP */
  929. {errno = EINVAL; return -1;}
  930. #endif /* ndef EPOLLHUP */
  931. if ((x & Mono_Posix_EpollEvents_EPOLLIN) == Mono_Posix_EpollEvents_EPOLLIN)
  932. #ifdef EPOLLIN
  933. *r |= EPOLLIN;
  934. #else /* def EPOLLIN */
  935. {errno = EINVAL; return -1;}
  936. #endif /* ndef EPOLLIN */
  937. if ((x & Mono_Posix_EpollEvents_EPOLLMSG) == Mono_Posix_EpollEvents_EPOLLMSG)
  938. #ifdef EPOLLMSG
  939. *r |= EPOLLMSG;
  940. #else /* def EPOLLMSG */
  941. {errno = EINVAL; return -1;}
  942. #endif /* ndef EPOLLMSG */
  943. if ((x & Mono_Posix_EpollEvents_EPOLLONESHOT) == Mono_Posix_EpollEvents_EPOLLONESHOT)
  944. #ifdef EPOLLONESHOT
  945. *r |= EPOLLONESHOT;
  946. #else /* def EPOLLONESHOT */
  947. {errno = EINVAL; return -1;}
  948. #endif /* ndef EPOLLONESHOT */
  949. if ((x & Mono_Posix_EpollEvents_EPOLLOUT) == Mono_Posix_EpollEvents_EPOLLOUT)
  950. #ifdef EPOLLOUT
  951. *r |= EPOLLOUT;
  952. #else /* def EPOLLOUT */
  953. {errno = EINVAL; return -1;}
  954. #endif /* ndef EPOLLOUT */
  955. if ((x & Mono_Posix_EpollEvents_EPOLLPRI) == Mono_Posix_EpollEvents_EPOLLPRI)
  956. #ifdef EPOLLPRI
  957. *r |= EPOLLPRI;
  958. #else /* def EPOLLPRI */
  959. {errno = EINVAL; return -1;}
  960. #endif /* ndef EPOLLPRI */
  961. if ((x & Mono_Posix_EpollEvents_EPOLLRDBAND) == Mono_Posix_EpollEvents_EPOLLRDBAND)
  962. #ifdef EPOLLRDBAND
  963. *r |= EPOLLRDBAND;
  964. #else /* def EPOLLRDBAND */
  965. {errno = EINVAL; return -1;}
  966. #endif /* ndef EPOLLRDBAND */
  967. if ((x & Mono_Posix_EpollEvents_EPOLLRDHUP) == Mono_Posix_EpollEvents_EPOLLRDHUP)
  968. #ifdef EPOLLRDHUP
  969. *r |= EPOLLRDHUP;
  970. #else /* def EPOLLRDHUP */
  971. {errno = EINVAL; return -1;}
  972. #endif /* ndef EPOLLRDHUP */
  973. if ((x & Mono_Posix_EpollEvents_EPOLLRDNORM) == Mono_Posix_EpollEvents_EPOLLRDNORM)
  974. #ifdef EPOLLRDNORM
  975. *r |= EPOLLRDNORM;
  976. #else /* def EPOLLRDNORM */
  977. {errno = EINVAL; return -1;}
  978. #endif /* ndef EPOLLRDNORM */
  979. if ((x & Mono_Posix_EpollEvents_EPOLLWRBAND) == Mono_Posix_EpollEvents_EPOLLWRBAND)
  980. #ifdef EPOLLWRBAND
  981. *r |= EPOLLWRBAND;
  982. #else /* def EPOLLWRBAND */
  983. {errno = EINVAL; return -1;}
  984. #endif /* ndef EPOLLWRBAND */
  985. if ((x & Mono_Posix_EpollEvents_EPOLLWRNORM) == Mono_Posix_EpollEvents_EPOLLWRNORM)
  986. #ifdef EPOLLWRNORM
  987. *r |= EPOLLWRNORM;
  988. #else /* def EPOLLWRNORM */
  989. {errno = EINVAL; return -1;}
  990. #endif /* ndef EPOLLWRNORM */
  991. if (x == 0)
  992. return 0;
  993. return 0;
  994. }
  995. int Mono_Posix_ToEpollEvents (unsigned int x, unsigned int *r)
  996. {
  997. *r = 0;
  998. if (x == 0)
  999. return 0;
  1000. #ifdef EPOLLERR
  1001. if ((x & EPOLLERR) == EPOLLERR)
  1002. *r |= Mono_Posix_EpollEvents_EPOLLERR;
  1003. #endif /* ndef EPOLLERR */
  1004. #ifdef EPOLLET
  1005. if ((x & EPOLLET) == EPOLLET)
  1006. *r |= Mono_Posix_EpollEvents_EPOLLET;
  1007. #endif /* ndef EPOLLET */
  1008. #ifdef EPOLLHUP
  1009. if ((x & EPOLLHUP) == EPOLLHUP)
  1010. *r |= Mono_Posix_EpollEvents_EPOLLHUP;
  1011. #endif /* ndef EPOLLHUP */
  1012. #ifdef EPOLLIN
  1013. if ((x & EPOLLIN) == EPOLLIN)
  1014. *r |= Mono_Posix_EpollEvents_EPOLLIN;
  1015. #endif /* ndef EPOLLIN */
  1016. #ifdef EPOLLMSG
  1017. if ((x & EPOLLMSG) == EPOLLMSG)
  1018. *r |= Mono_Posix_EpollEvents_EPOLLMSG;
  1019. #endif /* ndef EPOLLMSG */
  1020. #ifdef EPOLLONESHOT
  1021. if ((x & EPOLLONESHOT) == EPOLLONESHOT)
  1022. *r |= Mono_Posix_EpollEvents_EPOLLONESHOT;
  1023. #endif /* ndef EPOLLONESHOT */
  1024. #ifdef EPOLLOUT
  1025. if ((x & EPOLLOUT) == EPOLLOUT)
  1026. *r |= Mono_Posix_EpollEvents_EPOLLOUT;
  1027. #endif /* ndef EPOLLOUT */
  1028. #ifdef EPOLLPRI
  1029. if ((x & EPOLLPRI) == EPOLLPRI)
  1030. *r |= Mono_Posix_EpollEvents_EPOLLPRI;
  1031. #endif /* ndef EPOLLPRI */
  1032. #ifdef EPOLLRDBAND
  1033. if ((x & EPOLLRDBAND) == EPOLLRDBAND)
  1034. *r |= Mono_Posix_EpollEvents_EPOLLRDBAND;
  1035. #endif /* ndef EPOLLRDBAND */
  1036. #ifdef EPOLLRDHUP
  1037. if ((x & EPOLLRDHUP) == EPOLLRDHUP)
  1038. *r |= Mono_Posix_EpollEvents_EPOLLRDHUP;
  1039. #endif /* ndef EPOLLRDHUP */
  1040. #ifdef EPOLLRDNORM
  1041. if ((x & EPOLLRDNORM) == EPOLLRDNORM)
  1042. *r |= Mono_Posix_EpollEvents_EPOLLRDNORM;
  1043. #endif /* ndef EPOLLRDNORM */
  1044. #ifdef EPOLLWRBAND
  1045. if ((x & EPOLLWRBAND) == EPOLLWRBAND)
  1046. *r |= Mono_Posix_EpollEvents_EPOLLWRBAND;
  1047. #endif /* ndef EPOLLWRBAND */
  1048. #ifdef EPOLLWRNORM
  1049. if ((x & EPOLLWRNORM) == EPOLLWRNORM)
  1050. *r |= Mono_Posix_EpollEvents_EPOLLWRNORM;
  1051. #endif /* ndef EPOLLWRNORM */
  1052. return 0;
  1053. }
  1054. int Mono_Posix_FromEpollFlags (int x, int *r)
  1055. {
  1056. *r = 0;
  1057. if ((x & Mono_Posix_EpollFlags_EPOLL_CLOEXEC) == Mono_Posix_EpollFlags_EPOLL_CLOEXEC)
  1058. #ifdef EPOLL_CLOEXEC
  1059. *r |= EPOLL_CLOEXEC;
  1060. #else /* def EPOLL_CLOEXEC */
  1061. {errno = EINVAL; return -1;}
  1062. #endif /* ndef EPOLL_CLOEXEC */
  1063. if ((x & Mono_Posix_EpollFlags_EPOLL_NONBLOCK) == Mono_Posix_EpollFlags_EPOLL_NONBLOCK)
  1064. #ifdef EPOLL_NONBLOCK
  1065. *r |= EPOLL_NONBLOCK;
  1066. #else /* def EPOLL_NONBLOCK */
  1067. {errno = EINVAL; return -1;}
  1068. #endif /* ndef EPOLL_NONBLOCK */
  1069. if (x == 0)
  1070. return 0;
  1071. return 0;
  1072. }
  1073. int Mono_Posix_ToEpollFlags (int x, int *r)
  1074. {
  1075. *r = 0;
  1076. if (x == 0)
  1077. return 0;
  1078. #ifdef EPOLL_CLOEXEC
  1079. if ((x & EPOLL_CLOEXEC) == EPOLL_CLOEXEC)
  1080. *r |= Mono_Posix_EpollFlags_EPOLL_CLOEXEC;
  1081. #endif /* ndef EPOLL_CLOEXEC */
  1082. #ifdef EPOLL_NONBLOCK
  1083. if ((x & EPOLL_NONBLOCK) == EPOLL_NONBLOCK)
  1084. *r |= Mono_Posix_EpollFlags_EPOLL_NONBLOCK;
  1085. #endif /* ndef EPOLL_NONBLOCK */
  1086. return 0;
  1087. }
  1088. int Mono_Posix_FromErrno (int x, int *r)
  1089. {
  1090. *r = 0;
  1091. if (x == Mono_Posix_Errno_E2BIG)
  1092. #ifdef E2BIG
  1093. {*r = E2BIG; return 0;}
  1094. #else /* def E2BIG */
  1095. {errno = EINVAL; return -1;}
  1096. #endif /* ndef E2BIG */
  1097. if (x == Mono_Posix_Errno_EACCES)
  1098. #ifdef EACCES
  1099. {*r = EACCES; return 0;}
  1100. #else /* def EACCES */
  1101. {errno = EINVAL; return -1;}
  1102. #endif /* ndef EACCES */
  1103. if (x == Mono_Posix_Errno_EADDRINUSE)
  1104. #ifdef EADDRINUSE
  1105. {*r = EADDRINUSE; return 0;}
  1106. #else /* def EADDRINUSE */
  1107. {errno = EINVAL; return -1;}
  1108. #endif /* ndef EADDRINUSE */
  1109. if (x == Mono_Posix_Errno_EADDRNOTAVAIL)
  1110. #ifdef EADDRNOTAVAIL
  1111. {*r = EADDRNOTAVAIL; return 0;}
  1112. #else /* def EADDRNOTAVAIL */
  1113. {errno = EINVAL; return -1;}
  1114. #endif /* ndef EADDRNOTAVAIL */
  1115. if (x == Mono_Posix_Errno_EADV)
  1116. #ifdef EADV
  1117. {*r = EADV; return 0;}
  1118. #else /* def EADV */
  1119. {errno = EINVAL; return -1;}
  1120. #endif /* ndef EADV */
  1121. if (x == Mono_Posix_Errno_EAFNOSUPPORT)
  1122. #ifdef EAFNOSUPPORT
  1123. {*r = EAFNOSUPPORT; return 0;}
  1124. #else /* def EAFNOSUPPORT */
  1125. {errno = EINVAL; return -1;}
  1126. #endif /* ndef EAFNOSUPPORT */
  1127. if (x == Mono_Posix_Errno_EAGAIN)
  1128. #ifdef EAGAIN
  1129. {*r = EAGAIN; return 0;}
  1130. #else /* def EAGAIN */
  1131. {errno = EINVAL; return -1;}
  1132. #endif /* ndef EAGAIN */
  1133. if (x == Mono_Posix_Errno_EALREADY)
  1134. #ifdef EALREADY
  1135. {*r = EALREADY; return 0;}
  1136. #else /* def EALREADY */
  1137. {errno = EINVAL; return -1;}
  1138. #endif /* ndef EALREADY */
  1139. if (x == Mono_Posix_Errno_EAUTH)
  1140. #ifdef EAUTH
  1141. {*r = EAUTH; return 0;}
  1142. #else /* def EAUTH */
  1143. {errno = EINVAL; return -1;}
  1144. #endif /* ndef EAUTH */
  1145. if (x == Mono_Posix_Errno_EBADARCH)
  1146. #ifdef EBADARCH
  1147. {*r = EBADARCH; return 0;}
  1148. #else /* def EBADARCH */
  1149. {errno = EINVAL; return -1;}
  1150. #endif /* ndef EBADARCH */
  1151. if (x == Mono_Posix_Errno_EBADE)
  1152. #ifdef EBADE
  1153. {*r = EBADE; return 0;}
  1154. #else /* def EBADE */
  1155. {errno = EINVAL; return -1;}
  1156. #endif /* ndef EBADE */
  1157. if (x == Mono_Posix_Errno_EBADEXEC)
  1158. #ifdef EBADEXEC
  1159. {*r = EBADEXEC; return 0;}
  1160. #else /* def EBADEXEC */
  1161. {errno = EINVAL; return -1;}
  1162. #endif /* ndef EBADEXEC */
  1163. if (x == Mono_Posix_Errno_EBADF)
  1164. #ifdef EBADF
  1165. {*r = EBADF; return 0;}
  1166. #else /* def EBADF */
  1167. {errno = EINVAL; return -1;}
  1168. #endif /* ndef EBADF */
  1169. if (x == Mono_Posix_Errno_EBADFD)
  1170. #ifdef EBADFD
  1171. {*r = EBADFD; return 0;}
  1172. #else /* def EBADFD */
  1173. {errno = EINVAL; return -1;}
  1174. #endif /* ndef EBADFD */
  1175. if (x == Mono_Posix_Errno_EBADMACHO)
  1176. #ifdef EBADMACHO
  1177. {*r = EBADMACHO; return 0;}
  1178. #else /* def EBADMACHO */
  1179. {errno = EINVAL; return -1;}
  1180. #endif /* ndef EBADMACHO */
  1181. if (x == Mono_Posix_Errno_EBADMSG)
  1182. #ifdef EBADMSG
  1183. {*r = EBADMSG; return 0;}
  1184. #else /* def EBADMSG */
  1185. {errno = EINVAL; return -1;}
  1186. #endif /* ndef EBADMSG */
  1187. if (x == Mono_Posix_Errno_EBADR)
  1188. #ifdef EBADR
  1189. {*r = EBADR; return 0;}
  1190. #else /* def EBADR */
  1191. {errno = EINVAL; return -1;}
  1192. #endif /* ndef EBADR */
  1193. if (x == Mono_Posix_Errno_EBADRPC)
  1194. #ifdef EBADRPC
  1195. {*r = EBADRPC; return 0;}
  1196. #else /* def EBADRPC */
  1197. {errno = EINVAL; return -1;}
  1198. #endif /* ndef EBADRPC */
  1199. if (x == Mono_Posix_Errno_EBADRQC)
  1200. #ifdef EBADRQC
  1201. {*r = EBADRQC; return 0;}
  1202. #else /* def EBADRQC */
  1203. {errno = EINVAL; return -1;}
  1204. #endif /* ndef EBADRQC */
  1205. if (x == Mono_Posix_Errno_EBADSLT)
  1206. #ifdef EBADSLT
  1207. {*r = EBADSLT; return 0;}
  1208. #else /* def EBADSLT */
  1209. {errno = EINVAL; return -1;}
  1210. #endif /* ndef EBADSLT */
  1211. if (x == Mono_Posix_Errno_EBFONT)
  1212. #ifdef EBFONT
  1213. {*r = EBFONT; return 0;}
  1214. #else /* def EBFONT */
  1215. {errno = EINVAL; return -1;}
  1216. #endif /* ndef EBFONT */
  1217. if (x == Mono_Posix_Errno_EBUSY)
  1218. #ifdef EBUSY
  1219. {*r = EBUSY; return 0;}
  1220. #else /* def EBUSY */
  1221. {errno = EINVAL; return -1;}
  1222. #endif /* ndef EBUSY */
  1223. if (x == Mono_Posix_Errno_ECANCELED)
  1224. #ifdef ECANCELED
  1225. {*r = ECANCELED; return 0;}
  1226. #else /* def ECANCELED */
  1227. {errno = EINVAL; return -1;}
  1228. #endif /* ndef ECANCELED */
  1229. if (x == Mono_Posix_Errno_ECHILD)
  1230. #ifdef ECHILD
  1231. {*r = ECHILD; return 0;}
  1232. #else /* def ECHILD */
  1233. {errno = EINVAL; return -1;}
  1234. #endif /* ndef ECHILD */
  1235. if (x == Mono_Posix_Errno_ECHRNG)
  1236. #ifdef ECHRNG
  1237. {*r = ECHRNG; return 0;}
  1238. #else /* def ECHRNG */
  1239. {errno = EINVAL; return -1;}
  1240. #endif /* ndef ECHRNG */
  1241. if (x == Mono_Posix_Errno_ECOMM)
  1242. #ifdef ECOMM
  1243. {*r = ECOMM; return 0;}
  1244. #else /* def ECOMM */
  1245. {errno = EINVAL; return -1;}
  1246. #endif /* ndef ECOMM */
  1247. if (x == Mono_Posix_Errno_ECONNABORTED)
  1248. #ifdef ECONNABORTED
  1249. {*r = ECONNABORTED; return 0;}
  1250. #else /* def ECONNABORTED */
  1251. {errno = EINVAL; return -1;}
  1252. #endif /* ndef ECONNABORTED */
  1253. if (x == Mono_Posix_Errno_ECONNREFUSED)
  1254. #ifdef ECONNREFUSED
  1255. {*r = ECONNREFUSED; return 0;}
  1256. #else /* def ECONNREFUSED */
  1257. {errno = EINVAL; return -1;}
  1258. #endif /* ndef ECONNREFUSED */
  1259. if (x == Mono_Posix_Errno_ECONNRESET)
  1260. #ifdef ECONNRESET
  1261. {*r = ECONNRESET; return 0;}
  1262. #else /* def ECONNRESET */
  1263. {errno = EINVAL; return -1;}
  1264. #endif /* ndef ECONNRESET */
  1265. if (x == Mono_Posix_Errno_EDEADLK)
  1266. #ifdef EDEADLK
  1267. {*r = EDEADLK; return 0;}
  1268. #else /* def EDEADLK */
  1269. {errno = EINVAL; return -1;}
  1270. #endif /* ndef EDEADLK */
  1271. if (x == Mono_Posix_Errno_EDEADLOCK)
  1272. #ifdef EDEADLOCK
  1273. {*r = EDEADLOCK; return 0;}
  1274. #else /* def EDEADLOCK */
  1275. {errno = EINVAL; return -1;}
  1276. #endif /* ndef EDEADLOCK */
  1277. if (x == Mono_Posix_Errno_EDESTADDRREQ)
  1278. #ifdef EDESTADDRREQ
  1279. {*r = EDESTADDRREQ; return 0;}
  1280. #else /* def EDESTADDRREQ */
  1281. {errno = EINVAL; return -1;}
  1282. #endif /* ndef EDESTADDRREQ */
  1283. if (x == Mono_Posix_Errno_EDEVERR)
  1284. #ifdef EDEVERR
  1285. {*r = EDEVERR; return 0;}
  1286. #else /* def EDEVERR */
  1287. {errno = EINVAL; return -1;}
  1288. #endif /* ndef EDEVERR */
  1289. if (x == Mono_Posix_Errno_EDOM)
  1290. #ifdef EDOM
  1291. {*r = EDOM; return 0;}
  1292. #else /* def EDOM */
  1293. {errno = EINVAL; return -1;}
  1294. #endif /* ndef EDOM */
  1295. if (x == Mono_Posix_Errno_EDOTDOT)
  1296. #ifdef EDOTDOT
  1297. {*r = EDOTDOT; return 0;}
  1298. #else /* def EDOTDOT */
  1299. {errno = EINVAL; return -1;}
  1300. #endif /* ndef EDOTDOT */
  1301. if (x == Mono_Posix_Errno_EDQUOT)
  1302. #ifdef EDQUOT
  1303. {*r = EDQUOT; return 0;}
  1304. #else /* def EDQUOT */
  1305. {errno = EINVAL; return -1;}
  1306. #endif /* ndef EDQUOT */
  1307. if (x == Mono_Posix_Errno_EEXIST)
  1308. #ifdef EEXIST
  1309. {*r = EEXIST; return 0;}
  1310. #else /* def EEXIST */
  1311. {errno = EINVAL; return -1;}
  1312. #endif /* ndef EEXIST */
  1313. if (x == Mono_Posix_Errno_EFAULT)
  1314. #ifdef EFAULT
  1315. {*r = EFAULT; return 0;}
  1316. #else /* def EFAULT */
  1317. {errno = EINVAL; return -1;}
  1318. #endif /* ndef EFAULT */
  1319. if (x == Mono_Posix_Errno_EFBIG)
  1320. #ifdef EFBIG
  1321. {*r = EFBIG; return 0;}
  1322. #else /* def EFBIG */
  1323. {errno = EINVAL; return -1;}
  1324. #endif /* ndef EFBIG */
  1325. if (x == Mono_Posix_Errno_EFTYPE)
  1326. #ifdef EFTYPE
  1327. {*r = EFTYPE; return 0;}
  1328. #else /* def EFTYPE */
  1329. {errno = EINVAL; return -1;}
  1330. #endif /* ndef EFTYPE */
  1331. if (x == Mono_Posix_Errno_EHOSTDOWN)
  1332. #ifdef EHOSTDOWN
  1333. {*r = EHOSTDOWN; return 0;}
  1334. #else /* def EHOSTDOWN */
  1335. {errno = EINVAL; return -1;}
  1336. #endif /* ndef EHOSTDOWN */
  1337. if (x == Mono_Posix_Errno_EHOSTUNREACH)
  1338. #ifdef EHOSTUNREACH
  1339. {*r = EHOSTUNREACH; return 0;}
  1340. #else /* def EHOSTUNREACH */
  1341. {errno = EINVAL; return -1;}
  1342. #endif /* ndef EHOSTUNREACH */
  1343. if (x == Mono_Posix_Errno_EIDRM)
  1344. #ifdef EIDRM
  1345. {*r = EIDRM; return 0;}
  1346. #else /* def EIDRM */
  1347. {errno = EINVAL; return -1;}
  1348. #endif /* ndef EIDRM */
  1349. if (x == Mono_Posix_Errno_EILSEQ)
  1350. #ifdef EILSEQ
  1351. {*r = EILSEQ; return 0;}
  1352. #else /* def EILSEQ */
  1353. {errno = EINVAL; return -1;}
  1354. #endif /* ndef EILSEQ */
  1355. if (x == Mono_Posix_Errno_EINPROGRESS)
  1356. #ifdef EINPROGRESS
  1357. {*r = EINPROGRESS; return 0;}
  1358. #else /* def EINPROGRESS */
  1359. {errno = EINVAL; return -1;}
  1360. #endif /* ndef EINPROGRESS */
  1361. if (x == Mono_Posix_Errno_EINTR)
  1362. #ifdef EINTR
  1363. {*r = EINTR; return 0;}
  1364. #else /* def EINTR */
  1365. {errno = EINVAL; return -1;}
  1366. #endif /* ndef EINTR */
  1367. if (x == Mono_Posix_Errno_EINVAL)
  1368. #ifdef EINVAL
  1369. {*r = EINVAL; return 0;}
  1370. #else /* def EINVAL */
  1371. {errno = EINVAL; return -1;}
  1372. #endif /* ndef EINVAL */
  1373. if (x == Mono_Posix_Errno_EIO)
  1374. #ifdef EIO
  1375. {*r = EIO; return 0;}
  1376. #else /* def EIO */
  1377. {errno = EINVAL; return -1;}
  1378. #endif /* ndef EIO */
  1379. if (x == Mono_Posix_Errno_EISCONN)
  1380. #ifdef EISCONN
  1381. {*r = EISCONN; return 0;}
  1382. #else /* def EISCONN */
  1383. {errno = EINVAL; return -1;}
  1384. #endif /* ndef EISCONN */
  1385. if (x == Mono_Posix_Errno_EISDIR)
  1386. #ifdef EISDIR
  1387. {*r = EISDIR; return 0;}
  1388. #else /* def EISDIR */
  1389. {errno = EINVAL; return -1;}
  1390. #endif /* ndef EISDIR */
  1391. if (x == Mono_Posix_Errno_EISNAM)
  1392. #ifdef EISNAM
  1393. {*r = EISNAM; return 0;}
  1394. #else /* def EISNAM */
  1395. {errno = EINVAL; return -1;}
  1396. #endif /* ndef EISNAM */
  1397. if (x == Mono_Posix_Errno_EKEYEXPIRED)
  1398. #ifdef EKEYEXPIRED
  1399. {*r = EKEYEXPIRED; return 0;}
  1400. #else /* def EKEYEXPIRED */
  1401. {errno = EINVAL; return -1;}
  1402. #endif /* ndef EKEYEXPIRED */
  1403. if (x == Mono_Posix_Errno_EKEYREJECTED)
  1404. #ifdef EKEYREJECTED
  1405. {*r = EKEYREJECTED; return 0;}
  1406. #else /* def EKEYREJECTED */
  1407. {errno = EINVAL; return -1;}
  1408. #endif /* ndef EKEYREJECTED */
  1409. if (x == Mono_Posix_Errno_EKEYREVOKED)
  1410. #ifdef EKEYREVOKED
  1411. {*r = EKEYREVOKED; return 0;}
  1412. #else /* def EKEYREVOKED */
  1413. {errno = EINVAL; return -1;}
  1414. #endif /* ndef EKEYREVOKED */
  1415. if (x == Mono_Posix_Errno_EL2HLT)
  1416. #ifdef EL2HLT
  1417. {*r = EL2HLT; return 0;}
  1418. #else /* def EL2HLT */
  1419. {errno = EINVAL; return -1;}
  1420. #endif /* ndef EL2HLT */
  1421. if (x == Mono_Posix_Errno_EL2NSYNC)
  1422. #ifdef EL2NSYNC
  1423. {*r = EL2NSYNC; return 0;}
  1424. #else /* def EL2NSYNC */
  1425. {errno = EINVAL; return -1;}
  1426. #endif /* ndef EL2NSYNC */
  1427. if (x == Mono_Posix_Errno_EL3HLT)
  1428. #ifdef EL3HLT
  1429. {*r = EL3HLT; return 0;}
  1430. #else /* def EL3HLT */
  1431. {errno = EINVAL; return -1;}
  1432. #endif /* ndef EL3HLT */
  1433. if (x == Mono_Posix_Errno_EL3RST)
  1434. #ifdef EL3RST
  1435. {*r = EL3RST; return 0;}
  1436. #else /* def EL3RST */
  1437. {errno = EINVAL; return -1;}
  1438. #endif /* ndef EL3RST */
  1439. if (x == Mono_Posix_Errno_ELIBACC)
  1440. #ifdef ELIBACC
  1441. {*r = ELIBACC; return 0;}
  1442. #else /* def ELIBACC */
  1443. {errno = EINVAL; return -1;}
  1444. #endif /* ndef ELIBACC */
  1445. if (x == Mono_Posix_Errno_ELIBBAD)
  1446. #ifdef ELIBBAD
  1447. {*r = ELIBBAD; return 0;}
  1448. #else /* def ELIBBAD */
  1449. {errno = EINVAL; return -1;}
  1450. #endif /* ndef ELIBBAD */
  1451. if (x == Mono_Posix_Errno_ELIBEXEC)
  1452. #ifdef ELIBEXEC
  1453. {*r = ELIBEXEC; return 0;}
  1454. #else /* def ELIBEXEC */
  1455. {errno = EINVAL; return -1;}
  1456. #endif /* ndef ELIBEXEC */
  1457. if (x == Mono_Posix_Errno_ELIBMAX)
  1458. #ifdef ELIBMAX
  1459. {*r = ELIBMAX; return 0;}
  1460. #else /* def ELIBMAX */
  1461. {errno = EINVAL; return -1;}
  1462. #endif /* ndef ELIBMAX */
  1463. if (x == Mono_Posix_Errno_ELIBSCN)
  1464. #ifdef ELIBSCN
  1465. {*r = ELIBSCN; return 0;}
  1466. #else /* def ELIBSCN */
  1467. {errno = EINVAL; return -1;}
  1468. #endif /* ndef ELIBSCN */
  1469. if (x == Mono_Posix_Errno_ELNRNG)
  1470. #ifdef ELNRNG
  1471. {*r = ELNRNG; return 0;}
  1472. #else /* def ELNRNG */
  1473. {errno = EINVAL; return -1;}
  1474. #endif /* ndef ELNRNG */
  1475. if (x == Mono_Posix_Errno_ELOOP)
  1476. #ifdef ELOOP
  1477. {*r = ELOOP; return 0;}
  1478. #else /* def ELOOP */
  1479. {errno = EINVAL; return -1;}
  1480. #endif /* ndef ELOOP */
  1481. if (x == Mono_Posix_Errno_EMEDIUMTYPE)
  1482. #ifdef EMEDIUMTYPE
  1483. {*r = EMEDIUMTYPE; return 0;}
  1484. #else /* def EMEDIUMTYPE */
  1485. {errno = EINVAL; return -1;}
  1486. #endif /* ndef EMEDIUMTYPE */
  1487. if (x == Mono_Posix_Errno_EMFILE)
  1488. #ifdef EMFILE
  1489. {*r = EMFILE; return 0;}
  1490. #else /* def EMFILE */
  1491. {errno = EINVAL; return -1;}
  1492. #endif /* ndef EMFILE */
  1493. if (x == Mono_Posix_Errno_EMLINK)
  1494. #ifdef EMLINK
  1495. {*r = EMLINK; return 0;}
  1496. #else /* def EMLINK */
  1497. {errno = EINVAL; return -1;}
  1498. #endif /* ndef EMLINK */
  1499. if (x == Mono_Posix_Errno_EMSGSIZE)
  1500. #ifdef EMSGSIZE
  1501. {*r = EMSGSIZE; return 0;}
  1502. #else /* def EMSGSIZE */
  1503. {errno = EINVAL; return -1;}
  1504. #endif /* ndef EMSGSIZE */
  1505. if (x == Mono_Posix_Errno_EMULTIHOP)
  1506. #ifdef EMULTIHOP
  1507. {*r = EMULTIHOP; return 0;}
  1508. #else /* def EMULTIHOP */
  1509. {errno = EINVAL; return -1;}
  1510. #endif /* ndef EMULTIHOP */
  1511. if (x == Mono_Posix_Errno_ENAMETOOLONG)
  1512. #ifdef ENAMETOOLONG
  1513. {*r = ENAMETOOLONG; return 0;}
  1514. #else /* def ENAMETOOLONG */
  1515. {errno = EINVAL; return -1;}
  1516. #endif /* ndef ENAMETOOLONG */
  1517. if (x == Mono_Posix_Errno_ENAVAIL)
  1518. #ifdef ENAVAIL
  1519. {*r = ENAVAIL; return 0;}
  1520. #else /* def ENAVAIL */
  1521. {errno = EINVAL; return -1;}
  1522. #endif /* ndef ENAVAIL */
  1523. if (x == Mono_Posix_Errno_ENEEDAUTH)
  1524. #ifdef ENEEDAUTH
  1525. {*r = ENEEDAUTH; return 0;}
  1526. #else /* def ENEEDAUTH */
  1527. {errno = EINVAL; return -1;}
  1528. #endif /* ndef ENEEDAUTH */
  1529. if (x == Mono_Posix_Errno_ENETDOWN)
  1530. #ifdef ENETDOWN
  1531. {*r = ENETDOWN; return 0;}
  1532. #else /* def ENETDOWN */
  1533. {errno = EINVAL; return -1;}
  1534. #endif /* ndef ENETDOWN */
  1535. if (x == Mono_Posix_Errno_ENETRESET)
  1536. #ifdef ENETRESET
  1537. {*r = ENETRESET; return 0;}
  1538. #else /* def ENETRESET */
  1539. {errno = EINVAL; return -1;}
  1540. #endif /* ndef ENETRESET */
  1541. if (x == Mono_Posix_Errno_ENETUNREACH)
  1542. #ifdef ENETUNREACH
  1543. {*r = ENETUNREACH; return 0;}
  1544. #else /* def ENETUNREACH */
  1545. {errno = EINVAL; return -1;}
  1546. #endif /* ndef ENETUNREACH */
  1547. if (x == Mono_Posix_Errno_ENFILE)
  1548. #ifdef ENFILE
  1549. {*r = ENFILE; return 0;}
  1550. #else /* def ENFILE */
  1551. {errno = EINVAL; return -1;}
  1552. #endif /* ndef ENFILE */
  1553. if (x == Mono_Posix_Errno_ENOANO)
  1554. #ifdef ENOANO
  1555. {*r = ENOANO; return 0;}
  1556. #else /* def ENOANO */
  1557. {errno = EINVAL; return -1;}
  1558. #endif /* ndef ENOANO */
  1559. if (x == Mono_Posix_Errno_ENOATTR)
  1560. #ifdef ENOATTR
  1561. {*r = ENOATTR; return 0;}
  1562. #else /* def ENOATTR */
  1563. {errno = EINVAL; return -1;}
  1564. #endif /* ndef ENOATTR */
  1565. if (x == Mono_Posix_Errno_ENOBUFS)
  1566. #ifdef ENOBUFS
  1567. {*r = ENOBUFS; return 0;}
  1568. #else /* def ENOBUFS */
  1569. {errno = EINVAL; return -1;}
  1570. #endif /* ndef ENOBUFS */
  1571. if (x == Mono_Posix_Errno_ENOCSI)
  1572. #ifdef ENOCSI
  1573. {*r = ENOCSI; return 0;}
  1574. #else /* def ENOCSI */
  1575. {errno = EINVAL; return -1;}
  1576. #endif /* ndef ENOCSI */
  1577. if (x == Mono_Posix_Errno_ENODATA)
  1578. #ifdef ENODATA
  1579. {*r = ENODATA; return 0;}
  1580. #else /* def ENODATA */
  1581. {errno = EINVAL; return -1;}
  1582. #endif /* ndef ENODATA */
  1583. if (x == Mono_Posix_Errno_ENODEV)
  1584. #ifdef ENODEV
  1585. {*r = ENODEV; return 0;}
  1586. #else /* def ENODEV */
  1587. {errno = EINVAL; return -1;}
  1588. #endif /* ndef ENODEV */
  1589. if (x == Mono_Posix_Errno_ENOENT)
  1590. #ifdef ENOENT
  1591. {*r = ENOENT; return 0;}
  1592. #else /* def ENOENT */
  1593. {errno = EINVAL; return -1;}
  1594. #endif /* ndef ENOENT */
  1595. if (x == Mono_Posix_Errno_ENOEXEC)
  1596. #ifdef ENOEXEC
  1597. {*r = ENOEXEC; return 0;}
  1598. #else /* def ENOEXEC */
  1599. {errno = EINVAL; return -1;}
  1600. #endif /* ndef ENOEXEC */
  1601. if (x == Mono_Posix_Errno_ENOKEY)
  1602. #ifdef ENOKEY
  1603. {*r = ENOKEY; return 0;}
  1604. #else /* def ENOKEY */
  1605. {errno = EINVAL; return -1;}
  1606. #endif /* ndef ENOKEY */
  1607. if (x == Mono_Posix_Errno_ENOLCK)
  1608. #ifdef ENOLCK
  1609. {*r = ENOLCK; return 0;}
  1610. #else /* def ENOLCK */
  1611. {errno = EINVAL; return -1;}
  1612. #endif /* ndef ENOLCK */
  1613. if (x == Mono_Posix_Errno_ENOLINK)
  1614. #ifdef ENOLINK
  1615. {*r = ENOLINK; return 0;}
  1616. #else /* def ENOLINK */
  1617. {errno = EINVAL; return -1;}
  1618. #endif /* ndef ENOLINK */
  1619. if (x == Mono_Posix_Errno_ENOMEDIUM)
  1620. #ifdef ENOMEDIUM
  1621. {*r = ENOMEDIUM; return 0;}
  1622. #else /* def ENOMEDIUM */
  1623. {errno = EINVAL; return -1;}
  1624. #endif /* ndef ENOMEDIUM */
  1625. if (x == Mono_Posix_Errno_ENOMEM)
  1626. #ifdef ENOMEM
  1627. {*r = ENOMEM; return 0;}
  1628. #else /* def ENOMEM */
  1629. {errno = EINVAL; return -1;}
  1630. #endif /* ndef ENOMEM */
  1631. if (x == Mono_Posix_Errno_ENOMSG)
  1632. #ifdef ENOMSG
  1633. {*r = ENOMSG; return 0;}
  1634. #else /* def ENOMSG */
  1635. {errno = EINVAL; return -1;}
  1636. #endif /* ndef ENOMSG */
  1637. if (x == Mono_Posix_Errno_ENONET)
  1638. #ifdef ENONET
  1639. {*r = ENONET; return 0;}
  1640. #else /* def ENONET */
  1641. {errno = EINVAL; return -1;}
  1642. #endif /* ndef ENONET */
  1643. if (x == Mono_Posix_Errno_ENOPKG)
  1644. #ifdef ENOPKG
  1645. {*r = ENOPKG; return 0;}
  1646. #else /* def ENOPKG */
  1647. {errno = EINVAL; return -1;}
  1648. #endif /* ndef ENOPKG */
  1649. if (x == Mono_Posix_Errno_ENOPOLICY)
  1650. #ifdef ENOPOLICY
  1651. {*r = ENOPOLICY; return 0;}
  1652. #else /* def ENOPOLICY */
  1653. {errno = EINVAL; return -1;}
  1654. #endif /* ndef ENOPOLICY */
  1655. if (x == Mono_Posix_Errno_ENOPROTOOPT)
  1656. #ifdef ENOPROTOOPT
  1657. {*r = ENOPROTOOPT; return 0;}
  1658. #else /* def ENOPROTOOPT */
  1659. {errno = EINVAL; return -1;}
  1660. #endif /* ndef ENOPROTOOPT */
  1661. if (x == Mono_Posix_Errno_ENOSPC)
  1662. #ifdef ENOSPC
  1663. {*r = ENOSPC; return 0;}
  1664. #else /* def ENOSPC */
  1665. {errno = EINVAL; return -1;}
  1666. #endif /* ndef ENOSPC */
  1667. if (x == Mono_Posix_Errno_ENOSR)
  1668. #ifdef ENOSR
  1669. {*r = ENOSR; return 0;}
  1670. #else /* def ENOSR */
  1671. {errno = EINVAL; return -1;}
  1672. #endif /* ndef ENOSR */
  1673. if (x == Mono_Posix_Errno_ENOSTR)
  1674. #ifdef ENOSTR
  1675. {*r = ENOSTR; return 0;}
  1676. #else /* def ENOSTR */
  1677. {errno = EINVAL; return -1;}
  1678. #endif /* ndef ENOSTR */
  1679. if (x == Mono_Posix_Errno_ENOSYS)
  1680. #ifdef ENOSYS
  1681. {*r = ENOSYS; return 0;}
  1682. #else /* def ENOSYS */
  1683. {errno = EINVAL; return -1;}
  1684. #endif /* ndef ENOSYS */
  1685. if (x == Mono_Posix_Errno_ENOTBLK)
  1686. #ifdef ENOTBLK
  1687. {*r = ENOTBLK; return 0;}
  1688. #else /* def ENOTBLK */
  1689. {errno = EINVAL; return -1;}
  1690. #endif /* ndef ENOTBLK */
  1691. if (x == Mono_Posix_Errno_ENOTCONN)
  1692. #ifdef ENOTCONN
  1693. {*r = ENOTCONN; return 0;}
  1694. #else /* def ENOTCONN */
  1695. {errno = EINVAL; return -1;}
  1696. #endif /* ndef ENOTCONN */
  1697. if (x == Mono_Posix_Errno_ENOTDIR)
  1698. #ifdef ENOTDIR
  1699. {*r = ENOTDIR; return 0;}
  1700. #else /* def ENOTDIR */
  1701. {errno = EINVAL; return -1;}
  1702. #endif /* ndef ENOTDIR */
  1703. if (x == Mono_Posix_Errno_ENOTEMPTY)
  1704. #ifdef ENOTEMPTY
  1705. {*r = ENOTEMPTY; return 0;}
  1706. #else /* def ENOTEMPTY */
  1707. {errno = EINVAL; return -1;}
  1708. #endif /* ndef ENOTEMPTY */
  1709. if (x == Mono_Posix_Errno_ENOTNAM)
  1710. #ifdef ENOTNAM
  1711. {*r = ENOTNAM; return 0;}
  1712. #else /* def ENOTNAM */
  1713. {errno = EINVAL; return -1;}
  1714. #endif /* ndef ENOTNAM */
  1715. if (x == Mono_Posix_Errno_ENOTRECOVERABLE)
  1716. #ifdef ENOTRECOVERABLE
  1717. {*r = ENOTRECOVERABLE; return 0;}
  1718. #else /* def ENOTRECOVERABLE */
  1719. {errno = EINVAL; return -1;}
  1720. #endif /* ndef ENOTRECOVERABLE */
  1721. if (x == Mono_Posix_Errno_ENOTSOCK)
  1722. #ifdef ENOTSOCK
  1723. {*r = ENOTSOCK; return 0;}
  1724. #else /* def ENOTSOCK */
  1725. {errno = EINVAL; return -1;}
  1726. #endif /* ndef ENOTSOCK */
  1727. if (x == Mono_Posix_Errno_ENOTTY)
  1728. #ifdef ENOTTY
  1729. {*r = ENOTTY; return 0;}
  1730. #else /* def ENOTTY */
  1731. {errno = EINVAL; return -1;}
  1732. #endif /* ndef ENOTTY */
  1733. if (x == Mono_Posix_Errno_ENOTUNIQ)
  1734. #ifdef ENOTUNIQ
  1735. {*r = ENOTUNIQ; return 0;}
  1736. #else /* def ENOTUNIQ */
  1737. {errno = EINVAL; return -1;}
  1738. #endif /* ndef ENOTUNIQ */
  1739. if (x == Mono_Posix_Errno_ENXIO)
  1740. #ifdef ENXIO
  1741. {*r = ENXIO; return 0;}
  1742. #else /* def ENXIO */
  1743. {errno = EINVAL; return -1;}
  1744. #endif /* ndef ENXIO */
  1745. if (x == Mono_Posix_Errno_EOPNOTSUPP)
  1746. #ifdef EOPNOTSUPP
  1747. {*r = EOPNOTSUPP; return 0;}
  1748. #else /* def EOPNOTSUPP */
  1749. {errno = EINVAL; return -1;}
  1750. #endif /* ndef EOPNOTSUPP */
  1751. if (x == Mono_Posix_Errno_EOVERFLOW)
  1752. #ifdef EOVERFLOW
  1753. {*r = EOVERFLOW; return 0;}
  1754. #else /* def EOVERFLOW */
  1755. {errno = EINVAL; return -1;}
  1756. #endif /* ndef EOVERFLOW */
  1757. if (x == Mono_Posix_Errno_EOWNERDEAD)
  1758. #ifdef EOWNERDEAD
  1759. {*r = EOWNERDEAD; return 0;}
  1760. #else /* def EOWNERDEAD */
  1761. {errno = EINVAL; return -1;}
  1762. #endif /* ndef EOWNERDEAD */
  1763. if (x == Mono_Posix_Errno_EPERM)
  1764. #ifdef EPERM
  1765. {*r = EPERM; return 0;}
  1766. #else /* def EPERM */
  1767. {errno = EINVAL; return -1;}
  1768. #endif /* ndef EPERM */
  1769. if (x == Mono_Posix_Errno_EPFNOSUPPORT)
  1770. #ifdef EPFNOSUPPORT
  1771. {*r = EPFNOSUPPORT; return 0;}
  1772. #else /* def EPFNOSUPPORT */
  1773. {errno = EINVAL; return -1;}
  1774. #endif /* ndef EPFNOSUPPORT */
  1775. if (x == Mono_Posix_Errno_EPIPE)
  1776. #ifdef EPIPE
  1777. {*r = EPIPE; return 0;}
  1778. #else /* def EPIPE */
  1779. {errno = EINVAL; return -1;}
  1780. #endif /* ndef EPIPE */
  1781. if (x == Mono_Posix_Errno_EPROCLIM)
  1782. #ifdef EPROCLIM
  1783. {*r = EPROCLIM; return 0;}
  1784. #else /* def EPROCLIM */
  1785. {errno = EINVAL; return -1;}
  1786. #endif /* ndef EPROCLIM */
  1787. if (x == Mono_Posix_Errno_EPROCUNAVAIL)
  1788. #ifdef EPROCUNAVAIL
  1789. {*r = EPROCUNAVAIL; return 0;}
  1790. #else /* def EPROCUNAVAIL */
  1791. {errno = EINVAL; return -1;}
  1792. #endif /* ndef EPROCUNAVAIL */
  1793. if (x == Mono_Posix_Errno_EPROGMISMATCH)
  1794. #ifdef EPROGMISMATCH
  1795. {*r = EPROGMISMATCH; return 0;}
  1796. #else /* def EPROGMISMATCH */
  1797. {errno = EINVAL; return -1;}
  1798. #endif /* ndef EPROGMISMATCH */
  1799. if (x == Mono_Posix_Errno_EPROGUNAVAIL)
  1800. #ifdef EPROGUNAVAIL
  1801. {*r = EPROGUNAVAIL; return 0;}
  1802. #else /* def EPROGUNAVAIL */
  1803. {errno = EINVAL; return -1;}
  1804. #endif /* ndef EPROGUNAVAIL */
  1805. if (x == Mono_Posix_Errno_EPROTO)
  1806. #ifdef EPROTO
  1807. {*r = EPROTO; return 0;}
  1808. #else /* def EPROTO */
  1809. {errno = EINVAL; return -1;}
  1810. #endif /* ndef EPROTO */
  1811. if (x == Mono_Posix_Errno_EPROTONOSUPPORT)
  1812. #ifdef EPROTONOSUPPORT
  1813. {*r = EPROTONOSUPPORT; return 0;}
  1814. #else /* def EPROTONOSUPPORT */
  1815. {errno = EINVAL; return -1;}
  1816. #endif /* ndef EPROTONOSUPPORT */
  1817. if (x == Mono_Posix_Errno_EPROTOTYPE)
  1818. #ifdef EPROTOTYPE
  1819. {*r = EPROTOTYPE; return 0;}
  1820. #else /* def EPROTOTYPE */
  1821. {errno = EINVAL; return -1;}
  1822. #endif /* ndef EPROTOTYPE */
  1823. if (x == Mono_Posix_Errno_EPWROFF)
  1824. #ifdef EPWROFF
  1825. {*r = EPWROFF; return 0;}
  1826. #else /* def EPWROFF */
  1827. {errno = EINVAL; return -1;}
  1828. #endif /* ndef EPWROFF */
  1829. if (x == Mono_Posix_Errno_ERANGE)
  1830. #ifdef ERANGE
  1831. {*r = ERANGE; return 0;}
  1832. #else /* def ERANGE */
  1833. {errno = EINVAL; return -1;}
  1834. #endif /* ndef ERANGE */
  1835. if (x == Mono_Posix_Errno_EREMCHG)
  1836. #ifdef EREMCHG
  1837. {*r = EREMCHG; return 0;}
  1838. #else /* def EREMCHG */
  1839. {errno = EINVAL; return -1;}
  1840. #endif /* ndef EREMCHG */
  1841. if (x == Mono_Posix_Errno_EREMOTE)
  1842. #ifdef EREMOTE
  1843. {*r = EREMOTE; return 0;}
  1844. #else /* def EREMOTE */
  1845. {errno = EINVAL; return -1;}
  1846. #endif /* ndef EREMOTE */
  1847. if (x == Mono_Posix_Errno_EREMOTEIO)
  1848. #ifdef EREMOTEIO
  1849. {*r = EREMOTEIO; return 0;}
  1850. #else /* def EREMOTEIO */
  1851. {errno = EINVAL; return -1;}
  1852. #endif /* ndef EREMOTEIO */
  1853. if (x == Mono_Posix_Errno_ERESTART)
  1854. #ifdef ERESTART
  1855. {*r = ERESTART; return 0;}
  1856. #else /* def ERESTART */
  1857. {errno = EINVAL; return -1;}
  1858. #endif /* ndef ERESTART */
  1859. if (x == Mono_Posix_Errno_EROFS)
  1860. #ifdef EROFS
  1861. {*r = EROFS; return 0;}
  1862. #else /* def EROFS */
  1863. {errno = EINVAL; return -1;}
  1864. #endif /* ndef EROFS */
  1865. if (x == Mono_Posix_Errno_ERPCMISMATCH)
  1866. #ifdef ERPCMISMATCH
  1867. {*r = ERPCMISMATCH; return 0;}
  1868. #else /* def ERPCMISMATCH */
  1869. {errno = EINVAL; return -1;}
  1870. #endif /* ndef ERPCMISMATCH */
  1871. if (x == Mono_Posix_Errno_ESHLIBVERS)
  1872. #ifdef ESHLIBVERS
  1873. {*r = ESHLIBVERS; return 0;}
  1874. #else /* def ESHLIBVERS */
  1875. {errno = EINVAL; return -1;}
  1876. #endif /* ndef ESHLIBVERS */
  1877. if (x == Mono_Posix_Errno_ESHUTDOWN)
  1878. #ifdef ESHUTDOWN
  1879. {*r = ESHUTDOWN; return 0;}
  1880. #else /* def ESHUTDOWN */
  1881. {errno = EINVAL; return -1;}
  1882. #endif /* ndef ESHUTDOWN */
  1883. if (x == Mono_Posix_Errno_ESOCKTNOSUPPORT)
  1884. #ifdef ESOCKTNOSUPPORT
  1885. {*r = ESOCKTNOSUPPORT; return 0;}
  1886. #else /* def ESOCKTNOSUPPORT */
  1887. {errno = EINVAL; return -1;}
  1888. #endif /* ndef ESOCKTNOSUPPORT */
  1889. if (x == Mono_Posix_Errno_ESPIPE)
  1890. #ifdef ESPIPE
  1891. {*r = ESPIPE; return 0;}
  1892. #else /* def ESPIPE */
  1893. {errno = EINVAL; return -1;}
  1894. #endif /* ndef ESPIPE */
  1895. if (x == Mono_Posix_Errno_ESRCH)
  1896. #ifdef ESRCH
  1897. {*r = ESRCH; return 0;}
  1898. #else /* def ESRCH */
  1899. {errno = EINVAL; return -1;}
  1900. #endif /* ndef ESRCH */
  1901. if (x == Mono_Posix_Errno_ESRMNT)
  1902. #ifdef ESRMNT
  1903. {*r = ESRMNT; return 0;}
  1904. #else /* def ESRMNT */
  1905. {errno = EINVAL; return -1;}
  1906. #endif /* ndef ESRMNT */
  1907. if (x == Mono_Posix_Errno_ESTALE)
  1908. #ifdef ESTALE
  1909. {*r = ESTALE; return 0;}
  1910. #else /* def ESTALE */
  1911. {errno = EINVAL; return -1;}
  1912. #endif /* ndef ESTALE */
  1913. if (x == Mono_Posix_Errno_ESTRPIPE)
  1914. #ifdef ESTRPIPE
  1915. {*r = ESTRPIPE; return 0;}
  1916. #else /* def ESTRPIPE */
  1917. {errno = EINVAL; return -1;}
  1918. #endif /* ndef ESTRPIPE */
  1919. if (x == Mono_Posix_Errno_ETIME)
  1920. #ifdef ETIME
  1921. {*r = ETIME; return 0;}
  1922. #else /* def ETIME */
  1923. {errno = EINVAL; return -1;}
  1924. #endif /* ndef ETIME */
  1925. if (x == Mono_Posix_Errno_ETIMEDOUT)
  1926. #ifdef ETIMEDOUT
  1927. {*r = ETIMEDOUT; return 0;}
  1928. #else /* def ETIMEDOUT */
  1929. {errno = EINVAL; return -1;}
  1930. #endif /* ndef ETIMEDOUT */
  1931. if (x == Mono_Posix_Errno_ETOOMANYREFS)
  1932. #ifdef ETOOMANYREFS
  1933. {*r = ETOOMANYREFS; return 0;}
  1934. #else /* def ETOOMANYREFS */
  1935. {errno = EINVAL; return -1;}
  1936. #endif /* ndef ETOOMANYREFS */
  1937. if (x == Mono_Posix_Errno_ETXTBSY)
  1938. #ifdef ETXTBSY
  1939. {*r = ETXTBSY; return 0;}
  1940. #else /* def ETXTBSY */
  1941. {errno = EINVAL; return -1;}
  1942. #endif /* ndef ETXTBSY */
  1943. if (x == Mono_Posix_Errno_EUCLEAN)
  1944. #ifdef EUCLEAN
  1945. {*r = EUCLEAN; return 0;}
  1946. #else /* def EUCLEAN */
  1947. {errno = EINVAL; return -1;}
  1948. #endif /* ndef EUCLEAN */
  1949. if (x == Mono_Posix_Errno_EUNATCH)
  1950. #ifdef EUNATCH
  1951. {*r = EUNATCH; return 0;}
  1952. #else /* def EUNATCH */
  1953. {errno = EINVAL; return -1;}
  1954. #endif /* ndef EUNATCH */
  1955. if (x == Mono_Posix_Errno_EUSERS)
  1956. #ifdef EUSERS
  1957. {*r = EUSERS; return 0;}
  1958. #else /* def EUSERS */
  1959. {errno = EINVAL; return -1;}
  1960. #endif /* ndef EUSERS */
  1961. if (x == Mono_Posix_Errno_EWOULDBLOCK)
  1962. #ifdef EWOULDBLOCK
  1963. {*r = EWOULDBLOCK; return 0;}
  1964. #else /* def EWOULDBLOCK */
  1965. {errno = EINVAL; return -1;}
  1966. #endif /* ndef EWOULDBLOCK */
  1967. if (x == Mono_Posix_Errno_EXDEV)
  1968. #ifdef EXDEV
  1969. {*r = EXDEV; return 0;}
  1970. #else /* def EXDEV */
  1971. {errno = EINVAL; return -1;}
  1972. #endif /* ndef EXDEV */
  1973. if (x == Mono_Posix_Errno_EXFULL)
  1974. #ifdef EXFULL
  1975. {*r = EXFULL; return 0;}
  1976. #else /* def EXFULL */
  1977. {errno = EINVAL; return -1;}
  1978. #endif /* ndef EXFULL */
  1979. if (x == 0)
  1980. return 0;
  1981. errno = EINVAL; return -1;
  1982. }
  1983. int Mono_Posix_ToErrno (int x, int *r)
  1984. {
  1985. *r = 0;
  1986. if (x == 0)
  1987. return 0;
  1988. #ifdef E2BIG
  1989. if (x == E2BIG)
  1990. {*r = Mono_Posix_Errno_E2BIG; return 0;}
  1991. #endif /* ndef E2BIG */
  1992. #ifdef EACCES
  1993. if (x == EACCES)
  1994. {*r = Mono_Posix_Errno_EACCES; return 0;}
  1995. #endif /* ndef EACCES */
  1996. #ifdef EADDRINUSE
  1997. if (x == EADDRINUSE)
  1998. {*r = Mono_Posix_Errno_EADDRINUSE; return 0;}
  1999. #endif /* ndef EADDRINUSE */
  2000. #ifdef EADDRNOTAVAIL
  2001. if (x == EADDRNOTAVAIL)
  2002. {*r = Mono_Posix_Errno_EADDRNOTAVAIL; return 0;}
  2003. #endif /* ndef EADDRNOTAVAIL */
  2004. #ifdef EADV
  2005. if (x == EADV)
  2006. {*r = Mono_Posix_Errno_EADV; return 0;}
  2007. #endif /* ndef EADV */
  2008. #ifdef EAFNOSUPPORT
  2009. if (x == EAFNOSUPPORT)
  2010. {*r = Mono_Posix_Errno_EAFNOSUPPORT; return 0;}
  2011. #endif /* ndef EAFNOSUPPORT */
  2012. #ifdef EAGAIN
  2013. if (x == EAGAIN)
  2014. {*r = Mono_Posix_Errno_EAGAIN; return 0;}
  2015. #endif /* ndef EAGAIN */
  2016. #ifdef EALREADY
  2017. if (x == EALREADY)
  2018. {*r = Mono_Posix_Errno_EALREADY; return 0;}
  2019. #endif /* ndef EALREADY */
  2020. #ifdef EAUTH
  2021. if (x == EAUTH)
  2022. {*r = Mono_Posix_Errno_EAUTH; return 0;}
  2023. #endif /* ndef EAUTH */
  2024. #ifdef EBADARCH
  2025. if (x == EBADARCH)
  2026. {*r = Mono_Posix_Errno_EBADARCH; return 0;}
  2027. #endif /* ndef EBADARCH */
  2028. #ifdef EBADE
  2029. if (x == EBADE)
  2030. {*r = Mono_Posix_Errno_EBADE; return 0;}
  2031. #endif /* ndef EBADE */
  2032. #ifdef EBADEXEC
  2033. if (x == EBADEXEC)
  2034. {*r = Mono_Posix_Errno_EBADEXEC; return 0;}
  2035. #endif /* ndef EBADEXEC */
  2036. #ifdef EBADF
  2037. if (x == EBADF)
  2038. {*r = Mono_Posix_Errno_EBADF; return 0;}
  2039. #endif /* ndef EBADF */
  2040. #ifdef EBADFD
  2041. if (x == EBADFD)
  2042. {*r = Mono_Posix_Errno_EBADFD; return 0;}
  2043. #endif /* ndef EBADFD */
  2044. #ifdef EBADMACHO
  2045. if (x == EBADMACHO)
  2046. {*r = Mono_Posix_Errno_EBADMACHO; return 0;}
  2047. #endif /* ndef EBADMACHO */
  2048. #ifdef EBADMSG
  2049. if (x == EBADMSG)
  2050. {*r = Mono_Posix_Errno_EBADMSG; return 0;}
  2051. #endif /* ndef EBADMSG */
  2052. #ifdef EBADR
  2053. if (x == EBADR)
  2054. {*r = Mono_Posix_Errno_EBADR; return 0;}
  2055. #endif /* ndef EBADR */
  2056. #ifdef EBADRPC
  2057. if (x == EBADRPC)
  2058. {*r = Mono_Posix_Errno_EBADRPC; return 0;}
  2059. #endif /* ndef EBADRPC */
  2060. #ifdef EBADRQC
  2061. if (x == EBADRQC)
  2062. {*r = Mono_Posix_Errno_EBADRQC; return 0;}
  2063. #endif /* ndef EBADRQC */
  2064. #ifdef EBADSLT
  2065. if (x == EBADSLT)
  2066. {*r = Mono_Posix_Errno_EBADSLT; return 0;}
  2067. #endif /* ndef EBADSLT */
  2068. #ifdef EBFONT
  2069. if (x == EBFONT)
  2070. {*r = Mono_Posix_Errno_EBFONT; return 0;}
  2071. #endif /* ndef EBFONT */
  2072. #ifdef EBUSY
  2073. if (x == EBUSY)
  2074. {*r = Mono_Posix_Errno_EBUSY; return 0;}
  2075. #endif /* ndef EBUSY */
  2076. #ifdef ECANCELED
  2077. if (x == ECANCELED)
  2078. {*r = Mono_Posix_Errno_ECANCELED; return 0;}
  2079. #endif /* ndef ECANCELED */
  2080. #ifdef ECHILD
  2081. if (x == ECHILD)
  2082. {*r = Mono_Posix_Errno_ECHILD; return 0;}
  2083. #endif /* ndef ECHILD */
  2084. #ifdef ECHRNG
  2085. if (x == ECHRNG)
  2086. {*r = Mono_Posix_Errno_ECHRNG; return 0;}
  2087. #endif /* ndef ECHRNG */
  2088. #ifdef ECOMM
  2089. if (x == ECOMM)
  2090. {*r = Mono_Posix_Errno_ECOMM; return 0;}
  2091. #endif /* ndef ECOMM */
  2092. #ifdef ECONNABORTED
  2093. if (x == ECONNABORTED)
  2094. {*r = Mono_Posix_Errno_ECONNABORTED; return 0;}
  2095. #endif /* ndef ECONNABORTED */
  2096. #ifdef ECONNREFUSED
  2097. if (x == ECONNREFUSED)
  2098. {*r = Mono_Posix_Errno_ECONNREFUSED; return 0;}
  2099. #endif /* ndef ECONNREFUSED */
  2100. #ifdef ECONNRESET
  2101. if (x == ECONNRESET)
  2102. {*r = Mono_Posix_Errno_ECONNRESET; return 0;}
  2103. #endif /* ndef ECONNRESET */
  2104. #ifdef EDEADLK
  2105. if (x == EDEADLK)
  2106. {*r = Mono_Posix_Errno_EDEADLK; return 0;}
  2107. #endif /* ndef EDEADLK */
  2108. #ifdef EDEADLOCK
  2109. if (x == EDEADLOCK)
  2110. {*r = Mono_Posix_Errno_EDEADLOCK; return 0;}
  2111. #endif /* ndef EDEADLOCK */
  2112. #ifdef EDESTADDRREQ
  2113. if (x == EDESTADDRREQ)
  2114. {*r = Mono_Posix_Errno_EDESTADDRREQ; return 0;}
  2115. #endif /* ndef EDESTADDRREQ */
  2116. #ifdef EDEVERR
  2117. if (x == EDEVERR)
  2118. {*r = Mono_Posix_Errno_EDEVERR; return 0;}
  2119. #endif /* ndef EDEVERR */
  2120. #ifdef EDOM
  2121. if (x == EDOM)
  2122. {*r = Mono_Posix_Errno_EDOM; return 0;}
  2123. #endif /* ndef EDOM */
  2124. #ifdef EDOTDOT
  2125. if (x == EDOTDOT)
  2126. {*r = Mono_Posix_Errno_EDOTDOT; return 0;}
  2127. #endif /* ndef EDOTDOT */
  2128. #ifdef EDQUOT
  2129. if (x == EDQUOT)
  2130. {*r = Mono_Posix_Errno_EDQUOT; return 0;}
  2131. #endif /* ndef EDQUOT */
  2132. #ifdef EEXIST
  2133. if (x == EEXIST)
  2134. {*r = Mono_Posix_Errno_EEXIST; return 0;}
  2135. #endif /* ndef EEXIST */
  2136. #ifdef EFAULT
  2137. if (x == EFAULT)
  2138. {*r = Mono_Posix_Errno_EFAULT; return 0;}
  2139. #endif /* ndef EFAULT */
  2140. #ifdef EFBIG
  2141. if (x == EFBIG)
  2142. {*r = Mono_Posix_Errno_EFBIG; return 0;}
  2143. #endif /* ndef EFBIG */
  2144. #ifdef EFTYPE
  2145. if (x == EFTYPE)
  2146. {*r = Mono_Posix_Errno_EFTYPE; return 0;}
  2147. #endif /* ndef EFTYPE */
  2148. #ifdef EHOSTDOWN
  2149. if (x == EHOSTDOWN)
  2150. {*r = Mono_Posix_Errno_EHOSTDOWN; return 0;}
  2151. #endif /* ndef EHOSTDOWN */
  2152. #ifdef EHOSTUNREACH
  2153. if (x == EHOSTUNREACH)
  2154. {*r = Mono_Posix_Errno_EHOSTUNREACH; return 0;}
  2155. #endif /* ndef EHOSTUNREACH */
  2156. #ifdef EIDRM
  2157. if (x == EIDRM)
  2158. {*r = Mono_Posix_Errno_EIDRM; return 0;}
  2159. #endif /* ndef EIDRM */
  2160. #ifdef EILSEQ
  2161. if (x == EILSEQ)
  2162. {*r = Mono_Posix_Errno_EILSEQ; return 0;}
  2163. #endif /* ndef EILSEQ */
  2164. #ifdef EINPROGRESS
  2165. if (x == EINPROGRESS)
  2166. {*r = Mono_Posix_Errno_EINPROGRESS; return 0;}
  2167. #endif /* ndef EINPROGRESS */
  2168. #ifdef EINTR
  2169. if (x == EINTR)
  2170. {*r = Mono_Posix_Errno_EINTR; return 0;}
  2171. #endif /* ndef EINTR */
  2172. #ifdef EINVAL
  2173. if (x == EINVAL)
  2174. {*r = Mono_Posix_Errno_EINVAL; return 0;}
  2175. #endif /* ndef EINVAL */
  2176. #ifdef EIO
  2177. if (x == EIO)
  2178. {*r = Mono_Posix_Errno_EIO; return 0;}
  2179. #endif /* ndef EIO */
  2180. #ifdef EISCONN
  2181. if (x == EISCONN)
  2182. {*r = Mono_Posix_Errno_EISCONN; return 0;}
  2183. #endif /* ndef EISCONN */
  2184. #ifdef EISDIR
  2185. if (x == EISDIR)
  2186. {*r = Mono_Posix_Errno_EISDIR; return 0;}
  2187. #endif /* ndef EISDIR */
  2188. #ifdef EISNAM
  2189. if (x == EISNAM)
  2190. {*r = Mono_Posix_Errno_EISNAM; return 0;}
  2191. #endif /* ndef EISNAM */
  2192. #ifdef EKEYEXPIRED
  2193. if (x == EKEYEXPIRED)
  2194. {*r = Mono_Posix_Errno_EKEYEXPIRED; return 0;}
  2195. #endif /* ndef EKEYEXPIRED */
  2196. #ifdef EKEYREJECTED
  2197. if (x == EKEYREJECTED)
  2198. {*r = Mono_Posix_Errno_EKEYREJECTED; return 0;}
  2199. #endif /* ndef EKEYREJECTED */
  2200. #ifdef EKEYREVOKED
  2201. if (x == EKEYREVOKED)
  2202. {*r = Mono_Posix_Errno_EKEYREVOKED; return 0;}
  2203. #endif /* ndef EKEYREVOKED */
  2204. #ifdef EL2HLT
  2205. if (x == EL2HLT)
  2206. {*r = Mono_Posix_Errno_EL2HLT; return 0;}
  2207. #endif /* ndef EL2HLT */
  2208. #ifdef EL2NSYNC
  2209. if (x == EL2NSYNC)
  2210. {*r = Mono_Posix_Errno_EL2NSYNC; return 0;}
  2211. #endif /* ndef EL2NSYNC */
  2212. #ifdef EL3HLT
  2213. if (x == EL3HLT)
  2214. {*r = Mono_Posix_Errno_EL3HLT; return 0;}
  2215. #endif /* ndef EL3HLT */
  2216. #ifdef EL3RST
  2217. if (x == EL3RST)
  2218. {*r = Mono_Posix_Errno_EL3RST; return 0;}
  2219. #endif /* ndef EL3RST */
  2220. #ifdef ELIBACC
  2221. if (x == ELIBACC)
  2222. {*r = Mono_Posix_Errno_ELIBACC; return 0;}
  2223. #endif /* ndef ELIBACC */
  2224. #ifdef ELIBBAD
  2225. if (x == ELIBBAD)
  2226. {*r = Mono_Posix_Errno_ELIBBAD; return 0;}
  2227. #endif /* ndef ELIBBAD */
  2228. #ifdef ELIBEXEC
  2229. if (x == ELIBEXEC)
  2230. {*r = Mono_Posix_Errno_ELIBEXEC; return 0;}
  2231. #endif /* ndef ELIBEXEC */
  2232. #ifdef ELIBMAX
  2233. if (x == ELIBMAX)
  2234. {*r = Mono_Posix_Errno_ELIBMAX; return 0;}
  2235. #endif /* ndef ELIBMAX */
  2236. #ifdef ELIBSCN
  2237. if (x == ELIBSCN)
  2238. {*r = Mono_Posix_Errno_ELIBSCN; return 0;}
  2239. #endif /* ndef ELIBSCN */
  2240. #ifdef ELNRNG
  2241. if (x == ELNRNG)
  2242. {*r = Mono_Posix_Errno_ELNRNG; return 0;}
  2243. #endif /* ndef ELNRNG */
  2244. #ifdef ELOOP
  2245. if (x == ELOOP)
  2246. {*r = Mono_Posix_Errno_ELOOP; return 0;}
  2247. #endif /* ndef ELOOP */
  2248. #ifdef EMEDIUMTYPE
  2249. if (x == EMEDIUMTYPE)
  2250. {*r = Mono_Posix_Errno_EMEDIUMTYPE; return 0;}
  2251. #endif /* ndef EMEDIUMTYPE */
  2252. #ifdef EMFILE
  2253. if (x == EMFILE)
  2254. {*r = Mono_Posix_Errno_EMFILE; return 0;}
  2255. #endif /* ndef EMFILE */
  2256. #ifdef EMLINK
  2257. if (x == EMLINK)
  2258. {*r = Mono_Posix_Errno_EMLINK; return 0;}
  2259. #endif /* ndef EMLINK */
  2260. #ifdef EMSGSIZE
  2261. if (x == EMSGSIZE)
  2262. {*r = Mono_Posix_Errno_EMSGSIZE; return 0;}
  2263. #endif /* ndef EMSGSIZE */
  2264. #ifdef EMULTIHOP
  2265. if (x == EMULTIHOP)
  2266. {*r = Mono_Posix_Errno_EMULTIHOP; return 0;}
  2267. #endif /* ndef EMULTIHOP */
  2268. #ifdef ENAMETOOLONG
  2269. if (x == ENAMETOOLONG)
  2270. {*r = Mono_Posix_Errno_ENAMETOOLONG; return 0;}
  2271. #endif /* ndef ENAMETOOLONG */
  2272. #ifdef ENAVAIL
  2273. if (x == ENAVAIL)
  2274. {*r = Mono_Posix_Errno_ENAVAIL; return 0;}
  2275. #endif /* ndef ENAVAIL */
  2276. #ifdef ENEEDAUTH
  2277. if (x == ENEEDAUTH)
  2278. {*r = Mono_Posix_Errno_ENEEDAUTH; return 0;}
  2279. #endif /* ndef ENEEDAUTH */
  2280. #ifdef ENETDOWN
  2281. if (x == ENETDOWN)
  2282. {*r = Mono_Posix_Errno_ENETDOWN; return 0;}
  2283. #endif /* ndef ENETDOWN */
  2284. #ifdef ENETRESET
  2285. if (x == ENETRESET)
  2286. {*r = Mono_Posix_Errno_ENETRESET; return 0;}
  2287. #endif /* ndef ENETRESET */
  2288. #ifdef ENETUNREACH
  2289. if (x == ENETUNREACH)
  2290. {*r = Mono_Posix_Errno_ENETUNREACH; return 0;}
  2291. #endif /* ndef ENETUNREACH */
  2292. #ifdef ENFILE
  2293. if (x == ENFILE)
  2294. {*r = Mono_Posix_Errno_ENFILE; return 0;}
  2295. #endif /* ndef ENFILE */
  2296. #ifdef ENOANO
  2297. if (x == ENOANO)
  2298. {*r = Mono_Posix_Errno_ENOANO; return 0;}
  2299. #endif /* ndef ENOANO */
  2300. #ifdef ENOATTR
  2301. if (x == ENOATTR)
  2302. {*r = Mono_Posix_Errno_ENOATTR; return 0;}
  2303. #endif /* ndef ENOATTR */
  2304. #ifdef ENOBUFS
  2305. if (x == ENOBUFS)
  2306. {*r = Mono_Posix_Errno_ENOBUFS; return 0;}
  2307. #endif /* ndef ENOBUFS */
  2308. #ifdef ENOCSI
  2309. if (x == ENOCSI)
  2310. {*r = Mono_Posix_Errno_ENOCSI; return 0;}
  2311. #endif /* ndef ENOCSI */
  2312. #ifdef ENODATA
  2313. if (x == ENODATA)
  2314. {*r = Mono_Posix_Errno_ENODATA; return 0;}
  2315. #endif /* ndef ENODATA */
  2316. #ifdef ENODEV
  2317. if (x == ENODEV)
  2318. {*r = Mono_Posix_Errno_ENODEV; return 0;}
  2319. #endif /* ndef ENODEV */
  2320. #ifdef ENOENT
  2321. if (x == ENOENT)
  2322. {*r = Mono_Posix_Errno_ENOENT; return 0;}
  2323. #endif /* ndef ENOENT */
  2324. #ifdef ENOEXEC
  2325. if (x == ENOEXEC)
  2326. {*r = Mono_Posix_Errno_ENOEXEC; return 0;}
  2327. #endif /* ndef ENOEXEC */
  2328. #ifdef ENOKEY
  2329. if (x == ENOKEY)
  2330. {*r = Mono_Posix_Errno_ENOKEY; return 0;}
  2331. #endif /* ndef ENOKEY */
  2332. #ifdef ENOLCK
  2333. if (x == ENOLCK)
  2334. {*r = Mono_Posix_Errno_ENOLCK; return 0;}
  2335. #endif /* ndef ENOLCK */
  2336. #ifdef ENOLINK
  2337. if (x == ENOLINK)
  2338. {*r = Mono_Posix_Errno_ENOLINK; return 0;}
  2339. #endif /* ndef ENOLINK */
  2340. #ifdef ENOMEDIUM
  2341. if (x == ENOMEDIUM)
  2342. {*r = Mono_Posix_Errno_ENOMEDIUM; return 0;}
  2343. #endif /* ndef ENOMEDIUM */
  2344. #ifdef ENOMEM
  2345. if (x == ENOMEM)
  2346. {*r = Mono_Posix_Errno_ENOMEM; return 0;}
  2347. #endif /* ndef ENOMEM */
  2348. #ifdef ENOMSG
  2349. if (x == ENOMSG)
  2350. {*r = Mono_Posix_Errno_ENOMSG; return 0;}
  2351. #endif /* ndef ENOMSG */
  2352. #ifdef ENONET
  2353. if (x == ENONET)
  2354. {*r = Mono_Posix_Errno_ENONET; return 0;}
  2355. #endif /* ndef ENONET */
  2356. #ifdef ENOPKG
  2357. if (x == ENOPKG)
  2358. {*r = Mono_Posix_Errno_ENOPKG; return 0;}
  2359. #endif /* ndef ENOPKG */
  2360. #ifdef ENOPOLICY
  2361. if (x == ENOPOLICY)
  2362. {*r = Mono_Posix_Errno_ENOPOLICY; return 0;}
  2363. #endif /* ndef ENOPOLICY */
  2364. #ifdef ENOPROTOOPT
  2365. if (x == ENOPROTOOPT)
  2366. {*r = Mono_Posix_Errno_ENOPROTOOPT; return 0;}
  2367. #endif /* ndef ENOPROTOOPT */
  2368. #ifdef ENOSPC
  2369. if (x == ENOSPC)
  2370. {*r = Mono_Posix_Errno_ENOSPC; return 0;}
  2371. #endif /* ndef ENOSPC */
  2372. #ifdef ENOSR
  2373. if (x == ENOSR)
  2374. {*r = Mono_Posix_Errno_ENOSR; return 0;}
  2375. #endif /* ndef ENOSR */
  2376. #ifdef ENOSTR
  2377. if (x == ENOSTR)
  2378. {*r = Mono_Posix_Errno_ENOSTR; return 0;}
  2379. #endif /* ndef ENOSTR */
  2380. #ifdef ENOSYS
  2381. if (x == ENOSYS)
  2382. {*r = Mono_Posix_Errno_ENOSYS; return 0;}
  2383. #endif /* ndef ENOSYS */
  2384. #ifdef ENOTBLK
  2385. if (x == ENOTBLK)
  2386. {*r = Mono_Posix_Errno_ENOTBLK; return 0;}
  2387. #endif /* ndef ENOTBLK */
  2388. #ifdef ENOTCONN
  2389. if (x == ENOTCONN)
  2390. {*r = Mono_Posix_Errno_ENOTCONN; return 0;}
  2391. #endif /* ndef ENOTCONN */
  2392. #ifdef ENOTDIR
  2393. if (x == ENOTDIR)
  2394. {*r = Mono_Posix_Errno_ENOTDIR; return 0;}
  2395. #endif /* ndef ENOTDIR */
  2396. #ifdef ENOTEMPTY
  2397. if (x == ENOTEMPTY)
  2398. {*r = Mono_Posix_Errno_ENOTEMPTY; return 0;}
  2399. #endif /* ndef ENOTEMPTY */
  2400. #ifdef ENOTNAM
  2401. if (x == ENOTNAM)
  2402. {*r = Mono_Posix_Errno_ENOTNAM; return 0;}
  2403. #endif /* ndef ENOTNAM */
  2404. #ifdef ENOTRECOVERABLE
  2405. if (x == ENOTRECOVERABLE)
  2406. {*r = Mono_Posix_Errno_ENOTRECOVERABLE; return 0;}
  2407. #endif /* ndef ENOTRECOVERABLE */
  2408. #ifdef ENOTSOCK
  2409. if (x == ENOTSOCK)
  2410. {*r = Mono_Posix_Errno_ENOTSOCK; return 0;}
  2411. #endif /* ndef ENOTSOCK */
  2412. #ifdef ENOTTY
  2413. if (x == ENOTTY)
  2414. {*r = Mono_Posix_Errno_ENOTTY; return 0;}
  2415. #endif /* ndef ENOTTY */
  2416. #ifdef ENOTUNIQ
  2417. if (x == ENOTUNIQ)
  2418. {*r = Mono_Posix_Errno_ENOTUNIQ; return 0;}
  2419. #endif /* ndef ENOTUNIQ */
  2420. #ifdef ENXIO
  2421. if (x == ENXIO)
  2422. {*r = Mono_Posix_Errno_ENXIO; return 0;}
  2423. #endif /* ndef ENXIO */
  2424. #ifdef EOPNOTSUPP
  2425. if (x == EOPNOTSUPP)
  2426. {*r = Mono_Posix_Errno_EOPNOTSUPP; return 0;}
  2427. #endif /* ndef EOPNOTSUPP */
  2428. #ifdef EOVERFLOW
  2429. if (x == EOVERFLOW)
  2430. {*r = Mono_Posix_Errno_EOVERFLOW; return 0;}
  2431. #endif /* ndef EOVERFLOW */
  2432. #ifdef EOWNERDEAD
  2433. if (x == EOWNERDEAD)
  2434. {*r = Mono_Posix_Errno_EOWNERDEAD; return 0;}
  2435. #endif /* ndef EOWNERDEAD */
  2436. #ifdef EPERM
  2437. if (x == EPERM)
  2438. {*r = Mono_Posix_Errno_EPERM; return 0;}
  2439. #endif /* ndef EPERM */
  2440. #ifdef EPFNOSUPPORT
  2441. if (x == EPFNOSUPPORT)
  2442. {*r = Mono_Posix_Errno_EPFNOSUPPORT; return 0;}
  2443. #endif /* ndef EPFNOSUPPORT */
  2444. #ifdef EPIPE
  2445. if (x == EPIPE)
  2446. {*r = Mono_Posix_Errno_EPIPE; return 0;}
  2447. #endif /* ndef EPIPE */
  2448. #ifdef EPROCLIM
  2449. if (x == EPROCLIM)
  2450. {*r = Mono_Posix_Errno_EPROCLIM; return 0;}
  2451. #endif /* ndef EPROCLIM */
  2452. #ifdef EPROCUNAVAIL
  2453. if (x == EPROCUNAVAIL)
  2454. {*r = Mono_Posix_Errno_EPROCUNAVAIL; return 0;}
  2455. #endif /* ndef EPROCUNAVAIL */
  2456. #ifdef EPROGMISMATCH
  2457. if (x == EPROGMISMATCH)
  2458. {*r = Mono_Posix_Errno_EPROGMISMATCH; return 0;}
  2459. #endif /* ndef EPROGMISMATCH */
  2460. #ifdef EPROGUNAVAIL
  2461. if (x == EPROGUNAVAIL)
  2462. {*r = Mono_Posix_Errno_EPROGUNAVAIL; return 0;}
  2463. #endif /* ndef EPROGUNAVAIL */
  2464. #ifdef EPROTO
  2465. if (x == EPROTO)
  2466. {*r = Mono_Posix_Errno_EPROTO; return 0;}
  2467. #endif /* ndef EPROTO */
  2468. #ifdef EPROTONOSUPPORT
  2469. if (x == EPROTONOSUPPORT)
  2470. {*r = Mono_Posix_Errno_EPROTONOSUPPORT; return 0;}
  2471. #endif /* ndef EPROTONOSUPPORT */
  2472. #ifdef EPROTOTYPE
  2473. if (x == EPROTOTYPE)
  2474. {*r = Mono_Posix_Errno_EPROTOTYPE; return 0;}
  2475. #endif /* ndef EPROTOTYPE */
  2476. #ifdef EPWROFF
  2477. if (x == EPWROFF)
  2478. {*r = Mono_Posix_Errno_EPWROFF; return 0;}
  2479. #endif /* ndef EPWROFF */
  2480. #ifdef ERANGE
  2481. if (x == ERANGE)
  2482. {*r = Mono_Posix_Errno_ERANGE; return 0;}
  2483. #endif /* ndef ERANGE */
  2484. #ifdef EREMCHG
  2485. if (x == EREMCHG)
  2486. {*r = Mono_Posix_Errno_EREMCHG; return 0;}
  2487. #endif /* ndef EREMCHG */
  2488. #ifdef EREMOTE
  2489. if (x == EREMOTE)
  2490. {*r = Mono_Posix_Errno_EREMOTE; return 0;}
  2491. #endif /* ndef EREMOTE */
  2492. #ifdef EREMOTEIO
  2493. if (x == EREMOTEIO)
  2494. {*r = Mono_Posix_Errno_EREMOTEIO; return 0;}
  2495. #endif /* ndef EREMOTEIO */
  2496. #ifdef ERESTART
  2497. if (x == ERESTART)
  2498. {*r = Mono_Posix_Errno_ERESTART; return 0;}
  2499. #endif /* ndef ERESTART */
  2500. #ifdef EROFS
  2501. if (x == EROFS)
  2502. {*r = Mono_Posix_Errno_EROFS; return 0;}
  2503. #endif /* ndef EROFS */
  2504. #ifdef ERPCMISMATCH
  2505. if (x == ERPCMISMATCH)
  2506. {*r = Mono_Posix_Errno_ERPCMISMATCH; return 0;}
  2507. #endif /* ndef ERPCMISMATCH */
  2508. #ifdef ESHLIBVERS
  2509. if (x == ESHLIBVERS)
  2510. {*r = Mono_Posix_Errno_ESHLIBVERS; return 0;}
  2511. #endif /* ndef ESHLIBVERS */
  2512. #ifdef ESHUTDOWN
  2513. if (x == ESHUTDOWN)
  2514. {*r = Mono_Posix_Errno_ESHUTDOWN; return 0;}
  2515. #endif /* ndef ESHUTDOWN */
  2516. #ifdef ESOCKTNOSUPPORT
  2517. if (x == ESOCKTNOSUPPORT)
  2518. {*r = Mono_Posix_Errno_ESOCKTNOSUPPORT; return 0;}
  2519. #endif /* ndef ESOCKTNOSUPPORT */
  2520. #ifdef ESPIPE
  2521. if (x == ESPIPE)
  2522. {*r = Mono_Posix_Errno_ESPIPE; return 0;}
  2523. #endif /* ndef ESPIPE */
  2524. #ifdef ESRCH
  2525. if (x == ESRCH)
  2526. {*r = Mono_Posix_Errno_ESRCH; return 0;}
  2527. #endif /* ndef ESRCH */
  2528. #ifdef ESRMNT
  2529. if (x == ESRMNT)
  2530. {*r = Mono_Posix_Errno_ESRMNT; return 0;}
  2531. #endif /* ndef ESRMNT */
  2532. #ifdef ESTALE
  2533. if (x == ESTALE)
  2534. {*r = Mono_Posix_Errno_ESTALE; return 0;}
  2535. #endif /* ndef ESTALE */
  2536. #ifdef ESTRPIPE
  2537. if (x == ESTRPIPE)
  2538. {*r = Mono_Posix_Errno_ESTRPIPE; return 0;}
  2539. #endif /* ndef ESTRPIPE */
  2540. #ifdef ETIME
  2541. if (x == ETIME)
  2542. {*r = Mono_Posix_Errno_ETIME; return 0;}
  2543. #endif /* ndef ETIME */
  2544. #ifdef ETIMEDOUT
  2545. if (x == ETIMEDOUT)
  2546. {*r = Mono_Posix_Errno_ETIMEDOUT; return 0;}
  2547. #endif /* ndef ETIMEDOUT */
  2548. #ifdef ETOOMANYREFS
  2549. if (x == ETOOMANYREFS)
  2550. {*r = Mono_Posix_Errno_ETOOMANYREFS; return 0;}
  2551. #endif /* ndef ETOOMANYREFS */
  2552. #ifdef ETXTBSY
  2553. if (x == ETXTBSY)
  2554. {*r = Mono_Posix_Errno_ETXTBSY; return 0;}
  2555. #endif /* ndef ETXTBSY */
  2556. #ifdef EUCLEAN
  2557. if (x == EUCLEAN)
  2558. {*r = Mono_Posix_Errno_EUCLEAN; return 0;}
  2559. #endif /* ndef EUCLEAN */
  2560. #ifdef EUNATCH
  2561. if (x == EUNATCH)
  2562. {*r = Mono_Posix_Errno_EUNATCH; return 0;}
  2563. #endif /* ndef EUNATCH */
  2564. #ifdef EUSERS
  2565. if (x == EUSERS)
  2566. {*r = Mono_Posix_Errno_EUSERS; return 0;}
  2567. #endif /* ndef EUSERS */
  2568. #ifdef EWOULDBLOCK
  2569. if (x == EWOULDBLOCK)
  2570. {*r = Mono_Posix_Errno_EWOULDBLOCK; return 0;}
  2571. #endif /* ndef EWOULDBLOCK */
  2572. #ifdef EXDEV
  2573. if (x == EXDEV)
  2574. {*r = Mono_Posix_Errno_EXDEV; return 0;}
  2575. #endif /* ndef EXDEV */
  2576. #ifdef EXFULL
  2577. if (x == EXFULL)
  2578. {*r = Mono_Posix_Errno_EXFULL; return 0;}
  2579. #endif /* ndef EXFULL */
  2580. errno = EINVAL; return -1;
  2581. }
  2582. int Mono_Posix_FromFcntlCommand (int x, int *r)
  2583. {
  2584. *r = 0;
  2585. if (x == Mono_Posix_FcntlCommand_F_DUPFD)
  2586. #ifdef F_DUPFD
  2587. {*r = F_DUPFD; return 0;}
  2588. #else /* def F_DUPFD */
  2589. {errno = EINVAL; return -1;}
  2590. #endif /* ndef F_DUPFD */
  2591. if (x == Mono_Posix_FcntlCommand_F_GETFD)
  2592. #ifdef F_GETFD
  2593. {*r = F_GETFD; return 0;}
  2594. #else /* def F_GETFD */
  2595. {errno = EINVAL; return -1;}
  2596. #endif /* ndef F_GETFD */
  2597. if (x == Mono_Posix_FcntlCommand_F_GETFL)
  2598. #ifdef F_GETFL
  2599. {*r = F_GETFL; return 0;}
  2600. #else /* def F_GETFL */
  2601. {errno = EINVAL; return -1;}
  2602. #endif /* ndef F_GETFL */
  2603. if (x == Mono_Posix_FcntlCommand_F_GETLEASE)
  2604. #ifdef F_GETLEASE
  2605. {*r = F_GETLEASE; return 0;}
  2606. #else /* def F_GETLEASE */
  2607. {errno = EINVAL; return -1;}
  2608. #endif /* ndef F_GETLEASE */
  2609. if (x == Mono_Posix_FcntlCommand_F_GETLK)
  2610. #ifdef F_GETLK
  2611. {*r = F_GETLK; return 0;}
  2612. #else /* def F_GETLK */
  2613. {errno = EINVAL; return -1;}
  2614. #endif /* ndef F_GETLK */
  2615. if (x == Mono_Posix_FcntlCommand_F_GETOWN)
  2616. #ifdef F_GETOWN
  2617. {*r = F_GETOWN; return 0;}
  2618. #else /* def F_GETOWN */
  2619. {errno = EINVAL; return -1;}
  2620. #endif /* ndef F_GETOWN */
  2621. if (x == Mono_Posix_FcntlCommand_F_GETSIG)
  2622. #ifdef F_GETSIG
  2623. {*r = F_GETSIG; return 0;}
  2624. #else /* def F_GETSIG */
  2625. {errno = EINVAL; return -1;}
  2626. #endif /* ndef F_GETSIG */
  2627. if (x == Mono_Posix_FcntlCommand_F_NOCACHE)
  2628. #ifdef F_NOCACHE
  2629. {*r = F_NOCACHE; return 0;}
  2630. #else /* def F_NOCACHE */
  2631. {errno = EINVAL; return -1;}
  2632. #endif /* ndef F_NOCACHE */
  2633. if (x == Mono_Posix_FcntlCommand_F_NOTIFY)
  2634. #ifdef F_NOTIFY
  2635. {*r = F_NOTIFY; return 0;}
  2636. #else /* def F_NOTIFY */
  2637. {errno = EINVAL; return -1;}
  2638. #endif /* ndef F_NOTIFY */
  2639. if (x == Mono_Posix_FcntlCommand_F_SETFD)
  2640. #ifdef F_SETFD
  2641. {*r = F_SETFD; return 0;}
  2642. #else /* def F_SETFD */
  2643. {errno = EINVAL; return -1;}
  2644. #endif /* ndef F_SETFD */
  2645. if (x == Mono_Posix_FcntlCommand_F_SETFL)
  2646. #ifdef F_SETFL
  2647. {*r = F_SETFL; return 0;}
  2648. #else /* def F_SETFL */
  2649. {errno = EINVAL; return -1;}
  2650. #endif /* ndef F_SETFL */
  2651. if (x == Mono_Posix_FcntlCommand_F_SETLEASE)
  2652. #ifdef F_SETLEASE
  2653. {*r = F_SETLEASE; return 0;}
  2654. #else /* def F_SETLEASE */
  2655. {errno = EINVAL; return -1;}
  2656. #endif /* ndef F_SETLEASE */
  2657. if (x == Mono_Posix_FcntlCommand_F_SETLK)
  2658. #ifdef F_SETLK
  2659. {*r = F_SETLK; return 0;}
  2660. #else /* def F_SETLK */
  2661. {errno = EINVAL; return -1;}
  2662. #endif /* ndef F_SETLK */
  2663. if (x == Mono_Posix_FcntlCommand_F_SETLKW)
  2664. #ifdef F_SETLKW
  2665. {*r = F_SETLKW; return 0;}
  2666. #else /* def F_SETLKW */
  2667. {errno = EINVAL; return -1;}
  2668. #endif /* ndef F_SETLKW */
  2669. if (x == Mono_Posix_FcntlCommand_F_SETOWN)
  2670. #ifdef F_SETOWN
  2671. {*r = F_SETOWN; return 0;}
  2672. #else /* def F_SETOWN */
  2673. {errno = EINVAL; return -1;}
  2674. #endif /* ndef F_SETOWN */
  2675. if (x == Mono_Posix_FcntlCommand_F_SETSIG)
  2676. #ifdef F_SETSIG
  2677. {*r = F_SETSIG; return 0;}
  2678. #else /* def F_SETSIG */
  2679. {errno = EINVAL; return -1;}
  2680. #endif /* ndef F_SETSIG */
  2681. if (x == 0)
  2682. return 0;
  2683. errno = EINVAL; return -1;
  2684. }
  2685. int Mono_Posix_ToFcntlCommand (int x, int *r)
  2686. {
  2687. *r = 0;
  2688. if (x == 0)
  2689. return 0;
  2690. #ifdef F_DUPFD
  2691. if (x == F_DUPFD)
  2692. {*r = Mono_Posix_FcntlCommand_F_DUPFD; return 0;}
  2693. #endif /* ndef F_DUPFD */
  2694. #ifdef F_GETFD
  2695. if (x == F_GETFD)
  2696. {*r = Mono_Posix_FcntlCommand_F_GETFD; return 0;}
  2697. #endif /* ndef F_GETFD */
  2698. #ifdef F_GETFL
  2699. if (x == F_GETFL)
  2700. {*r = Mono_Posix_FcntlCommand_F_GETFL; return 0;}
  2701. #endif /* ndef F_GETFL */
  2702. #ifdef F_GETLEASE
  2703. if (x == F_GETLEASE)
  2704. {*r = Mono_Posix_FcntlCommand_F_GETLEASE; return 0;}
  2705. #endif /* ndef F_GETLEASE */
  2706. #ifdef F_GETLK
  2707. if (x == F_GETLK)
  2708. {*r = Mono_Posix_FcntlCommand_F_GETLK; return 0;}
  2709. #endif /* ndef F_GETLK */
  2710. #ifdef F_GETOWN
  2711. if (x == F_GETOWN)
  2712. {*r = Mono_Posix_FcntlCommand_F_GETOWN; return 0;}
  2713. #endif /* ndef F_GETOWN */
  2714. #ifdef F_GETSIG
  2715. if (x == F_GETSIG)
  2716. {*r = Mono_Posix_FcntlCommand_F_GETSIG; return 0;}
  2717. #endif /* ndef F_GETSIG */
  2718. #ifdef F_NOCACHE
  2719. if (x == F_NOCACHE)
  2720. {*r = Mono_Posix_FcntlCommand_F_NOCACHE; return 0;}
  2721. #endif /* ndef F_NOCACHE */
  2722. #ifdef F_NOTIFY
  2723. if (x == F_NOTIFY)
  2724. {*r = Mono_Posix_FcntlCommand_F_NOTIFY; return 0;}
  2725. #endif /* ndef F_NOTIFY */
  2726. #ifdef F_SETFD
  2727. if (x == F_SETFD)
  2728. {*r = Mono_Posix_FcntlCommand_F_SETFD; return 0;}
  2729. #endif /* ndef F_SETFD */
  2730. #ifdef F_SETFL
  2731. if (x == F_SETFL)
  2732. {*r = Mono_Posix_FcntlCommand_F_SETFL; return 0;}
  2733. #endif /* ndef F_SETFL */
  2734. #ifdef F_SETLEASE
  2735. if (x == F_SETLEASE)
  2736. {*r = Mono_Posix_FcntlCommand_F_SETLEASE; return 0;}
  2737. #endif /* ndef F_SETLEASE */
  2738. #ifdef F_SETLK
  2739. if (x == F_SETLK)
  2740. {*r = Mono_Posix_FcntlCommand_F_SETLK; return 0;}
  2741. #endif /* ndef F_SETLK */
  2742. #ifdef F_SETLKW
  2743. if (x == F_SETLKW)
  2744. {*r = Mono_Posix_FcntlCommand_F_SETLKW; return 0;}
  2745. #endif /* ndef F_SETLKW */
  2746. #ifdef F_SETOWN
  2747. if (x == F_SETOWN)
  2748. {*r = Mono_Posix_FcntlCommand_F_SETOWN; return 0;}
  2749. #endif /* ndef F_SETOWN */
  2750. #ifdef F_SETSIG
  2751. if (x == F_SETSIG)
  2752. {*r = Mono_Posix_FcntlCommand_F_SETSIG; return 0;}
  2753. #endif /* ndef F_SETSIG */
  2754. errno = EINVAL; return -1;
  2755. }
  2756. int Mono_Posix_FromFilePermissions (unsigned int x, unsigned int *r)
  2757. {
  2758. *r = 0;
  2759. if ((x & Mono_Posix_FilePermissions_ACCESSPERMS) == Mono_Posix_FilePermissions_ACCESSPERMS)
  2760. #ifdef ACCESSPERMS
  2761. *r |= ACCESSPERMS;
  2762. #else /* def ACCESSPERMS */
  2763. {/* Ignoring Mono_Posix_FilePermissions_ACCESSPERMS, as it is constructed from other values */}
  2764. #endif /* ndef ACCESSPERMS */
  2765. if ((x & Mono_Posix_FilePermissions_ALLPERMS) == Mono_Posix_FilePermissions_ALLPERMS)
  2766. #ifdef ALLPERMS
  2767. *r |= ALLPERMS;
  2768. #else /* def ALLPERMS */
  2769. {/* Ignoring Mono_Posix_FilePermissions_ALLPERMS, as it is constructed from other values */}
  2770. #endif /* ndef ALLPERMS */
  2771. if ((x & Mono_Posix_FilePermissions_DEFFILEMODE) == Mono_Posix_FilePermissions_DEFFILEMODE)
  2772. #ifdef DEFFILEMODE
  2773. *r |= DEFFILEMODE;
  2774. #else /* def DEFFILEMODE */
  2775. {/* Ignoring Mono_Posix_FilePermissions_DEFFILEMODE, as it is constructed from other values */}
  2776. #endif /* ndef DEFFILEMODE */
  2777. if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFBLK)
  2778. #ifdef S_IFBLK
  2779. *r |= S_IFBLK;
  2780. #else /* def S_IFBLK */
  2781. {errno = EINVAL; return -1;}
  2782. #endif /* ndef S_IFBLK */
  2783. if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFCHR)
  2784. #ifdef S_IFCHR
  2785. *r |= S_IFCHR;
  2786. #else /* def S_IFCHR */
  2787. {errno = EINVAL; return -1;}
  2788. #endif /* ndef S_IFCHR */
  2789. if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFDIR)
  2790. #ifdef S_IFDIR
  2791. *r |= S_IFDIR;
  2792. #else /* def S_IFDIR */
  2793. {errno = EINVAL; return -1;}
  2794. #endif /* ndef S_IFDIR */
  2795. if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFIFO)
  2796. #ifdef S_IFIFO
  2797. *r |= S_IFIFO;
  2798. #else /* def S_IFIFO */
  2799. {errno = EINVAL; return -1;}
  2800. #endif /* ndef S_IFIFO */
  2801. if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFLNK)
  2802. #ifdef S_IFLNK
  2803. *r |= S_IFLNK;
  2804. #else /* def S_IFLNK */
  2805. {errno = EINVAL; return -1;}
  2806. #endif /* ndef S_IFLNK */
  2807. if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFMT)
  2808. #ifdef S_IFMT
  2809. *r |= S_IFMT;
  2810. #else /* def S_IFMT */
  2811. {/* Ignoring Mono_Posix_FilePermissions_S_IFMT, as it is constructed from other values */}
  2812. #endif /* ndef S_IFMT */
  2813. if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFREG)
  2814. #ifdef S_IFREG
  2815. *r |= S_IFREG;
  2816. #else /* def S_IFREG */
  2817. {errno = EINVAL; return -1;}
  2818. #endif /* ndef S_IFREG */
  2819. if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFSOCK)
  2820. #ifdef S_IFSOCK
  2821. *r |= S_IFSOCK;
  2822. #else /* def S_IFSOCK */
  2823. {errno = EINVAL; return -1;}
  2824. #endif /* ndef S_IFSOCK */
  2825. if ((x & Mono_Posix_FilePermissions_S_IRGRP) == Mono_Posix_FilePermissions_S_IRGRP)
  2826. #ifdef S_IRGRP
  2827. *r |= S_IRGRP;
  2828. #else /* def S_IRGRP */
  2829. {errno = EINVAL; return -1;}
  2830. #endif /* ndef S_IRGRP */
  2831. if ((x & Mono_Posix_FilePermissions_S_IROTH) == Mono_Posix_FilePermissions_S_IROTH)
  2832. #ifdef S_IROTH
  2833. *r |= S_IROTH;
  2834. #else /* def S_IROTH */
  2835. {errno = EINVAL; return -1;}
  2836. #endif /* ndef S_IROTH */
  2837. if ((x & Mono_Posix_FilePermissions_S_IRUSR) == Mono_Posix_FilePermissions_S_IRUSR)
  2838. #ifdef S_IRUSR
  2839. *r |= S_IRUSR;
  2840. #else /* def S_IRUSR */
  2841. {errno = EINVAL; return -1;}
  2842. #endif /* ndef S_IRUSR */
  2843. if ((x & Mono_Posix_FilePermissions_S_IRWXG) == Mono_Posix_FilePermissions_S_IRWXG)
  2844. #ifdef S_IRWXG
  2845. *r |= S_IRWXG;
  2846. #else /* def S_IRWXG */
  2847. {/* Ignoring Mono_Posix_FilePermissions_S_IRWXG, as it is constructed from other values */}
  2848. #endif /* ndef S_IRWXG */
  2849. if ((x & Mono_Posix_FilePermissions_S_IRWXO) == Mono_Posix_FilePermissions_S_IRWXO)
  2850. #ifdef S_IRWXO
  2851. *r |= S_IRWXO;
  2852. #else /* def S_IRWXO */
  2853. {/* Ignoring Mono_Posix_FilePermissions_S_IRWXO, as it is constructed from other values */}
  2854. #endif /* ndef S_IRWXO */
  2855. if ((x & Mono_Posix_FilePermissions_S_IRWXU) == Mono_Posix_FilePermissions_S_IRWXU)
  2856. #ifdef S_IRWXU
  2857. *r |= S_IRWXU;
  2858. #else /* def S_IRWXU */
  2859. {/* Ignoring Mono_Posix_FilePermissions_S_IRWXU, as it is constructed from other values */}
  2860. #endif /* ndef S_IRWXU */
  2861. if ((x & Mono_Posix_FilePermissions_S_ISGID) == Mono_Posix_FilePermissions_S_ISGID)
  2862. #ifdef S_ISGID
  2863. *r |= S_ISGID;
  2864. #else /* def S_ISGID */
  2865. {errno = EINVAL; return -1;}
  2866. #endif /* ndef S_ISGID */
  2867. if ((x & Mono_Posix_FilePermissions_S_ISUID) == Mono_Posix_FilePermissions_S_ISUID)
  2868. #ifdef S_ISUID
  2869. *r |= S_ISUID;
  2870. #else /* def S_ISUID */
  2871. {errno = EINVAL; return -1;}
  2872. #endif /* ndef S_ISUID */
  2873. if ((x & Mono_Posix_FilePermissions_S_ISVTX) == Mono_Posix_FilePermissions_S_ISVTX)
  2874. #ifdef S_ISVTX
  2875. *r |= S_ISVTX;
  2876. #else /* def S_ISVTX */
  2877. {errno = EINVAL; return -1;}
  2878. #endif /* ndef S_ISVTX */
  2879. if ((x & Mono_Posix_FilePermissions_S_IWGRP) == Mono_Posix_FilePermissions_S_IWGRP)
  2880. #ifdef S_IWGRP
  2881. *r |= S_IWGRP;
  2882. #else /* def S_IWGRP */
  2883. {errno = EINVAL; return -1;}
  2884. #endif /* ndef S_IWGRP */
  2885. if ((x & Mono_Posix_FilePermissions_S_IWOTH) == Mono_Posix_FilePermissions_S_IWOTH)
  2886. #ifdef S_IWOTH
  2887. *r |= S_IWOTH;
  2888. #else /* def S_IWOTH */
  2889. {errno = EINVAL; return -1;}
  2890. #endif /* ndef S_IWOTH */
  2891. if ((x & Mono_Posix_FilePermissions_S_IWUSR) == Mono_Posix_FilePermissions_S_IWUSR)
  2892. #ifdef S_IWUSR
  2893. *r |= S_IWUSR;
  2894. #else /* def S_IWUSR */
  2895. {errno = EINVAL; return -1;}
  2896. #endif /* ndef S_IWUSR */
  2897. if ((x & Mono_Posix_FilePermissions_S_IXGRP) == Mono_Posix_FilePermissions_S_IXGRP)
  2898. #ifdef S_IXGRP
  2899. *r |= S_IXGRP;
  2900. #else /* def S_IXGRP */
  2901. {errno = EINVAL; return -1;}
  2902. #endif /* ndef S_IXGRP */
  2903. if ((x & Mono_Posix_FilePermissions_S_IXOTH) == Mono_Posix_FilePermissions_S_IXOTH)
  2904. #ifdef S_IXOTH
  2905. *r |= S_IXOTH;
  2906. #else /* def S_IXOTH */
  2907. {errno = EINVAL; return -1;}
  2908. #endif /* ndef S_IXOTH */
  2909. if ((x & Mono_Posix_FilePermissions_S_IXUSR) == Mono_Posix_FilePermissions_S_IXUSR)
  2910. #ifdef S_IXUSR
  2911. *r |= S_IXUSR;
  2912. #else /* def S_IXUSR */
  2913. {errno = EINVAL; return -1;}
  2914. #endif /* ndef S_IXUSR */
  2915. if (x == 0)
  2916. return 0;
  2917. return 0;
  2918. }
  2919. int Mono_Posix_ToFilePermissions (unsigned int x, unsigned int *r)
  2920. {
  2921. *r = 0;
  2922. if (x == 0)
  2923. return 0;
  2924. #ifdef ACCESSPERMS
  2925. if ((x & ACCESSPERMS) == ACCESSPERMS)
  2926. *r |= Mono_Posix_FilePermissions_ACCESSPERMS;
  2927. #endif /* ndef ACCESSPERMS */
  2928. #ifdef ALLPERMS
  2929. if ((x & ALLPERMS) == ALLPERMS)
  2930. *r |= Mono_Posix_FilePermissions_ALLPERMS;
  2931. #endif /* ndef ALLPERMS */
  2932. #ifdef DEFFILEMODE
  2933. if ((x & DEFFILEMODE) == DEFFILEMODE)
  2934. *r |= Mono_Posix_FilePermissions_DEFFILEMODE;
  2935. #endif /* ndef DEFFILEMODE */
  2936. #ifdef S_IFBLK
  2937. if ((x & S_IFMT) == S_IFBLK)
  2938. *r |= Mono_Posix_FilePermissions_S_IFBLK;
  2939. #endif /* ndef S_IFBLK */
  2940. #ifdef S_IFCHR
  2941. if ((x & S_IFMT) == S_IFCHR)
  2942. *r |= Mono_Posix_FilePermissions_S_IFCHR;
  2943. #endif /* ndef S_IFCHR */
  2944. #ifdef S_IFDIR
  2945. if ((x & S_IFMT) == S_IFDIR)
  2946. *r |= Mono_Posix_FilePermissions_S_IFDIR;
  2947. #endif /* ndef S_IFDIR */
  2948. #ifdef S_IFIFO
  2949. if ((x & S_IFMT) == S_IFIFO)
  2950. *r |= Mono_Posix_FilePermissions_S_IFIFO;
  2951. #endif /* ndef S_IFIFO */
  2952. #ifdef S_IFLNK
  2953. if ((x & S_IFMT) == S_IFLNK)
  2954. *r |= Mono_Posix_FilePermissions_S_IFLNK;
  2955. #endif /* ndef S_IFLNK */
  2956. #ifdef S_IFMT
  2957. if ((x & S_IFMT) == S_IFMT)
  2958. *r |= Mono_Posix_FilePermissions_S_IFMT;
  2959. #endif /* ndef S_IFMT */
  2960. #ifdef S_IFREG
  2961. if ((x & S_IFMT) == S_IFREG)
  2962. *r |= Mono_Posix_FilePermissions_S_IFREG;
  2963. #endif /* ndef S_IFREG */
  2964. #ifdef S_IFSOCK
  2965. if ((x & S_IFMT) == S_IFSOCK)
  2966. *r |= Mono_Posix_FilePermissions_S_IFSOCK;
  2967. #endif /* ndef S_IFSOCK */
  2968. #ifdef S_IRGRP
  2969. if ((x & S_IRGRP) == S_IRGRP)
  2970. *r |= Mono_Posix_FilePermissions_S_IRGRP;
  2971. #endif /* ndef S_IRGRP */
  2972. #ifdef S_IROTH
  2973. if ((x & S_IROTH) == S_IROTH)
  2974. *r |= Mono_Posix_FilePermissions_S_IROTH;
  2975. #endif /* ndef S_IROTH */
  2976. #ifdef S_IRUSR
  2977. if ((x & S_IRUSR) == S_IRUSR)
  2978. *r |= Mono_Posix_FilePermissions_S_IRUSR;
  2979. #endif /* ndef S_IRUSR */
  2980. #ifdef S_IRWXG
  2981. if ((x & S_IRWXG) == S_IRWXG)
  2982. *r |= Mono_Posix_FilePermissions_S_IRWXG;
  2983. #endif /* ndef S_IRWXG */
  2984. #ifdef S_IRWXO
  2985. if ((x & S_IRWXO) == S_IRWXO)
  2986. *r |= Mono_Posix_FilePermissions_S_IRWXO;
  2987. #endif /* ndef S_IRWXO */
  2988. #ifdef S_IRWXU
  2989. if ((x & S_IRWXU) == S_IRWXU)
  2990. *r |= Mono_Posix_FilePermissions_S_IRWXU;
  2991. #endif /* ndef S_IRWXU */
  2992. #ifdef S_ISGID
  2993. if ((x & S_ISGID) == S_ISGID)
  2994. *r |= Mono_Posix_FilePermissions_S_ISGID;
  2995. #endif /* ndef S_ISGID */
  2996. #ifdef S_ISUID
  2997. if ((x & S_ISUID) == S_ISUID)
  2998. *r |= Mono_Posix_FilePermissions_S_ISUID;
  2999. #endif /* ndef S_ISUID */
  3000. #ifdef S_ISVTX
  3001. if ((x & S_ISVTX) == S_ISVTX)
  3002. *r |= Mono_Posix_FilePermissions_S_ISVTX;
  3003. #endif /* ndef S_ISVTX */
  3004. #ifdef S_IWGRP
  3005. if ((x & S_IWGRP) == S_IWGRP)
  3006. *r |= Mono_Posix_FilePermissions_S_IWGRP;
  3007. #endif /* ndef S_IWGRP */
  3008. #ifdef S_IWOTH
  3009. if ((x & S_IWOTH) == S_IWOTH)
  3010. *r |= Mono_Posix_FilePermissions_S_IWOTH;
  3011. #endif /* ndef S_IWOTH */
  3012. #ifdef S_IWUSR
  3013. if ((x & S_IWUSR) == S_IWUSR)
  3014. *r |= Mono_Posix_FilePermissions_S_IWUSR;
  3015. #endif /* ndef S_IWUSR */
  3016. #ifdef S_IXGRP
  3017. if ((x & S_IXGRP) == S_IXGRP)
  3018. *r |= Mono_Posix_FilePermissions_S_IXGRP;
  3019. #endif /* ndef S_IXGRP */
  3020. #ifdef S_IXOTH
  3021. if ((x & S_IXOTH) == S_IXOTH)
  3022. *r |= Mono_Posix_FilePermissions_S_IXOTH;
  3023. #endif /* ndef S_IXOTH */
  3024. #ifdef S_IXUSR
  3025. if ((x & S_IXUSR) == S_IXUSR)
  3026. *r |= Mono_Posix_FilePermissions_S_IXUSR;
  3027. #endif /* ndef S_IXUSR */
  3028. return 0;
  3029. }
  3030. #ifdef HAVE_STRUCT_FLOCK
  3031. int
  3032. Mono_Posix_FromFlock (struct Mono_Posix_Flock *from, struct flock *to)
  3033. {
  3034. _cnm_return_val_if_overflow (off_t, from->l_start, -1);
  3035. _cnm_return_val_if_overflow (off_t, from->l_len, -1);
  3036. _cnm_return_val_if_overflow (pid_t, from->l_pid, -1);
  3037. memset (to, 0, sizeof(*to));
  3038. if (Mono_Posix_FromLockType (from->l_type, &to->l_type) != 0) {
  3039. return -1;
  3040. }
  3041. if (Mono_Posix_FromSeekFlags (from->l_whence, &to->l_whence) != 0) {
  3042. return -1;
  3043. }
  3044. to->l_start = from->l_start;
  3045. to->l_len = from->l_len;
  3046. to->l_pid = from->l_pid;
  3047. return 0;
  3048. }
  3049. #endif /* ndef HAVE_STRUCT_FLOCK */
  3050. #ifdef HAVE_STRUCT_FLOCK
  3051. int
  3052. Mono_Posix_ToFlock (struct flock *from, struct Mono_Posix_Flock *to)
  3053. {
  3054. _cnm_return_val_if_overflow (gint64, from->l_start, -1);
  3055. _cnm_return_val_if_overflow (gint64, from->l_len, -1);
  3056. _cnm_return_val_if_overflow (int, from->l_pid, -1);
  3057. memset (to, 0, sizeof(*to));
  3058. if (Mono_Posix_ToLockType (from->l_type, &to->l_type) != 0) {
  3059. return -1;
  3060. }
  3061. if (Mono_Posix_ToSeekFlags (from->l_whence, &to->l_whence) != 0) {
  3062. return -1;
  3063. }
  3064. to->l_start = from->l_start;
  3065. to->l_len = from->l_len;
  3066. to->l_pid = from->l_pid;
  3067. return 0;
  3068. }
  3069. #endif /* ndef HAVE_STRUCT_FLOCK */
  3070. #ifdef HAVE_STRUCT_IOVEC
  3071. int
  3072. Mono_Posix_FromIovec (struct Mono_Posix_Iovec *from, struct iovec *to)
  3073. {
  3074. _cnm_return_val_if_overflow (guint64, from->iov_len, -1);
  3075. memset (to, 0, sizeof(*to));
  3076. to->iov_base = from->iov_base;
  3077. to->iov_len = from->iov_len;
  3078. return 0;
  3079. }
  3080. #endif /* ndef HAVE_STRUCT_IOVEC */
  3081. #ifdef HAVE_STRUCT_IOVEC
  3082. int
  3083. Mono_Posix_ToIovec (struct iovec *from, struct Mono_Posix_Iovec *to)
  3084. {
  3085. _cnm_return_val_if_overflow (guint64, from->iov_len, -1);
  3086. memset (to, 0, sizeof(*to));
  3087. to->iov_base = from->iov_base;
  3088. to->iov_len = from->iov_len;
  3089. return 0;
  3090. }
  3091. #endif /* ndef HAVE_STRUCT_IOVEC */
  3092. #ifdef HAVE_STRUCT_LINGER
  3093. int
  3094. Mono_Posix_FromLinger (struct Mono_Posix_Linger *from, struct linger *to)
  3095. {
  3096. _cnm_return_val_if_overflow (int, from->l_onoff, -1);
  3097. _cnm_return_val_if_overflow (int, from->l_linger, -1);
  3098. memset (to, 0, sizeof(*to));
  3099. to->l_onoff = from->l_onoff;
  3100. to->l_linger = from->l_linger;
  3101. return 0;
  3102. }
  3103. #endif /* ndef HAVE_STRUCT_LINGER */
  3104. #ifdef HAVE_STRUCT_LINGER
  3105. int
  3106. Mono_Posix_ToLinger (struct linger *from, struct Mono_Posix_Linger *to)
  3107. {
  3108. _cnm_return_val_if_overflow (int, from->l_onoff, -1);
  3109. _cnm_return_val_if_overflow (int, from->l_linger, -1);
  3110. memset (to, 0, sizeof(*to));
  3111. to->l_onoff = from->l_onoff;
  3112. to->l_linger = from->l_linger;
  3113. return 0;
  3114. }
  3115. #endif /* ndef HAVE_STRUCT_LINGER */
  3116. int Mono_Posix_FromLockType (short x, short *r)
  3117. {
  3118. *r = 0;
  3119. if (x == Mono_Posix_LockType_F_RDLCK)
  3120. #ifdef F_RDLCK
  3121. {*r = F_RDLCK; return 0;}
  3122. #else /* def F_RDLCK */
  3123. {errno = EINVAL; return -1;}
  3124. #endif /* ndef F_RDLCK */
  3125. if (x == Mono_Posix_LockType_F_UNLCK)
  3126. #ifdef F_UNLCK
  3127. {*r = F_UNLCK; return 0;}
  3128. #else /* def F_UNLCK */
  3129. {errno = EINVAL; return -1;}
  3130. #endif /* ndef F_UNLCK */
  3131. if (x == Mono_Posix_LockType_F_WRLCK)
  3132. #ifdef F_WRLCK
  3133. {*r = F_WRLCK; return 0;}
  3134. #else /* def F_WRLCK */
  3135. {errno = EINVAL; return -1;}
  3136. #endif /* ndef F_WRLCK */
  3137. if (x == 0)
  3138. return 0;
  3139. errno = EINVAL; return -1;
  3140. }
  3141. int Mono_Posix_ToLockType (short x, short *r)
  3142. {
  3143. *r = 0;
  3144. if (x == 0)
  3145. return 0;
  3146. #ifdef F_RDLCK
  3147. if (x == F_RDLCK)
  3148. {*r = Mono_Posix_LockType_F_RDLCK; return 0;}
  3149. #endif /* ndef F_RDLCK */
  3150. #ifdef F_UNLCK
  3151. if (x == F_UNLCK)
  3152. {*r = Mono_Posix_LockType_F_UNLCK; return 0;}
  3153. #endif /* ndef F_UNLCK */
  3154. #ifdef F_WRLCK
  3155. if (x == F_WRLCK)
  3156. {*r = Mono_Posix_LockType_F_WRLCK; return 0;}
  3157. #endif /* ndef F_WRLCK */
  3158. errno = EINVAL; return -1;
  3159. }
  3160. int Mono_Posix_FromLockfCommand (int x, int *r)
  3161. {
  3162. *r = 0;
  3163. if (x == Mono_Posix_LockfCommand_F_LOCK)
  3164. #ifdef F_LOCK
  3165. {*r = F_LOCK; return 0;}
  3166. #else /* def F_LOCK */
  3167. {errno = EINVAL; return -1;}
  3168. #endif /* ndef F_LOCK */
  3169. if (x == Mono_Posix_LockfCommand_F_TEST)
  3170. #ifdef F_TEST
  3171. {*r = F_TEST; return 0;}
  3172. #else /* def F_TEST */
  3173. {errno = EINVAL; return -1;}
  3174. #endif /* ndef F_TEST */
  3175. if (x == Mono_Posix_LockfCommand_F_TLOCK)
  3176. #ifdef F_TLOCK
  3177. {*r = F_TLOCK; return 0;}
  3178. #else /* def F_TLOCK */
  3179. {errno = EINVAL; return -1;}
  3180. #endif /* ndef F_TLOCK */
  3181. if (x == Mono_Posix_LockfCommand_F_ULOCK)
  3182. #ifdef F_ULOCK
  3183. {*r = F_ULOCK; return 0;}
  3184. #else /* def F_ULOCK */
  3185. {errno = EINVAL; return -1;}
  3186. #endif /* ndef F_ULOCK */
  3187. if (x == 0)
  3188. return 0;
  3189. errno = EINVAL; return -1;
  3190. }
  3191. int Mono_Posix_ToLockfCommand (int x, int *r)
  3192. {
  3193. *r = 0;
  3194. if (x == 0)
  3195. return 0;
  3196. #ifdef F_LOCK
  3197. if (x == F_LOCK)
  3198. {*r = Mono_Posix_LockfCommand_F_LOCK; return 0;}
  3199. #endif /* ndef F_LOCK */
  3200. #ifdef F_TEST
  3201. if (x == F_TEST)
  3202. {*r = Mono_Posix_LockfCommand_F_TEST; return 0;}
  3203. #endif /* ndef F_TEST */
  3204. #ifdef F_TLOCK
  3205. if (x == F_TLOCK)
  3206. {*r = Mono_Posix_LockfCommand_F_TLOCK; return 0;}
  3207. #endif /* ndef F_TLOCK */
  3208. #ifdef F_ULOCK
  3209. if (x == F_ULOCK)
  3210. {*r = Mono_Posix_LockfCommand_F_ULOCK; return 0;}
  3211. #endif /* ndef F_ULOCK */
  3212. errno = EINVAL; return -1;
  3213. }
  3214. int Mono_Posix_FromMessageFlags (int x, int *r)
  3215. {
  3216. *r = 0;
  3217. if ((x & Mono_Posix_MessageFlags_MSG_CMSG_CLOEXEC) == Mono_Posix_MessageFlags_MSG_CMSG_CLOEXEC)
  3218. #ifdef MSG_CMSG_CLOEXEC
  3219. *r |= MSG_CMSG_CLOEXEC;
  3220. #else /* def MSG_CMSG_CLOEXEC */
  3221. {errno = EINVAL; return -1;}
  3222. #endif /* ndef MSG_CMSG_CLOEXEC */
  3223. if ((x & Mono_Posix_MessageFlags_MSG_CONFIRM) == Mono_Posix_MessageFlags_MSG_CONFIRM)
  3224. #ifdef MSG_CONFIRM
  3225. *r |= MSG_CONFIRM;
  3226. #else /* def MSG_CONFIRM */
  3227. {errno = EINVAL; return -1;}
  3228. #endif /* ndef MSG_CONFIRM */
  3229. if ((x & Mono_Posix_MessageFlags_MSG_CTRUNC) == Mono_Posix_MessageFlags_MSG_CTRUNC)
  3230. #ifdef MSG_CTRUNC
  3231. *r |= MSG_CTRUNC;
  3232. #else /* def MSG_CTRUNC */
  3233. {errno = EINVAL; return -1;}
  3234. #endif /* ndef MSG_CTRUNC */
  3235. if ((x & Mono_Posix_MessageFlags_MSG_DONTROUTE) == Mono_Posix_MessageFlags_MSG_DONTROUTE)
  3236. #ifdef MSG_DONTROUTE
  3237. *r |= MSG_DONTROUTE;
  3238. #else /* def MSG_DONTROUTE */
  3239. {errno = EINVAL; return -1;}
  3240. #endif /* ndef MSG_DONTROUTE */
  3241. if ((x & Mono_Posix_MessageFlags_MSG_DONTWAIT) == Mono_Posix_MessageFlags_MSG_DONTWAIT)
  3242. #ifdef MSG_DONTWAIT
  3243. *r |= MSG_DONTWAIT;
  3244. #else /* def MSG_DONTWAIT */
  3245. {errno = EINVAL; return -1;}
  3246. #endif /* ndef MSG_DONTWAIT */
  3247. if ((x & Mono_Posix_MessageFlags_MSG_EOR) == Mono_Posix_MessageFlags_MSG_EOR)
  3248. #ifdef MSG_EOR
  3249. *r |= MSG_EOR;
  3250. #else /* def MSG_EOR */
  3251. {errno = EINVAL; return -1;}
  3252. #endif /* ndef MSG_EOR */
  3253. if ((x & Mono_Posix_MessageFlags_MSG_ERRQUEUE) == Mono_Posix_MessageFlags_MSG_ERRQUEUE)
  3254. #ifdef MSG_ERRQUEUE
  3255. *r |= MSG_ERRQUEUE;
  3256. #else /* def MSG_ERRQUEUE */
  3257. {errno = EINVAL; return -1;}
  3258. #endif /* ndef MSG_ERRQUEUE */
  3259. if ((x & Mono_Posix_MessageFlags_MSG_FASTOPEN) == Mono_Posix_MessageFlags_MSG_FASTOPEN)
  3260. #ifdef MSG_FASTOPEN
  3261. *r |= MSG_FASTOPEN;
  3262. #else /* def MSG_FASTOPEN */
  3263. {errno = EINVAL; return -1;}
  3264. #endif /* ndef MSG_FASTOPEN */
  3265. if ((x & Mono_Posix_MessageFlags_MSG_FIN) == Mono_Posix_MessageFlags_MSG_FIN)
  3266. #ifdef MSG_FIN
  3267. *r |= MSG_FIN;
  3268. #else /* def MSG_FIN */
  3269. {errno = EINVAL; return -1;}
  3270. #endif /* ndef MSG_FIN */
  3271. if ((x & Mono_Posix_MessageFlags_MSG_MORE) == Mono_Posix_MessageFlags_MSG_MORE)
  3272. #ifdef MSG_MORE
  3273. *r |= MSG_MORE;
  3274. #else /* def MSG_MORE */
  3275. {errno = EINVAL; return -1;}
  3276. #endif /* ndef MSG_MORE */
  3277. if ((x & Mono_Posix_MessageFlags_MSG_NOSIGNAL) == Mono_Posix_MessageFlags_MSG_NOSIGNAL)
  3278. #ifdef MSG_NOSIGNAL
  3279. *r |= MSG_NOSIGNAL;
  3280. #else /* def MSG_NOSIGNAL */
  3281. {errno = EINVAL; return -1;}
  3282. #endif /* ndef MSG_NOSIGNAL */
  3283. if ((x & Mono_Posix_MessageFlags_MSG_OOB) == Mono_Posix_MessageFlags_MSG_OOB)
  3284. #ifdef MSG_OOB
  3285. *r |= MSG_OOB;
  3286. #else /* def MSG_OOB */
  3287. {errno = EINVAL; return -1;}
  3288. #endif /* ndef MSG_OOB */
  3289. if ((x & Mono_Posix_MessageFlags_MSG_PEEK) == Mono_Posix_MessageFlags_MSG_PEEK)
  3290. #ifdef MSG_PEEK
  3291. *r |= MSG_PEEK;
  3292. #else /* def MSG_PEEK */
  3293. {errno = EINVAL; return -1;}
  3294. #endif /* ndef MSG_PEEK */
  3295. if ((x & Mono_Posix_MessageFlags_MSG_PROXY) == Mono_Posix_MessageFlags_MSG_PROXY)
  3296. #ifdef MSG_PROXY
  3297. *r |= MSG_PROXY;
  3298. #else /* def MSG_PROXY */
  3299. {errno = EINVAL; return -1;}
  3300. #endif /* ndef MSG_PROXY */
  3301. if ((x & Mono_Posix_MessageFlags_MSG_RST) == Mono_Posix_MessageFlags_MSG_RST)
  3302. #ifdef MSG_RST
  3303. *r |= MSG_RST;
  3304. #else /* def MSG_RST */
  3305. {errno = EINVAL; return -1;}
  3306. #endif /* ndef MSG_RST */
  3307. if ((x & Mono_Posix_MessageFlags_MSG_SYN) == Mono_Posix_MessageFlags_MSG_SYN)
  3308. #ifdef MSG_SYN
  3309. *r |= MSG_SYN;
  3310. #else /* def MSG_SYN */
  3311. {errno = EINVAL; return -1;}
  3312. #endif /* ndef MSG_SYN */
  3313. if ((x & Mono_Posix_MessageFlags_MSG_TRUNC) == Mono_Posix_MessageFlags_MSG_TRUNC)
  3314. #ifdef MSG_TRUNC
  3315. *r |= MSG_TRUNC;
  3316. #else /* def MSG_TRUNC */
  3317. {errno = EINVAL; return -1;}
  3318. #endif /* ndef MSG_TRUNC */
  3319. if ((x & Mono_Posix_MessageFlags_MSG_WAITALL) == Mono_Posix_MessageFlags_MSG_WAITALL)
  3320. #ifdef MSG_WAITALL
  3321. *r |= MSG_WAITALL;
  3322. #else /* def MSG_WAITALL */
  3323. {errno = EINVAL; return -1;}
  3324. #endif /* ndef MSG_WAITALL */
  3325. if ((x & Mono_Posix_MessageFlags_MSG_WAITFORONE) == Mono_Posix_MessageFlags_MSG_WAITFORONE)
  3326. #ifdef MSG_WAITFORONE
  3327. *r |= MSG_WAITFORONE;
  3328. #else /* def MSG_WAITFORONE */
  3329. {errno = EINVAL; return -1;}
  3330. #endif /* ndef MSG_WAITFORONE */
  3331. if (x == 0)
  3332. return 0;
  3333. return 0;
  3334. }
  3335. int Mono_Posix_ToMessageFlags (int x, int *r)
  3336. {
  3337. *r = 0;
  3338. if (x == 0)
  3339. return 0;
  3340. #ifdef MSG_CMSG_CLOEXEC
  3341. if ((x & MSG_CMSG_CLOEXEC) == MSG_CMSG_CLOEXEC)
  3342. *r |= Mono_Posix_MessageFlags_MSG_CMSG_CLOEXEC;
  3343. #endif /* ndef MSG_CMSG_CLOEXEC */
  3344. #ifdef MSG_CONFIRM
  3345. if ((x & MSG_CONFIRM) == MSG_CONFIRM)
  3346. *r |= Mono_Posix_MessageFlags_MSG_CONFIRM;
  3347. #endif /* ndef MSG_CONFIRM */
  3348. #ifdef MSG_CTRUNC
  3349. if ((x & MSG_CTRUNC) == MSG_CTRUNC)
  3350. *r |= Mono_Posix_MessageFlags_MSG_CTRUNC;
  3351. #endif /* ndef MSG_CTRUNC */
  3352. #ifdef MSG_DONTROUTE
  3353. if ((x & MSG_DONTROUTE) == MSG_DONTROUTE)
  3354. *r |= Mono_Posix_MessageFlags_MSG_DONTROUTE;
  3355. #endif /* ndef MSG_DONTROUTE */
  3356. #ifdef MSG_DONTWAIT
  3357. if ((x & MSG_DONTWAIT) == MSG_DONTWAIT)
  3358. *r |= Mono_Posix_MessageFlags_MSG_DONTWAIT;
  3359. #endif /* ndef MSG_DONTWAIT */
  3360. #ifdef MSG_EOR
  3361. if ((x & MSG_EOR) == MSG_EOR)
  3362. *r |= Mono_Posix_MessageFlags_MSG_EOR;
  3363. #endif /* ndef MSG_EOR */
  3364. #ifdef MSG_ERRQUEUE
  3365. if ((x & MSG_ERRQUEUE) == MSG_ERRQUEUE)
  3366. *r |= Mono_Posix_MessageFlags_MSG_ERRQUEUE;
  3367. #endif /* ndef MSG_ERRQUEUE */
  3368. #ifdef MSG_FASTOPEN
  3369. if ((x & MSG_FASTOPEN) == MSG_FASTOPEN)
  3370. *r |= Mono_Posix_MessageFlags_MSG_FASTOPEN;
  3371. #endif /* ndef MSG_FASTOPEN */
  3372. #ifdef MSG_FIN
  3373. if ((x & MSG_FIN) == MSG_FIN)
  3374. *r |= Mono_Posix_MessageFlags_MSG_FIN;
  3375. #endif /* ndef MSG_FIN */
  3376. #ifdef MSG_MORE
  3377. if ((x & MSG_MORE) == MSG_MORE)
  3378. *r |= Mono_Posix_MessageFlags_MSG_MORE;
  3379. #endif /* ndef MSG_MORE */
  3380. #ifdef MSG_NOSIGNAL
  3381. if ((x & MSG_NOSIGNAL) == MSG_NOSIGNAL)
  3382. *r |= Mono_Posix_MessageFlags_MSG_NOSIGNAL;
  3383. #endif /* ndef MSG_NOSIGNAL */
  3384. #ifdef MSG_OOB
  3385. if ((x & MSG_OOB) == MSG_OOB)
  3386. *r |= Mono_Posix_MessageFlags_MSG_OOB;
  3387. #endif /* ndef MSG_OOB */
  3388. #ifdef MSG_PEEK
  3389. if ((x & MSG_PEEK) == MSG_PEEK)
  3390. *r |= Mono_Posix_MessageFlags_MSG_PEEK;
  3391. #endif /* ndef MSG_PEEK */
  3392. #ifdef MSG_PROXY
  3393. if ((x & MSG_PROXY) == MSG_PROXY)
  3394. *r |= Mono_Posix_MessageFlags_MSG_PROXY;
  3395. #endif /* ndef MSG_PROXY */
  3396. #ifdef MSG_RST
  3397. if ((x & MSG_RST) == MSG_RST)
  3398. *r |= Mono_Posix_MessageFlags_MSG_RST;
  3399. #endif /* ndef MSG_RST */
  3400. #ifdef MSG_SYN
  3401. if ((x & MSG_SYN) == MSG_SYN)
  3402. *r |= Mono_Posix_MessageFlags_MSG_SYN;
  3403. #endif /* ndef MSG_SYN */
  3404. #ifdef MSG_TRUNC
  3405. if ((x & MSG_TRUNC) == MSG_TRUNC)
  3406. *r |= Mono_Posix_MessageFlags_MSG_TRUNC;
  3407. #endif /* ndef MSG_TRUNC */
  3408. #ifdef MSG_WAITALL
  3409. if ((x & MSG_WAITALL) == MSG_WAITALL)
  3410. *r |= Mono_Posix_MessageFlags_MSG_WAITALL;
  3411. #endif /* ndef MSG_WAITALL */
  3412. #ifdef MSG_WAITFORONE
  3413. if ((x & MSG_WAITFORONE) == MSG_WAITFORONE)
  3414. *r |= Mono_Posix_MessageFlags_MSG_WAITFORONE;
  3415. #endif /* ndef MSG_WAITFORONE */
  3416. return 0;
  3417. }
  3418. int Mono_Posix_FromMlockallFlags (int x, int *r)
  3419. {
  3420. *r = 0;
  3421. if ((x & Mono_Posix_MlockallFlags_MCL_CURRENT) == Mono_Posix_MlockallFlags_MCL_CURRENT)
  3422. #ifdef MCL_CURRENT
  3423. *r |= MCL_CURRENT;
  3424. #else /* def MCL_CURRENT */
  3425. {errno = EINVAL; return -1;}
  3426. #endif /* ndef MCL_CURRENT */
  3427. if ((x & Mono_Posix_MlockallFlags_MCL_FUTURE) == Mono_Posix_MlockallFlags_MCL_FUTURE)
  3428. #ifdef MCL_FUTURE
  3429. *r |= MCL_FUTURE;
  3430. #else /* def MCL_FUTURE */
  3431. {errno = EINVAL; return -1;}
  3432. #endif /* ndef MCL_FUTURE */
  3433. if (x == 0)
  3434. return 0;
  3435. return 0;
  3436. }
  3437. int Mono_Posix_ToMlockallFlags (int x, int *r)
  3438. {
  3439. *r = 0;
  3440. if (x == 0)
  3441. return 0;
  3442. #ifdef MCL_CURRENT
  3443. if ((x & MCL_CURRENT) == MCL_CURRENT)
  3444. *r |= Mono_Posix_MlockallFlags_MCL_CURRENT;
  3445. #endif /* ndef MCL_CURRENT */
  3446. #ifdef MCL_FUTURE
  3447. if ((x & MCL_FUTURE) == MCL_FUTURE)
  3448. *r |= Mono_Posix_MlockallFlags_MCL_FUTURE;
  3449. #endif /* ndef MCL_FUTURE */
  3450. return 0;
  3451. }
  3452. int Mono_Posix_FromMmapFlags (int x, int *r)
  3453. {
  3454. *r = 0;
  3455. if ((x & Mono_Posix_MmapFlags_MAP_ANON) == Mono_Posix_MmapFlags_MAP_ANON)
  3456. #ifdef MAP_ANON
  3457. *r |= MAP_ANON;
  3458. #else /* def MAP_ANON */
  3459. {errno = EINVAL; return -1;}
  3460. #endif /* ndef MAP_ANON */
  3461. if ((x & Mono_Posix_MmapFlags_MAP_ANONYMOUS) == Mono_Posix_MmapFlags_MAP_ANONYMOUS)
  3462. #ifdef MAP_ANONYMOUS
  3463. *r |= MAP_ANONYMOUS;
  3464. #else /* def MAP_ANONYMOUS */
  3465. {errno = EINVAL; return -1;}
  3466. #endif /* ndef MAP_ANONYMOUS */
  3467. if ((x & Mono_Posix_MmapFlags_MAP_DENYWRITE) == Mono_Posix_MmapFlags_MAP_DENYWRITE)
  3468. #ifdef MAP_DENYWRITE
  3469. *r |= MAP_DENYWRITE;
  3470. #else /* def MAP_DENYWRITE */
  3471. {errno = EINVAL; return -1;}
  3472. #endif /* ndef MAP_DENYWRITE */
  3473. if ((x & Mono_Posix_MmapFlags_MAP_EXECUTABLE) == Mono_Posix_MmapFlags_MAP_EXECUTABLE)
  3474. #ifdef MAP_EXECUTABLE
  3475. *r |= MAP_EXECUTABLE;
  3476. #else /* def MAP_EXECUTABLE */
  3477. {errno = EINVAL; return -1;}
  3478. #endif /* ndef MAP_EXECUTABLE */
  3479. if ((x & Mono_Posix_MmapFlags_MAP_FILE) == Mono_Posix_MmapFlags_MAP_FILE)
  3480. #ifdef MAP_FILE
  3481. *r |= MAP_FILE;
  3482. #else /* def MAP_FILE */
  3483. {errno = EINVAL; return -1;}
  3484. #endif /* ndef MAP_FILE */
  3485. if ((x & Mono_Posix_MmapFlags_MAP_FIXED) == Mono_Posix_MmapFlags_MAP_FIXED)
  3486. #ifdef MAP_FIXED
  3487. *r |= MAP_FIXED;
  3488. #else /* def MAP_FIXED */
  3489. {errno = EINVAL; return -1;}
  3490. #endif /* ndef MAP_FIXED */
  3491. if ((x & Mono_Posix_MmapFlags_MAP_GROWSDOWN) == Mono_Posix_MmapFlags_MAP_GROWSDOWN)
  3492. #ifdef MAP_GROWSDOWN
  3493. *r |= MAP_GROWSDOWN;
  3494. #else /* def MAP_GROWSDOWN */
  3495. {errno = EINVAL; return -1;}
  3496. #endif /* ndef MAP_GROWSDOWN */
  3497. if ((x & Mono_Posix_MmapFlags_MAP_LOCKED) == Mono_Posix_MmapFlags_MAP_LOCKED)
  3498. #ifdef MAP_LOCKED
  3499. *r |= MAP_LOCKED;
  3500. #else /* def MAP_LOCKED */
  3501. {errno = EINVAL; return -1;}
  3502. #endif /* ndef MAP_LOCKED */
  3503. if ((x & Mono_Posix_MmapFlags_MAP_NONBLOCK) == Mono_Posix_MmapFlags_MAP_NONBLOCK)
  3504. #ifdef MAP_NONBLOCK
  3505. *r |= MAP_NONBLOCK;
  3506. #else /* def MAP_NONBLOCK */
  3507. {errno = EINVAL; return -1;}
  3508. #endif /* ndef MAP_NONBLOCK */
  3509. if ((x & Mono_Posix_MmapFlags_MAP_NORESERVE) == Mono_Posix_MmapFlags_MAP_NORESERVE)
  3510. #ifdef MAP_NORESERVE
  3511. *r |= MAP_NORESERVE;
  3512. #else /* def MAP_NORESERVE */
  3513. {errno = EINVAL; return -1;}
  3514. #endif /* ndef MAP_NORESERVE */
  3515. if ((x & Mono_Posix_MmapFlags_MAP_POPULATE) == Mono_Posix_MmapFlags_MAP_POPULATE)
  3516. #ifdef MAP_POPULATE
  3517. *r |= MAP_POPULATE;
  3518. #else /* def MAP_POPULATE */
  3519. {errno = EINVAL; return -1;}
  3520. #endif /* ndef MAP_POPULATE */
  3521. if ((x & Mono_Posix_MmapFlags_MAP_PRIVATE) == Mono_Posix_MmapFlags_MAP_PRIVATE)
  3522. #ifdef MAP_PRIVATE
  3523. *r |= MAP_PRIVATE;
  3524. #else /* def MAP_PRIVATE */
  3525. {errno = EINVAL; return -1;}
  3526. #endif /* ndef MAP_PRIVATE */
  3527. if ((x & Mono_Posix_MmapFlags_MAP_SHARED) == Mono_Posix_MmapFlags_MAP_SHARED)
  3528. #ifdef MAP_SHARED
  3529. *r |= MAP_SHARED;
  3530. #else /* def MAP_SHARED */
  3531. {errno = EINVAL; return -1;}
  3532. #endif /* ndef MAP_SHARED */
  3533. if ((x & Mono_Posix_MmapFlags_MAP_TYPE) == Mono_Posix_MmapFlags_MAP_TYPE)
  3534. #ifdef MAP_TYPE
  3535. *r |= MAP_TYPE;
  3536. #else /* def MAP_TYPE */
  3537. {errno = EINVAL; return -1;}
  3538. #endif /* ndef MAP_TYPE */
  3539. if (x == 0)
  3540. return 0;
  3541. return 0;
  3542. }
  3543. int Mono_Posix_ToMmapFlags (int x, int *r)
  3544. {
  3545. *r = 0;
  3546. if (x == 0)
  3547. return 0;
  3548. #ifdef MAP_ANON
  3549. if ((x & MAP_ANON) == MAP_ANON)
  3550. *r |= Mono_Posix_MmapFlags_MAP_ANON;
  3551. #endif /* ndef MAP_ANON */
  3552. #ifdef MAP_ANONYMOUS
  3553. if ((x & MAP_ANONYMOUS) == MAP_ANONYMOUS)
  3554. *r |= Mono_Posix_MmapFlags_MAP_ANONYMOUS;
  3555. #endif /* ndef MAP_ANONYMOUS */
  3556. #ifdef MAP_DENYWRITE
  3557. if ((x & MAP_DENYWRITE) == MAP_DENYWRITE)
  3558. *r |= Mono_Posix_MmapFlags_MAP_DENYWRITE;
  3559. #endif /* ndef MAP_DENYWRITE */
  3560. #ifdef MAP_EXECUTABLE
  3561. if ((x & MAP_EXECUTABLE) == MAP_EXECUTABLE)
  3562. *r |= Mono_Posix_MmapFlags_MAP_EXECUTABLE;
  3563. #endif /* ndef MAP_EXECUTABLE */
  3564. #ifdef MAP_FILE
  3565. if ((x & MAP_FILE) == MAP_FILE)
  3566. *r |= Mono_Posix_MmapFlags_MAP_FILE;
  3567. #endif /* ndef MAP_FILE */
  3568. #ifdef MAP_FIXED
  3569. if ((x & MAP_FIXED) == MAP_FIXED)
  3570. *r |= Mono_Posix_MmapFlags_MAP_FIXED;
  3571. #endif /* ndef MAP_FIXED */
  3572. #ifdef MAP_GROWSDOWN
  3573. if ((x & MAP_GROWSDOWN) == MAP_GROWSDOWN)
  3574. *r |= Mono_Posix_MmapFlags_MAP_GROWSDOWN;
  3575. #endif /* ndef MAP_GROWSDOWN */
  3576. #ifdef MAP_LOCKED
  3577. if ((x & MAP_LOCKED) == MAP_LOCKED)
  3578. *r |= Mono_Posix_MmapFlags_MAP_LOCKED;
  3579. #endif /* ndef MAP_LOCKED */
  3580. #ifdef MAP_NONBLOCK
  3581. if ((x & MAP_NONBLOCK) == MAP_NONBLOCK)
  3582. *r |= Mono_Posix_MmapFlags_MAP_NONBLOCK;
  3583. #endif /* ndef MAP_NONBLOCK */
  3584. #ifdef MAP_NORESERVE
  3585. if ((x & MAP_NORESERVE) == MAP_NORESERVE)
  3586. *r |= Mono_Posix_MmapFlags_MAP_NORESERVE;
  3587. #endif /* ndef MAP_NORESERVE */
  3588. #ifdef MAP_POPULATE
  3589. if ((x & MAP_POPULATE) == MAP_POPULATE)
  3590. *r |= Mono_Posix_MmapFlags_MAP_POPULATE;
  3591. #endif /* ndef MAP_POPULATE */
  3592. #ifdef MAP_PRIVATE
  3593. if ((x & MAP_PRIVATE) == MAP_PRIVATE)
  3594. *r |= Mono_Posix_MmapFlags_MAP_PRIVATE;
  3595. #endif /* ndef MAP_PRIVATE */
  3596. #ifdef MAP_SHARED
  3597. if ((x & MAP_SHARED) == MAP_SHARED)
  3598. *r |= Mono_Posix_MmapFlags_MAP_SHARED;
  3599. #endif /* ndef MAP_SHARED */
  3600. #ifdef MAP_TYPE
  3601. if ((x & MAP_TYPE) == MAP_TYPE)
  3602. *r |= Mono_Posix_MmapFlags_MAP_TYPE;
  3603. #endif /* ndef MAP_TYPE */
  3604. return 0;
  3605. }
  3606. int Mono_Posix_FromMmapProts (int x, int *r)
  3607. {
  3608. *r = 0;
  3609. if ((x & Mono_Posix_MmapProts_PROT_EXEC) == Mono_Posix_MmapProts_PROT_EXEC)
  3610. #ifdef PROT_EXEC
  3611. *r |= PROT_EXEC;
  3612. #else /* def PROT_EXEC */
  3613. {errno = EINVAL; return -1;}
  3614. #endif /* ndef PROT_EXEC */
  3615. if ((x & Mono_Posix_MmapProts_PROT_GROWSDOWN) == Mono_Posix_MmapProts_PROT_GROWSDOWN)
  3616. #ifdef PROT_GROWSDOWN
  3617. *r |= PROT_GROWSDOWN;
  3618. #else /* def PROT_GROWSDOWN */
  3619. {errno = EINVAL; return -1;}
  3620. #endif /* ndef PROT_GROWSDOWN */
  3621. if ((x & Mono_Posix_MmapProts_PROT_GROWSUP) == Mono_Posix_MmapProts_PROT_GROWSUP)
  3622. #ifdef PROT_GROWSUP
  3623. *r |= PROT_GROWSUP;
  3624. #else /* def PROT_GROWSUP */
  3625. {errno = EINVAL; return -1;}
  3626. #endif /* ndef PROT_GROWSUP */
  3627. if ((x & Mono_Posix_MmapProts_PROT_NONE) == Mono_Posix_MmapProts_PROT_NONE)
  3628. #ifdef PROT_NONE
  3629. *r |= PROT_NONE;
  3630. #else /* def PROT_NONE */
  3631. {errno = EINVAL; return -1;}
  3632. #endif /* ndef PROT_NONE */
  3633. if ((x & Mono_Posix_MmapProts_PROT_READ) == Mono_Posix_MmapProts_PROT_READ)
  3634. #ifdef PROT_READ
  3635. *r |= PROT_READ;
  3636. #else /* def PROT_READ */
  3637. {errno = EINVAL; return -1;}
  3638. #endif /* ndef PROT_READ */
  3639. if ((x & Mono_Posix_MmapProts_PROT_WRITE) == Mono_Posix_MmapProts_PROT_WRITE)
  3640. #ifdef PROT_WRITE
  3641. *r |= PROT_WRITE;
  3642. #else /* def PROT_WRITE */
  3643. {errno = EINVAL; return -1;}
  3644. #endif /* ndef PROT_WRITE */
  3645. if (x == 0)
  3646. return 0;
  3647. return 0;
  3648. }
  3649. int Mono_Posix_ToMmapProts (int x, int *r)
  3650. {
  3651. *r = 0;
  3652. if (x == 0)
  3653. return 0;
  3654. #ifdef PROT_EXEC
  3655. if ((x & PROT_EXEC) == PROT_EXEC)
  3656. *r |= Mono_Posix_MmapProts_PROT_EXEC;
  3657. #endif /* ndef PROT_EXEC */
  3658. #ifdef PROT_GROWSDOWN
  3659. if ((x & PROT_GROWSDOWN) == PROT_GROWSDOWN)
  3660. *r |= Mono_Posix_MmapProts_PROT_GROWSDOWN;
  3661. #endif /* ndef PROT_GROWSDOWN */
  3662. #ifdef PROT_GROWSUP
  3663. if ((x & PROT_GROWSUP) == PROT_GROWSUP)
  3664. *r |= Mono_Posix_MmapProts_PROT_GROWSUP;
  3665. #endif /* ndef PROT_GROWSUP */
  3666. #ifdef PROT_NONE
  3667. if ((x & PROT_NONE) == PROT_NONE)
  3668. *r |= Mono_Posix_MmapProts_PROT_NONE;
  3669. #endif /* ndef PROT_NONE */
  3670. #ifdef PROT_READ
  3671. if ((x & PROT_READ) == PROT_READ)
  3672. *r |= Mono_Posix_MmapProts_PROT_READ;
  3673. #endif /* ndef PROT_READ */
  3674. #ifdef PROT_WRITE
  3675. if ((x & PROT_WRITE) == PROT_WRITE)
  3676. *r |= Mono_Posix_MmapProts_PROT_WRITE;
  3677. #endif /* ndef PROT_WRITE */
  3678. return 0;
  3679. }
  3680. int Mono_Posix_FromMountFlags (guint64 x, guint64 *r)
  3681. {
  3682. *r = 0;
  3683. if ((x & Mono_Posix_MountFlags_ST_APPEND) == Mono_Posix_MountFlags_ST_APPEND)
  3684. #ifdef ST_APPEND
  3685. *r |= ST_APPEND;
  3686. #else /* def ST_APPEND */
  3687. {errno = EINVAL; return -1;}
  3688. #endif /* ndef ST_APPEND */
  3689. if ((x & Mono_Posix_MountFlags_ST_BIND) == Mono_Posix_MountFlags_ST_BIND)
  3690. #ifdef ST_BIND
  3691. *r |= ST_BIND;
  3692. #else /* def ST_BIND */
  3693. {errno = EINVAL; return -1;}
  3694. #endif /* ndef ST_BIND */
  3695. if ((x & Mono_Posix_MountFlags_ST_IMMUTABLE) == Mono_Posix_MountFlags_ST_IMMUTABLE)
  3696. #ifdef ST_IMMUTABLE
  3697. *r |= ST_IMMUTABLE;
  3698. #else /* def ST_IMMUTABLE */
  3699. {errno = EINVAL; return -1;}
  3700. #endif /* ndef ST_IMMUTABLE */
  3701. if ((x & Mono_Posix_MountFlags_ST_MANDLOCK) == Mono_Posix_MountFlags_ST_MANDLOCK)
  3702. #ifdef ST_MANDLOCK
  3703. *r |= ST_MANDLOCK;
  3704. #else /* def ST_MANDLOCK */
  3705. {errno = EINVAL; return -1;}
  3706. #endif /* ndef ST_MANDLOCK */
  3707. if ((x & Mono_Posix_MountFlags_ST_NOATIME) == Mono_Posix_MountFlags_ST_NOATIME)
  3708. #ifdef ST_NOATIME
  3709. *r |= ST_NOATIME;
  3710. #else /* def ST_NOATIME */
  3711. {errno = EINVAL; return -1;}
  3712. #endif /* ndef ST_NOATIME */
  3713. if ((x & Mono_Posix_MountFlags_ST_NODEV) == Mono_Posix_MountFlags_ST_NODEV)
  3714. #ifdef ST_NODEV
  3715. *r |= ST_NODEV;
  3716. #else /* def ST_NODEV */
  3717. {errno = EINVAL; return -1;}
  3718. #endif /* ndef ST_NODEV */
  3719. if ((x & Mono_Posix_MountFlags_ST_NODIRATIME) == Mono_Posix_MountFlags_ST_NODIRATIME)
  3720. #ifdef ST_NODIRATIME
  3721. *r |= ST_NODIRATIME;
  3722. #else /* def ST_NODIRATIME */
  3723. {errno = EINVAL; return -1;}
  3724. #endif /* ndef ST_NODIRATIME */
  3725. if ((x & Mono_Posix_MountFlags_ST_NOEXEC) == Mono_Posix_MountFlags_ST_NOEXEC)
  3726. #ifdef ST_NOEXEC
  3727. *r |= ST_NOEXEC;
  3728. #else /* def ST_NOEXEC */
  3729. {errno = EINVAL; return -1;}
  3730. #endif /* ndef ST_NOEXEC */
  3731. if ((x & Mono_Posix_MountFlags_ST_NOSUID) == Mono_Posix_MountFlags_ST_NOSUID)
  3732. #ifdef ST_NOSUID
  3733. *r |= ST_NOSUID;
  3734. #else /* def ST_NOSUID */
  3735. {errno = EINVAL; return -1;}
  3736. #endif /* ndef ST_NOSUID */
  3737. if ((x & Mono_Posix_MountFlags_ST_RDONLY) == Mono_Posix_MountFlags_ST_RDONLY)
  3738. #ifdef ST_RDONLY
  3739. *r |= ST_RDONLY;
  3740. #else /* def ST_RDONLY */
  3741. {errno = EINVAL; return -1;}
  3742. #endif /* ndef ST_RDONLY */
  3743. if ((x & Mono_Posix_MountFlags_ST_REMOUNT) == Mono_Posix_MountFlags_ST_REMOUNT)
  3744. #ifdef ST_REMOUNT
  3745. *r |= ST_REMOUNT;
  3746. #else /* def ST_REMOUNT */
  3747. {errno = EINVAL; return -1;}
  3748. #endif /* ndef ST_REMOUNT */
  3749. if ((x & Mono_Posix_MountFlags_ST_SYNCHRONOUS) == Mono_Posix_MountFlags_ST_SYNCHRONOUS)
  3750. #ifdef ST_SYNCHRONOUS
  3751. *r |= ST_SYNCHRONOUS;
  3752. #else /* def ST_SYNCHRONOUS */
  3753. {errno = EINVAL; return -1;}
  3754. #endif /* ndef ST_SYNCHRONOUS */
  3755. if ((x & Mono_Posix_MountFlags_ST_WRITE) == Mono_Posix_MountFlags_ST_WRITE)
  3756. #ifdef ST_WRITE
  3757. *r |= ST_WRITE;
  3758. #else /* def ST_WRITE */
  3759. {errno = EINVAL; return -1;}
  3760. #endif /* ndef ST_WRITE */
  3761. if (x == 0)
  3762. return 0;
  3763. return 0;
  3764. }
  3765. int Mono_Posix_ToMountFlags (guint64 x, guint64 *r)
  3766. {
  3767. *r = 0;
  3768. if (x == 0)
  3769. return 0;
  3770. #ifdef ST_APPEND
  3771. if ((x & ST_APPEND) == ST_APPEND)
  3772. *r |= Mono_Posix_MountFlags_ST_APPEND;
  3773. #endif /* ndef ST_APPEND */
  3774. #ifdef ST_BIND
  3775. if ((x & ST_BIND) == ST_BIND)
  3776. *r |= Mono_Posix_MountFlags_ST_BIND;
  3777. #endif /* ndef ST_BIND */
  3778. #ifdef ST_IMMUTABLE
  3779. if ((x & ST_IMMUTABLE) == ST_IMMUTABLE)
  3780. *r |= Mono_Posix_MountFlags_ST_IMMUTABLE;
  3781. #endif /* ndef ST_IMMUTABLE */
  3782. #ifdef ST_MANDLOCK
  3783. if ((x & ST_MANDLOCK) == ST_MANDLOCK)
  3784. *r |= Mono_Posix_MountFlags_ST_MANDLOCK;
  3785. #endif /* ndef ST_MANDLOCK */
  3786. #ifdef ST_NOATIME
  3787. if ((x & ST_NOATIME) == ST_NOATIME)
  3788. *r |= Mono_Posix_MountFlags_ST_NOATIME;
  3789. #endif /* ndef ST_NOATIME */
  3790. #ifdef ST_NODEV
  3791. if ((x & ST_NODEV) == ST_NODEV)
  3792. *r |= Mono_Posix_MountFlags_ST_NODEV;
  3793. #endif /* ndef ST_NODEV */
  3794. #ifdef ST_NODIRATIME
  3795. if ((x & ST_NODIRATIME) == ST_NODIRATIME)
  3796. *r |= Mono_Posix_MountFlags_ST_NODIRATIME;
  3797. #endif /* ndef ST_NODIRATIME */
  3798. #ifdef ST_NOEXEC
  3799. if ((x & ST_NOEXEC) == ST_NOEXEC)
  3800. *r |= Mono_Posix_MountFlags_ST_NOEXEC;
  3801. #endif /* ndef ST_NOEXEC */
  3802. #ifdef ST_NOSUID
  3803. if ((x & ST_NOSUID) == ST_NOSUID)
  3804. *r |= Mono_Posix_MountFlags_ST_NOSUID;
  3805. #endif /* ndef ST_NOSUID */
  3806. #ifdef ST_RDONLY
  3807. if ((x & ST_RDONLY) == ST_RDONLY)
  3808. *r |= Mono_Posix_MountFlags_ST_RDONLY;
  3809. #endif /* ndef ST_RDONLY */
  3810. #ifdef ST_REMOUNT
  3811. if ((x & ST_REMOUNT) == ST_REMOUNT)
  3812. *r |= Mono_Posix_MountFlags_ST_REMOUNT;
  3813. #endif /* ndef ST_REMOUNT */
  3814. #ifdef ST_SYNCHRONOUS
  3815. if ((x & ST_SYNCHRONOUS) == ST_SYNCHRONOUS)
  3816. *r |= Mono_Posix_MountFlags_ST_SYNCHRONOUS;
  3817. #endif /* ndef ST_SYNCHRONOUS */
  3818. #ifdef ST_WRITE
  3819. if ((x & ST_WRITE) == ST_WRITE)
  3820. *r |= Mono_Posix_MountFlags_ST_WRITE;
  3821. #endif /* ndef ST_WRITE */
  3822. return 0;
  3823. }
  3824. int Mono_Posix_FromMremapFlags (guint64 x, guint64 *r)
  3825. {
  3826. *r = 0;
  3827. if ((x & Mono_Posix_MremapFlags_MREMAP_MAYMOVE) == Mono_Posix_MremapFlags_MREMAP_MAYMOVE)
  3828. #ifdef MREMAP_MAYMOVE
  3829. *r |= MREMAP_MAYMOVE;
  3830. #else /* def MREMAP_MAYMOVE */
  3831. {errno = EINVAL; return -1;}
  3832. #endif /* ndef MREMAP_MAYMOVE */
  3833. if (x == 0)
  3834. return 0;
  3835. return 0;
  3836. }
  3837. int Mono_Posix_ToMremapFlags (guint64 x, guint64 *r)
  3838. {
  3839. *r = 0;
  3840. if (x == 0)
  3841. return 0;
  3842. #ifdef MREMAP_MAYMOVE
  3843. if ((x & MREMAP_MAYMOVE) == MREMAP_MAYMOVE)
  3844. *r |= Mono_Posix_MremapFlags_MREMAP_MAYMOVE;
  3845. #endif /* ndef MREMAP_MAYMOVE */
  3846. return 0;
  3847. }
  3848. int Mono_Posix_FromMsyncFlags (int x, int *r)
  3849. {
  3850. *r = 0;
  3851. if ((x & Mono_Posix_MsyncFlags_MS_ASYNC) == Mono_Posix_MsyncFlags_MS_ASYNC)
  3852. #ifdef MS_ASYNC
  3853. *r |= MS_ASYNC;
  3854. #else /* def MS_ASYNC */
  3855. {errno = EINVAL; return -1;}
  3856. #endif /* ndef MS_ASYNC */
  3857. if ((x & Mono_Posix_MsyncFlags_MS_INVALIDATE) == Mono_Posix_MsyncFlags_MS_INVALIDATE)
  3858. #ifdef MS_INVALIDATE
  3859. *r |= MS_INVALIDATE;
  3860. #else /* def MS_INVALIDATE */
  3861. {errno = EINVAL; return -1;}
  3862. #endif /* ndef MS_INVALIDATE */
  3863. if ((x & Mono_Posix_MsyncFlags_MS_SYNC) == Mono_Posix_MsyncFlags_MS_SYNC)
  3864. #ifdef MS_SYNC
  3865. *r |= MS_SYNC;
  3866. #else /* def MS_SYNC */
  3867. {errno = EINVAL; return -1;}
  3868. #endif /* ndef MS_SYNC */
  3869. if (x == 0)
  3870. return 0;
  3871. return 0;
  3872. }
  3873. int Mono_Posix_ToMsyncFlags (int x, int *r)
  3874. {
  3875. *r = 0;
  3876. if (x == 0)
  3877. return 0;
  3878. #ifdef MS_ASYNC
  3879. if ((x & MS_ASYNC) == MS_ASYNC)
  3880. *r |= Mono_Posix_MsyncFlags_MS_ASYNC;
  3881. #endif /* ndef MS_ASYNC */
  3882. #ifdef MS_INVALIDATE
  3883. if ((x & MS_INVALIDATE) == MS_INVALIDATE)
  3884. *r |= Mono_Posix_MsyncFlags_MS_INVALIDATE;
  3885. #endif /* ndef MS_INVALIDATE */
  3886. #ifdef MS_SYNC
  3887. if ((x & MS_SYNC) == MS_SYNC)
  3888. *r |= Mono_Posix_MsyncFlags_MS_SYNC;
  3889. #endif /* ndef MS_SYNC */
  3890. return 0;
  3891. }
  3892. int Mono_Posix_FromOpenFlags (int x, int *r)
  3893. {
  3894. *r = 0;
  3895. if ((x & Mono_Posix_OpenFlags_O_APPEND) == Mono_Posix_OpenFlags_O_APPEND)
  3896. #ifdef O_APPEND
  3897. *r |= O_APPEND;
  3898. #else /* def O_APPEND */
  3899. {errno = EINVAL; return -1;}
  3900. #endif /* ndef O_APPEND */
  3901. if ((x & Mono_Posix_OpenFlags_O_ASYNC) == Mono_Posix_OpenFlags_O_ASYNC)
  3902. #ifdef O_ASYNC
  3903. *r |= O_ASYNC;
  3904. #else /* def O_ASYNC */
  3905. {errno = EINVAL; return -1;}
  3906. #endif /* ndef O_ASYNC */
  3907. if ((x & Mono_Posix_OpenFlags_O_CLOEXEC) == Mono_Posix_OpenFlags_O_CLOEXEC)
  3908. #ifdef O_CLOEXEC
  3909. *r |= O_CLOEXEC;
  3910. #else /* def O_CLOEXEC */
  3911. {errno = EINVAL; return -1;}
  3912. #endif /* ndef O_CLOEXEC */
  3913. if ((x & Mono_Posix_OpenFlags_O_CREAT) == Mono_Posix_OpenFlags_O_CREAT)
  3914. #ifdef O_CREAT
  3915. *r |= O_CREAT;
  3916. #else /* def O_CREAT */
  3917. {errno = EINVAL; return -1;}
  3918. #endif /* ndef O_CREAT */
  3919. if ((x & Mono_Posix_OpenFlags_O_DIRECT) == Mono_Posix_OpenFlags_O_DIRECT)
  3920. #ifdef O_DIRECT
  3921. *r |= O_DIRECT;
  3922. #else /* def O_DIRECT */
  3923. {errno = EINVAL; return -1;}
  3924. #endif /* ndef O_DIRECT */
  3925. if ((x & Mono_Posix_OpenFlags_O_DIRECTORY) == Mono_Posix_OpenFlags_O_DIRECTORY)
  3926. #ifdef O_DIRECTORY
  3927. *r |= O_DIRECTORY;
  3928. #else /* def O_DIRECTORY */
  3929. {errno = EINVAL; return -1;}
  3930. #endif /* ndef O_DIRECTORY */
  3931. if ((x & Mono_Posix_OpenFlags_O_EXCL) == Mono_Posix_OpenFlags_O_EXCL)
  3932. #ifdef O_EXCL
  3933. *r |= O_EXCL;
  3934. #else /* def O_EXCL */
  3935. {errno = EINVAL; return -1;}
  3936. #endif /* ndef O_EXCL */
  3937. if ((x & Mono_Posix_OpenFlags_O_LARGEFILE) == Mono_Posix_OpenFlags_O_LARGEFILE)
  3938. #ifdef O_LARGEFILE
  3939. *r |= O_LARGEFILE;
  3940. #else /* def O_LARGEFILE */
  3941. {errno = EINVAL; return -1;}
  3942. #endif /* ndef O_LARGEFILE */
  3943. if ((x & Mono_Posix_OpenFlags_O_NOCTTY) == Mono_Posix_OpenFlags_O_NOCTTY)
  3944. #ifdef O_NOCTTY
  3945. *r |= O_NOCTTY;
  3946. #else /* def O_NOCTTY */
  3947. {errno = EINVAL; return -1;}
  3948. #endif /* ndef O_NOCTTY */
  3949. if ((x & Mono_Posix_OpenFlags_O_NOFOLLOW) == Mono_Posix_OpenFlags_O_NOFOLLOW)
  3950. #ifdef O_NOFOLLOW
  3951. *r |= O_NOFOLLOW;
  3952. #else /* def O_NOFOLLOW */
  3953. {errno = EINVAL; return -1;}
  3954. #endif /* ndef O_NOFOLLOW */
  3955. if ((x & Mono_Posix_OpenFlags_O_NONBLOCK) == Mono_Posix_OpenFlags_O_NONBLOCK)
  3956. #ifdef O_NONBLOCK
  3957. *r |= O_NONBLOCK;
  3958. #else /* def O_NONBLOCK */
  3959. {errno = EINVAL; return -1;}
  3960. #endif /* ndef O_NONBLOCK */
  3961. if ((x & Mono_Posix_OpenFlags_O_PATH) == Mono_Posix_OpenFlags_O_PATH)
  3962. #ifdef O_PATH
  3963. *r |= O_PATH;
  3964. #else /* def O_PATH */
  3965. {errno = EINVAL; return -1;}
  3966. #endif /* ndef O_PATH */
  3967. if ((x & Mono_Posix_OpenFlags_O_RDONLY) == Mono_Posix_OpenFlags_O_RDONLY)
  3968. #ifdef O_RDONLY
  3969. *r |= O_RDONLY;
  3970. #else /* def O_RDONLY */
  3971. {errno = EINVAL; return -1;}
  3972. #endif /* ndef O_RDONLY */
  3973. if ((x & Mono_Posix_OpenFlags_O_RDWR) == Mono_Posix_OpenFlags_O_RDWR)
  3974. #ifdef O_RDWR
  3975. *r |= O_RDWR;
  3976. #else /* def O_RDWR */
  3977. {errno = EINVAL; return -1;}
  3978. #endif /* ndef O_RDWR */
  3979. if ((x & Mono_Posix_OpenFlags_O_SYNC) == Mono_Posix_OpenFlags_O_SYNC)
  3980. #ifdef O_SYNC
  3981. *r |= O_SYNC;
  3982. #else /* def O_SYNC */
  3983. {errno = EINVAL; return -1;}
  3984. #endif /* ndef O_SYNC */
  3985. if ((x & Mono_Posix_OpenFlags_O_TRUNC) == Mono_Posix_OpenFlags_O_TRUNC)
  3986. #ifdef O_TRUNC
  3987. *r |= O_TRUNC;
  3988. #else /* def O_TRUNC */
  3989. {errno = EINVAL; return -1;}
  3990. #endif /* ndef O_TRUNC */
  3991. if ((x & Mono_Posix_OpenFlags_O_WRONLY) == Mono_Posix_OpenFlags_O_WRONLY)
  3992. #ifdef O_WRONLY
  3993. *r |= O_WRONLY;
  3994. #else /* def O_WRONLY */
  3995. {errno = EINVAL; return -1;}
  3996. #endif /* ndef O_WRONLY */
  3997. if (x == 0)
  3998. return 0;
  3999. return 0;
  4000. }
  4001. int Mono_Posix_ToOpenFlags (int x, int *r)
  4002. {
  4003. *r = 0;
  4004. if (x == 0)
  4005. return 0;
  4006. #ifdef O_APPEND
  4007. if ((x & O_APPEND) == O_APPEND)
  4008. *r |= Mono_Posix_OpenFlags_O_APPEND;
  4009. #endif /* ndef O_APPEND */
  4010. #ifdef O_ASYNC
  4011. if ((x & O_ASYNC) == O_ASYNC)
  4012. *r |= Mono_Posix_OpenFlags_O_ASYNC;
  4013. #endif /* ndef O_ASYNC */
  4014. #ifdef O_CLOEXEC
  4015. if ((x & O_CLOEXEC) == O_CLOEXEC)
  4016. *r |= Mono_Posix_OpenFlags_O_CLOEXEC;
  4017. #endif /* ndef O_CLOEXEC */
  4018. #ifdef O_CREAT
  4019. if ((x & O_CREAT) == O_CREAT)
  4020. *r |= Mono_Posix_OpenFlags_O_CREAT;
  4021. #endif /* ndef O_CREAT */
  4022. #ifdef O_DIRECT
  4023. if ((x & O_DIRECT) == O_DIRECT)
  4024. *r |= Mono_Posix_OpenFlags_O_DIRECT;
  4025. #endif /* ndef O_DIRECT */
  4026. #ifdef O_DIRECTORY
  4027. if ((x & O_DIRECTORY) == O_DIRECTORY)
  4028. *r |= Mono_Posix_OpenFlags_O_DIRECTORY;
  4029. #endif /* ndef O_DIRECTORY */
  4030. #ifdef O_EXCL
  4031. if ((x & O_EXCL) == O_EXCL)
  4032. *r |= Mono_Posix_OpenFlags_O_EXCL;
  4033. #endif /* ndef O_EXCL */
  4034. #ifdef O_LARGEFILE
  4035. if ((x & O_LARGEFILE) == O_LARGEFILE)
  4036. *r |= Mono_Posix_OpenFlags_O_LARGEFILE;
  4037. #endif /* ndef O_LARGEFILE */
  4038. #ifdef O_NOCTTY
  4039. if ((x & O_NOCTTY) == O_NOCTTY)
  4040. *r |= Mono_Posix_OpenFlags_O_NOCTTY;
  4041. #endif /* ndef O_NOCTTY */
  4042. #ifdef O_NOFOLLOW
  4043. if ((x & O_NOFOLLOW) == O_NOFOLLOW)
  4044. *r |= Mono_Posix_OpenFlags_O_NOFOLLOW;
  4045. #endif /* ndef O_NOFOLLOW */
  4046. #ifdef O_NONBLOCK
  4047. if ((x & O_NONBLOCK) == O_NONBLOCK)
  4048. *r |= Mono_Posix_OpenFlags_O_NONBLOCK;
  4049. #endif /* ndef O_NONBLOCK */
  4050. #ifdef O_PATH
  4051. if ((x & O_PATH) == O_PATH)
  4052. *r |= Mono_Posix_OpenFlags_O_PATH;
  4053. #endif /* ndef O_PATH */
  4054. #ifdef O_RDONLY
  4055. if ((x & O_RDONLY) == O_RDONLY)
  4056. *r |= Mono_Posix_OpenFlags_O_RDONLY;
  4057. #endif /* ndef O_RDONLY */
  4058. #ifdef O_RDWR
  4059. if ((x & O_RDWR) == O_RDWR)
  4060. *r |= Mono_Posix_OpenFlags_O_RDWR;
  4061. #endif /* ndef O_RDWR */
  4062. #ifdef O_SYNC
  4063. if ((x & O_SYNC) == O_SYNC)
  4064. *r |= Mono_Posix_OpenFlags_O_SYNC;
  4065. #endif /* ndef O_SYNC */
  4066. #ifdef O_TRUNC
  4067. if ((x & O_TRUNC) == O_TRUNC)
  4068. *r |= Mono_Posix_OpenFlags_O_TRUNC;
  4069. #endif /* ndef O_TRUNC */
  4070. #ifdef O_WRONLY
  4071. if ((x & O_WRONLY) == O_WRONLY)
  4072. *r |= Mono_Posix_OpenFlags_O_WRONLY;
  4073. #endif /* ndef O_WRONLY */
  4074. return 0;
  4075. }
  4076. int Mono_Posix_FromPathconfName (int x, int *r)
  4077. {
  4078. *r = 0;
  4079. if (x == Mono_Posix_PathconfName__PC_2_SYMLINKS)
  4080. #ifdef _PC_2_SYMLINKS
  4081. {*r = _PC_2_SYMLINKS; return 0;}
  4082. #else /* def _PC_2_SYMLINKS */
  4083. {errno = EINVAL; return -1;}
  4084. #endif /* ndef _PC_2_SYMLINKS */
  4085. if (x == Mono_Posix_PathconfName__PC_ALLOC_SIZE_MIN)
  4086. #ifdef _PC_ALLOC_SIZE_MIN
  4087. {*r = _PC_ALLOC_SIZE_MIN; return 0;}
  4088. #else /* def _PC_ALLOC_SIZE_MIN */
  4089. {errno = EINVAL; return -1;}
  4090. #endif /* ndef _PC_ALLOC_SIZE_MIN */
  4091. if (x == Mono_Posix_PathconfName__PC_ASYNC_IO)
  4092. #ifdef _PC_ASYNC_IO
  4093. {*r = _PC_ASYNC_IO; return 0;}
  4094. #else /* def _PC_ASYNC_IO */
  4095. {errno = EINVAL; return -1;}
  4096. #endif /* ndef _PC_ASYNC_IO */
  4097. if (x == Mono_Posix_PathconfName__PC_CHOWN_RESTRICTED)
  4098. #ifdef _PC_CHOWN_RESTRICTED
  4099. {*r = _PC_CHOWN_RESTRICTED; return 0;}
  4100. #else /* def _PC_CHOWN_RESTRICTED */
  4101. {errno = EINVAL; return -1;}
  4102. #endif /* ndef _PC_CHOWN_RESTRICTED */
  4103. if (x == Mono_Posix_PathconfName__PC_FILESIZEBITS)
  4104. #ifdef _PC_FILESIZEBITS
  4105. {*r = _PC_FILESIZEBITS; return 0;}
  4106. #else /* def _PC_FILESIZEBITS */
  4107. {errno = EINVAL; return -1;}
  4108. #endif /* ndef _PC_FILESIZEBITS */
  4109. if (x == Mono_Posix_PathconfName__PC_LINK_MAX)
  4110. #ifdef _PC_LINK_MAX
  4111. {*r = _PC_LINK_MAX; return 0;}
  4112. #else /* def _PC_LINK_MAX */
  4113. {errno = EINVAL; return -1;}
  4114. #endif /* ndef _PC_LINK_MAX */
  4115. if (x == Mono_Posix_PathconfName__PC_MAX_CANON)
  4116. #ifdef _PC_MAX_CANON
  4117. {*r = _PC_MAX_CANON; return 0;}
  4118. #else /* def _PC_MAX_CANON */
  4119. {errno = EINVAL; return -1;}
  4120. #endif /* ndef _PC_MAX_CANON */
  4121. if (x == Mono_Posix_PathconfName__PC_MAX_INPUT)
  4122. #ifdef _PC_MAX_INPUT
  4123. {*r = _PC_MAX_INPUT; return 0;}
  4124. #else /* def _PC_MAX_INPUT */
  4125. {errno = EINVAL; return -1;}
  4126. #endif /* ndef _PC_MAX_INPUT */
  4127. if (x == Mono_Posix_PathconfName__PC_NAME_MAX)
  4128. #ifdef _PC_NAME_MAX
  4129. {*r = _PC_NAME_MAX; return 0;}
  4130. #else /* def _PC_NAME_MAX */
  4131. {errno = EINVAL; return -1;}
  4132. #endif /* ndef _PC_NAME_MAX */
  4133. if (x == Mono_Posix_PathconfName__PC_NO_TRUNC)
  4134. #ifdef _PC_NO_TRUNC
  4135. {*r = _PC_NO_TRUNC; return 0;}
  4136. #else /* def _PC_NO_TRUNC */
  4137. {errno = EINVAL; return -1;}
  4138. #endif /* ndef _PC_NO_TRUNC */
  4139. if (x == Mono_Posix_PathconfName__PC_PATH_MAX)
  4140. #ifdef _PC_PATH_MAX
  4141. {*r = _PC_PATH_MAX; return 0;}
  4142. #else /* def _PC_PATH_MAX */
  4143. {errno = EINVAL; return -1;}
  4144. #endif /* ndef _PC_PATH_MAX */
  4145. if (x == Mono_Posix_PathconfName__PC_PIPE_BUF)
  4146. #ifdef _PC_PIPE_BUF
  4147. {*r = _PC_PIPE_BUF; return 0;}
  4148. #else /* def _PC_PIPE_BUF */
  4149. {errno = EINVAL; return -1;}
  4150. #endif /* ndef _PC_PIPE_BUF */
  4151. if (x == Mono_Posix_PathconfName__PC_PRIO_IO)
  4152. #ifdef _PC_PRIO_IO
  4153. {*r = _PC_PRIO_IO; return 0;}
  4154. #else /* def _PC_PRIO_IO */
  4155. {errno = EINVAL; return -1;}
  4156. #endif /* ndef _PC_PRIO_IO */
  4157. if (x == Mono_Posix_PathconfName__PC_REC_INCR_XFER_SIZE)
  4158. #ifdef _PC_REC_INCR_XFER_SIZE
  4159. {*r = _PC_REC_INCR_XFER_SIZE; return 0;}
  4160. #else /* def _PC_REC_INCR_XFER_SIZE */
  4161. {errno = EINVAL; return -1;}
  4162. #endif /* ndef _PC_REC_INCR_XFER_SIZE */
  4163. if (x == Mono_Posix_PathconfName__PC_REC_MAX_XFER_SIZE)
  4164. #ifdef _PC_REC_MAX_XFER_SIZE
  4165. {*r = _PC_REC_MAX_XFER_SIZE; return 0;}
  4166. #else /* def _PC_REC_MAX_XFER_SIZE */
  4167. {errno = EINVAL; return -1;}
  4168. #endif /* ndef _PC_REC_MAX_XFER_SIZE */
  4169. if (x == Mono_Posix_PathconfName__PC_REC_MIN_XFER_SIZE)
  4170. #ifdef _PC_REC_MIN_XFER_SIZE
  4171. {*r = _PC_REC_MIN_XFER_SIZE; return 0;}
  4172. #else /* def _PC_REC_MIN_XFER_SIZE */
  4173. {errno = EINVAL; return -1;}
  4174. #endif /* ndef _PC_REC_MIN_XFER_SIZE */
  4175. if (x == Mono_Posix_PathconfName__PC_REC_XFER_ALIGN)
  4176. #ifdef _PC_REC_XFER_ALIGN
  4177. {*r = _PC_REC_XFER_ALIGN; return 0;}
  4178. #else /* def _PC_REC_XFER_ALIGN */
  4179. {errno = EINVAL; return -1;}
  4180. #endif /* ndef _PC_REC_XFER_ALIGN */
  4181. if (x == Mono_Posix_PathconfName__PC_SOCK_MAXBUF)
  4182. #ifdef _PC_SOCK_MAXBUF
  4183. {*r = _PC_SOCK_MAXBUF; return 0;}
  4184. #else /* def _PC_SOCK_MAXBUF */
  4185. {errno = EINVAL; return -1;}
  4186. #endif /* ndef _PC_SOCK_MAXBUF */
  4187. if (x == Mono_Posix_PathconfName__PC_SYMLINK_MAX)
  4188. #ifdef _PC_SYMLINK_MAX
  4189. {*r = _PC_SYMLINK_MAX; return 0;}
  4190. #else /* def _PC_SYMLINK_MAX */
  4191. {errno = EINVAL; return -1;}
  4192. #endif /* ndef _PC_SYMLINK_MAX */
  4193. if (x == Mono_Posix_PathconfName__PC_SYNC_IO)
  4194. #ifdef _PC_SYNC_IO
  4195. {*r = _PC_SYNC_IO; return 0;}
  4196. #else /* def _PC_SYNC_IO */
  4197. {errno = EINVAL; return -1;}
  4198. #endif /* ndef _PC_SYNC_IO */
  4199. if (x == Mono_Posix_PathconfName__PC_VDISABLE)
  4200. #ifdef _PC_VDISABLE
  4201. {*r = _PC_VDISABLE; return 0;}
  4202. #else /* def _PC_VDISABLE */
  4203. {errno = EINVAL; return -1;}
  4204. #endif /* ndef _PC_VDISABLE */
  4205. if (x == 0)
  4206. return 0;
  4207. errno = EINVAL; return -1;
  4208. }
  4209. int Mono_Posix_ToPathconfName (int x, int *r)
  4210. {
  4211. *r = 0;
  4212. if (x == 0)
  4213. return 0;
  4214. #ifdef _PC_2_SYMLINKS
  4215. if (x == _PC_2_SYMLINKS)
  4216. {*r = Mono_Posix_PathconfName__PC_2_SYMLINKS; return 0;}
  4217. #endif /* ndef _PC_2_SYMLINKS */
  4218. #ifdef _PC_ALLOC_SIZE_MIN
  4219. if (x == _PC_ALLOC_SIZE_MIN)
  4220. {*r = Mono_Posix_PathconfName__PC_ALLOC_SIZE_MIN; return 0;}
  4221. #endif /* ndef _PC_ALLOC_SIZE_MIN */
  4222. #ifdef _PC_ASYNC_IO
  4223. if (x == _PC_ASYNC_IO)
  4224. {*r = Mono_Posix_PathconfName__PC_ASYNC_IO; return 0;}
  4225. #endif /* ndef _PC_ASYNC_IO */
  4226. #ifdef _PC_CHOWN_RESTRICTED
  4227. if (x == _PC_CHOWN_RESTRICTED)
  4228. {*r = Mono_Posix_PathconfName__PC_CHOWN_RESTRICTED; return 0;}
  4229. #endif /* ndef _PC_CHOWN_RESTRICTED */
  4230. #ifdef _PC_FILESIZEBITS
  4231. if (x == _PC_FILESIZEBITS)
  4232. {*r = Mono_Posix_PathconfName__PC_FILESIZEBITS; return 0;}
  4233. #endif /* ndef _PC_FILESIZEBITS */
  4234. #ifdef _PC_LINK_MAX
  4235. if (x == _PC_LINK_MAX)
  4236. {*r = Mono_Posix_PathconfName__PC_LINK_MAX; return 0;}
  4237. #endif /* ndef _PC_LINK_MAX */
  4238. #ifdef _PC_MAX_CANON
  4239. if (x == _PC_MAX_CANON)
  4240. {*r = Mono_Posix_PathconfName__PC_MAX_CANON; return 0;}
  4241. #endif /* ndef _PC_MAX_CANON */
  4242. #ifdef _PC_MAX_INPUT
  4243. if (x == _PC_MAX_INPUT)
  4244. {*r = Mono_Posix_PathconfName__PC_MAX_INPUT; return 0;}
  4245. #endif /* ndef _PC_MAX_INPUT */
  4246. #ifdef _PC_NAME_MAX
  4247. if (x == _PC_NAME_MAX)
  4248. {*r = Mono_Posix_PathconfName__PC_NAME_MAX; return 0;}
  4249. #endif /* ndef _PC_NAME_MAX */
  4250. #ifdef _PC_NO_TRUNC
  4251. if (x == _PC_NO_TRUNC)
  4252. {*r = Mono_Posix_PathconfName__PC_NO_TRUNC; return 0;}
  4253. #endif /* ndef _PC_NO_TRUNC */
  4254. #ifdef _PC_PATH_MAX
  4255. if (x == _PC_PATH_MAX)
  4256. {*r = Mono_Posix_PathconfName__PC_PATH_MAX; return 0;}
  4257. #endif /* ndef _PC_PATH_MAX */
  4258. #ifdef _PC_PIPE_BUF
  4259. if (x == _PC_PIPE_BUF)
  4260. {*r = Mono_Posix_PathconfName__PC_PIPE_BUF; return 0;}
  4261. #endif /* ndef _PC_PIPE_BUF */
  4262. #ifdef _PC_PRIO_IO
  4263. if (x == _PC_PRIO_IO)
  4264. {*r = Mono_Posix_PathconfName__PC_PRIO_IO; return 0;}
  4265. #endif /* ndef _PC_PRIO_IO */
  4266. #ifdef _PC_REC_INCR_XFER_SIZE
  4267. if (x == _PC_REC_INCR_XFER_SIZE)
  4268. {*r = Mono_Posix_PathconfName__PC_REC_INCR_XFER_SIZE; return 0;}
  4269. #endif /* ndef _PC_REC_INCR_XFER_SIZE */
  4270. #ifdef _PC_REC_MAX_XFER_SIZE
  4271. if (x == _PC_REC_MAX_XFER_SIZE)
  4272. {*r = Mono_Posix_PathconfName__PC_REC_MAX_XFER_SIZE; return 0;}
  4273. #endif /* ndef _PC_REC_MAX_XFER_SIZE */
  4274. #ifdef _PC_REC_MIN_XFER_SIZE
  4275. if (x == _PC_REC_MIN_XFER_SIZE)
  4276. {*r = Mono_Posix_PathconfName__PC_REC_MIN_XFER_SIZE; return 0;}
  4277. #endif /* ndef _PC_REC_MIN_XFER_SIZE */
  4278. #ifdef _PC_REC_XFER_ALIGN
  4279. if (x == _PC_REC_XFER_ALIGN)
  4280. {*r = Mono_Posix_PathconfName__PC_REC_XFER_ALIGN; return 0;}
  4281. #endif /* ndef _PC_REC_XFER_ALIGN */
  4282. #ifdef _PC_SOCK_MAXBUF
  4283. if (x == _PC_SOCK_MAXBUF)
  4284. {*r = Mono_Posix_PathconfName__PC_SOCK_MAXBUF; return 0;}
  4285. #endif /* ndef _PC_SOCK_MAXBUF */
  4286. #ifdef _PC_SYMLINK_MAX
  4287. if (x == _PC_SYMLINK_MAX)
  4288. {*r = Mono_Posix_PathconfName__PC_SYMLINK_MAX; return 0;}
  4289. #endif /* ndef _PC_SYMLINK_MAX */
  4290. #ifdef _PC_SYNC_IO
  4291. if (x == _PC_SYNC_IO)
  4292. {*r = Mono_Posix_PathconfName__PC_SYNC_IO; return 0;}
  4293. #endif /* ndef _PC_SYNC_IO */
  4294. #ifdef _PC_VDISABLE
  4295. if (x == _PC_VDISABLE)
  4296. {*r = Mono_Posix_PathconfName__PC_VDISABLE; return 0;}
  4297. #endif /* ndef _PC_VDISABLE */
  4298. errno = EINVAL; return -1;
  4299. }
  4300. int Mono_Posix_FromPollEvents (short x, short *r)
  4301. {
  4302. *r = 0;
  4303. if ((x & Mono_Posix_PollEvents_POLLERR) == Mono_Posix_PollEvents_POLLERR)
  4304. #ifdef POLLERR
  4305. *r |= POLLERR;
  4306. #else /* def POLLERR */
  4307. {errno = EINVAL; return -1;}
  4308. #endif /* ndef POLLERR */
  4309. if ((x & Mono_Posix_PollEvents_POLLHUP) == Mono_Posix_PollEvents_POLLHUP)
  4310. #ifdef POLLHUP
  4311. *r |= POLLHUP;
  4312. #else /* def POLLHUP */
  4313. {errno = EINVAL; return -1;}
  4314. #endif /* ndef POLLHUP */
  4315. if ((x & Mono_Posix_PollEvents_POLLIN) == Mono_Posix_PollEvents_POLLIN)
  4316. #ifdef POLLIN
  4317. *r |= POLLIN;
  4318. #else /* def POLLIN */
  4319. {errno = EINVAL; return -1;}
  4320. #endif /* ndef POLLIN */
  4321. if ((x & Mono_Posix_PollEvents_POLLNVAL) == Mono_Posix_PollEvents_POLLNVAL)
  4322. #ifdef POLLNVAL
  4323. *r |= POLLNVAL;
  4324. #else /* def POLLNVAL */
  4325. {errno = EINVAL; return -1;}
  4326. #endif /* ndef POLLNVAL */
  4327. if ((x & Mono_Posix_PollEvents_POLLOUT) == Mono_Posix_PollEvents_POLLOUT)
  4328. #ifdef POLLOUT
  4329. *r |= POLLOUT;
  4330. #else /* def POLLOUT */
  4331. {errno = EINVAL; return -1;}
  4332. #endif /* ndef POLLOUT */
  4333. if ((x & Mono_Posix_PollEvents_POLLPRI) == Mono_Posix_PollEvents_POLLPRI)
  4334. #ifdef POLLPRI
  4335. *r |= POLLPRI;
  4336. #else /* def POLLPRI */
  4337. {errno = EINVAL; return -1;}
  4338. #endif /* ndef POLLPRI */
  4339. if ((x & Mono_Posix_PollEvents_POLLRDBAND) == Mono_Posix_PollEvents_POLLRDBAND)
  4340. #ifdef POLLRDBAND
  4341. *r |= POLLRDBAND;
  4342. #else /* def POLLRDBAND */
  4343. {errno = EINVAL; return -1;}
  4344. #endif /* ndef POLLRDBAND */
  4345. if ((x & Mono_Posix_PollEvents_POLLRDNORM) == Mono_Posix_PollEvents_POLLRDNORM)
  4346. #ifdef POLLRDNORM
  4347. *r |= POLLRDNORM;
  4348. #else /* def POLLRDNORM */
  4349. {errno = EINVAL; return -1;}
  4350. #endif /* ndef POLLRDNORM */
  4351. if ((x & Mono_Posix_PollEvents_POLLWRBAND) == Mono_Posix_PollEvents_POLLWRBAND)
  4352. #ifdef POLLWRBAND
  4353. *r |= POLLWRBAND;
  4354. #else /* def POLLWRBAND */
  4355. {errno = EINVAL; return -1;}
  4356. #endif /* ndef POLLWRBAND */
  4357. if ((x & Mono_Posix_PollEvents_POLLWRNORM) == Mono_Posix_PollEvents_POLLWRNORM)
  4358. #ifdef POLLWRNORM
  4359. *r |= POLLWRNORM;
  4360. #else /* def POLLWRNORM */
  4361. {errno = EINVAL; return -1;}
  4362. #endif /* ndef POLLWRNORM */
  4363. if (x == 0)
  4364. return 0;
  4365. return 0;
  4366. }
  4367. int Mono_Posix_ToPollEvents (short x, short *r)
  4368. {
  4369. *r = 0;
  4370. if (x == 0)
  4371. return 0;
  4372. #ifdef POLLERR
  4373. if ((x & POLLERR) == POLLERR)
  4374. *r |= Mono_Posix_PollEvents_POLLERR;
  4375. #endif /* ndef POLLERR */
  4376. #ifdef POLLHUP
  4377. if ((x & POLLHUP) == POLLHUP)
  4378. *r |= Mono_Posix_PollEvents_POLLHUP;
  4379. #endif /* ndef POLLHUP */
  4380. #ifdef POLLIN
  4381. if ((x & POLLIN) == POLLIN)
  4382. *r |= Mono_Posix_PollEvents_POLLIN;
  4383. #endif /* ndef POLLIN */
  4384. #ifdef POLLNVAL
  4385. if ((x & POLLNVAL) == POLLNVAL)
  4386. *r |= Mono_Posix_PollEvents_POLLNVAL;
  4387. #endif /* ndef POLLNVAL */
  4388. #ifdef POLLOUT
  4389. if ((x & POLLOUT) == POLLOUT)
  4390. *r |= Mono_Posix_PollEvents_POLLOUT;
  4391. #endif /* ndef POLLOUT */
  4392. #ifdef POLLPRI
  4393. if ((x & POLLPRI) == POLLPRI)
  4394. *r |= Mono_Posix_PollEvents_POLLPRI;
  4395. #endif /* ndef POLLPRI */
  4396. #ifdef POLLRDBAND
  4397. if ((x & POLLRDBAND) == POLLRDBAND)
  4398. *r |= Mono_Posix_PollEvents_POLLRDBAND;
  4399. #endif /* ndef POLLRDBAND */
  4400. #ifdef POLLRDNORM
  4401. if ((x & POLLRDNORM) == POLLRDNORM)
  4402. *r |= Mono_Posix_PollEvents_POLLRDNORM;
  4403. #endif /* ndef POLLRDNORM */
  4404. #ifdef POLLWRBAND
  4405. if ((x & POLLWRBAND) == POLLWRBAND)
  4406. *r |= Mono_Posix_PollEvents_POLLWRBAND;
  4407. #endif /* ndef POLLWRBAND */
  4408. #ifdef POLLWRNORM
  4409. if ((x & POLLWRNORM) == POLLWRNORM)
  4410. *r |= Mono_Posix_PollEvents_POLLWRNORM;
  4411. #endif /* ndef POLLWRNORM */
  4412. return 0;
  4413. }
  4414. #ifdef HAVE_STRUCT_POLLFD
  4415. int
  4416. Mono_Posix_FromPollfd (struct Mono_Posix_Pollfd *from, struct pollfd *to)
  4417. {
  4418. _cnm_return_val_if_overflow (int, from->fd, -1);
  4419. memset (to, 0, sizeof(*to));
  4420. to->fd = from->fd;
  4421. if (Mono_Posix_FromPollEvents (from->events, &to->events) != 0) {
  4422. return -1;
  4423. }
  4424. if (Mono_Posix_FromPollEvents (from->revents, &to->revents) != 0) {
  4425. return -1;
  4426. }
  4427. return 0;
  4428. }
  4429. #endif /* ndef HAVE_STRUCT_POLLFD */
  4430. #ifdef HAVE_STRUCT_POLLFD
  4431. int
  4432. Mono_Posix_ToPollfd (struct pollfd *from, struct Mono_Posix_Pollfd *to)
  4433. {
  4434. _cnm_return_val_if_overflow (int, from->fd, -1);
  4435. memset (to, 0, sizeof(*to));
  4436. to->fd = from->fd;
  4437. if (Mono_Posix_ToPollEvents (from->events, &to->events) != 0) {
  4438. return -1;
  4439. }
  4440. if (Mono_Posix_ToPollEvents (from->revents, &to->revents) != 0) {
  4441. return -1;
  4442. }
  4443. return 0;
  4444. }
  4445. #endif /* ndef HAVE_STRUCT_POLLFD */
  4446. int Mono_Posix_FromPosixFadviseAdvice (int x, int *r)
  4447. {
  4448. *r = 0;
  4449. if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_DONTNEED)
  4450. #ifdef POSIX_FADV_DONTNEED
  4451. {*r = POSIX_FADV_DONTNEED; return 0;}
  4452. #else /* def POSIX_FADV_DONTNEED */
  4453. {errno = EINVAL; return -1;}
  4454. #endif /* ndef POSIX_FADV_DONTNEED */
  4455. if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_NOREUSE)
  4456. #ifdef POSIX_FADV_NOREUSE
  4457. {*r = POSIX_FADV_NOREUSE; return 0;}
  4458. #else /* def POSIX_FADV_NOREUSE */
  4459. {errno = EINVAL; return -1;}
  4460. #endif /* ndef POSIX_FADV_NOREUSE */
  4461. if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_NORMAL)
  4462. #ifdef POSIX_FADV_NORMAL
  4463. {*r = POSIX_FADV_NORMAL; return 0;}
  4464. #else /* def POSIX_FADV_NORMAL */
  4465. {errno = EINVAL; return -1;}
  4466. #endif /* ndef POSIX_FADV_NORMAL */
  4467. if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_RANDOM)
  4468. #ifdef POSIX_FADV_RANDOM
  4469. {*r = POSIX_FADV_RANDOM; return 0;}
  4470. #else /* def POSIX_FADV_RANDOM */
  4471. {errno = EINVAL; return -1;}
  4472. #endif /* ndef POSIX_FADV_RANDOM */
  4473. if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_SEQUENTIAL)
  4474. #ifdef POSIX_FADV_SEQUENTIAL
  4475. {*r = POSIX_FADV_SEQUENTIAL; return 0;}
  4476. #else /* def POSIX_FADV_SEQUENTIAL */
  4477. {errno = EINVAL; return -1;}
  4478. #endif /* ndef POSIX_FADV_SEQUENTIAL */
  4479. if (x == Mono_Posix_PosixFadviseAdvice_POSIX_FADV_WILLNEED)
  4480. #ifdef POSIX_FADV_WILLNEED
  4481. {*r = POSIX_FADV_WILLNEED; return 0;}
  4482. #else /* def POSIX_FADV_WILLNEED */
  4483. {errno = EINVAL; return -1;}
  4484. #endif /* ndef POSIX_FADV_WILLNEED */
  4485. if (x == 0)
  4486. return 0;
  4487. errno = EINVAL; return -1;
  4488. }
  4489. int Mono_Posix_ToPosixFadviseAdvice (int x, int *r)
  4490. {
  4491. *r = 0;
  4492. if (x == 0)
  4493. return 0;
  4494. #ifdef POSIX_FADV_DONTNEED
  4495. if (x == POSIX_FADV_DONTNEED)
  4496. {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_DONTNEED; return 0;}
  4497. #endif /* ndef POSIX_FADV_DONTNEED */
  4498. #ifdef POSIX_FADV_NOREUSE
  4499. if (x == POSIX_FADV_NOREUSE)
  4500. {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_NOREUSE; return 0;}
  4501. #endif /* ndef POSIX_FADV_NOREUSE */
  4502. #ifdef POSIX_FADV_NORMAL
  4503. if (x == POSIX_FADV_NORMAL)
  4504. {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_NORMAL; return 0;}
  4505. #endif /* ndef POSIX_FADV_NORMAL */
  4506. #ifdef POSIX_FADV_RANDOM
  4507. if (x == POSIX_FADV_RANDOM)
  4508. {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_RANDOM; return 0;}
  4509. #endif /* ndef POSIX_FADV_RANDOM */
  4510. #ifdef POSIX_FADV_SEQUENTIAL
  4511. if (x == POSIX_FADV_SEQUENTIAL)
  4512. {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_SEQUENTIAL; return 0;}
  4513. #endif /* ndef POSIX_FADV_SEQUENTIAL */
  4514. #ifdef POSIX_FADV_WILLNEED
  4515. if (x == POSIX_FADV_WILLNEED)
  4516. {*r = Mono_Posix_PosixFadviseAdvice_POSIX_FADV_WILLNEED; return 0;}
  4517. #endif /* ndef POSIX_FADV_WILLNEED */
  4518. errno = EINVAL; return -1;
  4519. }
  4520. int Mono_Posix_FromPosixMadviseAdvice (int x, int *r)
  4521. {
  4522. *r = 0;
  4523. if (x == Mono_Posix_PosixMadviseAdvice_POSIX_MADV_DONTNEED)
  4524. #ifdef POSIX_MADV_DONTNEED
  4525. {*r = POSIX_MADV_DONTNEED; return 0;}
  4526. #else /* def POSIX_MADV_DONTNEED */
  4527. {errno = EINVAL; return -1;}
  4528. #endif /* ndef POSIX_MADV_DONTNEED */
  4529. if (x == Mono_Posix_PosixMadviseAdvice_POSIX_MADV_NORMAL)
  4530. #ifdef POSIX_MADV_NORMAL
  4531. {*r = POSIX_MADV_NORMAL; return 0;}
  4532. #else /* def POSIX_MADV_NORMAL */
  4533. {errno = EINVAL; return -1;}
  4534. #endif /* ndef POSIX_MADV_NORMAL */
  4535. if (x == Mono_Posix_PosixMadviseAdvice_POSIX_MADV_RANDOM)
  4536. #ifdef POSIX_MADV_RANDOM
  4537. {*r = POSIX_MADV_RANDOM; return 0;}
  4538. #else /* def POSIX_MADV_RANDOM */
  4539. {errno = EINVAL; return -1;}
  4540. #endif /* ndef POSIX_MADV_RANDOM */
  4541. if (x == Mono_Posix_PosixMadviseAdvice_POSIX_MADV_SEQUENTIAL)
  4542. #ifdef POSIX_MADV_SEQUENTIAL
  4543. {*r = POSIX_MADV_SEQUENTIAL; return 0;}
  4544. #else /* def POSIX_MADV_SEQUENTIAL */
  4545. {errno = EINVAL; return -1;}
  4546. #endif /* ndef POSIX_MADV_SEQUENTIAL */
  4547. if (x == Mono_Posix_PosixMadviseAdvice_POSIX_MADV_WILLNEED)
  4548. #ifdef POSIX_MADV_WILLNEED
  4549. {*r = POSIX_MADV_WILLNEED; return 0;}
  4550. #else /* def POSIX_MADV_WILLNEED */
  4551. {errno = EINVAL; return -1;}
  4552. #endif /* ndef POSIX_MADV_WILLNEED */
  4553. if (x == 0)
  4554. return 0;
  4555. errno = EINVAL; return -1;
  4556. }
  4557. int Mono_Posix_ToPosixMadviseAdvice (int x, int *r)
  4558. {
  4559. *r = 0;
  4560. if (x == 0)
  4561. return 0;
  4562. #ifdef POSIX_MADV_DONTNEED
  4563. if (x == POSIX_MADV_DONTNEED)
  4564. {*r = Mono_Posix_PosixMadviseAdvice_POSIX_MADV_DONTNEED; return 0;}
  4565. #endif /* ndef POSIX_MADV_DONTNEED */
  4566. #ifdef POSIX_MADV_NORMAL
  4567. if (x == POSIX_MADV_NORMAL)
  4568. {*r = Mono_Posix_PosixMadviseAdvice_POSIX_MADV_NORMAL; return 0;}
  4569. #endif /* ndef POSIX_MADV_NORMAL */
  4570. #ifdef POSIX_MADV_RANDOM
  4571. if (x == POSIX_MADV_RANDOM)
  4572. {*r = Mono_Posix_PosixMadviseAdvice_POSIX_MADV_RANDOM; return 0;}
  4573. #endif /* ndef POSIX_MADV_RANDOM */
  4574. #ifdef POSIX_MADV_SEQUENTIAL
  4575. if (x == POSIX_MADV_SEQUENTIAL)
  4576. {*r = Mono_Posix_PosixMadviseAdvice_POSIX_MADV_SEQUENTIAL; return 0;}
  4577. #endif /* ndef POSIX_MADV_SEQUENTIAL */
  4578. #ifdef POSIX_MADV_WILLNEED
  4579. if (x == POSIX_MADV_WILLNEED)
  4580. {*r = Mono_Posix_PosixMadviseAdvice_POSIX_MADV_WILLNEED; return 0;}
  4581. #endif /* ndef POSIX_MADV_WILLNEED */
  4582. errno = EINVAL; return -1;
  4583. }
  4584. int Mono_Posix_FromSeekFlags (short x, short *r)
  4585. {
  4586. *r = 0;
  4587. if (x == Mono_Posix_SeekFlags_L_INCR)
  4588. #ifdef L_INCR
  4589. {*r = L_INCR; return 0;}
  4590. #else /* def L_INCR */
  4591. {errno = EINVAL; return -1;}
  4592. #endif /* ndef L_INCR */
  4593. if (x == Mono_Posix_SeekFlags_L_SET)
  4594. #ifdef L_SET
  4595. {*r = L_SET; return 0;}
  4596. #else /* def L_SET */
  4597. {errno = EINVAL; return -1;}
  4598. #endif /* ndef L_SET */
  4599. if (x == Mono_Posix_SeekFlags_L_XTND)
  4600. #ifdef L_XTND
  4601. {*r = L_XTND; return 0;}
  4602. #else /* def L_XTND */
  4603. {errno = EINVAL; return -1;}
  4604. #endif /* ndef L_XTND */
  4605. if (x == Mono_Posix_SeekFlags_SEEK_CUR)
  4606. #ifdef SEEK_CUR
  4607. {*r = SEEK_CUR; return 0;}
  4608. #else /* def SEEK_CUR */
  4609. {errno = EINVAL; return -1;}
  4610. #endif /* ndef SEEK_CUR */
  4611. if (x == Mono_Posix_SeekFlags_SEEK_END)
  4612. #ifdef SEEK_END
  4613. {*r = SEEK_END; return 0;}
  4614. #else /* def SEEK_END */
  4615. {errno = EINVAL; return -1;}
  4616. #endif /* ndef SEEK_END */
  4617. if (x == Mono_Posix_SeekFlags_SEEK_SET)
  4618. #ifdef SEEK_SET
  4619. {*r = SEEK_SET; return 0;}
  4620. #else /* def SEEK_SET */
  4621. {errno = EINVAL; return -1;}
  4622. #endif /* ndef SEEK_SET */
  4623. if (x == 0)
  4624. return 0;
  4625. errno = EINVAL; return -1;
  4626. }
  4627. int Mono_Posix_ToSeekFlags (short x, short *r)
  4628. {
  4629. *r = 0;
  4630. if (x == 0)
  4631. return 0;
  4632. #ifdef L_INCR
  4633. if (x == L_INCR)
  4634. {*r = Mono_Posix_SeekFlags_L_INCR; return 0;}
  4635. #endif /* ndef L_INCR */
  4636. #ifdef L_SET
  4637. if (x == L_SET)
  4638. {*r = Mono_Posix_SeekFlags_L_SET; return 0;}
  4639. #endif /* ndef L_SET */
  4640. #ifdef L_XTND
  4641. if (x == L_XTND)
  4642. {*r = Mono_Posix_SeekFlags_L_XTND; return 0;}
  4643. #endif /* ndef L_XTND */
  4644. #ifdef SEEK_CUR
  4645. if (x == SEEK_CUR)
  4646. {*r = Mono_Posix_SeekFlags_SEEK_CUR; return 0;}
  4647. #endif /* ndef SEEK_CUR */
  4648. #ifdef SEEK_END
  4649. if (x == SEEK_END)
  4650. {*r = Mono_Posix_SeekFlags_SEEK_END; return 0;}
  4651. #endif /* ndef SEEK_END */
  4652. #ifdef SEEK_SET
  4653. if (x == SEEK_SET)
  4654. {*r = Mono_Posix_SeekFlags_SEEK_SET; return 0;}
  4655. #endif /* ndef SEEK_SET */
  4656. errno = EINVAL; return -1;
  4657. }
  4658. int Mono_Posix_FromShutdownOption (int x, int *r)
  4659. {
  4660. *r = 0;
  4661. if (x == Mono_Posix_ShutdownOption_SHUT_RD)
  4662. #ifdef SHUT_RD
  4663. {*r = SHUT_RD; return 0;}
  4664. #else /* def SHUT_RD */
  4665. {errno = EINVAL; return -1;}
  4666. #endif /* ndef SHUT_RD */
  4667. if (x == Mono_Posix_ShutdownOption_SHUT_RDWR)
  4668. #ifdef SHUT_RDWR
  4669. {*r = SHUT_RDWR; return 0;}
  4670. #else /* def SHUT_RDWR */
  4671. {errno = EINVAL; return -1;}
  4672. #endif /* ndef SHUT_RDWR */
  4673. if (x == Mono_Posix_ShutdownOption_SHUT_WR)
  4674. #ifdef SHUT_WR
  4675. {*r = SHUT_WR; return 0;}
  4676. #else /* def SHUT_WR */
  4677. {errno = EINVAL; return -1;}
  4678. #endif /* ndef SHUT_WR */
  4679. if (x == 0)
  4680. return 0;
  4681. errno = EINVAL; return -1;
  4682. }
  4683. int Mono_Posix_ToShutdownOption (int x, int *r)
  4684. {
  4685. *r = 0;
  4686. if (x == 0)
  4687. return 0;
  4688. #ifdef SHUT_RD
  4689. if (x == SHUT_RD)
  4690. {*r = Mono_Posix_ShutdownOption_SHUT_RD; return 0;}
  4691. #endif /* ndef SHUT_RD */
  4692. #ifdef SHUT_RDWR
  4693. if (x == SHUT_RDWR)
  4694. {*r = Mono_Posix_ShutdownOption_SHUT_RDWR; return 0;}
  4695. #endif /* ndef SHUT_RDWR */
  4696. #ifdef SHUT_WR
  4697. if (x == SHUT_WR)
  4698. {*r = Mono_Posix_ShutdownOption_SHUT_WR; return 0;}
  4699. #endif /* ndef SHUT_WR */
  4700. errno = EINVAL; return -1;
  4701. }
  4702. int Mono_Posix_FromSignum (int x, int *r)
  4703. {
  4704. *r = 0;
  4705. if (x == Mono_Posix_Signum_SIGABRT)
  4706. #ifdef SIGABRT
  4707. {*r = SIGABRT; return 0;}
  4708. #else /* def SIGABRT */
  4709. {errno = EINVAL; return -1;}
  4710. #endif /* ndef SIGABRT */
  4711. if (x == Mono_Posix_Signum_SIGALRM)
  4712. #ifdef SIGALRM
  4713. {*r = SIGALRM; return 0;}
  4714. #else /* def SIGALRM */
  4715. {errno = EINVAL; return -1;}
  4716. #endif /* ndef SIGALRM */
  4717. if (x == Mono_Posix_Signum_SIGBUS)
  4718. #ifdef SIGBUS
  4719. {*r = SIGBUS; return 0;}
  4720. #else /* def SIGBUS */
  4721. {errno = EINVAL; return -1;}
  4722. #endif /* ndef SIGBUS */
  4723. if (x == Mono_Posix_Signum_SIGCHLD)
  4724. #ifdef SIGCHLD
  4725. {*r = SIGCHLD; return 0;}
  4726. #else /* def SIGCHLD */
  4727. {errno = EINVAL; return -1;}
  4728. #endif /* ndef SIGCHLD */
  4729. if (x == Mono_Posix_Signum_SIGCLD)
  4730. #ifdef SIGCLD
  4731. {*r = SIGCLD; return 0;}
  4732. #else /* def SIGCLD */
  4733. {errno = EINVAL; return -1;}
  4734. #endif /* ndef SIGCLD */
  4735. if (x == Mono_Posix_Signum_SIGCONT)
  4736. #ifdef SIGCONT
  4737. {*r = SIGCONT; return 0;}
  4738. #else /* def SIGCONT */
  4739. {errno = EINVAL; return -1;}
  4740. #endif /* ndef SIGCONT */
  4741. if (x == Mono_Posix_Signum_SIGFPE)
  4742. #ifdef SIGFPE
  4743. {*r = SIGFPE; return 0;}
  4744. #else /* def SIGFPE */
  4745. {errno = EINVAL; return -1;}
  4746. #endif /* ndef SIGFPE */
  4747. if (x == Mono_Posix_Signum_SIGHUP)
  4748. #ifdef SIGHUP
  4749. {*r = SIGHUP; return 0;}
  4750. #else /* def SIGHUP */
  4751. {errno = EINVAL; return -1;}
  4752. #endif /* ndef SIGHUP */
  4753. if (x == Mono_Posix_Signum_SIGILL)
  4754. #ifdef SIGILL
  4755. {*r = SIGILL; return 0;}
  4756. #else /* def SIGILL */
  4757. {errno = EINVAL; return -1;}
  4758. #endif /* ndef SIGILL */
  4759. if (x == Mono_Posix_Signum_SIGINT)
  4760. #ifdef SIGINT
  4761. {*r = SIGINT; return 0;}
  4762. #else /* def SIGINT */
  4763. {errno = EINVAL; return -1;}
  4764. #endif /* ndef SIGINT */
  4765. if (x == Mono_Posix_Signum_SIGIO)
  4766. #ifdef SIGIO
  4767. {*r = SIGIO; return 0;}
  4768. #else /* def SIGIO */
  4769. {errno = EINVAL; return -1;}
  4770. #endif /* ndef SIGIO */
  4771. if (x == Mono_Posix_Signum_SIGIOT)
  4772. #ifdef SIGIOT
  4773. {*r = SIGIOT; return 0;}
  4774. #else /* def SIGIOT */
  4775. {errno = EINVAL; return -1;}
  4776. #endif /* ndef SIGIOT */
  4777. if (x == Mono_Posix_Signum_SIGKILL)
  4778. #ifdef SIGKILL
  4779. {*r = SIGKILL; return 0;}
  4780. #else /* def SIGKILL */
  4781. {errno = EINVAL; return -1;}
  4782. #endif /* ndef SIGKILL */
  4783. if (x == Mono_Posix_Signum_SIGPIPE)
  4784. #ifdef SIGPIPE
  4785. {*r = SIGPIPE; return 0;}
  4786. #else /* def SIGPIPE */
  4787. {errno = EINVAL; return -1;}
  4788. #endif /* ndef SIGPIPE */
  4789. if (x == Mono_Posix_Signum_SIGPOLL)
  4790. #ifdef SIGPOLL
  4791. {*r = SIGPOLL; return 0;}
  4792. #else /* def SIGPOLL */
  4793. {errno = EINVAL; return -1;}
  4794. #endif /* ndef SIGPOLL */
  4795. if (x == Mono_Posix_Signum_SIGPROF)
  4796. #ifdef SIGPROF
  4797. {*r = SIGPROF; return 0;}
  4798. #else /* def SIGPROF */
  4799. {errno = EINVAL; return -1;}
  4800. #endif /* ndef SIGPROF */
  4801. if (x == Mono_Posix_Signum_SIGPWR)
  4802. #ifdef SIGPWR
  4803. {*r = SIGPWR; return 0;}
  4804. #else /* def SIGPWR */
  4805. {errno = EINVAL; return -1;}
  4806. #endif /* ndef SIGPWR */
  4807. if (x == Mono_Posix_Signum_SIGQUIT)
  4808. #ifdef SIGQUIT
  4809. {*r = SIGQUIT; return 0;}
  4810. #else /* def SIGQUIT */
  4811. {errno = EINVAL; return -1;}
  4812. #endif /* ndef SIGQUIT */
  4813. if (x == Mono_Posix_Signum_SIGSEGV)
  4814. #ifdef SIGSEGV
  4815. {*r = SIGSEGV; return 0;}
  4816. #else /* def SIGSEGV */
  4817. {errno = EINVAL; return -1;}
  4818. #endif /* ndef SIGSEGV */
  4819. if (x == Mono_Posix_Signum_SIGSTKFLT)
  4820. #ifdef SIGSTKFLT
  4821. {*r = SIGSTKFLT; return 0;}
  4822. #else /* def SIGSTKFLT */
  4823. {errno = EINVAL; return -1;}
  4824. #endif /* ndef SIGSTKFLT */
  4825. if (x == Mono_Posix_Signum_SIGSTOP)
  4826. #ifdef SIGSTOP
  4827. {*r = SIGSTOP; return 0;}
  4828. #else /* def SIGSTOP */
  4829. {errno = EINVAL; return -1;}
  4830. #endif /* ndef SIGSTOP */
  4831. if (x == Mono_Posix_Signum_SIGSYS)
  4832. #ifdef SIGSYS
  4833. {*r = SIGSYS; return 0;}
  4834. #else /* def SIGSYS */
  4835. {errno = EINVAL; return -1;}
  4836. #endif /* ndef SIGSYS */
  4837. if (x == Mono_Posix_Signum_SIGTERM)
  4838. #ifdef SIGTERM
  4839. {*r = SIGTERM; return 0;}
  4840. #else /* def SIGTERM */
  4841. {errno = EINVAL; return -1;}
  4842. #endif /* ndef SIGTERM */
  4843. if (x == Mono_Posix_Signum_SIGTRAP)
  4844. #ifdef SIGTRAP
  4845. {*r = SIGTRAP; return 0;}
  4846. #else /* def SIGTRAP */
  4847. {errno = EINVAL; return -1;}
  4848. #endif /* ndef SIGTRAP */
  4849. if (x == Mono_Posix_Signum_SIGTSTP)
  4850. #ifdef SIGTSTP
  4851. {*r = SIGTSTP; return 0;}
  4852. #else /* def SIGTSTP */
  4853. {errno = EINVAL; return -1;}
  4854. #endif /* ndef SIGTSTP */
  4855. if (x == Mono_Posix_Signum_SIGTTIN)
  4856. #ifdef SIGTTIN
  4857. {*r = SIGTTIN; return 0;}
  4858. #else /* def SIGTTIN */
  4859. {errno = EINVAL; return -1;}
  4860. #endif /* ndef SIGTTIN */
  4861. if (x == Mono_Posix_Signum_SIGTTOU)
  4862. #ifdef SIGTTOU
  4863. {*r = SIGTTOU; return 0;}
  4864. #else /* def SIGTTOU */
  4865. {errno = EINVAL; return -1;}
  4866. #endif /* ndef SIGTTOU */
  4867. if (x == Mono_Posix_Signum_SIGUNUSED)
  4868. #ifdef SIGUNUSED
  4869. {*r = SIGUNUSED; return 0;}
  4870. #else /* def SIGUNUSED */
  4871. {errno = EINVAL; return -1;}
  4872. #endif /* ndef SIGUNUSED */
  4873. if (x == Mono_Posix_Signum_SIGURG)
  4874. #ifdef SIGURG
  4875. {*r = SIGURG; return 0;}
  4876. #else /* def SIGURG */
  4877. {errno = EINVAL; return -1;}
  4878. #endif /* ndef SIGURG */
  4879. if (x == Mono_Posix_Signum_SIGUSR1)
  4880. #ifdef SIGUSR1
  4881. {*r = SIGUSR1; return 0;}
  4882. #else /* def SIGUSR1 */
  4883. {errno = EINVAL; return -1;}
  4884. #endif /* ndef SIGUSR1 */
  4885. if (x == Mono_Posix_Signum_SIGUSR2)
  4886. #ifdef SIGUSR2
  4887. {*r = SIGUSR2; return 0;}
  4888. #else /* def SIGUSR2 */
  4889. {errno = EINVAL; return -1;}
  4890. #endif /* ndef SIGUSR2 */
  4891. if (x == Mono_Posix_Signum_SIGVTALRM)
  4892. #ifdef SIGVTALRM
  4893. {*r = SIGVTALRM; return 0;}
  4894. #else /* def SIGVTALRM */
  4895. {errno = EINVAL; return -1;}
  4896. #endif /* ndef SIGVTALRM */
  4897. if (x == Mono_Posix_Signum_SIGWINCH)
  4898. #ifdef SIGWINCH
  4899. {*r = SIGWINCH; return 0;}
  4900. #else /* def SIGWINCH */
  4901. {errno = EINVAL; return -1;}
  4902. #endif /* ndef SIGWINCH */
  4903. if (x == Mono_Posix_Signum_SIGXCPU)
  4904. #ifdef SIGXCPU
  4905. {*r = SIGXCPU; return 0;}
  4906. #else /* def SIGXCPU */
  4907. {errno = EINVAL; return -1;}
  4908. #endif /* ndef SIGXCPU */
  4909. if (x == Mono_Posix_Signum_SIGXFSZ)
  4910. #ifdef SIGXFSZ
  4911. {*r = SIGXFSZ; return 0;}
  4912. #else /* def SIGXFSZ */
  4913. {errno = EINVAL; return -1;}
  4914. #endif /* ndef SIGXFSZ */
  4915. if (x == 0)
  4916. return 0;
  4917. errno = EINVAL; return -1;
  4918. }
  4919. int Mono_Posix_ToSignum (int x, int *r)
  4920. {
  4921. *r = 0;
  4922. if (x == 0)
  4923. return 0;
  4924. #ifdef SIGABRT
  4925. if (x == SIGABRT)
  4926. {*r = Mono_Posix_Signum_SIGABRT; return 0;}
  4927. #endif /* ndef SIGABRT */
  4928. #ifdef SIGALRM
  4929. if (x == SIGALRM)
  4930. {*r = Mono_Posix_Signum_SIGALRM; return 0;}
  4931. #endif /* ndef SIGALRM */
  4932. #ifdef SIGBUS
  4933. if (x == SIGBUS)
  4934. {*r = Mono_Posix_Signum_SIGBUS; return 0;}
  4935. #endif /* ndef SIGBUS */
  4936. #ifdef SIGCHLD
  4937. if (x == SIGCHLD)
  4938. {*r = Mono_Posix_Signum_SIGCHLD; return 0;}
  4939. #endif /* ndef SIGCHLD */
  4940. #ifdef SIGCLD
  4941. if (x == SIGCLD)
  4942. {*r = Mono_Posix_Signum_SIGCLD; return 0;}
  4943. #endif /* ndef SIGCLD */
  4944. #ifdef SIGCONT
  4945. if (x == SIGCONT)
  4946. {*r = Mono_Posix_Signum_SIGCONT; return 0;}
  4947. #endif /* ndef SIGCONT */
  4948. #ifdef SIGFPE
  4949. if (x == SIGFPE)
  4950. {*r = Mono_Posix_Signum_SIGFPE; return 0;}
  4951. #endif /* ndef SIGFPE */
  4952. #ifdef SIGHUP
  4953. if (x == SIGHUP)
  4954. {*r = Mono_Posix_Signum_SIGHUP; return 0;}
  4955. #endif /* ndef SIGHUP */
  4956. #ifdef SIGILL
  4957. if (x == SIGILL)
  4958. {*r = Mono_Posix_Signum_SIGILL; return 0;}
  4959. #endif /* ndef SIGILL */
  4960. #ifdef SIGINT
  4961. if (x == SIGINT)
  4962. {*r = Mono_Posix_Signum_SIGINT; return 0;}
  4963. #endif /* ndef SIGINT */
  4964. #ifdef SIGIO
  4965. if (x == SIGIO)
  4966. {*r = Mono_Posix_Signum_SIGIO; return 0;}
  4967. #endif /* ndef SIGIO */
  4968. #ifdef SIGIOT
  4969. if (x == SIGIOT)
  4970. {*r = Mono_Posix_Signum_SIGIOT; return 0;}
  4971. #endif /* ndef SIGIOT */
  4972. #ifdef SIGKILL
  4973. if (x == SIGKILL)
  4974. {*r = Mono_Posix_Signum_SIGKILL; return 0;}
  4975. #endif /* ndef SIGKILL */
  4976. #ifdef SIGPIPE
  4977. if (x == SIGPIPE)
  4978. {*r = Mono_Posix_Signum_SIGPIPE; return 0;}
  4979. #endif /* ndef SIGPIPE */
  4980. #ifdef SIGPOLL
  4981. if (x == SIGPOLL)
  4982. {*r = Mono_Posix_Signum_SIGPOLL; return 0;}
  4983. #endif /* ndef SIGPOLL */
  4984. #ifdef SIGPROF
  4985. if (x == SIGPROF)
  4986. {*r = Mono_Posix_Signum_SIGPROF; return 0;}
  4987. #endif /* ndef SIGPROF */
  4988. #ifdef SIGPWR
  4989. if (x == SIGPWR)
  4990. {*r = Mono_Posix_Signum_SIGPWR; return 0;}
  4991. #endif /* ndef SIGPWR */
  4992. #ifdef SIGQUIT
  4993. if (x == SIGQUIT)
  4994. {*r = Mono_Posix_Signum_SIGQUIT; return 0;}
  4995. #endif /* ndef SIGQUIT */
  4996. #ifdef SIGSEGV
  4997. if (x == SIGSEGV)
  4998. {*r = Mono_Posix_Signum_SIGSEGV; return 0;}
  4999. #endif /* ndef SIGSEGV */
  5000. #ifdef SIGSTKFLT
  5001. if (x == SIGSTKFLT)
  5002. {*r = Mono_Posix_Signum_SIGSTKFLT; return 0;}
  5003. #endif /* ndef SIGSTKFLT */
  5004. #ifdef SIGSTOP
  5005. if (x == SIGSTOP)
  5006. {*r = Mono_Posix_Signum_SIGSTOP; return 0;}
  5007. #endif /* ndef SIGSTOP */
  5008. #ifdef SIGSYS
  5009. if (x == SIGSYS)
  5010. {*r = Mono_Posix_Signum_SIGSYS; return 0;}
  5011. #endif /* ndef SIGSYS */
  5012. #ifdef SIGTERM
  5013. if (x == SIGTERM)
  5014. {*r = Mono_Posix_Signum_SIGTERM; return 0;}
  5015. #endif /* ndef SIGTERM */
  5016. #ifdef SIGTRAP
  5017. if (x == SIGTRAP)
  5018. {*r = Mono_Posix_Signum_SIGTRAP; return 0;}
  5019. #endif /* ndef SIGTRAP */
  5020. #ifdef SIGTSTP
  5021. if (x == SIGTSTP)
  5022. {*r = Mono_Posix_Signum_SIGTSTP; return 0;}
  5023. #endif /* ndef SIGTSTP */
  5024. #ifdef SIGTTIN
  5025. if (x == SIGTTIN)
  5026. {*r = Mono_Posix_Signum_SIGTTIN; return 0;}
  5027. #endif /* ndef SIGTTIN */
  5028. #ifdef SIGTTOU
  5029. if (x == SIGTTOU)
  5030. {*r = Mono_Posix_Signum_SIGTTOU; return 0;}
  5031. #endif /* ndef SIGTTOU */
  5032. #ifdef SIGUNUSED
  5033. if (x == SIGUNUSED)
  5034. {*r = Mono_Posix_Signum_SIGUNUSED; return 0;}
  5035. #endif /* ndef SIGUNUSED */
  5036. #ifdef SIGURG
  5037. if (x == SIGURG)
  5038. {*r = Mono_Posix_Signum_SIGURG; return 0;}
  5039. #endif /* ndef SIGURG */
  5040. #ifdef SIGUSR1
  5041. if (x == SIGUSR1)
  5042. {*r = Mono_Posix_Signum_SIGUSR1; return 0;}
  5043. #endif /* ndef SIGUSR1 */
  5044. #ifdef SIGUSR2
  5045. if (x == SIGUSR2)
  5046. {*r = Mono_Posix_Signum_SIGUSR2; return 0;}
  5047. #endif /* ndef SIGUSR2 */
  5048. #ifdef SIGVTALRM
  5049. if (x == SIGVTALRM)
  5050. {*r = Mono_Posix_Signum_SIGVTALRM; return 0;}
  5051. #endif /* ndef SIGVTALRM */
  5052. #ifdef SIGWINCH
  5053. if (x == SIGWINCH)
  5054. {*r = Mono_Posix_Signum_SIGWINCH; return 0;}
  5055. #endif /* ndef SIGWINCH */
  5056. #ifdef SIGXCPU
  5057. if (x == SIGXCPU)
  5058. {*r = Mono_Posix_Signum_SIGXCPU; return 0;}
  5059. #endif /* ndef SIGXCPU */
  5060. #ifdef SIGXFSZ
  5061. if (x == SIGXFSZ)
  5062. {*r = Mono_Posix_Signum_SIGXFSZ; return 0;}
  5063. #endif /* ndef SIGXFSZ */
  5064. errno = EINVAL; return -1;
  5065. }
  5066. #ifdef HAVE_STRUCT_SOCKADDR_IN
  5067. int
  5068. Mono_Posix_FromSockaddrIn (struct Mono_Posix_SockaddrIn *from, struct sockaddr_in *to)
  5069. {
  5070. _cnm_return_val_if_overflow (unsigned short, from->sin_port, -1);
  5071. memset (to, 0, sizeof(*to));
  5072. to->sin_port = from->sin_port;
  5073. if (Mono_Posix_FromInAddr (&from->sin_addr, &to->sin_addr) != 0) {
  5074. return -1;
  5075. }
  5076. return 0;
  5077. }
  5078. #endif /* ndef HAVE_STRUCT_SOCKADDR_IN */
  5079. #ifdef HAVE_STRUCT_SOCKADDR_IN
  5080. int
  5081. Mono_Posix_ToSockaddrIn (struct sockaddr_in *from, struct Mono_Posix_SockaddrIn *to)
  5082. {
  5083. _cnm_return_val_if_overflow (unsigned short, from->sin_port, -1);
  5084. memset (to, 0, sizeof(*to));
  5085. to->sin_port = from->sin_port;
  5086. if (Mono_Posix_ToInAddr (&from->sin_addr, &to->sin_addr) != 0) {
  5087. return -1;
  5088. }
  5089. return 0;
  5090. }
  5091. #endif /* ndef HAVE_STRUCT_SOCKADDR_IN */
  5092. #ifdef HAVE_STRUCT_SOCKADDR_IN6
  5093. int
  5094. Mono_Posix_FromSockaddrIn6 (struct Mono_Posix_SockaddrIn6 *from, struct sockaddr_in6 *to)
  5095. {
  5096. _cnm_return_val_if_overflow (unsigned short, from->sin6_port, -1);
  5097. _cnm_return_val_if_overflow (unsigned int, from->sin6_flowinfo, -1);
  5098. _cnm_return_val_if_overflow (unsigned int, from->sin6_scope_id, -1);
  5099. memset (to, 0, sizeof(*to));
  5100. to->sin6_port = from->sin6_port;
  5101. to->sin6_flowinfo = from->sin6_flowinfo;
  5102. if (Mono_Posix_FromIn6Addr (&from->sin6_addr, &to->sin6_addr) != 0) {
  5103. return -1;
  5104. }
  5105. to->sin6_scope_id = from->sin6_scope_id;
  5106. return 0;
  5107. }
  5108. #endif /* ndef HAVE_STRUCT_SOCKADDR_IN6 */
  5109. #ifdef HAVE_STRUCT_SOCKADDR_IN6
  5110. int
  5111. Mono_Posix_ToSockaddrIn6 (struct sockaddr_in6 *from, struct Mono_Posix_SockaddrIn6 *to)
  5112. {
  5113. _cnm_return_val_if_overflow (unsigned short, from->sin6_port, -1);
  5114. _cnm_return_val_if_overflow (unsigned int, from->sin6_flowinfo, -1);
  5115. _cnm_return_val_if_overflow (unsigned int, from->sin6_scope_id, -1);
  5116. memset (to, 0, sizeof(*to));
  5117. to->sin6_port = from->sin6_port;
  5118. to->sin6_flowinfo = from->sin6_flowinfo;
  5119. if (Mono_Posix_ToIn6Addr (&from->sin6_addr, &to->sin6_addr) != 0) {
  5120. return -1;
  5121. }
  5122. to->sin6_scope_id = from->sin6_scope_id;
  5123. return 0;
  5124. }
  5125. #endif /* ndef HAVE_STRUCT_SOCKADDR_IN6 */
  5126. int Mono_Posix_FromSockaddrType (int x, int *r)
  5127. {
  5128. *r = 0;
  5129. if (x == Mono_Posix_SockaddrType_Invalid)
  5130. #ifdef Invalid
  5131. {*r = Invalid; return 0;}
  5132. #else /* def Invalid */
  5133. {errno = EINVAL; return -1;}
  5134. #endif /* ndef Invalid */
  5135. if (x == Mono_Posix_SockaddrType_MustBeWrapped)
  5136. #ifdef MustBeWrapped
  5137. {*r = MustBeWrapped; return 0;}
  5138. #else /* def MustBeWrapped */
  5139. {errno = EINVAL; return -1;}
  5140. #endif /* ndef MustBeWrapped */
  5141. if (x == Mono_Posix_SockaddrType_Sockaddr)
  5142. #ifdef Sockaddr
  5143. {*r = Sockaddr; return 0;}
  5144. #else /* def Sockaddr */
  5145. {errno = EINVAL; return -1;}
  5146. #endif /* ndef Sockaddr */
  5147. if (x == Mono_Posix_SockaddrType_SockaddrIn)
  5148. #ifdef SockaddrIn
  5149. {*r = SockaddrIn; return 0;}
  5150. #else /* def SockaddrIn */
  5151. {errno = EINVAL; return -1;}
  5152. #endif /* ndef SockaddrIn */
  5153. if (x == Mono_Posix_SockaddrType_SockaddrIn6)
  5154. #ifdef SockaddrIn6
  5155. {*r = SockaddrIn6; return 0;}
  5156. #else /* def SockaddrIn6 */
  5157. {errno = EINVAL; return -1;}
  5158. #endif /* ndef SockaddrIn6 */
  5159. if (x == Mono_Posix_SockaddrType_SockaddrStorage)
  5160. #ifdef SockaddrStorage
  5161. {*r = SockaddrStorage; return 0;}
  5162. #else /* def SockaddrStorage */
  5163. {errno = EINVAL; return -1;}
  5164. #endif /* ndef SockaddrStorage */
  5165. if (x == Mono_Posix_SockaddrType_SockaddrUn)
  5166. #ifdef SockaddrUn
  5167. {*r = SockaddrUn; return 0;}
  5168. #else /* def SockaddrUn */
  5169. {errno = EINVAL; return -1;}
  5170. #endif /* ndef SockaddrUn */
  5171. if (x == 0)
  5172. return 0;
  5173. errno = EINVAL; return -1;
  5174. }
  5175. int Mono_Posix_ToSockaddrType (int x, int *r)
  5176. {
  5177. *r = 0;
  5178. if (x == 0)
  5179. return 0;
  5180. #ifdef Invalid
  5181. if (x == Invalid)
  5182. {*r = Mono_Posix_SockaddrType_Invalid; return 0;}
  5183. #endif /* ndef Invalid */
  5184. #ifdef MustBeWrapped
  5185. if (x == MustBeWrapped)
  5186. {*r = Mono_Posix_SockaddrType_MustBeWrapped; return 0;}
  5187. #endif /* ndef MustBeWrapped */
  5188. #ifdef Sockaddr
  5189. if (x == Sockaddr)
  5190. {*r = Mono_Posix_SockaddrType_Sockaddr; return 0;}
  5191. #endif /* ndef Sockaddr */
  5192. #ifdef SockaddrIn
  5193. if (x == SockaddrIn)
  5194. {*r = Mono_Posix_SockaddrType_SockaddrIn; return 0;}
  5195. #endif /* ndef SockaddrIn */
  5196. #ifdef SockaddrIn6
  5197. if (x == SockaddrIn6)
  5198. {*r = Mono_Posix_SockaddrType_SockaddrIn6; return 0;}
  5199. #endif /* ndef SockaddrIn6 */
  5200. #ifdef SockaddrStorage
  5201. if (x == SockaddrStorage)
  5202. {*r = Mono_Posix_SockaddrType_SockaddrStorage; return 0;}
  5203. #endif /* ndef SockaddrStorage */
  5204. #ifdef SockaddrUn
  5205. if (x == SockaddrUn)
  5206. {*r = Mono_Posix_SockaddrType_SockaddrUn; return 0;}
  5207. #endif /* ndef SockaddrUn */
  5208. errno = EINVAL; return -1;
  5209. }
  5210. int Mono_Posix_FromSysconfName (int x, int *r)
  5211. {
  5212. *r = 0;
  5213. if (x == Mono_Posix_SysconfName__SC_2_CHAR_TERM)
  5214. #ifdef _SC_2_CHAR_TERM
  5215. {*r = _SC_2_CHAR_TERM; return 0;}
  5216. #else /* def _SC_2_CHAR_TERM */
  5217. {errno = EINVAL; return -1;}
  5218. #endif /* ndef _SC_2_CHAR_TERM */
  5219. if (x == Mono_Posix_SysconfName__SC_2_C_BIND)
  5220. #ifdef _SC_2_C_BIND
  5221. {*r = _SC_2_C_BIND; return 0;}
  5222. #else /* def _SC_2_C_BIND */
  5223. {errno = EINVAL; return -1;}
  5224. #endif /* ndef _SC_2_C_BIND */
  5225. if (x == Mono_Posix_SysconfName__SC_2_C_DEV)
  5226. #ifdef _SC_2_C_DEV
  5227. {*r = _SC_2_C_DEV; return 0;}
  5228. #else /* def _SC_2_C_DEV */
  5229. {errno = EINVAL; return -1;}
  5230. #endif /* ndef _SC_2_C_DEV */
  5231. if (x == Mono_Posix_SysconfName__SC_2_C_VERSION)
  5232. #ifdef _SC_2_C_VERSION
  5233. {*r = _SC_2_C_VERSION; return 0;}
  5234. #else /* def _SC_2_C_VERSION */
  5235. {errno = EINVAL; return -1;}
  5236. #endif /* ndef _SC_2_C_VERSION */
  5237. if (x == Mono_Posix_SysconfName__SC_2_FORT_DEV)
  5238. #ifdef _SC_2_FORT_DEV
  5239. {*r = _SC_2_FORT_DEV; return 0;}
  5240. #else /* def _SC_2_FORT_DEV */
  5241. {errno = EINVAL; return -1;}
  5242. #endif /* ndef _SC_2_FORT_DEV */
  5243. if (x == Mono_Posix_SysconfName__SC_2_FORT_RUN)
  5244. #ifdef _SC_2_FORT_RUN
  5245. {*r = _SC_2_FORT_RUN; return 0;}
  5246. #else /* def _SC_2_FORT_RUN */
  5247. {errno = EINVAL; return -1;}
  5248. #endif /* ndef _SC_2_FORT_RUN */
  5249. if (x == Mono_Posix_SysconfName__SC_2_LOCALEDEF)
  5250. #ifdef _SC_2_LOCALEDEF
  5251. {*r = _SC_2_LOCALEDEF; return 0;}
  5252. #else /* def _SC_2_LOCALEDEF */
  5253. {errno = EINVAL; return -1;}
  5254. #endif /* ndef _SC_2_LOCALEDEF */
  5255. if (x == Mono_Posix_SysconfName__SC_2_PBS)
  5256. #ifdef _SC_2_PBS
  5257. {*r = _SC_2_PBS; return 0;}
  5258. #else /* def _SC_2_PBS */
  5259. {errno = EINVAL; return -1;}
  5260. #endif /* ndef _SC_2_PBS */
  5261. if (x == Mono_Posix_SysconfName__SC_2_PBS_ACCOUNTING)
  5262. #ifdef _SC_2_PBS_ACCOUNTING
  5263. {*r = _SC_2_PBS_ACCOUNTING; return 0;}
  5264. #else /* def _SC_2_PBS_ACCOUNTING */
  5265. {errno = EINVAL; return -1;}
  5266. #endif /* ndef _SC_2_PBS_ACCOUNTING */
  5267. if (x == Mono_Posix_SysconfName__SC_2_PBS_CHECKPOINT)
  5268. #ifdef _SC_2_PBS_CHECKPOINT
  5269. {*r = _SC_2_PBS_CHECKPOINT; return 0;}
  5270. #else /* def _SC_2_PBS_CHECKPOINT */
  5271. {errno = EINVAL; return -1;}
  5272. #endif /* ndef _SC_2_PBS_CHECKPOINT */
  5273. if (x == Mono_Posix_SysconfName__SC_2_PBS_LOCATE)
  5274. #ifdef _SC_2_PBS_LOCATE
  5275. {*r = _SC_2_PBS_LOCATE; return 0;}
  5276. #else /* def _SC_2_PBS_LOCATE */
  5277. {errno = EINVAL; return -1;}
  5278. #endif /* ndef _SC_2_PBS_LOCATE */
  5279. if (x == Mono_Posix_SysconfName__SC_2_PBS_MESSAGE)
  5280. #ifdef _SC_2_PBS_MESSAGE
  5281. {*r = _SC_2_PBS_MESSAGE; return 0;}
  5282. #else /* def _SC_2_PBS_MESSAGE */
  5283. {errno = EINVAL; return -1;}
  5284. #endif /* ndef _SC_2_PBS_MESSAGE */
  5285. if (x == Mono_Posix_SysconfName__SC_2_PBS_TRACK)
  5286. #ifdef _SC_2_PBS_TRACK
  5287. {*r = _SC_2_PBS_TRACK; return 0;}
  5288. #else /* def _SC_2_PBS_TRACK */
  5289. {errno = EINVAL; return -1;}
  5290. #endif /* ndef _SC_2_PBS_TRACK */
  5291. if (x == Mono_Posix_SysconfName__SC_2_SW_DEV)
  5292. #ifdef _SC_2_SW_DEV
  5293. {*r = _SC_2_SW_DEV; return 0;}
  5294. #else /* def _SC_2_SW_DEV */
  5295. {errno = EINVAL; return -1;}
  5296. #endif /* ndef _SC_2_SW_DEV */
  5297. if (x == Mono_Posix_SysconfName__SC_2_UPE)
  5298. #ifdef _SC_2_UPE
  5299. {*r = _SC_2_UPE; return 0;}
  5300. #else /* def _SC_2_UPE */
  5301. {errno = EINVAL; return -1;}
  5302. #endif /* ndef _SC_2_UPE */
  5303. if (x == Mono_Posix_SysconfName__SC_2_VERSION)
  5304. #ifdef _SC_2_VERSION
  5305. {*r = _SC_2_VERSION; return 0;}
  5306. #else /* def _SC_2_VERSION */
  5307. {errno = EINVAL; return -1;}
  5308. #endif /* ndef _SC_2_VERSION */
  5309. if (x == Mono_Posix_SysconfName__SC_ADVISORY_INFO)
  5310. #ifdef _SC_ADVISORY_INFO
  5311. {*r = _SC_ADVISORY_INFO; return 0;}
  5312. #else /* def _SC_ADVISORY_INFO */
  5313. {errno = EINVAL; return -1;}
  5314. #endif /* ndef _SC_ADVISORY_INFO */
  5315. if (x == Mono_Posix_SysconfName__SC_AIO_LISTIO_MAX)
  5316. #ifdef _SC_AIO_LISTIO_MAX
  5317. {*r = _SC_AIO_LISTIO_MAX; return 0;}
  5318. #else /* def _SC_AIO_LISTIO_MAX */
  5319. {errno = EINVAL; return -1;}
  5320. #endif /* ndef _SC_AIO_LISTIO_MAX */
  5321. if (x == Mono_Posix_SysconfName__SC_AIO_MAX)
  5322. #ifdef _SC_AIO_MAX
  5323. {*r = _SC_AIO_MAX; return 0;}
  5324. #else /* def _SC_AIO_MAX */
  5325. {errno = EINVAL; return -1;}
  5326. #endif /* ndef _SC_AIO_MAX */
  5327. if (x == Mono_Posix_SysconfName__SC_AIO_PRIO_DELTA_MAX)
  5328. #ifdef _SC_AIO_PRIO_DELTA_MAX
  5329. {*r = _SC_AIO_PRIO_DELTA_MAX; return 0;}
  5330. #else /* def _SC_AIO_PRIO_DELTA_MAX */
  5331. {errno = EINVAL; return -1;}
  5332. #endif /* ndef _SC_AIO_PRIO_DELTA_MAX */
  5333. if (x == Mono_Posix_SysconfName__SC_ARG_MAX)
  5334. #ifdef _SC_ARG_MAX
  5335. {*r = _SC_ARG_MAX; return 0;}
  5336. #else /* def _SC_ARG_MAX */
  5337. {errno = EINVAL; return -1;}
  5338. #endif /* ndef _SC_ARG_MAX */
  5339. if (x == Mono_Posix_SysconfName__SC_ASYNCHRONOUS_IO)
  5340. #ifdef _SC_ASYNCHRONOUS_IO
  5341. {*r = _SC_ASYNCHRONOUS_IO; return 0;}
  5342. #else /* def _SC_ASYNCHRONOUS_IO */
  5343. {errno = EINVAL; return -1;}
  5344. #endif /* ndef _SC_ASYNCHRONOUS_IO */
  5345. if (x == Mono_Posix_SysconfName__SC_ATEXIT_MAX)
  5346. #ifdef _SC_ATEXIT_MAX
  5347. {*r = _SC_ATEXIT_MAX; return 0;}
  5348. #else /* def _SC_ATEXIT_MAX */
  5349. {errno = EINVAL; return -1;}
  5350. #endif /* ndef _SC_ATEXIT_MAX */
  5351. if (x == Mono_Posix_SysconfName__SC_AVPHYS_PAGES)
  5352. #ifdef _SC_AVPHYS_PAGES
  5353. {*r = _SC_AVPHYS_PAGES; return 0;}
  5354. #else /* def _SC_AVPHYS_PAGES */
  5355. {errno = EINVAL; return -1;}
  5356. #endif /* ndef _SC_AVPHYS_PAGES */
  5357. if (x == Mono_Posix_SysconfName__SC_BARRIERS)
  5358. #ifdef _SC_BARRIERS
  5359. {*r = _SC_BARRIERS; return 0;}
  5360. #else /* def _SC_BARRIERS */
  5361. {errno = EINVAL; return -1;}
  5362. #endif /* ndef _SC_BARRIERS */
  5363. if (x == Mono_Posix_SysconfName__SC_BASE)
  5364. #ifdef _SC_BASE
  5365. {*r = _SC_BASE; return 0;}
  5366. #else /* def _SC_BASE */
  5367. {errno = EINVAL; return -1;}
  5368. #endif /* ndef _SC_BASE */
  5369. if (x == Mono_Posix_SysconfName__SC_BC_BASE_MAX)
  5370. #ifdef _SC_BC_BASE_MAX
  5371. {*r = _SC_BC_BASE_MAX; return 0;}
  5372. #else /* def _SC_BC_BASE_MAX */
  5373. {errno = EINVAL; return -1;}
  5374. #endif /* ndef _SC_BC_BASE_MAX */
  5375. if (x == Mono_Posix_SysconfName__SC_BC_DIM_MAX)
  5376. #ifdef _SC_BC_DIM_MAX
  5377. {*r = _SC_BC_DIM_MAX; return 0;}
  5378. #else /* def _SC_BC_DIM_MAX */
  5379. {errno = EINVAL; return -1;}
  5380. #endif /* ndef _SC_BC_DIM_MAX */
  5381. if (x == Mono_Posix_SysconfName__SC_BC_SCALE_MAX)
  5382. #ifdef _SC_BC_SCALE_MAX
  5383. {*r = _SC_BC_SCALE_MAX; return 0;}
  5384. #else /* def _SC_BC_SCALE_MAX */
  5385. {errno = EINVAL; return -1;}
  5386. #endif /* ndef _SC_BC_SCALE_MAX */
  5387. if (x == Mono_Posix_SysconfName__SC_BC_STRING_MAX)
  5388. #ifdef _SC_BC_STRING_MAX
  5389. {*r = _SC_BC_STRING_MAX; return 0;}
  5390. #else /* def _SC_BC_STRING_MAX */
  5391. {errno = EINVAL; return -1;}
  5392. #endif /* ndef _SC_BC_STRING_MAX */
  5393. if (x == Mono_Posix_SysconfName__SC_CHARCLASS_NAME_MAX)
  5394. #ifdef _SC_CHARCLASS_NAME_MAX
  5395. {*r = _SC_CHARCLASS_NAME_MAX; return 0;}
  5396. #else /* def _SC_CHARCLASS_NAME_MAX */
  5397. {errno = EINVAL; return -1;}
  5398. #endif /* ndef _SC_CHARCLASS_NAME_MAX */
  5399. if (x == Mono_Posix_SysconfName__SC_CHAR_BIT)
  5400. #ifdef _SC_CHAR_BIT
  5401. {*r = _SC_CHAR_BIT; return 0;}
  5402. #else /* def _SC_CHAR_BIT */
  5403. {errno = EINVAL; return -1;}
  5404. #endif /* ndef _SC_CHAR_BIT */
  5405. if (x == Mono_Posix_SysconfName__SC_CHAR_MAX)
  5406. #ifdef _SC_CHAR_MAX
  5407. {*r = _SC_CHAR_MAX; return 0;}
  5408. #else /* def _SC_CHAR_MAX */
  5409. {errno = EINVAL; return -1;}
  5410. #endif /* ndef _SC_CHAR_MAX */
  5411. if (x == Mono_Posix_SysconfName__SC_CHAR_MIN)
  5412. #ifdef _SC_CHAR_MIN
  5413. {*r = _SC_CHAR_MIN; return 0;}
  5414. #else /* def _SC_CHAR_MIN */
  5415. {errno = EINVAL; return -1;}
  5416. #endif /* ndef _SC_CHAR_MIN */
  5417. if (x == Mono_Posix_SysconfName__SC_CHILD_MAX)
  5418. #ifdef _SC_CHILD_MAX
  5419. {*r = _SC_CHILD_MAX; return 0;}
  5420. #else /* def _SC_CHILD_MAX */
  5421. {errno = EINVAL; return -1;}
  5422. #endif /* ndef _SC_CHILD_MAX */
  5423. if (x == Mono_Posix_SysconfName__SC_CLK_TCK)
  5424. #ifdef _SC_CLK_TCK
  5425. {*r = _SC_CLK_TCK; return 0;}
  5426. #else /* def _SC_CLK_TCK */
  5427. {errno = EINVAL; return -1;}
  5428. #endif /* ndef _SC_CLK_TCK */
  5429. if (x == Mono_Posix_SysconfName__SC_CLOCK_SELECTION)
  5430. #ifdef _SC_CLOCK_SELECTION
  5431. {*r = _SC_CLOCK_SELECTION; return 0;}
  5432. #else /* def _SC_CLOCK_SELECTION */
  5433. {errno = EINVAL; return -1;}
  5434. #endif /* ndef _SC_CLOCK_SELECTION */
  5435. if (x == Mono_Posix_SysconfName__SC_COLL_WEIGHTS_MAX)
  5436. #ifdef _SC_COLL_WEIGHTS_MAX
  5437. {*r = _SC_COLL_WEIGHTS_MAX; return 0;}
  5438. #else /* def _SC_COLL_WEIGHTS_MAX */
  5439. {errno = EINVAL; return -1;}
  5440. #endif /* ndef _SC_COLL_WEIGHTS_MAX */
  5441. if (x == Mono_Posix_SysconfName__SC_CPUTIME)
  5442. #ifdef _SC_CPUTIME
  5443. {*r = _SC_CPUTIME; return 0;}
  5444. #else /* def _SC_CPUTIME */
  5445. {errno = EINVAL; return -1;}
  5446. #endif /* ndef _SC_CPUTIME */
  5447. if (x == Mono_Posix_SysconfName__SC_C_LANG_SUPPORT)
  5448. #ifdef _SC_C_LANG_SUPPORT
  5449. {*r = _SC_C_LANG_SUPPORT; return 0;}
  5450. #else /* def _SC_C_LANG_SUPPORT */
  5451. {errno = EINVAL; return -1;}
  5452. #endif /* ndef _SC_C_LANG_SUPPORT */
  5453. if (x == Mono_Posix_SysconfName__SC_C_LANG_SUPPORT_R)
  5454. #ifdef _SC_C_LANG_SUPPORT_R
  5455. {*r = _SC_C_LANG_SUPPORT_R; return 0;}
  5456. #else /* def _SC_C_LANG_SUPPORT_R */
  5457. {errno = EINVAL; return -1;}
  5458. #endif /* ndef _SC_C_LANG_SUPPORT_R */
  5459. if (x == Mono_Posix_SysconfName__SC_DELAYTIMER_MAX)
  5460. #ifdef _SC_DELAYTIMER_MAX
  5461. {*r = _SC_DELAYTIMER_MAX; return 0;}
  5462. #else /* def _SC_DELAYTIMER_MAX */
  5463. {errno = EINVAL; return -1;}
  5464. #endif /* ndef _SC_DELAYTIMER_MAX */
  5465. if (x == Mono_Posix_SysconfName__SC_DEVICE_IO)
  5466. #ifdef _SC_DEVICE_IO
  5467. {*r = _SC_DEVICE_IO; return 0;}
  5468. #else /* def _SC_DEVICE_IO */
  5469. {errno = EINVAL; return -1;}
  5470. #endif /* ndef _SC_DEVICE_IO */
  5471. if (x == Mono_Posix_SysconfName__SC_DEVICE_SPECIFIC)
  5472. #ifdef _SC_DEVICE_SPECIFIC
  5473. {*r = _SC_DEVICE_SPECIFIC; return 0;}
  5474. #else /* def _SC_DEVICE_SPECIFIC */
  5475. {errno = EINVAL; return -1;}
  5476. #endif /* ndef _SC_DEVICE_SPECIFIC */
  5477. if (x == Mono_Posix_SysconfName__SC_DEVICE_SPECIFIC_R)
  5478. #ifdef _SC_DEVICE_SPECIFIC_R
  5479. {*r = _SC_DEVICE_SPECIFIC_R; return 0;}
  5480. #else /* def _SC_DEVICE_SPECIFIC_R */
  5481. {errno = EINVAL; return -1;}
  5482. #endif /* ndef _SC_DEVICE_SPECIFIC_R */
  5483. if (x == Mono_Posix_SysconfName__SC_EQUIV_CLASS_MAX)
  5484. #ifdef _SC_EQUIV_CLASS_MAX
  5485. {*r = _SC_EQUIV_CLASS_MAX; return 0;}
  5486. #else /* def _SC_EQUIV_CLASS_MAX */
  5487. {errno = EINVAL; return -1;}
  5488. #endif /* ndef _SC_EQUIV_CLASS_MAX */
  5489. if (x == Mono_Posix_SysconfName__SC_EXPR_NEST_MAX)
  5490. #ifdef _SC_EXPR_NEST_MAX
  5491. {*r = _SC_EXPR_NEST_MAX; return 0;}
  5492. #else /* def _SC_EXPR_NEST_MAX */
  5493. {errno = EINVAL; return -1;}
  5494. #endif /* ndef _SC_EXPR_NEST_MAX */
  5495. if (x == Mono_Posix_SysconfName__SC_FD_MGMT)
  5496. #ifdef _SC_FD_MGMT
  5497. {*r = _SC_FD_MGMT; return 0;}
  5498. #else /* def _SC_FD_MGMT */
  5499. {errno = EINVAL; return -1;}
  5500. #endif /* ndef _SC_FD_MGMT */
  5501. if (x == Mono_Posix_SysconfName__SC_FIFO)
  5502. #ifdef _SC_FIFO
  5503. {*r = _SC_FIFO; return 0;}
  5504. #else /* def _SC_FIFO */
  5505. {errno = EINVAL; return -1;}
  5506. #endif /* ndef _SC_FIFO */
  5507. if (x == Mono_Posix_SysconfName__SC_FILE_ATTRIBUTES)
  5508. #ifdef _SC_FILE_ATTRIBUTES
  5509. {*r = _SC_FILE_ATTRIBUTES; return 0;}
  5510. #else /* def _SC_FILE_ATTRIBUTES */
  5511. {errno = EINVAL; return -1;}
  5512. #endif /* ndef _SC_FILE_ATTRIBUTES */
  5513. if (x == Mono_Posix_SysconfName__SC_FILE_LOCKING)
  5514. #ifdef _SC_FILE_LOCKING
  5515. {*r = _SC_FILE_LOCKING; return 0;}
  5516. #else /* def _SC_FILE_LOCKING */
  5517. {errno = EINVAL; return -1;}
  5518. #endif /* ndef _SC_FILE_LOCKING */
  5519. if (x == Mono_Posix_SysconfName__SC_FILE_SYSTEM)
  5520. #ifdef _SC_FILE_SYSTEM
  5521. {*r = _SC_FILE_SYSTEM; return 0;}
  5522. #else /* def _SC_FILE_SYSTEM */
  5523. {errno = EINVAL; return -1;}
  5524. #endif /* ndef _SC_FILE_SYSTEM */
  5525. if (x == Mono_Posix_SysconfName__SC_FSYNC)
  5526. #ifdef _SC_FSYNC
  5527. {*r = _SC_FSYNC; return 0;}
  5528. #else /* def _SC_FSYNC */
  5529. {errno = EINVAL; return -1;}
  5530. #endif /* ndef _SC_FSYNC */
  5531. if (x == Mono_Posix_SysconfName__SC_GETGR_R_SIZE_MAX)
  5532. #ifdef _SC_GETGR_R_SIZE_MAX
  5533. {*r = _SC_GETGR_R_SIZE_MAX; return 0;}
  5534. #else /* def _SC_GETGR_R_SIZE_MAX */
  5535. {errno = EINVAL; return -1;}
  5536. #endif /* ndef _SC_GETGR_R_SIZE_MAX */
  5537. if (x == Mono_Posix_SysconfName__SC_GETPW_R_SIZE_MAX)
  5538. #ifdef _SC_GETPW_R_SIZE_MAX
  5539. {*r = _SC_GETPW_R_SIZE_MAX; return 0;}
  5540. #else /* def _SC_GETPW_R_SIZE_MAX */
  5541. {errno = EINVAL; return -1;}
  5542. #endif /* ndef _SC_GETPW_R_SIZE_MAX */
  5543. if (x == Mono_Posix_SysconfName__SC_HOST_NAME_MAX)
  5544. #ifdef _SC_HOST_NAME_MAX
  5545. {*r = _SC_HOST_NAME_MAX; return 0;}
  5546. #else /* def _SC_HOST_NAME_MAX */
  5547. {errno = EINVAL; return -1;}
  5548. #endif /* ndef _SC_HOST_NAME_MAX */
  5549. if (x == Mono_Posix_SysconfName__SC_INT_MAX)
  5550. #ifdef _SC_INT_MAX
  5551. {*r = _SC_INT_MAX; return 0;}
  5552. #else /* def _SC_INT_MAX */
  5553. {errno = EINVAL; return -1;}
  5554. #endif /* ndef _SC_INT_MAX */
  5555. if (x == Mono_Posix_SysconfName__SC_INT_MIN)
  5556. #ifdef _SC_INT_MIN
  5557. {*r = _SC_INT_MIN; return 0;}
  5558. #else /* def _SC_INT_MIN */
  5559. {errno = EINVAL; return -1;}
  5560. #endif /* ndef _SC_INT_MIN */
  5561. if (x == Mono_Posix_SysconfName__SC_IOV_MAX)
  5562. #ifdef _SC_IOV_MAX
  5563. {*r = _SC_IOV_MAX; return 0;}
  5564. #else /* def _SC_IOV_MAX */
  5565. {errno = EINVAL; return -1;}
  5566. #endif /* ndef _SC_IOV_MAX */
  5567. if (x == Mono_Posix_SysconfName__SC_JOB_CONTROL)
  5568. #ifdef _SC_JOB_CONTROL
  5569. {*r = _SC_JOB_CONTROL; return 0;}
  5570. #else /* def _SC_JOB_CONTROL */
  5571. {errno = EINVAL; return -1;}
  5572. #endif /* ndef _SC_JOB_CONTROL */
  5573. if (x == Mono_Posix_SysconfName__SC_LEVEL1_DCACHE_ASSOC)
  5574. #ifdef _SC_LEVEL1_DCACHE_ASSOC
  5575. {*r = _SC_LEVEL1_DCACHE_ASSOC; return 0;}
  5576. #else /* def _SC_LEVEL1_DCACHE_ASSOC */
  5577. {errno = EINVAL; return -1;}
  5578. #endif /* ndef _SC_LEVEL1_DCACHE_ASSOC */
  5579. if (x == Mono_Posix_SysconfName__SC_LEVEL1_DCACHE_LINESIZE)
  5580. #ifdef _SC_LEVEL1_DCACHE_LINESIZE
  5581. {*r = _SC_LEVEL1_DCACHE_LINESIZE; return 0;}
  5582. #else /* def _SC_LEVEL1_DCACHE_LINESIZE */
  5583. {errno = EINVAL; return -1;}
  5584. #endif /* ndef _SC_LEVEL1_DCACHE_LINESIZE */
  5585. if (x == Mono_Posix_SysconfName__SC_LEVEL1_DCACHE_SIZE)
  5586. #ifdef _SC_LEVEL1_DCACHE_SIZE
  5587. {*r = _SC_LEVEL1_DCACHE_SIZE; return 0;}
  5588. #else /* def _SC_LEVEL1_DCACHE_SIZE */
  5589. {errno = EINVAL; return -1;}
  5590. #endif /* ndef _SC_LEVEL1_DCACHE_SIZE */
  5591. if (x == Mono_Posix_SysconfName__SC_LEVEL1_ICACHE_ASSOC)
  5592. #ifdef _SC_LEVEL1_ICACHE_ASSOC
  5593. {*r = _SC_LEVEL1_ICACHE_ASSOC; return 0;}
  5594. #else /* def _SC_LEVEL1_ICACHE_ASSOC */
  5595. {errno = EINVAL; return -1;}
  5596. #endif /* ndef _SC_LEVEL1_ICACHE_ASSOC */
  5597. if (x == Mono_Posix_SysconfName__SC_LEVEL1_ICACHE_LINESIZE)
  5598. #ifdef _SC_LEVEL1_ICACHE_LINESIZE
  5599. {*r = _SC_LEVEL1_ICACHE_LINESIZE; return 0;}
  5600. #else /* def _SC_LEVEL1_ICACHE_LINESIZE */
  5601. {errno = EINVAL; return -1;}
  5602. #endif /* ndef _SC_LEVEL1_ICACHE_LINESIZE */
  5603. if (x == Mono_Posix_SysconfName__SC_LEVEL1_ICACHE_SIZE)
  5604. #ifdef _SC_LEVEL1_ICACHE_SIZE
  5605. {*r = _SC_LEVEL1_ICACHE_SIZE; return 0;}
  5606. #else /* def _SC_LEVEL1_ICACHE_SIZE */
  5607. {errno = EINVAL; return -1;}
  5608. #endif /* ndef _SC_LEVEL1_ICACHE_SIZE */
  5609. if (x == Mono_Posix_SysconfName__SC_LEVEL2_CACHE_ASSOC)
  5610. #ifdef _SC_LEVEL2_CACHE_ASSOC
  5611. {*r = _SC_LEVEL2_CACHE_ASSOC; return 0;}
  5612. #else /* def _SC_LEVEL2_CACHE_ASSOC */
  5613. {errno = EINVAL; return -1;}
  5614. #endif /* ndef _SC_LEVEL2_CACHE_ASSOC */
  5615. if (x == Mono_Posix_SysconfName__SC_LEVEL2_CACHE_LINESIZE)
  5616. #ifdef _SC_LEVEL2_CACHE_LINESIZE
  5617. {*r = _SC_LEVEL2_CACHE_LINESIZE; return 0;}
  5618. #else /* def _SC_LEVEL2_CACHE_LINESIZE */
  5619. {errno = EINVAL; return -1;}
  5620. #endif /* ndef _SC_LEVEL2_CACHE_LINESIZE */
  5621. if (x == Mono_Posix_SysconfName__SC_LEVEL2_CACHE_SIZE)
  5622. #ifdef _SC_LEVEL2_CACHE_SIZE
  5623. {*r = _SC_LEVEL2_CACHE_SIZE; return 0;}
  5624. #else /* def _SC_LEVEL2_CACHE_SIZE */
  5625. {errno = EINVAL; return -1;}
  5626. #endif /* ndef _SC_LEVEL2_CACHE_SIZE */
  5627. if (x == Mono_Posix_SysconfName__SC_LEVEL3_CACHE_ASSOC)
  5628. #ifdef _SC_LEVEL3_CACHE_ASSOC
  5629. {*r = _SC_LEVEL3_CACHE_ASSOC; return 0;}
  5630. #else /* def _SC_LEVEL3_CACHE_ASSOC */
  5631. {errno = EINVAL; return -1;}
  5632. #endif /* ndef _SC_LEVEL3_CACHE_ASSOC */
  5633. if (x == Mono_Posix_SysconfName__SC_LEVEL3_CACHE_LINESIZE)
  5634. #ifdef _SC_LEVEL3_CACHE_LINESIZE
  5635. {*r = _SC_LEVEL3_CACHE_LINESIZE; return 0;}
  5636. #else /* def _SC_LEVEL3_CACHE_LINESIZE */
  5637. {errno = EINVAL; return -1;}
  5638. #endif /* ndef _SC_LEVEL3_CACHE_LINESIZE */
  5639. if (x == Mono_Posix_SysconfName__SC_LEVEL3_CACHE_SIZE)
  5640. #ifdef _SC_LEVEL3_CACHE_SIZE
  5641. {*r = _SC_LEVEL3_CACHE_SIZE; return 0;}
  5642. #else /* def _SC_LEVEL3_CACHE_SIZE */
  5643. {errno = EINVAL; return -1;}
  5644. #endif /* ndef _SC_LEVEL3_CACHE_SIZE */
  5645. if (x == Mono_Posix_SysconfName__SC_LEVEL4_CACHE_ASSOC)
  5646. #ifdef _SC_LEVEL4_CACHE_ASSOC
  5647. {*r = _SC_LEVEL4_CACHE_ASSOC; return 0;}
  5648. #else /* def _SC_LEVEL4_CACHE_ASSOC */
  5649. {errno = EINVAL; return -1;}
  5650. #endif /* ndef _SC_LEVEL4_CACHE_ASSOC */
  5651. if (x == Mono_Posix_SysconfName__SC_LEVEL4_CACHE_LINESIZE)
  5652. #ifdef _SC_LEVEL4_CACHE_LINESIZE
  5653. {*r = _SC_LEVEL4_CACHE_LINESIZE; return 0;}
  5654. #else /* def _SC_LEVEL4_CACHE_LINESIZE */
  5655. {errno = EINVAL; return -1;}
  5656. #endif /* ndef _SC_LEVEL4_CACHE_LINESIZE */
  5657. if (x == Mono_Posix_SysconfName__SC_LEVEL4_CACHE_SIZE)
  5658. #ifdef _SC_LEVEL4_CACHE_SIZE
  5659. {*r = _SC_LEVEL4_CACHE_SIZE; return 0;}
  5660. #else /* def _SC_LEVEL4_CACHE_SIZE */
  5661. {errno = EINVAL; return -1;}
  5662. #endif /* ndef _SC_LEVEL4_CACHE_SIZE */
  5663. if (x == Mono_Posix_SysconfName__SC_LINE_MAX)
  5664. #ifdef _SC_LINE_MAX
  5665. {*r = _SC_LINE_MAX; return 0;}
  5666. #else /* def _SC_LINE_MAX */
  5667. {errno = EINVAL; return -1;}
  5668. #endif /* ndef _SC_LINE_MAX */
  5669. if (x == Mono_Posix_SysconfName__SC_LOGIN_NAME_MAX)
  5670. #ifdef _SC_LOGIN_NAME_MAX
  5671. {*r = _SC_LOGIN_NAME_MAX; return 0;}
  5672. #else /* def _SC_LOGIN_NAME_MAX */
  5673. {errno = EINVAL; return -1;}
  5674. #endif /* ndef _SC_LOGIN_NAME_MAX */
  5675. if (x == Mono_Posix_SysconfName__SC_LONG_BIT)
  5676. #ifdef _SC_LONG_BIT
  5677. {*r = _SC_LONG_BIT; return 0;}
  5678. #else /* def _SC_LONG_BIT */
  5679. {errno = EINVAL; return -1;}
  5680. #endif /* ndef _SC_LONG_BIT */
  5681. if (x == Mono_Posix_SysconfName__SC_MAPPED_FILES)
  5682. #ifdef _SC_MAPPED_FILES
  5683. {*r = _SC_MAPPED_FILES; return 0;}
  5684. #else /* def _SC_MAPPED_FILES */
  5685. {errno = EINVAL; return -1;}
  5686. #endif /* ndef _SC_MAPPED_FILES */
  5687. if (x == Mono_Posix_SysconfName__SC_MB_LEN_MAX)
  5688. #ifdef _SC_MB_LEN_MAX
  5689. {*r = _SC_MB_LEN_MAX; return 0;}
  5690. #else /* def _SC_MB_LEN_MAX */
  5691. {errno = EINVAL; return -1;}
  5692. #endif /* ndef _SC_MB_LEN_MAX */
  5693. if (x == Mono_Posix_SysconfName__SC_MEMLOCK)
  5694. #ifdef _SC_MEMLOCK
  5695. {*r = _SC_MEMLOCK; return 0;}
  5696. #else /* def _SC_MEMLOCK */
  5697. {errno = EINVAL; return -1;}
  5698. #endif /* ndef _SC_MEMLOCK */
  5699. if (x == Mono_Posix_SysconfName__SC_MEMLOCK_RANGE)
  5700. #ifdef _SC_MEMLOCK_RANGE
  5701. {*r = _SC_MEMLOCK_RANGE; return 0;}
  5702. #else /* def _SC_MEMLOCK_RANGE */
  5703. {errno = EINVAL; return -1;}
  5704. #endif /* ndef _SC_MEMLOCK_RANGE */
  5705. if (x == Mono_Posix_SysconfName__SC_MEMORY_PROTECTION)
  5706. #ifdef _SC_MEMORY_PROTECTION
  5707. {*r = _SC_MEMORY_PROTECTION; return 0;}
  5708. #else /* def _SC_MEMORY_PROTECTION */
  5709. {errno = EINVAL; return -1;}
  5710. #endif /* ndef _SC_MEMORY_PROTECTION */
  5711. if (x == Mono_Posix_SysconfName__SC_MESSAGE_PASSING)
  5712. #ifdef _SC_MESSAGE_PASSING
  5713. {*r = _SC_MESSAGE_PASSING; return 0;}
  5714. #else /* def _SC_MESSAGE_PASSING */
  5715. {errno = EINVAL; return -1;}
  5716. #endif /* ndef _SC_MESSAGE_PASSING */
  5717. if (x == Mono_Posix_SysconfName__SC_MONOTONIC_CLOCK)
  5718. #ifdef _SC_MONOTONIC_CLOCK
  5719. {*r = _SC_MONOTONIC_CLOCK; return 0;}
  5720. #else /* def _SC_MONOTONIC_CLOCK */
  5721. {errno = EINVAL; return -1;}
  5722. #endif /* ndef _SC_MONOTONIC_CLOCK */
  5723. if (x == Mono_Posix_SysconfName__SC_MQ_OPEN_MAX)
  5724. #ifdef _SC_MQ_OPEN_MAX
  5725. {*r = _SC_MQ_OPEN_MAX; return 0;}
  5726. #else /* def _SC_MQ_OPEN_MAX */
  5727. {errno = EINVAL; return -1;}
  5728. #endif /* ndef _SC_MQ_OPEN_MAX */
  5729. if (x == Mono_Posix_SysconfName__SC_MQ_PRIO_MAX)
  5730. #ifdef _SC_MQ_PRIO_MAX
  5731. {*r = _SC_MQ_PRIO_MAX; return 0;}
  5732. #else /* def _SC_MQ_PRIO_MAX */
  5733. {errno = EINVAL; return -1;}
  5734. #endif /* ndef _SC_MQ_PRIO_MAX */
  5735. if (x == Mono_Posix_SysconfName__SC_MULTI_PROCESS)
  5736. #ifdef _SC_MULTI_PROCESS
  5737. {*r = _SC_MULTI_PROCESS; return 0;}
  5738. #else /* def _SC_MULTI_PROCESS */
  5739. {errno = EINVAL; return -1;}
  5740. #endif /* ndef _SC_MULTI_PROCESS */
  5741. if (x == Mono_Posix_SysconfName__SC_NETWORKING)
  5742. #ifdef _SC_NETWORKING
  5743. {*r = _SC_NETWORKING; return 0;}
  5744. #else /* def _SC_NETWORKING */
  5745. {errno = EINVAL; return -1;}
  5746. #endif /* ndef _SC_NETWORKING */
  5747. if (x == Mono_Posix_SysconfName__SC_NGROUPS_MAX)
  5748. #ifdef _SC_NGROUPS_MAX
  5749. {*r = _SC_NGROUPS_MAX; return 0;}
  5750. #else /* def _SC_NGROUPS_MAX */
  5751. {errno = EINVAL; return -1;}
  5752. #endif /* ndef _SC_NGROUPS_MAX */
  5753. if (x == Mono_Posix_SysconfName__SC_NL_ARGMAX)
  5754. #ifdef _SC_NL_ARGMAX
  5755. {*r = _SC_NL_ARGMAX; return 0;}
  5756. #else /* def _SC_NL_ARGMAX */
  5757. {errno = EINVAL; return -1;}
  5758. #endif /* ndef _SC_NL_ARGMAX */
  5759. if (x == Mono_Posix_SysconfName__SC_NL_LANGMAX)
  5760. #ifdef _SC_NL_LANGMAX
  5761. {*r = _SC_NL_LANGMAX; return 0;}
  5762. #else /* def _SC_NL_LANGMAX */
  5763. {errno = EINVAL; return -1;}
  5764. #endif /* ndef _SC_NL_LANGMAX */
  5765. if (x == Mono_Posix_SysconfName__SC_NL_MSGMAX)
  5766. #ifdef _SC_NL_MSGMAX
  5767. {*r = _SC_NL_MSGMAX; return 0;}
  5768. #else /* def _SC_NL_MSGMAX */
  5769. {errno = EINVAL; return -1;}
  5770. #endif /* ndef _SC_NL_MSGMAX */
  5771. if (x == Mono_Posix_SysconfName__SC_NL_NMAX)
  5772. #ifdef _SC_NL_NMAX
  5773. {*r = _SC_NL_NMAX; return 0;}
  5774. #else /* def _SC_NL_NMAX */
  5775. {errno = EINVAL; return -1;}
  5776. #endif /* ndef _SC_NL_NMAX */
  5777. if (x == Mono_Posix_SysconfName__SC_NL_SETMAX)
  5778. #ifdef _SC_NL_SETMAX
  5779. {*r = _SC_NL_SETMAX; return 0;}
  5780. #else /* def _SC_NL_SETMAX */
  5781. {errno = EINVAL; return -1;}
  5782. #endif /* ndef _SC_NL_SETMAX */
  5783. if (x == Mono_Posix_SysconfName__SC_NL_TEXTMAX)
  5784. #ifdef _SC_NL_TEXTMAX
  5785. {*r = _SC_NL_TEXTMAX; return 0;}
  5786. #else /* def _SC_NL_TEXTMAX */
  5787. {errno = EINVAL; return -1;}
  5788. #endif /* ndef _SC_NL_TEXTMAX */
  5789. if (x == Mono_Posix_SysconfName__SC_NPROCESSORS_CONF)
  5790. #ifdef _SC_NPROCESSORS_CONF
  5791. {*r = _SC_NPROCESSORS_CONF; return 0;}
  5792. #else /* def _SC_NPROCESSORS_CONF */
  5793. {errno = EINVAL; return -1;}
  5794. #endif /* ndef _SC_NPROCESSORS_CONF */
  5795. if (x == Mono_Posix_SysconfName__SC_NPROCESSORS_ONLN)
  5796. #ifdef _SC_NPROCESSORS_ONLN
  5797. {*r = _SC_NPROCESSORS_ONLN; return 0;}
  5798. #else /* def _SC_NPROCESSORS_ONLN */
  5799. {errno = EINVAL; return -1;}
  5800. #endif /* ndef _SC_NPROCESSORS_ONLN */
  5801. if (x == Mono_Posix_SysconfName__SC_NZERO)
  5802. #ifdef _SC_NZERO
  5803. {*r = _SC_NZERO; return 0;}
  5804. #else /* def _SC_NZERO */
  5805. {errno = EINVAL; return -1;}
  5806. #endif /* ndef _SC_NZERO */
  5807. if (x == Mono_Posix_SysconfName__SC_OPEN_MAX)
  5808. #ifdef _SC_OPEN_MAX
  5809. {*r = _SC_OPEN_MAX; return 0;}
  5810. #else /* def _SC_OPEN_MAX */
  5811. {errno = EINVAL; return -1;}
  5812. #endif /* ndef _SC_OPEN_MAX */
  5813. if (x == Mono_Posix_SysconfName__SC_PAGESIZE)
  5814. #ifdef _SC_PAGESIZE
  5815. {*r = _SC_PAGESIZE; return 0;}
  5816. #else /* def _SC_PAGESIZE */
  5817. {errno = EINVAL; return -1;}
  5818. #endif /* ndef _SC_PAGESIZE */
  5819. if (x == Mono_Posix_SysconfName__SC_PASS_MAX)
  5820. #ifdef _SC_PASS_MAX
  5821. {*r = _SC_PASS_MAX; return 0;}
  5822. #else /* def _SC_PASS_MAX */
  5823. {errno = EINVAL; return -1;}
  5824. #endif /* ndef _SC_PASS_MAX */
  5825. if (x == Mono_Posix_SysconfName__SC_PHYS_PAGES)
  5826. #ifdef _SC_PHYS_PAGES
  5827. {*r = _SC_PHYS_PAGES; return 0;}
  5828. #else /* def _SC_PHYS_PAGES */
  5829. {errno = EINVAL; return -1;}
  5830. #endif /* ndef _SC_PHYS_PAGES */
  5831. if (x == Mono_Posix_SysconfName__SC_PII)
  5832. #ifdef _SC_PII
  5833. {*r = _SC_PII; return 0;}
  5834. #else /* def _SC_PII */
  5835. {errno = EINVAL; return -1;}
  5836. #endif /* ndef _SC_PII */
  5837. if (x == Mono_Posix_SysconfName__SC_PII_INTERNET)
  5838. #ifdef _SC_PII_INTERNET
  5839. {*r = _SC_PII_INTERNET; return 0;}
  5840. #else /* def _SC_PII_INTERNET */
  5841. {errno = EINVAL; return -1;}
  5842. #endif /* ndef _SC_PII_INTERNET */
  5843. if (x == Mono_Posix_SysconfName__SC_PII_INTERNET_DGRAM)
  5844. #ifdef _SC_PII_INTERNET_DGRAM
  5845. {*r = _SC_PII_INTERNET_DGRAM; return 0;}
  5846. #else /* def _SC_PII_INTERNET_DGRAM */
  5847. {errno = EINVAL; return -1;}
  5848. #endif /* ndef _SC_PII_INTERNET_DGRAM */
  5849. if (x == Mono_Posix_SysconfName__SC_PII_INTERNET_STREAM)
  5850. #ifdef _SC_PII_INTERNET_STREAM
  5851. {*r = _SC_PII_INTERNET_STREAM; return 0;}
  5852. #else /* def _SC_PII_INTERNET_STREAM */
  5853. {errno = EINVAL; return -1;}
  5854. #endif /* ndef _SC_PII_INTERNET_STREAM */
  5855. if (x == Mono_Posix_SysconfName__SC_PII_OSI)
  5856. #ifdef _SC_PII_OSI
  5857. {*r = _SC_PII_OSI; return 0;}
  5858. #else /* def _SC_PII_OSI */
  5859. {errno = EINVAL; return -1;}
  5860. #endif /* ndef _SC_PII_OSI */
  5861. if (x == Mono_Posix_SysconfName__SC_PII_OSI_CLTS)
  5862. #ifdef _SC_PII_OSI_CLTS
  5863. {*r = _SC_PII_OSI_CLTS; return 0;}
  5864. #else /* def _SC_PII_OSI_CLTS */
  5865. {errno = EINVAL; return -1;}
  5866. #endif /* ndef _SC_PII_OSI_CLTS */
  5867. if (x == Mono_Posix_SysconfName__SC_PII_OSI_COTS)
  5868. #ifdef _SC_PII_OSI_COTS
  5869. {*r = _SC_PII_OSI_COTS; return 0;}
  5870. #else /* def _SC_PII_OSI_COTS */
  5871. {errno = EINVAL; return -1;}
  5872. #endif /* ndef _SC_PII_OSI_COTS */
  5873. if (x == Mono_Posix_SysconfName__SC_PII_OSI_M)
  5874. #ifdef _SC_PII_OSI_M
  5875. {*r = _SC_PII_OSI_M; return 0;}
  5876. #else /* def _SC_PII_OSI_M */
  5877. {errno = EINVAL; return -1;}
  5878. #endif /* ndef _SC_PII_OSI_M */
  5879. if (x == Mono_Posix_SysconfName__SC_PII_SOCKET)
  5880. #ifdef _SC_PII_SOCKET
  5881. {*r = _SC_PII_SOCKET; return 0;}
  5882. #else /* def _SC_PII_SOCKET */
  5883. {errno = EINVAL; return -1;}
  5884. #endif /* ndef _SC_PII_SOCKET */
  5885. if (x == Mono_Posix_SysconfName__SC_PII_XTI)
  5886. #ifdef _SC_PII_XTI
  5887. {*r = _SC_PII_XTI; return 0;}
  5888. #else /* def _SC_PII_XTI */
  5889. {errno = EINVAL; return -1;}
  5890. #endif /* ndef _SC_PII_XTI */
  5891. if (x == Mono_Posix_SysconfName__SC_PIPE)
  5892. #ifdef _SC_PIPE
  5893. {*r = _SC_PIPE; return 0;}
  5894. #else /* def _SC_PIPE */
  5895. {errno = EINVAL; return -1;}
  5896. #endif /* ndef _SC_PIPE */
  5897. if (x == Mono_Posix_SysconfName__SC_POLL)
  5898. #ifdef _SC_POLL
  5899. {*r = _SC_POLL; return 0;}
  5900. #else /* def _SC_POLL */
  5901. {errno = EINVAL; return -1;}
  5902. #endif /* ndef _SC_POLL */
  5903. if (x == Mono_Posix_SysconfName__SC_PRIORITIZED_IO)
  5904. #ifdef _SC_PRIORITIZED_IO
  5905. {*r = _SC_PRIORITIZED_IO; return 0;}
  5906. #else /* def _SC_PRIORITIZED_IO */
  5907. {errno = EINVAL; return -1;}
  5908. #endif /* ndef _SC_PRIORITIZED_IO */
  5909. if (x == Mono_Posix_SysconfName__SC_PRIORITY_SCHEDULING)
  5910. #ifdef _SC_PRIORITY_SCHEDULING
  5911. {*r = _SC_PRIORITY_SCHEDULING; return 0;}
  5912. #else /* def _SC_PRIORITY_SCHEDULING */
  5913. {errno = EINVAL; return -1;}
  5914. #endif /* ndef _SC_PRIORITY_SCHEDULING */
  5915. if (x == Mono_Posix_SysconfName__SC_READER_WRITER_LOCKS)
  5916. #ifdef _SC_READER_WRITER_LOCKS
  5917. {*r = _SC_READER_WRITER_LOCKS; return 0;}
  5918. #else /* def _SC_READER_WRITER_LOCKS */
  5919. {errno = EINVAL; return -1;}
  5920. #endif /* ndef _SC_READER_WRITER_LOCKS */
  5921. if (x == Mono_Posix_SysconfName__SC_REALTIME_SIGNALS)
  5922. #ifdef _SC_REALTIME_SIGNALS
  5923. {*r = _SC_REALTIME_SIGNALS; return 0;}
  5924. #else /* def _SC_REALTIME_SIGNALS */
  5925. {errno = EINVAL; return -1;}
  5926. #endif /* ndef _SC_REALTIME_SIGNALS */
  5927. if (x == Mono_Posix_SysconfName__SC_REGEXP)
  5928. #ifdef _SC_REGEXP
  5929. {*r = _SC_REGEXP; return 0;}
  5930. #else /* def _SC_REGEXP */
  5931. {errno = EINVAL; return -1;}
  5932. #endif /* ndef _SC_REGEXP */
  5933. if (x == Mono_Posix_SysconfName__SC_REGEX_VERSION)
  5934. #ifdef _SC_REGEX_VERSION
  5935. {*r = _SC_REGEX_VERSION; return 0;}
  5936. #else /* def _SC_REGEX_VERSION */
  5937. {errno = EINVAL; return -1;}
  5938. #endif /* ndef _SC_REGEX_VERSION */
  5939. if (x == Mono_Posix_SysconfName__SC_RE_DUP_MAX)
  5940. #ifdef _SC_RE_DUP_MAX
  5941. {*r = _SC_RE_DUP_MAX; return 0;}
  5942. #else /* def _SC_RE_DUP_MAX */
  5943. {errno = EINVAL; return -1;}
  5944. #endif /* ndef _SC_RE_DUP_MAX */
  5945. if (x == Mono_Posix_SysconfName__SC_RTSIG_MAX)
  5946. #ifdef _SC_RTSIG_MAX
  5947. {*r = _SC_RTSIG_MAX; return 0;}
  5948. #else /* def _SC_RTSIG_MAX */
  5949. {errno = EINVAL; return -1;}
  5950. #endif /* ndef _SC_RTSIG_MAX */
  5951. if (x == Mono_Posix_SysconfName__SC_SAVED_IDS)
  5952. #ifdef _SC_SAVED_IDS
  5953. {*r = _SC_SAVED_IDS; return 0;}
  5954. #else /* def _SC_SAVED_IDS */
  5955. {errno = EINVAL; return -1;}
  5956. #endif /* ndef _SC_SAVED_IDS */
  5957. if (x == Mono_Posix_SysconfName__SC_SCHAR_MAX)
  5958. #ifdef _SC_SCHAR_MAX
  5959. {*r = _SC_SCHAR_MAX; return 0;}
  5960. #else /* def _SC_SCHAR_MAX */
  5961. {errno = EINVAL; return -1;}
  5962. #endif /* ndef _SC_SCHAR_MAX */
  5963. if (x == Mono_Posix_SysconfName__SC_SCHAR_MIN)
  5964. #ifdef _SC_SCHAR_MIN
  5965. {*r = _SC_SCHAR_MIN; return 0;}
  5966. #else /* def _SC_SCHAR_MIN */
  5967. {errno = EINVAL; return -1;}
  5968. #endif /* ndef _SC_SCHAR_MIN */
  5969. if (x == Mono_Posix_SysconfName__SC_SELECT)
  5970. #ifdef _SC_SELECT
  5971. {*r = _SC_SELECT; return 0;}
  5972. #else /* def _SC_SELECT */
  5973. {errno = EINVAL; return -1;}
  5974. #endif /* ndef _SC_SELECT */
  5975. if (x == Mono_Posix_SysconfName__SC_SEMAPHORES)
  5976. #ifdef _SC_SEMAPHORES
  5977. {*r = _SC_SEMAPHORES; return 0;}
  5978. #else /* def _SC_SEMAPHORES */
  5979. {errno = EINVAL; return -1;}
  5980. #endif /* ndef _SC_SEMAPHORES */
  5981. if (x == Mono_Posix_SysconfName__SC_SEM_NSEMS_MAX)
  5982. #ifdef _SC_SEM_NSEMS_MAX
  5983. {*r = _SC_SEM_NSEMS_MAX; return 0;}
  5984. #else /* def _SC_SEM_NSEMS_MAX */
  5985. {errno = EINVAL; return -1;}
  5986. #endif /* ndef _SC_SEM_NSEMS_MAX */
  5987. if (x == Mono_Posix_SysconfName__SC_SEM_VALUE_MAX)
  5988. #ifdef _SC_SEM_VALUE_MAX
  5989. {*r = _SC_SEM_VALUE_MAX; return 0;}
  5990. #else /* def _SC_SEM_VALUE_MAX */
  5991. {errno = EINVAL; return -1;}
  5992. #endif /* ndef _SC_SEM_VALUE_MAX */
  5993. if (x == Mono_Posix_SysconfName__SC_SHARED_MEMORY_OBJECTS)
  5994. #ifdef _SC_SHARED_MEMORY_OBJECTS
  5995. {*r = _SC_SHARED_MEMORY_OBJECTS; return 0;}
  5996. #else /* def _SC_SHARED_MEMORY_OBJECTS */
  5997. {errno = EINVAL; return -1;}
  5998. #endif /* ndef _SC_SHARED_MEMORY_OBJECTS */
  5999. if (x == Mono_Posix_SysconfName__SC_SHELL)
  6000. #ifdef _SC_SHELL
  6001. {*r = _SC_SHELL; return 0;}
  6002. #else /* def _SC_SHELL */
  6003. {errno = EINVAL; return -1;}
  6004. #endif /* ndef _SC_SHELL */
  6005. if (x == Mono_Posix_SysconfName__SC_SHRT_MAX)
  6006. #ifdef _SC_SHRT_MAX
  6007. {*r = _SC_SHRT_MAX; return 0;}
  6008. #else /* def _SC_SHRT_MAX */
  6009. {errno = EINVAL; return -1;}
  6010. #endif /* ndef _SC_SHRT_MAX */
  6011. if (x == Mono_Posix_SysconfName__SC_SHRT_MIN)
  6012. #ifdef _SC_SHRT_MIN
  6013. {*r = _SC_SHRT_MIN; return 0;}
  6014. #else /* def _SC_SHRT_MIN */
  6015. {errno = EINVAL; return -1;}
  6016. #endif /* ndef _SC_SHRT_MIN */
  6017. if (x == Mono_Posix_SysconfName__SC_SIGNALS)
  6018. #ifdef _SC_SIGNALS
  6019. {*r = _SC_SIGNALS; return 0;}
  6020. #else /* def _SC_SIGNALS */
  6021. {errno = EINVAL; return -1;}
  6022. #endif /* ndef _SC_SIGNALS */
  6023. if (x == Mono_Posix_SysconfName__SC_SIGQUEUE_MAX)
  6024. #ifdef _SC_SIGQUEUE_MAX
  6025. {*r = _SC_SIGQUEUE_MAX; return 0;}
  6026. #else /* def _SC_SIGQUEUE_MAX */
  6027. {errno = EINVAL; return -1;}
  6028. #endif /* ndef _SC_SIGQUEUE_MAX */
  6029. if (x == Mono_Posix_SysconfName__SC_SINGLE_PROCESS)
  6030. #ifdef _SC_SINGLE_PROCESS
  6031. {*r = _SC_SINGLE_PROCESS; return 0;}
  6032. #else /* def _SC_SINGLE_PROCESS */
  6033. {errno = EINVAL; return -1;}
  6034. #endif /* ndef _SC_SINGLE_PROCESS */
  6035. if (x == Mono_Posix_SysconfName__SC_SPAWN)
  6036. #ifdef _SC_SPAWN
  6037. {*r = _SC_SPAWN; return 0;}
  6038. #else /* def _SC_SPAWN */
  6039. {errno = EINVAL; return -1;}
  6040. #endif /* ndef _SC_SPAWN */
  6041. if (x == Mono_Posix_SysconfName__SC_SPIN_LOCKS)
  6042. #ifdef _SC_SPIN_LOCKS
  6043. {*r = _SC_SPIN_LOCKS; return 0;}
  6044. #else /* def _SC_SPIN_LOCKS */
  6045. {errno = EINVAL; return -1;}
  6046. #endif /* ndef _SC_SPIN_LOCKS */
  6047. if (x == Mono_Posix_SysconfName__SC_SPORADIC_SERVER)
  6048. #ifdef _SC_SPORADIC_SERVER
  6049. {*r = _SC_SPORADIC_SERVER; return 0;}
  6050. #else /* def _SC_SPORADIC_SERVER */
  6051. {errno = EINVAL; return -1;}
  6052. #endif /* ndef _SC_SPORADIC_SERVER */
  6053. if (x == Mono_Posix_SysconfName__SC_SSIZE_MAX)
  6054. #ifdef _SC_SSIZE_MAX
  6055. {*r = _SC_SSIZE_MAX; return 0;}
  6056. #else /* def _SC_SSIZE_MAX */
  6057. {errno = EINVAL; return -1;}
  6058. #endif /* ndef _SC_SSIZE_MAX */
  6059. if (x == Mono_Posix_SysconfName__SC_STREAMS)
  6060. #ifdef _SC_STREAMS
  6061. {*r = _SC_STREAMS; return 0;}
  6062. #else /* def _SC_STREAMS */
  6063. {errno = EINVAL; return -1;}
  6064. #endif /* ndef _SC_STREAMS */
  6065. if (x == Mono_Posix_SysconfName__SC_STREAM_MAX)
  6066. #ifdef _SC_STREAM_MAX
  6067. {*r = _SC_STREAM_MAX; return 0;}
  6068. #else /* def _SC_STREAM_MAX */
  6069. {errno = EINVAL; return -1;}
  6070. #endif /* ndef _SC_STREAM_MAX */
  6071. if (x == Mono_Posix_SysconfName__SC_SYMLOOP_MAX)
  6072. #ifdef _SC_SYMLOOP_MAX
  6073. {*r = _SC_SYMLOOP_MAX; return 0;}
  6074. #else /* def _SC_SYMLOOP_MAX */
  6075. {errno = EINVAL; return -1;}
  6076. #endif /* ndef _SC_SYMLOOP_MAX */
  6077. if (x == Mono_Posix_SysconfName__SC_SYNCHRONIZED_IO)
  6078. #ifdef _SC_SYNCHRONIZED_IO
  6079. {*r = _SC_SYNCHRONIZED_IO; return 0;}
  6080. #else /* def _SC_SYNCHRONIZED_IO */
  6081. {errno = EINVAL; return -1;}
  6082. #endif /* ndef _SC_SYNCHRONIZED_IO */
  6083. if (x == Mono_Posix_SysconfName__SC_SYSTEM_DATABASE)
  6084. #ifdef _SC_SYSTEM_DATABASE
  6085. {*r = _SC_SYSTEM_DATABASE; return 0;}
  6086. #else /* def _SC_SYSTEM_DATABASE */
  6087. {errno = EINVAL; return -1;}
  6088. #endif /* ndef _SC_SYSTEM_DATABASE */
  6089. if (x == Mono_Posix_SysconfName__SC_SYSTEM_DATABASE_R)
  6090. #ifdef _SC_SYSTEM_DATABASE_R
  6091. {*r = _SC_SYSTEM_DATABASE_R; return 0;}
  6092. #else /* def _SC_SYSTEM_DATABASE_R */
  6093. {errno = EINVAL; return -1;}
  6094. #endif /* ndef _SC_SYSTEM_DATABASE_R */
  6095. if (x == Mono_Posix_SysconfName__SC_THREADS)
  6096. #ifdef _SC_THREADS
  6097. {*r = _SC_THREADS; return 0;}
  6098. #else /* def _SC_THREADS */
  6099. {errno = EINVAL; return -1;}
  6100. #endif /* ndef _SC_THREADS */
  6101. if (x == Mono_Posix_SysconfName__SC_THREAD_ATTR_STACKADDR)
  6102. #ifdef _SC_THREAD_ATTR_STACKADDR
  6103. {*r = _SC_THREAD_ATTR_STACKADDR; return 0;}
  6104. #else /* def _SC_THREAD_ATTR_STACKADDR */
  6105. {errno = EINVAL; return -1;}
  6106. #endif /* ndef _SC_THREAD_ATTR_STACKADDR */
  6107. if (x == Mono_Posix_SysconfName__SC_THREAD_ATTR_STACKSIZE)
  6108. #ifdef _SC_THREAD_ATTR_STACKSIZE
  6109. {*r = _SC_THREAD_ATTR_STACKSIZE; return 0;}
  6110. #else /* def _SC_THREAD_ATTR_STACKSIZE */
  6111. {errno = EINVAL; return -1;}
  6112. #endif /* ndef _SC_THREAD_ATTR_STACKSIZE */
  6113. if (x == Mono_Posix_SysconfName__SC_THREAD_CPUTIME)
  6114. #ifdef _SC_THREAD_CPUTIME
  6115. {*r = _SC_THREAD_CPUTIME; return 0;}
  6116. #else /* def _SC_THREAD_CPUTIME */
  6117. {errno = EINVAL; return -1;}
  6118. #endif /* ndef _SC_THREAD_CPUTIME */
  6119. if (x == Mono_Posix_SysconfName__SC_THREAD_DESTRUCTOR_ITERATIONS)
  6120. #ifdef _SC_THREAD_DESTRUCTOR_ITERATIONS
  6121. {*r = _SC_THREAD_DESTRUCTOR_ITERATIONS; return 0;}
  6122. #else /* def _SC_THREAD_DESTRUCTOR_ITERATIONS */
  6123. {errno = EINVAL; return -1;}
  6124. #endif /* ndef _SC_THREAD_DESTRUCTOR_ITERATIONS */
  6125. if (x == Mono_Posix_SysconfName__SC_THREAD_KEYS_MAX)
  6126. #ifdef _SC_THREAD_KEYS_MAX
  6127. {*r = _SC_THREAD_KEYS_MAX; return 0;}
  6128. #else /* def _SC_THREAD_KEYS_MAX */
  6129. {errno = EINVAL; return -1;}
  6130. #endif /* ndef _SC_THREAD_KEYS_MAX */
  6131. if (x == Mono_Posix_SysconfName__SC_THREAD_PRIORITY_SCHEDULING)
  6132. #ifdef _SC_THREAD_PRIORITY_SCHEDULING
  6133. {*r = _SC_THREAD_PRIORITY_SCHEDULING; return 0;}
  6134. #else /* def _SC_THREAD_PRIORITY_SCHEDULING */
  6135. {errno = EINVAL; return -1;}
  6136. #endif /* ndef _SC_THREAD_PRIORITY_SCHEDULING */
  6137. if (x == Mono_Posix_SysconfName__SC_THREAD_PRIO_INHERIT)
  6138. #ifdef _SC_THREAD_PRIO_INHERIT
  6139. {*r = _SC_THREAD_PRIO_INHERIT; return 0;}
  6140. #else /* def _SC_THREAD_PRIO_INHERIT */
  6141. {errno = EINVAL; return -1;}
  6142. #endif /* ndef _SC_THREAD_PRIO_INHERIT */
  6143. if (x == Mono_Posix_SysconfName__SC_THREAD_PRIO_PROTECT)
  6144. #ifdef _SC_THREAD_PRIO_PROTECT
  6145. {*r = _SC_THREAD_PRIO_PROTECT; return 0;}
  6146. #else /* def _SC_THREAD_PRIO_PROTECT */
  6147. {errno = EINVAL; return -1;}
  6148. #endif /* ndef _SC_THREAD_PRIO_PROTECT */
  6149. if (x == Mono_Posix_SysconfName__SC_THREAD_PROCESS_SHARED)
  6150. #ifdef _SC_THREAD_PROCESS_SHARED
  6151. {*r = _SC_THREAD_PROCESS_SHARED; return 0;}
  6152. #else /* def _SC_THREAD_PROCESS_SHARED */
  6153. {errno = EINVAL; return -1;}
  6154. #endif /* ndef _SC_THREAD_PROCESS_SHARED */
  6155. if (x == Mono_Posix_SysconfName__SC_THREAD_SAFE_FUNCTIONS)
  6156. #ifdef _SC_THREAD_SAFE_FUNCTIONS
  6157. {*r = _SC_THREAD_SAFE_FUNCTIONS; return 0;}
  6158. #else /* def _SC_THREAD_SAFE_FUNCTIONS */
  6159. {errno = EINVAL; return -1;}
  6160. #endif /* ndef _SC_THREAD_SAFE_FUNCTIONS */
  6161. if (x == Mono_Posix_SysconfName__SC_THREAD_SPORADIC_SERVER)
  6162. #ifdef _SC_THREAD_SPORADIC_SERVER
  6163. {*r = _SC_THREAD_SPORADIC_SERVER; return 0;}
  6164. #else /* def _SC_THREAD_SPORADIC_SERVER */
  6165. {errno = EINVAL; return -1;}
  6166. #endif /* ndef _SC_THREAD_SPORADIC_SERVER */
  6167. if (x == Mono_Posix_SysconfName__SC_THREAD_STACK_MIN)
  6168. #ifdef _SC_THREAD_STACK_MIN
  6169. {*r = _SC_THREAD_STACK_MIN; return 0;}
  6170. #else /* def _SC_THREAD_STACK_MIN */
  6171. {errno = EINVAL; return -1;}
  6172. #endif /* ndef _SC_THREAD_STACK_MIN */
  6173. if (x == Mono_Posix_SysconfName__SC_THREAD_THREADS_MAX)
  6174. #ifdef _SC_THREAD_THREADS_MAX
  6175. {*r = _SC_THREAD_THREADS_MAX; return 0;}
  6176. #else /* def _SC_THREAD_THREADS_MAX */
  6177. {errno = EINVAL; return -1;}
  6178. #endif /* ndef _SC_THREAD_THREADS_MAX */
  6179. if (x == Mono_Posix_SysconfName__SC_TIMEOUTS)
  6180. #ifdef _SC_TIMEOUTS
  6181. {*r = _SC_TIMEOUTS; return 0;}
  6182. #else /* def _SC_TIMEOUTS */
  6183. {errno = EINVAL; return -1;}
  6184. #endif /* ndef _SC_TIMEOUTS */
  6185. if (x == Mono_Posix_SysconfName__SC_TIMERS)
  6186. #ifdef _SC_TIMERS
  6187. {*r = _SC_TIMERS; return 0;}
  6188. #else /* def _SC_TIMERS */
  6189. {errno = EINVAL; return -1;}
  6190. #endif /* ndef _SC_TIMERS */
  6191. if (x == Mono_Posix_SysconfName__SC_TIMER_MAX)
  6192. #ifdef _SC_TIMER_MAX
  6193. {*r = _SC_TIMER_MAX; return 0;}
  6194. #else /* def _SC_TIMER_MAX */
  6195. {errno = EINVAL; return -1;}
  6196. #endif /* ndef _SC_TIMER_MAX */
  6197. if (x == Mono_Posix_SysconfName__SC_TRACE)
  6198. #ifdef _SC_TRACE
  6199. {*r = _SC_TRACE; return 0;}
  6200. #else /* def _SC_TRACE */
  6201. {errno = EINVAL; return -1;}
  6202. #endif /* ndef _SC_TRACE */
  6203. if (x == Mono_Posix_SysconfName__SC_TRACE_EVENT_FILTER)
  6204. #ifdef _SC_TRACE_EVENT_FILTER
  6205. {*r = _SC_TRACE_EVENT_FILTER; return 0;}
  6206. #else /* def _SC_TRACE_EVENT_FILTER */
  6207. {errno = EINVAL; return -1;}
  6208. #endif /* ndef _SC_TRACE_EVENT_FILTER */
  6209. if (x == Mono_Posix_SysconfName__SC_TRACE_INHERIT)
  6210. #ifdef _SC_TRACE_INHERIT
  6211. {*r = _SC_TRACE_INHERIT; return 0;}
  6212. #else /* def _SC_TRACE_INHERIT */
  6213. {errno = EINVAL; return -1;}
  6214. #endif /* ndef _SC_TRACE_INHERIT */
  6215. if (x == Mono_Posix_SysconfName__SC_TRACE_LOG)
  6216. #ifdef _SC_TRACE_LOG
  6217. {*r = _SC_TRACE_LOG; return 0;}
  6218. #else /* def _SC_TRACE_LOG */
  6219. {errno = EINVAL; return -1;}
  6220. #endif /* ndef _SC_TRACE_LOG */
  6221. if (x == Mono_Posix_SysconfName__SC_TTY_NAME_MAX)
  6222. #ifdef _SC_TTY_NAME_MAX
  6223. {*r = _SC_TTY_NAME_MAX; return 0;}
  6224. #else /* def _SC_TTY_NAME_MAX */
  6225. {errno = EINVAL; return -1;}
  6226. #endif /* ndef _SC_TTY_NAME_MAX */
  6227. if (x == Mono_Posix_SysconfName__SC_TYPED_MEMORY_OBJECTS)
  6228. #ifdef _SC_TYPED_MEMORY_OBJECTS
  6229. {*r = _SC_TYPED_MEMORY_OBJECTS; return 0;}
  6230. #else /* def _SC_TYPED_MEMORY_OBJECTS */
  6231. {errno = EINVAL; return -1;}
  6232. #endif /* ndef _SC_TYPED_MEMORY_OBJECTS */
  6233. if (x == Mono_Posix_SysconfName__SC_TZNAME_MAX)
  6234. #ifdef _SC_TZNAME_MAX
  6235. {*r = _SC_TZNAME_MAX; return 0;}
  6236. #else /* def _SC_TZNAME_MAX */
  6237. {errno = EINVAL; return -1;}
  6238. #endif /* ndef _SC_TZNAME_MAX */
  6239. if (x == Mono_Posix_SysconfName__SC_T_IOV_MAX)
  6240. #ifdef _SC_T_IOV_MAX
  6241. {*r = _SC_T_IOV_MAX; return 0;}
  6242. #else /* def _SC_T_IOV_MAX */
  6243. {errno = EINVAL; return -1;}
  6244. #endif /* ndef _SC_T_IOV_MAX */
  6245. if (x == Mono_Posix_SysconfName__SC_UCHAR_MAX)
  6246. #ifdef _SC_UCHAR_MAX
  6247. {*r = _SC_UCHAR_MAX; return 0;}
  6248. #else /* def _SC_UCHAR_MAX */
  6249. {errno = EINVAL; return -1;}
  6250. #endif /* ndef _SC_UCHAR_MAX */
  6251. if (x == Mono_Posix_SysconfName__SC_UINT_MAX)
  6252. #ifdef _SC_UINT_MAX
  6253. {*r = _SC_UINT_MAX; return 0;}
  6254. #else /* def _SC_UINT_MAX */
  6255. {errno = EINVAL; return -1;}
  6256. #endif /* ndef _SC_UINT_MAX */
  6257. if (x == Mono_Posix_SysconfName__SC_UIO_MAXIOV)
  6258. #ifdef _SC_UIO_MAXIOV
  6259. {*r = _SC_UIO_MAXIOV; return 0;}
  6260. #else /* def _SC_UIO_MAXIOV */
  6261. {errno = EINVAL; return -1;}
  6262. #endif /* ndef _SC_UIO_MAXIOV */
  6263. if (x == Mono_Posix_SysconfName__SC_ULONG_MAX)
  6264. #ifdef _SC_ULONG_MAX
  6265. {*r = _SC_ULONG_MAX; return 0;}
  6266. #else /* def _SC_ULONG_MAX */
  6267. {errno = EINVAL; return -1;}
  6268. #endif /* ndef _SC_ULONG_MAX */
  6269. if (x == Mono_Posix_SysconfName__SC_USER_GROUPS)
  6270. #ifdef _SC_USER_GROUPS
  6271. {*r = _SC_USER_GROUPS; return 0;}
  6272. #else /* def _SC_USER_GROUPS */
  6273. {errno = EINVAL; return -1;}
  6274. #endif /* ndef _SC_USER_GROUPS */
  6275. if (x == Mono_Posix_SysconfName__SC_USER_GROUPS_R)
  6276. #ifdef _SC_USER_GROUPS_R
  6277. {*r = _SC_USER_GROUPS_R; return 0;}
  6278. #else /* def _SC_USER_GROUPS_R */
  6279. {errno = EINVAL; return -1;}
  6280. #endif /* ndef _SC_USER_GROUPS_R */
  6281. if (x == Mono_Posix_SysconfName__SC_USHRT_MAX)
  6282. #ifdef _SC_USHRT_MAX
  6283. {*r = _SC_USHRT_MAX; return 0;}
  6284. #else /* def _SC_USHRT_MAX */
  6285. {errno = EINVAL; return -1;}
  6286. #endif /* ndef _SC_USHRT_MAX */
  6287. if (x == Mono_Posix_SysconfName__SC_V6_ILP32_OFF32)
  6288. #ifdef _SC_V6_ILP32_OFF32
  6289. {*r = _SC_V6_ILP32_OFF32; return 0;}
  6290. #else /* def _SC_V6_ILP32_OFF32 */
  6291. {errno = EINVAL; return -1;}
  6292. #endif /* ndef _SC_V6_ILP32_OFF32 */
  6293. if (x == Mono_Posix_SysconfName__SC_V6_ILP32_OFFBIG)
  6294. #ifdef _SC_V6_ILP32_OFFBIG
  6295. {*r = _SC_V6_ILP32_OFFBIG; return 0;}
  6296. #else /* def _SC_V6_ILP32_OFFBIG */
  6297. {errno = EINVAL; return -1;}
  6298. #endif /* ndef _SC_V6_ILP32_OFFBIG */
  6299. if (x == Mono_Posix_SysconfName__SC_V6_LP64_OFF64)
  6300. #ifdef _SC_V6_LP64_OFF64
  6301. {*r = _SC_V6_LP64_OFF64; return 0;}
  6302. #else /* def _SC_V6_LP64_OFF64 */
  6303. {errno = EINVAL; return -1;}
  6304. #endif /* ndef _SC_V6_LP64_OFF64 */
  6305. if (x == Mono_Posix_SysconfName__SC_V6_LPBIG_OFFBIG)
  6306. #ifdef _SC_V6_LPBIG_OFFBIG
  6307. {*r = _SC_V6_LPBIG_OFFBIG; return 0;}
  6308. #else /* def _SC_V6_LPBIG_OFFBIG */
  6309. {errno = EINVAL; return -1;}
  6310. #endif /* ndef _SC_V6_LPBIG_OFFBIG */
  6311. if (x == Mono_Posix_SysconfName__SC_VERSION)
  6312. #ifdef _SC_VERSION
  6313. {*r = _SC_VERSION; return 0;}
  6314. #else /* def _SC_VERSION */
  6315. {errno = EINVAL; return -1;}
  6316. #endif /* ndef _SC_VERSION */
  6317. if (x == Mono_Posix_SysconfName__SC_WORD_BIT)
  6318. #ifdef _SC_WORD_BIT
  6319. {*r = _SC_WORD_BIT; return 0;}
  6320. #else /* def _SC_WORD_BIT */
  6321. {errno = EINVAL; return -1;}
  6322. #endif /* ndef _SC_WORD_BIT */
  6323. if (x == Mono_Posix_SysconfName__SC_XBS5_ILP32_OFF32)
  6324. #ifdef _SC_XBS5_ILP32_OFF32
  6325. {*r = _SC_XBS5_ILP32_OFF32; return 0;}
  6326. #else /* def _SC_XBS5_ILP32_OFF32 */
  6327. {errno = EINVAL; return -1;}
  6328. #endif /* ndef _SC_XBS5_ILP32_OFF32 */
  6329. if (x == Mono_Posix_SysconfName__SC_XBS5_ILP32_OFFBIG)
  6330. #ifdef _SC_XBS5_ILP32_OFFBIG
  6331. {*r = _SC_XBS5_ILP32_OFFBIG; return 0;}
  6332. #else /* def _SC_XBS5_ILP32_OFFBIG */
  6333. {errno = EINVAL; return -1;}
  6334. #endif /* ndef _SC_XBS5_ILP32_OFFBIG */
  6335. if (x == Mono_Posix_SysconfName__SC_XBS5_LP64_OFF64)
  6336. #ifdef _SC_XBS5_LP64_OFF64
  6337. {*r = _SC_XBS5_LP64_OFF64; return 0;}
  6338. #else /* def _SC_XBS5_LP64_OFF64 */
  6339. {errno = EINVAL; return -1;}
  6340. #endif /* ndef _SC_XBS5_LP64_OFF64 */
  6341. if (x == Mono_Posix_SysconfName__SC_XBS5_LPBIG_OFFBIG)
  6342. #ifdef _SC_XBS5_LPBIG_OFFBIG
  6343. {*r = _SC_XBS5_LPBIG_OFFBIG; return 0;}
  6344. #else /* def _SC_XBS5_LPBIG_OFFBIG */
  6345. {errno = EINVAL; return -1;}
  6346. #endif /* ndef _SC_XBS5_LPBIG_OFFBIG */
  6347. if (x == Mono_Posix_SysconfName__SC_XOPEN_CRYPT)
  6348. #ifdef _SC_XOPEN_CRYPT
  6349. {*r = _SC_XOPEN_CRYPT; return 0;}
  6350. #else /* def _SC_XOPEN_CRYPT */
  6351. {errno = EINVAL; return -1;}
  6352. #endif /* ndef _SC_XOPEN_CRYPT */
  6353. if (x == Mono_Posix_SysconfName__SC_XOPEN_ENH_I18N)
  6354. #ifdef _SC_XOPEN_ENH_I18N
  6355. {*r = _SC_XOPEN_ENH_I18N; return 0;}
  6356. #else /* def _SC_XOPEN_ENH_I18N */
  6357. {errno = EINVAL; return -1;}
  6358. #endif /* ndef _SC_XOPEN_ENH_I18N */
  6359. if (x == Mono_Posix_SysconfName__SC_XOPEN_LEGACY)
  6360. #ifdef _SC_XOPEN_LEGACY
  6361. {*r = _SC_XOPEN_LEGACY; return 0;}
  6362. #else /* def _SC_XOPEN_LEGACY */
  6363. {errno = EINVAL; return -1;}
  6364. #endif /* ndef _SC_XOPEN_LEGACY */
  6365. if (x == Mono_Posix_SysconfName__SC_XOPEN_REALTIME)
  6366. #ifdef _SC_XOPEN_REALTIME
  6367. {*r = _SC_XOPEN_REALTIME; return 0;}
  6368. #else /* def _SC_XOPEN_REALTIME */
  6369. {errno = EINVAL; return -1;}
  6370. #endif /* ndef _SC_XOPEN_REALTIME */
  6371. if (x == Mono_Posix_SysconfName__SC_XOPEN_REALTIME_THREADS)
  6372. #ifdef _SC_XOPEN_REALTIME_THREADS
  6373. {*r = _SC_XOPEN_REALTIME_THREADS; return 0;}
  6374. #else /* def _SC_XOPEN_REALTIME_THREADS */
  6375. {errno = EINVAL; return -1;}
  6376. #endif /* ndef _SC_XOPEN_REALTIME_THREADS */
  6377. if (x == Mono_Posix_SysconfName__SC_XOPEN_SHM)
  6378. #ifdef _SC_XOPEN_SHM
  6379. {*r = _SC_XOPEN_SHM; return 0;}
  6380. #else /* def _SC_XOPEN_SHM */
  6381. {errno = EINVAL; return -1;}
  6382. #endif /* ndef _SC_XOPEN_SHM */
  6383. if (x == Mono_Posix_SysconfName__SC_XOPEN_UNIX)
  6384. #ifdef _SC_XOPEN_UNIX
  6385. {*r = _SC_XOPEN_UNIX; return 0;}
  6386. #else /* def _SC_XOPEN_UNIX */
  6387. {errno = EINVAL; return -1;}
  6388. #endif /* ndef _SC_XOPEN_UNIX */
  6389. if (x == Mono_Posix_SysconfName__SC_XOPEN_VERSION)
  6390. #ifdef _SC_XOPEN_VERSION
  6391. {*r = _SC_XOPEN_VERSION; return 0;}
  6392. #else /* def _SC_XOPEN_VERSION */
  6393. {errno = EINVAL; return -1;}
  6394. #endif /* ndef _SC_XOPEN_VERSION */
  6395. if (x == Mono_Posix_SysconfName__SC_XOPEN_XCU_VERSION)
  6396. #ifdef _SC_XOPEN_XCU_VERSION
  6397. {*r = _SC_XOPEN_XCU_VERSION; return 0;}
  6398. #else /* def _SC_XOPEN_XCU_VERSION */
  6399. {errno = EINVAL; return -1;}
  6400. #endif /* ndef _SC_XOPEN_XCU_VERSION */
  6401. if (x == Mono_Posix_SysconfName__SC_XOPEN_XPG2)
  6402. #ifdef _SC_XOPEN_XPG2
  6403. {*r = _SC_XOPEN_XPG2; return 0;}
  6404. #else /* def _SC_XOPEN_XPG2 */
  6405. {errno = EINVAL; return -1;}
  6406. #endif /* ndef _SC_XOPEN_XPG2 */
  6407. if (x == Mono_Posix_SysconfName__SC_XOPEN_XPG3)
  6408. #ifdef _SC_XOPEN_XPG3
  6409. {*r = _SC_XOPEN_XPG3; return 0;}
  6410. #else /* def _SC_XOPEN_XPG3 */
  6411. {errno = EINVAL; return -1;}
  6412. #endif /* ndef _SC_XOPEN_XPG3 */
  6413. if (x == Mono_Posix_SysconfName__SC_XOPEN_XPG4)
  6414. #ifdef _SC_XOPEN_XPG4
  6415. {*r = _SC_XOPEN_XPG4; return 0;}
  6416. #else /* def _SC_XOPEN_XPG4 */
  6417. {errno = EINVAL; return -1;}
  6418. #endif /* ndef _SC_XOPEN_XPG4 */
  6419. if (x == 0)
  6420. return 0;
  6421. errno = EINVAL; return -1;
  6422. }
  6423. int Mono_Posix_ToSysconfName (int x, int *r)
  6424. {
  6425. *r = 0;
  6426. if (x == 0)
  6427. return 0;
  6428. #ifdef _SC_2_CHAR_TERM
  6429. if (x == _SC_2_CHAR_TERM)
  6430. {*r = Mono_Posix_SysconfName__SC_2_CHAR_TERM; return 0;}
  6431. #endif /* ndef _SC_2_CHAR_TERM */
  6432. #ifdef _SC_2_C_BIND
  6433. if (x == _SC_2_C_BIND)
  6434. {*r = Mono_Posix_SysconfName__SC_2_C_BIND; return 0;}
  6435. #endif /* ndef _SC_2_C_BIND */
  6436. #ifdef _SC_2_C_DEV
  6437. if (x == _SC_2_C_DEV)
  6438. {*r = Mono_Posix_SysconfName__SC_2_C_DEV; return 0;}
  6439. #endif /* ndef _SC_2_C_DEV */
  6440. #ifdef _SC_2_C_VERSION
  6441. if (x == _SC_2_C_VERSION)
  6442. {*r = Mono_Posix_SysconfName__SC_2_C_VERSION; return 0;}
  6443. #endif /* ndef _SC_2_C_VERSION */
  6444. #ifdef _SC_2_FORT_DEV
  6445. if (x == _SC_2_FORT_DEV)
  6446. {*r = Mono_Posix_SysconfName__SC_2_FORT_DEV; return 0;}
  6447. #endif /* ndef _SC_2_FORT_DEV */
  6448. #ifdef _SC_2_FORT_RUN
  6449. if (x == _SC_2_FORT_RUN)
  6450. {*r = Mono_Posix_SysconfName__SC_2_FORT_RUN; return 0;}
  6451. #endif /* ndef _SC_2_FORT_RUN */
  6452. #ifdef _SC_2_LOCALEDEF
  6453. if (x == _SC_2_LOCALEDEF)
  6454. {*r = Mono_Posix_SysconfName__SC_2_LOCALEDEF; return 0;}
  6455. #endif /* ndef _SC_2_LOCALEDEF */
  6456. #ifdef _SC_2_PBS
  6457. if (x == _SC_2_PBS)
  6458. {*r = Mono_Posix_SysconfName__SC_2_PBS; return 0;}
  6459. #endif /* ndef _SC_2_PBS */
  6460. #ifdef _SC_2_PBS_ACCOUNTING
  6461. if (x == _SC_2_PBS_ACCOUNTING)
  6462. {*r = Mono_Posix_SysconfName__SC_2_PBS_ACCOUNTING; return 0;}
  6463. #endif /* ndef _SC_2_PBS_ACCOUNTING */
  6464. #ifdef _SC_2_PBS_CHECKPOINT
  6465. if (x == _SC_2_PBS_CHECKPOINT)
  6466. {*r = Mono_Posix_SysconfName__SC_2_PBS_CHECKPOINT; return 0;}
  6467. #endif /* ndef _SC_2_PBS_CHECKPOINT */
  6468. #ifdef _SC_2_PBS_LOCATE
  6469. if (x == _SC_2_PBS_LOCATE)
  6470. {*r = Mono_Posix_SysconfName__SC_2_PBS_LOCATE; return 0;}
  6471. #endif /* ndef _SC_2_PBS_LOCATE */
  6472. #ifdef _SC_2_PBS_MESSAGE
  6473. if (x == _SC_2_PBS_MESSAGE)
  6474. {*r = Mono_Posix_SysconfName__SC_2_PBS_MESSAGE; return 0;}
  6475. #endif /* ndef _SC_2_PBS_MESSAGE */
  6476. #ifdef _SC_2_PBS_TRACK
  6477. if (x == _SC_2_PBS_TRACK)
  6478. {*r = Mono_Posix_SysconfName__SC_2_PBS_TRACK; return 0;}
  6479. #endif /* ndef _SC_2_PBS_TRACK */
  6480. #ifdef _SC_2_SW_DEV
  6481. if (x == _SC_2_SW_DEV)
  6482. {*r = Mono_Posix_SysconfName__SC_2_SW_DEV; return 0;}
  6483. #endif /* ndef _SC_2_SW_DEV */
  6484. #ifdef _SC_2_UPE
  6485. if (x == _SC_2_UPE)
  6486. {*r = Mono_Posix_SysconfName__SC_2_UPE; return 0;}
  6487. #endif /* ndef _SC_2_UPE */
  6488. #ifdef _SC_2_VERSION
  6489. if (x == _SC_2_VERSION)
  6490. {*r = Mono_Posix_SysconfName__SC_2_VERSION; return 0;}
  6491. #endif /* ndef _SC_2_VERSION */
  6492. #ifdef _SC_ADVISORY_INFO
  6493. if (x == _SC_ADVISORY_INFO)
  6494. {*r = Mono_Posix_SysconfName__SC_ADVISORY_INFO; return 0;}
  6495. #endif /* ndef _SC_ADVISORY_INFO */
  6496. #ifdef _SC_AIO_LISTIO_MAX
  6497. if (x == _SC_AIO_LISTIO_MAX)
  6498. {*r = Mono_Posix_SysconfName__SC_AIO_LISTIO_MAX; return 0;}
  6499. #endif /* ndef _SC_AIO_LISTIO_MAX */
  6500. #ifdef _SC_AIO_MAX
  6501. if (x == _SC_AIO_MAX)
  6502. {*r = Mono_Posix_SysconfName__SC_AIO_MAX; return 0;}
  6503. #endif /* ndef _SC_AIO_MAX */
  6504. #ifdef _SC_AIO_PRIO_DELTA_MAX
  6505. if (x == _SC_AIO_PRIO_DELTA_MAX)
  6506. {*r = Mono_Posix_SysconfName__SC_AIO_PRIO_DELTA_MAX; return 0;}
  6507. #endif /* ndef _SC_AIO_PRIO_DELTA_MAX */
  6508. #ifdef _SC_ARG_MAX
  6509. if (x == _SC_ARG_MAX)
  6510. {*r = Mono_Posix_SysconfName__SC_ARG_MAX; return 0;}
  6511. #endif /* ndef _SC_ARG_MAX */
  6512. #ifdef _SC_ASYNCHRONOUS_IO
  6513. if (x == _SC_ASYNCHRONOUS_IO)
  6514. {*r = Mono_Posix_SysconfName__SC_ASYNCHRONOUS_IO; return 0;}
  6515. #endif /* ndef _SC_ASYNCHRONOUS_IO */
  6516. #ifdef _SC_ATEXIT_MAX
  6517. if (x == _SC_ATEXIT_MAX)
  6518. {*r = Mono_Posix_SysconfName__SC_ATEXIT_MAX; return 0;}
  6519. #endif /* ndef _SC_ATEXIT_MAX */
  6520. #ifdef _SC_AVPHYS_PAGES
  6521. if (x == _SC_AVPHYS_PAGES)
  6522. {*r = Mono_Posix_SysconfName__SC_AVPHYS_PAGES; return 0;}
  6523. #endif /* ndef _SC_AVPHYS_PAGES */
  6524. #ifdef _SC_BARRIERS
  6525. if (x == _SC_BARRIERS)
  6526. {*r = Mono_Posix_SysconfName__SC_BARRIERS; return 0;}
  6527. #endif /* ndef _SC_BARRIERS */
  6528. #ifdef _SC_BASE
  6529. if (x == _SC_BASE)
  6530. {*r = Mono_Posix_SysconfName__SC_BASE; return 0;}
  6531. #endif /* ndef _SC_BASE */
  6532. #ifdef _SC_BC_BASE_MAX
  6533. if (x == _SC_BC_BASE_MAX)
  6534. {*r = Mono_Posix_SysconfName__SC_BC_BASE_MAX; return 0;}
  6535. #endif /* ndef _SC_BC_BASE_MAX */
  6536. #ifdef _SC_BC_DIM_MAX
  6537. if (x == _SC_BC_DIM_MAX)
  6538. {*r = Mono_Posix_SysconfName__SC_BC_DIM_MAX; return 0;}
  6539. #endif /* ndef _SC_BC_DIM_MAX */
  6540. #ifdef _SC_BC_SCALE_MAX
  6541. if (x == _SC_BC_SCALE_MAX)
  6542. {*r = Mono_Posix_SysconfName__SC_BC_SCALE_MAX; return 0;}
  6543. #endif /* ndef _SC_BC_SCALE_MAX */
  6544. #ifdef _SC_BC_STRING_MAX
  6545. if (x == _SC_BC_STRING_MAX)
  6546. {*r = Mono_Posix_SysconfName__SC_BC_STRING_MAX; return 0;}
  6547. #endif /* ndef _SC_BC_STRING_MAX */
  6548. #ifdef _SC_CHARCLASS_NAME_MAX
  6549. if (x == _SC_CHARCLASS_NAME_MAX)
  6550. {*r = Mono_Posix_SysconfName__SC_CHARCLASS_NAME_MAX; return 0;}
  6551. #endif /* ndef _SC_CHARCLASS_NAME_MAX */
  6552. #ifdef _SC_CHAR_BIT
  6553. if (x == _SC_CHAR_BIT)
  6554. {*r = Mono_Posix_SysconfName__SC_CHAR_BIT; return 0;}
  6555. #endif /* ndef _SC_CHAR_BIT */
  6556. #ifdef _SC_CHAR_MAX
  6557. if (x == _SC_CHAR_MAX)
  6558. {*r = Mono_Posix_SysconfName__SC_CHAR_MAX; return 0;}
  6559. #endif /* ndef _SC_CHAR_MAX */
  6560. #ifdef _SC_CHAR_MIN
  6561. if (x == _SC_CHAR_MIN)
  6562. {*r = Mono_Posix_SysconfName__SC_CHAR_MIN; return 0;}
  6563. #endif /* ndef _SC_CHAR_MIN */
  6564. #ifdef _SC_CHILD_MAX
  6565. if (x == _SC_CHILD_MAX)
  6566. {*r = Mono_Posix_SysconfName__SC_CHILD_MAX; return 0;}
  6567. #endif /* ndef _SC_CHILD_MAX */
  6568. #ifdef _SC_CLK_TCK
  6569. if (x == _SC_CLK_TCK)
  6570. {*r = Mono_Posix_SysconfName__SC_CLK_TCK; return 0;}
  6571. #endif /* ndef _SC_CLK_TCK */
  6572. #ifdef _SC_CLOCK_SELECTION
  6573. if (x == _SC_CLOCK_SELECTION)
  6574. {*r = Mono_Posix_SysconfName__SC_CLOCK_SELECTION; return 0;}
  6575. #endif /* ndef _SC_CLOCK_SELECTION */
  6576. #ifdef _SC_COLL_WEIGHTS_MAX
  6577. if (x == _SC_COLL_WEIGHTS_MAX)
  6578. {*r = Mono_Posix_SysconfName__SC_COLL_WEIGHTS_MAX; return 0;}
  6579. #endif /* ndef _SC_COLL_WEIGHTS_MAX */
  6580. #ifdef _SC_CPUTIME
  6581. if (x == _SC_CPUTIME)
  6582. {*r = Mono_Posix_SysconfName__SC_CPUTIME; return 0;}
  6583. #endif /* ndef _SC_CPUTIME */
  6584. #ifdef _SC_C_LANG_SUPPORT
  6585. if (x == _SC_C_LANG_SUPPORT)
  6586. {*r = Mono_Posix_SysconfName__SC_C_LANG_SUPPORT; return 0;}
  6587. #endif /* ndef _SC_C_LANG_SUPPORT */
  6588. #ifdef _SC_C_LANG_SUPPORT_R
  6589. if (x == _SC_C_LANG_SUPPORT_R)
  6590. {*r = Mono_Posix_SysconfName__SC_C_LANG_SUPPORT_R; return 0;}
  6591. #endif /* ndef _SC_C_LANG_SUPPORT_R */
  6592. #ifdef _SC_DELAYTIMER_MAX
  6593. if (x == _SC_DELAYTIMER_MAX)
  6594. {*r = Mono_Posix_SysconfName__SC_DELAYTIMER_MAX; return 0;}
  6595. #endif /* ndef _SC_DELAYTIMER_MAX */
  6596. #ifdef _SC_DEVICE_IO
  6597. if (x == _SC_DEVICE_IO)
  6598. {*r = Mono_Posix_SysconfName__SC_DEVICE_IO; return 0;}
  6599. #endif /* ndef _SC_DEVICE_IO */
  6600. #ifdef _SC_DEVICE_SPECIFIC
  6601. if (x == _SC_DEVICE_SPECIFIC)
  6602. {*r = Mono_Posix_SysconfName__SC_DEVICE_SPECIFIC; return 0;}
  6603. #endif /* ndef _SC_DEVICE_SPECIFIC */
  6604. #ifdef _SC_DEVICE_SPECIFIC_R
  6605. if (x == _SC_DEVICE_SPECIFIC_R)
  6606. {*r = Mono_Posix_SysconfName__SC_DEVICE_SPECIFIC_R; return 0;}
  6607. #endif /* ndef _SC_DEVICE_SPECIFIC_R */
  6608. #ifdef _SC_EQUIV_CLASS_MAX
  6609. if (x == _SC_EQUIV_CLASS_MAX)
  6610. {*r = Mono_Posix_SysconfName__SC_EQUIV_CLASS_MAX; return 0;}
  6611. #endif /* ndef _SC_EQUIV_CLASS_MAX */
  6612. #ifdef _SC_EXPR_NEST_MAX
  6613. if (x == _SC_EXPR_NEST_MAX)
  6614. {*r = Mono_Posix_SysconfName__SC_EXPR_NEST_MAX; return 0;}
  6615. #endif /* ndef _SC_EXPR_NEST_MAX */
  6616. #ifdef _SC_FD_MGMT
  6617. if (x == _SC_FD_MGMT)
  6618. {*r = Mono_Posix_SysconfName__SC_FD_MGMT; return 0;}
  6619. #endif /* ndef _SC_FD_MGMT */
  6620. #ifdef _SC_FIFO
  6621. if (x == _SC_FIFO)
  6622. {*r = Mono_Posix_SysconfName__SC_FIFO; return 0;}
  6623. #endif /* ndef _SC_FIFO */
  6624. #ifdef _SC_FILE_ATTRIBUTES
  6625. if (x == _SC_FILE_ATTRIBUTES)
  6626. {*r = Mono_Posix_SysconfName__SC_FILE_ATTRIBUTES; return 0;}
  6627. #endif /* ndef _SC_FILE_ATTRIBUTES */
  6628. #ifdef _SC_FILE_LOCKING
  6629. if (x == _SC_FILE_LOCKING)
  6630. {*r = Mono_Posix_SysconfName__SC_FILE_LOCKING; return 0;}
  6631. #endif /* ndef _SC_FILE_LOCKING */
  6632. #ifdef _SC_FILE_SYSTEM
  6633. if (x == _SC_FILE_SYSTEM)
  6634. {*r = Mono_Posix_SysconfName__SC_FILE_SYSTEM; return 0;}
  6635. #endif /* ndef _SC_FILE_SYSTEM */
  6636. #ifdef _SC_FSYNC
  6637. if (x == _SC_FSYNC)
  6638. {*r = Mono_Posix_SysconfName__SC_FSYNC; return 0;}
  6639. #endif /* ndef _SC_FSYNC */
  6640. #ifdef _SC_GETGR_R_SIZE_MAX
  6641. if (x == _SC_GETGR_R_SIZE_MAX)
  6642. {*r = Mono_Posix_SysconfName__SC_GETGR_R_SIZE_MAX; return 0;}
  6643. #endif /* ndef _SC_GETGR_R_SIZE_MAX */
  6644. #ifdef _SC_GETPW_R_SIZE_MAX
  6645. if (x == _SC_GETPW_R_SIZE_MAX)
  6646. {*r = Mono_Posix_SysconfName__SC_GETPW_R_SIZE_MAX; return 0;}
  6647. #endif /* ndef _SC_GETPW_R_SIZE_MAX */
  6648. #ifdef _SC_HOST_NAME_MAX
  6649. if (x == _SC_HOST_NAME_MAX)
  6650. {*r = Mono_Posix_SysconfName__SC_HOST_NAME_MAX; return 0;}
  6651. #endif /* ndef _SC_HOST_NAME_MAX */
  6652. #ifdef _SC_INT_MAX
  6653. if (x == _SC_INT_MAX)
  6654. {*r = Mono_Posix_SysconfName__SC_INT_MAX; return 0;}
  6655. #endif /* ndef _SC_INT_MAX */
  6656. #ifdef _SC_INT_MIN
  6657. if (x == _SC_INT_MIN)
  6658. {*r = Mono_Posix_SysconfName__SC_INT_MIN; return 0;}
  6659. #endif /* ndef _SC_INT_MIN */
  6660. #ifdef _SC_IOV_MAX
  6661. if (x == _SC_IOV_MAX)
  6662. {*r = Mono_Posix_SysconfName__SC_IOV_MAX; return 0;}
  6663. #endif /* ndef _SC_IOV_MAX */
  6664. #ifdef _SC_JOB_CONTROL
  6665. if (x == _SC_JOB_CONTROL)
  6666. {*r = Mono_Posix_SysconfName__SC_JOB_CONTROL; return 0;}
  6667. #endif /* ndef _SC_JOB_CONTROL */
  6668. #ifdef _SC_LEVEL1_DCACHE_ASSOC
  6669. if (x == _SC_LEVEL1_DCACHE_ASSOC)
  6670. {*r = Mono_Posix_SysconfName__SC_LEVEL1_DCACHE_ASSOC; return 0;}
  6671. #endif /* ndef _SC_LEVEL1_DCACHE_ASSOC */
  6672. #ifdef _SC_LEVEL1_DCACHE_LINESIZE
  6673. if (x == _SC_LEVEL1_DCACHE_LINESIZE)
  6674. {*r = Mono_Posix_SysconfName__SC_LEVEL1_DCACHE_LINESIZE; return 0;}
  6675. #endif /* ndef _SC_LEVEL1_DCACHE_LINESIZE */
  6676. #ifdef _SC_LEVEL1_DCACHE_SIZE
  6677. if (x == _SC_LEVEL1_DCACHE_SIZE)
  6678. {*r = Mono_Posix_SysconfName__SC_LEVEL1_DCACHE_SIZE; return 0;}
  6679. #endif /* ndef _SC_LEVEL1_DCACHE_SIZE */
  6680. #ifdef _SC_LEVEL1_ICACHE_ASSOC
  6681. if (x == _SC_LEVEL1_ICACHE_ASSOC)
  6682. {*r = Mono_Posix_SysconfName__SC_LEVEL1_ICACHE_ASSOC; return 0;}
  6683. #endif /* ndef _SC_LEVEL1_ICACHE_ASSOC */
  6684. #ifdef _SC_LEVEL1_ICACHE_LINESIZE
  6685. if (x == _SC_LEVEL1_ICACHE_LINESIZE)
  6686. {*r = Mono_Posix_SysconfName__SC_LEVEL1_ICACHE_LINESIZE; return 0;}
  6687. #endif /* ndef _SC_LEVEL1_ICACHE_LINESIZE */
  6688. #ifdef _SC_LEVEL1_ICACHE_SIZE
  6689. if (x == _SC_LEVEL1_ICACHE_SIZE)
  6690. {*r = Mono_Posix_SysconfName__SC_LEVEL1_ICACHE_SIZE; return 0;}
  6691. #endif /* ndef _SC_LEVEL1_ICACHE_SIZE */
  6692. #ifdef _SC_LEVEL2_CACHE_ASSOC
  6693. if (x == _SC_LEVEL2_CACHE_ASSOC)
  6694. {*r = Mono_Posix_SysconfName__SC_LEVEL2_CACHE_ASSOC; return 0;}
  6695. #endif /* ndef _SC_LEVEL2_CACHE_ASSOC */
  6696. #ifdef _SC_LEVEL2_CACHE_LINESIZE
  6697. if (x == _SC_LEVEL2_CACHE_LINESIZE)
  6698. {*r = Mono_Posix_SysconfName__SC_LEVEL2_CACHE_LINESIZE; return 0;}
  6699. #endif /* ndef _SC_LEVEL2_CACHE_LINESIZE */
  6700. #ifdef _SC_LEVEL2_CACHE_SIZE
  6701. if (x == _SC_LEVEL2_CACHE_SIZE)
  6702. {*r = Mono_Posix_SysconfName__SC_LEVEL2_CACHE_SIZE; return 0;}
  6703. #endif /* ndef _SC_LEVEL2_CACHE_SIZE */
  6704. #ifdef _SC_LEVEL3_CACHE_ASSOC
  6705. if (x == _SC_LEVEL3_CACHE_ASSOC)
  6706. {*r = Mono_Posix_SysconfName__SC_LEVEL3_CACHE_ASSOC; return 0;}
  6707. #endif /* ndef _SC_LEVEL3_CACHE_ASSOC */
  6708. #ifdef _SC_LEVEL3_CACHE_LINESIZE
  6709. if (x == _SC_LEVEL3_CACHE_LINESIZE)
  6710. {*r = Mono_Posix_SysconfName__SC_LEVEL3_CACHE_LINESIZE; return 0;}
  6711. #endif /* ndef _SC_LEVEL3_CACHE_LINESIZE */
  6712. #ifdef _SC_LEVEL3_CACHE_SIZE
  6713. if (x == _SC_LEVEL3_CACHE_SIZE)
  6714. {*r = Mono_Posix_SysconfName__SC_LEVEL3_CACHE_SIZE; return 0;}
  6715. #endif /* ndef _SC_LEVEL3_CACHE_SIZE */
  6716. #ifdef _SC_LEVEL4_CACHE_ASSOC
  6717. if (x == _SC_LEVEL4_CACHE_ASSOC)
  6718. {*r = Mono_Posix_SysconfName__SC_LEVEL4_CACHE_ASSOC; return 0;}
  6719. #endif /* ndef _SC_LEVEL4_CACHE_ASSOC */
  6720. #ifdef _SC_LEVEL4_CACHE_LINESIZE
  6721. if (x == _SC_LEVEL4_CACHE_LINESIZE)
  6722. {*r = Mono_Posix_SysconfName__SC_LEVEL4_CACHE_LINESIZE; return 0;}
  6723. #endif /* ndef _SC_LEVEL4_CACHE_LINESIZE */
  6724. #ifdef _SC_LEVEL4_CACHE_SIZE
  6725. if (x == _SC_LEVEL4_CACHE_SIZE)
  6726. {*r = Mono_Posix_SysconfName__SC_LEVEL4_CACHE_SIZE; return 0;}
  6727. #endif /* ndef _SC_LEVEL4_CACHE_SIZE */
  6728. #ifdef _SC_LINE_MAX
  6729. if (x == _SC_LINE_MAX)
  6730. {*r = Mono_Posix_SysconfName__SC_LINE_MAX; return 0;}
  6731. #endif /* ndef _SC_LINE_MAX */
  6732. #ifdef _SC_LOGIN_NAME_MAX
  6733. if (x == _SC_LOGIN_NAME_MAX)
  6734. {*r = Mono_Posix_SysconfName__SC_LOGIN_NAME_MAX; return 0;}
  6735. #endif /* ndef _SC_LOGIN_NAME_MAX */
  6736. #ifdef _SC_LONG_BIT
  6737. if (x == _SC_LONG_BIT)
  6738. {*r = Mono_Posix_SysconfName__SC_LONG_BIT; return 0;}
  6739. #endif /* ndef _SC_LONG_BIT */
  6740. #ifdef _SC_MAPPED_FILES
  6741. if (x == _SC_MAPPED_FILES)
  6742. {*r = Mono_Posix_SysconfName__SC_MAPPED_FILES; return 0;}
  6743. #endif /* ndef _SC_MAPPED_FILES */
  6744. #ifdef _SC_MB_LEN_MAX
  6745. if (x == _SC_MB_LEN_MAX)
  6746. {*r = Mono_Posix_SysconfName__SC_MB_LEN_MAX; return 0;}
  6747. #endif /* ndef _SC_MB_LEN_MAX */
  6748. #ifdef _SC_MEMLOCK
  6749. if (x == _SC_MEMLOCK)
  6750. {*r = Mono_Posix_SysconfName__SC_MEMLOCK; return 0;}
  6751. #endif /* ndef _SC_MEMLOCK */
  6752. #ifdef _SC_MEMLOCK_RANGE
  6753. if (x == _SC_MEMLOCK_RANGE)
  6754. {*r = Mono_Posix_SysconfName__SC_MEMLOCK_RANGE; return 0;}
  6755. #endif /* ndef _SC_MEMLOCK_RANGE */
  6756. #ifdef _SC_MEMORY_PROTECTION
  6757. if (x == _SC_MEMORY_PROTECTION)
  6758. {*r = Mono_Posix_SysconfName__SC_MEMORY_PROTECTION; return 0;}
  6759. #endif /* ndef _SC_MEMORY_PROTECTION */
  6760. #ifdef _SC_MESSAGE_PASSING
  6761. if (x == _SC_MESSAGE_PASSING)
  6762. {*r = Mono_Posix_SysconfName__SC_MESSAGE_PASSING; return 0;}
  6763. #endif /* ndef _SC_MESSAGE_PASSING */
  6764. #ifdef _SC_MONOTONIC_CLOCK
  6765. if (x == _SC_MONOTONIC_CLOCK)
  6766. {*r = Mono_Posix_SysconfName__SC_MONOTONIC_CLOCK; return 0;}
  6767. #endif /* ndef _SC_MONOTONIC_CLOCK */
  6768. #ifdef _SC_MQ_OPEN_MAX
  6769. if (x == _SC_MQ_OPEN_MAX)
  6770. {*r = Mono_Posix_SysconfName__SC_MQ_OPEN_MAX; return 0;}
  6771. #endif /* ndef _SC_MQ_OPEN_MAX */
  6772. #ifdef _SC_MQ_PRIO_MAX
  6773. if (x == _SC_MQ_PRIO_MAX)
  6774. {*r = Mono_Posix_SysconfName__SC_MQ_PRIO_MAX; return 0;}
  6775. #endif /* ndef _SC_MQ_PRIO_MAX */
  6776. #ifdef _SC_MULTI_PROCESS
  6777. if (x == _SC_MULTI_PROCESS)
  6778. {*r = Mono_Posix_SysconfName__SC_MULTI_PROCESS; return 0;}
  6779. #endif /* ndef _SC_MULTI_PROCESS */
  6780. #ifdef _SC_NETWORKING
  6781. if (x == _SC_NETWORKING)
  6782. {*r = Mono_Posix_SysconfName__SC_NETWORKING; return 0;}
  6783. #endif /* ndef _SC_NETWORKING */
  6784. #ifdef _SC_NGROUPS_MAX
  6785. if (x == _SC_NGROUPS_MAX)
  6786. {*r = Mono_Posix_SysconfName__SC_NGROUPS_MAX; return 0;}
  6787. #endif /* ndef _SC_NGROUPS_MAX */
  6788. #ifdef _SC_NL_ARGMAX
  6789. if (x == _SC_NL_ARGMAX)
  6790. {*r = Mono_Posix_SysconfName__SC_NL_ARGMAX; return 0;}
  6791. #endif /* ndef _SC_NL_ARGMAX */
  6792. #ifdef _SC_NL_LANGMAX
  6793. if (x == _SC_NL_LANGMAX)
  6794. {*r = Mono_Posix_SysconfName__SC_NL_LANGMAX; return 0;}
  6795. #endif /* ndef _SC_NL_LANGMAX */
  6796. #ifdef _SC_NL_MSGMAX
  6797. if (x == _SC_NL_MSGMAX)
  6798. {*r = Mono_Posix_SysconfName__SC_NL_MSGMAX; return 0;}
  6799. #endif /* ndef _SC_NL_MSGMAX */
  6800. #ifdef _SC_NL_NMAX
  6801. if (x == _SC_NL_NMAX)
  6802. {*r = Mono_Posix_SysconfName__SC_NL_NMAX; return 0;}
  6803. #endif /* ndef _SC_NL_NMAX */
  6804. #ifdef _SC_NL_SETMAX
  6805. if (x == _SC_NL_SETMAX)
  6806. {*r = Mono_Posix_SysconfName__SC_NL_SETMAX; return 0;}
  6807. #endif /* ndef _SC_NL_SETMAX */
  6808. #ifdef _SC_NL_TEXTMAX
  6809. if (x == _SC_NL_TEXTMAX)
  6810. {*r = Mono_Posix_SysconfName__SC_NL_TEXTMAX; return 0;}
  6811. #endif /* ndef _SC_NL_TEXTMAX */
  6812. #ifdef _SC_NPROCESSORS_CONF
  6813. if (x == _SC_NPROCESSORS_CONF)
  6814. {*r = Mono_Posix_SysconfName__SC_NPROCESSORS_CONF; return 0;}
  6815. #endif /* ndef _SC_NPROCESSORS_CONF */
  6816. #ifdef _SC_NPROCESSORS_ONLN
  6817. if (x == _SC_NPROCESSORS_ONLN)
  6818. {*r = Mono_Posix_SysconfName__SC_NPROCESSORS_ONLN; return 0;}
  6819. #endif /* ndef _SC_NPROCESSORS_ONLN */
  6820. #ifdef _SC_NZERO
  6821. if (x == _SC_NZERO)
  6822. {*r = Mono_Posix_SysconfName__SC_NZERO; return 0;}
  6823. #endif /* ndef _SC_NZERO */
  6824. #ifdef _SC_OPEN_MAX
  6825. if (x == _SC_OPEN_MAX)
  6826. {*r = Mono_Posix_SysconfName__SC_OPEN_MAX; return 0;}
  6827. #endif /* ndef _SC_OPEN_MAX */
  6828. #ifdef _SC_PAGESIZE
  6829. if (x == _SC_PAGESIZE)
  6830. {*r = Mono_Posix_SysconfName__SC_PAGESIZE; return 0;}
  6831. #endif /* ndef _SC_PAGESIZE */
  6832. #ifdef _SC_PASS_MAX
  6833. if (x == _SC_PASS_MAX)
  6834. {*r = Mono_Posix_SysconfName__SC_PASS_MAX; return 0;}
  6835. #endif /* ndef _SC_PASS_MAX */
  6836. #ifdef _SC_PHYS_PAGES
  6837. if (x == _SC_PHYS_PAGES)
  6838. {*r = Mono_Posix_SysconfName__SC_PHYS_PAGES; return 0;}
  6839. #endif /* ndef _SC_PHYS_PAGES */
  6840. #ifdef _SC_PII
  6841. if (x == _SC_PII)
  6842. {*r = Mono_Posix_SysconfName__SC_PII; return 0;}
  6843. #endif /* ndef _SC_PII */
  6844. #ifdef _SC_PII_INTERNET
  6845. if (x == _SC_PII_INTERNET)
  6846. {*r = Mono_Posix_SysconfName__SC_PII_INTERNET; return 0;}
  6847. #endif /* ndef _SC_PII_INTERNET */
  6848. #ifdef _SC_PII_INTERNET_DGRAM
  6849. if (x == _SC_PII_INTERNET_DGRAM)
  6850. {*r = Mono_Posix_SysconfName__SC_PII_INTERNET_DGRAM; return 0;}
  6851. #endif /* ndef _SC_PII_INTERNET_DGRAM */
  6852. #ifdef _SC_PII_INTERNET_STREAM
  6853. if (x == _SC_PII_INTERNET_STREAM)
  6854. {*r = Mono_Posix_SysconfName__SC_PII_INTERNET_STREAM; return 0;}
  6855. #endif /* ndef _SC_PII_INTERNET_STREAM */
  6856. #ifdef _SC_PII_OSI
  6857. if (x == _SC_PII_OSI)
  6858. {*r = Mono_Posix_SysconfName__SC_PII_OSI; return 0;}
  6859. #endif /* ndef _SC_PII_OSI */
  6860. #ifdef _SC_PII_OSI_CLTS
  6861. if (x == _SC_PII_OSI_CLTS)
  6862. {*r = Mono_Posix_SysconfName__SC_PII_OSI_CLTS; return 0;}
  6863. #endif /* ndef _SC_PII_OSI_CLTS */
  6864. #ifdef _SC_PII_OSI_COTS
  6865. if (x == _SC_PII_OSI_COTS)
  6866. {*r = Mono_Posix_SysconfName__SC_PII_OSI_COTS; return 0;}
  6867. #endif /* ndef _SC_PII_OSI_COTS */
  6868. #ifdef _SC_PII_OSI_M
  6869. if (x == _SC_PII_OSI_M)
  6870. {*r = Mono_Posix_SysconfName__SC_PII_OSI_M; return 0;}
  6871. #endif /* ndef _SC_PII_OSI_M */
  6872. #ifdef _SC_PII_SOCKET
  6873. if (x == _SC_PII_SOCKET)
  6874. {*r = Mono_Posix_SysconfName__SC_PII_SOCKET; return 0;}
  6875. #endif /* ndef _SC_PII_SOCKET */
  6876. #ifdef _SC_PII_XTI
  6877. if (x == _SC_PII_XTI)
  6878. {*r = Mono_Posix_SysconfName__SC_PII_XTI; return 0;}
  6879. #endif /* ndef _SC_PII_XTI */
  6880. #ifdef _SC_PIPE
  6881. if (x == _SC_PIPE)
  6882. {*r = Mono_Posix_SysconfName__SC_PIPE; return 0;}
  6883. #endif /* ndef _SC_PIPE */
  6884. #ifdef _SC_POLL
  6885. if (x == _SC_POLL)
  6886. {*r = Mono_Posix_SysconfName__SC_POLL; return 0;}
  6887. #endif /* ndef _SC_POLL */
  6888. #ifdef _SC_PRIORITIZED_IO
  6889. if (x == _SC_PRIORITIZED_IO)
  6890. {*r = Mono_Posix_SysconfName__SC_PRIORITIZED_IO; return 0;}
  6891. #endif /* ndef _SC_PRIORITIZED_IO */
  6892. #ifdef _SC_PRIORITY_SCHEDULING
  6893. if (x == _SC_PRIORITY_SCHEDULING)
  6894. {*r = Mono_Posix_SysconfName__SC_PRIORITY_SCHEDULING; return 0;}
  6895. #endif /* ndef _SC_PRIORITY_SCHEDULING */
  6896. #ifdef _SC_READER_WRITER_LOCKS
  6897. if (x == _SC_READER_WRITER_LOCKS)
  6898. {*r = Mono_Posix_SysconfName__SC_READER_WRITER_LOCKS; return 0;}
  6899. #endif /* ndef _SC_READER_WRITER_LOCKS */
  6900. #ifdef _SC_REALTIME_SIGNALS
  6901. if (x == _SC_REALTIME_SIGNALS)
  6902. {*r = Mono_Posix_SysconfName__SC_REALTIME_SIGNALS; return 0;}
  6903. #endif /* ndef _SC_REALTIME_SIGNALS */
  6904. #ifdef _SC_REGEXP
  6905. if (x == _SC_REGEXP)
  6906. {*r = Mono_Posix_SysconfName__SC_REGEXP; return 0;}
  6907. #endif /* ndef _SC_REGEXP */
  6908. #ifdef _SC_REGEX_VERSION
  6909. if (x == _SC_REGEX_VERSION)
  6910. {*r = Mono_Posix_SysconfName__SC_REGEX_VERSION; return 0;}
  6911. #endif /* ndef _SC_REGEX_VERSION */
  6912. #ifdef _SC_RE_DUP_MAX
  6913. if (x == _SC_RE_DUP_MAX)
  6914. {*r = Mono_Posix_SysconfName__SC_RE_DUP_MAX; return 0;}
  6915. #endif /* ndef _SC_RE_DUP_MAX */
  6916. #ifdef _SC_RTSIG_MAX
  6917. if (x == _SC_RTSIG_MAX)
  6918. {*r = Mono_Posix_SysconfName__SC_RTSIG_MAX; return 0;}
  6919. #endif /* ndef _SC_RTSIG_MAX */
  6920. #ifdef _SC_SAVED_IDS
  6921. if (x == _SC_SAVED_IDS)
  6922. {*r = Mono_Posix_SysconfName__SC_SAVED_IDS; return 0;}
  6923. #endif /* ndef _SC_SAVED_IDS */
  6924. #ifdef _SC_SCHAR_MAX
  6925. if (x == _SC_SCHAR_MAX)
  6926. {*r = Mono_Posix_SysconfName__SC_SCHAR_MAX; return 0;}
  6927. #endif /* ndef _SC_SCHAR_MAX */
  6928. #ifdef _SC_SCHAR_MIN
  6929. if (x == _SC_SCHAR_MIN)
  6930. {*r = Mono_Posix_SysconfName__SC_SCHAR_MIN; return 0;}
  6931. #endif /* ndef _SC_SCHAR_MIN */
  6932. #ifdef _SC_SELECT
  6933. if (x == _SC_SELECT)
  6934. {*r = Mono_Posix_SysconfName__SC_SELECT; return 0;}
  6935. #endif /* ndef _SC_SELECT */
  6936. #ifdef _SC_SEMAPHORES
  6937. if (x == _SC_SEMAPHORES)
  6938. {*r = Mono_Posix_SysconfName__SC_SEMAPHORES; return 0;}
  6939. #endif /* ndef _SC_SEMAPHORES */
  6940. #ifdef _SC_SEM_NSEMS_MAX
  6941. if (x == _SC_SEM_NSEMS_MAX)
  6942. {*r = Mono_Posix_SysconfName__SC_SEM_NSEMS_MAX; return 0;}
  6943. #endif /* ndef _SC_SEM_NSEMS_MAX */
  6944. #ifdef _SC_SEM_VALUE_MAX
  6945. if (x == _SC_SEM_VALUE_MAX)
  6946. {*r = Mono_Posix_SysconfName__SC_SEM_VALUE_MAX; return 0;}
  6947. #endif /* ndef _SC_SEM_VALUE_MAX */
  6948. #ifdef _SC_SHARED_MEMORY_OBJECTS
  6949. if (x == _SC_SHARED_MEMORY_OBJECTS)
  6950. {*r = Mono_Posix_SysconfName__SC_SHARED_MEMORY_OBJECTS; return 0;}
  6951. #endif /* ndef _SC_SHARED_MEMORY_OBJECTS */
  6952. #ifdef _SC_SHELL
  6953. if (x == _SC_SHELL)
  6954. {*r = Mono_Posix_SysconfName__SC_SHELL; return 0;}
  6955. #endif /* ndef _SC_SHELL */
  6956. #ifdef _SC_SHRT_MAX
  6957. if (x == _SC_SHRT_MAX)
  6958. {*r = Mono_Posix_SysconfName__SC_SHRT_MAX; return 0;}
  6959. #endif /* ndef _SC_SHRT_MAX */
  6960. #ifdef _SC_SHRT_MIN
  6961. if (x == _SC_SHRT_MIN)
  6962. {*r = Mono_Posix_SysconfName__SC_SHRT_MIN; return 0;}
  6963. #endif /* ndef _SC_SHRT_MIN */
  6964. #ifdef _SC_SIGNALS
  6965. if (x == _SC_SIGNALS)
  6966. {*r = Mono_Posix_SysconfName__SC_SIGNALS; return 0;}
  6967. #endif /* ndef _SC_SIGNALS */
  6968. #ifdef _SC_SIGQUEUE_MAX
  6969. if (x == _SC_SIGQUEUE_MAX)
  6970. {*r = Mono_Posix_SysconfName__SC_SIGQUEUE_MAX; return 0;}
  6971. #endif /* ndef _SC_SIGQUEUE_MAX */
  6972. #ifdef _SC_SINGLE_PROCESS
  6973. if (x == _SC_SINGLE_PROCESS)
  6974. {*r = Mono_Posix_SysconfName__SC_SINGLE_PROCESS; return 0;}
  6975. #endif /* ndef _SC_SINGLE_PROCESS */
  6976. #ifdef _SC_SPAWN
  6977. if (x == _SC_SPAWN)
  6978. {*r = Mono_Posix_SysconfName__SC_SPAWN; return 0;}
  6979. #endif /* ndef _SC_SPAWN */
  6980. #ifdef _SC_SPIN_LOCKS
  6981. if (x == _SC_SPIN_LOCKS)
  6982. {*r = Mono_Posix_SysconfName__SC_SPIN_LOCKS; return 0;}
  6983. #endif /* ndef _SC_SPIN_LOCKS */
  6984. #ifdef _SC_SPORADIC_SERVER
  6985. if (x == _SC_SPORADIC_SERVER)
  6986. {*r = Mono_Posix_SysconfName__SC_SPORADIC_SERVER; return 0;}
  6987. #endif /* ndef _SC_SPORADIC_SERVER */
  6988. #ifdef _SC_SSIZE_MAX
  6989. if (x == _SC_SSIZE_MAX)
  6990. {*r = Mono_Posix_SysconfName__SC_SSIZE_MAX; return 0;}
  6991. #endif /* ndef _SC_SSIZE_MAX */
  6992. #ifdef _SC_STREAMS
  6993. if (x == _SC_STREAMS)
  6994. {*r = Mono_Posix_SysconfName__SC_STREAMS; return 0;}
  6995. #endif /* ndef _SC_STREAMS */
  6996. #ifdef _SC_STREAM_MAX
  6997. if (x == _SC_STREAM_MAX)
  6998. {*r = Mono_Posix_SysconfName__SC_STREAM_MAX; return 0;}
  6999. #endif /* ndef _SC_STREAM_MAX */
  7000. #ifdef _SC_SYMLOOP_MAX
  7001. if (x == _SC_SYMLOOP_MAX)
  7002. {*r = Mono_Posix_SysconfName__SC_SYMLOOP_MAX; return 0;}
  7003. #endif /* ndef _SC_SYMLOOP_MAX */
  7004. #ifdef _SC_SYNCHRONIZED_IO
  7005. if (x == _SC_SYNCHRONIZED_IO)
  7006. {*r = Mono_Posix_SysconfName__SC_SYNCHRONIZED_IO; return 0;}
  7007. #endif /* ndef _SC_SYNCHRONIZED_IO */
  7008. #ifdef _SC_SYSTEM_DATABASE
  7009. if (x == _SC_SYSTEM_DATABASE)
  7010. {*r = Mono_Posix_SysconfName__SC_SYSTEM_DATABASE; return 0;}
  7011. #endif /* ndef _SC_SYSTEM_DATABASE */
  7012. #ifdef _SC_SYSTEM_DATABASE_R
  7013. if (x == _SC_SYSTEM_DATABASE_R)
  7014. {*r = Mono_Posix_SysconfName__SC_SYSTEM_DATABASE_R; return 0;}
  7015. #endif /* ndef _SC_SYSTEM_DATABASE_R */
  7016. #ifdef _SC_THREADS
  7017. if (x == _SC_THREADS)
  7018. {*r = Mono_Posix_SysconfName__SC_THREADS; return 0;}
  7019. #endif /* ndef _SC_THREADS */
  7020. #ifdef _SC_THREAD_ATTR_STACKADDR
  7021. if (x == _SC_THREAD_ATTR_STACKADDR)
  7022. {*r = Mono_Posix_SysconfName__SC_THREAD_ATTR_STACKADDR; return 0;}
  7023. #endif /* ndef _SC_THREAD_ATTR_STACKADDR */
  7024. #ifdef _SC_THREAD_ATTR_STACKSIZE
  7025. if (x == _SC_THREAD_ATTR_STACKSIZE)
  7026. {*r = Mono_Posix_SysconfName__SC_THREAD_ATTR_STACKSIZE; return 0;}
  7027. #endif /* ndef _SC_THREAD_ATTR_STACKSIZE */
  7028. #ifdef _SC_THREAD_CPUTIME
  7029. if (x == _SC_THREAD_CPUTIME)
  7030. {*r = Mono_Posix_SysconfName__SC_THREAD_CPUTIME; return 0;}
  7031. #endif /* ndef _SC_THREAD_CPUTIME */
  7032. #ifdef _SC_THREAD_DESTRUCTOR_ITERATIONS
  7033. if (x == _SC_THREAD_DESTRUCTOR_ITERATIONS)
  7034. {*r = Mono_Posix_SysconfName__SC_THREAD_DESTRUCTOR_ITERATIONS; return 0;}
  7035. #endif /* ndef _SC_THREAD_DESTRUCTOR_ITERATIONS */
  7036. #ifdef _SC_THREAD_KEYS_MAX
  7037. if (x == _SC_THREAD_KEYS_MAX)
  7038. {*r = Mono_Posix_SysconfName__SC_THREAD_KEYS_MAX; return 0;}
  7039. #endif /* ndef _SC_THREAD_KEYS_MAX */
  7040. #ifdef _SC_THREAD_PRIORITY_SCHEDULING
  7041. if (x == _SC_THREAD_PRIORITY_SCHEDULING)
  7042. {*r = Mono_Posix_SysconfName__SC_THREAD_PRIORITY_SCHEDULING; return 0;}
  7043. #endif /* ndef _SC_THREAD_PRIORITY_SCHEDULING */
  7044. #ifdef _SC_THREAD_PRIO_INHERIT
  7045. if (x == _SC_THREAD_PRIO_INHERIT)
  7046. {*r = Mono_Posix_SysconfName__SC_THREAD_PRIO_INHERIT; return 0;}
  7047. #endif /* ndef _SC_THREAD_PRIO_INHERIT */
  7048. #ifdef _SC_THREAD_PRIO_PROTECT
  7049. if (x == _SC_THREAD_PRIO_PROTECT)
  7050. {*r = Mono_Posix_SysconfName__SC_THREAD_PRIO_PROTECT; return 0;}
  7051. #endif /* ndef _SC_THREAD_PRIO_PROTECT */
  7052. #ifdef _SC_THREAD_PROCESS_SHARED
  7053. if (x == _SC_THREAD_PROCESS_SHARED)
  7054. {*r = Mono_Posix_SysconfName__SC_THREAD_PROCESS_SHARED; return 0;}
  7055. #endif /* ndef _SC_THREAD_PROCESS_SHARED */
  7056. #ifdef _SC_THREAD_SAFE_FUNCTIONS
  7057. if (x == _SC_THREAD_SAFE_FUNCTIONS)
  7058. {*r = Mono_Posix_SysconfName__SC_THREAD_SAFE_FUNCTIONS; return 0;}
  7059. #endif /* ndef _SC_THREAD_SAFE_FUNCTIONS */
  7060. #ifdef _SC_THREAD_SPORADIC_SERVER
  7061. if (x == _SC_THREAD_SPORADIC_SERVER)
  7062. {*r = Mono_Posix_SysconfName__SC_THREAD_SPORADIC_SERVER; return 0;}
  7063. #endif /* ndef _SC_THREAD_SPORADIC_SERVER */
  7064. #ifdef _SC_THREAD_STACK_MIN
  7065. if (x == _SC_THREAD_STACK_MIN)
  7066. {*r = Mono_Posix_SysconfName__SC_THREAD_STACK_MIN; return 0;}
  7067. #endif /* ndef _SC_THREAD_STACK_MIN */
  7068. #ifdef _SC_THREAD_THREADS_MAX
  7069. if (x == _SC_THREAD_THREADS_MAX)
  7070. {*r = Mono_Posix_SysconfName__SC_THREAD_THREADS_MAX; return 0;}
  7071. #endif /* ndef _SC_THREAD_THREADS_MAX */
  7072. #ifdef _SC_TIMEOUTS
  7073. if (x == _SC_TIMEOUTS)
  7074. {*r = Mono_Posix_SysconfName__SC_TIMEOUTS; return 0;}
  7075. #endif /* ndef _SC_TIMEOUTS */
  7076. #ifdef _SC_TIMERS
  7077. if (x == _SC_TIMERS)
  7078. {*r = Mono_Posix_SysconfName__SC_TIMERS; return 0;}
  7079. #endif /* ndef _SC_TIMERS */
  7080. #ifdef _SC_TIMER_MAX
  7081. if (x == _SC_TIMER_MAX)
  7082. {*r = Mono_Posix_SysconfName__SC_TIMER_MAX; return 0;}
  7083. #endif /* ndef _SC_TIMER_MAX */
  7084. #ifdef _SC_TRACE
  7085. if (x == _SC_TRACE)
  7086. {*r = Mono_Posix_SysconfName__SC_TRACE; return 0;}
  7087. #endif /* ndef _SC_TRACE */
  7088. #ifdef _SC_TRACE_EVENT_FILTER
  7089. if (x == _SC_TRACE_EVENT_FILTER)
  7090. {*r = Mono_Posix_SysconfName__SC_TRACE_EVENT_FILTER; return 0;}
  7091. #endif /* ndef _SC_TRACE_EVENT_FILTER */
  7092. #ifdef _SC_TRACE_INHERIT
  7093. if (x == _SC_TRACE_INHERIT)
  7094. {*r = Mono_Posix_SysconfName__SC_TRACE_INHERIT; return 0;}
  7095. #endif /* ndef _SC_TRACE_INHERIT */
  7096. #ifdef _SC_TRACE_LOG
  7097. if (x == _SC_TRACE_LOG)
  7098. {*r = Mono_Posix_SysconfName__SC_TRACE_LOG; return 0;}
  7099. #endif /* ndef _SC_TRACE_LOG */
  7100. #ifdef _SC_TTY_NAME_MAX
  7101. if (x == _SC_TTY_NAME_MAX)
  7102. {*r = Mono_Posix_SysconfName__SC_TTY_NAME_MAX; return 0;}
  7103. #endif /* ndef _SC_TTY_NAME_MAX */
  7104. #ifdef _SC_TYPED_MEMORY_OBJECTS
  7105. if (x == _SC_TYPED_MEMORY_OBJECTS)
  7106. {*r = Mono_Posix_SysconfName__SC_TYPED_MEMORY_OBJECTS; return 0;}
  7107. #endif /* ndef _SC_TYPED_MEMORY_OBJECTS */
  7108. #ifdef _SC_TZNAME_MAX
  7109. if (x == _SC_TZNAME_MAX)
  7110. {*r = Mono_Posix_SysconfName__SC_TZNAME_MAX; return 0;}
  7111. #endif /* ndef _SC_TZNAME_MAX */
  7112. #ifdef _SC_T_IOV_MAX
  7113. if (x == _SC_T_IOV_MAX)
  7114. {*r = Mono_Posix_SysconfName__SC_T_IOV_MAX; return 0;}
  7115. #endif /* ndef _SC_T_IOV_MAX */
  7116. #ifdef _SC_UCHAR_MAX
  7117. if (x == _SC_UCHAR_MAX)
  7118. {*r = Mono_Posix_SysconfName__SC_UCHAR_MAX; return 0;}
  7119. #endif /* ndef _SC_UCHAR_MAX */
  7120. #ifdef _SC_UINT_MAX
  7121. if (x == _SC_UINT_MAX)
  7122. {*r = Mono_Posix_SysconfName__SC_UINT_MAX; return 0;}
  7123. #endif /* ndef _SC_UINT_MAX */
  7124. #ifdef _SC_UIO_MAXIOV
  7125. if (x == _SC_UIO_MAXIOV)
  7126. {*r = Mono_Posix_SysconfName__SC_UIO_MAXIOV; return 0;}
  7127. #endif /* ndef _SC_UIO_MAXIOV */
  7128. #ifdef _SC_ULONG_MAX
  7129. if (x == _SC_ULONG_MAX)
  7130. {*r = Mono_Posix_SysconfName__SC_ULONG_MAX; return 0;}
  7131. #endif /* ndef _SC_ULONG_MAX */
  7132. #ifdef _SC_USER_GROUPS
  7133. if (x == _SC_USER_GROUPS)
  7134. {*r = Mono_Posix_SysconfName__SC_USER_GROUPS; return 0;}
  7135. #endif /* ndef _SC_USER_GROUPS */
  7136. #ifdef _SC_USER_GROUPS_R
  7137. if (x == _SC_USER_GROUPS_R)
  7138. {*r = Mono_Posix_SysconfName__SC_USER_GROUPS_R; return 0;}
  7139. #endif /* ndef _SC_USER_GROUPS_R */
  7140. #ifdef _SC_USHRT_MAX
  7141. if (x == _SC_USHRT_MAX)
  7142. {*r = Mono_Posix_SysconfName__SC_USHRT_MAX; return 0;}
  7143. #endif /* ndef _SC_USHRT_MAX */
  7144. #ifdef _SC_V6_ILP32_OFF32
  7145. if (x == _SC_V6_ILP32_OFF32)
  7146. {*r = Mono_Posix_SysconfName__SC_V6_ILP32_OFF32; return 0;}
  7147. #endif /* ndef _SC_V6_ILP32_OFF32 */
  7148. #ifdef _SC_V6_ILP32_OFFBIG
  7149. if (x == _SC_V6_ILP32_OFFBIG)
  7150. {*r = Mono_Posix_SysconfName__SC_V6_ILP32_OFFBIG; return 0;}
  7151. #endif /* ndef _SC_V6_ILP32_OFFBIG */
  7152. #ifdef _SC_V6_LP64_OFF64
  7153. if (x == _SC_V6_LP64_OFF64)
  7154. {*r = Mono_Posix_SysconfName__SC_V6_LP64_OFF64; return 0;}
  7155. #endif /* ndef _SC_V6_LP64_OFF64 */
  7156. #ifdef _SC_V6_LPBIG_OFFBIG
  7157. if (x == _SC_V6_LPBIG_OFFBIG)
  7158. {*r = Mono_Posix_SysconfName__SC_V6_LPBIG_OFFBIG; return 0;}
  7159. #endif /* ndef _SC_V6_LPBIG_OFFBIG */
  7160. #ifdef _SC_VERSION
  7161. if (x == _SC_VERSION)
  7162. {*r = Mono_Posix_SysconfName__SC_VERSION; return 0;}
  7163. #endif /* ndef _SC_VERSION */
  7164. #ifdef _SC_WORD_BIT
  7165. if (x == _SC_WORD_BIT)
  7166. {*r = Mono_Posix_SysconfName__SC_WORD_BIT; return 0;}
  7167. #endif /* ndef _SC_WORD_BIT */
  7168. #ifdef _SC_XBS5_ILP32_OFF32
  7169. if (x == _SC_XBS5_ILP32_OFF32)
  7170. {*r = Mono_Posix_SysconfName__SC_XBS5_ILP32_OFF32; return 0;}
  7171. #endif /* ndef _SC_XBS5_ILP32_OFF32 */
  7172. #ifdef _SC_XBS5_ILP32_OFFBIG
  7173. if (x == _SC_XBS5_ILP32_OFFBIG)
  7174. {*r = Mono_Posix_SysconfName__SC_XBS5_ILP32_OFFBIG; return 0;}
  7175. #endif /* ndef _SC_XBS5_ILP32_OFFBIG */
  7176. #ifdef _SC_XBS5_LP64_OFF64
  7177. if (x == _SC_XBS5_LP64_OFF64)
  7178. {*r = Mono_Posix_SysconfName__SC_XBS5_LP64_OFF64; return 0;}
  7179. #endif /* ndef _SC_XBS5_LP64_OFF64 */
  7180. #ifdef _SC_XBS5_LPBIG_OFFBIG
  7181. if (x == _SC_XBS5_LPBIG_OFFBIG)
  7182. {*r = Mono_Posix_SysconfName__SC_XBS5_LPBIG_OFFBIG; return 0;}
  7183. #endif /* ndef _SC_XBS5_LPBIG_OFFBIG */
  7184. #ifdef _SC_XOPEN_CRYPT
  7185. if (x == _SC_XOPEN_CRYPT)
  7186. {*r = Mono_Posix_SysconfName__SC_XOPEN_CRYPT; return 0;}
  7187. #endif /* ndef _SC_XOPEN_CRYPT */
  7188. #ifdef _SC_XOPEN_ENH_I18N
  7189. if (x == _SC_XOPEN_ENH_I18N)
  7190. {*r = Mono_Posix_SysconfName__SC_XOPEN_ENH_I18N; return 0;}
  7191. #endif /* ndef _SC_XOPEN_ENH_I18N */
  7192. #ifdef _SC_XOPEN_LEGACY
  7193. if (x == _SC_XOPEN_LEGACY)
  7194. {*r = Mono_Posix_SysconfName__SC_XOPEN_LEGACY; return 0;}
  7195. #endif /* ndef _SC_XOPEN_LEGACY */
  7196. #ifdef _SC_XOPEN_REALTIME
  7197. if (x == _SC_XOPEN_REALTIME)
  7198. {*r = Mono_Posix_SysconfName__SC_XOPEN_REALTIME; return 0;}
  7199. #endif /* ndef _SC_XOPEN_REALTIME */
  7200. #ifdef _SC_XOPEN_REALTIME_THREADS
  7201. if (x == _SC_XOPEN_REALTIME_THREADS)
  7202. {*r = Mono_Posix_SysconfName__SC_XOPEN_REALTIME_THREADS; return 0;}
  7203. #endif /* ndef _SC_XOPEN_REALTIME_THREADS */
  7204. #ifdef _SC_XOPEN_SHM
  7205. if (x == _SC_XOPEN_SHM)
  7206. {*r = Mono_Posix_SysconfName__SC_XOPEN_SHM; return 0;}
  7207. #endif /* ndef _SC_XOPEN_SHM */
  7208. #ifdef _SC_XOPEN_UNIX
  7209. if (x == _SC_XOPEN_UNIX)
  7210. {*r = Mono_Posix_SysconfName__SC_XOPEN_UNIX; return 0;}
  7211. #endif /* ndef _SC_XOPEN_UNIX */
  7212. #ifdef _SC_XOPEN_VERSION
  7213. if (x == _SC_XOPEN_VERSION)
  7214. {*r = Mono_Posix_SysconfName__SC_XOPEN_VERSION; return 0;}
  7215. #endif /* ndef _SC_XOPEN_VERSION */
  7216. #ifdef _SC_XOPEN_XCU_VERSION
  7217. if (x == _SC_XOPEN_XCU_VERSION)
  7218. {*r = Mono_Posix_SysconfName__SC_XOPEN_XCU_VERSION; return 0;}
  7219. #endif /* ndef _SC_XOPEN_XCU_VERSION */
  7220. #ifdef _SC_XOPEN_XPG2
  7221. if (x == _SC_XOPEN_XPG2)
  7222. {*r = Mono_Posix_SysconfName__SC_XOPEN_XPG2; return 0;}
  7223. #endif /* ndef _SC_XOPEN_XPG2 */
  7224. #ifdef _SC_XOPEN_XPG3
  7225. if (x == _SC_XOPEN_XPG3)
  7226. {*r = Mono_Posix_SysconfName__SC_XOPEN_XPG3; return 0;}
  7227. #endif /* ndef _SC_XOPEN_XPG3 */
  7228. #ifdef _SC_XOPEN_XPG4
  7229. if (x == _SC_XOPEN_XPG4)
  7230. {*r = Mono_Posix_SysconfName__SC_XOPEN_XPG4; return 0;}
  7231. #endif /* ndef _SC_XOPEN_XPG4 */
  7232. errno = EINVAL; return -1;
  7233. }
  7234. int Mono_Posix_FromSyslogFacility (int x, int *r)
  7235. {
  7236. *r = 0;
  7237. if (x == Mono_Posix_SyslogFacility_LOG_AUTH)
  7238. #ifdef LOG_AUTH
  7239. {*r = LOG_AUTH; return 0;}
  7240. #else /* def LOG_AUTH */
  7241. {errno = EINVAL; return -1;}
  7242. #endif /* ndef LOG_AUTH */
  7243. if (x == Mono_Posix_SyslogFacility_LOG_AUTHPRIV)
  7244. #ifdef LOG_AUTHPRIV
  7245. {*r = LOG_AUTHPRIV; return 0;}
  7246. #else /* def LOG_AUTHPRIV */
  7247. {errno = EINVAL; return -1;}
  7248. #endif /* ndef LOG_AUTHPRIV */
  7249. if (x == Mono_Posix_SyslogFacility_LOG_CRON)
  7250. #ifdef LOG_CRON
  7251. {*r = LOG_CRON; return 0;}
  7252. #else /* def LOG_CRON */
  7253. {errno = EINVAL; return -1;}
  7254. #endif /* ndef LOG_CRON */
  7255. if (x == Mono_Posix_SyslogFacility_LOG_DAEMON)
  7256. #ifdef LOG_DAEMON
  7257. {*r = LOG_DAEMON; return 0;}
  7258. #else /* def LOG_DAEMON */
  7259. {errno = EINVAL; return -1;}
  7260. #endif /* ndef LOG_DAEMON */
  7261. if (x == Mono_Posix_SyslogFacility_LOG_FTP)
  7262. #ifdef LOG_FTP
  7263. {*r = LOG_FTP; return 0;}
  7264. #else /* def LOG_FTP */
  7265. {errno = EINVAL; return -1;}
  7266. #endif /* ndef LOG_FTP */
  7267. if (x == Mono_Posix_SyslogFacility_LOG_KERN)
  7268. #ifdef LOG_KERN
  7269. {*r = LOG_KERN; return 0;}
  7270. #else /* def LOG_KERN */
  7271. {errno = EINVAL; return -1;}
  7272. #endif /* ndef LOG_KERN */
  7273. if (x == Mono_Posix_SyslogFacility_LOG_LOCAL0)
  7274. #ifdef LOG_LOCAL0
  7275. {*r = LOG_LOCAL0; return 0;}
  7276. #else /* def LOG_LOCAL0 */
  7277. {errno = EINVAL; return -1;}
  7278. #endif /* ndef LOG_LOCAL0 */
  7279. if (x == Mono_Posix_SyslogFacility_LOG_LOCAL1)
  7280. #ifdef LOG_LOCAL1
  7281. {*r = LOG_LOCAL1; return 0;}
  7282. #else /* def LOG_LOCAL1 */
  7283. {errno = EINVAL; return -1;}
  7284. #endif /* ndef LOG_LOCAL1 */
  7285. if (x == Mono_Posix_SyslogFacility_LOG_LOCAL2)
  7286. #ifdef LOG_LOCAL2
  7287. {*r = LOG_LOCAL2; return 0;}
  7288. #else /* def LOG_LOCAL2 */
  7289. {errno = EINVAL; return -1;}
  7290. #endif /* ndef LOG_LOCAL2 */
  7291. if (x == Mono_Posix_SyslogFacility_LOG_LOCAL3)
  7292. #ifdef LOG_LOCAL3
  7293. {*r = LOG_LOCAL3; return 0;}
  7294. #else /* def LOG_LOCAL3 */
  7295. {errno = EINVAL; return -1;}
  7296. #endif /* ndef LOG_LOCAL3 */
  7297. if (x == Mono_Posix_SyslogFacility_LOG_LOCAL4)
  7298. #ifdef LOG_LOCAL4
  7299. {*r = LOG_LOCAL4; return 0;}
  7300. #else /* def LOG_LOCAL4 */
  7301. {errno = EINVAL; return -1;}
  7302. #endif /* ndef LOG_LOCAL4 */
  7303. if (x == Mono_Posix_SyslogFacility_LOG_LOCAL5)
  7304. #ifdef LOG_LOCAL5
  7305. {*r = LOG_LOCAL5; return 0;}
  7306. #else /* def LOG_LOCAL5 */
  7307. {errno = EINVAL; return -1;}
  7308. #endif /* ndef LOG_LOCAL5 */
  7309. if (x == Mono_Posix_SyslogFacility_LOG_LOCAL6)
  7310. #ifdef LOG_LOCAL6
  7311. {*r = LOG_LOCAL6; return 0;}
  7312. #else /* def LOG_LOCAL6 */
  7313. {errno = EINVAL; return -1;}
  7314. #endif /* ndef LOG_LOCAL6 */
  7315. if (x == Mono_Posix_SyslogFacility_LOG_LOCAL7)
  7316. #ifdef LOG_LOCAL7
  7317. {*r = LOG_LOCAL7; return 0;}
  7318. #else /* def LOG_LOCAL7 */
  7319. {errno = EINVAL; return -1;}
  7320. #endif /* ndef LOG_LOCAL7 */
  7321. if (x == Mono_Posix_SyslogFacility_LOG_LPR)
  7322. #ifdef LOG_LPR
  7323. {*r = LOG_LPR; return 0;}
  7324. #else /* def LOG_LPR */
  7325. {errno = EINVAL; return -1;}
  7326. #endif /* ndef LOG_LPR */
  7327. if (x == Mono_Posix_SyslogFacility_LOG_MAIL)
  7328. #ifdef LOG_MAIL
  7329. {*r = LOG_MAIL; return 0;}
  7330. #else /* def LOG_MAIL */
  7331. {errno = EINVAL; return -1;}
  7332. #endif /* ndef LOG_MAIL */
  7333. if (x == Mono_Posix_SyslogFacility_LOG_NEWS)
  7334. #ifdef LOG_NEWS
  7335. {*r = LOG_NEWS; return 0;}
  7336. #else /* def LOG_NEWS */
  7337. {errno = EINVAL; return -1;}
  7338. #endif /* ndef LOG_NEWS */
  7339. if (x == Mono_Posix_SyslogFacility_LOG_SYSLOG)
  7340. #ifdef LOG_SYSLOG
  7341. {*r = LOG_SYSLOG; return 0;}
  7342. #else /* def LOG_SYSLOG */
  7343. {errno = EINVAL; return -1;}
  7344. #endif /* ndef LOG_SYSLOG */
  7345. if (x == Mono_Posix_SyslogFacility_LOG_USER)
  7346. #ifdef LOG_USER
  7347. {*r = LOG_USER; return 0;}
  7348. #else /* def LOG_USER */
  7349. {errno = EINVAL; return -1;}
  7350. #endif /* ndef LOG_USER */
  7351. if (x == Mono_Posix_SyslogFacility_LOG_UUCP)
  7352. #ifdef LOG_UUCP
  7353. {*r = LOG_UUCP; return 0;}
  7354. #else /* def LOG_UUCP */
  7355. {errno = EINVAL; return -1;}
  7356. #endif /* ndef LOG_UUCP */
  7357. if (x == 0)
  7358. return 0;
  7359. errno = EINVAL; return -1;
  7360. }
  7361. int Mono_Posix_ToSyslogFacility (int x, int *r)
  7362. {
  7363. *r = 0;
  7364. if (x == 0)
  7365. return 0;
  7366. #ifdef LOG_AUTH
  7367. if (x == LOG_AUTH)
  7368. {*r = Mono_Posix_SyslogFacility_LOG_AUTH; return 0;}
  7369. #endif /* ndef LOG_AUTH */
  7370. #ifdef LOG_AUTHPRIV
  7371. if (x == LOG_AUTHPRIV)
  7372. {*r = Mono_Posix_SyslogFacility_LOG_AUTHPRIV; return 0;}
  7373. #endif /* ndef LOG_AUTHPRIV */
  7374. #ifdef LOG_CRON
  7375. if (x == LOG_CRON)
  7376. {*r = Mono_Posix_SyslogFacility_LOG_CRON; return 0;}
  7377. #endif /* ndef LOG_CRON */
  7378. #ifdef LOG_DAEMON
  7379. if (x == LOG_DAEMON)
  7380. {*r = Mono_Posix_SyslogFacility_LOG_DAEMON; return 0;}
  7381. #endif /* ndef LOG_DAEMON */
  7382. #ifdef LOG_FTP
  7383. if (x == LOG_FTP)
  7384. {*r = Mono_Posix_SyslogFacility_LOG_FTP; return 0;}
  7385. #endif /* ndef LOG_FTP */
  7386. #ifdef LOG_KERN
  7387. if (x == LOG_KERN)
  7388. {*r = Mono_Posix_SyslogFacility_LOG_KERN; return 0;}
  7389. #endif /* ndef LOG_KERN */
  7390. #ifdef LOG_LOCAL0
  7391. if (x == LOG_LOCAL0)
  7392. {*r = Mono_Posix_SyslogFacility_LOG_LOCAL0; return 0;}
  7393. #endif /* ndef LOG_LOCAL0 */
  7394. #ifdef LOG_LOCAL1
  7395. if (x == LOG_LOCAL1)
  7396. {*r = Mono_Posix_SyslogFacility_LOG_LOCAL1; return 0;}
  7397. #endif /* ndef LOG_LOCAL1 */
  7398. #ifdef LOG_LOCAL2
  7399. if (x == LOG_LOCAL2)
  7400. {*r = Mono_Posix_SyslogFacility_LOG_LOCAL2; return 0;}
  7401. #endif /* ndef LOG_LOCAL2 */
  7402. #ifdef LOG_LOCAL3
  7403. if (x == LOG_LOCAL3)
  7404. {*r = Mono_Posix_SyslogFacility_LOG_LOCAL3; return 0;}
  7405. #endif /* ndef LOG_LOCAL3 */
  7406. #ifdef LOG_LOCAL4
  7407. if (x == LOG_LOCAL4)
  7408. {*r = Mono_Posix_SyslogFacility_LOG_LOCAL4; return 0;}
  7409. #endif /* ndef LOG_LOCAL4 */
  7410. #ifdef LOG_LOCAL5
  7411. if (x == LOG_LOCAL5)
  7412. {*r = Mono_Posix_SyslogFacility_LOG_LOCAL5; return 0;}
  7413. #endif /* ndef LOG_LOCAL5 */
  7414. #ifdef LOG_LOCAL6
  7415. if (x == LOG_LOCAL6)
  7416. {*r = Mono_Posix_SyslogFacility_LOG_LOCAL6; return 0;}
  7417. #endif /* ndef LOG_LOCAL6 */
  7418. #ifdef LOG_LOCAL7
  7419. if (x == LOG_LOCAL7)
  7420. {*r = Mono_Posix_SyslogFacility_LOG_LOCAL7; return 0;}
  7421. #endif /* ndef LOG_LOCAL7 */
  7422. #ifdef LOG_LPR
  7423. if (x == LOG_LPR)
  7424. {*r = Mono_Posix_SyslogFacility_LOG_LPR; return 0;}
  7425. #endif /* ndef LOG_LPR */
  7426. #ifdef LOG_MAIL
  7427. if (x == LOG_MAIL)
  7428. {*r = Mono_Posix_SyslogFacility_LOG_MAIL; return 0;}
  7429. #endif /* ndef LOG_MAIL */
  7430. #ifdef LOG_NEWS
  7431. if (x == LOG_NEWS)
  7432. {*r = Mono_Posix_SyslogFacility_LOG_NEWS; return 0;}
  7433. #endif /* ndef LOG_NEWS */
  7434. #ifdef LOG_SYSLOG
  7435. if (x == LOG_SYSLOG)
  7436. {*r = Mono_Posix_SyslogFacility_LOG_SYSLOG; return 0;}
  7437. #endif /* ndef LOG_SYSLOG */
  7438. #ifdef LOG_USER
  7439. if (x == LOG_USER)
  7440. {*r = Mono_Posix_SyslogFacility_LOG_USER; return 0;}
  7441. #endif /* ndef LOG_USER */
  7442. #ifdef LOG_UUCP
  7443. if (x == LOG_UUCP)
  7444. {*r = Mono_Posix_SyslogFacility_LOG_UUCP; return 0;}
  7445. #endif /* ndef LOG_UUCP */
  7446. errno = EINVAL; return -1;
  7447. }
  7448. int Mono_Posix_FromSyslogLevel (int x, int *r)
  7449. {
  7450. *r = 0;
  7451. if (x == Mono_Posix_SyslogLevel_LOG_ALERT)
  7452. #ifdef LOG_ALERT
  7453. {*r = LOG_ALERT; return 0;}
  7454. #else /* def LOG_ALERT */
  7455. {errno = EINVAL; return -1;}
  7456. #endif /* ndef LOG_ALERT */
  7457. if (x == Mono_Posix_SyslogLevel_LOG_CRIT)
  7458. #ifdef LOG_CRIT
  7459. {*r = LOG_CRIT; return 0;}
  7460. #else /* def LOG_CRIT */
  7461. {errno = EINVAL; return -1;}
  7462. #endif /* ndef LOG_CRIT */
  7463. if (x == Mono_Posix_SyslogLevel_LOG_DEBUG)
  7464. #ifdef LOG_DEBUG
  7465. {*r = LOG_DEBUG; return 0;}
  7466. #else /* def LOG_DEBUG */
  7467. {errno = EINVAL; return -1;}
  7468. #endif /* ndef LOG_DEBUG */
  7469. if (x == Mono_Posix_SyslogLevel_LOG_EMERG)
  7470. #ifdef LOG_EMERG
  7471. {*r = LOG_EMERG; return 0;}
  7472. #else /* def LOG_EMERG */
  7473. {errno = EINVAL; return -1;}
  7474. #endif /* ndef LOG_EMERG */
  7475. if (x == Mono_Posix_SyslogLevel_LOG_ERR)
  7476. #ifdef LOG_ERR
  7477. {*r = LOG_ERR; return 0;}
  7478. #else /* def LOG_ERR */
  7479. {errno = EINVAL; return -1;}
  7480. #endif /* ndef LOG_ERR */
  7481. if (x == Mono_Posix_SyslogLevel_LOG_INFO)
  7482. #ifdef LOG_INFO
  7483. {*r = LOG_INFO; return 0;}
  7484. #else /* def LOG_INFO */
  7485. {errno = EINVAL; return -1;}
  7486. #endif /* ndef LOG_INFO */
  7487. if (x == Mono_Posix_SyslogLevel_LOG_NOTICE)
  7488. #ifdef LOG_NOTICE
  7489. {*r = LOG_NOTICE; return 0;}
  7490. #else /* def LOG_NOTICE */
  7491. {errno = EINVAL; return -1;}
  7492. #endif /* ndef LOG_NOTICE */
  7493. if (x == Mono_Posix_SyslogLevel_LOG_WARNING)
  7494. #ifdef LOG_WARNING
  7495. {*r = LOG_WARNING; return 0;}
  7496. #else /* def LOG_WARNING */
  7497. {errno = EINVAL; return -1;}
  7498. #endif /* ndef LOG_WARNING */
  7499. if (x == 0)
  7500. return 0;
  7501. errno = EINVAL; return -1;
  7502. }
  7503. int Mono_Posix_ToSyslogLevel (int x, int *r)
  7504. {
  7505. *r = 0;
  7506. if (x == 0)
  7507. return 0;
  7508. #ifdef LOG_ALERT
  7509. if (x == LOG_ALERT)
  7510. {*r = Mono_Posix_SyslogLevel_LOG_ALERT; return 0;}
  7511. #endif /* ndef LOG_ALERT */
  7512. #ifdef LOG_CRIT
  7513. if (x == LOG_CRIT)
  7514. {*r = Mono_Posix_SyslogLevel_LOG_CRIT; return 0;}
  7515. #endif /* ndef LOG_CRIT */
  7516. #ifdef LOG_DEBUG
  7517. if (x == LOG_DEBUG)
  7518. {*r = Mono_Posix_SyslogLevel_LOG_DEBUG; return 0;}
  7519. #endif /* ndef LOG_DEBUG */
  7520. #ifdef LOG_EMERG
  7521. if (x == LOG_EMERG)
  7522. {*r = Mono_Posix_SyslogLevel_LOG_EMERG; return 0;}
  7523. #endif /* ndef LOG_EMERG */
  7524. #ifdef LOG_ERR
  7525. if (x == LOG_ERR)
  7526. {*r = Mono_Posix_SyslogLevel_LOG_ERR; return 0;}
  7527. #endif /* ndef LOG_ERR */
  7528. #ifdef LOG_INFO
  7529. if (x == LOG_INFO)
  7530. {*r = Mono_Posix_SyslogLevel_LOG_INFO; return 0;}
  7531. #endif /* ndef LOG_INFO */
  7532. #ifdef LOG_NOTICE
  7533. if (x == LOG_NOTICE)
  7534. {*r = Mono_Posix_SyslogLevel_LOG_NOTICE; return 0;}
  7535. #endif /* ndef LOG_NOTICE */
  7536. #ifdef LOG_WARNING
  7537. if (x == LOG_WARNING)
  7538. {*r = Mono_Posix_SyslogLevel_LOG_WARNING; return 0;}
  7539. #endif /* ndef LOG_WARNING */
  7540. errno = EINVAL; return -1;
  7541. }
  7542. int Mono_Posix_FromSyslogOptions (int x, int *r)
  7543. {
  7544. *r = 0;
  7545. if ((x & Mono_Posix_SyslogOptions_LOG_CONS) == Mono_Posix_SyslogOptions_LOG_CONS)
  7546. #ifdef LOG_CONS
  7547. *r |= LOG_CONS;
  7548. #else /* def LOG_CONS */
  7549. {errno = EINVAL; return -1;}
  7550. #endif /* ndef LOG_CONS */
  7551. if ((x & Mono_Posix_SyslogOptions_LOG_NDELAY) == Mono_Posix_SyslogOptions_LOG_NDELAY)
  7552. #ifdef LOG_NDELAY
  7553. *r |= LOG_NDELAY;
  7554. #else /* def LOG_NDELAY */
  7555. {errno = EINVAL; return -1;}
  7556. #endif /* ndef LOG_NDELAY */
  7557. if ((x & Mono_Posix_SyslogOptions_LOG_NOWAIT) == Mono_Posix_SyslogOptions_LOG_NOWAIT)
  7558. #ifdef LOG_NOWAIT
  7559. *r |= LOG_NOWAIT;
  7560. #else /* def LOG_NOWAIT */
  7561. {errno = EINVAL; return -1;}
  7562. #endif /* ndef LOG_NOWAIT */
  7563. if ((x & Mono_Posix_SyslogOptions_LOG_ODELAY) == Mono_Posix_SyslogOptions_LOG_ODELAY)
  7564. #ifdef LOG_ODELAY
  7565. *r |= LOG_ODELAY;
  7566. #else /* def LOG_ODELAY */
  7567. {errno = EINVAL; return -1;}
  7568. #endif /* ndef LOG_ODELAY */
  7569. if ((x & Mono_Posix_SyslogOptions_LOG_PERROR) == Mono_Posix_SyslogOptions_LOG_PERROR)
  7570. #ifdef LOG_PERROR
  7571. *r |= LOG_PERROR;
  7572. #else /* def LOG_PERROR */
  7573. {errno = EINVAL; return -1;}
  7574. #endif /* ndef LOG_PERROR */
  7575. if ((x & Mono_Posix_SyslogOptions_LOG_PID) == Mono_Posix_SyslogOptions_LOG_PID)
  7576. #ifdef LOG_PID
  7577. *r |= LOG_PID;
  7578. #else /* def LOG_PID */
  7579. {errno = EINVAL; return -1;}
  7580. #endif /* ndef LOG_PID */
  7581. if (x == 0)
  7582. return 0;
  7583. return 0;
  7584. }
  7585. int Mono_Posix_ToSyslogOptions (int x, int *r)
  7586. {
  7587. *r = 0;
  7588. if (x == 0)
  7589. return 0;
  7590. #ifdef LOG_CONS
  7591. if ((x & LOG_CONS) == LOG_CONS)
  7592. *r |= Mono_Posix_SyslogOptions_LOG_CONS;
  7593. #endif /* ndef LOG_CONS */
  7594. #ifdef LOG_NDELAY
  7595. if ((x & LOG_NDELAY) == LOG_NDELAY)
  7596. *r |= Mono_Posix_SyslogOptions_LOG_NDELAY;
  7597. #endif /* ndef LOG_NDELAY */
  7598. #ifdef LOG_NOWAIT
  7599. if ((x & LOG_NOWAIT) == LOG_NOWAIT)
  7600. *r |= Mono_Posix_SyslogOptions_LOG_NOWAIT;
  7601. #endif /* ndef LOG_NOWAIT */
  7602. #ifdef LOG_ODELAY
  7603. if ((x & LOG_ODELAY) == LOG_ODELAY)
  7604. *r |= Mono_Posix_SyslogOptions_LOG_ODELAY;
  7605. #endif /* ndef LOG_ODELAY */
  7606. #ifdef LOG_PERROR
  7607. if ((x & LOG_PERROR) == LOG_PERROR)
  7608. *r |= Mono_Posix_SyslogOptions_LOG_PERROR;
  7609. #endif /* ndef LOG_PERROR */
  7610. #ifdef LOG_PID
  7611. if ((x & LOG_PID) == LOG_PID)
  7612. *r |= Mono_Posix_SyslogOptions_LOG_PID;
  7613. #endif /* ndef LOG_PID */
  7614. return 0;
  7615. }
  7616. #ifdef HAVE_STRUCT_TIMESPEC
  7617. int
  7618. Mono_Posix_FromTimespec (struct Mono_Posix_Timespec *from, struct timespec *to)
  7619. {
  7620. _cnm_return_val_if_overflow (time_t, from->tv_sec, -1);
  7621. _cnm_return_val_if_overflow (gint64, from->tv_nsec, -1);
  7622. memset (to, 0, sizeof(*to));
  7623. to->tv_sec = from->tv_sec;
  7624. to->tv_nsec = from->tv_nsec;
  7625. return 0;
  7626. }
  7627. #endif /* ndef HAVE_STRUCT_TIMESPEC */
  7628. #ifdef HAVE_STRUCT_TIMESPEC
  7629. int
  7630. Mono_Posix_ToTimespec (struct timespec *from, struct Mono_Posix_Timespec *to)
  7631. {
  7632. _cnm_return_val_if_overflow (gint64, from->tv_sec, -1);
  7633. _cnm_return_val_if_overflow (gint64, from->tv_nsec, -1);
  7634. memset (to, 0, sizeof(*to));
  7635. to->tv_sec = from->tv_sec;
  7636. to->tv_nsec = from->tv_nsec;
  7637. return 0;
  7638. }
  7639. #endif /* ndef HAVE_STRUCT_TIMESPEC */
  7640. #ifdef HAVE_STRUCT_TIMEVAL
  7641. int
  7642. Mono_Posix_FromTimeval (struct Mono_Posix_Timeval *from, struct timeval *to)
  7643. {
  7644. _cnm_return_val_if_overflow (time_t, from->tv_sec, -1);
  7645. _cnm_return_val_if_overflow (suseconds_t, from->tv_usec, -1);
  7646. memset (to, 0, sizeof(*to));
  7647. to->tv_sec = from->tv_sec;
  7648. to->tv_usec = from->tv_usec;
  7649. return 0;
  7650. }
  7651. #endif /* ndef HAVE_STRUCT_TIMEVAL */
  7652. #ifdef HAVE_STRUCT_TIMEVAL
  7653. int
  7654. Mono_Posix_ToTimeval (struct timeval *from, struct Mono_Posix_Timeval *to)
  7655. {
  7656. _cnm_return_val_if_overflow (gint64, from->tv_sec, -1);
  7657. _cnm_return_val_if_overflow (gint64, from->tv_usec, -1);
  7658. memset (to, 0, sizeof(*to));
  7659. to->tv_sec = from->tv_sec;
  7660. to->tv_usec = from->tv_usec;
  7661. return 0;
  7662. }
  7663. #endif /* ndef HAVE_STRUCT_TIMEVAL */
  7664. #ifdef HAVE_STRUCT_TIMEZONE
  7665. int
  7666. Mono_Posix_FromTimezone (struct Mono_Posix_Timezone *from, struct timezone *to)
  7667. {
  7668. _cnm_return_val_if_overflow (int, from->tz_minuteswest, -1);
  7669. _cnm_return_val_if_overflow (int, from->tz_dsttime, -1);
  7670. memset (to, 0, sizeof(*to));
  7671. to->tz_minuteswest = from->tz_minuteswest;
  7672. to->tz_dsttime = from->tz_dsttime;
  7673. return 0;
  7674. }
  7675. #endif /* ndef HAVE_STRUCT_TIMEZONE */
  7676. #ifdef HAVE_STRUCT_TIMEZONE
  7677. int
  7678. Mono_Posix_ToTimezone (struct timezone *from, struct Mono_Posix_Timezone *to)
  7679. {
  7680. _cnm_return_val_if_overflow (int, from->tz_minuteswest, -1);
  7681. _cnm_return_val_if_overflow (int, from->tz_dsttime, -1);
  7682. memset (to, 0, sizeof(*to));
  7683. to->tz_minuteswest = from->tz_minuteswest;
  7684. to->tz_dsttime = from->tz_dsttime;
  7685. return 0;
  7686. }
  7687. #endif /* ndef HAVE_STRUCT_TIMEZONE */
  7688. int Mono_Posix_FromUnixAddressFamily (int x, int *r)
  7689. {
  7690. *r = 0;
  7691. if (x == Mono_Posix_UnixAddressFamily_AF_ALG)
  7692. #ifdef AF_ALG
  7693. {*r = AF_ALG; return 0;}
  7694. #else /* def AF_ALG */
  7695. {errno = EINVAL; return -1;}
  7696. #endif /* ndef AF_ALG */
  7697. if (x == Mono_Posix_UnixAddressFamily_AF_APPLETALK)
  7698. #ifdef AF_APPLETALK
  7699. {*r = AF_APPLETALK; return 0;}
  7700. #else /* def AF_APPLETALK */
  7701. {errno = EINVAL; return -1;}
  7702. #endif /* ndef AF_APPLETALK */
  7703. if (x == Mono_Posix_UnixAddressFamily_AF_ASH)
  7704. #ifdef AF_ASH
  7705. {*r = AF_ASH; return 0;}
  7706. #else /* def AF_ASH */
  7707. {errno = EINVAL; return -1;}
  7708. #endif /* ndef AF_ASH */
  7709. if (x == Mono_Posix_UnixAddressFamily_AF_ATMPVC)
  7710. #ifdef AF_ATMPVC
  7711. {*r = AF_ATMPVC; return 0;}
  7712. #else /* def AF_ATMPVC */
  7713. {errno = EINVAL; return -1;}
  7714. #endif /* ndef AF_ATMPVC */
  7715. if (x == Mono_Posix_UnixAddressFamily_AF_ATMSVC)
  7716. #ifdef AF_ATMSVC
  7717. {*r = AF_ATMSVC; return 0;}
  7718. #else /* def AF_ATMSVC */
  7719. {errno = EINVAL; return -1;}
  7720. #endif /* ndef AF_ATMSVC */
  7721. if (x == Mono_Posix_UnixAddressFamily_AF_AX25)
  7722. #ifdef AF_AX25
  7723. {*r = AF_AX25; return 0;}
  7724. #else /* def AF_AX25 */
  7725. {errno = EINVAL; return -1;}
  7726. #endif /* ndef AF_AX25 */
  7727. if (x == Mono_Posix_UnixAddressFamily_AF_BLUETOOTH)
  7728. #ifdef AF_BLUETOOTH
  7729. {*r = AF_BLUETOOTH; return 0;}
  7730. #else /* def AF_BLUETOOTH */
  7731. {errno = EINVAL; return -1;}
  7732. #endif /* ndef AF_BLUETOOTH */
  7733. if (x == Mono_Posix_UnixAddressFamily_AF_BRIDGE)
  7734. #ifdef AF_BRIDGE
  7735. {*r = AF_BRIDGE; return 0;}
  7736. #else /* def AF_BRIDGE */
  7737. {errno = EINVAL; return -1;}
  7738. #endif /* ndef AF_BRIDGE */
  7739. if (x == Mono_Posix_UnixAddressFamily_AF_CAIF)
  7740. #ifdef AF_CAIF
  7741. {*r = AF_CAIF; return 0;}
  7742. #else /* def AF_CAIF */
  7743. {errno = EINVAL; return -1;}
  7744. #endif /* ndef AF_CAIF */
  7745. if (x == Mono_Posix_UnixAddressFamily_AF_CAN)
  7746. #ifdef AF_CAN
  7747. {*r = AF_CAN; return 0;}
  7748. #else /* def AF_CAN */
  7749. {errno = EINVAL; return -1;}
  7750. #endif /* ndef AF_CAN */
  7751. if (x == Mono_Posix_UnixAddressFamily_AF_DECnet)
  7752. #ifdef AF_DECnet
  7753. {*r = AF_DECnet; return 0;}
  7754. #else /* def AF_DECnet */
  7755. {errno = EINVAL; return -1;}
  7756. #endif /* ndef AF_DECnet */
  7757. if (x == Mono_Posix_UnixAddressFamily_AF_ECONET)
  7758. #ifdef AF_ECONET
  7759. {*r = AF_ECONET; return 0;}
  7760. #else /* def AF_ECONET */
  7761. {errno = EINVAL; return -1;}
  7762. #endif /* ndef AF_ECONET */
  7763. if (x == Mono_Posix_UnixAddressFamily_AF_IEEE802154)
  7764. #ifdef AF_IEEE802154
  7765. {*r = AF_IEEE802154; return 0;}
  7766. #else /* def AF_IEEE802154 */
  7767. {errno = EINVAL; return -1;}
  7768. #endif /* ndef AF_IEEE802154 */
  7769. if (x == Mono_Posix_UnixAddressFamily_AF_INET)
  7770. #ifdef AF_INET
  7771. {*r = AF_INET; return 0;}
  7772. #else /* def AF_INET */
  7773. {errno = EINVAL; return -1;}
  7774. #endif /* ndef AF_INET */
  7775. if (x == Mono_Posix_UnixAddressFamily_AF_INET6)
  7776. #ifdef AF_INET6
  7777. {*r = AF_INET6; return 0;}
  7778. #else /* def AF_INET6 */
  7779. {errno = EINVAL; return -1;}
  7780. #endif /* ndef AF_INET6 */
  7781. if (x == Mono_Posix_UnixAddressFamily_AF_IPX)
  7782. #ifdef AF_IPX
  7783. {*r = AF_IPX; return 0;}
  7784. #else /* def AF_IPX */
  7785. {errno = EINVAL; return -1;}
  7786. #endif /* ndef AF_IPX */
  7787. if (x == Mono_Posix_UnixAddressFamily_AF_IRDA)
  7788. #ifdef AF_IRDA
  7789. {*r = AF_IRDA; return 0;}
  7790. #else /* def AF_IRDA */
  7791. {errno = EINVAL; return -1;}
  7792. #endif /* ndef AF_IRDA */
  7793. if (x == Mono_Posix_UnixAddressFamily_AF_ISDN)
  7794. #ifdef AF_ISDN
  7795. {*r = AF_ISDN; return 0;}
  7796. #else /* def AF_ISDN */
  7797. {errno = EINVAL; return -1;}
  7798. #endif /* ndef AF_ISDN */
  7799. if (x == Mono_Posix_UnixAddressFamily_AF_IUCV)
  7800. #ifdef AF_IUCV
  7801. {*r = AF_IUCV; return 0;}
  7802. #else /* def AF_IUCV */
  7803. {errno = EINVAL; return -1;}
  7804. #endif /* ndef AF_IUCV */
  7805. if (x == Mono_Posix_UnixAddressFamily_AF_KEY)
  7806. #ifdef AF_KEY
  7807. {*r = AF_KEY; return 0;}
  7808. #else /* def AF_KEY */
  7809. {errno = EINVAL; return -1;}
  7810. #endif /* ndef AF_KEY */
  7811. if (x == Mono_Posix_UnixAddressFamily_AF_LLC)
  7812. #ifdef AF_LLC
  7813. {*r = AF_LLC; return 0;}
  7814. #else /* def AF_LLC */
  7815. {errno = EINVAL; return -1;}
  7816. #endif /* ndef AF_LLC */
  7817. if (x == Mono_Posix_UnixAddressFamily_AF_NETBEUI)
  7818. #ifdef AF_NETBEUI
  7819. {*r = AF_NETBEUI; return 0;}
  7820. #else /* def AF_NETBEUI */
  7821. {errno = EINVAL; return -1;}
  7822. #endif /* ndef AF_NETBEUI */
  7823. if (x == Mono_Posix_UnixAddressFamily_AF_NETLINK)
  7824. #ifdef AF_NETLINK
  7825. {*r = AF_NETLINK; return 0;}
  7826. #else /* def AF_NETLINK */
  7827. {errno = EINVAL; return -1;}
  7828. #endif /* ndef AF_NETLINK */
  7829. if (x == Mono_Posix_UnixAddressFamily_AF_NETROM)
  7830. #ifdef AF_NETROM
  7831. {*r = AF_NETROM; return 0;}
  7832. #else /* def AF_NETROM */
  7833. {errno = EINVAL; return -1;}
  7834. #endif /* ndef AF_NETROM */
  7835. if (x == Mono_Posix_UnixAddressFamily_AF_NFC)
  7836. #ifdef AF_NFC
  7837. {*r = AF_NFC; return 0;}
  7838. #else /* def AF_NFC */
  7839. {errno = EINVAL; return -1;}
  7840. #endif /* ndef AF_NFC */
  7841. if (x == Mono_Posix_UnixAddressFamily_AF_PACKET)
  7842. #ifdef AF_PACKET
  7843. {*r = AF_PACKET; return 0;}
  7844. #else /* def AF_PACKET */
  7845. {errno = EINVAL; return -1;}
  7846. #endif /* ndef AF_PACKET */
  7847. if (x == Mono_Posix_UnixAddressFamily_AF_PHONET)
  7848. #ifdef AF_PHONET
  7849. {*r = AF_PHONET; return 0;}
  7850. #else /* def AF_PHONET */
  7851. {errno = EINVAL; return -1;}
  7852. #endif /* ndef AF_PHONET */
  7853. if (x == Mono_Posix_UnixAddressFamily_AF_PPPOX)
  7854. #ifdef AF_PPPOX
  7855. {*r = AF_PPPOX; return 0;}
  7856. #else /* def AF_PPPOX */
  7857. {errno = EINVAL; return -1;}
  7858. #endif /* ndef AF_PPPOX */
  7859. if (x == Mono_Posix_UnixAddressFamily_AF_RDS)
  7860. #ifdef AF_RDS
  7861. {*r = AF_RDS; return 0;}
  7862. #else /* def AF_RDS */
  7863. {errno = EINVAL; return -1;}
  7864. #endif /* ndef AF_RDS */
  7865. if (x == Mono_Posix_UnixAddressFamily_AF_ROSE)
  7866. #ifdef AF_ROSE
  7867. {*r = AF_ROSE; return 0;}
  7868. #else /* def AF_ROSE */
  7869. {errno = EINVAL; return -1;}
  7870. #endif /* ndef AF_ROSE */
  7871. if (x == Mono_Posix_UnixAddressFamily_AF_RXRPC)
  7872. #ifdef AF_RXRPC
  7873. {*r = AF_RXRPC; return 0;}
  7874. #else /* def AF_RXRPC */
  7875. {errno = EINVAL; return -1;}
  7876. #endif /* ndef AF_RXRPC */
  7877. if (x == Mono_Posix_UnixAddressFamily_AF_SECURITY)
  7878. #ifdef AF_SECURITY
  7879. {*r = AF_SECURITY; return 0;}
  7880. #else /* def AF_SECURITY */
  7881. {errno = EINVAL; return -1;}
  7882. #endif /* ndef AF_SECURITY */
  7883. if (x == Mono_Posix_UnixAddressFamily_AF_SNA)
  7884. #ifdef AF_SNA
  7885. {*r = AF_SNA; return 0;}
  7886. #else /* def AF_SNA */
  7887. {errno = EINVAL; return -1;}
  7888. #endif /* ndef AF_SNA */
  7889. if (x == Mono_Posix_UnixAddressFamily_AF_TIPC)
  7890. #ifdef AF_TIPC
  7891. {*r = AF_TIPC; return 0;}
  7892. #else /* def AF_TIPC */
  7893. {errno = EINVAL; return -1;}
  7894. #endif /* ndef AF_TIPC */
  7895. if (x == Mono_Posix_UnixAddressFamily_AF_UNIX)
  7896. #ifdef AF_UNIX
  7897. {*r = AF_UNIX; return 0;}
  7898. #else /* def AF_UNIX */
  7899. {errno = EINVAL; return -1;}
  7900. #endif /* ndef AF_UNIX */
  7901. if (x == Mono_Posix_UnixAddressFamily_AF_UNSPEC)
  7902. #ifdef AF_UNSPEC
  7903. {*r = AF_UNSPEC; return 0;}
  7904. #else /* def AF_UNSPEC */
  7905. {errno = EINVAL; return -1;}
  7906. #endif /* ndef AF_UNSPEC */
  7907. if (x == Mono_Posix_UnixAddressFamily_AF_VSOCK)
  7908. #ifdef AF_VSOCK
  7909. {*r = AF_VSOCK; return 0;}
  7910. #else /* def AF_VSOCK */
  7911. {errno = EINVAL; return -1;}
  7912. #endif /* ndef AF_VSOCK */
  7913. if (x == Mono_Posix_UnixAddressFamily_AF_WANPIPE)
  7914. #ifdef AF_WANPIPE
  7915. {*r = AF_WANPIPE; return 0;}
  7916. #else /* def AF_WANPIPE */
  7917. {errno = EINVAL; return -1;}
  7918. #endif /* ndef AF_WANPIPE */
  7919. if (x == Mono_Posix_UnixAddressFamily_AF_X25)
  7920. #ifdef AF_X25
  7921. {*r = AF_X25; return 0;}
  7922. #else /* def AF_X25 */
  7923. {errno = EINVAL; return -1;}
  7924. #endif /* ndef AF_X25 */
  7925. if (x == Mono_Posix_UnixAddressFamily_Unknown)
  7926. #ifdef Unknown
  7927. {*r = Unknown; return 0;}
  7928. #else /* def Unknown */
  7929. {errno = EINVAL; return -1;}
  7930. #endif /* ndef Unknown */
  7931. if (x == 0)
  7932. return 0;
  7933. errno = EINVAL; return -1;
  7934. }
  7935. int Mono_Posix_ToUnixAddressFamily (int x, int *r)
  7936. {
  7937. *r = 0;
  7938. if (x == 0)
  7939. return 0;
  7940. #ifdef AF_ALG
  7941. if (x == AF_ALG)
  7942. {*r = Mono_Posix_UnixAddressFamily_AF_ALG; return 0;}
  7943. #endif /* ndef AF_ALG */
  7944. #ifdef AF_APPLETALK
  7945. if (x == AF_APPLETALK)
  7946. {*r = Mono_Posix_UnixAddressFamily_AF_APPLETALK; return 0;}
  7947. #endif /* ndef AF_APPLETALK */
  7948. #ifdef AF_ASH
  7949. if (x == AF_ASH)
  7950. {*r = Mono_Posix_UnixAddressFamily_AF_ASH; return 0;}
  7951. #endif /* ndef AF_ASH */
  7952. #ifdef AF_ATMPVC
  7953. if (x == AF_ATMPVC)
  7954. {*r = Mono_Posix_UnixAddressFamily_AF_ATMPVC; return 0;}
  7955. #endif /* ndef AF_ATMPVC */
  7956. #ifdef AF_ATMSVC
  7957. if (x == AF_ATMSVC)
  7958. {*r = Mono_Posix_UnixAddressFamily_AF_ATMSVC; return 0;}
  7959. #endif /* ndef AF_ATMSVC */
  7960. #ifdef AF_AX25
  7961. if (x == AF_AX25)
  7962. {*r = Mono_Posix_UnixAddressFamily_AF_AX25; return 0;}
  7963. #endif /* ndef AF_AX25 */
  7964. #ifdef AF_BLUETOOTH
  7965. if (x == AF_BLUETOOTH)
  7966. {*r = Mono_Posix_UnixAddressFamily_AF_BLUETOOTH; return 0;}
  7967. #endif /* ndef AF_BLUETOOTH */
  7968. #ifdef AF_BRIDGE
  7969. if (x == AF_BRIDGE)
  7970. {*r = Mono_Posix_UnixAddressFamily_AF_BRIDGE; return 0;}
  7971. #endif /* ndef AF_BRIDGE */
  7972. #ifdef AF_CAIF
  7973. if (x == AF_CAIF)
  7974. {*r = Mono_Posix_UnixAddressFamily_AF_CAIF; return 0;}
  7975. #endif /* ndef AF_CAIF */
  7976. #ifdef AF_CAN
  7977. if (x == AF_CAN)
  7978. {*r = Mono_Posix_UnixAddressFamily_AF_CAN; return 0;}
  7979. #endif /* ndef AF_CAN */
  7980. #ifdef AF_DECnet
  7981. if (x == AF_DECnet)
  7982. {*r = Mono_Posix_UnixAddressFamily_AF_DECnet; return 0;}
  7983. #endif /* ndef AF_DECnet */
  7984. #ifdef AF_ECONET
  7985. if (x == AF_ECONET)
  7986. {*r = Mono_Posix_UnixAddressFamily_AF_ECONET; return 0;}
  7987. #endif /* ndef AF_ECONET */
  7988. #ifdef AF_IEEE802154
  7989. if (x == AF_IEEE802154)
  7990. {*r = Mono_Posix_UnixAddressFamily_AF_IEEE802154; return 0;}
  7991. #endif /* ndef AF_IEEE802154 */
  7992. #ifdef AF_INET
  7993. if (x == AF_INET)
  7994. {*r = Mono_Posix_UnixAddressFamily_AF_INET; return 0;}
  7995. #endif /* ndef AF_INET */
  7996. #ifdef AF_INET6
  7997. if (x == AF_INET6)
  7998. {*r = Mono_Posix_UnixAddressFamily_AF_INET6; return 0;}
  7999. #endif /* ndef AF_INET6 */
  8000. #ifdef AF_IPX
  8001. if (x == AF_IPX)
  8002. {*r = Mono_Posix_UnixAddressFamily_AF_IPX; return 0;}
  8003. #endif /* ndef AF_IPX */
  8004. #ifdef AF_IRDA
  8005. if (x == AF_IRDA)
  8006. {*r = Mono_Posix_UnixAddressFamily_AF_IRDA; return 0;}
  8007. #endif /* ndef AF_IRDA */
  8008. #ifdef AF_ISDN
  8009. if (x == AF_ISDN)
  8010. {*r = Mono_Posix_UnixAddressFamily_AF_ISDN; return 0;}
  8011. #endif /* ndef AF_ISDN */
  8012. #ifdef AF_IUCV
  8013. if (x == AF_IUCV)
  8014. {*r = Mono_Posix_UnixAddressFamily_AF_IUCV; return 0;}
  8015. #endif /* ndef AF_IUCV */
  8016. #ifdef AF_KEY
  8017. if (x == AF_KEY)
  8018. {*r = Mono_Posix_UnixAddressFamily_AF_KEY; return 0;}
  8019. #endif /* ndef AF_KEY */
  8020. #ifdef AF_LLC
  8021. if (x == AF_LLC)
  8022. {*r = Mono_Posix_UnixAddressFamily_AF_LLC; return 0;}
  8023. #endif /* ndef AF_LLC */
  8024. #ifdef AF_NETBEUI
  8025. if (x == AF_NETBEUI)
  8026. {*r = Mono_Posix_UnixAddressFamily_AF_NETBEUI; return 0;}
  8027. #endif /* ndef AF_NETBEUI */
  8028. #ifdef AF_NETLINK
  8029. if (x == AF_NETLINK)
  8030. {*r = Mono_Posix_UnixAddressFamily_AF_NETLINK; return 0;}
  8031. #endif /* ndef AF_NETLINK */
  8032. #ifdef AF_NETROM
  8033. if (x == AF_NETROM)
  8034. {*r = Mono_Posix_UnixAddressFamily_AF_NETROM; return 0;}
  8035. #endif /* ndef AF_NETROM */
  8036. #ifdef AF_NFC
  8037. if (x == AF_NFC)
  8038. {*r = Mono_Posix_UnixAddressFamily_AF_NFC; return 0;}
  8039. #endif /* ndef AF_NFC */
  8040. #ifdef AF_PACKET
  8041. if (x == AF_PACKET)
  8042. {*r = Mono_Posix_UnixAddressFamily_AF_PACKET; return 0;}
  8043. #endif /* ndef AF_PACKET */
  8044. #ifdef AF_PHONET
  8045. if (x == AF_PHONET)
  8046. {*r = Mono_Posix_UnixAddressFamily_AF_PHONET; return 0;}
  8047. #endif /* ndef AF_PHONET */
  8048. #ifdef AF_PPPOX
  8049. if (x == AF_PPPOX)
  8050. {*r = Mono_Posix_UnixAddressFamily_AF_PPPOX; return 0;}
  8051. #endif /* ndef AF_PPPOX */
  8052. #ifdef AF_RDS
  8053. if (x == AF_RDS)
  8054. {*r = Mono_Posix_UnixAddressFamily_AF_RDS; return 0;}
  8055. #endif /* ndef AF_RDS */
  8056. #ifdef AF_ROSE
  8057. if (x == AF_ROSE)
  8058. {*r = Mono_Posix_UnixAddressFamily_AF_ROSE; return 0;}
  8059. #endif /* ndef AF_ROSE */
  8060. #ifdef AF_RXRPC
  8061. if (x == AF_RXRPC)
  8062. {*r = Mono_Posix_UnixAddressFamily_AF_RXRPC; return 0;}
  8063. #endif /* ndef AF_RXRPC */
  8064. #ifdef AF_SECURITY
  8065. if (x == AF_SECURITY)
  8066. {*r = Mono_Posix_UnixAddressFamily_AF_SECURITY; return 0;}
  8067. #endif /* ndef AF_SECURITY */
  8068. #ifdef AF_SNA
  8069. if (x == AF_SNA)
  8070. {*r = Mono_Posix_UnixAddressFamily_AF_SNA; return 0;}
  8071. #endif /* ndef AF_SNA */
  8072. #ifdef AF_TIPC
  8073. if (x == AF_TIPC)
  8074. {*r = Mono_Posix_UnixAddressFamily_AF_TIPC; return 0;}
  8075. #endif /* ndef AF_TIPC */
  8076. #ifdef AF_UNIX
  8077. if (x == AF_UNIX)
  8078. {*r = Mono_Posix_UnixAddressFamily_AF_UNIX; return 0;}
  8079. #endif /* ndef AF_UNIX */
  8080. #ifdef AF_UNSPEC
  8081. if (x == AF_UNSPEC)
  8082. {*r = Mono_Posix_UnixAddressFamily_AF_UNSPEC; return 0;}
  8083. #endif /* ndef AF_UNSPEC */
  8084. #ifdef AF_VSOCK
  8085. if (x == AF_VSOCK)
  8086. {*r = Mono_Posix_UnixAddressFamily_AF_VSOCK; return 0;}
  8087. #endif /* ndef AF_VSOCK */
  8088. #ifdef AF_WANPIPE
  8089. if (x == AF_WANPIPE)
  8090. {*r = Mono_Posix_UnixAddressFamily_AF_WANPIPE; return 0;}
  8091. #endif /* ndef AF_WANPIPE */
  8092. #ifdef AF_X25
  8093. if (x == AF_X25)
  8094. {*r = Mono_Posix_UnixAddressFamily_AF_X25; return 0;}
  8095. #endif /* ndef AF_X25 */
  8096. #ifdef Unknown
  8097. if (x == Unknown)
  8098. {*r = Mono_Posix_UnixAddressFamily_Unknown; return 0;}
  8099. #endif /* ndef Unknown */
  8100. errno = EINVAL; return -1;
  8101. }
  8102. int Mono_Posix_FromUnixSocketControlMessage (int x, int *r)
  8103. {
  8104. *r = 0;
  8105. if (x == Mono_Posix_UnixSocketControlMessage_SCM_CREDENTIALS)
  8106. #ifdef SCM_CREDENTIALS
  8107. {*r = SCM_CREDENTIALS; return 0;}
  8108. #else /* def SCM_CREDENTIALS */
  8109. {errno = EINVAL; return -1;}
  8110. #endif /* ndef SCM_CREDENTIALS */
  8111. if (x == Mono_Posix_UnixSocketControlMessage_SCM_RIGHTS)
  8112. #ifdef SCM_RIGHTS
  8113. {*r = SCM_RIGHTS; return 0;}
  8114. #else /* def SCM_RIGHTS */
  8115. {errno = EINVAL; return -1;}
  8116. #endif /* ndef SCM_RIGHTS */
  8117. if (x == 0)
  8118. return 0;
  8119. errno = EINVAL; return -1;
  8120. }
  8121. int Mono_Posix_ToUnixSocketControlMessage (int x, int *r)
  8122. {
  8123. *r = 0;
  8124. if (x == 0)
  8125. return 0;
  8126. #ifdef SCM_CREDENTIALS
  8127. if (x == SCM_CREDENTIALS)
  8128. {*r = Mono_Posix_UnixSocketControlMessage_SCM_CREDENTIALS; return 0;}
  8129. #endif /* ndef SCM_CREDENTIALS */
  8130. #ifdef SCM_RIGHTS
  8131. if (x == SCM_RIGHTS)
  8132. {*r = Mono_Posix_UnixSocketControlMessage_SCM_RIGHTS; return 0;}
  8133. #endif /* ndef SCM_RIGHTS */
  8134. errno = EINVAL; return -1;
  8135. }
  8136. int Mono_Posix_FromUnixSocketFlags (int x, int *r)
  8137. {
  8138. *r = 0;
  8139. if ((x & Mono_Posix_UnixSocketFlags_SOCK_CLOEXEC) == Mono_Posix_UnixSocketFlags_SOCK_CLOEXEC)
  8140. #ifdef SOCK_CLOEXEC
  8141. *r |= SOCK_CLOEXEC;
  8142. #else /* def SOCK_CLOEXEC */
  8143. {errno = EINVAL; return -1;}
  8144. #endif /* ndef SOCK_CLOEXEC */
  8145. if ((x & Mono_Posix_UnixSocketFlags_SOCK_NONBLOCK) == Mono_Posix_UnixSocketFlags_SOCK_NONBLOCK)
  8146. #ifdef SOCK_NONBLOCK
  8147. *r |= SOCK_NONBLOCK;
  8148. #else /* def SOCK_NONBLOCK */
  8149. {errno = EINVAL; return -1;}
  8150. #endif /* ndef SOCK_NONBLOCK */
  8151. if (x == 0)
  8152. return 0;
  8153. return 0;
  8154. }
  8155. int Mono_Posix_ToUnixSocketFlags (int x, int *r)
  8156. {
  8157. *r = 0;
  8158. if (x == 0)
  8159. return 0;
  8160. #ifdef SOCK_CLOEXEC
  8161. if ((x & SOCK_CLOEXEC) == SOCK_CLOEXEC)
  8162. *r |= Mono_Posix_UnixSocketFlags_SOCK_CLOEXEC;
  8163. #endif /* ndef SOCK_CLOEXEC */
  8164. #ifdef SOCK_NONBLOCK
  8165. if ((x & SOCK_NONBLOCK) == SOCK_NONBLOCK)
  8166. *r |= Mono_Posix_UnixSocketFlags_SOCK_NONBLOCK;
  8167. #endif /* ndef SOCK_NONBLOCK */
  8168. return 0;
  8169. }
  8170. int Mono_Posix_FromUnixSocketOptionName (int x, int *r)
  8171. {
  8172. *r = 0;
  8173. if (x == Mono_Posix_UnixSocketOptionName_SO_ACCEPTCONN)
  8174. #ifdef SO_ACCEPTCONN
  8175. {*r = SO_ACCEPTCONN; return 0;}
  8176. #else /* def SO_ACCEPTCONN */
  8177. {errno = EINVAL; return -1;}
  8178. #endif /* ndef SO_ACCEPTCONN */
  8179. if (x == Mono_Posix_UnixSocketOptionName_SO_ATTACH_FILTER)
  8180. #ifdef SO_ATTACH_FILTER
  8181. {*r = SO_ATTACH_FILTER; return 0;}
  8182. #else /* def SO_ATTACH_FILTER */
  8183. {errno = EINVAL; return -1;}
  8184. #endif /* ndef SO_ATTACH_FILTER */
  8185. if (x == Mono_Posix_UnixSocketOptionName_SO_BINDTODEVICE)
  8186. #ifdef SO_BINDTODEVICE
  8187. {*r = SO_BINDTODEVICE; return 0;}
  8188. #else /* def SO_BINDTODEVICE */
  8189. {errno = EINVAL; return -1;}
  8190. #endif /* ndef SO_BINDTODEVICE */
  8191. if (x == Mono_Posix_UnixSocketOptionName_SO_BROADCAST)
  8192. #ifdef SO_BROADCAST
  8193. {*r = SO_BROADCAST; return 0;}
  8194. #else /* def SO_BROADCAST */
  8195. {errno = EINVAL; return -1;}
  8196. #endif /* ndef SO_BROADCAST */
  8197. if (x == Mono_Posix_UnixSocketOptionName_SO_BSDCOMPAT)
  8198. #ifdef SO_BSDCOMPAT
  8199. {*r = SO_BSDCOMPAT; return 0;}
  8200. #else /* def SO_BSDCOMPAT */
  8201. {errno = EINVAL; return -1;}
  8202. #endif /* ndef SO_BSDCOMPAT */
  8203. if (x == Mono_Posix_UnixSocketOptionName_SO_BUSY_POLL)
  8204. #ifdef SO_BUSY_POLL
  8205. {*r = SO_BUSY_POLL; return 0;}
  8206. #else /* def SO_BUSY_POLL */
  8207. {errno = EINVAL; return -1;}
  8208. #endif /* ndef SO_BUSY_POLL */
  8209. if (x == Mono_Posix_UnixSocketOptionName_SO_DEBUG)
  8210. #ifdef SO_DEBUG
  8211. {*r = SO_DEBUG; return 0;}
  8212. #else /* def SO_DEBUG */
  8213. {errno = EINVAL; return -1;}
  8214. #endif /* ndef SO_DEBUG */
  8215. if (x == Mono_Posix_UnixSocketOptionName_SO_DETACH_FILTER)
  8216. #ifdef SO_DETACH_FILTER
  8217. {*r = SO_DETACH_FILTER; return 0;}
  8218. #else /* def SO_DETACH_FILTER */
  8219. {errno = EINVAL; return -1;}
  8220. #endif /* ndef SO_DETACH_FILTER */
  8221. if (x == Mono_Posix_UnixSocketOptionName_SO_DOMAIN)
  8222. #ifdef SO_DOMAIN
  8223. {*r = SO_DOMAIN; return 0;}
  8224. #else /* def SO_DOMAIN */
  8225. {errno = EINVAL; return -1;}
  8226. #endif /* ndef SO_DOMAIN */
  8227. if (x == Mono_Posix_UnixSocketOptionName_SO_DONTROUTE)
  8228. #ifdef SO_DONTROUTE
  8229. {*r = SO_DONTROUTE; return 0;}
  8230. #else /* def SO_DONTROUTE */
  8231. {errno = EINVAL; return -1;}
  8232. #endif /* ndef SO_DONTROUTE */
  8233. if (x == Mono_Posix_UnixSocketOptionName_SO_ERROR)
  8234. #ifdef SO_ERROR
  8235. {*r = SO_ERROR; return 0;}
  8236. #else /* def SO_ERROR */
  8237. {errno = EINVAL; return -1;}
  8238. #endif /* ndef SO_ERROR */
  8239. if (x == Mono_Posix_UnixSocketOptionName_SO_KEEPALIVE)
  8240. #ifdef SO_KEEPALIVE
  8241. {*r = SO_KEEPALIVE; return 0;}
  8242. #else /* def SO_KEEPALIVE */
  8243. {errno = EINVAL; return -1;}
  8244. #endif /* ndef SO_KEEPALIVE */
  8245. if (x == Mono_Posix_UnixSocketOptionName_SO_LINGER)
  8246. #ifdef SO_LINGER
  8247. {*r = SO_LINGER; return 0;}
  8248. #else /* def SO_LINGER */
  8249. {errno = EINVAL; return -1;}
  8250. #endif /* ndef SO_LINGER */
  8251. if (x == Mono_Posix_UnixSocketOptionName_SO_LOCK_FILTER)
  8252. #ifdef SO_LOCK_FILTER
  8253. {*r = SO_LOCK_FILTER; return 0;}
  8254. #else /* def SO_LOCK_FILTER */
  8255. {errno = EINVAL; return -1;}
  8256. #endif /* ndef SO_LOCK_FILTER */
  8257. if (x == Mono_Posix_UnixSocketOptionName_SO_MARK)
  8258. #ifdef SO_MARK
  8259. {*r = SO_MARK; return 0;}
  8260. #else /* def SO_MARK */
  8261. {errno = EINVAL; return -1;}
  8262. #endif /* ndef SO_MARK */
  8263. if (x == Mono_Posix_UnixSocketOptionName_SO_MAX_PACING_RATE)
  8264. #ifdef SO_MAX_PACING_RATE
  8265. {*r = SO_MAX_PACING_RATE; return 0;}
  8266. #else /* def SO_MAX_PACING_RATE */
  8267. {errno = EINVAL; return -1;}
  8268. #endif /* ndef SO_MAX_PACING_RATE */
  8269. if (x == Mono_Posix_UnixSocketOptionName_SO_NOFCS)
  8270. #ifdef SO_NOFCS
  8271. {*r = SO_NOFCS; return 0;}
  8272. #else /* def SO_NOFCS */
  8273. {errno = EINVAL; return -1;}
  8274. #endif /* ndef SO_NOFCS */
  8275. if (x == Mono_Posix_UnixSocketOptionName_SO_NO_CHECK)
  8276. #ifdef SO_NO_CHECK
  8277. {*r = SO_NO_CHECK; return 0;}
  8278. #else /* def SO_NO_CHECK */
  8279. {errno = EINVAL; return -1;}
  8280. #endif /* ndef SO_NO_CHECK */
  8281. if (x == Mono_Posix_UnixSocketOptionName_SO_OOBINLINE)
  8282. #ifdef SO_OOBINLINE
  8283. {*r = SO_OOBINLINE; return 0;}
  8284. #else /* def SO_OOBINLINE */
  8285. {errno = EINVAL; return -1;}
  8286. #endif /* ndef SO_OOBINLINE */
  8287. if (x == Mono_Posix_UnixSocketOptionName_SO_PASSCRED)
  8288. #ifdef SO_PASSCRED
  8289. {*r = SO_PASSCRED; return 0;}
  8290. #else /* def SO_PASSCRED */
  8291. {errno = EINVAL; return -1;}
  8292. #endif /* ndef SO_PASSCRED */
  8293. if (x == Mono_Posix_UnixSocketOptionName_SO_PASSSEC)
  8294. #ifdef SO_PASSSEC
  8295. {*r = SO_PASSSEC; return 0;}
  8296. #else /* def SO_PASSSEC */
  8297. {errno = EINVAL; return -1;}
  8298. #endif /* ndef SO_PASSSEC */
  8299. if (x == Mono_Posix_UnixSocketOptionName_SO_PEEK_OFF)
  8300. #ifdef SO_PEEK_OFF
  8301. {*r = SO_PEEK_OFF; return 0;}
  8302. #else /* def SO_PEEK_OFF */
  8303. {errno = EINVAL; return -1;}
  8304. #endif /* ndef SO_PEEK_OFF */
  8305. if (x == Mono_Posix_UnixSocketOptionName_SO_PEERCRED)
  8306. #ifdef SO_PEERCRED
  8307. {*r = SO_PEERCRED; return 0;}
  8308. #else /* def SO_PEERCRED */
  8309. {errno = EINVAL; return -1;}
  8310. #endif /* ndef SO_PEERCRED */
  8311. if (x == Mono_Posix_UnixSocketOptionName_SO_PEERNAME)
  8312. #ifdef SO_PEERNAME
  8313. {*r = SO_PEERNAME; return 0;}
  8314. #else /* def SO_PEERNAME */
  8315. {errno = EINVAL; return -1;}
  8316. #endif /* ndef SO_PEERNAME */
  8317. if (x == Mono_Posix_UnixSocketOptionName_SO_PEERSEC)
  8318. #ifdef SO_PEERSEC
  8319. {*r = SO_PEERSEC; return 0;}
  8320. #else /* def SO_PEERSEC */
  8321. {errno = EINVAL; return -1;}
  8322. #endif /* ndef SO_PEERSEC */
  8323. if (x == Mono_Posix_UnixSocketOptionName_SO_PRIORITY)
  8324. #ifdef SO_PRIORITY
  8325. {*r = SO_PRIORITY; return 0;}
  8326. #else /* def SO_PRIORITY */
  8327. {errno = EINVAL; return -1;}
  8328. #endif /* ndef SO_PRIORITY */
  8329. if (x == Mono_Posix_UnixSocketOptionName_SO_PROTOCOL)
  8330. #ifdef SO_PROTOCOL
  8331. {*r = SO_PROTOCOL; return 0;}
  8332. #else /* def SO_PROTOCOL */
  8333. {errno = EINVAL; return -1;}
  8334. #endif /* ndef SO_PROTOCOL */
  8335. if (x == Mono_Posix_UnixSocketOptionName_SO_RCVBUF)
  8336. #ifdef SO_RCVBUF
  8337. {*r = SO_RCVBUF; return 0;}
  8338. #else /* def SO_RCVBUF */
  8339. {errno = EINVAL; return -1;}
  8340. #endif /* ndef SO_RCVBUF */
  8341. if (x == Mono_Posix_UnixSocketOptionName_SO_RCVBUFFORCE)
  8342. #ifdef SO_RCVBUFFORCE
  8343. {*r = SO_RCVBUFFORCE; return 0;}
  8344. #else /* def SO_RCVBUFFORCE */
  8345. {errno = EINVAL; return -1;}
  8346. #endif /* ndef SO_RCVBUFFORCE */
  8347. if (x == Mono_Posix_UnixSocketOptionName_SO_RCVLOWAT)
  8348. #ifdef SO_RCVLOWAT
  8349. {*r = SO_RCVLOWAT; return 0;}
  8350. #else /* def SO_RCVLOWAT */
  8351. {errno = EINVAL; return -1;}
  8352. #endif /* ndef SO_RCVLOWAT */
  8353. if (x == Mono_Posix_UnixSocketOptionName_SO_RCVTIMEO)
  8354. #ifdef SO_RCVTIMEO
  8355. {*r = SO_RCVTIMEO; return 0;}
  8356. #else /* def SO_RCVTIMEO */
  8357. {errno = EINVAL; return -1;}
  8358. #endif /* ndef SO_RCVTIMEO */
  8359. if (x == Mono_Posix_UnixSocketOptionName_SO_REUSEADDR)
  8360. #ifdef SO_REUSEADDR
  8361. {*r = SO_REUSEADDR; return 0;}
  8362. #else /* def SO_REUSEADDR */
  8363. {errno = EINVAL; return -1;}
  8364. #endif /* ndef SO_REUSEADDR */
  8365. if (x == Mono_Posix_UnixSocketOptionName_SO_REUSEPORT)
  8366. #ifdef SO_REUSEPORT
  8367. {*r = SO_REUSEPORT; return 0;}
  8368. #else /* def SO_REUSEPORT */
  8369. {errno = EINVAL; return -1;}
  8370. #endif /* ndef SO_REUSEPORT */
  8371. if (x == Mono_Posix_UnixSocketOptionName_SO_RXQ_OVFL)
  8372. #ifdef SO_RXQ_OVFL
  8373. {*r = SO_RXQ_OVFL; return 0;}
  8374. #else /* def SO_RXQ_OVFL */
  8375. {errno = EINVAL; return -1;}
  8376. #endif /* ndef SO_RXQ_OVFL */
  8377. if (x == Mono_Posix_UnixSocketOptionName_SO_SECURITY_AUTHENTICATION)
  8378. #ifdef SO_SECURITY_AUTHENTICATION
  8379. {*r = SO_SECURITY_AUTHENTICATION; return 0;}
  8380. #else /* def SO_SECURITY_AUTHENTICATION */
  8381. {errno = EINVAL; return -1;}
  8382. #endif /* ndef SO_SECURITY_AUTHENTICATION */
  8383. if (x == Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_NETWORK)
  8384. #ifdef SO_SECURITY_ENCRYPTION_NETWORK
  8385. {*r = SO_SECURITY_ENCRYPTION_NETWORK; return 0;}
  8386. #else /* def SO_SECURITY_ENCRYPTION_NETWORK */
  8387. {errno = EINVAL; return -1;}
  8388. #endif /* ndef SO_SECURITY_ENCRYPTION_NETWORK */
  8389. if (x == Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_TRANSPORT)
  8390. #ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
  8391. {*r = SO_SECURITY_ENCRYPTION_TRANSPORT; return 0;}
  8392. #else /* def SO_SECURITY_ENCRYPTION_TRANSPORT */
  8393. {errno = EINVAL; return -1;}
  8394. #endif /* ndef SO_SECURITY_ENCRYPTION_TRANSPORT */
  8395. if (x == Mono_Posix_UnixSocketOptionName_SO_SELECT_ERR_QUEUE)
  8396. #ifdef SO_SELECT_ERR_QUEUE
  8397. {*r = SO_SELECT_ERR_QUEUE; return 0;}
  8398. #else /* def SO_SELECT_ERR_QUEUE */
  8399. {errno = EINVAL; return -1;}
  8400. #endif /* ndef SO_SELECT_ERR_QUEUE */
  8401. if (x == Mono_Posix_UnixSocketOptionName_SO_SNDBUF)
  8402. #ifdef SO_SNDBUF
  8403. {*r = SO_SNDBUF; return 0;}
  8404. #else /* def SO_SNDBUF */
  8405. {errno = EINVAL; return -1;}
  8406. #endif /* ndef SO_SNDBUF */
  8407. if (x == Mono_Posix_UnixSocketOptionName_SO_SNDBUFFORCE)
  8408. #ifdef SO_SNDBUFFORCE
  8409. {*r = SO_SNDBUFFORCE; return 0;}
  8410. #else /* def SO_SNDBUFFORCE */
  8411. {errno = EINVAL; return -1;}
  8412. #endif /* ndef SO_SNDBUFFORCE */
  8413. if (x == Mono_Posix_UnixSocketOptionName_SO_SNDLOWAT)
  8414. #ifdef SO_SNDLOWAT
  8415. {*r = SO_SNDLOWAT; return 0;}
  8416. #else /* def SO_SNDLOWAT */
  8417. {errno = EINVAL; return -1;}
  8418. #endif /* ndef SO_SNDLOWAT */
  8419. if (x == Mono_Posix_UnixSocketOptionName_SO_SNDTIMEO)
  8420. #ifdef SO_SNDTIMEO
  8421. {*r = SO_SNDTIMEO; return 0;}
  8422. #else /* def SO_SNDTIMEO */
  8423. {errno = EINVAL; return -1;}
  8424. #endif /* ndef SO_SNDTIMEO */
  8425. if (x == Mono_Posix_UnixSocketOptionName_SO_TIMESTAMP)
  8426. #ifdef SO_TIMESTAMP
  8427. {*r = SO_TIMESTAMP; return 0;}
  8428. #else /* def SO_TIMESTAMP */
  8429. {errno = EINVAL; return -1;}
  8430. #endif /* ndef SO_TIMESTAMP */
  8431. if (x == Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPING)
  8432. #ifdef SO_TIMESTAMPING
  8433. {*r = SO_TIMESTAMPING; return 0;}
  8434. #else /* def SO_TIMESTAMPING */
  8435. {errno = EINVAL; return -1;}
  8436. #endif /* ndef SO_TIMESTAMPING */
  8437. if (x == Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPNS)
  8438. #ifdef SO_TIMESTAMPNS
  8439. {*r = SO_TIMESTAMPNS; return 0;}
  8440. #else /* def SO_TIMESTAMPNS */
  8441. {errno = EINVAL; return -1;}
  8442. #endif /* ndef SO_TIMESTAMPNS */
  8443. if (x == Mono_Posix_UnixSocketOptionName_SO_TYPE)
  8444. #ifdef SO_TYPE
  8445. {*r = SO_TYPE; return 0;}
  8446. #else /* def SO_TYPE */
  8447. {errno = EINVAL; return -1;}
  8448. #endif /* ndef SO_TYPE */
  8449. if (x == Mono_Posix_UnixSocketOptionName_SO_WIFI_STATUS)
  8450. #ifdef SO_WIFI_STATUS
  8451. {*r = SO_WIFI_STATUS; return 0;}
  8452. #else /* def SO_WIFI_STATUS */
  8453. {errno = EINVAL; return -1;}
  8454. #endif /* ndef SO_WIFI_STATUS */
  8455. if (x == 0)
  8456. return 0;
  8457. errno = EINVAL; return -1;
  8458. }
  8459. int Mono_Posix_ToUnixSocketOptionName (int x, int *r)
  8460. {
  8461. *r = 0;
  8462. if (x == 0)
  8463. return 0;
  8464. #ifdef SO_ACCEPTCONN
  8465. if (x == SO_ACCEPTCONN)
  8466. {*r = Mono_Posix_UnixSocketOptionName_SO_ACCEPTCONN; return 0;}
  8467. #endif /* ndef SO_ACCEPTCONN */
  8468. #ifdef SO_ATTACH_FILTER
  8469. if (x == SO_ATTACH_FILTER)
  8470. {*r = Mono_Posix_UnixSocketOptionName_SO_ATTACH_FILTER; return 0;}
  8471. #endif /* ndef SO_ATTACH_FILTER */
  8472. #ifdef SO_BINDTODEVICE
  8473. if (x == SO_BINDTODEVICE)
  8474. {*r = Mono_Posix_UnixSocketOptionName_SO_BINDTODEVICE; return 0;}
  8475. #endif /* ndef SO_BINDTODEVICE */
  8476. #ifdef SO_BROADCAST
  8477. if (x == SO_BROADCAST)
  8478. {*r = Mono_Posix_UnixSocketOptionName_SO_BROADCAST; return 0;}
  8479. #endif /* ndef SO_BROADCAST */
  8480. #ifdef SO_BSDCOMPAT
  8481. if (x == SO_BSDCOMPAT)
  8482. {*r = Mono_Posix_UnixSocketOptionName_SO_BSDCOMPAT; return 0;}
  8483. #endif /* ndef SO_BSDCOMPAT */
  8484. #ifdef SO_BUSY_POLL
  8485. if (x == SO_BUSY_POLL)
  8486. {*r = Mono_Posix_UnixSocketOptionName_SO_BUSY_POLL; return 0;}
  8487. #endif /* ndef SO_BUSY_POLL */
  8488. #ifdef SO_DEBUG
  8489. if (x == SO_DEBUG)
  8490. {*r = Mono_Posix_UnixSocketOptionName_SO_DEBUG; return 0;}
  8491. #endif /* ndef SO_DEBUG */
  8492. #ifdef SO_DETACH_FILTER
  8493. if (x == SO_DETACH_FILTER)
  8494. {*r = Mono_Posix_UnixSocketOptionName_SO_DETACH_FILTER; return 0;}
  8495. #endif /* ndef SO_DETACH_FILTER */
  8496. #ifdef SO_DOMAIN
  8497. if (x == SO_DOMAIN)
  8498. {*r = Mono_Posix_UnixSocketOptionName_SO_DOMAIN; return 0;}
  8499. #endif /* ndef SO_DOMAIN */
  8500. #ifdef SO_DONTROUTE
  8501. if (x == SO_DONTROUTE)
  8502. {*r = Mono_Posix_UnixSocketOptionName_SO_DONTROUTE; return 0;}
  8503. #endif /* ndef SO_DONTROUTE */
  8504. #ifdef SO_ERROR
  8505. if (x == SO_ERROR)
  8506. {*r = Mono_Posix_UnixSocketOptionName_SO_ERROR; return 0;}
  8507. #endif /* ndef SO_ERROR */
  8508. #ifdef SO_KEEPALIVE
  8509. if (x == SO_KEEPALIVE)
  8510. {*r = Mono_Posix_UnixSocketOptionName_SO_KEEPALIVE; return 0;}
  8511. #endif /* ndef SO_KEEPALIVE */
  8512. #ifdef SO_LINGER
  8513. if (x == SO_LINGER)
  8514. {*r = Mono_Posix_UnixSocketOptionName_SO_LINGER; return 0;}
  8515. #endif /* ndef SO_LINGER */
  8516. #ifdef SO_LOCK_FILTER
  8517. if (x == SO_LOCK_FILTER)
  8518. {*r = Mono_Posix_UnixSocketOptionName_SO_LOCK_FILTER; return 0;}
  8519. #endif /* ndef SO_LOCK_FILTER */
  8520. #ifdef SO_MARK
  8521. if (x == SO_MARK)
  8522. {*r = Mono_Posix_UnixSocketOptionName_SO_MARK; return 0;}
  8523. #endif /* ndef SO_MARK */
  8524. #ifdef SO_MAX_PACING_RATE
  8525. if (x == SO_MAX_PACING_RATE)
  8526. {*r = Mono_Posix_UnixSocketOptionName_SO_MAX_PACING_RATE; return 0;}
  8527. #endif /* ndef SO_MAX_PACING_RATE */
  8528. #ifdef SO_NOFCS
  8529. if (x == SO_NOFCS)
  8530. {*r = Mono_Posix_UnixSocketOptionName_SO_NOFCS; return 0;}
  8531. #endif /* ndef SO_NOFCS */
  8532. #ifdef SO_NO_CHECK
  8533. if (x == SO_NO_CHECK)
  8534. {*r = Mono_Posix_UnixSocketOptionName_SO_NO_CHECK; return 0;}
  8535. #endif /* ndef SO_NO_CHECK */
  8536. #ifdef SO_OOBINLINE
  8537. if (x == SO_OOBINLINE)
  8538. {*r = Mono_Posix_UnixSocketOptionName_SO_OOBINLINE; return 0;}
  8539. #endif /* ndef SO_OOBINLINE */
  8540. #ifdef SO_PASSCRED
  8541. if (x == SO_PASSCRED)
  8542. {*r = Mono_Posix_UnixSocketOptionName_SO_PASSCRED; return 0;}
  8543. #endif /* ndef SO_PASSCRED */
  8544. #ifdef SO_PASSSEC
  8545. if (x == SO_PASSSEC)
  8546. {*r = Mono_Posix_UnixSocketOptionName_SO_PASSSEC; return 0;}
  8547. #endif /* ndef SO_PASSSEC */
  8548. #ifdef SO_PEEK_OFF
  8549. if (x == SO_PEEK_OFF)
  8550. {*r = Mono_Posix_UnixSocketOptionName_SO_PEEK_OFF; return 0;}
  8551. #endif /* ndef SO_PEEK_OFF */
  8552. #ifdef SO_PEERCRED
  8553. if (x == SO_PEERCRED)
  8554. {*r = Mono_Posix_UnixSocketOptionName_SO_PEERCRED; return 0;}
  8555. #endif /* ndef SO_PEERCRED */
  8556. #ifdef SO_PEERNAME
  8557. if (x == SO_PEERNAME)
  8558. {*r = Mono_Posix_UnixSocketOptionName_SO_PEERNAME; return 0;}
  8559. #endif /* ndef SO_PEERNAME */
  8560. #ifdef SO_PEERSEC
  8561. if (x == SO_PEERSEC)
  8562. {*r = Mono_Posix_UnixSocketOptionName_SO_PEERSEC; return 0;}
  8563. #endif /* ndef SO_PEERSEC */
  8564. #ifdef SO_PRIORITY
  8565. if (x == SO_PRIORITY)
  8566. {*r = Mono_Posix_UnixSocketOptionName_SO_PRIORITY; return 0;}
  8567. #endif /* ndef SO_PRIORITY */
  8568. #ifdef SO_PROTOCOL
  8569. if (x == SO_PROTOCOL)
  8570. {*r = Mono_Posix_UnixSocketOptionName_SO_PROTOCOL; return 0;}
  8571. #endif /* ndef SO_PROTOCOL */
  8572. #ifdef SO_RCVBUF
  8573. if (x == SO_RCVBUF)
  8574. {*r = Mono_Posix_UnixSocketOptionName_SO_RCVBUF; return 0;}
  8575. #endif /* ndef SO_RCVBUF */
  8576. #ifdef SO_RCVBUFFORCE
  8577. if (x == SO_RCVBUFFORCE)
  8578. {*r = Mono_Posix_UnixSocketOptionName_SO_RCVBUFFORCE; return 0;}
  8579. #endif /* ndef SO_RCVBUFFORCE */
  8580. #ifdef SO_RCVLOWAT
  8581. if (x == SO_RCVLOWAT)
  8582. {*r = Mono_Posix_UnixSocketOptionName_SO_RCVLOWAT; return 0;}
  8583. #endif /* ndef SO_RCVLOWAT */
  8584. #ifdef SO_RCVTIMEO
  8585. if (x == SO_RCVTIMEO)
  8586. {*r = Mono_Posix_UnixSocketOptionName_SO_RCVTIMEO; return 0;}
  8587. #endif /* ndef SO_RCVTIMEO */
  8588. #ifdef SO_REUSEADDR
  8589. if (x == SO_REUSEADDR)
  8590. {*r = Mono_Posix_UnixSocketOptionName_SO_REUSEADDR; return 0;}
  8591. #endif /* ndef SO_REUSEADDR */
  8592. #ifdef SO_REUSEPORT
  8593. if (x == SO_REUSEPORT)
  8594. {*r = Mono_Posix_UnixSocketOptionName_SO_REUSEPORT; return 0;}
  8595. #endif /* ndef SO_REUSEPORT */
  8596. #ifdef SO_RXQ_OVFL
  8597. if (x == SO_RXQ_OVFL)
  8598. {*r = Mono_Posix_UnixSocketOptionName_SO_RXQ_OVFL; return 0;}
  8599. #endif /* ndef SO_RXQ_OVFL */
  8600. #ifdef SO_SECURITY_AUTHENTICATION
  8601. if (x == SO_SECURITY_AUTHENTICATION)
  8602. {*r = Mono_Posix_UnixSocketOptionName_SO_SECURITY_AUTHENTICATION; return 0;}
  8603. #endif /* ndef SO_SECURITY_AUTHENTICATION */
  8604. #ifdef SO_SECURITY_ENCRYPTION_NETWORK
  8605. if (x == SO_SECURITY_ENCRYPTION_NETWORK)
  8606. {*r = Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_NETWORK; return 0;}
  8607. #endif /* ndef SO_SECURITY_ENCRYPTION_NETWORK */
  8608. #ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
  8609. if (x == SO_SECURITY_ENCRYPTION_TRANSPORT)
  8610. {*r = Mono_Posix_UnixSocketOptionName_SO_SECURITY_ENCRYPTION_TRANSPORT; return 0;}
  8611. #endif /* ndef SO_SECURITY_ENCRYPTION_TRANSPORT */
  8612. #ifdef SO_SELECT_ERR_QUEUE
  8613. if (x == SO_SELECT_ERR_QUEUE)
  8614. {*r = Mono_Posix_UnixSocketOptionName_SO_SELECT_ERR_QUEUE; return 0;}
  8615. #endif /* ndef SO_SELECT_ERR_QUEUE */
  8616. #ifdef SO_SNDBUF
  8617. if (x == SO_SNDBUF)
  8618. {*r = Mono_Posix_UnixSocketOptionName_SO_SNDBUF; return 0;}
  8619. #endif /* ndef SO_SNDBUF */
  8620. #ifdef SO_SNDBUFFORCE
  8621. if (x == SO_SNDBUFFORCE)
  8622. {*r = Mono_Posix_UnixSocketOptionName_SO_SNDBUFFORCE; return 0;}
  8623. #endif /* ndef SO_SNDBUFFORCE */
  8624. #ifdef SO_SNDLOWAT
  8625. if (x == SO_SNDLOWAT)
  8626. {*r = Mono_Posix_UnixSocketOptionName_SO_SNDLOWAT; return 0;}
  8627. #endif /* ndef SO_SNDLOWAT */
  8628. #ifdef SO_SNDTIMEO
  8629. if (x == SO_SNDTIMEO)
  8630. {*r = Mono_Posix_UnixSocketOptionName_SO_SNDTIMEO; return 0;}
  8631. #endif /* ndef SO_SNDTIMEO */
  8632. #ifdef SO_TIMESTAMP
  8633. if (x == SO_TIMESTAMP)
  8634. {*r = Mono_Posix_UnixSocketOptionName_SO_TIMESTAMP; return 0;}
  8635. #endif /* ndef SO_TIMESTAMP */
  8636. #ifdef SO_TIMESTAMPING
  8637. if (x == SO_TIMESTAMPING)
  8638. {*r = Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPING; return 0;}
  8639. #endif /* ndef SO_TIMESTAMPING */
  8640. #ifdef SO_TIMESTAMPNS
  8641. if (x == SO_TIMESTAMPNS)
  8642. {*r = Mono_Posix_UnixSocketOptionName_SO_TIMESTAMPNS; return 0;}
  8643. #endif /* ndef SO_TIMESTAMPNS */
  8644. #ifdef SO_TYPE
  8645. if (x == SO_TYPE)
  8646. {*r = Mono_Posix_UnixSocketOptionName_SO_TYPE; return 0;}
  8647. #endif /* ndef SO_TYPE */
  8648. #ifdef SO_WIFI_STATUS
  8649. if (x == SO_WIFI_STATUS)
  8650. {*r = Mono_Posix_UnixSocketOptionName_SO_WIFI_STATUS; return 0;}
  8651. #endif /* ndef SO_WIFI_STATUS */
  8652. errno = EINVAL; return -1;
  8653. }
  8654. int Mono_Posix_FromUnixSocketProtocol (int x, int *r)
  8655. {
  8656. *r = 0;
  8657. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_AH)
  8658. #ifdef IPPROTO_AH
  8659. {*r = IPPROTO_AH; return 0;}
  8660. #else /* def IPPROTO_AH */
  8661. {errno = EINVAL; return -1;}
  8662. #endif /* ndef IPPROTO_AH */
  8663. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_BEETPH)
  8664. #ifdef IPPROTO_BEETPH
  8665. {*r = IPPROTO_BEETPH; return 0;}
  8666. #else /* def IPPROTO_BEETPH */
  8667. {errno = EINVAL; return -1;}
  8668. #endif /* ndef IPPROTO_BEETPH */
  8669. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_COMP)
  8670. #ifdef IPPROTO_COMP
  8671. {*r = IPPROTO_COMP; return 0;}
  8672. #else /* def IPPROTO_COMP */
  8673. {errno = EINVAL; return -1;}
  8674. #endif /* ndef IPPROTO_COMP */
  8675. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_DCCP)
  8676. #ifdef IPPROTO_DCCP
  8677. {*r = IPPROTO_DCCP; return 0;}
  8678. #else /* def IPPROTO_DCCP */
  8679. {errno = EINVAL; return -1;}
  8680. #endif /* ndef IPPROTO_DCCP */
  8681. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_EGP)
  8682. #ifdef IPPROTO_EGP
  8683. {*r = IPPROTO_EGP; return 0;}
  8684. #else /* def IPPROTO_EGP */
  8685. {errno = EINVAL; return -1;}
  8686. #endif /* ndef IPPROTO_EGP */
  8687. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_ENCAP)
  8688. #ifdef IPPROTO_ENCAP
  8689. {*r = IPPROTO_ENCAP; return 0;}
  8690. #else /* def IPPROTO_ENCAP */
  8691. {errno = EINVAL; return -1;}
  8692. #endif /* ndef IPPROTO_ENCAP */
  8693. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_ESP)
  8694. #ifdef IPPROTO_ESP
  8695. {*r = IPPROTO_ESP; return 0;}
  8696. #else /* def IPPROTO_ESP */
  8697. {errno = EINVAL; return -1;}
  8698. #endif /* ndef IPPROTO_ESP */
  8699. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_GRE)
  8700. #ifdef IPPROTO_GRE
  8701. {*r = IPPROTO_GRE; return 0;}
  8702. #else /* def IPPROTO_GRE */
  8703. {errno = EINVAL; return -1;}
  8704. #endif /* ndef IPPROTO_GRE */
  8705. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_ICMP)
  8706. #ifdef IPPROTO_ICMP
  8707. {*r = IPPROTO_ICMP; return 0;}
  8708. #else /* def IPPROTO_ICMP */
  8709. {errno = EINVAL; return -1;}
  8710. #endif /* ndef IPPROTO_ICMP */
  8711. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_IDP)
  8712. #ifdef IPPROTO_IDP
  8713. {*r = IPPROTO_IDP; return 0;}
  8714. #else /* def IPPROTO_IDP */
  8715. {errno = EINVAL; return -1;}
  8716. #endif /* ndef IPPROTO_IDP */
  8717. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_IGMP)
  8718. #ifdef IPPROTO_IGMP
  8719. {*r = IPPROTO_IGMP; return 0;}
  8720. #else /* def IPPROTO_IGMP */
  8721. {errno = EINVAL; return -1;}
  8722. #endif /* ndef IPPROTO_IGMP */
  8723. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_IP)
  8724. #ifdef IPPROTO_IP
  8725. {*r = IPPROTO_IP; return 0;}
  8726. #else /* def IPPROTO_IP */
  8727. {errno = EINVAL; return -1;}
  8728. #endif /* ndef IPPROTO_IP */
  8729. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_IPIP)
  8730. #ifdef IPPROTO_IPIP
  8731. {*r = IPPROTO_IPIP; return 0;}
  8732. #else /* def IPPROTO_IPIP */
  8733. {errno = EINVAL; return -1;}
  8734. #endif /* ndef IPPROTO_IPIP */
  8735. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_IPV6)
  8736. #ifdef IPPROTO_IPV6
  8737. {*r = IPPROTO_IPV6; return 0;}
  8738. #else /* def IPPROTO_IPV6 */
  8739. {errno = EINVAL; return -1;}
  8740. #endif /* ndef IPPROTO_IPV6 */
  8741. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_MTP)
  8742. #ifdef IPPROTO_MTP
  8743. {*r = IPPROTO_MTP; return 0;}
  8744. #else /* def IPPROTO_MTP */
  8745. {errno = EINVAL; return -1;}
  8746. #endif /* ndef IPPROTO_MTP */
  8747. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_PIM)
  8748. #ifdef IPPROTO_PIM
  8749. {*r = IPPROTO_PIM; return 0;}
  8750. #else /* def IPPROTO_PIM */
  8751. {errno = EINVAL; return -1;}
  8752. #endif /* ndef IPPROTO_PIM */
  8753. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_PUP)
  8754. #ifdef IPPROTO_PUP
  8755. {*r = IPPROTO_PUP; return 0;}
  8756. #else /* def IPPROTO_PUP */
  8757. {errno = EINVAL; return -1;}
  8758. #endif /* ndef IPPROTO_PUP */
  8759. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_RAW)
  8760. #ifdef IPPROTO_RAW
  8761. {*r = IPPROTO_RAW; return 0;}
  8762. #else /* def IPPROTO_RAW */
  8763. {errno = EINVAL; return -1;}
  8764. #endif /* ndef IPPROTO_RAW */
  8765. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_RSVP)
  8766. #ifdef IPPROTO_RSVP
  8767. {*r = IPPROTO_RSVP; return 0;}
  8768. #else /* def IPPROTO_RSVP */
  8769. {errno = EINVAL; return -1;}
  8770. #endif /* ndef IPPROTO_RSVP */
  8771. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_SCTP)
  8772. #ifdef IPPROTO_SCTP
  8773. {*r = IPPROTO_SCTP; return 0;}
  8774. #else /* def IPPROTO_SCTP */
  8775. {errno = EINVAL; return -1;}
  8776. #endif /* ndef IPPROTO_SCTP */
  8777. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_TCP)
  8778. #ifdef IPPROTO_TCP
  8779. {*r = IPPROTO_TCP; return 0;}
  8780. #else /* def IPPROTO_TCP */
  8781. {errno = EINVAL; return -1;}
  8782. #endif /* ndef IPPROTO_TCP */
  8783. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_TP)
  8784. #ifdef IPPROTO_TP
  8785. {*r = IPPROTO_TP; return 0;}
  8786. #else /* def IPPROTO_TP */
  8787. {errno = EINVAL; return -1;}
  8788. #endif /* ndef IPPROTO_TP */
  8789. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_UDP)
  8790. #ifdef IPPROTO_UDP
  8791. {*r = IPPROTO_UDP; return 0;}
  8792. #else /* def IPPROTO_UDP */
  8793. {errno = EINVAL; return -1;}
  8794. #endif /* ndef IPPROTO_UDP */
  8795. if (x == Mono_Posix_UnixSocketProtocol_IPPROTO_UDPLITE)
  8796. #ifdef IPPROTO_UDPLITE
  8797. {*r = IPPROTO_UDPLITE; return 0;}
  8798. #else /* def IPPROTO_UDPLITE */
  8799. {errno = EINVAL; return -1;}
  8800. #endif /* ndef IPPROTO_UDPLITE */
  8801. if (x == Mono_Posix_UnixSocketProtocol_SOL_SOCKET)
  8802. #ifdef SOL_SOCKET
  8803. {*r = SOL_SOCKET; return 0;}
  8804. #else /* def SOL_SOCKET */
  8805. {errno = EINVAL; return -1;}
  8806. #endif /* ndef SOL_SOCKET */
  8807. if (x == 0)
  8808. return 0;
  8809. errno = EINVAL; return -1;
  8810. }
  8811. int Mono_Posix_ToUnixSocketProtocol (int x, int *r)
  8812. {
  8813. *r = 0;
  8814. if (x == 0)
  8815. return 0;
  8816. #ifdef IPPROTO_AH
  8817. if (x == IPPROTO_AH)
  8818. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_AH; return 0;}
  8819. #endif /* ndef IPPROTO_AH */
  8820. #ifdef IPPROTO_BEETPH
  8821. if (x == IPPROTO_BEETPH)
  8822. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_BEETPH; return 0;}
  8823. #endif /* ndef IPPROTO_BEETPH */
  8824. #ifdef IPPROTO_COMP
  8825. if (x == IPPROTO_COMP)
  8826. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_COMP; return 0;}
  8827. #endif /* ndef IPPROTO_COMP */
  8828. #ifdef IPPROTO_DCCP
  8829. if (x == IPPROTO_DCCP)
  8830. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_DCCP; return 0;}
  8831. #endif /* ndef IPPROTO_DCCP */
  8832. #ifdef IPPROTO_EGP
  8833. if (x == IPPROTO_EGP)
  8834. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_EGP; return 0;}
  8835. #endif /* ndef IPPROTO_EGP */
  8836. #ifdef IPPROTO_ENCAP
  8837. if (x == IPPROTO_ENCAP)
  8838. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_ENCAP; return 0;}
  8839. #endif /* ndef IPPROTO_ENCAP */
  8840. #ifdef IPPROTO_ESP
  8841. if (x == IPPROTO_ESP)
  8842. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_ESP; return 0;}
  8843. #endif /* ndef IPPROTO_ESP */
  8844. #ifdef IPPROTO_GRE
  8845. if (x == IPPROTO_GRE)
  8846. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_GRE; return 0;}
  8847. #endif /* ndef IPPROTO_GRE */
  8848. #ifdef IPPROTO_ICMP
  8849. if (x == IPPROTO_ICMP)
  8850. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_ICMP; return 0;}
  8851. #endif /* ndef IPPROTO_ICMP */
  8852. #ifdef IPPROTO_IDP
  8853. if (x == IPPROTO_IDP)
  8854. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_IDP; return 0;}
  8855. #endif /* ndef IPPROTO_IDP */
  8856. #ifdef IPPROTO_IGMP
  8857. if (x == IPPROTO_IGMP)
  8858. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_IGMP; return 0;}
  8859. #endif /* ndef IPPROTO_IGMP */
  8860. #ifdef IPPROTO_IP
  8861. if (x == IPPROTO_IP)
  8862. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_IP; return 0;}
  8863. #endif /* ndef IPPROTO_IP */
  8864. #ifdef IPPROTO_IPIP
  8865. if (x == IPPROTO_IPIP)
  8866. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_IPIP; return 0;}
  8867. #endif /* ndef IPPROTO_IPIP */
  8868. #ifdef IPPROTO_IPV6
  8869. if (x == IPPROTO_IPV6)
  8870. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_IPV6; return 0;}
  8871. #endif /* ndef IPPROTO_IPV6 */
  8872. #ifdef IPPROTO_MTP
  8873. if (x == IPPROTO_MTP)
  8874. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_MTP; return 0;}
  8875. #endif /* ndef IPPROTO_MTP */
  8876. #ifdef IPPROTO_PIM
  8877. if (x == IPPROTO_PIM)
  8878. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_PIM; return 0;}
  8879. #endif /* ndef IPPROTO_PIM */
  8880. #ifdef IPPROTO_PUP
  8881. if (x == IPPROTO_PUP)
  8882. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_PUP; return 0;}
  8883. #endif /* ndef IPPROTO_PUP */
  8884. #ifdef IPPROTO_RAW
  8885. if (x == IPPROTO_RAW)
  8886. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_RAW; return 0;}
  8887. #endif /* ndef IPPROTO_RAW */
  8888. #ifdef IPPROTO_RSVP
  8889. if (x == IPPROTO_RSVP)
  8890. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_RSVP; return 0;}
  8891. #endif /* ndef IPPROTO_RSVP */
  8892. #ifdef IPPROTO_SCTP
  8893. if (x == IPPROTO_SCTP)
  8894. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_SCTP; return 0;}
  8895. #endif /* ndef IPPROTO_SCTP */
  8896. #ifdef IPPROTO_TCP
  8897. if (x == IPPROTO_TCP)
  8898. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_TCP; return 0;}
  8899. #endif /* ndef IPPROTO_TCP */
  8900. #ifdef IPPROTO_TP
  8901. if (x == IPPROTO_TP)
  8902. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_TP; return 0;}
  8903. #endif /* ndef IPPROTO_TP */
  8904. #ifdef IPPROTO_UDP
  8905. if (x == IPPROTO_UDP)
  8906. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_UDP; return 0;}
  8907. #endif /* ndef IPPROTO_UDP */
  8908. #ifdef IPPROTO_UDPLITE
  8909. if (x == IPPROTO_UDPLITE)
  8910. {*r = Mono_Posix_UnixSocketProtocol_IPPROTO_UDPLITE; return 0;}
  8911. #endif /* ndef IPPROTO_UDPLITE */
  8912. #ifdef SOL_SOCKET
  8913. if (x == SOL_SOCKET)
  8914. {*r = Mono_Posix_UnixSocketProtocol_SOL_SOCKET; return 0;}
  8915. #endif /* ndef SOL_SOCKET */
  8916. errno = EINVAL; return -1;
  8917. }
  8918. int Mono_Posix_FromUnixSocketType (int x, int *r)
  8919. {
  8920. *r = 0;
  8921. if (x == Mono_Posix_UnixSocketType_SOCK_DCCP)
  8922. #ifdef SOCK_DCCP
  8923. {*r = SOCK_DCCP; return 0;}
  8924. #else /* def SOCK_DCCP */
  8925. {errno = EINVAL; return -1;}
  8926. #endif /* ndef SOCK_DCCP */
  8927. if (x == Mono_Posix_UnixSocketType_SOCK_DGRAM)
  8928. #ifdef SOCK_DGRAM
  8929. {*r = SOCK_DGRAM; return 0;}
  8930. #else /* def SOCK_DGRAM */
  8931. {errno = EINVAL; return -1;}
  8932. #endif /* ndef SOCK_DGRAM */
  8933. if (x == Mono_Posix_UnixSocketType_SOCK_PACKET)
  8934. #ifdef SOCK_PACKET
  8935. {*r = SOCK_PACKET; return 0;}
  8936. #else /* def SOCK_PACKET */
  8937. {errno = EINVAL; return -1;}
  8938. #endif /* ndef SOCK_PACKET */
  8939. if (x == Mono_Posix_UnixSocketType_SOCK_RAW)
  8940. #ifdef SOCK_RAW
  8941. {*r = SOCK_RAW; return 0;}
  8942. #else /* def SOCK_RAW */
  8943. {errno = EINVAL; return -1;}
  8944. #endif /* ndef SOCK_RAW */
  8945. if (x == Mono_Posix_UnixSocketType_SOCK_RDM)
  8946. #ifdef SOCK_RDM
  8947. {*r = SOCK_RDM; return 0;}
  8948. #else /* def SOCK_RDM */
  8949. {errno = EINVAL; return -1;}
  8950. #endif /* ndef SOCK_RDM */
  8951. if (x == Mono_Posix_UnixSocketType_SOCK_SEQPACKET)
  8952. #ifdef SOCK_SEQPACKET
  8953. {*r = SOCK_SEQPACKET; return 0;}
  8954. #else /* def SOCK_SEQPACKET */
  8955. {errno = EINVAL; return -1;}
  8956. #endif /* ndef SOCK_SEQPACKET */
  8957. if (x == Mono_Posix_UnixSocketType_SOCK_STREAM)
  8958. #ifdef SOCK_STREAM
  8959. {*r = SOCK_STREAM; return 0;}
  8960. #else /* def SOCK_STREAM */
  8961. {errno = EINVAL; return -1;}
  8962. #endif /* ndef SOCK_STREAM */
  8963. if (x == 0)
  8964. return 0;
  8965. errno = EINVAL; return -1;
  8966. }
  8967. int Mono_Posix_ToUnixSocketType (int x, int *r)
  8968. {
  8969. *r = 0;
  8970. if (x == 0)
  8971. return 0;
  8972. #ifdef SOCK_DCCP
  8973. if (x == SOCK_DCCP)
  8974. {*r = Mono_Posix_UnixSocketType_SOCK_DCCP; return 0;}
  8975. #endif /* ndef SOCK_DCCP */
  8976. #ifdef SOCK_DGRAM
  8977. if (x == SOCK_DGRAM)
  8978. {*r = Mono_Posix_UnixSocketType_SOCK_DGRAM; return 0;}
  8979. #endif /* ndef SOCK_DGRAM */
  8980. #ifdef SOCK_PACKET
  8981. if (x == SOCK_PACKET)
  8982. {*r = Mono_Posix_UnixSocketType_SOCK_PACKET; return 0;}
  8983. #endif /* ndef SOCK_PACKET */
  8984. #ifdef SOCK_RAW
  8985. if (x == SOCK_RAW)
  8986. {*r = Mono_Posix_UnixSocketType_SOCK_RAW; return 0;}
  8987. #endif /* ndef SOCK_RAW */
  8988. #ifdef SOCK_RDM
  8989. if (x == SOCK_RDM)
  8990. {*r = Mono_Posix_UnixSocketType_SOCK_RDM; return 0;}
  8991. #endif /* ndef SOCK_RDM */
  8992. #ifdef SOCK_SEQPACKET
  8993. if (x == SOCK_SEQPACKET)
  8994. {*r = Mono_Posix_UnixSocketType_SOCK_SEQPACKET; return 0;}
  8995. #endif /* ndef SOCK_SEQPACKET */
  8996. #ifdef SOCK_STREAM
  8997. if (x == SOCK_STREAM)
  8998. {*r = Mono_Posix_UnixSocketType_SOCK_STREAM; return 0;}
  8999. #endif /* ndef SOCK_STREAM */
  9000. errno = EINVAL; return -1;
  9001. }
  9002. #ifdef HAVE_STRUCT_UTIMBUF
  9003. int
  9004. Mono_Posix_FromUtimbuf (struct Mono_Posix_Utimbuf *from, struct utimbuf *to)
  9005. {
  9006. _cnm_return_val_if_overflow (time_t, from->actime, -1);
  9007. _cnm_return_val_if_overflow (time_t, from->modtime, -1);
  9008. memset (to, 0, sizeof(*to));
  9009. to->actime = from->actime;
  9010. to->modtime = from->modtime;
  9011. return 0;
  9012. }
  9013. #endif /* ndef HAVE_STRUCT_UTIMBUF */
  9014. #ifdef HAVE_STRUCT_UTIMBUF
  9015. int
  9016. Mono_Posix_ToUtimbuf (struct utimbuf *from, struct Mono_Posix_Utimbuf *to)
  9017. {
  9018. _cnm_return_val_if_overflow (gint64, from->actime, -1);
  9019. _cnm_return_val_if_overflow (gint64, from->modtime, -1);
  9020. memset (to, 0, sizeof(*to));
  9021. to->actime = from->actime;
  9022. to->modtime = from->modtime;
  9023. return 0;
  9024. }
  9025. #endif /* ndef HAVE_STRUCT_UTIMBUF */
  9026. int Mono_Posix_FromWaitOptions (int x, int *r)
  9027. {
  9028. *r = 0;
  9029. if ((x & Mono_Posix_WaitOptions_WNOHANG) == Mono_Posix_WaitOptions_WNOHANG)
  9030. #ifdef WNOHANG
  9031. *r |= WNOHANG;
  9032. #else /* def WNOHANG */
  9033. {errno = EINVAL; return -1;}
  9034. #endif /* ndef WNOHANG */
  9035. if ((x & Mono_Posix_WaitOptions_WUNTRACED) == Mono_Posix_WaitOptions_WUNTRACED)
  9036. #ifdef WUNTRACED
  9037. *r |= WUNTRACED;
  9038. #else /* def WUNTRACED */
  9039. {errno = EINVAL; return -1;}
  9040. #endif /* ndef WUNTRACED */
  9041. if (x == 0)
  9042. return 0;
  9043. return 0;
  9044. }
  9045. int Mono_Posix_ToWaitOptions (int x, int *r)
  9046. {
  9047. *r = 0;
  9048. if (x == 0)
  9049. return 0;
  9050. #ifdef WNOHANG
  9051. if ((x & WNOHANG) == WNOHANG)
  9052. *r |= Mono_Posix_WaitOptions_WNOHANG;
  9053. #endif /* ndef WNOHANG */
  9054. #ifdef WUNTRACED
  9055. if ((x & WUNTRACED) == WUNTRACED)
  9056. *r |= Mono_Posix_WaitOptions_WUNTRACED;
  9057. #endif /* ndef WUNTRACED */
  9058. return 0;
  9059. }
  9060. int Mono_Posix_FromXattrFlags (int x, int *r)
  9061. {
  9062. *r = 0;
  9063. if ((x & Mono_Posix_XattrFlags_XATTR_AUTO) == Mono_Posix_XattrFlags_XATTR_AUTO)
  9064. #ifdef XATTR_AUTO
  9065. *r |= XATTR_AUTO;
  9066. #else /* def XATTR_AUTO */
  9067. {errno = EINVAL; return -1;}
  9068. #endif /* ndef XATTR_AUTO */
  9069. if ((x & Mono_Posix_XattrFlags_XATTR_CREATE) == Mono_Posix_XattrFlags_XATTR_CREATE)
  9070. #ifdef XATTR_CREATE
  9071. *r |= XATTR_CREATE;
  9072. #else /* def XATTR_CREATE */
  9073. {errno = EINVAL; return -1;}
  9074. #endif /* ndef XATTR_CREATE */
  9075. if ((x & Mono_Posix_XattrFlags_XATTR_REPLACE) == Mono_Posix_XattrFlags_XATTR_REPLACE)
  9076. #ifdef XATTR_REPLACE
  9077. *r |= XATTR_REPLACE;
  9078. #else /* def XATTR_REPLACE */
  9079. {errno = EINVAL; return -1;}
  9080. #endif /* ndef XATTR_REPLACE */
  9081. if (x == 0)
  9082. return 0;
  9083. return 0;
  9084. }
  9085. int Mono_Posix_ToXattrFlags (int x, int *r)
  9086. {
  9087. *r = 0;
  9088. if (x == 0)
  9089. return 0;
  9090. #ifdef XATTR_AUTO
  9091. if ((x & XATTR_AUTO) == XATTR_AUTO)
  9092. *r |= Mono_Posix_XattrFlags_XATTR_AUTO;
  9093. #endif /* ndef XATTR_AUTO */
  9094. #ifdef XATTR_CREATE
  9095. if ((x & XATTR_CREATE) == XATTR_CREATE)
  9096. *r |= Mono_Posix_XattrFlags_XATTR_CREATE;
  9097. #endif /* ndef XATTR_CREATE */
  9098. #ifdef XATTR_REPLACE
  9099. if ((x & XATTR_REPLACE) == XATTR_REPLACE)
  9100. *r |= Mono_Posix_XattrFlags_XATTR_REPLACE;
  9101. #endif /* ndef XATTR_REPLACE */
  9102. return 0;
  9103. }