musl_illumos_amd64.go 198 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210
  1. // Code generated by 'ccgo -export-externs X -hide __syscall0,__syscall1,__syscall2,__syscall3,__syscall4,__syscall5,__syscall6 -nostdinc -nostdlib -o ../musl_linux_amd64.go -pkgname libc -static-locals-prefix _s -Iarch/x86_64 -Iarch/generic -Iobj/src/internal -Isrc/include -Isrc/internal -Iobj/include -Iinclude copyright.c src/ctype/__ctype_b_loc.c src/ctype/isalnum.c src/ctype/isalpha.c src/ctype/isdigit.c src/ctype/islower.c src/ctype/isprint.c src/ctype/isupper.c src/ctype/isxdigit.c src/dirent/closedir.c src/dirent/opendir.c src/dirent/readdir.c src/internal/floatscan.c src/internal/intscan.c src/internal/shgetc.c src/locale/localeconv.c src/math/__fpclassify.c src/math/__fpclassifyf.c src/math/__fpclassifyl.c src/math/copysignl.c src/math/fabsl.c src/math/fmodl.c src/math/nanf.c src/math/rint.c src/math/scalbn.c src/math/scalbnl.c src/multibyte/internal.c src/multibyte/mbrtowc.c src/multibyte/mbsinit.c src/network/freeaddrinfo.c src/network/getaddrinfo.c src/network/gethostbyaddr.c src/network/gethostbyaddr_r.c src/network/gethostbyname.c src/network/gethostbyname2.c src/network/gethostbyname2_r.c src/network/gethostbyname_r.c src/network/getnameinfo.c src/network/h_errno.c src/network/inet_aton.c src/network/inet_ntop.c src/network/inet_pton.c src/network/lookup_ipliteral.c src/network/lookup_name.c src/network/lookup_serv.c src/prng/rand_r.c src/stdio/__lockfile.c src/stdio/__toread.c src/stdio/__uflow.c src/stdio/sscanf.c src/stdio/vfscanf.c src/stdio/vsscanf.c src/stdlib/bsearch.c src/stdlib/strtod.c src/stdlib/strtol.c src/string/strdup.c src/string/strlcat.c src/string/strlcpy.c src/string/strncasecmp.c src/string/strncat.c src/string/strnlen.c src/string/strspn.c src/string/strtok.c src/thread/pthread_attr_get.c src/thread/pthread_attr_setdetachstate.c src/thread/pthread_mutex_lock.c src/thread/pthread_mutexattr_destroy.c src/thread/pthread_mutexattr_init.c src/thread/pthread_mutexattr_settype.c', DO NOT EDIT.
  2. package libc
  3. import (
  4. "math"
  5. "reflect"
  6. "sync/atomic"
  7. "unsafe"
  8. )
  9. var _ = math.Pi
  10. var _ reflect.Kind
  11. var _ atomic.Value
  12. var _ unsafe.Pointer
  13. // musl as a whole is licensed under the following standard MIT license:
  14. //
  15. // ----------------------------------------------------------------------
  16. // Copyright © 2005-2020 Rich Felker, et al.
  17. //
  18. // Permission is hereby granted, free of charge, to any person obtaining
  19. // a copy of this software and associated documentation files (the
  20. // "Software"), to deal in the Software without restriction, including
  21. // without limitation the rights to use, copy, modify, merge, publish,
  22. // distribute, sublicense, and/or sell copies of the Software, and to
  23. // permit persons to whom the Software is furnished to do so, subject to
  24. // the following conditions:
  25. //
  26. // The above copyright notice and this permission notice shall be
  27. // included in all copies or substantial portions of the Software.
  28. //
  29. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  30. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  31. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  32. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  33. // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  34. // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  35. // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  36. // ----------------------------------------------------------------------
  37. //
  38. // Authors/contributors include:
  39. //
  40. // A. Wilcox
  41. // Ada Worcester
  42. // Alex Dowad
  43. // Alex Suykov
  44. // Alexander Monakov
  45. // Andre McCurdy
  46. // Andrew Kelley
  47. // Anthony G. Basile
  48. // Aric Belsito
  49. // Arvid Picciani
  50. // Bartosz Brachaczek
  51. // Benjamin Peterson
  52. // Bobby Bingham
  53. // Boris Brezillon
  54. // Brent Cook
  55. // Chris Spiegel
  56. // Clément Vasseur
  57. // Daniel Micay
  58. // Daniel Sabogal
  59. // Daurnimator
  60. // David Carlier
  61. // David Edelsohn
  62. // Denys Vlasenko
  63. // Dmitry Ivanov
  64. // Dmitry V. Levin
  65. // Drew DeVault
  66. // Emil Renner Berthing
  67. // Fangrui Song
  68. // Felix Fietkau
  69. // Felix Janda
  70. // Gianluca Anzolin
  71. // Hauke Mehrtens
  72. // He X
  73. // Hiltjo Posthuma
  74. // Isaac Dunham
  75. // Jaydeep Patil
  76. // Jens Gustedt
  77. // Jeremy Huntwork
  78. // Jo-Philipp Wich
  79. // Joakim Sindholt
  80. // John Spencer
  81. // Julien Ramseier
  82. // Justin Cormack
  83. // Kaarle Ritvanen
  84. // Khem Raj
  85. // Kylie McClain
  86. // Leah Neukirchen
  87. // Luca Barbato
  88. // Luka Perkov
  89. // M Farkas-Dyck (Strake)
  90. // Mahesh Bodapati
  91. // Markus Wichmann
  92. // Masanori Ogino
  93. // Michael Clark
  94. // Michael Forney
  95. // Mikhail Kremnyov
  96. // Natanael Copa
  97. // Nicholas J. Kain
  98. // orc
  99. // Pascal Cuoq
  100. // Patrick Oppenlander
  101. // Petr Hosek
  102. // Petr Skocik
  103. // Pierre Carrier
  104. // Reini Urban
  105. // Rich Felker
  106. // Richard Pennington
  107. // Ryan Fairfax
  108. // Samuel Holland
  109. // Segev Finer
  110. // Shiz
  111. // sin
  112. // Solar Designer
  113. // Stefan Kristiansson
  114. // Stefan O'Rear
  115. // Szabolcs Nagy
  116. // Timo Teräs
  117. // Trutz Behn
  118. // Valentin Ochs
  119. // Will Dietz
  120. // William Haddon
  121. // William Pitcock
  122. //
  123. // Portions of this software are derived from third-party works licensed
  124. // under terms compatible with the above MIT license:
  125. //
  126. // The TRE regular expression implementation (src/regex/reg* and
  127. // src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed
  128. // under a 2-clause BSD license (license text in the source files). The
  129. // included version has been heavily modified by Rich Felker in 2012, in
  130. // the interests of size, simplicity, and namespace cleanliness.
  131. //
  132. // Much of the math library code (src/math/* and src/complex/*) is
  133. // Copyright © 1993,2004 Sun Microsystems or
  134. // Copyright © 2003-2011 David Schultz or
  135. // Copyright © 2003-2009 Steven G. Kargl or
  136. // Copyright © 2003-2009 Bruce D. Evans or
  137. // Copyright © 2008 Stephen L. Moshier or
  138. // Copyright © 2017-2018 Arm Limited
  139. // and labelled as such in comments in the individual source files. All
  140. // have been licensed under extremely permissive terms.
  141. //
  142. // The ARM memcpy code (src/string/arm/memcpy.S) is Copyright © 2008
  143. // The Android Open Source Project and is licensed under a two-clause BSD
  144. // license. It was taken from Bionic libc, used on Android.
  145. //
  146. // The AArch64 memcpy and memset code (src/string/aarch64/*) are
  147. // Copyright © 1999-2019, Arm Limited.
  148. //
  149. // The implementation of DES for crypt (src/crypt/crypt_des.c) is
  150. // Copyright © 1994 David Burren. It is licensed under a BSD license.
  151. //
  152. // The implementation of blowfish crypt (src/crypt/crypt_blowfish.c) was
  153. // originally written by Solar Designer and placed into the public
  154. // domain. The code also comes with a fallback permissive license for use
  155. // in jurisdictions that may not recognize the public domain.
  156. //
  157. // The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011
  158. // Valentin Ochs and is licensed under an MIT-style license.
  159. //
  160. // The x86_64 port was written by Nicholas J. Kain and is licensed under
  161. // the standard MIT terms.
  162. //
  163. // The mips and microblaze ports were originally written by Richard
  164. // Pennington for use in the ellcc project. The original code was adapted
  165. // by Rich Felker for build system and code conventions during upstream
  166. // integration. It is licensed under the standard MIT terms.
  167. //
  168. // The mips64 port was contributed by Imagination Technologies and is
  169. // licensed under the standard MIT terms.
  170. //
  171. // The powerpc port was also originally written by Richard Pennington,
  172. // and later supplemented and integrated by John Spencer. It is licensed
  173. // under the standard MIT terms.
  174. //
  175. // All other files which have no copyright comments are original works
  176. // produced specifically for use as part of this library, written either
  177. // by Rich Felker, the main author of the library, or by one or more
  178. // contibutors listed above. Details on authorship of individual files
  179. // can be found in the git version control history of the project. The
  180. // omission of copyright and license comments in each file is in the
  181. // interest of source tree size.
  182. //
  183. // In addition, permission is hereby granted for all public header files
  184. // (include/* and arch/*/bits/*) and crt files intended to be linked into
  185. // applications (crt/*, ldso/dlstart.c, and arch/*/crt_arch.h) to omit
  186. // the copyright notice and permission notice otherwise required by the
  187. // license, and to use these files without any requirement of
  188. // attribution. These files include substantial contributions from:
  189. //
  190. // Bobby Bingham
  191. // John Spencer
  192. // Nicholas J. Kain
  193. // Rich Felker
  194. // Richard Pennington
  195. // Stefan Kristiansson
  196. // Szabolcs Nagy
  197. //
  198. // all of whom have explicitly granted such permission.
  199. //
  200. // This file previously contained text expressing a belief that most of
  201. // the files covered by the above exception were sufficiently trivial not
  202. // to be subject to copyright, resulting in confusion over whether it
  203. // negated the permissions granted in the license. In the spirit of
  204. // permissive licensing, and of not having licensing issues being an
  205. // obstacle to adoption, that text has been removed.
  206. const ( /* copyright.c:194:1: */
  207. __musl__copyright__ = 0
  208. )
  209. const ( /* nameser.h:117:1: */
  210. ns_uop_delete = 0
  211. ns_uop_add = 1
  212. ns_uop_max = 2
  213. )
  214. const ( /* nameser.h:147:1: */
  215. ns_t_invalid = 0
  216. ns_t_a = 1
  217. ns_t_ns = 2
  218. ns_t_md = 3
  219. ns_t_mf = 4
  220. ns_t_cname = 5
  221. ns_t_soa = 6
  222. ns_t_mb = 7
  223. ns_t_mg = 8
  224. ns_t_mr = 9
  225. ns_t_null = 10
  226. ns_t_wks = 11
  227. ns_t_ptr = 12
  228. ns_t_hinfo = 13
  229. ns_t_minfo = 14
  230. ns_t_mx = 15
  231. ns_t_txt = 16
  232. ns_t_rp = 17
  233. ns_t_afsdb = 18
  234. ns_t_x25 = 19
  235. ns_t_isdn = 20
  236. ns_t_rt = 21
  237. ns_t_nsap = 22
  238. ns_t_nsap_ptr = 23
  239. ns_t_sig = 24
  240. ns_t_key = 25
  241. ns_t_px = 26
  242. ns_t_gpos = 27
  243. ns_t_aaaa = 28
  244. ns_t_loc = 29
  245. ns_t_nxt = 30
  246. ns_t_eid = 31
  247. ns_t_nimloc = 32
  248. ns_t_srv = 33
  249. ns_t_atma = 34
  250. ns_t_naptr = 35
  251. ns_t_kx = 36
  252. ns_t_cert = 37
  253. ns_t_a6 = 38
  254. ns_t_dname = 39
  255. ns_t_sink = 40
  256. ns_t_opt = 41
  257. ns_t_apl = 42
  258. ns_t_tkey = 249
  259. ns_t_tsig = 250
  260. ns_t_ixfr = 251
  261. ns_t_axfr = 252
  262. ns_t_mailb = 253
  263. ns_t_maila = 254
  264. ns_t_any = 255
  265. ns_t_zxfr = 256
  266. ns_t_max = 65536
  267. )
  268. const ( /* nameser.h:210:1: */
  269. ns_c_invalid = 0
  270. ns_c_in = 1
  271. ns_c_2 = 2
  272. ns_c_chaos = 3
  273. ns_c_hs = 4
  274. ns_c_none = 254
  275. ns_c_any = 255
  276. ns_c_max = 65536
  277. )
  278. const ( /* nameser.h:221:1: */
  279. ns_kt_rsa = 1
  280. ns_kt_dh = 2
  281. ns_kt_dsa = 3
  282. ns_kt_private = 254
  283. )
  284. const ( /* nameser.h:228:1: */
  285. cert_t_pkix = 1
  286. cert_t_spki = 2
  287. cert_t_pgp = 3
  288. cert_t_url = 253
  289. cert_t_oid = 254
  290. )
  291. const ( /* nameser.h:28:1: */
  292. ns_s_qd = 0
  293. ns_s_zn = 0
  294. ns_s_an = 1
  295. ns_s_pr = 1
  296. ns_s_ns = 2
  297. ns_s_ud = 2
  298. ns_s_ar = 3
  299. ns_s_max = 4
  300. )
  301. const ( /* nameser.h:75:1: */
  302. ns_f_qr = 0
  303. ns_f_opcode = 1
  304. ns_f_aa = 2
  305. ns_f_tc = 3
  306. ns_f_rd = 4
  307. ns_f_ra = 5
  308. ns_f_z = 6
  309. ns_f_ad = 7
  310. ns_f_cd = 8
  311. ns_f_rcode = 9
  312. ns_f_max = 10
  313. )
  314. const ( /* nameser.h:89:1: */
  315. ns_o_query = 0
  316. ns_o_iquery = 1
  317. ns_o_status = 2
  318. ns_o_notify = 4
  319. ns_o_update = 5
  320. ns_o_max = 6
  321. )
  322. const ( /* nameser.h:98:1: */
  323. ns_r_noerror = 0
  324. ns_r_formerr = 1
  325. ns_r_servfail = 2
  326. ns_r_nxdomain = 3
  327. ns_r_notimpl = 4
  328. ns_r_refused = 5
  329. ns_r_yxdomain = 6
  330. ns_r_yxrrset = 7
  331. ns_r_nxrrset = 8
  332. ns_r_notauth = 9
  333. ns_r_notzone = 10
  334. ns_r_max = 11
  335. ns_r_badvers = 16
  336. ns_r_badsig = 16
  337. ns_r_badkey = 17
  338. ns_r_badtime = 18
  339. )
  340. const ( /* pthread_impl.h:58:1: */
  341. DT_EXITING = 0
  342. DT_JOINABLE = 1
  343. DT_DETACHED = 2
  344. )
  345. type ptrdiff_t = int64 /* <builtin>:3:26 */
  346. type size_t = uint64 /* <builtin>:9:23 */
  347. type wchar_t = int32 /* <builtin>:15:24 */
  348. type uint16_t = uint16 /* alltypes.h:126:25 */
  349. type uint32_t = uint32 /* alltypes.h:131:25 */
  350. type uint64_t = uint64 /* alltypes.h:136:25 */
  351. func __bswap32(tls *TLS, __x uint32_t) uint32_t { /* endian.h:24:26: */
  352. return __x>>24 | __x>>8&uint32_t(0xff00) | __x<<8&uint32_t(0xff0000) | __x<<24
  353. }
  354. var table = [384]uint16{
  355. uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0),
  356. uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0),
  357. uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0),
  358. uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0),
  359. uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536),
  360. uint16((0x200/256 | 0x200*256) % 65536), uint16((0x320/256 | 0x320*256) % 65536), uint16((0x220/256 | 0x220*256) % 65536), uint16((0x220/256 | 0x220*256) % 65536), uint16((0x220/256 | 0x220*256) % 65536), uint16((0x220/256 | 0x220*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536),
  361. uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536),
  362. uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536),
  363. uint16((0x160/256 | 0x160*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536),
  364. uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536),
  365. uint16((0x8d8/256 | 0x8d8*256) % 65536), uint16((0x8d8/256 | 0x8d8*256) % 65536), uint16((0x8d8/256 | 0x8d8*256) % 65536), uint16((0x8d8/256 | 0x8d8*256) % 65536), uint16((0x8d8/256 | 0x8d8*256) % 65536), uint16((0x8d8/256 | 0x8d8*256) % 65536), uint16((0x8d8/256 | 0x8d8*256) % 65536), uint16((0x8d8/256 | 0x8d8*256) % 65536),
  366. uint16((0x8d8/256 | 0x8d8*256) % 65536), uint16((0x8d8/256 | 0x8d8*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536),
  367. uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x8d5/256 | 0x8d5*256) % 65536), uint16((0x8d5/256 | 0x8d5*256) % 65536), uint16((0x8d5/256 | 0x8d5*256) % 65536), uint16((0x8d5/256 | 0x8d5*256) % 65536), uint16((0x8d5/256 | 0x8d5*256) % 65536), uint16((0x8d5/256 | 0x8d5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536),
  368. uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536),
  369. uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536),
  370. uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x8c5/256 | 0x8c5*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536),
  371. uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x8d6/256 | 0x8d6*256) % 65536), uint16((0x8d6/256 | 0x8d6*256) % 65536), uint16((0x8d6/256 | 0x8d6*256) % 65536), uint16((0x8d6/256 | 0x8d6*256) % 65536), uint16((0x8d6/256 | 0x8d6*256) % 65536), uint16((0x8d6/256 | 0x8d6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536),
  372. uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536),
  373. uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536),
  374. uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x8c6/256 | 0x8c6*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x4c0/256 | 0x4c0*256) % 65536), uint16((0x200/256 | 0x200*256) % 65536),
  375. uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0),
  376. uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0),
  377. uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0),
  378. uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0), uint16(0),
  379. } /* __ctype_b_loc.c:9:29 */
  380. var ptable uintptr = 0 /* __ctype_b_loc.c:36:29 */
  381. func X__ctype_b_loc(tls *TLS) uintptr { /* __ctype_b_loc.c:38:22: */
  382. if __ccgo_strace {
  383. trc("tls=%v, (%v:)", tls, origin(2))
  384. }
  385. return uintptr(unsafe.Pointer(&ptable))
  386. }
  387. func __isspace(tls *TLS, _c int32) int32 { /* ctype.h:26:21: */
  388. return Bool32(_c == ' ' || uint32(_c)-uint32('\t') < uint32(5))
  389. }
  390. type __locale_struct = struct{ cat [6]uintptr } /* alltypes.h:343:9 */
  391. type locale_t = uintptr /* alltypes.h:343:32 */
  392. func Xisalnum(tls *TLS, c int32) int32 { /* isalnum.c:3:5: */
  393. if __ccgo_strace {
  394. trc("tls=%v c=%v, (%v:)", tls, c, origin(2))
  395. }
  396. return Bool32(func() int32 {
  397. if 0 != 0 {
  398. return Xisalpha(tls, c)
  399. }
  400. return Bool32(uint32(c)|uint32(32)-uint32('a') < uint32(26))
  401. }() != 0 || func() int32 {
  402. if 0 != 0 {
  403. return Xisdigit(tls, c)
  404. }
  405. return Bool32(uint32(c)-uint32('0') < uint32(10))
  406. }() != 0)
  407. }
  408. func X__isalnum_l(tls *TLS, c int32, l locale_t) int32 { /* isalnum.c:8:5: */
  409. if __ccgo_strace {
  410. trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2))
  411. }
  412. return Xisalnum(tls, c)
  413. }
  414. func Xisalpha(tls *TLS, c int32) int32 { /* isalpha.c:4:5: */
  415. if __ccgo_strace {
  416. trc("tls=%v c=%v, (%v:)", tls, c, origin(2))
  417. }
  418. return Bool32(uint32(c)|uint32(32)-uint32('a') < uint32(26))
  419. }
  420. func X__isalpha_l(tls *TLS, c int32, l locale_t) int32 { /* isalpha.c:9:5: */
  421. if __ccgo_strace {
  422. trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2))
  423. }
  424. return Xisalpha(tls, c)
  425. }
  426. func Xisdigit(tls *TLS, c int32) int32 { /* isdigit.c:4:5: */
  427. if __ccgo_strace {
  428. trc("tls=%v c=%v, (%v:)", tls, c, origin(2))
  429. }
  430. return Bool32(uint32(c)-uint32('0') < uint32(10))
  431. }
  432. func X__isdigit_l(tls *TLS, c int32, l locale_t) int32 { /* isdigit.c:9:5: */
  433. if __ccgo_strace {
  434. trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2))
  435. }
  436. return Xisdigit(tls, c)
  437. }
  438. func Xislower(tls *TLS, c int32) int32 { /* islower.c:4:5: */
  439. if __ccgo_strace {
  440. trc("tls=%v c=%v, (%v:)", tls, c, origin(2))
  441. }
  442. return Bool32(uint32(c)-uint32('a') < uint32(26))
  443. }
  444. func X__islower_l(tls *TLS, c int32, l locale_t) int32 { /* islower.c:9:5: */
  445. if __ccgo_strace {
  446. trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2))
  447. }
  448. return Xislower(tls, c)
  449. }
  450. func Xisprint(tls *TLS, c int32) int32 { /* isprint.c:4:5: */
  451. if __ccgo_strace {
  452. trc("tls=%v c=%v, (%v:)", tls, c, origin(2))
  453. }
  454. return Bool32(uint32(c)-uint32(0x20) < uint32(0x5f))
  455. }
  456. func X__builtin_isprint(tls *TLS, c int32) int32 { /* isprint.c:4:5: */
  457. if __ccgo_strace {
  458. trc("tls=%v c=%v, (%v:)", tls, c, origin(2))
  459. }
  460. return Bool32(uint32(c)-uint32(0x20) < uint32(0x5f))
  461. }
  462. func X__isprint_l(tls *TLS, c int32, l locale_t) int32 { /* isprint.c:9:5: */
  463. if __ccgo_strace {
  464. trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2))
  465. }
  466. return Xisprint(tls, c)
  467. }
  468. func Xisupper(tls *TLS, c int32) int32 { /* isupper.c:4:5: */
  469. if __ccgo_strace {
  470. trc("tls=%v c=%v, (%v:)", tls, c, origin(2))
  471. }
  472. return Bool32(uint32(c)-uint32('A') < uint32(26))
  473. }
  474. func X__isupper_l(tls *TLS, c int32, l locale_t) int32 { /* isupper.c:9:5: */
  475. if __ccgo_strace {
  476. trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2))
  477. }
  478. return Xisupper(tls, c)
  479. }
  480. func Xisxdigit(tls *TLS, c int32) int32 { /* isxdigit.c:3:5: */
  481. if __ccgo_strace {
  482. trc("tls=%v c=%v, (%v:)", tls, c, origin(2))
  483. }
  484. return Bool32(func() int32 {
  485. if 0 != 0 {
  486. return Xisdigit(tls, c)
  487. }
  488. return Bool32(uint32(c)-uint32('0') < uint32(10))
  489. }() != 0 || uint32(c)|uint32(32)-uint32('a') < uint32(6))
  490. }
  491. func X__isxdigit_l(tls *TLS, c int32, l locale_t) int32 { /* isxdigit.c:8:5: */
  492. if __ccgo_strace {
  493. trc("tls=%v c=%v l=%v, (%v:)", tls, c, l, origin(2))
  494. }
  495. return Xisxdigit(tls, c)
  496. }
  497. type off_t = int64 /* alltypes.h:162:16 */
  498. type ino_t = uint64 /* alltypes.h:167:25 */
  499. type dirent = struct {
  500. d_ino ino_t
  501. d_off off_t
  502. d_reclen uint16
  503. d_type uint8
  504. d_name [256]int8
  505. _ [5]byte
  506. } /* dirent.h:5:1 */
  507. type __dirstream = struct {
  508. tell off_t
  509. fd int32
  510. buf_pos int32
  511. buf_end int32
  512. lock [1]int32
  513. buf [2048]int8
  514. } /* dirent.h:20:9 */
  515. type DIR = __dirstream /* dirent.h:20:28 */
  516. type ssize_t = int64 /* alltypes.h:65:15 */
  517. type intptr_t = int64 /* alltypes.h:70:15 */
  518. type pid_t = int32 /* alltypes.h:235:13 */
  519. type uid_t = uint32 /* alltypes.h:245:18 */
  520. type gid_t = uint32 /* alltypes.h:250:18 */
  521. type useconds_t = uint32 /* alltypes.h:260:18 */
  522. type div_t = struct {
  523. quot int32
  524. rem int32
  525. } /* stdlib.h:62:35 */
  526. type ldiv_t = struct {
  527. quot int64
  528. rem int64
  529. } /* stdlib.h:63:36 */
  530. type lldiv_t = struct {
  531. quot int64
  532. rem int64
  533. } /* stdlib.h:64:41 */
  534. func Xclosedir(tls *TLS, dir uintptr) int32 { /* closedir.c:6:5: */
  535. if __ccgo_strace {
  536. trc("tls=%v dir=%v, (%v:)", tls, dir, origin(2))
  537. }
  538. var ret int32 = Xclose(tls, (*DIR)(unsafe.Pointer(dir)).fd)
  539. Xfree(tls, dir)
  540. return ret
  541. }
  542. type mode_t = uint32 /* alltypes.h:152:18 */
  543. type iovec = struct {
  544. iov_base uintptr
  545. iov_len size_t
  546. } /* alltypes.h:355:1 */
  547. type flock = struct {
  548. l_type int16
  549. l_whence int16
  550. _ [4]byte
  551. l_start off_t
  552. l_len off_t
  553. l_pid pid_t
  554. _ [4]byte
  555. } /* fcntl.h:24:1 */
  556. type file_handle = struct {
  557. _ [0]uint32
  558. handle_bytes uint32
  559. handle_type int32
  560. } /* fcntl.h:167:1 */
  561. type f_owner_ex = struct {
  562. __type int32
  563. pid pid_t
  564. } /* fcntl.h:172:1 */
  565. type syscall_arg_t = int64 /* syscall.h:22:14 */
  566. func Xopendir(tls *TLS, name uintptr) uintptr { /* opendir.c:8:5: */
  567. if __ccgo_strace {
  568. trc("tls=%v name=%v, (%v:)", tls, name, origin(2))
  569. }
  570. panic(todo(""))
  571. // var fd int32
  572. // var dir uintptr
  573. //
  574. // if AssignInt32(&fd, Xopen(tls, name, 00|0200000|02000000, 0)) < 0 {
  575. // return uintptr(0)
  576. // }
  577. // if !(int32(AssignUintptr(&dir, Xcalloc(tls, uint64(1), uint64(unsafe.Sizeof(DIR{}))))) != 0) {
  578. // X__syscall1(tls, int64(3), int64(fd))
  579. // return uintptr(0)
  580. // }
  581. // (*DIR)(unsafe.Pointer(dir)).fd = fd
  582. // return dir
  583. }
  584. type max_align_t = struct {
  585. __ll int64
  586. __ld float64
  587. } /* alltypes.h:41:54 */
  588. type dirstream_buf_alignment_check = [1]int8 /* readdir.c:7:14 */
  589. func Xreaddir(tls *TLS, dir uintptr) uintptr { /* readdir.c:10:15: */
  590. if __ccgo_strace {
  591. trc("tls=%v dir=%v, (%v:)", tls, dir, origin(2))
  592. }
  593. panic(todo(""))
  594. // var de uintptr
  595. //
  596. // if (*DIR)(unsafe.Pointer(dir)).buf_pos >= (*DIR)(unsafe.Pointer(dir)).buf_end {
  597. // var len int32 = int32(X__syscall3(tls, int64(217), int64((*DIR)(unsafe.Pointer(dir)).fd), int64(dir+24), int64(unsafe.Sizeof([2048]int8{}))))
  598. // if len <= 0 {
  599. // if len < 0 && len != -2 {
  600. // *(*int32)(unsafe.Pointer(X___errno_location(tls))) = -len
  601. // }
  602. // return uintptr(0)
  603. // }
  604. // (*DIR)(unsafe.Pointer(dir)).buf_end = len
  605. // (*DIR)(unsafe.Pointer(dir)).buf_pos = 0
  606. // }
  607. // de = dir + 24 + uintptr((*DIR)(unsafe.Pointer(dir)).buf_pos)
  608. // *(*int32)(unsafe.Pointer(dir + 12)) += int32((*dirent)(unsafe.Pointer(de)).d_reclen)
  609. // (*DIR)(unsafe.Pointer(dir)).tell = (*dirent)(unsafe.Pointer(de)).d_off
  610. // return de
  611. }
  612. type uintptr_t = uint64 /* alltypes.h:55:24 */
  613. type int8_t = int8 /* alltypes.h:96:25 */
  614. type int16_t = int16 /* alltypes.h:101:25 */
  615. type int32_t = int32 /* alltypes.h:106:25 */
  616. type int64_t = int64 /* alltypes.h:111:25 */
  617. type intmax_t = int64 /* alltypes.h:116:25 */
  618. type uint8_t = uint8 /* alltypes.h:121:25 */
  619. type uintmax_t = uint64 /* alltypes.h:146:25 */
  620. type int_fast8_t = int8_t /* stdint.h:22:16 */
  621. type int_fast64_t = int64_t /* stdint.h:23:17 */
  622. type int_least8_t = int8_t /* stdint.h:25:17 */
  623. type int_least16_t = int16_t /* stdint.h:26:17 */
  624. type int_least32_t = int32_t /* stdint.h:27:17 */
  625. type int_least64_t = int64_t /* stdint.h:28:17 */
  626. type uint_fast8_t = uint8_t /* stdint.h:30:17 */
  627. type uint_fast64_t = uint64_t /* stdint.h:31:18 */
  628. type uint_least8_t = uint8_t /* stdint.h:33:18 */
  629. type uint_least16_t = uint16_t /* stdint.h:34:18 */
  630. type uint_least32_t = uint32_t /* stdint.h:35:18 */
  631. type uint_least64_t = uint64_t /* stdint.h:36:18 */
  632. type int_fast16_t = int32_t /* stdint.h:1:17 */
  633. type int_fast32_t = int32_t /* stdint.h:2:17 */
  634. type uint_fast16_t = uint32_t /* stdint.h:3:18 */
  635. type uint_fast32_t = uint32_t /* stdint.h:4:18 */
  636. type _IO_FILE = struct {
  637. flags uint32
  638. _ [4]byte
  639. rpos uintptr
  640. rend uintptr
  641. close uintptr
  642. wend uintptr
  643. wpos uintptr
  644. mustbezero_1 uintptr
  645. wbase uintptr
  646. read uintptr
  647. write uintptr
  648. seek uintptr
  649. buf uintptr
  650. buf_size size_t
  651. prev uintptr
  652. next uintptr
  653. fd int32
  654. pipe_pid int32
  655. lockcount int64
  656. mode int32
  657. lock int32
  658. lbf int32
  659. _ [4]byte
  660. cookie uintptr
  661. off off_t
  662. getln_buf uintptr
  663. mustbezero_2 uintptr
  664. shend uintptr
  665. shlim off_t
  666. shcnt off_t
  667. prev_locked uintptr
  668. next_locked uintptr
  669. locale uintptr
  670. } /* alltypes.h:320:9 */
  671. type FILE = _IO_FILE /* alltypes.h:320:25 */
  672. type va_list = uintptr /* alltypes.h:326:27 */
  673. type _G_fpos64_t = struct {
  674. _ [0]uint64
  675. __opaque [16]int8
  676. } /* stdio.h:54:9 */
  677. type fpos_t = _G_fpos64_t /* stdio.h:58:3 */
  678. type float_t = float32 /* alltypes.h:29:15 */
  679. type double_t = float64 /* alltypes.h:34:16 */
  680. func __FLOAT_BITS(tls *TLS, __f float32) uint32 { /* math.h:55:26: */
  681. bp := tls.Alloc(4)
  682. defer tls.Free(4)
  683. // var __u struct {__f float32;} at bp, 4
  684. *(*float32)(unsafe.Pointer(bp)) = __f
  685. return *(*uint32)(unsafe.Pointer(bp))
  686. }
  687. func __DOUBLE_BITS(tls *TLS, __f float64) uint64 { /* math.h:61:36: */
  688. bp := tls.Alloc(8)
  689. defer tls.Free(8)
  690. // var __u struct {__f float64;} at bp, 8
  691. *(*float64)(unsafe.Pointer(bp)) = __f
  692. return *(*uint64)(unsafe.Pointer(bp))
  693. }
  694. type __pthread = struct {
  695. self uintptr
  696. dtv uintptr
  697. prev uintptr
  698. next uintptr
  699. sysinfo uintptr_t
  700. canary uintptr_t
  701. canary2 uintptr_t
  702. tid int32
  703. errno_val int32
  704. detach_state int32
  705. cancel int32
  706. canceldisable uint8
  707. cancelasync uint8
  708. tsd_used uint8 /* unsigned char tsd_used: 1, unsigned char dlerror_flag: 1 */
  709. _ [5]byte
  710. map_base uintptr
  711. map_size size_t
  712. stack uintptr
  713. stack_size size_t
  714. guard_size size_t
  715. result uintptr
  716. cancelbuf uintptr
  717. tsd uintptr
  718. robust_list struct {
  719. head uintptr
  720. off int64
  721. pending uintptr
  722. }
  723. timer_id int32
  724. _ [4]byte
  725. locale locale_t
  726. killlock [1]int32
  727. _ [4]byte
  728. dlerror_buf uintptr
  729. stdio_locks uintptr
  730. canary_at_end uintptr_t
  731. dtv_copy uintptr
  732. } /* alltypes.h:273:9 */
  733. func scanexp(tls *TLS, f uintptr, pok int32) int64 { /* floatscan.c:37:18: */
  734. var c int32
  735. var x int32
  736. var y int64
  737. var neg int32 = 0
  738. c = func() int32 {
  739. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  740. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  741. }
  742. return X__shgetc(tls, f)
  743. }()
  744. if c == '+' || c == '-' {
  745. neg = Bool32(c == '-')
  746. c = func() int32 {
  747. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  748. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  749. }
  750. return X__shgetc(tls, f)
  751. }()
  752. if uint32(c-'0') >= 10 && pok != 0 {
  753. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  754. (*FILE)(unsafe.Pointer(f)).rpos--
  755. } else {
  756. }
  757. }
  758. }
  759. if uint32(c-'0') >= 10 {
  760. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  761. (*FILE)(unsafe.Pointer(f)).rpos--
  762. } else {
  763. }
  764. return -0x7fffffffffffffff - int64(1)
  765. }
  766. for x = 0; uint32(c-'0') < 10 && x < 0x7fffffff/10; c = func() int32 {
  767. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  768. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  769. }
  770. return X__shgetc(tls, f)
  771. }() {
  772. x = 10*x + c - '0'
  773. }
  774. for y = int64(x); uint32(c-'0') < 10 && y < 0x7fffffffffffffff/int64(100); c = func() int32 {
  775. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  776. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  777. }
  778. return X__shgetc(tls, f)
  779. }() {
  780. y = int64(10)*y + int64(c) - int64('0')
  781. }
  782. for ; uint32(c-'0') < 10; c = func() int32 {
  783. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  784. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  785. }
  786. return X__shgetc(tls, f)
  787. }() {
  788. }
  789. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  790. (*FILE)(unsafe.Pointer(f)).rpos--
  791. } else {
  792. }
  793. if neg != 0 {
  794. return -y
  795. }
  796. return y
  797. }
  798. func decfloat(tls *TLS, f uintptr, c int32, bits int32, emin int32, sign int32, pok int32) float64 { /* floatscan.c:64:20: */
  799. bp := tls.Alloc(512)
  800. defer tls.Free(512)
  801. // var x [128]uint32_t at bp, 512
  802. var i int32
  803. var j int32
  804. var k int32
  805. var a int32
  806. var z int32
  807. var lrp int64 = int64(0)
  808. var dc int64 = int64(0)
  809. var e10 int64 = int64(0)
  810. var lnz int32 = 0
  811. var gotdig int32 = 0
  812. var gotrad int32 = 0
  813. var rp int32
  814. var e2 int32
  815. var emax int32 = -emin - bits + 3
  816. var denormal int32 = 0
  817. var y float64
  818. var frac float64 = float64(0)
  819. var bias float64 = float64(0)
  820. j = 0
  821. k = 0
  822. // Don't let leading zeros consume buffer space
  823. for ; c == '0'; c = func() int32 {
  824. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  825. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  826. }
  827. return X__shgetc(tls, f)
  828. }() {
  829. gotdig = 1
  830. }
  831. if c == '.' {
  832. gotrad = 1
  833. for c = func() int32 {
  834. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  835. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  836. }
  837. return X__shgetc(tls, f)
  838. }(); c == '0'; c = func() int32 {
  839. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  840. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  841. }
  842. return X__shgetc(tls, f)
  843. }() {
  844. gotdig = 1
  845. lrp--
  846. }
  847. }
  848. *(*uint32_t)(unsafe.Pointer(bp)) = uint32_t(0)
  849. for ; uint32(c-'0') < 10 || c == '.'; c = func() int32 {
  850. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  851. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  852. }
  853. return X__shgetc(tls, f)
  854. }() {
  855. if c == '.' {
  856. if gotrad != 0 {
  857. break
  858. }
  859. gotrad = 1
  860. lrp = dc
  861. } else if k < 128-3 {
  862. dc++
  863. if c != '0' {
  864. lnz = int32(dc)
  865. }
  866. if j != 0 {
  867. *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))*uint32_t(10) + uint32_t(c) - uint32_t('0')
  868. } else {
  869. *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = uint32_t(c - '0')
  870. }
  871. if PreIncInt32(&j, 1) == 9 {
  872. k++
  873. j = 0
  874. }
  875. gotdig = 1
  876. } else {
  877. dc++
  878. if c != '0' {
  879. lnz = (128 - 4) * 9
  880. *(*uint32_t)(unsafe.Pointer(bp + 124*4)) |= uint32_t(1)
  881. }
  882. }
  883. }
  884. if !(gotrad != 0) {
  885. lrp = dc
  886. }
  887. if gotdig != 0 && c|32 == 'e' {
  888. e10 = scanexp(tls, f, pok)
  889. if e10 == -0x7fffffffffffffff-int64(1) {
  890. if pok != 0 {
  891. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  892. (*FILE)(unsafe.Pointer(f)).rpos--
  893. } else {
  894. }
  895. } else {
  896. X__shlim(tls, f, int64(0))
  897. return float64(0)
  898. }
  899. e10 = int64(0)
  900. }
  901. lrp = lrp + e10
  902. } else if c >= 0 {
  903. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  904. (*FILE)(unsafe.Pointer(f)).rpos--
  905. } else {
  906. }
  907. }
  908. if !(gotdig != 0) {
  909. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22
  910. X__shlim(tls, f, int64(0))
  911. return float64(0)
  912. }
  913. // Handle zero specially to avoid nasty special cases later
  914. if !(int32(*(*uint32_t)(unsafe.Pointer(bp))) != 0) {
  915. return float64(sign) * 0.0
  916. }
  917. // Optimize small integers (w/no exponent) and over/under-flow
  918. if lrp == dc && dc < int64(10) && (bits > 30 || *(*uint32_t)(unsafe.Pointer(bp))>>bits == uint32_t(0)) {
  919. return float64(sign) * float64(*(*uint32_t)(unsafe.Pointer(bp)))
  920. }
  921. if lrp > int64(-emin/2) {
  922. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  923. return float64(sign) * 1.79769313486231570815e+308 * 1.79769313486231570815e+308
  924. }
  925. if lrp < int64(emin-2*53) {
  926. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  927. return float64(sign) * 2.22507385850720138309e-308 * 2.22507385850720138309e-308
  928. }
  929. // Align incomplete final B1B digit
  930. if j != 0 {
  931. for ; j < 9; j++ {
  932. *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) *= uint32_t(10)
  933. }
  934. k++
  935. j = 0
  936. }
  937. a = 0
  938. z = k
  939. e2 = 0
  940. rp = int32(lrp)
  941. // Optimize small to mid-size integers (even in exp. notation)
  942. if lnz < 9 && lnz <= rp && rp < 18 {
  943. if rp == 9 {
  944. return float64(sign) * float64(*(*uint32_t)(unsafe.Pointer(bp)))
  945. }
  946. if rp < 9 {
  947. return float64(sign) * float64(*(*uint32_t)(unsafe.Pointer(bp))) / float64(_sp10s[8-rp])
  948. }
  949. var bitlim int32 = bits - 3*(rp-9)
  950. if bitlim > 30 || *(*uint32_t)(unsafe.Pointer(bp))>>bitlim == uint32_t(0) {
  951. return float64(sign) * float64(*(*uint32_t)(unsafe.Pointer(bp))) * float64(_sp10s[rp-10])
  952. }
  953. }
  954. // Drop trailing zeros
  955. for ; !(int32(*(*uint32_t)(unsafe.Pointer(bp + uintptr(z-1)*4))) != 0); z-- {
  956. }
  957. // Align radix point to B1B digit boundary
  958. if rp%9 != 0 {
  959. var rpm9 int32
  960. if rp >= 0 {
  961. rpm9 = rp % 9
  962. } else {
  963. rpm9 = rp%9 + 9
  964. }
  965. var p10 int32 = _sp10s[8-rpm9]
  966. var carry uint32_t = uint32_t(0)
  967. for k = a; k != z; k++ {
  968. var tmp uint32_t = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) % uint32_t(p10)
  969. *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))/uint32_t(p10) + carry
  970. carry = uint32_t(1000000000/p10) * tmp
  971. if k == a && !(int32(*(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))) != 0) {
  972. a = (a + 1) & (128 - 1)
  973. rp = rp - 9
  974. }
  975. }
  976. if carry != 0 {
  977. *(*uint32_t)(unsafe.Pointer(bp + uintptr(PostIncInt32(&z, 1))*4)) = carry
  978. }
  979. rp = rp + (9 - rpm9)
  980. }
  981. // Upscale until desired number of bits are left of radix point
  982. for rp < 9*2 || rp == 9*2 && *(*uint32_t)(unsafe.Pointer(bp + uintptr(a)*4)) < _sth[0] {
  983. var carry uint32_t = uint32_t(0)
  984. e2 = e2 - 29
  985. for k = (z - 1) & (128 - 1); ; k = (k - 1) & (128 - 1) {
  986. var tmp uint64_t = uint64_t(*(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)))<<29 + uint64_t(carry)
  987. if tmp > uint64(1000000000) {
  988. carry = uint32_t(tmp / uint64(1000000000))
  989. *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = uint32_t(tmp % uint64(1000000000))
  990. } else {
  991. carry = uint32_t(0)
  992. *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = uint32_t(tmp)
  993. }
  994. if k == (z-1)&(128-1) && k != a && !(int32(*(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))) != 0) {
  995. z = k
  996. }
  997. if k == a {
  998. break
  999. }
  1000. }
  1001. if carry != 0 {
  1002. rp = rp + 9
  1003. a = (a - 1) & (128 - 1)
  1004. if a == z {
  1005. z = (z - 1) & (128 - 1)
  1006. *(*uint32_t)(unsafe.Pointer(bp + uintptr((z-1)&(128-1))*4)) |= *(*uint32_t)(unsafe.Pointer(bp + uintptr(z)*4))
  1007. }
  1008. *(*uint32_t)(unsafe.Pointer(bp + uintptr(a)*4)) = carry
  1009. }
  1010. }
  1011. // Downscale until exactly number of bits are left of radix point
  1012. for {
  1013. var carry uint32_t = uint32_t(0)
  1014. var sh int32 = 1
  1015. for i = 0; i < 2; i++ {
  1016. k = (a + i) & (128 - 1)
  1017. if k == z || *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) < _sth[i] {
  1018. i = 2
  1019. break
  1020. }
  1021. if *(*uint32_t)(unsafe.Pointer(bp + uintptr((a+i)&(128-1))*4)) > _sth[i] {
  1022. break
  1023. }
  1024. }
  1025. if i == 2 && rp == 9*2 {
  1026. break
  1027. }
  1028. // FIXME: find a way to compute optimal sh
  1029. if rp > 9+9*2 {
  1030. sh = 9
  1031. }
  1032. e2 = e2 + sh
  1033. for k = a; k != z; k = (k + 1) & (128 - 1) {
  1034. var tmp uint32_t = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) & uint32_t(int32(1)<<sh-1)
  1035. *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))>>sh + carry
  1036. carry = uint32_t(int32(1000000000)>>sh) * tmp
  1037. if k == a && !(int32(*(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))) != 0) {
  1038. a = (a + 1) & (128 - 1)
  1039. i--
  1040. rp = rp - 9
  1041. }
  1042. }
  1043. if carry != 0 {
  1044. if (z+1)&(128-1) != a {
  1045. *(*uint32_t)(unsafe.Pointer(bp + uintptr(z)*4)) = carry
  1046. z = (z + 1) & (128 - 1)
  1047. } else {
  1048. *(*uint32_t)(unsafe.Pointer(bp + uintptr((z-1)&(128-1))*4)) |= uint32_t(1)
  1049. }
  1050. }
  1051. }
  1052. // Assemble desired bits into floating point variable
  1053. for y = float64(AssignInt32(&i, 0)); i < 2; i++ {
  1054. if (a+i)&(128-1) == z {
  1055. *(*uint32_t)(unsafe.Pointer(bp + uintptr(AssignInt32(&z, (z+1)&(128-1))-1)*4)) = uint32_t(0)
  1056. }
  1057. y = 1000000000.0*y + float64(*(*uint32_t)(unsafe.Pointer(bp + uintptr((a+i)&(128-1))*4)))
  1058. }
  1059. y = y * float64(sign)
  1060. // Limit precision for denormal results
  1061. if bits > 53+e2-emin {
  1062. bits = 53 + e2 - emin
  1063. if bits < 0 {
  1064. bits = 0
  1065. }
  1066. denormal = 1
  1067. }
  1068. // Calculate bias term to force rounding, move out lower bits
  1069. if bits < 53 {
  1070. bias = Xcopysignl(tls, Xscalbn(tls, float64(1), 2*53-bits-1), y)
  1071. frac = Xfmodl(tls, y, Xscalbn(tls, float64(1), 53-bits))
  1072. y = y - frac
  1073. y = y + bias
  1074. }
  1075. // Process tail of decimal input so it can affect rounding
  1076. if (a+i)&(128-1) != z {
  1077. var t uint32_t = *(*uint32_t)(unsafe.Pointer(bp + uintptr((a+i)&(128-1))*4))
  1078. if t < uint32_t(500000000) && (t != 0 || (a+i+1)&(128-1) != z) {
  1079. frac = frac + 0.25*float64(sign)
  1080. } else if t > uint32_t(500000000) {
  1081. frac = frac + 0.75*float64(sign)
  1082. } else if t == uint32_t(500000000) {
  1083. if (a+i+1)&(128-1) == z {
  1084. frac = frac + 0.5*float64(sign)
  1085. } else {
  1086. frac = frac + 0.75*float64(sign)
  1087. }
  1088. }
  1089. if 53-bits >= 2 && !(Xfmodl(tls, frac, float64(1)) != 0) {
  1090. frac += 1
  1091. }
  1092. }
  1093. y = y + frac
  1094. y = y - bias
  1095. if (e2+53)&0x7fffffff > emax-5 {
  1096. if Xfabsl(tls, y) >= float64(float64(2))/2.22044604925031308085e-16 {
  1097. if denormal != 0 && bits == 53+e2-emin {
  1098. denormal = 0
  1099. }
  1100. y = y * 0.5
  1101. e2++
  1102. }
  1103. if e2+53 > emax || denormal != 0 && frac != 0 {
  1104. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  1105. }
  1106. }
  1107. return Xscalbnl(tls, y, e2)
  1108. }
  1109. var _sth = [2]uint32_t{uint32_t(9007199), uint32_t(254740991)} /* floatscan.c:67:24 */
  1110. var _sp10s = [8]int32{10, 100, 1000, 10000,
  1111. 100000, 1000000, 10000000, 100000000} /* floatscan.c:80:19 */
  1112. func hexfloat(tls *TLS, f uintptr, bits int32, emin int32, sign int32, pok int32) float64 { /* floatscan.c:315:20: */
  1113. var x uint32_t = uint32_t(0)
  1114. var y float64 = float64(0)
  1115. var scale float64 = float64(1)
  1116. var bias float64 = float64(0)
  1117. var gottail int32 = 0
  1118. var gotrad int32 = 0
  1119. var gotdig int32 = 0
  1120. var rp int64 = int64(0)
  1121. var dc int64 = int64(0)
  1122. var e2 int64 = int64(0)
  1123. var d int32
  1124. var c int32
  1125. c = func() int32 {
  1126. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1127. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1128. }
  1129. return X__shgetc(tls, f)
  1130. }()
  1131. // Skip leading zeros
  1132. for ; c == '0'; c = func() int32 {
  1133. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1134. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1135. }
  1136. return X__shgetc(tls, f)
  1137. }() {
  1138. gotdig = 1
  1139. }
  1140. if c == '.' {
  1141. gotrad = 1
  1142. c = func() int32 {
  1143. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1144. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1145. }
  1146. return X__shgetc(tls, f)
  1147. }()
  1148. // Count zeros after the radix point before significand
  1149. rp = int64(0)
  1150. __1:
  1151. if !(c == '0') {
  1152. goto __3
  1153. }
  1154. gotdig = 1
  1155. goto __2
  1156. __2:
  1157. c = func() int32 {
  1158. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1159. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1160. }
  1161. return X__shgetc(tls, f)
  1162. }()
  1163. rp--
  1164. goto __1
  1165. goto __3
  1166. __3:
  1167. }
  1168. for ; uint32(c-'0') < 10 || uint32(c|32-'a') < 6 || c == '.'; c = func() int32 {
  1169. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1170. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1171. }
  1172. return X__shgetc(tls, f)
  1173. }() {
  1174. if c == '.' {
  1175. if gotrad != 0 {
  1176. break
  1177. }
  1178. rp = dc
  1179. gotrad = 1
  1180. } else {
  1181. gotdig = 1
  1182. if c > '9' {
  1183. d = c | 32 + 10 - 'a'
  1184. } else {
  1185. d = c - '0'
  1186. }
  1187. if dc < int64(8) {
  1188. x = x*uint32_t(16) + uint32_t(d)
  1189. } else if dc < int64(53/4+1) {
  1190. y = y + float64(d)*AssignDivFloat64(&scale, float64(16))
  1191. } else if d != 0 && !(gottail != 0) {
  1192. y = y + 0.5*scale
  1193. gottail = 1
  1194. }
  1195. dc++
  1196. }
  1197. }
  1198. if !(gotdig != 0) {
  1199. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  1200. (*FILE)(unsafe.Pointer(f)).rpos--
  1201. } else {
  1202. }
  1203. if pok != 0 {
  1204. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  1205. (*FILE)(unsafe.Pointer(f)).rpos--
  1206. } else {
  1207. }
  1208. if gotrad != 0 {
  1209. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  1210. (*FILE)(unsafe.Pointer(f)).rpos--
  1211. } else {
  1212. }
  1213. }
  1214. } else {
  1215. X__shlim(tls, f, int64(0))
  1216. }
  1217. return float64(sign) * 0.0
  1218. }
  1219. if !(gotrad != 0) {
  1220. rp = dc
  1221. }
  1222. for dc < int64(8) {
  1223. x = x * uint32_t(16)
  1224. dc++
  1225. }
  1226. if c|32 == 'p' {
  1227. e2 = scanexp(tls, f, pok)
  1228. if e2 == -0x7fffffffffffffff-int64(1) {
  1229. if pok != 0 {
  1230. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  1231. (*FILE)(unsafe.Pointer(f)).rpos--
  1232. } else {
  1233. }
  1234. } else {
  1235. X__shlim(tls, f, int64(0))
  1236. return float64(0)
  1237. }
  1238. e2 = int64(0)
  1239. }
  1240. } else {
  1241. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  1242. (*FILE)(unsafe.Pointer(f)).rpos--
  1243. } else {
  1244. }
  1245. }
  1246. e2 = e2 + (int64(4)*rp - int64(32))
  1247. if !(x != 0) {
  1248. return float64(sign) * 0.0
  1249. }
  1250. if e2 > int64(-emin) {
  1251. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  1252. return float64(sign) * 1.79769313486231570815e+308 * 1.79769313486231570815e+308
  1253. }
  1254. if e2 < int64(emin-2*53) {
  1255. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  1256. return float64(sign) * 2.22507385850720138309e-308 * 2.22507385850720138309e-308
  1257. }
  1258. for x < 0x80000000 {
  1259. if y >= 0.5 {
  1260. x = x + (x + uint32_t(1))
  1261. y = y + (y - float64(1))
  1262. } else {
  1263. x = x + x
  1264. y = y + y
  1265. }
  1266. e2--
  1267. }
  1268. if int64(bits) > int64(32)+e2-int64(emin) {
  1269. bits = int32(int64(32) + e2 - int64(emin))
  1270. if bits < 0 {
  1271. bits = 0
  1272. }
  1273. }
  1274. if bits < 53 {
  1275. bias = Xcopysignl(tls, Xscalbn(tls, float64(1), 32+53-bits-1), float64(sign))
  1276. }
  1277. if bits < 32 && y != 0 && !(x&uint32_t(1) != 0) {
  1278. x++
  1279. y = float64(0)
  1280. }
  1281. y = bias + float64(sign)*float64(x) + float64(sign)*y
  1282. y = y - bias
  1283. if !(y != 0) {
  1284. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  1285. }
  1286. return Xscalbnl(tls, y, int32(e2))
  1287. }
  1288. func X__floatscan(tls *TLS, f uintptr, prec int32, pok int32) float64 { /* floatscan.c:427:13: */
  1289. if __ccgo_strace {
  1290. trc("tls=%v f=%v prec=%v pok=%v, (%v:)", tls, f, prec, pok, origin(2))
  1291. }
  1292. var sign int32 = 1
  1293. var i size_t
  1294. var bits int32
  1295. var emin int32
  1296. var c int32
  1297. switch prec {
  1298. case 0:
  1299. bits = 24
  1300. emin = -125 - bits
  1301. break
  1302. case 1:
  1303. bits = 53
  1304. emin = -1021 - bits
  1305. break
  1306. case 2:
  1307. bits = 53
  1308. emin = -1021 - bits
  1309. break
  1310. default:
  1311. return float64(0)
  1312. }
  1313. for __isspace(tls, AssignInt32(&c, func() int32 {
  1314. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1315. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1316. }
  1317. return X__shgetc(tls, f)
  1318. }())) != 0 {
  1319. }
  1320. if c == '+' || c == '-' {
  1321. sign = sign - 2*Bool32(c == '-')
  1322. c = func() int32 {
  1323. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1324. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1325. }
  1326. return X__shgetc(tls, f)
  1327. }()
  1328. }
  1329. for i = uint64(0); i < uint64(8) && c|32 == int32(*(*int8)(unsafe.Pointer(ts /* "infinity" */ + uintptr(i)))); i++ {
  1330. if i < uint64(7) {
  1331. c = func() int32 {
  1332. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1333. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1334. }
  1335. return X__shgetc(tls, f)
  1336. }()
  1337. }
  1338. }
  1339. if i == uint64(3) || i == uint64(8) || i > uint64(3) && pok != 0 {
  1340. if i != uint64(8) {
  1341. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  1342. (*FILE)(unsafe.Pointer(f)).rpos--
  1343. } else {
  1344. }
  1345. if pok != 0 {
  1346. for ; i > uint64(3); i-- {
  1347. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  1348. (*FILE)(unsafe.Pointer(f)).rpos--
  1349. } else {
  1350. }
  1351. }
  1352. }
  1353. }
  1354. return float64(float32(sign) * X__builtin_inff(tls))
  1355. }
  1356. if !(i != 0) {
  1357. for i = uint64(0); i < uint64(3) && c|32 == int32(*(*int8)(unsafe.Pointer(ts + 9 /* "nan" */ + uintptr(i)))); i++ {
  1358. if i < uint64(2) {
  1359. c = func() int32 {
  1360. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1361. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1362. }
  1363. return X__shgetc(tls, f)
  1364. }()
  1365. }
  1366. }
  1367. }
  1368. if i == uint64(3) {
  1369. if func() int32 {
  1370. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1371. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1372. }
  1373. return X__shgetc(tls, f)
  1374. }() != '(' {
  1375. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  1376. (*FILE)(unsafe.Pointer(f)).rpos--
  1377. } else {
  1378. }
  1379. return float64(X__builtin_nanf(tls, ts+13))
  1380. }
  1381. for i = uint64(1); ; i++ {
  1382. c = func() int32 {
  1383. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1384. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1385. }
  1386. return X__shgetc(tls, f)
  1387. }()
  1388. if uint32(c-'0') < 10 || uint32(c-'A') < 26 || uint32(c-'a') < 26 || c == '_' {
  1389. continue
  1390. }
  1391. if c == ')' {
  1392. return float64(X__builtin_nanf(tls, ts+13))
  1393. }
  1394. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  1395. (*FILE)(unsafe.Pointer(f)).rpos--
  1396. } else {
  1397. }
  1398. if !(pok != 0) {
  1399. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22
  1400. X__shlim(tls, f, int64(0))
  1401. return float64(0)
  1402. }
  1403. for PostDecUint64(&i, 1) != 0 {
  1404. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  1405. (*FILE)(unsafe.Pointer(f)).rpos--
  1406. } else {
  1407. }
  1408. }
  1409. return float64(X__builtin_nanf(tls, ts+13))
  1410. }
  1411. return float64(X__builtin_nanf(tls, ts+13))
  1412. }
  1413. if i != 0 {
  1414. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  1415. (*FILE)(unsafe.Pointer(f)).rpos--
  1416. } else {
  1417. }
  1418. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22
  1419. X__shlim(tls, f, int64(0))
  1420. return float64(0)
  1421. }
  1422. if c == '0' {
  1423. c = func() int32 {
  1424. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1425. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1426. }
  1427. return X__shgetc(tls, f)
  1428. }()
  1429. if c|32 == 'x' {
  1430. return hexfloat(tls, f, bits, emin, sign, pok)
  1431. }
  1432. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  1433. (*FILE)(unsafe.Pointer(f)).rpos--
  1434. } else {
  1435. }
  1436. c = '0'
  1437. }
  1438. return decfloat(tls, f, c, bits, emin, sign, pok)
  1439. }
  1440. // Lookup table for digit values. -1==255>=36 -> invalid
  1441. var table1 = [257]uint8{Uint8FromInt32(-1),
  1442. Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1),
  1443. Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1),
  1444. Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1),
  1445. uint8(0), uint8(1), uint8(2), uint8(3), uint8(4), uint8(5), uint8(6), uint8(7), uint8(8), uint8(9), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1),
  1446. Uint8FromInt32(-1), uint8(10), uint8(11), uint8(12), uint8(13), uint8(14), uint8(15), uint8(16), uint8(17), uint8(18), uint8(19), uint8(20), uint8(21), uint8(22), uint8(23), uint8(24),
  1447. uint8(25), uint8(26), uint8(27), uint8(28), uint8(29), uint8(30), uint8(31), uint8(32), uint8(33), uint8(34), uint8(35), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1),
  1448. Uint8FromInt32(-1), uint8(10), uint8(11), uint8(12), uint8(13), uint8(14), uint8(15), uint8(16), uint8(17), uint8(18), uint8(19), uint8(20), uint8(21), uint8(22), uint8(23), uint8(24),
  1449. uint8(25), uint8(26), uint8(27), uint8(28), uint8(29), uint8(30), uint8(31), uint8(32), uint8(33), uint8(34), uint8(35), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1),
  1450. Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1),
  1451. Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1),
  1452. Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1),
  1453. Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1),
  1454. Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1),
  1455. Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1),
  1456. Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1),
  1457. Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1), Uint8FromInt32(-1),
  1458. } /* intscan.c:7:28 */
  1459. func X__intscan(tls *TLS, f uintptr, base uint32, pok int32, lim uint64) uint64 { /* intscan.c:26:20: */
  1460. if __ccgo_strace {
  1461. trc("tls=%v f=%v base=%v pok=%v lim=%v, (%v:)", tls, f, base, pok, lim, origin(2))
  1462. }
  1463. var val uintptr
  1464. var c int32
  1465. var neg int32
  1466. var x uint32
  1467. var y uint64
  1468. var bs int32
  1469. val = uintptr(unsafe.Pointer(&table1)) + uintptr(1)
  1470. neg = 0
  1471. if !(base > uint32(36) || base == uint32(1)) {
  1472. goto __1
  1473. }
  1474. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22
  1475. return uint64(0)
  1476. __1:
  1477. ;
  1478. __2:
  1479. if !(__isspace(tls, AssignInt32(&c, func() int32 {
  1480. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1481. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1482. }
  1483. return X__shgetc(tls, f)
  1484. }())) != 0) {
  1485. goto __3
  1486. }
  1487. goto __2
  1488. __3:
  1489. ;
  1490. if !(c == '+' || c == '-') {
  1491. goto __4
  1492. }
  1493. neg = -Bool32(c == '-')
  1494. c = func() int32 {
  1495. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1496. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1497. }
  1498. return X__shgetc(tls, f)
  1499. }()
  1500. __4:
  1501. ;
  1502. if !((base == uint32(0) || base == uint32(16)) && c == '0') {
  1503. goto __5
  1504. }
  1505. c = func() int32 {
  1506. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1507. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1508. }
  1509. return X__shgetc(tls, f)
  1510. }()
  1511. if !(c|32 == 'x') {
  1512. goto __7
  1513. }
  1514. c = func() int32 {
  1515. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1516. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1517. }
  1518. return X__shgetc(tls, f)
  1519. }()
  1520. if !(int32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) >= 16) {
  1521. goto __9
  1522. }
  1523. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  1524. (*FILE)(unsafe.Pointer(f)).rpos--
  1525. } else {
  1526. }
  1527. if !(pok != 0) {
  1528. goto __10
  1529. }
  1530. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  1531. (*FILE)(unsafe.Pointer(f)).rpos--
  1532. } else {
  1533. }
  1534. goto __11
  1535. __10:
  1536. X__shlim(tls, f, int64(0))
  1537. __11:
  1538. ;
  1539. return uint64(0)
  1540. __9:
  1541. ;
  1542. base = uint32(16)
  1543. goto __8
  1544. __7:
  1545. if !(base == uint32(0)) {
  1546. goto __12
  1547. }
  1548. base = uint32(8)
  1549. __12:
  1550. ;
  1551. __8:
  1552. ;
  1553. goto __6
  1554. __5:
  1555. if !(base == uint32(0)) {
  1556. goto __13
  1557. }
  1558. base = uint32(10)
  1559. __13:
  1560. ;
  1561. if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) >= base) {
  1562. goto __14
  1563. }
  1564. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  1565. (*FILE)(unsafe.Pointer(f)).rpos--
  1566. } else {
  1567. }
  1568. X__shlim(tls, f, int64(0))
  1569. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22
  1570. return uint64(0)
  1571. __14:
  1572. ;
  1573. __6:
  1574. ;
  1575. if !(base == uint32(10)) {
  1576. goto __15
  1577. }
  1578. x = uint32(0)
  1579. __17:
  1580. if !(uint32(c-'0') < 10 && x <= 0xffffffff/uint32(10)-uint32(1)) {
  1581. goto __19
  1582. }
  1583. x = x*uint32(10) + uint32(c-'0')
  1584. goto __18
  1585. __18:
  1586. c = func() int32 {
  1587. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1588. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1589. }
  1590. return X__shgetc(tls, f)
  1591. }()
  1592. goto __17
  1593. goto __19
  1594. __19:
  1595. ;
  1596. y = uint64(x)
  1597. __20:
  1598. if !(uint32(c-'0') < 10 && y <= (2*uint64(0x7fffffffffffffff)+uint64(1))/uint64(10) && uint64(10)*y <= 2*uint64(0x7fffffffffffffff)+uint64(1)-uint64(c-'0')) {
  1599. goto __22
  1600. }
  1601. y = y*uint64(10) + uint64(c-'0')
  1602. goto __21
  1603. __21:
  1604. c = func() int32 {
  1605. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1606. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1607. }
  1608. return X__shgetc(tls, f)
  1609. }()
  1610. goto __20
  1611. goto __22
  1612. __22:
  1613. ;
  1614. if !(uint32(c-'0') >= 10) {
  1615. goto __23
  1616. }
  1617. goto done
  1618. __23:
  1619. ;
  1620. goto __16
  1621. __15:
  1622. if !!(base&(base-uint32(1)) != 0) {
  1623. goto __24
  1624. }
  1625. bs = int32(*(*int8)(unsafe.Pointer(ts + 14 + uintptr(uint32(0x17)*base>>5&uint32(7)))))
  1626. x = uint32(0)
  1627. __26:
  1628. if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) < base && x <= 0xffffffff/uint32(32)) {
  1629. goto __28
  1630. }
  1631. x = x<<bs | uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c))))
  1632. goto __27
  1633. __27:
  1634. c = func() int32 {
  1635. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1636. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1637. }
  1638. return X__shgetc(tls, f)
  1639. }()
  1640. goto __26
  1641. goto __28
  1642. __28:
  1643. ;
  1644. y = uint64(x)
  1645. __29:
  1646. if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) < base && y <= uint64(2*uint64(0x7fffffffffffffff)+uint64(1))>>bs) {
  1647. goto __31
  1648. }
  1649. y = y<<bs | uint64(*(*uint8)(unsafe.Pointer(val + uintptr(c))))
  1650. goto __30
  1651. __30:
  1652. c = func() int32 {
  1653. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1654. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1655. }
  1656. return X__shgetc(tls, f)
  1657. }()
  1658. goto __29
  1659. goto __31
  1660. __31:
  1661. ;
  1662. goto __25
  1663. __24:
  1664. x = uint32(0)
  1665. __32:
  1666. if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) < base && x <= 0xffffffff/uint32(36)-uint32(1)) {
  1667. goto __34
  1668. }
  1669. x = x*base + uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c))))
  1670. goto __33
  1671. __33:
  1672. c = func() int32 {
  1673. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1674. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1675. }
  1676. return X__shgetc(tls, f)
  1677. }()
  1678. goto __32
  1679. goto __34
  1680. __34:
  1681. ;
  1682. y = uint64(x)
  1683. __35:
  1684. if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) < base && y <= (2*uint64(0x7fffffffffffffff)+uint64(1))/uint64(base) && uint64(base)*y <= 2*uint64(0x7fffffffffffffff)+uint64(1)-uint64(*(*uint8)(unsafe.Pointer(val + uintptr(c))))) {
  1685. goto __37
  1686. }
  1687. y = y*uint64(base) + uint64(*(*uint8)(unsafe.Pointer(val + uintptr(c))))
  1688. goto __36
  1689. __36:
  1690. c = func() int32 {
  1691. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1692. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1693. }
  1694. return X__shgetc(tls, f)
  1695. }()
  1696. goto __35
  1697. goto __37
  1698. __37:
  1699. ;
  1700. __25:
  1701. ;
  1702. __16:
  1703. ;
  1704. if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) < base) {
  1705. goto __38
  1706. }
  1707. __39:
  1708. if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) < base) {
  1709. goto __41
  1710. }
  1711. goto __40
  1712. __40:
  1713. c = func() int32 {
  1714. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  1715. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  1716. }
  1717. return X__shgetc(tls, f)
  1718. }()
  1719. goto __39
  1720. goto __41
  1721. __41:
  1722. ;
  1723. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  1724. y = lim
  1725. if !(lim&uint64(1) != 0) {
  1726. goto __42
  1727. }
  1728. neg = 0
  1729. __42:
  1730. ;
  1731. __38:
  1732. ;
  1733. done:
  1734. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  1735. (*FILE)(unsafe.Pointer(f)).rpos--
  1736. } else {
  1737. }
  1738. if !(y >= lim) {
  1739. goto __43
  1740. }
  1741. if !(!(lim&uint64(1) != 0) && !(neg != 0)) {
  1742. goto __44
  1743. }
  1744. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  1745. return lim - uint64(1)
  1746. goto __45
  1747. __44:
  1748. if !(y > lim) {
  1749. goto __46
  1750. }
  1751. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  1752. return lim
  1753. __46:
  1754. ;
  1755. __45:
  1756. ;
  1757. __43:
  1758. ;
  1759. return y ^ uint64(neg) - uint64(neg)
  1760. }
  1761. // The shcnt field stores the number of bytes read so far, offset by
  1762. // the value of buf-rpos at the last function call (__shlim or __shgetc),
  1763. // so that between calls the inline shcnt macro can add rpos-buf to get
  1764. // the actual count.
  1765. func X__shlim(tls *TLS, f uintptr, lim off_t) { /* shgetc.c:8:6: */
  1766. if __ccgo_strace {
  1767. trc("tls=%v f=%v lim=%v, (%v:)", tls, f, lim, origin(2))
  1768. }
  1769. (*FILE)(unsafe.Pointer(f)).shlim = lim
  1770. (*FILE)(unsafe.Pointer(f)).shcnt = (int64((*FILE)(unsafe.Pointer(f)).buf) - int64((*FILE)(unsafe.Pointer(f)).rpos)) / 1
  1771. // If lim is nonzero, rend must be a valid pointer.
  1772. if lim != 0 && (int64((*FILE)(unsafe.Pointer(f)).rend)-int64((*FILE)(unsafe.Pointer(f)).rpos))/1 > lim {
  1773. (*FILE)(unsafe.Pointer(f)).shend = (*FILE)(unsafe.Pointer(f)).rpos + uintptr(lim)
  1774. } else {
  1775. (*FILE)(unsafe.Pointer(f)).shend = (*FILE)(unsafe.Pointer(f)).rend
  1776. }
  1777. }
  1778. func X__shgetc(tls *TLS, f uintptr) int32 { /* shgetc.c:19:5: */
  1779. if __ccgo_strace {
  1780. trc("tls=%v f=%v, (%v:)", tls, f, origin(2))
  1781. }
  1782. var c int32
  1783. var cnt off_t = (*FILE)(unsafe.Pointer(f)).shcnt + (int64((*FILE)(unsafe.Pointer(f)).rpos)-int64((*FILE)(unsafe.Pointer(f)).buf))/1
  1784. if (*FILE)(unsafe.Pointer(f)).shlim != 0 && cnt >= (*FILE)(unsafe.Pointer(f)).shlim || AssignInt32(&c, X__uflow(tls, f)) < 0 {
  1785. (*FILE)(unsafe.Pointer(f)).shcnt = (int64((*FILE)(unsafe.Pointer(f)).buf)-int64((*FILE)(unsafe.Pointer(f)).rpos))/1 + cnt
  1786. (*FILE)(unsafe.Pointer(f)).shend = (*FILE)(unsafe.Pointer(f)).rpos
  1787. (*FILE)(unsafe.Pointer(f)).shlim = int64(-1)
  1788. return -1
  1789. }
  1790. cnt++
  1791. if (*FILE)(unsafe.Pointer(f)).shlim != 0 && (int64((*FILE)(unsafe.Pointer(f)).rend)-int64((*FILE)(unsafe.Pointer(f)).rpos))/1 > (*FILE)(unsafe.Pointer(f)).shlim-cnt {
  1792. (*FILE)(unsafe.Pointer(f)).shend = (*FILE)(unsafe.Pointer(f)).rpos + uintptr((*FILE)(unsafe.Pointer(f)).shlim-cnt)
  1793. } else {
  1794. (*FILE)(unsafe.Pointer(f)).shend = (*FILE)(unsafe.Pointer(f)).rend
  1795. }
  1796. (*FILE)(unsafe.Pointer(f)).shcnt = (int64((*FILE)(unsafe.Pointer(f)).buf)-int64((*FILE)(unsafe.Pointer(f)).rpos))/1 + cnt
  1797. if (*FILE)(unsafe.Pointer(f)).rpos <= (*FILE)(unsafe.Pointer(f)).buf {
  1798. *(*uint8)(unsafe.Pointer((*FILE)(unsafe.Pointer(f)).rpos + UintptrFromInt32(-1))) = uint8(c)
  1799. }
  1800. return c
  1801. }
  1802. type lconv = struct {
  1803. decimal_point uintptr
  1804. thousands_sep uintptr
  1805. grouping uintptr
  1806. int_curr_symbol uintptr
  1807. currency_symbol uintptr
  1808. mon_decimal_point uintptr
  1809. mon_thousands_sep uintptr
  1810. mon_grouping uintptr
  1811. positive_sign uintptr
  1812. negative_sign uintptr
  1813. int_frac_digits int8
  1814. frac_digits int8
  1815. p_cs_precedes int8
  1816. p_sep_by_space int8
  1817. n_cs_precedes int8
  1818. n_sep_by_space int8
  1819. p_sign_posn int8
  1820. n_sign_posn int8
  1821. int_p_cs_precedes int8
  1822. int_p_sep_by_space int8
  1823. int_n_cs_precedes int8
  1824. int_n_sep_by_space int8
  1825. int_p_sign_posn int8
  1826. int_n_sign_posn int8
  1827. _ [2]byte
  1828. } /* locale.h:24:1 */
  1829. // Support signed or unsigned plain-char
  1830. // Implementation choices...
  1831. // Arbitrary numbers...
  1832. // POSIX/SUS requirements follow. These numbers come directly
  1833. // from SUS and have nothing to do with the host system.
  1834. var posix_lconv = lconv{decimal_point: ts + 23, thousands_sep: ts + 13, grouping: ts + 13, int_curr_symbol: ts + 13, currency_symbol: ts + 13, mon_decimal_point: ts + 13, mon_thousands_sep: ts + 13, mon_grouping: ts + 13, positive_sign: ts + 13, negative_sign: ts + 13, int_frac_digits: Int8FromInt32(255), frac_digits: Int8FromInt32(255), p_cs_precedes: Int8FromInt32(255), p_sep_by_space: Int8FromInt32(255), n_cs_precedes: Int8FromInt32(255), n_sep_by_space: Int8FromInt32(255), p_sign_posn: Int8FromInt32(255), n_sign_posn: Int8FromInt32(255), int_p_cs_precedes: Int8FromInt32(255), int_p_sep_by_space: Int8FromInt32(255), int_n_cs_precedes: Int8FromInt32(255), int_n_sep_by_space: Int8FromInt32(255), int_p_sign_posn: Int8FromInt32(255), int_n_sign_posn: Int8FromInt32(255)} /* localeconv.c:4:27 */
  1835. func Xlocaleconv(tls *TLS) uintptr { /* localeconv.c:31:14: */
  1836. if __ccgo_strace {
  1837. trc("tls=%v, (%v:)", tls, origin(2))
  1838. }
  1839. return uintptr(unsafe.Pointer(&posix_lconv))
  1840. }
  1841. func X__fpclassify(tls *TLS, x float64) int32 { /* __fpclassify.c:4:5: */
  1842. if __ccgo_strace {
  1843. trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
  1844. }
  1845. bp := tls.Alloc(8)
  1846. defer tls.Free(8)
  1847. *(*struct{ f float64 })(unsafe.Pointer(bp)) = func() (r struct{ f float64 }) {
  1848. *(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
  1849. return r
  1850. }()
  1851. var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
  1852. if !(e != 0) {
  1853. if *(*uint64_t)(unsafe.Pointer(bp))<<1 != 0 {
  1854. return 3
  1855. }
  1856. return 2
  1857. }
  1858. if e == 0x7ff {
  1859. if *(*uint64_t)(unsafe.Pointer(bp))<<12 != 0 {
  1860. return 0
  1861. }
  1862. return 1
  1863. }
  1864. return 4
  1865. }
  1866. func X__fpclassifyf(tls *TLS, x float32) int32 { /* __fpclassifyf.c:4:5: */
  1867. if __ccgo_strace {
  1868. trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
  1869. }
  1870. bp := tls.Alloc(4)
  1871. defer tls.Free(4)
  1872. *(*struct{ f float32 })(unsafe.Pointer(bp)) = func() (r struct{ f float32 }) {
  1873. *(*float32)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
  1874. return r
  1875. }()
  1876. var e int32 = int32(*(*uint32_t)(unsafe.Pointer(bp)) >> 23 & uint32_t(0xff))
  1877. if !(e != 0) {
  1878. if *(*uint32_t)(unsafe.Pointer(bp))<<1 != 0 {
  1879. return 3
  1880. }
  1881. return 2
  1882. }
  1883. if e == 0xff {
  1884. if *(*uint32_t)(unsafe.Pointer(bp))<<9 != 0 {
  1885. return 0
  1886. }
  1887. return 1
  1888. }
  1889. return 4
  1890. }
  1891. func X__fpclassifyl(tls *TLS, x float64) int32 { /* __fpclassifyl.c:4:5: */
  1892. if __ccgo_strace {
  1893. trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
  1894. }
  1895. return X__fpclassify(tls, x)
  1896. }
  1897. func Xcopysignl(tls *TLS, x float64, y float64) float64 { /* copysignl.c:4:13: */
  1898. if __ccgo_strace {
  1899. trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2))
  1900. }
  1901. return Xcopysign(tls, x, y)
  1902. }
  1903. func Xfabsl(tls *TLS, x float64) float64 { /* fabsl.c:3:13: */
  1904. if __ccgo_strace {
  1905. trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
  1906. }
  1907. return Xfabs(tls, x)
  1908. }
  1909. func Xfmodl(tls *TLS, x float64, y float64) float64 { /* fmodl.c:4:13: */
  1910. if __ccgo_strace {
  1911. trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2))
  1912. }
  1913. return Xfmod(tls, x, y)
  1914. }
  1915. func Xnanf(tls *TLS, s uintptr) float32 { /* nanf.c:3:7: */
  1916. if __ccgo_strace {
  1917. trc("tls=%v s=%v, (%v:)", tls, s, origin(2))
  1918. }
  1919. return X__builtin_nanf(tls, ts+13)
  1920. }
  1921. var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
  1922. func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
  1923. if __ccgo_strace {
  1924. trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
  1925. }
  1926. bp := tls.Alloc(8)
  1927. defer tls.Free(8)
  1928. *(*struct{ f float64 })(unsafe.Pointer(bp)) = func() (r struct{ f float64 }) {
  1929. *(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
  1930. return r
  1931. }()
  1932. var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
  1933. var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
  1934. var y double_t
  1935. if e >= 0x3ff+52 {
  1936. return x
  1937. }
  1938. if s != 0 {
  1939. y = x - toint + toint
  1940. } else {
  1941. y = x + toint - toint
  1942. }
  1943. if y == float64(0) {
  1944. if s != 0 {
  1945. return -Float64FromFloat64(0.0)
  1946. }
  1947. return float64(0)
  1948. }
  1949. return y
  1950. }
  1951. func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
  1952. if __ccgo_strace {
  1953. trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
  1954. }
  1955. bp := tls.Alloc(8)
  1956. defer tls.Free(8)
  1957. // var u struct {f float64;} at bp, 8
  1958. var y double_t = x
  1959. if n > 1023 {
  1960. y = y * 0x1p1023
  1961. n = n - 1023
  1962. if n > 1023 {
  1963. y = y * 0x1p1023
  1964. n = n - 1023
  1965. if n > 1023 {
  1966. n = 1023
  1967. }
  1968. }
  1969. } else if n < -1022 {
  1970. // make sure final n < -53 to avoid double
  1971. // rounding in the subnormal range
  1972. y = y * (float64(0x1p-1022) * 0x1p53)
  1973. n = n + (1022 - 53)
  1974. if n < -1022 {
  1975. y = y * (float64(0x1p-1022) * 0x1p53)
  1976. n = n + (1022 - 53)
  1977. if n < -1022 {
  1978. n = -1022
  1979. }
  1980. }
  1981. }
  1982. *(*uint64_t)(unsafe.Pointer(bp)) = uint64_t(0x3ff+n) << 52
  1983. x = y * *(*float64)(unsafe.Pointer(bp))
  1984. return x
  1985. }
  1986. func Xscalbnl(tls *TLS, x float64, n int32) float64 { /* scalbnl.c:4:13: */
  1987. if __ccgo_strace {
  1988. trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
  1989. }
  1990. return Xscalbn(tls, x, n)
  1991. }
  1992. // Support signed or unsigned plain-char
  1993. // Implementation choices...
  1994. // Arbitrary numbers...
  1995. // POSIX/SUS requirements follow. These numbers come directly
  1996. // from SUS and have nothing to do with the host system.
  1997. type __locale_map = struct {
  1998. __map uintptr
  1999. map_size size_t
  2000. name [24]int8
  2001. next uintptr
  2002. } /* alltypes.h:343:9 */
  2003. type tls_module = struct {
  2004. next uintptr
  2005. image uintptr
  2006. len size_t
  2007. size size_t
  2008. align size_t
  2009. offset size_t
  2010. } /* libc.h:14:1 */
  2011. type __libc = struct {
  2012. can_do_threads int8
  2013. threaded int8
  2014. secure int8
  2015. need_locks int8
  2016. threads_minus_1 int32
  2017. auxv uintptr
  2018. tls_head uintptr
  2019. tls_size size_t
  2020. tls_align size_t
  2021. tls_cnt size_t
  2022. page_size size_t
  2023. global_locale struct{ cat [6]uintptr }
  2024. } /* libc.h:20:1 */
  2025. type time_t = int64 /* alltypes.h:85:16 */
  2026. type clockid_t = int32 /* alltypes.h:214:13 */
  2027. type timespec = struct {
  2028. tv_sec time_t
  2029. tv_nsec int64
  2030. } /* alltypes.h:229:1 */
  2031. type pthread_t = uintptr /* alltypes.h:273:26 */
  2032. type pthread_once_t = int32 /* alltypes.h:279:13 */
  2033. type pthread_key_t = uint32 /* alltypes.h:284:18 */
  2034. type pthread_spinlock_t = int32 /* alltypes.h:289:13 */
  2035. type pthread_mutexattr_t = struct{ __attr uint32 } /* alltypes.h:294:37 */
  2036. type pthread_condattr_t = struct{ __attr uint32 } /* alltypes.h:299:37 */
  2037. type pthread_barrierattr_t = struct{ __attr uint32 } /* alltypes.h:304:37 */
  2038. type pthread_rwlockattr_t = struct{ __attr [2]uint32 } /* alltypes.h:309:40 */
  2039. type __sigset_t = struct{ __bits [16]uint64 } /* alltypes.h:349:9 */
  2040. type sigset_t = __sigset_t /* alltypes.h:349:71 */
  2041. type pthread_attr_t = struct {
  2042. __u struct {
  2043. _ [0]uint64
  2044. __i [14]int32
  2045. }
  2046. } /* alltypes.h:372:147 */
  2047. type pthread_mutex_t = struct {
  2048. __u struct {
  2049. _ [0]uint64
  2050. __i [10]int32
  2051. }
  2052. } /* alltypes.h:377:157 */
  2053. type pthread_cond_t = struct {
  2054. __u struct {
  2055. _ [0]uint64
  2056. __i [12]int32
  2057. }
  2058. } /* alltypes.h:387:112 */
  2059. type pthread_rwlock_t = struct {
  2060. __u struct {
  2061. _ [0]uint64
  2062. __i [14]int32
  2063. }
  2064. } /* alltypes.h:397:139 */
  2065. type pthread_barrier_t = struct {
  2066. __u struct {
  2067. _ [0]uint64
  2068. __i [8]int32
  2069. }
  2070. } /* alltypes.h:402:137 */
  2071. type sched_param = struct {
  2072. sched_priority int32
  2073. __reserved1 int32
  2074. __reserved2 [2]struct {
  2075. __reserved1 time_t
  2076. __reserved2 int64
  2077. }
  2078. __reserved3 int32
  2079. _ [4]byte
  2080. } /* sched.h:19:1 */
  2081. type timer_t = uintptr /* alltypes.h:209:14 */
  2082. type clock_t = int64 /* alltypes.h:219:14 */
  2083. type tm = struct {
  2084. tm_sec int32
  2085. tm_min int32
  2086. tm_hour int32
  2087. tm_mday int32
  2088. tm_mon int32
  2089. tm_year int32
  2090. tm_wday int32
  2091. tm_yday int32
  2092. tm_isdst int32
  2093. _ [4]byte
  2094. tm_gmtoff int64
  2095. tm_zone uintptr
  2096. } /* time.h:38:1 */
  2097. type itimerspec = struct {
  2098. it_interval struct {
  2099. tv_sec time_t
  2100. tv_nsec int64
  2101. }
  2102. it_value struct {
  2103. tv_sec time_t
  2104. tv_nsec int64
  2105. }
  2106. } /* time.h:80:1 */
  2107. type sigevent = struct {
  2108. sigev_value struct {
  2109. _ [0]uint64
  2110. sival_int int32
  2111. _ [4]byte
  2112. }
  2113. sigev_signo int32
  2114. sigev_notify int32
  2115. sigev_notify_function uintptr
  2116. sigev_notify_attributes uintptr
  2117. __pad [32]int8
  2118. } /* time.h:107:1 */
  2119. type __ptcb = struct {
  2120. __f uintptr
  2121. __x uintptr
  2122. __next uintptr
  2123. } /* alltypes.h:273:9 */
  2124. type sigaltstack = struct {
  2125. ss_sp uintptr
  2126. ss_flags int32
  2127. _ [4]byte
  2128. ss_size size_t
  2129. } /* signal.h:44:9 */
  2130. type stack_t = sigaltstack /* signal.h:44:28 */
  2131. type greg_t = int64 /* signal.h:59:19 */
  2132. type gregset_t = [23]int64 /* signal.h:59:27 */
  2133. type _fpstate = struct {
  2134. cwd uint16
  2135. swd uint16
  2136. ftw uint16
  2137. fop uint16
  2138. rip uint64
  2139. rdp uint64
  2140. mxcsr uint32
  2141. mxcr_mask uint32
  2142. _st [8]struct {
  2143. significand [4]uint16
  2144. exponent uint16
  2145. padding [3]uint16
  2146. }
  2147. _xmm [16]struct{ element [4]uint32 }
  2148. padding [24]uint32
  2149. } /* signal.h:60:9 */
  2150. type fpregset_t = uintptr /* signal.h:71:3 */
  2151. type sigcontext = struct {
  2152. r8 uint64
  2153. r9 uint64
  2154. r10 uint64
  2155. r11 uint64
  2156. r12 uint64
  2157. r13 uint64
  2158. r14 uint64
  2159. r15 uint64
  2160. rdi uint64
  2161. rsi uint64
  2162. rbp uint64
  2163. rbx uint64
  2164. rdx uint64
  2165. rax uint64
  2166. rcx uint64
  2167. rsp uint64
  2168. rip uint64
  2169. eflags uint64
  2170. cs uint16
  2171. gs uint16
  2172. fs uint16
  2173. __pad0 uint16
  2174. err uint64
  2175. trapno uint64
  2176. oldmask uint64
  2177. cr2 uint64
  2178. fpstate uintptr
  2179. __reserved1 [8]uint64
  2180. } /* signal.h:72:1 */
  2181. type mcontext_t = struct {
  2182. gregs gregset_t
  2183. fpregs fpregset_t
  2184. __reserved1 [8]uint64
  2185. } /* signal.h:84:3 */
  2186. type __ucontext = struct {
  2187. uc_flags uint64
  2188. uc_link uintptr
  2189. uc_stack stack_t
  2190. uc_mcontext mcontext_t
  2191. uc_sigmask sigset_t
  2192. __fpregs_mem [64]uint64
  2193. } /* signal.h:97:9 */
  2194. type ucontext_t = __ucontext /* signal.h:104:3 */
  2195. type sigval = struct {
  2196. _ [0]uint64
  2197. sival_int int32
  2198. _ [4]byte
  2199. } /* time.h:107:1 */
  2200. type siginfo_t = struct {
  2201. si_signo int32
  2202. si_errno int32
  2203. si_code int32
  2204. _ [4]byte
  2205. __si_fields struct {
  2206. _ [0]uint64
  2207. __pad [112]int8
  2208. }
  2209. } /* signal.h:145:3 */
  2210. type sigaction = struct {
  2211. __sa_handler struct{ sa_handler uintptr }
  2212. sa_mask sigset_t
  2213. sa_flags int32
  2214. _ [4]byte
  2215. sa_restorer uintptr
  2216. } /* signal.h:167:1 */
  2217. type sig_t = uintptr /* signal.h:251:14 */
  2218. type sig_atomic_t = int32 /* signal.h:269:13 */
  2219. func a_cas(tls *TLS, p uintptr, t int32, s int32) int32 { /* atomic_arch.h:2:19: */
  2220. panic(`arch/x86_64/atomic_arch.h:4:2: assembler statements not supported`)
  2221. return t
  2222. }
  2223. func a_swap(tls *TLS, p uintptr, v int32) int32 { /* atomic_arch.h:20:19: */
  2224. panic(`arch/x86_64/atomic_arch.h:22:2: assembler statements not supported`)
  2225. return v
  2226. }
  2227. func a_or(tls *TLS, p uintptr, v int32) { /* atomic_arch.h:46:20: */
  2228. panic(`arch/x86_64/atomic_arch.h:48:2: assembler statements not supported`)
  2229. }
  2230. func a_or_64(tls *TLS, p uintptr, v uint64_t) { /* atomic_arch.h:62:20: */
  2231. panic(`arch/x86_64/atomic_arch.h:64:2: assembler statements not supported`)
  2232. }
  2233. func a_ctz_64(tls *TLS, x uint64_t) int32 { /* atomic_arch.h:112:19: */
  2234. panic(`arch/x86_64/atomic_arch.h:114:2: assembler statements not supported`)
  2235. return int32(x)
  2236. }
  2237. func a_ctz_32(tls *TLS, x uint32_t) int32 { /* atomic.h:256:19: */
  2238. return int32(_sdebruijn328[x&-x*uint32_t(0x076be629)>>27])
  2239. }
  2240. var _sdebruijn328 = [32]int8{
  2241. int8(0), int8(1), int8(23), int8(2), int8(29), int8(24), int8(19), int8(3), int8(30), int8(27), int8(25), int8(11), int8(20), int8(8), int8(4), int8(13),
  2242. int8(31), int8(22), int8(28), int8(18), int8(26), int8(10), int8(7), int8(12), int8(21), int8(17), int8(9), int8(6), int8(16), int8(5), int8(15), int8(14),
  2243. } /* atomic.h:261:20 */
  2244. type __timer = struct {
  2245. timerid int32
  2246. _ [4]byte
  2247. thread pthread_t
  2248. } /* pthread_impl.h:64:1 */
  2249. func __pthread_self(tls *TLS) uintptr { /* pthread_arch.h:1:30: */
  2250. var self uintptr
  2251. panic(`arch/x86_64/pthread_arch.h:4:2: assembler statements not supported`)
  2252. return self
  2253. }
  2254. func __wake(tls *TLS, addr uintptr, cnt int32, priv int32) { /* pthread_impl.h:155:20: */
  2255. panic(todo(""))
  2256. // if priv != 0 {
  2257. // priv = 128
  2258. // }
  2259. //
  2260. // if cnt < 0 {
  2261. // cnt = 0x7fffffff
  2262. // }
  2263. //
  2264. // _ = Bool32(X__syscall3(tls, int64(202), int64(addr), int64(1|priv), int64(cnt)) != int64(-38) || X__syscall3(tls, int64(202), int64(addr), int64(1), int64(cnt)) != 0)
  2265. }
  2266. func __futexwait(tls *TLS, addr uintptr, val int32, priv int32) { /* pthread_impl.h:162:20: */
  2267. panic(todo(""))
  2268. // if priv != 0 {
  2269. // priv = 128
  2270. // }
  2271. //
  2272. // _ = Bool32(X__syscall4(tls, int64(202), int64(addr), int64(0|priv), int64(val), int64(0)) != int64(-38) || X__syscall4(tls, int64(202), int64(addr), int64(0), int64(val), int64(0)) != 0)
  2273. }
  2274. var X__fsmu8 = [51]uint32_t{
  2275. func() uint32 {
  2276. if 0x2 < 2 {
  2277. return Uint32FromInt32(-1)
  2278. }
  2279. return func() uint32 {
  2280. if Int32(0x80) == Int32(0x80) {
  2281. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2282. }
  2283. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2284. }()<<23 | uint32_t(0x2)
  2285. }(), func() uint32 {
  2286. if 0x3 < 2 {
  2287. return Uint32FromInt32(-1)
  2288. }
  2289. return func() uint32 {
  2290. if Int32(0x80) == Int32(0x80) {
  2291. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2292. }
  2293. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2294. }()<<23 | uint32_t(0x3)
  2295. }(), func() uint32 {
  2296. if 0x4 < 2 {
  2297. return Uint32FromInt32(-1)
  2298. }
  2299. return func() uint32 {
  2300. if Int32(0x80) == Int32(0x80) {
  2301. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2302. }
  2303. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2304. }()<<23 | uint32_t(0x4)
  2305. }(), func() uint32 {
  2306. if 0x5 < 2 {
  2307. return Uint32FromInt32(-1)
  2308. }
  2309. return func() uint32 {
  2310. if Int32(0x80) == Int32(0x80) {
  2311. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2312. }
  2313. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2314. }()<<23 | uint32_t(0x5)
  2315. }(), func() uint32 {
  2316. if 0x6 < 2 {
  2317. return Uint32FromInt32(-1)
  2318. }
  2319. return func() uint32 {
  2320. if Int32(0x80) == Int32(0x80) {
  2321. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2322. }
  2323. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2324. }()<<23 | uint32_t(0x6)
  2325. }(), func() uint32 {
  2326. if 0x7 < 2 {
  2327. return Uint32FromInt32(-1)
  2328. }
  2329. return func() uint32 {
  2330. if Int32(0x80) == Int32(0x80) {
  2331. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2332. }
  2333. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2334. }()<<23 | uint32_t(0x7)
  2335. }(),
  2336. func() uint32 {
  2337. if 0x8 < 2 {
  2338. return Uint32FromInt32(-1)
  2339. }
  2340. return func() uint32 {
  2341. if Int32(0x80) == Int32(0x80) {
  2342. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2343. }
  2344. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2345. }()<<23 | uint32_t(0x8)
  2346. }(), func() uint32 {
  2347. if 0x9 < 2 {
  2348. return Uint32FromInt32(-1)
  2349. }
  2350. return func() uint32 {
  2351. if Int32(0x80) == Int32(0x80) {
  2352. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2353. }
  2354. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2355. }()<<23 | uint32_t(0x9)
  2356. }(), func() uint32 {
  2357. if 0xa < 2 {
  2358. return Uint32FromInt32(-1)
  2359. }
  2360. return func() uint32 {
  2361. if Int32(0x80) == Int32(0x80) {
  2362. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2363. }
  2364. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2365. }()<<23 | uint32_t(0xa)
  2366. }(), func() uint32 {
  2367. if 0xb < 2 {
  2368. return Uint32FromInt32(-1)
  2369. }
  2370. return func() uint32 {
  2371. if Int32(0x80) == Int32(0x80) {
  2372. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2373. }
  2374. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2375. }()<<23 | uint32_t(0xb)
  2376. }(), func() uint32 {
  2377. if 0xc < 2 {
  2378. return Uint32FromInt32(-1)
  2379. }
  2380. return func() uint32 {
  2381. if Int32(0x80) == Int32(0x80) {
  2382. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2383. }
  2384. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2385. }()<<23 | uint32_t(0xc)
  2386. }(), func() uint32 {
  2387. if 0xd < 2 {
  2388. return Uint32FromInt32(-1)
  2389. }
  2390. return func() uint32 {
  2391. if Int32(0x80) == Int32(0x80) {
  2392. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2393. }
  2394. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2395. }()<<23 | uint32_t(0xd)
  2396. }(), func() uint32 {
  2397. if 0xe < 2 {
  2398. return Uint32FromInt32(-1)
  2399. }
  2400. return func() uint32 {
  2401. if Int32(0x80) == Int32(0x80) {
  2402. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2403. }
  2404. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2405. }()<<23 | uint32_t(0xe)
  2406. }(), func() uint32 {
  2407. if 0xf < 2 {
  2408. return Uint32FromInt32(-1)
  2409. }
  2410. return func() uint32 {
  2411. if Int32(0x80) == Int32(0x80) {
  2412. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2413. }
  2414. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2415. }()<<23 | uint32_t(0xf)
  2416. }(),
  2417. func() uint32 {
  2418. if 0x0+16 < 2 {
  2419. return Uint32FromInt32(-1)
  2420. }
  2421. return func() uint32 {
  2422. if Int32(0x80) == Int32(0x80) {
  2423. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2424. }
  2425. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2426. }()<<23 | uint32_t(0x0+16)
  2427. }(), func() uint32 {
  2428. if 0x1+16 < 2 {
  2429. return Uint32FromInt32(-1)
  2430. }
  2431. return func() uint32 {
  2432. if Int32(0x80) == Int32(0x80) {
  2433. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2434. }
  2435. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2436. }()<<23 | uint32_t(0x1+16)
  2437. }(), func() uint32 {
  2438. if 0x2+16 < 2 {
  2439. return Uint32FromInt32(-1)
  2440. }
  2441. return func() uint32 {
  2442. if Int32(0x80) == Int32(0x80) {
  2443. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2444. }
  2445. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2446. }()<<23 | uint32_t(0x2+16)
  2447. }(), func() uint32 {
  2448. if 0x3+16 < 2 {
  2449. return Uint32FromInt32(-1)
  2450. }
  2451. return func() uint32 {
  2452. if Int32(0x80) == Int32(0x80) {
  2453. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2454. }
  2455. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2456. }()<<23 | uint32_t(0x3+16)
  2457. }(), func() uint32 {
  2458. if 0x4+16 < 2 {
  2459. return Uint32FromInt32(-1)
  2460. }
  2461. return func() uint32 {
  2462. if Int32(0x80) == Int32(0x80) {
  2463. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2464. }
  2465. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2466. }()<<23 | uint32_t(0x4+16)
  2467. }(), func() uint32 {
  2468. if 0x5+16 < 2 {
  2469. return Uint32FromInt32(-1)
  2470. }
  2471. return func() uint32 {
  2472. if Int32(0x80) == Int32(0x80) {
  2473. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2474. }
  2475. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2476. }()<<23 | uint32_t(0x5+16)
  2477. }(), func() uint32 {
  2478. if 0x6+16 < 2 {
  2479. return Uint32FromInt32(-1)
  2480. }
  2481. return func() uint32 {
  2482. if Int32(0x80) == Int32(0x80) {
  2483. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2484. }
  2485. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2486. }()<<23 | uint32_t(0x6+16)
  2487. }(), func() uint32 {
  2488. if 0x7+16 < 2 {
  2489. return Uint32FromInt32(-1)
  2490. }
  2491. return func() uint32 {
  2492. if Int32(0x80) == Int32(0x80) {
  2493. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2494. }
  2495. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2496. }()<<23 | uint32_t(0x7+16)
  2497. }(),
  2498. func() uint32 {
  2499. if 0x8+16 < 2 {
  2500. return Uint32FromInt32(-1)
  2501. }
  2502. return func() uint32 {
  2503. if Int32(0x80) == Int32(0x80) {
  2504. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2505. }
  2506. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2507. }()<<23 | uint32_t(0x8+16)
  2508. }(), func() uint32 {
  2509. if 0x9+16 < 2 {
  2510. return Uint32FromInt32(-1)
  2511. }
  2512. return func() uint32 {
  2513. if Int32(0x80) == Int32(0x80) {
  2514. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2515. }
  2516. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2517. }()<<23 | uint32_t(0x9+16)
  2518. }(), func() uint32 {
  2519. if 0xa+16 < 2 {
  2520. return Uint32FromInt32(-1)
  2521. }
  2522. return func() uint32 {
  2523. if Int32(0x80) == Int32(0x80) {
  2524. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2525. }
  2526. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2527. }()<<23 | uint32_t(0xa+16)
  2528. }(), func() uint32 {
  2529. if 0xb+16 < 2 {
  2530. return Uint32FromInt32(-1)
  2531. }
  2532. return func() uint32 {
  2533. if Int32(0x80) == Int32(0x80) {
  2534. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2535. }
  2536. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2537. }()<<23 | uint32_t(0xb+16)
  2538. }(), func() uint32 {
  2539. if 0xc+16 < 2 {
  2540. return Uint32FromInt32(-1)
  2541. }
  2542. return func() uint32 {
  2543. if Int32(0x80) == Int32(0x80) {
  2544. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2545. }
  2546. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2547. }()<<23 | uint32_t(0xc+16)
  2548. }(), func() uint32 {
  2549. if 0xd+16 < 2 {
  2550. return Uint32FromInt32(-1)
  2551. }
  2552. return func() uint32 {
  2553. if Int32(0x80) == Int32(0x80) {
  2554. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2555. }
  2556. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2557. }()<<23 | uint32_t(0xd+16)
  2558. }(), func() uint32 {
  2559. if 0xe+16 < 2 {
  2560. return Uint32FromInt32(-1)
  2561. }
  2562. return func() uint32 {
  2563. if Int32(0x80) == Int32(0x80) {
  2564. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2565. }
  2566. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2567. }()<<23 | uint32_t(0xe+16)
  2568. }(), func() uint32 {
  2569. if 0xf+16 < 2 {
  2570. return Uint32FromInt32(-1)
  2571. }
  2572. return func() uint32 {
  2573. if Int32(0x80) == Int32(0x80) {
  2574. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2575. }
  2576. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2577. }()<<23 | uint32_t(0xf+16)
  2578. }(),
  2579. func() uint32 {
  2580. if 0x0 == 0 {
  2581. return func() uint32 {
  2582. if Int32(0xa0) == Int32(0x80) {
  2583. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2584. }
  2585. return Uint32(Uint32(0) - Uint32FromInt32(0xa0))
  2586. }() << 23
  2587. }
  2588. return func() uint32 {
  2589. if 0x0 == 0xd {
  2590. return func() uint32 {
  2591. if Int32(0x80) == Int32(0x80) {
  2592. return Uint32(Uint32(0x40) - Uint32FromInt32(0xa0))
  2593. }
  2594. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2595. }() << 23
  2596. }
  2597. return func() uint32 {
  2598. if Int32(0x80) == Int32(0x80) {
  2599. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2600. }
  2601. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2602. }() << 23
  2603. }()
  2604. }() | uint32_t(func() uint32 {
  2605. if Int32(0x80) == Int32(0x80) {
  2606. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2607. }
  2608. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2609. }()<<23)>>6 | uint32_t(0x0), func() uint32 {
  2610. if 0x1 == 0 {
  2611. return func() uint32 {
  2612. if Int32(0xa0) == Int32(0x80) {
  2613. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2614. }
  2615. return Uint32(Uint32(0) - Uint32FromInt32(0xa0))
  2616. }() << 23
  2617. }
  2618. return func() uint32 {
  2619. if 0x1 == 0xd {
  2620. return func() uint32 {
  2621. if Int32(0x80) == Int32(0x80) {
  2622. return Uint32(Uint32(0x40) - Uint32FromInt32(0xa0))
  2623. }
  2624. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2625. }() << 23
  2626. }
  2627. return func() uint32 {
  2628. if Int32(0x80) == Int32(0x80) {
  2629. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2630. }
  2631. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2632. }() << 23
  2633. }()
  2634. }() | uint32_t(func() uint32 {
  2635. if Int32(0x80) == Int32(0x80) {
  2636. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2637. }
  2638. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2639. }()<<23)>>6 | uint32_t(0x1), func() uint32 {
  2640. if 0x2 == 0 {
  2641. return func() uint32 {
  2642. if Int32(0xa0) == Int32(0x80) {
  2643. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2644. }
  2645. return Uint32(Uint32(0) - Uint32FromInt32(0xa0))
  2646. }() << 23
  2647. }
  2648. return func() uint32 {
  2649. if 0x2 == 0xd {
  2650. return func() uint32 {
  2651. if Int32(0x80) == Int32(0x80) {
  2652. return Uint32(Uint32(0x40) - Uint32FromInt32(0xa0))
  2653. }
  2654. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2655. }() << 23
  2656. }
  2657. return func() uint32 {
  2658. if Int32(0x80) == Int32(0x80) {
  2659. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2660. }
  2661. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2662. }() << 23
  2663. }()
  2664. }() | uint32_t(func() uint32 {
  2665. if Int32(0x80) == Int32(0x80) {
  2666. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2667. }
  2668. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2669. }()<<23)>>6 | uint32_t(0x2), func() uint32 {
  2670. if 0x3 == 0 {
  2671. return func() uint32 {
  2672. if Int32(0xa0) == Int32(0x80) {
  2673. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2674. }
  2675. return Uint32(Uint32(0) - Uint32FromInt32(0xa0))
  2676. }() << 23
  2677. }
  2678. return func() uint32 {
  2679. if 0x3 == 0xd {
  2680. return func() uint32 {
  2681. if Int32(0x80) == Int32(0x80) {
  2682. return Uint32(Uint32(0x40) - Uint32FromInt32(0xa0))
  2683. }
  2684. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2685. }() << 23
  2686. }
  2687. return func() uint32 {
  2688. if Int32(0x80) == Int32(0x80) {
  2689. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2690. }
  2691. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2692. }() << 23
  2693. }()
  2694. }() | uint32_t(func() uint32 {
  2695. if Int32(0x80) == Int32(0x80) {
  2696. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2697. }
  2698. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2699. }()<<23)>>6 | uint32_t(0x3), func() uint32 {
  2700. if 0x4 == 0 {
  2701. return func() uint32 {
  2702. if Int32(0xa0) == Int32(0x80) {
  2703. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2704. }
  2705. return Uint32(Uint32(0) - Uint32FromInt32(0xa0))
  2706. }() << 23
  2707. }
  2708. return func() uint32 {
  2709. if 0x4 == 0xd {
  2710. return func() uint32 {
  2711. if Int32(0x80) == Int32(0x80) {
  2712. return Uint32(Uint32(0x40) - Uint32FromInt32(0xa0))
  2713. }
  2714. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2715. }() << 23
  2716. }
  2717. return func() uint32 {
  2718. if Int32(0x80) == Int32(0x80) {
  2719. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2720. }
  2721. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2722. }() << 23
  2723. }()
  2724. }() | uint32_t(func() uint32 {
  2725. if Int32(0x80) == Int32(0x80) {
  2726. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2727. }
  2728. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2729. }()<<23)>>6 | uint32_t(0x4), func() uint32 {
  2730. if 0x5 == 0 {
  2731. return func() uint32 {
  2732. if Int32(0xa0) == Int32(0x80) {
  2733. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2734. }
  2735. return Uint32(Uint32(0) - Uint32FromInt32(0xa0))
  2736. }() << 23
  2737. }
  2738. return func() uint32 {
  2739. if 0x5 == 0xd {
  2740. return func() uint32 {
  2741. if Int32(0x80) == Int32(0x80) {
  2742. return Uint32(Uint32(0x40) - Uint32FromInt32(0xa0))
  2743. }
  2744. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2745. }() << 23
  2746. }
  2747. return func() uint32 {
  2748. if Int32(0x80) == Int32(0x80) {
  2749. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2750. }
  2751. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2752. }() << 23
  2753. }()
  2754. }() | uint32_t(func() uint32 {
  2755. if Int32(0x80) == Int32(0x80) {
  2756. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2757. }
  2758. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2759. }()<<23)>>6 | uint32_t(0x5), func() uint32 {
  2760. if 0x6 == 0 {
  2761. return func() uint32 {
  2762. if Int32(0xa0) == Int32(0x80) {
  2763. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2764. }
  2765. return Uint32(Uint32(0) - Uint32FromInt32(0xa0))
  2766. }() << 23
  2767. }
  2768. return func() uint32 {
  2769. if 0x6 == 0xd {
  2770. return func() uint32 {
  2771. if Int32(0x80) == Int32(0x80) {
  2772. return Uint32(Uint32(0x40) - Uint32FromInt32(0xa0))
  2773. }
  2774. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2775. }() << 23
  2776. }
  2777. return func() uint32 {
  2778. if Int32(0x80) == Int32(0x80) {
  2779. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2780. }
  2781. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2782. }() << 23
  2783. }()
  2784. }() | uint32_t(func() uint32 {
  2785. if Int32(0x80) == Int32(0x80) {
  2786. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2787. }
  2788. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2789. }()<<23)>>6 | uint32_t(0x6), func() uint32 {
  2790. if 0x7 == 0 {
  2791. return func() uint32 {
  2792. if Int32(0xa0) == Int32(0x80) {
  2793. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2794. }
  2795. return Uint32(Uint32(0) - Uint32FromInt32(0xa0))
  2796. }() << 23
  2797. }
  2798. return func() uint32 {
  2799. if 0x7 == 0xd {
  2800. return func() uint32 {
  2801. if Int32(0x80) == Int32(0x80) {
  2802. return Uint32(Uint32(0x40) - Uint32FromInt32(0xa0))
  2803. }
  2804. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2805. }() << 23
  2806. }
  2807. return func() uint32 {
  2808. if Int32(0x80) == Int32(0x80) {
  2809. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2810. }
  2811. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2812. }() << 23
  2813. }()
  2814. }() | uint32_t(func() uint32 {
  2815. if Int32(0x80) == Int32(0x80) {
  2816. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2817. }
  2818. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2819. }()<<23)>>6 | uint32_t(0x7),
  2820. func() uint32 {
  2821. if 0x8 == 0 {
  2822. return func() uint32 {
  2823. if Int32(0xa0) == Int32(0x80) {
  2824. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2825. }
  2826. return Uint32(Uint32(0) - Uint32FromInt32(0xa0))
  2827. }() << 23
  2828. }
  2829. return func() uint32 {
  2830. if 0x8 == 0xd {
  2831. return func() uint32 {
  2832. if Int32(0x80) == Int32(0x80) {
  2833. return Uint32(Uint32(0x40) - Uint32FromInt32(0xa0))
  2834. }
  2835. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2836. }() << 23
  2837. }
  2838. return func() uint32 {
  2839. if Int32(0x80) == Int32(0x80) {
  2840. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2841. }
  2842. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2843. }() << 23
  2844. }()
  2845. }() | uint32_t(func() uint32 {
  2846. if Int32(0x80) == Int32(0x80) {
  2847. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2848. }
  2849. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2850. }()<<23)>>6 | uint32_t(0x8), func() uint32 {
  2851. if 0x9 == 0 {
  2852. return func() uint32 {
  2853. if Int32(0xa0) == Int32(0x80) {
  2854. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2855. }
  2856. return Uint32(Uint32(0) - Uint32FromInt32(0xa0))
  2857. }() << 23
  2858. }
  2859. return func() uint32 {
  2860. if 0x9 == 0xd {
  2861. return func() uint32 {
  2862. if Int32(0x80) == Int32(0x80) {
  2863. return Uint32(Uint32(0x40) - Uint32FromInt32(0xa0))
  2864. }
  2865. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2866. }() << 23
  2867. }
  2868. return func() uint32 {
  2869. if Int32(0x80) == Int32(0x80) {
  2870. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2871. }
  2872. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2873. }() << 23
  2874. }()
  2875. }() | uint32_t(func() uint32 {
  2876. if Int32(0x80) == Int32(0x80) {
  2877. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2878. }
  2879. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2880. }()<<23)>>6 | uint32_t(0x9), func() uint32 {
  2881. if 0xa == 0 {
  2882. return func() uint32 {
  2883. if Int32(0xa0) == Int32(0x80) {
  2884. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2885. }
  2886. return Uint32(Uint32(0) - Uint32FromInt32(0xa0))
  2887. }() << 23
  2888. }
  2889. return func() uint32 {
  2890. if 0xa == 0xd {
  2891. return func() uint32 {
  2892. if Int32(0x80) == Int32(0x80) {
  2893. return Uint32(Uint32(0x40) - Uint32FromInt32(0xa0))
  2894. }
  2895. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2896. }() << 23
  2897. }
  2898. return func() uint32 {
  2899. if Int32(0x80) == Int32(0x80) {
  2900. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2901. }
  2902. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2903. }() << 23
  2904. }()
  2905. }() | uint32_t(func() uint32 {
  2906. if Int32(0x80) == Int32(0x80) {
  2907. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2908. }
  2909. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2910. }()<<23)>>6 | uint32_t(0xa), func() uint32 {
  2911. if 0xb == 0 {
  2912. return func() uint32 {
  2913. if Int32(0xa0) == Int32(0x80) {
  2914. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2915. }
  2916. return Uint32(Uint32(0) - Uint32FromInt32(0xa0))
  2917. }() << 23
  2918. }
  2919. return func() uint32 {
  2920. if 0xb == 0xd {
  2921. return func() uint32 {
  2922. if Int32(0x80) == Int32(0x80) {
  2923. return Uint32(Uint32(0x40) - Uint32FromInt32(0xa0))
  2924. }
  2925. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2926. }() << 23
  2927. }
  2928. return func() uint32 {
  2929. if Int32(0x80) == Int32(0x80) {
  2930. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2931. }
  2932. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2933. }() << 23
  2934. }()
  2935. }() | uint32_t(func() uint32 {
  2936. if Int32(0x80) == Int32(0x80) {
  2937. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2938. }
  2939. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2940. }()<<23)>>6 | uint32_t(0xb), func() uint32 {
  2941. if 0xc == 0 {
  2942. return func() uint32 {
  2943. if Int32(0xa0) == Int32(0x80) {
  2944. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2945. }
  2946. return Uint32(Uint32(0) - Uint32FromInt32(0xa0))
  2947. }() << 23
  2948. }
  2949. return func() uint32 {
  2950. if 0xc == 0xd {
  2951. return func() uint32 {
  2952. if Int32(0x80) == Int32(0x80) {
  2953. return Uint32(Uint32(0x40) - Uint32FromInt32(0xa0))
  2954. }
  2955. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2956. }() << 23
  2957. }
  2958. return func() uint32 {
  2959. if Int32(0x80) == Int32(0x80) {
  2960. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2961. }
  2962. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2963. }() << 23
  2964. }()
  2965. }() | uint32_t(func() uint32 {
  2966. if Int32(0x80) == Int32(0x80) {
  2967. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2968. }
  2969. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2970. }()<<23)>>6 | uint32_t(0xc), func() uint32 {
  2971. if 0xd == 0 {
  2972. return func() uint32 {
  2973. if Int32(0xa0) == Int32(0x80) {
  2974. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2975. }
  2976. return Uint32(Uint32(0) - Uint32FromInt32(0xa0))
  2977. }() << 23
  2978. }
  2979. return func() uint32 {
  2980. if 0xd == 0xd {
  2981. return func() uint32 {
  2982. if Int32(0x80) == Int32(0x80) {
  2983. return Uint32(Uint32(0x40) - Uint32FromInt32(0xa0))
  2984. }
  2985. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2986. }() << 23
  2987. }
  2988. return func() uint32 {
  2989. if Int32(0x80) == Int32(0x80) {
  2990. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2991. }
  2992. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  2993. }() << 23
  2994. }()
  2995. }() | uint32_t(func() uint32 {
  2996. if Int32(0x80) == Int32(0x80) {
  2997. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  2998. }
  2999. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3000. }()<<23)>>6 | uint32_t(0xd), func() uint32 {
  3001. if 0xe == 0 {
  3002. return func() uint32 {
  3003. if Int32(0xa0) == Int32(0x80) {
  3004. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3005. }
  3006. return Uint32(Uint32(0) - Uint32FromInt32(0xa0))
  3007. }() << 23
  3008. }
  3009. return func() uint32 {
  3010. if 0xe == 0xd {
  3011. return func() uint32 {
  3012. if Int32(0x80) == Int32(0x80) {
  3013. return Uint32(Uint32(0x40) - Uint32FromInt32(0xa0))
  3014. }
  3015. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3016. }() << 23
  3017. }
  3018. return func() uint32 {
  3019. if Int32(0x80) == Int32(0x80) {
  3020. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3021. }
  3022. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3023. }() << 23
  3024. }()
  3025. }() | uint32_t(func() uint32 {
  3026. if Int32(0x80) == Int32(0x80) {
  3027. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3028. }
  3029. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3030. }()<<23)>>6 | uint32_t(0xe), func() uint32 {
  3031. if 0xf == 0 {
  3032. return func() uint32 {
  3033. if Int32(0xa0) == Int32(0x80) {
  3034. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3035. }
  3036. return Uint32(Uint32(0) - Uint32FromInt32(0xa0))
  3037. }() << 23
  3038. }
  3039. return func() uint32 {
  3040. if 0xf == 0xd {
  3041. return func() uint32 {
  3042. if Int32(0x80) == Int32(0x80) {
  3043. return Uint32(Uint32(0x40) - Uint32FromInt32(0xa0))
  3044. }
  3045. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3046. }() << 23
  3047. }
  3048. return func() uint32 {
  3049. if Int32(0x80) == Int32(0x80) {
  3050. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3051. }
  3052. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3053. }() << 23
  3054. }()
  3055. }() | uint32_t(func() uint32 {
  3056. if Int32(0x80) == Int32(0x80) {
  3057. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3058. }
  3059. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3060. }()<<23)>>6 | uint32_t(0xf),
  3061. func() uint32 {
  3062. if 0x0 >= 5 {
  3063. return uint32(0)
  3064. }
  3065. return func() uint32 {
  3066. if 0x0 == 0 {
  3067. return func() uint32 {
  3068. if Int32(0x90) == Int32(0x80) {
  3069. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3070. }
  3071. return Uint32(Uint32(0) - Uint32FromInt32(0x90))
  3072. }() << 23
  3073. }
  3074. return func() uint32 {
  3075. if 0x0 == 4 {
  3076. return func() uint32 {
  3077. if Int32(0x80) == Int32(0x80) {
  3078. return Uint32(Uint32(0x40) - Uint32FromInt32(0x90))
  3079. }
  3080. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3081. }() << 23
  3082. }
  3083. return func() uint32 {
  3084. if Int32(0x80) == Int32(0x80) {
  3085. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3086. }
  3087. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3088. }() << 23
  3089. }()
  3090. }()
  3091. }() | uint32_t(func() uint32 {
  3092. if Int32(0x80) == Int32(0x80) {
  3093. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3094. }
  3095. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3096. }()<<23)>>6 | uint32_t(func() uint32 {
  3097. if Int32(0x80) == Int32(0x80) {
  3098. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3099. }
  3100. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3101. }()<<23)>>12 | uint32_t(0x0), func() uint32 {
  3102. if 0x1 >= 5 {
  3103. return uint32(0)
  3104. }
  3105. return func() uint32 {
  3106. if 0x1 == 0 {
  3107. return func() uint32 {
  3108. if Int32(0x90) == Int32(0x80) {
  3109. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3110. }
  3111. return Uint32(Uint32(0) - Uint32FromInt32(0x90))
  3112. }() << 23
  3113. }
  3114. return func() uint32 {
  3115. if 0x1 == 4 {
  3116. return func() uint32 {
  3117. if Int32(0x80) == Int32(0x80) {
  3118. return Uint32(Uint32(0x40) - Uint32FromInt32(0x90))
  3119. }
  3120. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3121. }() << 23
  3122. }
  3123. return func() uint32 {
  3124. if Int32(0x80) == Int32(0x80) {
  3125. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3126. }
  3127. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3128. }() << 23
  3129. }()
  3130. }()
  3131. }() | uint32_t(func() uint32 {
  3132. if Int32(0x80) == Int32(0x80) {
  3133. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3134. }
  3135. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3136. }()<<23)>>6 | uint32_t(func() uint32 {
  3137. if Int32(0x80) == Int32(0x80) {
  3138. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3139. }
  3140. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3141. }()<<23)>>12 | uint32_t(0x1), func() uint32 {
  3142. if 0x2 >= 5 {
  3143. return uint32(0)
  3144. }
  3145. return func() uint32 {
  3146. if 0x2 == 0 {
  3147. return func() uint32 {
  3148. if Int32(0x90) == Int32(0x80) {
  3149. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3150. }
  3151. return Uint32(Uint32(0) - Uint32FromInt32(0x90))
  3152. }() << 23
  3153. }
  3154. return func() uint32 {
  3155. if 0x2 == 4 {
  3156. return func() uint32 {
  3157. if Int32(0x80) == Int32(0x80) {
  3158. return Uint32(Uint32(0x40) - Uint32FromInt32(0x90))
  3159. }
  3160. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3161. }() << 23
  3162. }
  3163. return func() uint32 {
  3164. if Int32(0x80) == Int32(0x80) {
  3165. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3166. }
  3167. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3168. }() << 23
  3169. }()
  3170. }()
  3171. }() | uint32_t(func() uint32 {
  3172. if Int32(0x80) == Int32(0x80) {
  3173. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3174. }
  3175. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3176. }()<<23)>>6 | uint32_t(func() uint32 {
  3177. if Int32(0x80) == Int32(0x80) {
  3178. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3179. }
  3180. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3181. }()<<23)>>12 | uint32_t(0x2), func() uint32 {
  3182. if 0x3 >= 5 {
  3183. return uint32(0)
  3184. }
  3185. return func() uint32 {
  3186. if 0x3 == 0 {
  3187. return func() uint32 {
  3188. if Int32(0x90) == Int32(0x80) {
  3189. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3190. }
  3191. return Uint32(Uint32(0) - Uint32FromInt32(0x90))
  3192. }() << 23
  3193. }
  3194. return func() uint32 {
  3195. if 0x3 == 4 {
  3196. return func() uint32 {
  3197. if Int32(0x80) == Int32(0x80) {
  3198. return Uint32(Uint32(0x40) - Uint32FromInt32(0x90))
  3199. }
  3200. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3201. }() << 23
  3202. }
  3203. return func() uint32 {
  3204. if Int32(0x80) == Int32(0x80) {
  3205. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3206. }
  3207. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3208. }() << 23
  3209. }()
  3210. }()
  3211. }() | uint32_t(func() uint32 {
  3212. if Int32(0x80) == Int32(0x80) {
  3213. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3214. }
  3215. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3216. }()<<23)>>6 | uint32_t(func() uint32 {
  3217. if Int32(0x80) == Int32(0x80) {
  3218. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3219. }
  3220. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3221. }()<<23)>>12 | uint32_t(0x3), func() uint32 {
  3222. if 0x4 >= 5 {
  3223. return uint32(0)
  3224. }
  3225. return func() uint32 {
  3226. if 0x4 == 0 {
  3227. return func() uint32 {
  3228. if Int32(0x90) == Int32(0x80) {
  3229. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3230. }
  3231. return Uint32(Uint32(0) - Uint32FromInt32(0x90))
  3232. }() << 23
  3233. }
  3234. return func() uint32 {
  3235. if 0x4 == 4 {
  3236. return func() uint32 {
  3237. if Int32(0x80) == Int32(0x80) {
  3238. return Uint32(Uint32(0x40) - Uint32FromInt32(0x90))
  3239. }
  3240. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3241. }() << 23
  3242. }
  3243. return func() uint32 {
  3244. if Int32(0x80) == Int32(0x80) {
  3245. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3246. }
  3247. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3248. }() << 23
  3249. }()
  3250. }()
  3251. }() | uint32_t(func() uint32 {
  3252. if Int32(0x80) == Int32(0x80) {
  3253. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3254. }
  3255. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3256. }()<<23)>>6 | uint32_t(func() uint32 {
  3257. if Int32(0x80) == Int32(0x80) {
  3258. return Uint32(Uint32(0x40) - Uint32FromInt32(0xc0))
  3259. }
  3260. return Uint32(Uint32(0) - Uint32FromInt32(0x80))
  3261. }()<<23)>>12 | uint32_t(0x4),
  3262. } /* internal.c:18:16 */
  3263. type wint_t = uint32 /* alltypes.h:198:18 */
  3264. type wctype_t = uint64 /* alltypes.h:203:23 */
  3265. type __mbstate_t = struct {
  3266. __opaque1 uint32
  3267. __opaque2 uint32
  3268. } /* alltypes.h:337:9 */
  3269. type mbstate_t = __mbstate_t /* alltypes.h:337:63 */
  3270. func Xmbrtowc(tls *TLS, wc uintptr, src uintptr, n size_t, st uintptr) size_t { /* mbrtowc.c:6:8: */
  3271. if __ccgo_strace {
  3272. trc("tls=%v wc=%v src=%v n=%v st=%v, (%v:)", tls, wc, src, n, st, origin(2))
  3273. }
  3274. bp := tls.Alloc(4)
  3275. defer tls.Free(4)
  3276. var c uint32
  3277. var s uintptr
  3278. var N uint32
  3279. // var dummy wchar_t at bp, 4
  3280. s = src
  3281. N = uint32(n)
  3282. if !!(st != 0) {
  3283. goto __1
  3284. }
  3285. st = uintptr(unsafe.Pointer(&_sinternal_state))
  3286. __1:
  3287. ;
  3288. c = *(*uint32)(unsafe.Pointer(st))
  3289. if !!(s != 0) {
  3290. goto __2
  3291. }
  3292. if !(c != 0) {
  3293. goto __4
  3294. }
  3295. goto ilseq
  3296. __4:
  3297. ;
  3298. return uint64(0)
  3299. goto __3
  3300. __2:
  3301. if !!(wc != 0) {
  3302. goto __5
  3303. }
  3304. wc = bp /* &dummy */
  3305. __5:
  3306. ;
  3307. __3:
  3308. ;
  3309. if !!(n != 0) {
  3310. goto __6
  3311. }
  3312. return Uint64FromInt32(-2)
  3313. __6:
  3314. ;
  3315. if !!(c != 0) {
  3316. goto __7
  3317. }
  3318. if !(int32(*(*uint8)(unsafe.Pointer(s))) < 0x80) {
  3319. goto __8
  3320. }
  3321. return BoolUint64(!!(AssignPtrInt32(wc, wchar_t(*(*uint8)(unsafe.Pointer(s)))) != 0))
  3322. __8:
  3323. ;
  3324. if !(func() int32 {
  3325. if !!(int32(*(*uintptr)(unsafe.Pointer((*__pthread)(unsafe.Pointer(__pthread_self(tls))).locale))) != 0) {
  3326. return 4
  3327. }
  3328. return 1
  3329. }() == 1) {
  3330. goto __9
  3331. }
  3332. *(*wchar_t)(unsafe.Pointer(wc)) = 0xdfff & int32(int8(*(*uint8)(unsafe.Pointer(s))))
  3333. return 1
  3334. __9:
  3335. ;
  3336. if !(uint32(*(*uint8)(unsafe.Pointer(s)))-0xc2 > 0xf4-0xc2) {
  3337. goto __10
  3338. }
  3339. goto ilseq
  3340. __10:
  3341. ;
  3342. c = X__fsmu8[uint32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&s, 1))))-0xc2]
  3343. n--
  3344. __7:
  3345. ;
  3346. if !(n != 0) {
  3347. goto __11
  3348. }
  3349. if !((int32(*(*uint8)(unsafe.Pointer(s)))>>3-0x10|(int32(*(*uint8)(unsafe.Pointer(s)))>>3+int32_t(c)>>26))&CplInt32(7) != 0) {
  3350. goto __12
  3351. }
  3352. goto ilseq
  3353. __12:
  3354. ;
  3355. loop:
  3356. c = c<<6 | uint32(int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&s, 1))))-0x80)
  3357. n--
  3358. if !!(c&(uint32(1)<<31) != 0) {
  3359. goto __13
  3360. }
  3361. *(*uint32)(unsafe.Pointer(st)) = uint32(0)
  3362. *(*wchar_t)(unsafe.Pointer(wc)) = wchar_t(c)
  3363. return size_t(N) - n
  3364. __13:
  3365. ;
  3366. if !(n != 0) {
  3367. goto __14
  3368. }
  3369. if !(uint32(*(*uint8)(unsafe.Pointer(s)))-0x80 >= uint32(0x40)) {
  3370. goto __15
  3371. }
  3372. goto ilseq
  3373. __15:
  3374. ;
  3375. goto loop
  3376. __14:
  3377. ;
  3378. __11:
  3379. ;
  3380. *(*uint32)(unsafe.Pointer(st)) = c
  3381. return Uint64FromInt32(-2)
  3382. ilseq:
  3383. *(*uint32)(unsafe.Pointer(st)) = uint32(0)
  3384. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 84
  3385. return Uint64FromInt32(-1)
  3386. }
  3387. var _sinternal_state uint32 /* mbrtowc.c:8:18: */
  3388. func Xmbsinit(tls *TLS, st uintptr) int32 { /* mbsinit.c:3:5: */
  3389. if __ccgo_strace {
  3390. trc("tls=%v st=%v, (%v:)", tls, st, origin(2))
  3391. }
  3392. return Bool32(!(st != 0) || !(int32(*(*uint32)(unsafe.Pointer(st))) != 0))
  3393. }
  3394. type imaxdiv_t = struct {
  3395. quot intmax_t
  3396. rem intmax_t
  3397. } /* inttypes.h:14:40 */
  3398. type socklen_t = uint32 /* alltypes.h:361:18 */
  3399. type sa_family_t = uint16 /* alltypes.h:366:24 */
  3400. type msghdr = struct {
  3401. msg_name uintptr
  3402. msg_namelen socklen_t
  3403. _ [4]byte
  3404. msg_iov uintptr
  3405. msg_iovlen int32
  3406. __pad1 int32
  3407. msg_control uintptr
  3408. msg_controllen socklen_t
  3409. __pad2 int32
  3410. msg_flags int32
  3411. _ [4]byte
  3412. } /* socket.h:22:1 */
  3413. type cmsghdr = struct {
  3414. cmsg_len socklen_t
  3415. __pad1 int32
  3416. cmsg_level int32
  3417. cmsg_type int32
  3418. } /* socket.h:44:1 */
  3419. type linger = struct {
  3420. l_onoff int32
  3421. l_linger int32
  3422. } /* socket.h:74:1 */
  3423. type sockaddr = struct {
  3424. sa_family sa_family_t
  3425. sa_data [14]int8
  3426. } /* socket.h:367:1 */
  3427. type sockaddr_storage = struct {
  3428. ss_family sa_family_t
  3429. __ss_padding [118]int8
  3430. __ss_align uint64
  3431. } /* socket.h:372:1 */
  3432. type in_port_t = uint16_t /* in.h:12:18 */
  3433. type in_addr_t = uint32_t /* in.h:13:18 */
  3434. type in_addr = struct{ s_addr in_addr_t } /* in.h:14:1 */
  3435. type sockaddr_in = struct {
  3436. sin_family sa_family_t
  3437. sin_port in_port_t
  3438. sin_addr struct{ s_addr in_addr_t }
  3439. sin_zero [8]uint8_t
  3440. } /* in.h:16:1 */
  3441. type in6_addr = struct {
  3442. __in6_union struct {
  3443. _ [0]uint32
  3444. __s6_addr [16]uint8_t
  3445. }
  3446. } /* in.h:23:1 */
  3447. type sockaddr_in6 = struct {
  3448. sin6_family sa_family_t
  3449. sin6_port in_port_t
  3450. sin6_flowinfo uint32_t
  3451. sin6_addr struct {
  3452. __in6_union struct {
  3453. _ [0]uint32
  3454. __s6_addr [16]uint8_t
  3455. }
  3456. }
  3457. sin6_scope_id uint32_t
  3458. } /* in.h:34:1 */
  3459. type ipv6_mreq = struct {
  3460. ipv6mr_multiaddr struct {
  3461. __in6_union struct {
  3462. _ [0]uint32
  3463. __s6_addr [16]uint8_t
  3464. }
  3465. }
  3466. ipv6mr_interface uint32
  3467. } /* in.h:42:1 */
  3468. type ip_opts = struct {
  3469. ip_dst struct{ s_addr in_addr_t }
  3470. ip_opts [40]int8
  3471. } /* in.h:229:1 */
  3472. type ip_mreq = struct {
  3473. imr_multiaddr struct{ s_addr in_addr_t }
  3474. imr_interface struct{ s_addr in_addr_t }
  3475. } /* in.h:247:1 */
  3476. type ip_mreqn = struct {
  3477. imr_multiaddr struct{ s_addr in_addr_t }
  3478. imr_address struct{ s_addr in_addr_t }
  3479. imr_ifindex int32
  3480. } /* in.h:252:1 */
  3481. type ip_mreq_source = struct {
  3482. imr_multiaddr struct{ s_addr in_addr_t }
  3483. imr_interface struct{ s_addr in_addr_t }
  3484. imr_sourceaddr struct{ s_addr in_addr_t }
  3485. } /* in.h:258:1 */
  3486. type ip_msfilter = struct {
  3487. imsf_multiaddr struct{ s_addr in_addr_t }
  3488. imsf_interface struct{ s_addr in_addr_t }
  3489. imsf_fmode uint32_t
  3490. imsf_numsrc uint32_t
  3491. imsf_slist [1]struct{ s_addr in_addr_t }
  3492. } /* in.h:264:1 */
  3493. type group_req = struct {
  3494. gr_interface uint32_t
  3495. _ [4]byte
  3496. gr_group struct {
  3497. ss_family sa_family_t
  3498. __ss_padding [118]int8
  3499. __ss_align uint64
  3500. }
  3501. } /* in.h:275:1 */
  3502. type group_source_req = struct {
  3503. gsr_interface uint32_t
  3504. _ [4]byte
  3505. gsr_group struct {
  3506. ss_family sa_family_t
  3507. __ss_padding [118]int8
  3508. __ss_align uint64
  3509. }
  3510. gsr_source struct {
  3511. ss_family sa_family_t
  3512. __ss_padding [118]int8
  3513. __ss_align uint64
  3514. }
  3515. } /* in.h:280:1 */
  3516. type group_filter = struct {
  3517. gf_interface uint32_t
  3518. _ [4]byte
  3519. gf_group struct {
  3520. ss_family sa_family_t
  3521. __ss_padding [118]int8
  3522. __ss_align uint64
  3523. }
  3524. gf_fmode uint32_t
  3525. gf_numsrc uint32_t
  3526. gf_slist [1]struct {
  3527. ss_family sa_family_t
  3528. __ss_padding [118]int8
  3529. __ss_align uint64
  3530. }
  3531. } /* in.h:286:1 */
  3532. type in_pktinfo = struct {
  3533. ipi_ifindex int32
  3534. ipi_spec_dst struct{ s_addr in_addr_t }
  3535. ipi_addr struct{ s_addr in_addr_t }
  3536. } /* in.h:297:1 */
  3537. type in6_pktinfo = struct {
  3538. ipi6_addr struct {
  3539. __in6_union struct {
  3540. _ [0]uint32
  3541. __s6_addr [16]uint8_t
  3542. }
  3543. }
  3544. ipi6_ifindex uint32
  3545. } /* in.h:303:1 */
  3546. type ip6_mtuinfo = struct {
  3547. ip6m_addr struct {
  3548. sin6_family sa_family_t
  3549. sin6_port in_port_t
  3550. sin6_flowinfo uint32_t
  3551. sin6_addr struct {
  3552. __in6_union struct {
  3553. _ [0]uint32
  3554. __s6_addr [16]uint8_t
  3555. }
  3556. }
  3557. sin6_scope_id uint32_t
  3558. }
  3559. ip6m_mtu uint32_t
  3560. } /* in.h:308:1 */
  3561. type addrinfo = struct {
  3562. ai_flags int32
  3563. ai_family int32
  3564. ai_socktype int32
  3565. ai_protocol int32
  3566. ai_addrlen socklen_t
  3567. _ [4]byte
  3568. ai_addr uintptr
  3569. ai_canonname uintptr
  3570. ai_next uintptr
  3571. } /* netdb.h:16:1 */
  3572. // Legacy functions follow (marked OBsolete in SUS)
  3573. type netent = struct {
  3574. n_name uintptr
  3575. n_aliases uintptr
  3576. n_addrtype int32
  3577. n_net uint32_t
  3578. } /* netdb.h:62:1 */
  3579. type hostent = struct {
  3580. h_name uintptr
  3581. h_aliases uintptr
  3582. h_addrtype int32
  3583. h_length int32
  3584. h_addr_list uintptr
  3585. } /* netdb.h:69:1 */
  3586. type servent = struct {
  3587. s_name uintptr
  3588. s_aliases uintptr
  3589. s_port int32
  3590. _ [4]byte
  3591. s_proto uintptr
  3592. } /* netdb.h:78:1 */
  3593. type protoent = struct {
  3594. p_name uintptr
  3595. p_aliases uintptr
  3596. p_proto int32
  3597. _ [4]byte
  3598. } /* netdb.h:85:1 */
  3599. type aibuf = struct {
  3600. ai struct {
  3601. ai_flags int32
  3602. ai_family int32
  3603. ai_socktype int32
  3604. ai_protocol int32
  3605. ai_addrlen socklen_t
  3606. _ [4]byte
  3607. ai_addr uintptr
  3608. ai_canonname uintptr
  3609. ai_next uintptr
  3610. }
  3611. sa struct {
  3612. sin struct {
  3613. sin_family sa_family_t
  3614. sin_port in_port_t
  3615. sin_addr struct{ s_addr in_addr_t }
  3616. sin_zero [8]uint8_t
  3617. }
  3618. _ [12]byte
  3619. }
  3620. lock [1]int32
  3621. slot int16
  3622. ref int16
  3623. _ [4]byte
  3624. } /* lookup.h:10:1 */
  3625. type sa = struct {
  3626. sin struct {
  3627. sin_family sa_family_t
  3628. sin_port in_port_t
  3629. sin_addr struct{ s_addr in_addr_t }
  3630. sin_zero [8]uint8_t
  3631. }
  3632. _ [12]byte
  3633. } /* lookup.h:10:1 */
  3634. type address = struct {
  3635. family int32
  3636. scopeid uint32
  3637. addr [16]uint8_t
  3638. sortkey int32
  3639. } /* lookup.h:20:1 */
  3640. type service = struct {
  3641. port uint16_t
  3642. proto uint8
  3643. socktype uint8
  3644. } /* lookup.h:27:1 */
  3645. type resolvconf = struct {
  3646. ns [3]struct {
  3647. family int32
  3648. scopeid uint32
  3649. addr [16]uint8_t
  3650. sortkey int32
  3651. }
  3652. nns uint32
  3653. attempts uint32
  3654. ndots uint32
  3655. timeout uint32
  3656. } /* lookup.h:34:1 */
  3657. func Xfreeaddrinfo(tls *TLS, p uintptr) { /* freeaddrinfo.c:7:6: */
  3658. if __ccgo_strace {
  3659. trc("tls=%v p=%v, (%v:)", tls, p, origin(2))
  3660. }
  3661. var cnt size_t
  3662. cnt = uint64(1)
  3663. __1:
  3664. if !((*addrinfo)(unsafe.Pointer(p)).ai_next != 0) {
  3665. goto __3
  3666. }
  3667. goto __2
  3668. __2:
  3669. cnt++
  3670. p = (*addrinfo)(unsafe.Pointer(p)).ai_next
  3671. goto __1
  3672. goto __3
  3673. __3:
  3674. ;
  3675. var b uintptr = p - uintptr(uint64(uintptr(0)))
  3676. b -= 88 * uintptr((*aibuf)(unsafe.Pointer(b)).slot)
  3677. //TODO LOCK(b->lock);
  3678. if !(int32(AssignSubPtrInt16(b+82, int16(cnt))) != 0) {
  3679. Xfree(tls, b)
  3680. }
  3681. //TODO else UNLOCK(b->lock);
  3682. }
  3683. func Xgetaddrinfo(tls *TLS, host uintptr, serv uintptr, hint uintptr, res uintptr) int32 { /* getaddrinfo.c:12:5: */
  3684. if __ccgo_strace {
  3685. trc("tls=%v host=%v serv=%v hint=%v res=%v, (%v:)", tls, host, serv, hint, res, origin(2))
  3686. }
  3687. bp := tls.Alloc(1608)
  3688. defer tls.Free(1608)
  3689. // var ports [2]service at bp, 8
  3690. // var addrs [48]address at bp+8, 1344
  3691. // var canon [256]int8 at bp+1352, 256
  3692. var outcanon uintptr
  3693. var nservs int32
  3694. var naddrs int32
  3695. var nais int32
  3696. var canon_len int32
  3697. var i int32
  3698. var j int32
  3699. var k int32
  3700. var family int32 = 0
  3701. var flags int32 = 0
  3702. var proto int32 = 0
  3703. var socktype int32 = 0
  3704. var out uintptr
  3705. if !(host != 0) && !(serv != 0) {
  3706. return -2
  3707. }
  3708. if hint != 0 {
  3709. family = (*addrinfo)(unsafe.Pointer(hint)).ai_family
  3710. flags = (*addrinfo)(unsafe.Pointer(hint)).ai_flags
  3711. proto = (*addrinfo)(unsafe.Pointer(hint)).ai_protocol
  3712. socktype = (*addrinfo)(unsafe.Pointer(hint)).ai_socktype
  3713. var mask int32 = 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x400
  3714. if flags&mask != flags {
  3715. return -1
  3716. }
  3717. switch family {
  3718. case 2:
  3719. fallthrough
  3720. case 10:
  3721. fallthrough
  3722. case 0:
  3723. break
  3724. fallthrough
  3725. default:
  3726. return -6
  3727. }
  3728. }
  3729. if flags&0x20 != 0 {
  3730. Xabort(tls) //TODO-
  3731. // /* Define the "an address is configured" condition for address
  3732. // * families via ability to create a socket for the family plus
  3733. // * routability of the loopback address for the family. */
  3734. // static const struct sockaddr_in lo4 = {
  3735. // .sin_family = AF_INET, .sin_port = 65535,
  3736. // .sin_addr.s_addr = __BYTE_ORDER == __BIG_ENDIAN
  3737. // ? 0x7f000001 : 0x0100007f
  3738. // };
  3739. // static const struct sockaddr_in6 lo6 = {
  3740. // .sin6_family = AF_INET6, .sin6_port = 65535,
  3741. // .sin6_addr = IN6ADDR_LOOPBACK_INIT
  3742. // };
  3743. // int tf[2] = { AF_INET, AF_INET6 };
  3744. // const void *ta[2] = { &lo4, &lo6 };
  3745. // socklen_t tl[2] = { sizeof lo4, sizeof lo6 };
  3746. // for (i=0; i<2; i++) {
  3747. // if (family==tf[1-i]) continue;
  3748. // int s = socket(tf[i], SOCK_CLOEXEC|SOCK_DGRAM,
  3749. // IPPROTO_UDP);
  3750. // if (s>=0) {
  3751. // int cs;
  3752. // pthread_setcancelstate(
  3753. // PTHREAD_CANCEL_DISABLE, &cs);
  3754. // int r = connect(s, ta[i], tl[i]);
  3755. // pthread_setcancelstate(cs, 0);
  3756. // close(s);
  3757. // if (!r) continue;
  3758. // }
  3759. // switch (errno) {
  3760. // case EADDRNOTAVAIL:
  3761. // case EAFNOSUPPORT:
  3762. // case EHOSTUNREACH:
  3763. // case ENETDOWN:
  3764. // case ENETUNREACH:
  3765. // break;
  3766. // default:
  3767. // return EAI_SYSTEM;
  3768. // }
  3769. // if (family == tf[i]) return EAI_NONAME;
  3770. // family = tf[1-i];
  3771. // }
  3772. }
  3773. nservs = X__lookup_serv(tls, bp, serv, proto, socktype, flags)
  3774. if nservs < 0 {
  3775. return nservs
  3776. }
  3777. naddrs = X__lookup_name(tls, bp+8, bp+1352, host, family, flags)
  3778. if naddrs < 0 {
  3779. return naddrs
  3780. }
  3781. nais = nservs * naddrs
  3782. canon_len = int32(Xstrlen(tls, bp+1352))
  3783. out = Xcalloc(tls, uint64(1), uint64(nais)*uint64(unsafe.Sizeof(aibuf{}))+uint64(canon_len)+uint64(1))
  3784. if !(out != 0) {
  3785. return -10
  3786. }
  3787. if canon_len != 0 {
  3788. outcanon = out + uintptr(nais)*88
  3789. Xmemcpy(tls, outcanon, bp+1352, uint64(canon_len+1))
  3790. } else {
  3791. outcanon = uintptr(0)
  3792. }
  3793. for k = AssignInt32(&i, 0); i < naddrs; i++ {
  3794. j = 0
  3795. __1:
  3796. if !(j < nservs) {
  3797. goto __3
  3798. }
  3799. {
  3800. (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).slot = int16(k)
  3801. //TODO out[k].ai = (struct addrinfo){
  3802. //TODO .ai_family = addrs[i].family,
  3803. //TODO .ai_socktype = ports[j].socktype,
  3804. //TODO .ai_protocol = ports[j].proto,
  3805. //TODO .ai_addrlen = addrs[i].family == AF_INET
  3806. //TODO ? sizeof(struct sockaddr_in)
  3807. //TODO : sizeof(struct sockaddr_in6),
  3808. //TODO .ai_addr = (void *)&out[k].sa,
  3809. //TODO .ai_canonname = outcanon };
  3810. (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).ai.ai_family = (*address)(unsafe.Pointer(bp + 8 + uintptr(i)*28)).family
  3811. (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).ai.ai_socktype = int32((*service)(unsafe.Pointer(bp + uintptr(j)*4)).socktype)
  3812. (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).ai.ai_protocol = int32((*service)(unsafe.Pointer(bp + uintptr(j)*4)).proto)
  3813. (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).ai.ai_addrlen = func() uint32 {
  3814. if (*address)(unsafe.Pointer(bp+8+uintptr(i)*28)).family == 2 {
  3815. return uint32(unsafe.Sizeof(sockaddr_in{}))
  3816. }
  3817. return uint32(unsafe.Sizeof(sockaddr_in6{}))
  3818. }()
  3819. (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).ai.ai_addr = out + uintptr(k)*88 + 48
  3820. (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).ai.ai_canonname = outcanon
  3821. if k != 0 {
  3822. (*aibuf)(unsafe.Pointer(out + uintptr(k-1)*88)).ai.ai_next = out + uintptr(k)*88
  3823. }
  3824. switch (*address)(unsafe.Pointer(bp + 8 + uintptr(i)*28)).family {
  3825. case 2:
  3826. (*sockaddr_in)(unsafe.Pointer(out + uintptr(k)*88 + 48)).sin_family = sa_family_t(2)
  3827. (*sockaddr_in)(unsafe.Pointer(out + uintptr(k)*88 + 48)).sin_port = Xhtons(tls, (*service)(unsafe.Pointer(bp+uintptr(j)*4)).port)
  3828. Xmemcpy(tls, out+uintptr(k)*88+48+4, bp+8+uintptr(i)*28+8, uint64(4))
  3829. break
  3830. case 10:
  3831. (*sockaddr_in6)(unsafe.Pointer(out + uintptr(k)*88 + 48)).sin6_family = sa_family_t(10)
  3832. (*sockaddr_in6)(unsafe.Pointer(out + uintptr(k)*88 + 48)).sin6_port = Xhtons(tls, (*service)(unsafe.Pointer(bp+uintptr(j)*4)).port)
  3833. (*sockaddr_in6)(unsafe.Pointer(out + uintptr(k)*88 + 48)).sin6_scope_id = (*address)(unsafe.Pointer(bp + 8 + uintptr(i)*28)).scopeid
  3834. Xmemcpy(tls, out+uintptr(k)*88+48+8, bp+8+uintptr(i)*28+8, uint64(16))
  3835. break
  3836. }
  3837. }
  3838. goto __2
  3839. __2:
  3840. j++
  3841. k++
  3842. goto __1
  3843. goto __3
  3844. __3:
  3845. }
  3846. (*aibuf)(unsafe.Pointer(out)).ref = int16(nais)
  3847. *(*uintptr)(unsafe.Pointer(res)) = out
  3848. return 0
  3849. }
  3850. type ucred = struct {
  3851. pid pid_t
  3852. uid uid_t
  3853. gid gid_t
  3854. } /* socket.h:57:1 */
  3855. type mmsghdr = struct {
  3856. msg_hdr struct {
  3857. msg_name uintptr
  3858. msg_namelen socklen_t
  3859. _ [4]byte
  3860. msg_iov uintptr
  3861. msg_iovlen int32
  3862. __pad1 int32
  3863. msg_control uintptr
  3864. msg_controllen socklen_t
  3865. __pad2 int32
  3866. msg_flags int32
  3867. _ [4]byte
  3868. }
  3869. msg_len uint32
  3870. _ [4]byte
  3871. } /* socket.h:63:1 */
  3872. func Xgethostbyaddr(tls *TLS, a uintptr, l socklen_t, af int32) uintptr { /* gethostbyaddr.c:7:16: */
  3873. if __ccgo_strace {
  3874. trc("tls=%v a=%v l=%v af=%v, (%v:)", tls, a, l, af, origin(2))
  3875. }
  3876. bp := tls.Alloc(8)
  3877. defer tls.Free(8)
  3878. var size size_t = uint64(63)
  3879. // var res uintptr at bp, 8
  3880. var err int32
  3881. for __ccgo := true; __ccgo; __ccgo = err == 34 {
  3882. Xfree(tls, _sh)
  3883. _sh = Xmalloc(tls, AssignAddUint64(&size, size+uint64(1)))
  3884. if !(_sh != 0) {
  3885. *(*int32)(unsafe.Pointer(X__h_errno_location(tls))) = 3
  3886. return uintptr(0)
  3887. }
  3888. err = Xgethostbyaddr_r(tls, a, l, af, _sh,
  3889. _sh+uintptr(1)*32, size-size_t(unsafe.Sizeof(hostent{})), bp, X__h_errno_location(tls))
  3890. }
  3891. if err != 0 {
  3892. return uintptr(0)
  3893. }
  3894. return _sh
  3895. }
  3896. var _sh uintptr /* gethostbyaddr.c:9:24: */
  3897. func Xgethostbyaddr_r(tls *TLS, a uintptr, l socklen_t, af int32, h uintptr, buf uintptr, buflen size_t, res uintptr, err uintptr) int32 { /* gethostbyaddr_r.c:10:5: */
  3898. if __ccgo_strace {
  3899. trc("tls=%v a=%v l=%v af=%v h=%v buf=%v buflen=%v res=%v err=%v, (%v:)", tls, a, l, af, h, buf, buflen, res, err, origin(2))
  3900. }
  3901. bp := tls.Alloc(28)
  3902. defer tls.Free(28)
  3903. //TODO union {
  3904. //TODO struct sockaddr_in sin;
  3905. //TODO struct sockaddr_in6 sin6;
  3906. //TODO } sa = { .sin.sin_family = af };
  3907. *(*struct {
  3908. sin sockaddr_in
  3909. _ [12]byte
  3910. })(unsafe.Pointer(bp)) = struct {
  3911. sin sockaddr_in
  3912. _ [12]byte
  3913. }{} //TODO-
  3914. (*sockaddr_in)(unsafe.Pointer(bp)).sin_family = sa_family_t(af) //TODO-
  3915. var sl socklen_t
  3916. if af == 10 {
  3917. sl = uint32(unsafe.Sizeof(sockaddr_in6{}))
  3918. } else {
  3919. sl = uint32(unsafe.Sizeof(sockaddr_in{}))
  3920. }
  3921. var i int32
  3922. *(*uintptr)(unsafe.Pointer(res)) = uintptr(0)
  3923. // Load address argument into sockaddr structure
  3924. if af == 10 && l == socklen_t(16) {
  3925. Xmemcpy(tls, bp+8, a, uint64(16))
  3926. } else if af == 2 && l == socklen_t(4) {
  3927. Xmemcpy(tls, bp+4, a, uint64(4))
  3928. } else {
  3929. *(*int32)(unsafe.Pointer(err)) = 3
  3930. return 22
  3931. }
  3932. // Align buffer and check for space for pointers and ip address
  3933. i = int32(uintptr_t(buf) & (uint64(unsafe.Sizeof(uintptr(0))) - uint64(1)))
  3934. if !(i != 0) {
  3935. i = int32(unsafe.Sizeof(uintptr(0)))
  3936. }
  3937. if buflen <= uint64(5)*uint64(unsafe.Sizeof(uintptr(0)))-uint64(i)+uint64(l) {
  3938. return 34
  3939. }
  3940. buf += uintptr(uint64(unsafe.Sizeof(uintptr(0))) - uint64(i))
  3941. buflen = buflen - (uint64(5)*uint64(unsafe.Sizeof(uintptr(0))) - uint64(i) + uint64(l))
  3942. (*hostent)(unsafe.Pointer(h)).h_addr_list = buf
  3943. buf += uintptr(uint64(2) * uint64(unsafe.Sizeof(uintptr(0))))
  3944. (*hostent)(unsafe.Pointer(h)).h_aliases = buf
  3945. buf += uintptr(uint64(2) * uint64(unsafe.Sizeof(uintptr(0))))
  3946. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_addr_list)) = buf
  3947. Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_addr_list)), a, uint64(l))
  3948. buf += uintptr(l)
  3949. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_addr_list + 1*8)) = uintptr(0)
  3950. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases)) = buf
  3951. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases + 1*8)) = uintptr(0)
  3952. switch Xgetnameinfo(tls, bp, sl, buf, uint32(buflen), uintptr(0), uint32(0), 0) {
  3953. case -3:
  3954. *(*int32)(unsafe.Pointer(err)) = 2
  3955. return 11
  3956. case -12:
  3957. return 34
  3958. default:
  3959. fallthrough
  3960. case -10:
  3961. fallthrough
  3962. case -11:
  3963. fallthrough
  3964. case -4:
  3965. *(*int32)(unsafe.Pointer(err)) = 3
  3966. return *(*int32)(unsafe.Pointer(X___errno_location(tls)))
  3967. case 0:
  3968. break
  3969. }
  3970. (*hostent)(unsafe.Pointer(h)).h_addrtype = af
  3971. (*hostent)(unsafe.Pointer(h)).h_length = int32(l)
  3972. (*hostent)(unsafe.Pointer(h)).h_name = *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases))
  3973. *(*uintptr)(unsafe.Pointer(res)) = h
  3974. return 0
  3975. }
  3976. func Xgethostbyname(tls *TLS, name uintptr) uintptr { /* gethostbyname.c:8:16: */
  3977. if __ccgo_strace {
  3978. trc("tls=%v name=%v, (%v:)", tls, name, origin(2))
  3979. }
  3980. return Xgethostbyname2(tls, name, 2)
  3981. }
  3982. func Xgethostbyname2(tls *TLS, name uintptr, af int32) uintptr { /* gethostbyname2.c:8:16: */
  3983. if __ccgo_strace {
  3984. trc("tls=%v name=%v af=%v, (%v:)", tls, name, af, origin(2))
  3985. }
  3986. bp := tls.Alloc(8)
  3987. defer tls.Free(8)
  3988. var size size_t = uint64(63)
  3989. // var res uintptr at bp, 8
  3990. var err int32
  3991. for __ccgo := true; __ccgo; __ccgo = err == 34 {
  3992. Xfree(tls, _sh1)
  3993. _sh1 = Xmalloc(tls, AssignAddUint64(&size, size+uint64(1)))
  3994. if !(_sh1 != 0) {
  3995. *(*int32)(unsafe.Pointer(X__h_errno_location(tls))) = 3
  3996. return uintptr(0)
  3997. }
  3998. err = Xgethostbyname2_r(tls, name, af, _sh1,
  3999. _sh1+uintptr(1)*32, size-size_t(unsafe.Sizeof(hostent{})), bp, X__h_errno_location(tls))
  4000. }
  4001. if err != 0 {
  4002. return uintptr(0)
  4003. }
  4004. return _sh1
  4005. }
  4006. var _sh1 uintptr /* gethostbyname2.c:10:24: */
  4007. func Xgethostbyname2_r(tls *TLS, name uintptr, af int32, h uintptr, buf uintptr, buflen size_t, res uintptr, err uintptr) int32 { /* gethostbyname2_r.c:11:5: */
  4008. if __ccgo_strace {
  4009. trc("tls=%v name=%v af=%v h=%v buf=%v buflen=%v res=%v err=%v, (%v:)", tls, name, af, h, buf, buflen, res, err, origin(2))
  4010. }
  4011. bp := tls.Alloc(1600)
  4012. defer tls.Free(1600)
  4013. // var addrs [48]address at bp, 1344
  4014. // var canon [256]int8 at bp+1344, 256
  4015. var i int32
  4016. var cnt int32
  4017. var align size_t
  4018. var need size_t
  4019. *(*uintptr)(unsafe.Pointer(res)) = uintptr(0)
  4020. cnt = X__lookup_name(tls, bp, bp+1344, name, af, 0x02)
  4021. if cnt < 0 {
  4022. switch cnt {
  4023. case -2:
  4024. *(*int32)(unsafe.Pointer(err)) = 1
  4025. return 2
  4026. fallthrough
  4027. case -3:
  4028. *(*int32)(unsafe.Pointer(err)) = 2
  4029. return 11
  4030. fallthrough
  4031. default:
  4032. fallthrough
  4033. case -4:
  4034. *(*int32)(unsafe.Pointer(err)) = 3
  4035. return 74
  4036. fallthrough
  4037. case -10:
  4038. fallthrough
  4039. case -11:
  4040. *(*int32)(unsafe.Pointer(err)) = 3
  4041. return *(*int32)(unsafe.Pointer(X___errno_location(tls)))
  4042. }
  4043. }
  4044. (*hostent)(unsafe.Pointer(h)).h_addrtype = af
  4045. (*hostent)(unsafe.Pointer(h)).h_length = func() int32 {
  4046. if af == 10 {
  4047. return 16
  4048. }
  4049. return 4
  4050. }()
  4051. // Align buffer
  4052. align = -uintptr_t(buf) & (uint64(unsafe.Sizeof(uintptr(0))) - uint64(1))
  4053. need = uint64(4) * uint64(unsafe.Sizeof(uintptr(0)))
  4054. need = need + uint64(cnt+1)*(uint64(unsafe.Sizeof(uintptr(0)))+uint64((*hostent)(unsafe.Pointer(h)).h_length))
  4055. need = need + (Xstrlen(tls, name) + uint64(1))
  4056. need = need + (Xstrlen(tls, bp+1344) + uint64(1))
  4057. need = need + align
  4058. if need > buflen {
  4059. return 34
  4060. }
  4061. buf += uintptr(align)
  4062. (*hostent)(unsafe.Pointer(h)).h_aliases = buf
  4063. buf += uintptr(uint64(3) * uint64(unsafe.Sizeof(uintptr(0))))
  4064. (*hostent)(unsafe.Pointer(h)).h_addr_list = buf
  4065. buf += uintptr(uint64(cnt+1) * uint64(unsafe.Sizeof(uintptr(0))))
  4066. for i = 0; i < cnt; i++ {
  4067. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_addr_list + uintptr(i)*8)) = buf
  4068. buf += uintptr((*hostent)(unsafe.Pointer(h)).h_length)
  4069. Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_addr_list + uintptr(i)*8)), bp+uintptr(i)*28+8, uint64((*hostent)(unsafe.Pointer(h)).h_length))
  4070. }
  4071. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_addr_list + uintptr(i)*8)) = uintptr(0)
  4072. (*hostent)(unsafe.Pointer(h)).h_name = AssignPtrUintptr((*hostent)(unsafe.Pointer(h)).h_aliases, buf)
  4073. Xstrcpy(tls, (*hostent)(unsafe.Pointer(h)).h_name, bp+1344)
  4074. buf += uintptr(Xstrlen(tls, (*hostent)(unsafe.Pointer(h)).h_name) + uint64(1))
  4075. if Xstrcmp(tls, (*hostent)(unsafe.Pointer(h)).h_name, name) != 0 {
  4076. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases + 1*8)) = buf
  4077. Xstrcpy(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases + 1*8)), name)
  4078. buf += uintptr(Xstrlen(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases + 1*8))) + uint64(1))
  4079. } else {
  4080. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases + 1*8)) = uintptr(0)
  4081. }
  4082. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).h_aliases + 2*8)) = uintptr(0)
  4083. *(*uintptr)(unsafe.Pointer(res)) = h
  4084. return 0
  4085. }
  4086. func Xgethostbyname_r(tls *TLS, name uintptr, h uintptr, buf uintptr, buflen size_t, res uintptr, err uintptr) int32 { /* gethostbyname_r.c:6:5: */
  4087. if __ccgo_strace {
  4088. trc("tls=%v name=%v h=%v buf=%v buflen=%v res=%v err=%v, (%v:)", tls, name, h, buf, buflen, res, err, origin(2))
  4089. }
  4090. return Xgethostbyname2_r(tls, name, 2, h, buf, buflen, res, err)
  4091. }
  4092. type if_nameindex = struct {
  4093. if_index uint32
  4094. _ [4]byte
  4095. if_name uintptr
  4096. } /* if.h:12:1 */
  4097. type ifaddr = struct {
  4098. ifa_addr struct {
  4099. sa_family sa_family_t
  4100. sa_data [14]int8
  4101. }
  4102. ifa_ifu struct {
  4103. ifu_broadaddr struct {
  4104. sa_family sa_family_t
  4105. sa_data [14]int8
  4106. }
  4107. }
  4108. ifa_ifp uintptr
  4109. ifa_next uintptr
  4110. } /* if.h:51:1 */
  4111. type ifmap = struct {
  4112. mem_start uint64
  4113. mem_end uint64
  4114. base_addr uint16
  4115. irq uint8
  4116. dma uint8
  4117. port uint8
  4118. _ [3]byte
  4119. } /* if.h:64:1 */
  4120. type ifreq = struct {
  4121. ifr_ifrn struct{ ifrn_name [16]int8 }
  4122. ifr_ifru struct {
  4123. _ [0]uint64
  4124. ifru_addr struct {
  4125. sa_family sa_family_t
  4126. sa_data [14]int8
  4127. }
  4128. _ [8]byte
  4129. }
  4130. } /* if.h:76:1 */
  4131. type ifconf = struct {
  4132. ifc_len int32
  4133. _ [4]byte
  4134. ifc_ifcu struct{ ifcu_buf uintptr }
  4135. } /* if.h:116:1 */
  4136. type ns_sect = uint32 /* nameser.h:37:3 */
  4137. type __ns_msg = struct {
  4138. _msg uintptr
  4139. _eom uintptr
  4140. _id uint16_t
  4141. _flags uint16_t
  4142. _counts [4]uint16_t
  4143. _ [4]byte
  4144. _sections [4]uintptr
  4145. _sect ns_sect
  4146. _rrnum int32
  4147. _msg_ptr uintptr
  4148. } /* nameser.h:39:9 */
  4149. type ns_msg = __ns_msg /* nameser.h:46:3 */
  4150. type _ns_flagdata = struct {
  4151. mask int32
  4152. shift int32
  4153. } /* nameser.h:48:1 */
  4154. type __ns_rr = struct {
  4155. name [1025]int8
  4156. _ [1]byte
  4157. __type uint16_t
  4158. rr_class uint16_t
  4159. _ [2]byte
  4160. ttl uint32_t
  4161. rdlength uint16_t
  4162. _ [2]byte
  4163. rdata uintptr
  4164. } /* nameser.h:59:9 */
  4165. type ns_rr = __ns_rr /* nameser.h:66:3 */
  4166. type ns_flag = uint32 /* nameser.h:87:3 */
  4167. type ns_opcode = uint32 /* nameser.h:96:3 */
  4168. type ns_rcode = uint32 /* nameser.h:115:3 */
  4169. type ns_update_operation = uint32 /* nameser.h:121:3 */
  4170. type ns_tsig_key1 = struct {
  4171. name [1025]int8
  4172. alg [1025]int8
  4173. _ [6]byte
  4174. data uintptr
  4175. len int32
  4176. _ [4]byte
  4177. } /* nameser.h:123:1 */
  4178. type ns_tsig_key = ns_tsig_key1 /* nameser.h:128:28 */
  4179. type ns_tcp_tsig_state1 = struct {
  4180. counter int32
  4181. _ [4]byte
  4182. key uintptr
  4183. ctx uintptr
  4184. sig [512]uint8
  4185. siglen int32
  4186. _ [4]byte
  4187. } /* nameser.h:130:1 */
  4188. type ns_tcp_tsig_state = ns_tcp_tsig_state1 /* nameser.h:137:34 */
  4189. type ns_type = uint32 /* nameser.h:200:3 */
  4190. type ns_class = uint32 /* nameser.h:219:3 */
  4191. type ns_key_types = uint32 /* nameser.h:226:3 */
  4192. type ns_cert_types = uint32 /* nameser.h:234:3 */
  4193. type HEADER = struct {
  4194. _ [0]uint32
  4195. id uint32 /* unsigned id: 16, unsigned rd: 1, unsigned tc: 1, unsigned aa: 1, unsigned opcode: 4, unsigned qr: 1, unsigned rcode: 4, unsigned cd: 1, unsigned ad: 1, unsigned unused: 1, unsigned ra: 1 */
  4196. qdcount uint32 /* unsigned qdcount: 16, unsigned ancount: 16 */
  4197. nscount uint32 /* unsigned nscount: 16, unsigned arcount: 16 */
  4198. } /* nameser.h:353:3 */
  4199. // unused; purely for broken apps
  4200. type __res_state = struct {
  4201. retrans int32
  4202. retry int32
  4203. options uint64
  4204. nscount int32
  4205. nsaddr_list [3]struct {
  4206. sin_family sa_family_t
  4207. sin_port in_port_t
  4208. sin_addr struct{ s_addr in_addr_t }
  4209. sin_zero [8]uint8_t
  4210. }
  4211. id uint16
  4212. _ [2]byte
  4213. dnsrch [7]uintptr
  4214. defdname [256]int8
  4215. pfcode uint64
  4216. ndots uint32 /* unsigned ndots: 4, unsigned nsort: 4, unsigned ipv6_unavail: 1, unsigned unused: 23 */
  4217. _ [4]byte
  4218. sort_list [10]struct {
  4219. addr struct{ s_addr in_addr_t }
  4220. mask uint32_t
  4221. }
  4222. qhook uintptr
  4223. rhook uintptr
  4224. res_h_errno int32
  4225. _vcsock int32
  4226. _flags uint32
  4227. _ [4]byte
  4228. _u struct {
  4229. _ [0]uint64
  4230. pad [52]int8
  4231. _ [4]byte
  4232. }
  4233. } /* resolv.h:26:9 */
  4234. // unused; purely for broken apps
  4235. type res_state = uintptr /* resolv.h:62:3 */
  4236. type res_sym = struct {
  4237. number int32
  4238. _ [4]byte
  4239. name uintptr
  4240. humanname uintptr
  4241. } /* resolv.h:70:1 */
  4242. func itoa(tls *TLS, p uintptr, x uint32) uintptr { /* getnameinfo.c:18:13: */
  4243. p += uintptr(uint64(3) * uint64(unsafe.Sizeof(int32(0))))
  4244. *(*int8)(unsafe.Pointer(PreDecUintptr(&p, 1))) = int8(0)
  4245. for __ccgo := true; __ccgo; __ccgo = x != 0 {
  4246. *(*int8)(unsafe.Pointer(PreDecUintptr(&p, 1))) = int8(uint32('0') + x%uint32(10))
  4247. x = x / uint32(10)
  4248. }
  4249. return p
  4250. }
  4251. func mkptr4(tls *TLS, s uintptr, ip uintptr) { /* getnameinfo.c:28:13: */
  4252. bp := tls.Alloc(32)
  4253. defer tls.Free(32)
  4254. Xsprintf(tls, s, ts+25,
  4255. VaList(bp, int32(*(*uint8)(unsafe.Pointer(ip + 3))), int32(*(*uint8)(unsafe.Pointer(ip + 2))), int32(*(*uint8)(unsafe.Pointer(ip + 1))), int32(*(*uint8)(unsafe.Pointer(ip)))))
  4256. }
  4257. func mkptr6(tls *TLS, s uintptr, ip uintptr) { /* getnameinfo.c:34:13: */
  4258. var i int32
  4259. for i = 15; i >= 0; i-- {
  4260. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = _sxdigits[int32(*(*uint8)(unsafe.Pointer(ip + uintptr(i))))&15]
  4261. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8('.')
  4262. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = _sxdigits[int32(*(*uint8)(unsafe.Pointer(ip + uintptr(i))))>>4]
  4263. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8('.')
  4264. }
  4265. Xstrcpy(tls, s, ts+50)
  4266. }
  4267. var _sxdigits = *(*[17]int8)(unsafe.Pointer(ts + 59)) /* getnameinfo.c:36:20 */
  4268. func reverse_hosts(tls *TLS, buf uintptr, a uintptr, scopeid uint32, family int32) { /* getnameinfo.c:45:13: */
  4269. bp := tls.Alloc(556)
  4270. defer tls.Free(556)
  4271. // var line [512]int8 at bp+16, 512
  4272. var p uintptr
  4273. var z uintptr
  4274. var _buf [1032]uint8
  4275. _ = _buf
  4276. // var atmp [16]uint8 at bp, 16
  4277. // var iplit address at bp+528, 28
  4278. //TODO FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf);
  4279. var f uintptr = Xfopen(tls, ts+76, ts+87)
  4280. if !(f != 0) {
  4281. return
  4282. }
  4283. if family == 2 {
  4284. Xmemcpy(tls, bp+uintptr(12), a, uint64(4))
  4285. Xmemcpy(tls, bp, ts+90, uint64(12))
  4286. a = bp /* &atmp[0] */
  4287. }
  4288. for Xfgets(tls, bp+16, int32(unsafe.Sizeof([512]int8{})), f) != 0 {
  4289. if AssignUintptr(&p, Xstrchr(tls, bp+16, '#')) != 0 {
  4290. *(*int8)(unsafe.Pointer(PostIncUintptr(&p, 1))) = int8('\n')
  4291. *(*int8)(unsafe.Pointer(p)) = int8(0)
  4292. }
  4293. for p = bp + 16; /* &line[0] */ *(*int8)(unsafe.Pointer(p)) != 0 && !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(p)))) != 0); p++ {
  4294. }
  4295. *(*int8)(unsafe.Pointer(PostIncUintptr(&p, 1))) = int8(0)
  4296. if X__lookup_ipliteral(tls, bp+528, bp+16, 0) <= 0 {
  4297. continue
  4298. }
  4299. if (*address)(unsafe.Pointer(bp+528)).family == 2 {
  4300. Xmemcpy(tls, bp+528+8+uintptr(12), bp+528+8, uint64(4))
  4301. Xmemcpy(tls, bp+528+8, ts+90, uint64(12))
  4302. (*address)(unsafe.Pointer(bp + 528 /* &iplit */)).scopeid = uint32(0)
  4303. }
  4304. if Xmemcmp(tls, a, bp+528+8, uint64(16)) != 0 || (*address)(unsafe.Pointer(bp+528)).scopeid != scopeid {
  4305. continue
  4306. }
  4307. for ; *(*int8)(unsafe.Pointer(p)) != 0 && __isspace(tls, int32(*(*int8)(unsafe.Pointer(p)))) != 0; p++ {
  4308. }
  4309. for z = p; *(*int8)(unsafe.Pointer(z)) != 0 && !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(z)))) != 0); z++ {
  4310. }
  4311. *(*int8)(unsafe.Pointer(z)) = int8(0)
  4312. if (int64(z)-int64(p))/1 < int64(256) {
  4313. Xmemcpy(tls, buf, p, uint64((int64(z)-int64(p))/1+int64(1)))
  4314. break
  4315. }
  4316. }
  4317. //TODO __fclose_ca(f);
  4318. Xfclose(tls, f)
  4319. }
  4320. func reverse_services(tls *TLS, buf uintptr, port int32, dgram int32) { /* getnameinfo.c:87:13: */
  4321. Xabort(tls) //TODO-
  4322. // unsigned long svport;
  4323. // char line[128], *p, *z;
  4324. // unsigned char _buf[1032];
  4325. // FILE _f, *f = __fopen_rb_ca("/etc/services", &_f, _buf, sizeof _buf);
  4326. // if (!f) return;
  4327. // while (fgets(line, sizeof line, f)) {
  4328. // if ((p=strchr(line, '#'))) *p++='\n', *p=0;
  4329. // for (p=line; *p && !isspace(*p); p++);
  4330. // if (!*p) continue;
  4331. // *p++ = 0;
  4332. // svport = strtoul(p, &z, 10);
  4333. // if (svport != port || z==p) continue;
  4334. // if (dgram && strncmp(z, "/udp", 4)) continue;
  4335. // if (!dgram && strncmp(z, "/tcp", 4)) continue;
  4336. // if (p-line > 32) continue;
  4337. // memcpy(buf, line, p-line);
  4338. // break;
  4339. // }
  4340. // __fclose_ca(f);
  4341. }
  4342. func Xgetnameinfo(tls *TLS, sa1 uintptr, sl socklen_t, node uintptr, nodelen socklen_t, serv uintptr, servlen socklen_t, flags int32) int32 { /* getnameinfo.c:125:5: */
  4343. if __ccgo_strace {
  4344. trc("tls=%v sa1=%v sl=%v node=%v nodelen=%v serv=%v servlen=%v flags=%v, (%v:)", tls, sa1, sl, node, nodelen, serv, servlen, flags, origin(2))
  4345. }
  4346. bp := tls.Alloc(347)
  4347. defer tls.Free(347)
  4348. // var ptr [78]int8 at bp, 78
  4349. // var buf [256]int8 at bp+78, 256
  4350. // var num [13]int8 at bp+334, 13
  4351. var af int32 = int32((*sockaddr)(unsafe.Pointer(sa1)).sa_family)
  4352. var a uintptr
  4353. var scopeid uint32
  4354. switch af {
  4355. case 2:
  4356. a = sa1 + 4
  4357. if uint64(sl) < uint64(unsafe.Sizeof(sockaddr_in{})) {
  4358. return -6
  4359. }
  4360. mkptr4(tls, bp, a)
  4361. scopeid = uint32(0)
  4362. break
  4363. case 10:
  4364. a = sa1 + 8
  4365. if uint64(sl) < uint64(unsafe.Sizeof(sockaddr_in6{})) {
  4366. return -6
  4367. }
  4368. if Xmemcmp(tls, a, ts+90, uint64(12)) != 0 {
  4369. mkptr6(tls, bp, a)
  4370. } else {
  4371. mkptr4(tls, bp, a+uintptr(12))
  4372. }
  4373. scopeid = (*sockaddr_in6)(unsafe.Pointer(sa1)).sin6_scope_id
  4374. break
  4375. default:
  4376. return -6
  4377. }
  4378. if node != 0 && nodelen != 0 {
  4379. *(*int8)(unsafe.Pointer(bp + 78)) = int8(0)
  4380. if !(flags&0x01 != 0) {
  4381. reverse_hosts(tls, bp+78, a, scopeid, af)
  4382. }
  4383. if !(int32(*(*int8)(unsafe.Pointer(bp + 78))) != 0) && !(flags&0x01 != 0) {
  4384. Xabort(tls) //TODO-
  4385. // unsigned char query[18+PTR_MAX], reply[512];
  4386. // int qlen = __res_mkquery(0, ptr, 1, RR_PTR,
  4387. // 0, 0, 0, query, sizeof query);
  4388. // query[3] = 0; /* don't need AD flag */
  4389. // int rlen = __res_send(query, qlen, reply, sizeof reply);
  4390. // buf[0] = 0;
  4391. // if (rlen > 0)
  4392. // __dns_parse(reply, rlen, dns_parse_callback, buf);
  4393. }
  4394. if !(int32(*(*int8)(unsafe.Pointer(bp + 78))) != 0) {
  4395. if flags&0x08 != 0 {
  4396. return -2
  4397. }
  4398. Xinet_ntop(tls, af, a, bp+78, uint32(unsafe.Sizeof([256]int8{})))
  4399. if scopeid != 0 {
  4400. Xabort(tls) //TODO-
  4401. // char *p = 0, tmp[IF_NAMESIZE+1];
  4402. // if (!(flags & NI_NUMERICSCOPE) &&
  4403. // (IN6_IS_ADDR_LINKLOCAL(a) ||
  4404. // IN6_IS_ADDR_MC_LINKLOCAL(a)))
  4405. // p = if_indextoname(scopeid, tmp+1);
  4406. // if (!p)
  4407. // p = itoa(num, scopeid);
  4408. // *--p = '%';
  4409. // strcat(buf, p);
  4410. }
  4411. }
  4412. if Xstrlen(tls, bp+78) >= size_t(nodelen) {
  4413. return -12
  4414. }
  4415. Xstrcpy(tls, node, bp+78)
  4416. }
  4417. if serv != 0 && servlen != 0 {
  4418. var p uintptr = bp + 78 /* buf */
  4419. var port int32 = int32(Xntohs(tls, (*sockaddr_in)(unsafe.Pointer(sa1)).sin_port))
  4420. *(*int8)(unsafe.Pointer(bp + 78)) = int8(0)
  4421. if !(flags&0x02 != 0) {
  4422. reverse_services(tls, bp+78, port, flags&0x10)
  4423. }
  4424. if !(int32(*(*int8)(unsafe.Pointer(p))) != 0) {
  4425. p = itoa(tls, bp+334, uint32(port))
  4426. }
  4427. if Xstrlen(tls, p) >= size_t(servlen) {
  4428. return -12
  4429. }
  4430. Xstrcpy(tls, serv, p)
  4431. }
  4432. return 0
  4433. }
  4434. var Xh_errno int32 /* h_errno.c:4:5: */
  4435. func X__h_errno_location(tls *TLS) uintptr { /* h_errno.c:6:5: */
  4436. if __ccgo_strace {
  4437. trc("tls=%v, (%v:)", tls, origin(2))
  4438. }
  4439. return uintptr(unsafe.Pointer(&Xh_errno))
  4440. }
  4441. func X__inet_aton(tls *TLS, s0 uintptr, dest uintptr) int32 { /* inet_aton.c:7:5: */
  4442. if __ccgo_strace {
  4443. trc("tls=%v s0=%v dest=%v, (%v:)", tls, s0, dest, origin(2))
  4444. }
  4445. bp := tls.Alloc(40)
  4446. defer tls.Free(40)
  4447. var s uintptr = s0
  4448. var d uintptr = dest
  4449. *(*[4]uint64)(unsafe.Pointer(bp /* a */)) = [4]uint64{0: uint64(0)}
  4450. // var z uintptr at bp+32, 8
  4451. var i int32
  4452. for i = 0; i < 4; i++ {
  4453. *(*uint64)(unsafe.Pointer(bp + uintptr(i)*8)) = Xstrtoul(tls, s, bp+32, 0)
  4454. if *(*uintptr)(unsafe.Pointer(bp + 32)) == s || *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32)))) != 0 && int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32))))) != '.' || !(func() int32 {
  4455. if 0 != 0 {
  4456. return Xisdigit(tls, int32(*(*int8)(unsafe.Pointer(s))))
  4457. }
  4458. return Bool32(uint32(*(*int8)(unsafe.Pointer(s)))-uint32('0') < uint32(10))
  4459. }() != 0) {
  4460. return 0
  4461. }
  4462. if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32))))) != 0) {
  4463. break
  4464. }
  4465. s = *(*uintptr)(unsafe.Pointer(bp + 32)) + uintptr(1)
  4466. }
  4467. if i == 4 {
  4468. return 0
  4469. }
  4470. switch i {
  4471. case 0:
  4472. *(*uint64)(unsafe.Pointer(bp + 1*8)) = *(*uint64)(unsafe.Pointer(bp)) & uint64(0xffffff)
  4473. AssignShrPtrUint64(bp, int(24))
  4474. fallthrough
  4475. case 1:
  4476. *(*uint64)(unsafe.Pointer(bp + 2*8)) = *(*uint64)(unsafe.Pointer(bp + 1*8)) & uint64(0xffff)
  4477. AssignShrPtrUint64(bp+1*8, int(16))
  4478. fallthrough
  4479. case 2:
  4480. *(*uint64)(unsafe.Pointer(bp + 3*8)) = *(*uint64)(unsafe.Pointer(bp + 2*8)) & uint64(0xff)
  4481. AssignShrPtrUint64(bp+2*8, int(8))
  4482. }
  4483. for i = 0; i < 4; i++ {
  4484. if *(*uint64)(unsafe.Pointer(bp + uintptr(i)*8)) > uint64(255) {
  4485. return 0
  4486. }
  4487. *(*uint8)(unsafe.Pointer(d + uintptr(i))) = uint8(*(*uint64)(unsafe.Pointer(bp + uintptr(i)*8)))
  4488. }
  4489. return 1
  4490. }
  4491. func Xinet_ntop(tls *TLS, af int32, a0 uintptr, s uintptr, l socklen_t) uintptr { /* inet_ntop.c:7:12: */
  4492. if __ccgo_strace {
  4493. trc("tls=%v af=%v a0=%v s=%v l=%v, (%v:)", tls, af, a0, s, l, origin(2))
  4494. }
  4495. bp := tls.Alloc(276)
  4496. defer tls.Free(276)
  4497. var a uintptr = a0
  4498. var i int32
  4499. var j int32
  4500. var max int32
  4501. var best int32
  4502. // var buf [100]int8 at bp+176, 100
  4503. switch af {
  4504. case 2:
  4505. if socklen_t(Xsnprintf(tls, s, uint64(l), ts+103, VaList(bp, int32(*(*uint8)(unsafe.Pointer(a))), int32(*(*uint8)(unsafe.Pointer(a + 1))), int32(*(*uint8)(unsafe.Pointer(a + 2))), int32(*(*uint8)(unsafe.Pointer(a + 3)))))) < l {
  4506. return s
  4507. }
  4508. break
  4509. case 10:
  4510. if Xmemcmp(tls, a, ts+90, uint64(12)) != 0 {
  4511. Xsnprintf(tls, bp+176, uint64(unsafe.Sizeof([100]int8{})),
  4512. ts+115,
  4513. VaList(bp+32, 256*int32(*(*uint8)(unsafe.Pointer(a)))+int32(*(*uint8)(unsafe.Pointer(a + 1))), 256*int32(*(*uint8)(unsafe.Pointer(a + 2)))+int32(*(*uint8)(unsafe.Pointer(a + 3))),
  4514. 256*int32(*(*uint8)(unsafe.Pointer(a + 4)))+int32(*(*uint8)(unsafe.Pointer(a + 5))), 256*int32(*(*uint8)(unsafe.Pointer(a + 6)))+int32(*(*uint8)(unsafe.Pointer(a + 7))),
  4515. 256*int32(*(*uint8)(unsafe.Pointer(a + 8)))+int32(*(*uint8)(unsafe.Pointer(a + 9))), 256*int32(*(*uint8)(unsafe.Pointer(a + 10)))+int32(*(*uint8)(unsafe.Pointer(a + 11))),
  4516. 256*int32(*(*uint8)(unsafe.Pointer(a + 12)))+int32(*(*uint8)(unsafe.Pointer(a + 13))), 256*int32(*(*uint8)(unsafe.Pointer(a + 14)))+int32(*(*uint8)(unsafe.Pointer(a + 15)))))
  4517. } else {
  4518. Xsnprintf(tls, bp+176, uint64(unsafe.Sizeof([100]int8{})),
  4519. ts+139,
  4520. VaList(bp+96, 256*int32(*(*uint8)(unsafe.Pointer(a)))+int32(*(*uint8)(unsafe.Pointer(a + 1))), 256*int32(*(*uint8)(unsafe.Pointer(a + 2)))+int32(*(*uint8)(unsafe.Pointer(a + 3))),
  4521. 256*int32(*(*uint8)(unsafe.Pointer(a + 4)))+int32(*(*uint8)(unsafe.Pointer(a + 5))), 256*int32(*(*uint8)(unsafe.Pointer(a + 6)))+int32(*(*uint8)(unsafe.Pointer(a + 7))),
  4522. 256*int32(*(*uint8)(unsafe.Pointer(a + 8)))+int32(*(*uint8)(unsafe.Pointer(a + 9))), 256*int32(*(*uint8)(unsafe.Pointer(a + 10)))+int32(*(*uint8)(unsafe.Pointer(a + 11))),
  4523. int32(*(*uint8)(unsafe.Pointer(a + 12))), int32(*(*uint8)(unsafe.Pointer(a + 13))), int32(*(*uint8)(unsafe.Pointer(a + 14))), int32(*(*uint8)(unsafe.Pointer(a + 15)))))
  4524. }
  4525. // Replace longest /(^0|:)[:0]{2,}/ with "::"
  4526. i = AssignInt32(&best, 0)
  4527. max = 2
  4528. for ; *(*int8)(unsafe.Pointer(bp + 176 + uintptr(i))) != 0; i++ {
  4529. if i != 0 && int32(*(*int8)(unsafe.Pointer(bp + 176 + uintptr(i)))) != ':' {
  4530. continue
  4531. }
  4532. j = int32(Xstrspn(tls, bp+176+uintptr(i), ts+169))
  4533. if j > max {
  4534. best = i
  4535. max = j
  4536. }
  4537. }
  4538. if max > 3 {
  4539. *(*int8)(unsafe.Pointer(bp + 176 + uintptr(best))) = AssignPtrInt8(bp+176+uintptr(best+1), int8(':'))
  4540. Xmemmove(tls, bp+176+uintptr(best)+uintptr(2), bp+176+uintptr(best)+uintptr(max), uint64(i-best-max+1))
  4541. }
  4542. if Xstrlen(tls, bp+176) < size_t(l) {
  4543. Xstrcpy(tls, s, bp+176)
  4544. return s
  4545. }
  4546. break
  4547. default:
  4548. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 97
  4549. return uintptr(0)
  4550. }
  4551. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 28
  4552. return uintptr(0)
  4553. }
  4554. func hexval(tls *TLS, c uint32) int32 { /* inet_pton.c:7:12: */
  4555. if c-uint32('0') < uint32(10) {
  4556. return int32(c - uint32('0'))
  4557. }
  4558. c = c | uint32(32)
  4559. if c-uint32('a') < uint32(6) {
  4560. return int32(c - uint32('a') + uint32(10))
  4561. }
  4562. return -1
  4563. }
  4564. func Xinet_pton(tls *TLS, af int32, s uintptr, a0 uintptr) int32 { /* inet_pton.c:15:5: */
  4565. if __ccgo_strace {
  4566. trc("tls=%v af=%v s=%v a0=%v, (%v:)", tls, af, s, a0, origin(2))
  4567. }
  4568. bp := tls.Alloc(16)
  4569. defer tls.Free(16)
  4570. // var ip [8]uint16_t at bp, 16
  4571. var a uintptr = a0
  4572. var i int32
  4573. var j int32
  4574. var v int32
  4575. var d int32
  4576. var brk int32 = -1
  4577. var need_v4 int32 = 0
  4578. if af == 2 {
  4579. for i = 0; i < 4; i++ {
  4580. for v = AssignInt32(&j, 0); j < 3 && func() int32 {
  4581. if 0 != 0 {
  4582. return Xisdigit(tls, int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))))
  4583. }
  4584. return Bool32(uint32(*(*int8)(unsafe.Pointer(s + uintptr(j))))-uint32('0') < uint32(10))
  4585. }() != 0; j++ {
  4586. v = 10*v + int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) - '0'
  4587. }
  4588. if j == 0 || j > 1 && int32(*(*int8)(unsafe.Pointer(s))) == '0' || v > 255 {
  4589. return 0
  4590. }
  4591. *(*uint8)(unsafe.Pointer(a + uintptr(i))) = uint8(v)
  4592. if int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) == 0 && i == 3 {
  4593. return 1
  4594. }
  4595. if int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) != '.' {
  4596. return 0
  4597. }
  4598. s += uintptr(j + 1)
  4599. }
  4600. return 0
  4601. } else if af != 10 {
  4602. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 97
  4603. return -1
  4604. }
  4605. if int32(*(*int8)(unsafe.Pointer(s))) == ':' && int32(*(*int8)(unsafe.Pointer(PreIncUintptr(&s, 1)))) != ':' {
  4606. return 0
  4607. }
  4608. for i = 0; ; i++ {
  4609. if int32(*(*int8)(unsafe.Pointer(s))) == ':' && brk < 0 {
  4610. brk = i
  4611. *(*uint16_t)(unsafe.Pointer(bp + uintptr(i&7)*2)) = uint16_t(0)
  4612. if !(int32(*(*int8)(unsafe.Pointer(PreIncUintptr(&s, 1)))) != 0) {
  4613. break
  4614. }
  4615. if i == 7 {
  4616. return 0
  4617. }
  4618. continue
  4619. }
  4620. for v = AssignInt32(&j, 0); j < 4 && AssignInt32(&d, hexval(tls, uint32(*(*int8)(unsafe.Pointer(s + uintptr(j)))))) >= 0; j++ {
  4621. v = 16*v + d
  4622. }
  4623. if j == 0 {
  4624. return 0
  4625. }
  4626. *(*uint16_t)(unsafe.Pointer(bp + uintptr(i&7)*2)) = uint16_t(v)
  4627. if !(int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) != 0) && (brk >= 0 || i == 7) {
  4628. break
  4629. }
  4630. if i == 7 {
  4631. return 0
  4632. }
  4633. if int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) != ':' {
  4634. if int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) != '.' || i < 6 && brk < 0 {
  4635. return 0
  4636. }
  4637. need_v4 = 1
  4638. i++
  4639. break
  4640. }
  4641. s += uintptr(j + 1)
  4642. }
  4643. if brk >= 0 {
  4644. Xmemmove(tls, bp+uintptr(brk)*2+uintptr(7)*2-uintptr(i)*2, bp+uintptr(brk)*2, uint64(2*(i+1-brk)))
  4645. for j = 0; j < 7-i; j++ {
  4646. *(*uint16_t)(unsafe.Pointer(bp + uintptr(brk+j)*2)) = uint16_t(0)
  4647. }
  4648. }
  4649. for j = 0; j < 8; j++ {
  4650. *(*uint8)(unsafe.Pointer(PostIncUintptr(&a, 1))) = uint8(int32(*(*uint16_t)(unsafe.Pointer(bp + uintptr(j)*2))) >> 8)
  4651. *(*uint8)(unsafe.Pointer(PostIncUintptr(&a, 1))) = uint8(*(*uint16_t)(unsafe.Pointer(bp + uintptr(j)*2)))
  4652. }
  4653. if need_v4 != 0 && Xinet_pton(tls, 2, s, a-uintptr(4)) <= 0 {
  4654. return 0
  4655. }
  4656. return 1
  4657. }
  4658. func X__lookup_ipliteral(tls *TLS, buf uintptr, name uintptr, family int32) int32 { /* lookup_ipliteral.c:12:5: */
  4659. if __ccgo_strace {
  4660. trc("tls=%v buf=%v name=%v family=%v, (%v:)", tls, buf, name, family, origin(2))
  4661. }
  4662. bp := tls.Alloc(96)
  4663. defer tls.Free(96)
  4664. // var a4 in_addr at bp, 4
  4665. // var a6 in6_addr at bp+68, 16
  4666. if X__inet_aton(tls, name, bp) > 0 {
  4667. if family == 10 { // wrong family
  4668. return -2
  4669. }
  4670. Xmemcpy(tls, buf+8, bp, uint64(unsafe.Sizeof(in_addr{})))
  4671. (*address)(unsafe.Pointer(buf)).family = 2
  4672. (*address)(unsafe.Pointer(buf)).scopeid = uint32(0)
  4673. return 1
  4674. }
  4675. // var tmp [64]int8 at bp+4, 64
  4676. var p uintptr = Xstrchr(tls, name, '%')
  4677. // var z uintptr at bp+88, 8
  4678. var scopeid uint64 = uint64(0)
  4679. if p != 0 && (int64(p)-int64(name))/1 < int64(64) {
  4680. Xmemcpy(tls, bp+4, name, uint64((int64(p)-int64(name))/1))
  4681. *(*int8)(unsafe.Pointer(bp + 4 + uintptr((int64(p)-int64(name))/1))) = int8(0)
  4682. name = bp + 4 /* &tmp[0] */
  4683. }
  4684. if Xinet_pton(tls, 10, name, bp+68) <= 0 {
  4685. return 0
  4686. }
  4687. if family == 2 { // wrong family
  4688. return -2
  4689. }
  4690. Xmemcpy(tls, buf+8, bp+68, uint64(unsafe.Sizeof(in6_addr{})))
  4691. (*address)(unsafe.Pointer(buf)).family = 10
  4692. if p != 0 {
  4693. if func() int32 {
  4694. if 0 != 0 {
  4695. return Xisdigit(tls, int32(*(*int8)(unsafe.Pointer(PreIncUintptr(&p, 1)))))
  4696. }
  4697. return Bool32(uint32(*(*int8)(unsafe.Pointer(PreIncUintptr(&p, 1))))-uint32('0') < uint32(10))
  4698. }() != 0 {
  4699. scopeid = Xstrtoull(tls, p, bp+88, 10)
  4700. } else {
  4701. *(*uintptr)(unsafe.Pointer(bp + 88 /* z */)) = p - uintptr(1)
  4702. }
  4703. if *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 88)))) != 0 {
  4704. Xabort(tls) //TODO-
  4705. // if (!IN6_IS_ADDR_LINKLOCAL(&a6) &&
  4706. // !IN6_IS_ADDR_MC_LINKLOCAL(&a6))
  4707. // return EAI_NONAME;
  4708. // scopeid = if_nametoindex(p);
  4709. // if (!scopeid) return EAI_NONAME;
  4710. }
  4711. if scopeid > uint64(0xffffffff) {
  4712. return -2
  4713. }
  4714. }
  4715. (*address)(unsafe.Pointer(buf)).scopeid = uint32(scopeid)
  4716. return 1
  4717. }
  4718. func is_valid_hostname(tls *TLS, host uintptr) int32 { /* lookup_name.c:18:12: */
  4719. var s uintptr
  4720. //TODO if (strnlen(host, 255)-1 >= 254 || mbstowcs(0, host, 0) == -1) return 0;
  4721. if Xstrnlen(tls, host, uint64(255))-uint64(1) >= uint64(254) {
  4722. return 0
  4723. }
  4724. for s = host; int32(*(*uint8)(unsafe.Pointer(s))) >= 0x80 || int32(*(*uint8)(unsafe.Pointer(s))) == '.' || int32(*(*uint8)(unsafe.Pointer(s))) == '-' || Xisalnum(tls, int32(*(*uint8)(unsafe.Pointer(s)))) != 0; s++ {
  4725. }
  4726. return BoolInt32(!(*(*uint8)(unsafe.Pointer(s)) != 0))
  4727. }
  4728. var Xzero_struct_address address /* lookup_name.c:27:16: */
  4729. func name_from_null(tls *TLS, buf uintptr, name uintptr, family int32, flags int32) int32 { /* lookup_name.c:29:12: */
  4730. var cnt int32 = 0
  4731. if name != 0 {
  4732. return 0
  4733. }
  4734. if flags&0x01 != 0 {
  4735. //TODO if (family != AF_INET6)
  4736. //TODO buf[cnt++] = (struct address){ .family = AF_INET };
  4737. if family != 10 {
  4738. var x = Xzero_struct_address
  4739. x.family = 2
  4740. *(*address)(unsafe.Pointer(buf + uintptr(PostIncInt32(&cnt, 1))*28)) = x
  4741. }
  4742. //TODO if (family != AF_INET)
  4743. //TODO buf[cnt++] = (struct address){ .family = AF_INET6 };
  4744. if family != 2 {
  4745. var x = Xzero_struct_address
  4746. x.family = 10
  4747. *(*address)(unsafe.Pointer(buf + uintptr(PostIncInt32(&cnt, 1))*28)) = x
  4748. }
  4749. } else {
  4750. Xabort(tls) //TODO-
  4751. // if (family != AF_INET6)
  4752. // buf[cnt++] = (struct address){ .family = AF_INET, .addr = { 127,0,0,1 } };
  4753. // if (family != AF_INET)
  4754. // buf[cnt++] = (struct address){ .family = AF_INET6, .addr = { [15] = 1 } };
  4755. }
  4756. return cnt
  4757. }
  4758. func name_from_numeric(tls *TLS, buf uintptr, name uintptr, family int32) int32 { /* lookup_name.c:58:12: */
  4759. return X__lookup_ipliteral(tls, buf, name, family)
  4760. }
  4761. func name_from_hosts(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32) int32 { /* lookup_name.c:63:12: */
  4762. bp := tls.Alloc(512)
  4763. defer tls.Free(512)
  4764. // var line [512]int8 at bp, 512
  4765. var l size_t = Xstrlen(tls, name)
  4766. var cnt int32 = 0
  4767. var badfam int32 = 0
  4768. var _buf [1032]uint8
  4769. _ = _buf
  4770. //TODO FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf);
  4771. var _f FILE
  4772. _ = _f
  4773. var f uintptr = Xfopen(tls, ts+76, ts+87)
  4774. if !(f != 0) {
  4775. switch *(*int32)(unsafe.Pointer(X___errno_location(tls))) {
  4776. case 2:
  4777. fallthrough
  4778. case 20:
  4779. fallthrough
  4780. case 13:
  4781. return 0
  4782. fallthrough
  4783. default:
  4784. return -11
  4785. }
  4786. }
  4787. for Xfgets(tls, bp, int32(unsafe.Sizeof([512]int8{})), f) != 0 && cnt < 48 {
  4788. var p uintptr
  4789. var z uintptr
  4790. if AssignUintptr(&p, Xstrchr(tls, bp, '#')) != 0 {
  4791. *(*int8)(unsafe.Pointer(PostIncUintptr(&p, 1))) = int8('\n')
  4792. *(*int8)(unsafe.Pointer(p)) = int8(0)
  4793. }
  4794. for p = bp + uintptr(1); AssignUintptr(&p, Xstrstr(tls, p, name)) != 0 && (!(__isspace(tls, int32(*(*int8)(unsafe.Pointer(p + UintptrFromInt32(-1))))) != 0) || !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(p + uintptr(l))))) != 0)); p++ {
  4795. }
  4796. if !(p != 0) {
  4797. continue
  4798. }
  4799. // Isolate IP address to parse
  4800. for p = bp; /* &line[0] */ *(*int8)(unsafe.Pointer(p)) != 0 && !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(p)))) != 0); p++ {
  4801. }
  4802. *(*int8)(unsafe.Pointer(PostIncUintptr(&p, 1))) = int8(0)
  4803. switch name_from_numeric(tls, buf+uintptr(cnt)*28, bp, family) {
  4804. case 1:
  4805. cnt++
  4806. break
  4807. case 0:
  4808. continue
  4809. default:
  4810. badfam = -2
  4811. continue
  4812. }
  4813. // Extract first name as canonical name
  4814. for ; *(*int8)(unsafe.Pointer(p)) != 0 && __isspace(tls, int32(*(*int8)(unsafe.Pointer(p)))) != 0; p++ {
  4815. }
  4816. for z = p; *(*int8)(unsafe.Pointer(z)) != 0 && !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(z)))) != 0); z++ {
  4817. }
  4818. *(*int8)(unsafe.Pointer(z)) = int8(0)
  4819. if is_valid_hostname(tls, p) != 0 {
  4820. Xmemcpy(tls, canon, p, uint64((int64(z)-int64(p))/1+int64(1)))
  4821. }
  4822. }
  4823. //TODO __fclose_ca(f);
  4824. Xfclose(tls, f)
  4825. if cnt != 0 {
  4826. return cnt
  4827. }
  4828. return badfam
  4829. }
  4830. type dpc_ctx = struct {
  4831. addrs uintptr
  4832. canon uintptr
  4833. cnt int32
  4834. _ [4]byte
  4835. } /* lookup_name.c:112:1 */
  4836. func name_from_dns_search(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32) int32 { /* lookup_name.c:191:12: */
  4837. return -1 //TODO-
  4838. Xabort(tls)
  4839. return int32(0) //TODO-
  4840. // char search[256];
  4841. // struct resolvconf conf;
  4842. // size_t l, dots;
  4843. // char *p, *z;
  4844. // if (__get_resolv_conf(&conf, search, sizeof search) < 0) return -1;
  4845. // /* Count dots, suppress search when >=ndots or name ends in
  4846. // * a dot, which is an explicit request for global scope. */
  4847. // for (dots=l=0; name[l]; l++) if (name[l]=='.') dots++;
  4848. // if (dots >= conf.ndots || name[l-1]=='.') *search = 0;
  4849. // /* Strip final dot for canon, fail if multiple trailing dots. */
  4850. // if (name[l-1]=='.') l--;
  4851. // if (!l || name[l-1]=='.') return EAI_NONAME;
  4852. // /* This can never happen; the caller already checked length. */
  4853. // if (l >= 256) return EAI_NONAME;
  4854. // /* Name with search domain appended is setup in canon[]. This both
  4855. // * provides the desired default canonical name (if the requested
  4856. // * name is not a CNAME record) and serves as a buffer for passing
  4857. // * the full requested name to name_from_dns. */
  4858. // memcpy(canon, name, l);
  4859. // canon[l] = '.';
  4860. // for (p=search; *p; p=z) {
  4861. // for (; isspace(*p); p++);
  4862. // for (z=p; *z && !isspace(*z); z++);
  4863. // if (z==p) break;
  4864. // if (z-p < 256 - l - 1) {
  4865. // memcpy(canon+l+1, p, z-p);
  4866. // canon[z-p+1+l] = 0;
  4867. // int cnt = name_from_dns(buf, canon, canon, family, &conf);
  4868. // if (cnt) return cnt;
  4869. // }
  4870. // }
  4871. // canon[l] = 0;
  4872. // return name_from_dns(buf, canon, name, family, &conf);
  4873. }
  4874. type policy = struct {
  4875. addr [16]uint8
  4876. len uint8
  4877. mask uint8
  4878. prec uint8
  4879. label uint8
  4880. } /* lookup_name.c:237:14 */
  4881. var defpolicy = [6]policy{
  4882. {addr: *(*[16]uint8)(unsafe.Pointer(ts + 172)), len: uint8(15), mask: uint8(0xff), prec: uint8(50)},
  4883. {addr: *(*[16]uint8)(unsafe.Pointer(ts + 189)), len: uint8(11), mask: uint8(0xff), prec: uint8(35), label: uint8(4)},
  4884. {addr: *(*[16]uint8)(unsafe.Pointer(ts + 205)), len: uint8(1), mask: uint8(0xff), prec: uint8(30), label: uint8(2)},
  4885. {addr: *(*[16]uint8)(unsafe.Pointer(ts + 221)), len: uint8(3), mask: uint8(0xff), prec: uint8(5), label: uint8(5)},
  4886. {addr: *(*[16]uint8)(unsafe.Pointer(ts + 237)), mask: uint8(0xfe), prec: uint8(3), label: uint8(13)},
  4887. // Last rule must match all addresses to stop loop.
  4888. {addr: *(*[16]uint8)(unsafe.Pointer(ts + 253)), prec: uint8(40), label: uint8(1)},
  4889. } /* lookup_name.c:241:3 */
  4890. func policyof(tls *TLS, a uintptr) uintptr { /* lookup_name.c:259:28: */
  4891. var i int32
  4892. for i = 0; ; i++ {
  4893. if Xmemcmp(tls, a, uintptr(unsafe.Pointer(&defpolicy))+uintptr(i)*20, uint64(defpolicy[i].len)) != 0 {
  4894. continue
  4895. }
  4896. if int32(*(*uint8_t)(unsafe.Pointer(a + uintptr(defpolicy[i].len))))&int32(defpolicy[i].mask) !=
  4897. int32(*(*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(&defpolicy)) + uintptr(i)*20 + uintptr(defpolicy[i].len)))) {
  4898. continue
  4899. }
  4900. return uintptr(unsafe.Pointer(&defpolicy)) + uintptr(i)*20
  4901. }
  4902. return uintptr(0)
  4903. }
  4904. func labelof(tls *TLS, a uintptr) int32 { /* lookup_name.c:272:12: */
  4905. return int32((*policy)(unsafe.Pointer(policyof(tls, a))).label)
  4906. }
  4907. func scopeof(tls *TLS, a uintptr) int32 { /* lookup_name.c:277:12: */
  4908. if int32(*(*uint8_t)(unsafe.Pointer(a))) == 0xff {
  4909. return int32(*(*uint8_t)(unsafe.Pointer(a + 1))) & 15
  4910. }
  4911. if int32(*(*uint8_t)(unsafe.Pointer(a))) == 0xfe && int32(*(*uint8_t)(unsafe.Pointer(a + 1)))&0xc0 == 0x80 {
  4912. return 2
  4913. }
  4914. if *(*uint32_t)(unsafe.Pointer(a)) == uint32_t(0) && *(*uint32_t)(unsafe.Pointer(a + 1*4)) == uint32_t(0) && *(*uint32_t)(unsafe.Pointer(a + 2*4)) == uint32_t(0) && int32(*(*uint8_t)(unsafe.Pointer(a + 12))) == 0 && int32(*(*uint8_t)(unsafe.Pointer(a + 13))) == 0 && int32(*(*uint8_t)(unsafe.Pointer(a + 14))) == 0 && int32(*(*uint8_t)(unsafe.Pointer(a + 15))) == 1 {
  4915. return 2
  4916. }
  4917. if int32(*(*uint8_t)(unsafe.Pointer(a))) == 0xfe && int32(*(*uint8_t)(unsafe.Pointer(a + 1)))&0xc0 == 0xc0 {
  4918. return 5
  4919. }
  4920. return 14
  4921. }
  4922. func prefixmatch(tls *TLS, s uintptr, d uintptr) int32 { /* lookup_name.c:286:12: */
  4923. // FIXME: The common prefix length should be limited to no greater
  4924. // than the nominal length of the prefix portion of the source
  4925. // address. However the definition of the source prefix length is
  4926. // not clear and thus this limiting is not yet implemented.
  4927. var i uint32
  4928. for i = uint32(0); i < uint32(128) && !((int32(*(*uint8_t)(unsafe.Pointer(s /* &.__in6_union */ /* &.__s6_addr */ + uintptr(i/uint32(8)))))^int32(*(*uint8_t)(unsafe.Pointer(d /* &.__in6_union */ /* &.__s6_addr */ + uintptr(i/uint32(8))))))&(int32(128)>>(i%uint32(8))) != 0); i++ {
  4929. }
  4930. return int32(i)
  4931. }
  4932. func addrcmp(tls *TLS, _a uintptr, _b uintptr) int32 { /* lookup_name.c:305:12: */
  4933. var a uintptr = _a
  4934. var b uintptr = _b
  4935. return (*address)(unsafe.Pointer(b)).sortkey - (*address)(unsafe.Pointer(a)).sortkey
  4936. }
  4937. func X__lookup_name(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32, flags int32) int32 { /* lookup_name.c:311:5: */
  4938. if __ccgo_strace {
  4939. trc("tls=%v buf=%v canon=%v name=%v family=%v flags=%v, (%v:)", tls, buf, canon, name, family, flags, origin(2))
  4940. }
  4941. bp := tls.Alloc(92)
  4942. defer tls.Free(92)
  4943. var cnt int32 = 0
  4944. var i int32
  4945. var j int32
  4946. _ = j
  4947. *(*int8)(unsafe.Pointer(canon)) = int8(0)
  4948. if name != 0 {
  4949. // reject empty name and check len so it fits into temp bufs
  4950. var l size_t = Xstrnlen(tls, name, uint64(255))
  4951. if l-uint64(1) >= uint64(254) {
  4952. return -2
  4953. }
  4954. Xmemcpy(tls, canon, name, l+uint64(1))
  4955. }
  4956. // Procedurally, a request for v6 addresses with the v4-mapped
  4957. // flag set is like a request for unspecified family, followed
  4958. // by filtering of the results.
  4959. if flags&0x08 != 0 {
  4960. if family == 10 {
  4961. family = 0
  4962. } else {
  4963. flags = flags - 0x08
  4964. }
  4965. }
  4966. // Try each backend until there's at least one result.
  4967. cnt = name_from_null(tls, buf, name, family, flags)
  4968. if !(cnt != 0) {
  4969. cnt = name_from_numeric(tls, buf, name, family)
  4970. }
  4971. if !(cnt != 0) && !(flags&0x04 != 0) {
  4972. cnt = name_from_hosts(tls, buf, canon, name, family)
  4973. if !(cnt != 0) {
  4974. cnt = name_from_dns_search(tls, buf, canon, name, family)
  4975. }
  4976. }
  4977. if cnt <= 0 {
  4978. if cnt != 0 {
  4979. return cnt
  4980. }
  4981. return -2
  4982. }
  4983. // Filter/transform results for v4-mapped lookup, if requested.
  4984. if flags&0x08 != 0 {
  4985. Xabort(tls) //TODO-
  4986. // if (!(flags & AI_ALL)) {
  4987. // /* If any v6 results exist, remove v4 results. */
  4988. // for (i=0; i<cnt && buf[i].family != AF_INET6; i++);
  4989. // if (i<cnt) {
  4990. // for (j=0; i<cnt; i++) {
  4991. // if (buf[i].family == AF_INET6)
  4992. // buf[j++] = buf[i];
  4993. // }
  4994. // cnt = i = j;
  4995. // }
  4996. // }
  4997. // /* Translate any remaining v4 results to v6 */
  4998. // for (i=0; i<cnt; i++) {
  4999. // if (buf[i].family != AF_INET) continue;
  5000. // memcpy(buf[i].addr+12, buf[i].addr, 4);
  5001. // memcpy(buf[i].addr, "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
  5002. // buf[i].family = AF_INET6;
  5003. // }
  5004. }
  5005. // No further processing is needed if there are fewer than 2
  5006. // results or if there are only IPv4 results.
  5007. if cnt < 2 || family == 2 {
  5008. return cnt
  5009. }
  5010. for i = 0; i < cnt; i++ {
  5011. if (*address)(unsafe.Pointer(buf+uintptr(i)*28)).family != 2 {
  5012. break
  5013. }
  5014. }
  5015. if i == cnt {
  5016. return cnt
  5017. }
  5018. var cs int32
  5019. _ = cs
  5020. //TODO pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
  5021. // The following implements a subset of RFC 3484/6724 destination
  5022. // address selection by generating a single 31-bit sort key for
  5023. // each address. Rules 3, 4, and 7 are omitted for having
  5024. // excessive runtime and code size cost and dubious benefit.
  5025. // So far the label/precedence table cannot be customized.
  5026. for i = 0; i < cnt; i++ {
  5027. var family int32 = (*address)(unsafe.Pointer(buf + uintptr(i)*28)).family
  5028. var key int32 = 0
  5029. *(*sockaddr_in6)(unsafe.Pointer(bp + 28 /* sa6 */)) = sockaddr_in6{}
  5030. *(*sockaddr_in6)(unsafe.Pointer(bp /* da6 */)) = sockaddr_in6{sin6_family: sa_family_t(10), sin6_port: in_port_t(65535), sin6_scope_id: (*address)(unsafe.Pointer(buf + uintptr(i)*28)).scopeid}
  5031. *(*sockaddr_in)(unsafe.Pointer(bp + 72 /* sa4 */)) = sockaddr_in{}
  5032. *(*sockaddr_in)(unsafe.Pointer(bp + 56 /* da4 */)) = sockaddr_in{sin_family: sa_family_t(2), sin_port: in_port_t(65535)}
  5033. var sa1 uintptr
  5034. var da uintptr
  5035. // var salen socklen_t at bp+88, 4
  5036. var dalen socklen_t
  5037. if family == 10 {
  5038. Xmemcpy(tls, bp+8, buf+uintptr(i)*28+8, uint64(16))
  5039. da = bp /* &da6 */
  5040. dalen = socklen_t(unsafe.Sizeof(sockaddr_in6{}))
  5041. sa1 = bp + 28 /* &sa6 */
  5042. *(*socklen_t)(unsafe.Pointer(bp + 88 /* salen */)) = socklen_t(unsafe.Sizeof(sockaddr_in6{}))
  5043. } else {
  5044. Xmemcpy(tls, bp+28+8,
  5045. ts+90, uint64(12))
  5046. Xmemcpy(tls, bp+8+uintptr(12), buf+uintptr(i)*28+8, uint64(4))
  5047. Xmemcpy(tls, bp+8,
  5048. ts+90, uint64(12))
  5049. Xmemcpy(tls, bp+8+uintptr(12), buf+uintptr(i)*28+8, uint64(4))
  5050. Xmemcpy(tls, bp+56+4, buf+uintptr(i)*28+8, uint64(4))
  5051. da = bp + 56 /* &da4 */
  5052. dalen = socklen_t(unsafe.Sizeof(sockaddr_in{}))
  5053. sa1 = bp + 72 /* &sa4 */
  5054. *(*socklen_t)(unsafe.Pointer(bp + 88 /* salen */)) = socklen_t(unsafe.Sizeof(sockaddr_in{}))
  5055. }
  5056. var dpolicy uintptr = policyof(tls, bp+8)
  5057. var dscope int32 = scopeof(tls, bp+8)
  5058. var dlabel int32 = int32((*policy)(unsafe.Pointer(dpolicy)).label)
  5059. var dprec int32 = int32((*policy)(unsafe.Pointer(dpolicy)).prec)
  5060. var prefixlen int32 = 0
  5061. var fd int32 = Xsocket(tls, family, 2|02000000, 17)
  5062. if fd >= 0 {
  5063. if !(Xconnect(tls, fd, da, dalen) != 0) {
  5064. key = key | 0x40000000
  5065. if !(Xgetsockname(tls, fd, sa1, bp+88) != 0) {
  5066. if family == 2 {
  5067. Xmemcpy(tls,
  5068. bp+28+8+uintptr(12),
  5069. bp+72+4, uint64(4))
  5070. }
  5071. if dscope == scopeof(tls, bp+28+8) {
  5072. key = key | 0x20000000
  5073. }
  5074. if dlabel == labelof(tls, bp+28+8) {
  5075. key = key | 0x10000000
  5076. }
  5077. prefixlen = prefixmatch(tls, bp+28+8,
  5078. bp+8)
  5079. }
  5080. }
  5081. Xclose(tls, fd)
  5082. }
  5083. key = key | dprec<<20
  5084. key = key | (15-dscope)<<16
  5085. key = key | prefixlen<<8
  5086. key = key | (48-i)<<0
  5087. (*address)(unsafe.Pointer(buf + uintptr(i)*28)).sortkey = key
  5088. }
  5089. Xqsort(tls, buf, uint64(cnt), uint64(unsafe.Sizeof(address{})), *(*uintptr)(unsafe.Pointer(&struct {
  5090. f func(*TLS, uintptr, uintptr) int32
  5091. }{addrcmp})))
  5092. //TODO pthread_setcancelstate(cs, 0);
  5093. return cnt
  5094. }
  5095. func X__lookup_serv(tls *TLS, buf uintptr, name uintptr, proto int32, socktype int32, flags int32) int32 { /* lookup_serv.c:12:5: */
  5096. if __ccgo_strace {
  5097. trc("tls=%v buf=%v name=%v proto=%v socktype=%v flags=%v, (%v:)", tls, buf, name, proto, socktype, flags, origin(2))
  5098. }
  5099. bp := tls.Alloc(8)
  5100. defer tls.Free(8)
  5101. var line [128]int8
  5102. _ = line
  5103. var cnt int32 = 0
  5104. var p uintptr
  5105. _ = p
  5106. *(*uintptr)(unsafe.Pointer(bp /* z */)) = ts + 13 /* "" */
  5107. var port uint64 = uint64(0)
  5108. switch socktype {
  5109. case 1:
  5110. switch proto {
  5111. case 0:
  5112. proto = 6
  5113. fallthrough
  5114. case 6:
  5115. break
  5116. default:
  5117. return -8
  5118. }
  5119. break
  5120. case 2:
  5121. switch proto {
  5122. case 0:
  5123. proto = 17
  5124. fallthrough
  5125. case 17:
  5126. break
  5127. default:
  5128. return -8
  5129. }
  5130. fallthrough
  5131. case 0:
  5132. break
  5133. default:
  5134. if name != 0 {
  5135. return -8
  5136. }
  5137. (*service)(unsafe.Pointer(buf)).port = uint16_t(0)
  5138. (*service)(unsafe.Pointer(buf)).proto = uint8(proto)
  5139. (*service)(unsafe.Pointer(buf)).socktype = uint8(socktype)
  5140. return 1
  5141. }
  5142. if name != 0 {
  5143. if !(int32(*(*int8)(unsafe.Pointer(name))) != 0) {
  5144. return -8
  5145. }
  5146. port = Xstrtoul(tls, name, bp, 10)
  5147. }
  5148. if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != 0) {
  5149. if port > uint64(65535) {
  5150. return -8
  5151. }
  5152. if proto != 17 {
  5153. (*service)(unsafe.Pointer(buf + uintptr(cnt)*4)).port = uint16_t(port)
  5154. (*service)(unsafe.Pointer(buf + uintptr(cnt)*4)).socktype = uint8(1)
  5155. (*service)(unsafe.Pointer(buf + uintptr(PostIncInt32(&cnt, 1))*4)).proto = uint8(6)
  5156. }
  5157. if proto != 6 {
  5158. (*service)(unsafe.Pointer(buf + uintptr(cnt)*4)).port = uint16_t(port)
  5159. (*service)(unsafe.Pointer(buf + uintptr(cnt)*4)).socktype = uint8(2)
  5160. (*service)(unsafe.Pointer(buf + uintptr(PostIncInt32(&cnt, 1))*4)).proto = uint8(17)
  5161. }
  5162. return cnt
  5163. }
  5164. if flags&0x400 != 0 {
  5165. return -2
  5166. }
  5167. var l size_t = Xstrlen(tls, name)
  5168. _ = l
  5169. Xabort(tls) //TODO-
  5170. // unsigned char _buf[1032];
  5171. // FILE _f, *f = __fopen_rb_ca("/etc/services", &_f, _buf, sizeof _buf);
  5172. // if (!f) switch (errno) {
  5173. // case ENOENT:
  5174. // case ENOTDIR:
  5175. // case EACCES:
  5176. // return EAI_SERVICE;
  5177. // default:
  5178. // return EAI_SYSTEM;
  5179. // }
  5180. Xabort(tls) //TODO-
  5181. // while (fgets(line, sizeof line, f) && cnt < MAXSERVS) {
  5182. // if ((p=strchr(line, '#'))) *p++='\n', *p=0;
  5183. // /* Find service name */
  5184. // for(p=line; (p=strstr(p, name)); p++) {
  5185. // if (p>line && !isspace(p[-1])) continue;
  5186. // if (p[l] && !isspace(p[l])) continue;
  5187. // break;
  5188. // }
  5189. // if (!p) continue;
  5190. // /* Skip past canonical name at beginning of line */
  5191. // for (p=line; *p && !isspace(*p); p++);
  5192. // port = strtoul(p, &z, 10);
  5193. // if (port > 65535 || z==p) continue;
  5194. // if (!strncmp(z, "/udp", 4)) {
  5195. // if (proto == IPPROTO_TCP) continue;
  5196. // buf[cnt].port = port;
  5197. // buf[cnt].socktype = SOCK_DGRAM;
  5198. // buf[cnt++].proto = IPPROTO_UDP;
  5199. // }
  5200. // if (!strncmp(z, "/tcp", 4)) {
  5201. // if (proto == IPPROTO_UDP) continue;
  5202. // buf[cnt].port = port;
  5203. // buf[cnt].socktype = SOCK_STREAM;
  5204. // buf[cnt++].proto = IPPROTO_TCP;
  5205. // }
  5206. // }
  5207. // __fclose_ca(f);
  5208. // return cnt > 0 ? cnt : EAI_SERVICE;
  5209. Xabort(tls)
  5210. return int32(0) //TODO-
  5211. }
  5212. func temper(tls *TLS, x uint32) uint32 { /* rand_r.c:3:17: */
  5213. x = x ^ x>>11
  5214. x = x ^ x<<7&0x9D2C5680
  5215. x = x ^ x<<15&0xEFC60000
  5216. x = x ^ x>>18
  5217. return x
  5218. }
  5219. func Xrand_r(tls *TLS, seed uintptr) int32 { /* rand_r.c:12:5: */
  5220. if __ccgo_strace {
  5221. trc("tls=%v seed=%v, (%v:)", tls, seed, origin(2))
  5222. }
  5223. return int32(temper(tls, AssignPtrUint32(seed, *(*uint32)(unsafe.Pointer(seed))*uint32(1103515245)+uint32(12345))) / uint32(2))
  5224. }
  5225. func X__lockfile(tls *TLS, f uintptr) int32 { /* __lockfile.c:4:5: */
  5226. if __ccgo_strace {
  5227. trc("tls=%v f=%v, (%v:)", tls, f, origin(2))
  5228. }
  5229. var owner int32 = (*FILE)(unsafe.Pointer(f)).lock
  5230. var tid int32 = (*__pthread)(unsafe.Pointer(__pthread_self(tls))).tid
  5231. if owner&CplInt32(0x40000000) == tid {
  5232. return 0
  5233. }
  5234. owner = a_cas(tls, f+140, 0, tid)
  5235. if !(owner != 0) {
  5236. return 1
  5237. }
  5238. for AssignInt32(&owner, a_cas(tls, f+140, 0, tid|0x40000000)) != 0 {
  5239. if owner&0x40000000 != 0 || a_cas(tls, f+140, owner, owner|0x40000000) == owner {
  5240. __futexwait(tls, f+140, owner|0x40000000, 1)
  5241. }
  5242. }
  5243. return 1
  5244. }
  5245. func X__unlockfile(tls *TLS, f uintptr) { /* __lockfile.c:19:6: */
  5246. if __ccgo_strace {
  5247. trc("tls=%v f=%v, (%v:)", tls, f, origin(2))
  5248. }
  5249. if a_swap(tls, f+140, 0)&0x40000000 != 0 {
  5250. __wake(tls, f+140, 1, 1)
  5251. }
  5252. }
  5253. func X__toread(tls *TLS, f uintptr) int32 { /* __toread.c:3:5: */
  5254. if __ccgo_strace {
  5255. trc("tls=%v f=%v, (%v:)", tls, f, origin(2))
  5256. }
  5257. *(*int32)(unsafe.Pointer(f + 136)) |= (*FILE)(unsafe.Pointer(f)).mode - 1
  5258. if (*FILE)(unsafe.Pointer(f)).wpos != (*FILE)(unsafe.Pointer(f)).wbase {
  5259. (*struct {
  5260. f func(*TLS, uintptr, uintptr, size_t) size_t
  5261. })(unsafe.Pointer(&struct{ uintptr }{(*FILE)(unsafe.Pointer(f)).write})).f(tls, f, uintptr(0), uint64(0))
  5262. }
  5263. (*FILE)(unsafe.Pointer(f)).wpos = AssignPtrUintptr(f+56, AssignPtrUintptr(f+32, uintptr(0)))
  5264. if (*FILE)(unsafe.Pointer(f)).flags&uint32(4) != 0 {
  5265. *(*uint32)(unsafe.Pointer(f)) |= uint32(32)
  5266. return -1
  5267. }
  5268. (*FILE)(unsafe.Pointer(f)).rpos = AssignPtrUintptr(f+16, (*FILE)(unsafe.Pointer(f)).buf+uintptr((*FILE)(unsafe.Pointer(f)).buf_size))
  5269. if (*FILE)(unsafe.Pointer(f)).flags&uint32(16) != 0 {
  5270. return -1
  5271. }
  5272. return 0
  5273. }
  5274. func X__toread_needs_stdio_exit(tls *TLS) { /* __toread.c:16:13: */
  5275. if __ccgo_strace {
  5276. trc("tls=%v, (%v:)", tls, origin(2))
  5277. }
  5278. X__builtin_abort(tls) //TODO-
  5279. // __stdio_exit_needed();
  5280. }
  5281. // This function assumes it will never be called if there is already
  5282. // data buffered for reading.
  5283. func X__uflow(tls *TLS, f uintptr) int32 { /* __uflow.c:6:5: */
  5284. if __ccgo_strace {
  5285. trc("tls=%v f=%v, (%v:)", tls, f, origin(2))
  5286. }
  5287. bp := tls.Alloc(1)
  5288. defer tls.Free(1)
  5289. // var c uint8 at bp, 1
  5290. if !(X__toread(tls, f) != 0) && (*struct {
  5291. f func(*TLS, uintptr, uintptr, size_t) size_t
  5292. })(unsafe.Pointer(&struct{ uintptr }{(*FILE)(unsafe.Pointer(f)).read})).f(tls, f, bp, uint64(1)) == uint64(1) {
  5293. return int32(*(*uint8)(unsafe.Pointer(bp)))
  5294. }
  5295. return -1
  5296. }
  5297. func Xsscanf(tls *TLS, s uintptr, fmt uintptr, va uintptr) int32 { /* sscanf.c:4:5: */
  5298. if __ccgo_strace {
  5299. trc("tls=%v s=%v fmt=%v va=%v, (%v:)", tls, s, fmt, va, origin(2))
  5300. }
  5301. var ret int32
  5302. var ap va_list
  5303. _ = ap
  5304. ap = va
  5305. ret = Xvsscanf(tls, s, fmt, ap)
  5306. _ = ap
  5307. return ret
  5308. }
  5309. type wctrans_t = uintptr /* wctype.h:20:19 */
  5310. func store_int(tls *TLS, dest uintptr, size int32, i uint64) { /* vfscanf.c:22:13: */
  5311. if !(dest != 0) {
  5312. return
  5313. }
  5314. switch size {
  5315. case -2:
  5316. *(*int8)(unsafe.Pointer(dest)) = int8(i)
  5317. break
  5318. case -1:
  5319. *(*int16)(unsafe.Pointer(dest)) = int16(i)
  5320. break
  5321. case 0:
  5322. *(*int32)(unsafe.Pointer(dest)) = int32(i)
  5323. break
  5324. case 1:
  5325. *(*int64)(unsafe.Pointer(dest)) = int64(i)
  5326. break
  5327. case 3:
  5328. *(*int64)(unsafe.Pointer(dest)) = int64(i)
  5329. break
  5330. }
  5331. }
  5332. func arg_n(tls *TLS, ap va_list, n uint32) uintptr { /* vfscanf.c:44:13: */
  5333. var p uintptr
  5334. var i uint32
  5335. var ap2 va_list
  5336. _ = ap2
  5337. ap2 = ap
  5338. for i = n; i > uint32(1); i-- {
  5339. VaUintptr(&ap2)
  5340. }
  5341. p = VaUintptr(&ap2)
  5342. _ = ap2
  5343. return p
  5344. }
  5345. func Xvfscanf(tls *TLS, f uintptr, fmt uintptr, ap va_list) int32 { /* vfscanf.c:56:5: */
  5346. if __ccgo_strace {
  5347. trc("tls=%v f=%v fmt=%v ap=%v, (%v:)", tls, f, fmt, ap, origin(2))
  5348. }
  5349. bp := tls.Alloc(276)
  5350. defer tls.Free(276)
  5351. var width int32
  5352. var size int32
  5353. var alloc int32
  5354. var base int32
  5355. var p uintptr
  5356. var c int32
  5357. var t int32
  5358. var s uintptr
  5359. var wcs uintptr
  5360. // var st mbstate_t at bp+268, 8
  5361. var dest uintptr
  5362. var invert int32
  5363. var matches int32
  5364. var x uint64
  5365. var y float64
  5366. var pos off_t
  5367. // var scanset [257]uint8 at bp, 257
  5368. var i size_t
  5369. var k size_t
  5370. // var wc wchar_t at bp+260, 4
  5371. var __need_unlock int32
  5372. var tmp uintptr
  5373. var tmp1 uintptr
  5374. alloc = 0
  5375. dest = uintptr(0)
  5376. matches = 0
  5377. pos = int64(0)
  5378. __need_unlock = 0
  5379. if !!(int32((*FILE)(unsafe.Pointer(f)).rpos) != 0) {
  5380. goto __1
  5381. }
  5382. X__toread(tls, f)
  5383. __1:
  5384. ;
  5385. if !!(int32((*FILE)(unsafe.Pointer(f)).rpos) != 0) {
  5386. goto __2
  5387. }
  5388. goto input_fail
  5389. __2:
  5390. ;
  5391. p = fmt
  5392. __3:
  5393. if !(*(*uint8)(unsafe.Pointer(p)) != 0) {
  5394. goto __5
  5395. }
  5396. alloc = 0
  5397. if !(__isspace(tls, int32(*(*uint8)(unsafe.Pointer(p)))) != 0) {
  5398. goto __6
  5399. }
  5400. __7:
  5401. if !(__isspace(tls, int32(*(*uint8)(unsafe.Pointer(p + 1)))) != 0) {
  5402. goto __8
  5403. }
  5404. p++
  5405. goto __7
  5406. __8:
  5407. ;
  5408. X__shlim(tls, f, int64(0))
  5409. __9:
  5410. if !(__isspace(tls, func() int32 {
  5411. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  5412. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  5413. }
  5414. return X__shgetc(tls, f)
  5415. }()) != 0) {
  5416. goto __10
  5417. }
  5418. goto __9
  5419. __10:
  5420. ;
  5421. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  5422. (*FILE)(unsafe.Pointer(f)).rpos--
  5423. } else {
  5424. }
  5425. pos = pos + ((*FILE)(unsafe.Pointer(f)).shcnt + (int64((*FILE)(unsafe.Pointer(f)).rpos)-int64((*FILE)(unsafe.Pointer(f)).buf))/1)
  5426. goto __4
  5427. __6:
  5428. ;
  5429. if !(int32(*(*uint8)(unsafe.Pointer(p))) != '%' || int32(*(*uint8)(unsafe.Pointer(p + 1))) == '%') {
  5430. goto __11
  5431. }
  5432. X__shlim(tls, f, int64(0))
  5433. if !(int32(*(*uint8)(unsafe.Pointer(p))) == '%') {
  5434. goto __12
  5435. }
  5436. p++
  5437. __14:
  5438. if !(__isspace(tls, AssignInt32(&c, func() int32 {
  5439. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  5440. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  5441. }
  5442. return X__shgetc(tls, f)
  5443. }())) != 0) {
  5444. goto __15
  5445. }
  5446. goto __14
  5447. __15:
  5448. ;
  5449. goto __13
  5450. __12:
  5451. c = func() int32 {
  5452. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  5453. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  5454. }
  5455. return X__shgetc(tls, f)
  5456. }()
  5457. __13:
  5458. ;
  5459. if !(c != int32(*(*uint8)(unsafe.Pointer(p)))) {
  5460. goto __16
  5461. }
  5462. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  5463. (*FILE)(unsafe.Pointer(f)).rpos--
  5464. } else {
  5465. }
  5466. if !(c < 0) {
  5467. goto __17
  5468. }
  5469. goto input_fail
  5470. __17:
  5471. ;
  5472. goto match_fail
  5473. __16:
  5474. ;
  5475. pos = pos + ((*FILE)(unsafe.Pointer(f)).shcnt + (int64((*FILE)(unsafe.Pointer(f)).rpos)-int64((*FILE)(unsafe.Pointer(f)).buf))/1)
  5476. goto __4
  5477. __11:
  5478. ;
  5479. p++
  5480. if !(int32(*(*uint8)(unsafe.Pointer(p))) == '*') {
  5481. goto __18
  5482. }
  5483. dest = uintptr(0)
  5484. p++
  5485. goto __19
  5486. __18:
  5487. if !(func() int32 {
  5488. if 0 != 0 {
  5489. return Xisdigit(tls, int32(*(*uint8)(unsafe.Pointer(p))))
  5490. }
  5491. return Bool32(uint32(*(*uint8)(unsafe.Pointer(p)))-uint32('0') < uint32(10))
  5492. }() != 0 && int32(*(*uint8)(unsafe.Pointer(p + 1))) == '$') {
  5493. goto __20
  5494. }
  5495. dest = arg_n(tls, ap, uint32(int32(*(*uint8)(unsafe.Pointer(p)))-'0'))
  5496. p += uintptr(2)
  5497. goto __21
  5498. __20:
  5499. dest = VaUintptr(&ap)
  5500. __21:
  5501. ;
  5502. __19:
  5503. ;
  5504. width = 0
  5505. __22:
  5506. if !(func() int32 {
  5507. if 0 != 0 {
  5508. return Xisdigit(tls, int32(*(*uint8)(unsafe.Pointer(p))))
  5509. }
  5510. return Bool32(uint32(*(*uint8)(unsafe.Pointer(p)))-uint32('0') < uint32(10))
  5511. }() != 0) {
  5512. goto __24
  5513. }
  5514. width = 10*width + int32(*(*uint8)(unsafe.Pointer(p))) - '0'
  5515. goto __23
  5516. __23:
  5517. p++
  5518. goto __22
  5519. goto __24
  5520. __24:
  5521. ;
  5522. if !(int32(*(*uint8)(unsafe.Pointer(p))) == 'm') {
  5523. goto __25
  5524. }
  5525. wcs = uintptr(0)
  5526. s = uintptr(0)
  5527. alloc = BoolInt32(!!(dest != 0))
  5528. p++
  5529. goto __26
  5530. __25:
  5531. alloc = 0
  5532. __26:
  5533. ;
  5534. size = 0
  5535. switch int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&p, 1)))) {
  5536. case 'h':
  5537. goto __28
  5538. case 'l':
  5539. goto __29
  5540. case 'j':
  5541. goto __30
  5542. case 'z':
  5543. goto __31
  5544. case 't':
  5545. goto __32
  5546. case 'L':
  5547. goto __33
  5548. case 'd':
  5549. goto __34
  5550. case 'i':
  5551. goto __35
  5552. case 'o':
  5553. goto __36
  5554. case 'u':
  5555. goto __37
  5556. case 'x':
  5557. goto __38
  5558. case 'a':
  5559. goto __39
  5560. case 'e':
  5561. goto __40
  5562. case 'f':
  5563. goto __41
  5564. case 'g':
  5565. goto __42
  5566. case 'A':
  5567. goto __43
  5568. case 'E':
  5569. goto __44
  5570. case 'F':
  5571. goto __45
  5572. case 'G':
  5573. goto __46
  5574. case 'X':
  5575. goto __47
  5576. case 's':
  5577. goto __48
  5578. case 'c':
  5579. goto __49
  5580. case '[':
  5581. goto __50
  5582. case 'S':
  5583. goto __51
  5584. case 'C':
  5585. goto __52
  5586. case 'p':
  5587. goto __53
  5588. case 'n':
  5589. goto __54
  5590. default:
  5591. goto __55
  5592. }
  5593. goto __27
  5594. __28:
  5595. if !(int32(*(*uint8)(unsafe.Pointer(p))) == 'h') {
  5596. goto __56
  5597. }
  5598. p++
  5599. size = -2
  5600. goto __57
  5601. __56:
  5602. size = -1
  5603. __57:
  5604. ;
  5605. goto __27
  5606. __29:
  5607. if !(int32(*(*uint8)(unsafe.Pointer(p))) == 'l') {
  5608. goto __58
  5609. }
  5610. p++
  5611. size = 3
  5612. goto __59
  5613. __58:
  5614. size = 1
  5615. __59:
  5616. ;
  5617. goto __27
  5618. __30:
  5619. size = 3
  5620. goto __27
  5621. __31:
  5622. __32:
  5623. size = 1
  5624. goto __27
  5625. __33:
  5626. size = 2
  5627. goto __27
  5628. __34:
  5629. __35:
  5630. __36:
  5631. __37:
  5632. __38:
  5633. __39:
  5634. __40:
  5635. __41:
  5636. __42:
  5637. __43:
  5638. __44:
  5639. __45:
  5640. __46:
  5641. __47:
  5642. __48:
  5643. __49:
  5644. __50:
  5645. __51:
  5646. __52:
  5647. __53:
  5648. __54:
  5649. p--
  5650. goto __27
  5651. __55:
  5652. goto fmt_fail
  5653. __27:
  5654. ;
  5655. t = int32(*(*uint8)(unsafe.Pointer(p)))
  5656. // C or S
  5657. if !(t&0x2f == 3) {
  5658. goto __60
  5659. }
  5660. t = t | 32
  5661. size = 1
  5662. __60:
  5663. ;
  5664. switch t {
  5665. case 'c':
  5666. goto __62
  5667. case '[':
  5668. goto __63
  5669. case 'n':
  5670. goto __64
  5671. default:
  5672. goto __65
  5673. }
  5674. goto __61
  5675. __62:
  5676. if !(width < 1) {
  5677. goto __66
  5678. }
  5679. width = 1
  5680. __66:
  5681. ;
  5682. __63:
  5683. goto __61
  5684. __64:
  5685. store_int(tls, dest, size, uint64(pos))
  5686. // do not increment match count, etc!
  5687. goto __4
  5688. __65:
  5689. X__shlim(tls, f, int64(0))
  5690. __67:
  5691. if !(__isspace(tls, func() int32 {
  5692. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  5693. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  5694. }
  5695. return X__shgetc(tls, f)
  5696. }()) != 0) {
  5697. goto __68
  5698. }
  5699. goto __67
  5700. __68:
  5701. ;
  5702. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  5703. (*FILE)(unsafe.Pointer(f)).rpos--
  5704. } else {
  5705. }
  5706. pos = pos + ((*FILE)(unsafe.Pointer(f)).shcnt + (int64((*FILE)(unsafe.Pointer(f)).rpos)-int64((*FILE)(unsafe.Pointer(f)).buf))/1)
  5707. __61:
  5708. ;
  5709. X__shlim(tls, f, int64(width))
  5710. if !(func() int32 {
  5711. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  5712. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  5713. }
  5714. return X__shgetc(tls, f)
  5715. }() < 0) {
  5716. goto __69
  5717. }
  5718. goto input_fail
  5719. __69:
  5720. ;
  5721. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  5722. (*FILE)(unsafe.Pointer(f)).rpos--
  5723. } else {
  5724. }
  5725. switch t {
  5726. case 's':
  5727. goto __71
  5728. case 'c':
  5729. goto __72
  5730. case '[':
  5731. goto __73
  5732. case 'p':
  5733. goto __74
  5734. case 'X':
  5735. goto __75
  5736. case 'x':
  5737. goto __76
  5738. case 'o':
  5739. goto __77
  5740. case 'd':
  5741. goto __78
  5742. case 'u':
  5743. goto __79
  5744. case 'i':
  5745. goto __80
  5746. case 'a':
  5747. goto __81
  5748. case 'A':
  5749. goto __82
  5750. case 'e':
  5751. goto __83
  5752. case 'E':
  5753. goto __84
  5754. case 'f':
  5755. goto __85
  5756. case 'F':
  5757. goto __86
  5758. case 'g':
  5759. goto __87
  5760. case 'G':
  5761. goto __88
  5762. }
  5763. goto __70
  5764. __71:
  5765. __72:
  5766. __73:
  5767. if !(t == 'c' || t == 's') {
  5768. goto __89
  5769. }
  5770. Xmemset(tls, bp, -1, uint64(unsafe.Sizeof([257]uint8{})))
  5771. *(*uint8)(unsafe.Pointer(bp)) = uint8(0)
  5772. if !(t == 's') {
  5773. goto __91
  5774. }
  5775. *(*uint8)(unsafe.Pointer(bp + 10)) = uint8(0)
  5776. *(*uint8)(unsafe.Pointer(bp + 11)) = uint8(0)
  5777. *(*uint8)(unsafe.Pointer(bp + 12)) = uint8(0)
  5778. *(*uint8)(unsafe.Pointer(bp + 13)) = uint8(0)
  5779. *(*uint8)(unsafe.Pointer(bp + 14)) = uint8(0)
  5780. *(*uint8)(unsafe.Pointer(bp + 33)) = uint8(0)
  5781. __91:
  5782. ;
  5783. goto __90
  5784. __89:
  5785. if !(int32(*(*uint8)(unsafe.Pointer(PreIncUintptr(&p, 1)))) == '^') {
  5786. goto __92
  5787. }
  5788. p++
  5789. invert = 1
  5790. goto __93
  5791. __92:
  5792. invert = 0
  5793. __93:
  5794. ;
  5795. Xmemset(tls, bp, invert, uint64(unsafe.Sizeof([257]uint8{})))
  5796. *(*uint8)(unsafe.Pointer(bp)) = uint8(0)
  5797. if !(int32(*(*uint8)(unsafe.Pointer(p))) == '-') {
  5798. goto __94
  5799. }
  5800. p++
  5801. *(*uint8)(unsafe.Pointer(bp + 46)) = uint8(1 - invert)
  5802. goto __95
  5803. __94:
  5804. if !(int32(*(*uint8)(unsafe.Pointer(p))) == ']') {
  5805. goto __96
  5806. }
  5807. p++
  5808. *(*uint8)(unsafe.Pointer(bp + 94)) = uint8(1 - invert)
  5809. __96:
  5810. ;
  5811. __95:
  5812. ;
  5813. __97:
  5814. if !(int32(*(*uint8)(unsafe.Pointer(p))) != ']') {
  5815. goto __99
  5816. }
  5817. if !!(int32(*(*uint8)(unsafe.Pointer(p))) != 0) {
  5818. goto __100
  5819. }
  5820. goto fmt_fail
  5821. __100:
  5822. ;
  5823. if !(int32(*(*uint8)(unsafe.Pointer(p))) == '-' && *(*uint8)(unsafe.Pointer(p + 1)) != 0 && int32(*(*uint8)(unsafe.Pointer(p + 1))) != ']') {
  5824. goto __101
  5825. }
  5826. c = int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&p, 1) + UintptrFromInt32(-1))))
  5827. __102:
  5828. if !(c < int32(*(*uint8)(unsafe.Pointer(p)))) {
  5829. goto __104
  5830. }
  5831. *(*uint8)(unsafe.Pointer(bp + uintptr(1+c))) = uint8(1 - invert)
  5832. goto __103
  5833. __103:
  5834. c++
  5835. goto __102
  5836. goto __104
  5837. __104:
  5838. ;
  5839. __101:
  5840. ;
  5841. *(*uint8)(unsafe.Pointer(bp + uintptr(1+int32(*(*uint8)(unsafe.Pointer(p)))))) = uint8(1 - invert)
  5842. goto __98
  5843. __98:
  5844. p++
  5845. goto __97
  5846. goto __99
  5847. __99:
  5848. ;
  5849. __90:
  5850. ;
  5851. wcs = uintptr(0)
  5852. s = uintptr(0)
  5853. i = uint64(0)
  5854. if t == 'c' {
  5855. k = uint64(uint32(width) + 1)
  5856. } else {
  5857. k = uint64(31)
  5858. }
  5859. if !(size == 1) {
  5860. goto __105
  5861. }
  5862. if !(alloc != 0) {
  5863. goto __107
  5864. }
  5865. wcs = Xmalloc(tls, k*size_t(unsafe.Sizeof(wchar_t(0))))
  5866. if !!(wcs != 0) {
  5867. goto __109
  5868. }
  5869. goto alloc_fail
  5870. __109:
  5871. ;
  5872. goto __108
  5873. __107:
  5874. wcs = dest
  5875. __108:
  5876. ;
  5877. *(*mbstate_t)(unsafe.Pointer(bp + 268 /* st */)) = mbstate_t{}
  5878. __110:
  5879. if !(*(*uint8)(unsafe.Pointer(bp + uintptr(AssignInt32(&c, func() int32 {
  5880. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  5881. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  5882. }
  5883. return X__shgetc(tls, f)
  5884. }())+1))) != 0) {
  5885. goto __111
  5886. }
  5887. switch Xmbrtowc(tls, bp+260, func() uintptr { *(*int8)(unsafe.Pointer(bp + 264)) = int8(c); return bp + 264 }(), uint64(1), bp+268 /* &st */) {
  5888. case Uint64FromInt32(-1):
  5889. goto __113
  5890. case Uint64FromInt32(-2):
  5891. goto __114
  5892. }
  5893. goto __112
  5894. __113:
  5895. goto input_fail
  5896. __114:
  5897. goto __110
  5898. __112:
  5899. ;
  5900. if !(wcs != 0) {
  5901. goto __115
  5902. }
  5903. *(*wchar_t)(unsafe.Pointer(wcs + uintptr(PostIncUint64(&i, 1))*4)) = *(*wchar_t)(unsafe.Pointer(bp + 260 /* wc */))
  5904. __115:
  5905. ;
  5906. if !(alloc != 0 && i == k) {
  5907. goto __116
  5908. }
  5909. k = k + (k + uint64(1))
  5910. tmp = Xrealloc(tls, wcs, k*size_t(unsafe.Sizeof(wchar_t(0))))
  5911. if !!(tmp != 0) {
  5912. goto __117
  5913. }
  5914. goto alloc_fail
  5915. __117:
  5916. ;
  5917. wcs = tmp
  5918. __116:
  5919. ;
  5920. goto __110
  5921. __111:
  5922. ;
  5923. if !!(Xmbsinit(tls, bp+268) != 0) {
  5924. goto __118
  5925. }
  5926. goto input_fail
  5927. __118:
  5928. ;
  5929. goto __106
  5930. __105:
  5931. if !(alloc != 0) {
  5932. goto __119
  5933. }
  5934. s = Xmalloc(tls, k)
  5935. if !!(s != 0) {
  5936. goto __121
  5937. }
  5938. goto alloc_fail
  5939. __121:
  5940. ;
  5941. __122:
  5942. if !(*(*uint8)(unsafe.Pointer(bp + uintptr(AssignInt32(&c, func() int32 {
  5943. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  5944. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  5945. }
  5946. return X__shgetc(tls, f)
  5947. }())+1))) != 0) {
  5948. goto __123
  5949. }
  5950. *(*int8)(unsafe.Pointer(s + uintptr(PostIncUint64(&i, 1)))) = int8(c)
  5951. if !(i == k) {
  5952. goto __124
  5953. }
  5954. k = k + (k + uint64(1))
  5955. tmp1 = Xrealloc(tls, s, k)
  5956. if !!(tmp1 != 0) {
  5957. goto __125
  5958. }
  5959. goto alloc_fail
  5960. __125:
  5961. ;
  5962. s = tmp1
  5963. __124:
  5964. ;
  5965. goto __122
  5966. __123:
  5967. ;
  5968. goto __120
  5969. __119:
  5970. if !(AssignUintptr(&s, dest) != 0) {
  5971. goto __126
  5972. }
  5973. __128:
  5974. if !(*(*uint8)(unsafe.Pointer(bp + uintptr(AssignInt32(&c, func() int32 {
  5975. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  5976. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  5977. }
  5978. return X__shgetc(tls, f)
  5979. }())+1))) != 0) {
  5980. goto __129
  5981. }
  5982. *(*int8)(unsafe.Pointer(s + uintptr(PostIncUint64(&i, 1)))) = int8(c)
  5983. goto __128
  5984. __129:
  5985. ;
  5986. goto __127
  5987. __126:
  5988. __130:
  5989. if !(*(*uint8)(unsafe.Pointer(bp + uintptr(AssignInt32(&c, func() int32 {
  5990. if (*FILE)(unsafe.Pointer(f)).rpos != (*FILE)(unsafe.Pointer(f)).shend {
  5991. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).rpos, 1))))
  5992. }
  5993. return X__shgetc(tls, f)
  5994. }())+1))) != 0) {
  5995. goto __131
  5996. }
  5997. goto __130
  5998. __131:
  5999. ;
  6000. __127:
  6001. ;
  6002. __120:
  6003. ;
  6004. __106:
  6005. ;
  6006. if (*FILE)(unsafe.Pointer(f)).shlim >= int64(0) {
  6007. (*FILE)(unsafe.Pointer(f)).rpos--
  6008. } else {
  6009. }
  6010. if !!((*FILE)(unsafe.Pointer(f)).shcnt+(int64((*FILE)(unsafe.Pointer(f)).rpos)-int64((*FILE)(unsafe.Pointer(f)).buf))/1 != 0) {
  6011. goto __132
  6012. }
  6013. goto match_fail
  6014. __132:
  6015. ;
  6016. if !(t == 'c' && (*FILE)(unsafe.Pointer(f)).shcnt+(int64((*FILE)(unsafe.Pointer(f)).rpos)-int64((*FILE)(unsafe.Pointer(f)).buf))/1 != off_t(width)) {
  6017. goto __133
  6018. }
  6019. goto match_fail
  6020. __133:
  6021. ;
  6022. if !(alloc != 0) {
  6023. goto __134
  6024. }
  6025. if !(size == 1) {
  6026. goto __135
  6027. }
  6028. *(*uintptr)(unsafe.Pointer(dest)) = wcs
  6029. goto __136
  6030. __135:
  6031. *(*uintptr)(unsafe.Pointer(dest)) = s
  6032. __136:
  6033. ;
  6034. __134:
  6035. ;
  6036. if !(t != 'c') {
  6037. goto __137
  6038. }
  6039. if !(wcs != 0) {
  6040. goto __138
  6041. }
  6042. *(*wchar_t)(unsafe.Pointer(wcs + uintptr(i)*4)) = 0
  6043. __138:
  6044. ;
  6045. if !(s != 0) {
  6046. goto __139
  6047. }
  6048. *(*int8)(unsafe.Pointer(s + uintptr(i))) = int8(0)
  6049. __139:
  6050. ;
  6051. __137:
  6052. ;
  6053. goto __70
  6054. __74:
  6055. __75:
  6056. __76:
  6057. base = 16
  6058. goto int_common
  6059. __77:
  6060. base = 8
  6061. goto int_common
  6062. __78:
  6063. __79:
  6064. base = 10
  6065. goto int_common
  6066. __80:
  6067. base = 0
  6068. int_common:
  6069. x = X__intscan(tls, f, uint32(base), 0, 2*uint64(0x7fffffffffffffff)+uint64(1))
  6070. if !!((*FILE)(unsafe.Pointer(f)).shcnt+(int64((*FILE)(unsafe.Pointer(f)).rpos)-int64((*FILE)(unsafe.Pointer(f)).buf))/1 != 0) {
  6071. goto __140
  6072. }
  6073. goto match_fail
  6074. __140:
  6075. ;
  6076. if !(t == 'p' && dest != 0) {
  6077. goto __141
  6078. }
  6079. *(*uintptr)(unsafe.Pointer(dest)) = uintptr(uintptr_t(x))
  6080. goto __142
  6081. __141:
  6082. store_int(tls, dest, size, x)
  6083. __142:
  6084. ;
  6085. goto __70
  6086. __81:
  6087. __82:
  6088. __83:
  6089. __84:
  6090. __85:
  6091. __86:
  6092. __87:
  6093. __88:
  6094. y = X__floatscan(tls, f, size, 0)
  6095. if !!((*FILE)(unsafe.Pointer(f)).shcnt+(int64((*FILE)(unsafe.Pointer(f)).rpos)-int64((*FILE)(unsafe.Pointer(f)).buf))/1 != 0) {
  6096. goto __143
  6097. }
  6098. goto match_fail
  6099. __143:
  6100. ;
  6101. if !(dest != 0) {
  6102. goto __144
  6103. }
  6104. switch size {
  6105. case 0:
  6106. goto __146
  6107. case 1:
  6108. goto __147
  6109. case 2:
  6110. goto __148
  6111. }
  6112. goto __145
  6113. __146:
  6114. *(*float32)(unsafe.Pointer(dest)) = float32(y)
  6115. goto __145
  6116. __147:
  6117. *(*float64)(unsafe.Pointer(dest)) = y
  6118. goto __145
  6119. __148:
  6120. *(*float64)(unsafe.Pointer(dest)) = y
  6121. goto __145
  6122. __145:
  6123. ;
  6124. __144:
  6125. ;
  6126. goto __70
  6127. __70:
  6128. ;
  6129. pos = pos + ((*FILE)(unsafe.Pointer(f)).shcnt + (int64((*FILE)(unsafe.Pointer(f)).rpos)-int64((*FILE)(unsafe.Pointer(f)).buf))/1)
  6130. if !(dest != 0) {
  6131. goto __149
  6132. }
  6133. matches++
  6134. __149:
  6135. ;
  6136. goto __4
  6137. __4:
  6138. p++
  6139. goto __3
  6140. goto __5
  6141. __5:
  6142. ;
  6143. if !(0 != 0) {
  6144. goto __150
  6145. }
  6146. fmt_fail:
  6147. alloc_fail:
  6148. input_fail:
  6149. if !!(matches != 0) {
  6150. goto __151
  6151. }
  6152. matches--
  6153. __151:
  6154. ;
  6155. match_fail:
  6156. if !(alloc != 0) {
  6157. goto __152
  6158. }
  6159. Xfree(tls, s)
  6160. Xfree(tls, wcs)
  6161. __152:
  6162. ;
  6163. __150:
  6164. ;
  6165. __153:
  6166. if !(__need_unlock != 0) {
  6167. goto __156
  6168. }
  6169. X__unlockfile(tls, f)
  6170. __156:
  6171. ;
  6172. goto __154
  6173. __154:
  6174. if 0 != 0 {
  6175. goto __153
  6176. }
  6177. goto __155
  6178. __155:
  6179. ;
  6180. return matches
  6181. }
  6182. func string_read(tls *TLS, f uintptr, buf uintptr, len size_t) size_t { /* vsscanf.c:4:15: */
  6183. var src uintptr = (*FILE)(unsafe.Pointer(f)).cookie
  6184. var k size_t = len + uint64(256)
  6185. var end uintptr = Xmemchr(tls, src, 0, k)
  6186. if end != 0 {
  6187. k = size_t((int64(end) - int64(src)) / 1)
  6188. }
  6189. if k < len {
  6190. len = k
  6191. }
  6192. Xmemcpy(tls, buf, src, len)
  6193. (*FILE)(unsafe.Pointer(f)).rpos = src + uintptr(len)
  6194. (*FILE)(unsafe.Pointer(f)).rend = src + uintptr(k)
  6195. (*FILE)(unsafe.Pointer(f)).cookie = src + uintptr(k)
  6196. return len
  6197. }
  6198. func Xvsscanf(tls *TLS, s uintptr, fmt uintptr, ap va_list) int32 { /* vsscanf.c:18:5: */
  6199. if __ccgo_strace {
  6200. trc("tls=%v s=%v fmt=%v ap=%v, (%v:)", tls, s, fmt, ap, origin(2))
  6201. }
  6202. bp := tls.Alloc(232)
  6203. defer tls.Free(232)
  6204. *(*FILE)(unsafe.Pointer(bp /* f */)) = FILE{read: *(*uintptr)(unsafe.Pointer(&struct {
  6205. f func(*TLS, uintptr, uintptr, size_t) size_t
  6206. }{string_read})), buf: s, lock: -1, cookie: s}
  6207. return Xvfscanf(tls, bp, fmt, ap)
  6208. }
  6209. func Xbsearch(tls *TLS, key uintptr, base uintptr, nel size_t, width size_t, cmp uintptr) uintptr { /* bsearch.c:3:6: */
  6210. if __ccgo_strace {
  6211. trc("tls=%v key=%v base=%v nel=%v width=%v cmp=%v, (%v:)", tls, key, base, nel, width, cmp, origin(2))
  6212. }
  6213. var try uintptr
  6214. var sign int32
  6215. for nel > uint64(0) {
  6216. try = base + uintptr(width*(nel/uint64(2)))
  6217. sign = (*struct {
  6218. f func(*TLS, uintptr, uintptr) int32
  6219. })(unsafe.Pointer(&struct{ uintptr }{cmp})).f(tls, key, try)
  6220. if sign < 0 {
  6221. nel = nel / uint64(2)
  6222. } else if sign > 0 {
  6223. base = try + uintptr(width)
  6224. nel = nel - (nel/uint64(2) + uint64(1))
  6225. } else {
  6226. return try
  6227. }
  6228. }
  6229. return uintptr(0)
  6230. }
  6231. func strtox(tls *TLS, s uintptr, p uintptr, prec int32) float64 { /* strtod.c:6:20: */
  6232. bp := tls.Alloc(232)
  6233. defer tls.Free(232)
  6234. // var f FILE at bp, 232
  6235. (*FILE)(unsafe.Pointer(bp)).buf = AssignPtrUintptr(bp+8, s)
  6236. (*FILE)(unsafe.Pointer(bp)).rend = UintptrFromInt32(-1)
  6237. X__shlim(tls, bp, int64(0))
  6238. var y float64 = X__floatscan(tls, bp, prec, 1)
  6239. var cnt off_t = (*FILE)(unsafe.Pointer(bp)).shcnt + (int64((*FILE)(unsafe.Pointer(bp)).rpos)-int64((*FILE)(unsafe.Pointer(bp)).buf))/1
  6240. if p != 0 {
  6241. *(*uintptr)(unsafe.Pointer(p)) = func() uintptr {
  6242. if cnt != 0 {
  6243. return s + uintptr(cnt)
  6244. }
  6245. return s
  6246. }()
  6247. }
  6248. return y
  6249. }
  6250. func Xstrtof(tls *TLS, s uintptr, p uintptr) float32 { /* strtod.c:17:7: */
  6251. if __ccgo_strace {
  6252. trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2))
  6253. }
  6254. return float32(strtox(tls, s, p, 0))
  6255. }
  6256. func Xstrtod(tls *TLS, s uintptr, p uintptr) float64 { /* strtod.c:22:8: */
  6257. if __ccgo_strace {
  6258. trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2))
  6259. }
  6260. return strtox(tls, s, p, 1)
  6261. }
  6262. func Xstrtold(tls *TLS, s uintptr, p uintptr) float64 { /* strtod.c:27:13: */
  6263. if __ccgo_strace {
  6264. trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2))
  6265. }
  6266. return strtox(tls, s, p, 2)
  6267. }
  6268. func strtox1(tls *TLS, s uintptr, p uintptr, base int32, lim uint64) uint64 { /* strtol.c:8:27: */
  6269. bp := tls.Alloc(232)
  6270. defer tls.Free(232)
  6271. // var f FILE at bp, 232
  6272. (*FILE)(unsafe.Pointer(bp)).buf = AssignPtrUintptr(bp+8, s)
  6273. (*FILE)(unsafe.Pointer(bp)).rend = UintptrFromInt32(-1)
  6274. X__shlim(tls, bp, int64(0))
  6275. var y uint64 = X__intscan(tls, bp, uint32(base), 1, lim)
  6276. if p != 0 {
  6277. var cnt size_t = size_t((*FILE)(unsafe.Pointer(bp)).shcnt + (int64((*FILE)(unsafe.Pointer(bp)).rpos)-int64((*FILE)(unsafe.Pointer(bp)).buf))/1)
  6278. *(*uintptr)(unsafe.Pointer(p)) = s + uintptr(cnt)
  6279. }
  6280. return y
  6281. }
  6282. func Xstrtoull(tls *TLS, s uintptr, p uintptr, base int32) uint64 { /* strtol.c:21:20: */
  6283. if __ccgo_strace {
  6284. trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2))
  6285. }
  6286. return strtox1(tls, s, p, base, 2*uint64(0x7fffffffffffffff)+uint64(1))
  6287. }
  6288. func Xstrtoll(tls *TLS, s uintptr, p uintptr, base int32) int64 { /* strtol.c:26:11: */
  6289. if __ccgo_strace {
  6290. trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2))
  6291. }
  6292. return int64(strtox1(tls, s, p, base, Uint64FromInt64(-0x7fffffffffffffff-int64(1))))
  6293. }
  6294. func Xstrtoul(tls *TLS, s uintptr, p uintptr, base int32) uint64 { /* strtol.c:31:15: */
  6295. if __ccgo_strace {
  6296. trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2))
  6297. }
  6298. return uint64(strtox1(tls, s, p, base, 2*uint64(0x7fffffffffffffff)+uint64(1)))
  6299. }
  6300. func Xstrtol(tls *TLS, s uintptr, p uintptr, base int32) int64 { /* strtol.c:36:6: */
  6301. if __ccgo_strace {
  6302. trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2))
  6303. }
  6304. return int64(strtox1(tls, s, p, base, 0+Uint64FromInt64(Int64(-Int64(0x7fffffffffffffff))-Int64FromInt32(1))))
  6305. }
  6306. func Xstrtoimax(tls *TLS, s uintptr, p uintptr, base int32) intmax_t { /* strtol.c:41:10: */
  6307. if __ccgo_strace {
  6308. trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2))
  6309. }
  6310. return intmax_t(Xstrtoll(tls, s, p, base))
  6311. }
  6312. func Xstrtoumax(tls *TLS, s uintptr, p uintptr, base int32) uintmax_t { /* strtol.c:46:11: */
  6313. if __ccgo_strace {
  6314. trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2))
  6315. }
  6316. return uintmax_t(Xstrtoull(tls, s, p, base))
  6317. }
  6318. func Xstrdup(tls *TLS, s uintptr) uintptr { /* strdup.c:4:6: */
  6319. if __ccgo_strace {
  6320. trc("tls=%v s=%v, (%v:)", tls, s, origin(2))
  6321. }
  6322. var l size_t = Xstrlen(tls, s)
  6323. var d uintptr = Xmalloc(tls, l+uint64(1))
  6324. if !(d != 0) {
  6325. return uintptr(0)
  6326. }
  6327. return Xmemcpy(tls, d, s, l+uint64(1))
  6328. }
  6329. func Xstrlcat(tls *TLS, d uintptr, s uintptr, n size_t) size_t { /* strlcat.c:4:8: */
  6330. if __ccgo_strace {
  6331. trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2))
  6332. }
  6333. var l size_t = Xstrnlen(tls, d, n)
  6334. if l == n {
  6335. return l + Xstrlen(tls, s)
  6336. }
  6337. return l + Xstrlcpy(tls, d+uintptr(l), s, n-l)
  6338. }
  6339. // Support signed or unsigned plain-char
  6340. // Implementation choices...
  6341. // Arbitrary numbers...
  6342. // POSIX/SUS requirements follow. These numbers come directly
  6343. // from SUS and have nothing to do with the host system.
  6344. func Xstrlcpy(tls *TLS, d uintptr, s uintptr, n size_t) size_t { /* strlcpy.c:11:8: */
  6345. if __ccgo_strace {
  6346. trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2))
  6347. }
  6348. var d0 uintptr
  6349. var wd uintptr
  6350. var ws uintptr
  6351. d0 = d
  6352. if !!(int32(PostDecUint64(&n, 1)) != 0) {
  6353. goto __1
  6354. }
  6355. goto finish
  6356. __1:
  6357. ;
  6358. if !(uintptr_t(s)&(uint64(unsafe.Sizeof(size_t(0)))-uint64(1)) == uintptr_t(d)&(uint64(unsafe.Sizeof(size_t(0)))-uint64(1))) {
  6359. goto __2
  6360. }
  6361. __3:
  6362. if !(uintptr_t(s)&(uint64(unsafe.Sizeof(size_t(0)))-uint64(1)) != 0 && n != 0 && AssignPtrInt8(d, *(*int8)(unsafe.Pointer(s))) != 0) {
  6363. goto __5
  6364. }
  6365. goto __4
  6366. __4:
  6367. n--
  6368. s++
  6369. d++
  6370. goto __3
  6371. goto __5
  6372. __5:
  6373. ;
  6374. if !(n != 0 && *(*int8)(unsafe.Pointer(s)) != 0) {
  6375. goto __6
  6376. }
  6377. wd = d
  6378. ws = s
  6379. __7:
  6380. if !(n >= size_t(unsafe.Sizeof(size_t(0))) && !((*(*uint64)(unsafe.Pointer(ws))-Uint64(Uint64FromInt32(-1))/uint64(255)) & ^*(*uint64)(unsafe.Pointer(ws)) & (Uint64(Uint64FromInt32(-1))/uint64(255)*uint64(255/2+1)) != 0)) {
  6381. goto __9
  6382. }
  6383. *(*size_t)(unsafe.Pointer(wd)) = *(*uint64)(unsafe.Pointer(ws))
  6384. goto __8
  6385. __8:
  6386. n = n - size_t(unsafe.Sizeof(size_t(0)))
  6387. ws += 8
  6388. wd += 8
  6389. goto __7
  6390. goto __9
  6391. __9:
  6392. ;
  6393. d = wd
  6394. s = ws
  6395. __6:
  6396. ;
  6397. __2:
  6398. ;
  6399. __10:
  6400. if !(n != 0 && AssignPtrInt8(d, *(*int8)(unsafe.Pointer(s))) != 0) {
  6401. goto __12
  6402. }
  6403. goto __11
  6404. __11:
  6405. n--
  6406. s++
  6407. d++
  6408. goto __10
  6409. goto __12
  6410. __12:
  6411. ;
  6412. *(*int8)(unsafe.Pointer(d)) = int8(0)
  6413. finish:
  6414. return size_t((int64(d)-int64(d0))/1) + Xstrlen(tls, s)
  6415. }
  6416. func Xstrncasecmp(tls *TLS, _l uintptr, _r uintptr, n size_t) int32 { /* strncasecmp.c:4:5: */
  6417. if __ccgo_strace {
  6418. trc("tls=%v _l=%v _r=%v n=%v, (%v:)", tls, _l, _r, n, origin(2))
  6419. }
  6420. var l uintptr = _l
  6421. var r uintptr = _r
  6422. if !(int32(PostDecUint64(&n, 1)) != 0) {
  6423. return 0
  6424. }
  6425. __1:
  6426. if !(*(*uint8)(unsafe.Pointer(l)) != 0 && *(*uint8)(unsafe.Pointer(r)) != 0 && n != 0 && (int32(*(*uint8)(unsafe.Pointer(l))) == int32(*(*uint8)(unsafe.Pointer(r))) || Xtolower(tls, int32(*(*uint8)(unsafe.Pointer(l)))) == Xtolower(tls, int32(*(*uint8)(unsafe.Pointer(r)))))) {
  6427. goto __3
  6428. }
  6429. goto __2
  6430. __2:
  6431. l++
  6432. r++
  6433. n--
  6434. goto __1
  6435. goto __3
  6436. __3:
  6437. ;
  6438. return Xtolower(tls, int32(*(*uint8)(unsafe.Pointer(l)))) - Xtolower(tls, int32(*(*uint8)(unsafe.Pointer(r))))
  6439. }
  6440. func X__strncasecmp_l(tls *TLS, l uintptr, r uintptr, n size_t, loc locale_t) int32 { /* strncasecmp.c:12:5: */
  6441. if __ccgo_strace {
  6442. trc("tls=%v l=%v r=%v n=%v loc=%v, (%v:)", tls, l, r, n, loc, origin(2))
  6443. }
  6444. return Xstrncasecmp(tls, l, r, n)
  6445. }
  6446. func Xstrncat(tls *TLS, d uintptr, s uintptr, n size_t) uintptr { /* strncat.c:3:6: */
  6447. if __ccgo_strace {
  6448. trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2))
  6449. }
  6450. var a uintptr = d
  6451. d += uintptr(Xstrlen(tls, d))
  6452. for n != 0 && *(*int8)(unsafe.Pointer(s)) != 0 {
  6453. n--
  6454. *(*int8)(unsafe.Pointer(PostIncUintptr(&d, 1))) = *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1)))
  6455. }
  6456. *(*int8)(unsafe.Pointer(PostIncUintptr(&d, 1))) = int8(0)
  6457. return a
  6458. }
  6459. func Xstrnlen(tls *TLS, s uintptr, n size_t) size_t { /* strnlen.c:3:8: */
  6460. if __ccgo_strace {
  6461. trc("tls=%v s=%v n=%v, (%v:)", tls, s, n, origin(2))
  6462. }
  6463. var p uintptr = Xmemchr(tls, s, 0, n)
  6464. if p != 0 {
  6465. return uint64((int64(p) - int64(s)) / 1)
  6466. }
  6467. return n
  6468. }
  6469. func Xstrspn(tls *TLS, s uintptr, c uintptr) size_t { /* strspn.c:6:8: */
  6470. if __ccgo_strace {
  6471. trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2))
  6472. }
  6473. bp := tls.Alloc(32)
  6474. defer tls.Free(32)
  6475. var a uintptr = s
  6476. *(*[4]size_t)(unsafe.Pointer(bp /* byteset */)) = [4]size_t{0: uint64(0)}
  6477. if !(int32(*(*int8)(unsafe.Pointer(c))) != 0) {
  6478. return uint64(0)
  6479. }
  6480. if !(int32(*(*int8)(unsafe.Pointer(c + 1))) != 0) {
  6481. for ; int32(*(*int8)(unsafe.Pointer(s))) == int32(*(*int8)(unsafe.Pointer(c))); s++ {
  6482. }
  6483. return size_t((int64(s) - int64(a)) / 1)
  6484. }
  6485. for ; *(*int8)(unsafe.Pointer(c)) != 0 && AssignOrPtrUint64(bp+uintptr(size_t(*(*uint8)(unsafe.Pointer(c)))/(uint64(8)*uint64(unsafe.Sizeof(size_t(0)))))*8, size_t(uint64(1))<<(size_t(*(*uint8)(unsafe.Pointer(c)))%(uint64(8)*uint64(unsafe.Sizeof(size_t(0)))))) != 0; c++ {
  6486. }
  6487. for ; *(*int8)(unsafe.Pointer(s)) != 0 && *(*size_t)(unsafe.Pointer(bp + uintptr(size_t(*(*uint8)(unsafe.Pointer(s)))/(uint64(8)*uint64(unsafe.Sizeof(size_t(0)))))*8))&(size_t(uint64(1))<<(size_t(*(*uint8)(unsafe.Pointer(s)))%(uint64(8)*uint64(unsafe.Sizeof(size_t(0)))))) != 0; s++ {
  6488. }
  6489. return size_t((int64(s) - int64(a)) / 1)
  6490. }
  6491. func Xstrtok(tls *TLS, s uintptr, sep uintptr) uintptr { /* strtok.c:3:6: */
  6492. if __ccgo_strace {
  6493. trc("tls=%v s=%v sep=%v, (%v:)", tls, s, sep, origin(2))
  6494. }
  6495. if !(s != 0) && !(int32(AssignUintptr(&s, _sp)) != 0) {
  6496. return uintptr(0)
  6497. }
  6498. s += uintptr(Xstrspn(tls, s, sep))
  6499. if !(int32(*(*int8)(unsafe.Pointer(s))) != 0) {
  6500. return AssignPtrUintptr(uintptr(unsafe.Pointer(&_sp)), uintptr(0))
  6501. }
  6502. _sp = s + uintptr(Xstrcspn(tls, s, sep))
  6503. if *(*int8)(unsafe.Pointer(_sp)) != 0 {
  6504. *(*int8)(unsafe.Pointer(PostIncUintptr(&_sp, 1))) = int8(0)
  6505. } else {
  6506. _sp = uintptr(0)
  6507. }
  6508. return s
  6509. }
  6510. var _sp uintptr /* strtok.c:5:14: */
  6511. func X__ccgo_pthreadAttrGetDetachState(tls *TLS, a uintptr) int32 { /* pthread_attr_get.c:3:5: */
  6512. if __ccgo_strace {
  6513. trc("tls=%v a=%v, (%v:)", tls, a, origin(2))
  6514. }
  6515. return *(*int32)(unsafe.Pointer(a + 6*4))
  6516. }
  6517. func Xpthread_attr_getdetachstate(tls *TLS, a uintptr, state uintptr) int32 { /* pthread_attr_get.c:7:5: */
  6518. if __ccgo_strace {
  6519. trc("tls=%v a=%v state=%v, (%v:)", tls, a, state, origin(2))
  6520. }
  6521. *(*int32)(unsafe.Pointer(state)) = *(*int32)(unsafe.Pointer(a + 6*4))
  6522. return 0
  6523. }
  6524. //
  6525. // int pthread_attr_getguardsize(const pthread_attr_t *restrict a, size_t *restrict size)
  6526. // {
  6527. // *size = a->_a_guardsize;
  6528. // return 0;
  6529. // }
  6530. //
  6531. // int pthread_attr_getinheritsched(const pthread_attr_t *restrict a, int *restrict inherit)
  6532. // {
  6533. // *inherit = a->_a_sched;
  6534. // return 0;
  6535. // }
  6536. //
  6537. // int pthread_attr_getschedparam(const pthread_attr_t *restrict a, struct sched_param *restrict param)
  6538. // {
  6539. // param->sched_priority = a->_a_prio;
  6540. // return 0;
  6541. // }
  6542. //
  6543. // int pthread_attr_getschedpolicy(const pthread_attr_t *restrict a, int *restrict policy)
  6544. // {
  6545. // *policy = a->_a_policy;
  6546. // return 0;
  6547. // }
  6548. //
  6549. // int pthread_attr_getscope(const pthread_attr_t *restrict a, int *restrict scope)
  6550. // {
  6551. // *scope = PTHREAD_SCOPE_SYSTEM;
  6552. // return 0;
  6553. // }
  6554. //
  6555. // int pthread_attr_getstack(const pthread_attr_t *restrict a, void **restrict addr, size_t *restrict size)
  6556. // {
  6557. // if (!a->_a_stackaddr)
  6558. // return EINVAL;
  6559. // *size = a->_a_stacksize;
  6560. // *addr = (void *)(a->_a_stackaddr - *size);
  6561. // return 0;
  6562. // }
  6563. //
  6564. // int pthread_attr_getstacksize(const pthread_attr_t *restrict a, size_t *restrict size)
  6565. // {
  6566. // *size = a->_a_stacksize;
  6567. // return 0;
  6568. // }
  6569. //
  6570. // int pthread_barrierattr_getpshared(const pthread_barrierattr_t *restrict a, int *restrict pshared)
  6571. // {
  6572. // *pshared = !!a->__attr;
  6573. // return 0;
  6574. // }
  6575. //
  6576. // int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *restrict clk)
  6577. // {
  6578. // *clk = a->__attr & 0x7fffffff;
  6579. // return 0;
  6580. // }
  6581. //
  6582. // int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restrict pshared)
  6583. // {
  6584. // *pshared = a->__attr>>31;
  6585. // return 0;
  6586. // }
  6587. //
  6588. // int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *restrict a, int *restrict protocol)
  6589. // {
  6590. // *protocol = PTHREAD_PRIO_NONE;
  6591. // return 0;
  6592. // }
  6593. // int pthread_mutexattr_getpshared(const pthread_mutexattr_t *restrict a, int *restrict pshared)
  6594. // {
  6595. // *pshared = a->__attr / 128U % 2;
  6596. // return 0;
  6597. // }
  6598. //
  6599. // int pthread_mutexattr_getrobust(const pthread_mutexattr_t *restrict a, int *restrict robust)
  6600. // {
  6601. // *robust = a->__attr / 4U % 2;
  6602. // return 0;
  6603. // }
  6604. func X__ccgo_pthreadMutexattrGettype(tls *TLS, a uintptr) int32 { /* pthread_attr_get.c:93:5: */
  6605. if __ccgo_strace {
  6606. trc("tls=%v a=%v, (%v:)", tls, a, origin(2))
  6607. }
  6608. return int32((*pthread_mutexattr_t)(unsafe.Pointer(a)).__attr & uint32(3))
  6609. }
  6610. // int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict a, int *restrict type)
  6611. // {
  6612. // *type = a->__attr & 3;
  6613. // return 0;
  6614. // }
  6615. //
  6616. // int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *restrict a, int *restrict pshared)
  6617. // {
  6618. // *pshared = a->__attr[0];
  6619. // return 0;
  6620. // }
  6621. func Xpthread_attr_setdetachstate(tls *TLS, a uintptr, state int32) int32 { /* pthread_attr_setdetachstate.c:3:5: */
  6622. if __ccgo_strace {
  6623. trc("tls=%v a=%v state=%v, (%v:)", tls, a, state, origin(2))
  6624. }
  6625. if uint32(state) > 1 {
  6626. return 22
  6627. }
  6628. *(*int32)(unsafe.Pointer(a + 6*4)) = state
  6629. return 0
  6630. }
  6631. func X__ccgo_getMutexType(tls *TLS, m uintptr) int32 { /* pthread_mutex_lock.c:3:5: */
  6632. if __ccgo_strace {
  6633. trc("tls=%v m=%v, (%v:)", tls, m, origin(2))
  6634. }
  6635. return *(*int32)(unsafe.Pointer(m)) & 15
  6636. }
  6637. // int __pthread_mutex_lock(pthread_mutex_t *m)
  6638. // {
  6639. // if ((m->_m_type&15) == PTHREAD_MUTEX_NORMAL
  6640. // && !a_cas(&m->_m_lock, 0, EBUSY))
  6641. // return 0;
  6642. //
  6643. // return __pthread_mutex_timedlock(m, 0);
  6644. // }
  6645. //
  6646. // weak_alias(__pthread_mutex_lock, pthread_mutex_lock);
  6647. func Xpthread_mutexattr_destroy(tls *TLS, a uintptr) int32 { /* pthread_mutexattr_destroy.c:3:5: */
  6648. if __ccgo_strace {
  6649. trc("tls=%v a=%v, (%v:)", tls, a, origin(2))
  6650. }
  6651. return 0
  6652. }
  6653. func Xpthread_mutexattr_init(tls *TLS, a uintptr) int32 { /* pthread_mutexattr_init.c:3:5: */
  6654. if __ccgo_strace {
  6655. trc("tls=%v a=%v, (%v:)", tls, a, origin(2))
  6656. }
  6657. *(*pthread_mutexattr_t)(unsafe.Pointer(a)) = pthread_mutexattr_t{}
  6658. return 0
  6659. }
  6660. func Xpthread_mutexattr_settype(tls *TLS, a uintptr, type1 int32) int32 { /* pthread_mutexattr_settype.c:3:5: */
  6661. if __ccgo_strace {
  6662. trc("tls=%v a=%v type1=%v, (%v:)", tls, a, type1, origin(2))
  6663. }
  6664. if uint32(type1) > uint32(2) {
  6665. return 22
  6666. }
  6667. (*pthread_mutexattr_t)(unsafe.Pointer(a)).__attr = (*pthread_mutexattr_t)(unsafe.Pointer(a)).__attr&Uint32FromInt32(CplInt32(3)) | uint32(type1)
  6668. return 0
  6669. }
  6670. func init() {
  6671. *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&ptable)) + 0)) = uintptr(unsafe.Pointer(&table)) + uintptr(128)*2 // __ctype_b_loc.c:36:45:
  6672. }
  6673. var ts1 = "infinity\x00nan\x00\x00\x00\x01\x02\x04\a\x03\x06\x05\x00.\x00%d.%d.%d.%d.in-addr.arpa\x00ip6.arpa\x000123456789abcdef\x00/etc/hosts\x00rb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00%d.%d.%d.%d\x00%x:%x:%x:%x:%x:%x:%x:%x\x00%x:%x:%x:%x:%x:%x:%d.%d.%d.%d\x00:0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00 \x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  6674. var ts = (*reflect.StringHeader)(unsafe.Pointer(&ts1)).Data