musl_darwin_amd64.go 147 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988
  1. // Code generated by 'ccgo -D__environ=environ -export-externs X -export-fields F -hide __syscall0,__syscall1,__syscall2,__syscall3,__syscall4,__syscall5,__syscall6 -hide isascii,isspace,tolower,toupper -nostdinc -nostdlib -o ../musl_darwin_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 ../darwin/table.c src/env/putenv.c src/env/setenv.c src/env/unsetenv.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/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/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/__toread.c src/stdio/__uflow.c src/stdlib/bsearch.c src/stdlib/strtod.c src/stdlib/strtol.c src/string/strchrnul.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', 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. type ptrdiff_t = int64 /* <builtin>:3:26 */
  341. type size_t = uint64 /* <builtin>:9:23 */
  342. type wchar_t = int32 /* <builtin>:15:24 */
  343. // /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_fd_def.h:54
  344. // int __darwin_check_fd_set_overflow(int, const void *, int) __API_AVAILABLE(macosx(11.0), ios(14.0), tvos(14.0), watchos(7.0));
  345. func X__darwin_check_fd_set_overflow(tls *TLS, _ int32, _ uintptr, _ int32) int32 {
  346. return 1
  347. }
  348. // pthread opaque structures
  349. type __darwin_pthread_handler_rec = struct {
  350. F__routine uintptr
  351. F__arg uintptr
  352. F__next uintptr
  353. } /* table.c:1396:1 */
  354. type _opaque_pthread_attr_t = struct {
  355. F__sig int64
  356. F__opaque [56]int8
  357. } /* table.c:1402:1 */
  358. type _opaque_pthread_cond_t = struct {
  359. F__sig int64
  360. F__opaque [40]int8
  361. } /* table.c:1407:1 */
  362. type _opaque_pthread_condattr_t = struct {
  363. F__sig int64
  364. F__opaque [8]int8
  365. } /* table.c:1412:1 */
  366. type _opaque_pthread_mutex_t = struct {
  367. F__sig int64
  368. F__opaque [56]int8
  369. } /* table.c:1417:1 */
  370. type _opaque_pthread_mutexattr_t = struct {
  371. F__sig int64
  372. F__opaque [8]int8
  373. } /* table.c:1422:1 */
  374. type _opaque_pthread_once_t = struct {
  375. F__sig int64
  376. F__opaque [8]int8
  377. } /* table.c:1427:1 */
  378. type _opaque_pthread_rwlock_t = struct {
  379. F__sig int64
  380. F__opaque [192]int8
  381. } /* table.c:1432:1 */
  382. type _opaque_pthread_rwlockattr_t = struct {
  383. F__sig int64
  384. F__opaque [16]int8
  385. } /* table.c:1437:1 */
  386. type _opaque_pthread_t = struct {
  387. F__sig int64
  388. F__cleanup_stack uintptr
  389. F__opaque [8176]int8
  390. } /* table.c:1442:1 */
  391. type ct_rune_t = int32 /* table.c:1527:28 */
  392. type rune_t = int32 /* table.c:1536:25 */
  393. type wint_t = int32 /* table.c:1558:25 */
  394. type _RuneEntry = struct {
  395. F__min int32
  396. F__max int32
  397. F__map int32
  398. F__ccgo_pad1 [4]byte
  399. F__types uintptr
  400. } /* table.c:1575:3 */
  401. type _RuneRange = struct {
  402. F__nranges int32
  403. F__ccgo_pad1 [4]byte
  404. F__ranges uintptr
  405. } /* table.c:1580:3 */
  406. type _RuneCharClass = struct {
  407. F__name [14]int8
  408. F__ccgo_pad1 [2]byte
  409. F__mask uint32
  410. } /* table.c:1585:3 */
  411. type _RuneLocale = struct {
  412. F__magic [8]int8
  413. F__encoding [32]int8
  414. F__sgetrune uintptr
  415. F__sputrune uintptr
  416. F__invalid_rune int32
  417. F__runetype [256]uint32
  418. F__maplower [256]int32
  419. F__mapupper [256]int32
  420. F__ccgo_pad1 [4]byte
  421. F__runetype_ext _RuneRange
  422. F__maplower_ext _RuneRange
  423. F__mapupper_ext _RuneRange
  424. F__variable uintptr
  425. F__variable_len int32
  426. F__ncharclasses int32
  427. F__charclasses uintptr
  428. } /* table.c:1616:3 */
  429. func X__istype(tls *TLS, _c int32, _f uint64) int32 { /* table.c:1670:1: */
  430. if __ccgo_strace {
  431. trc("tls=%v _c=%v _f=%v, (%v:)", tls, _c, _f, origin(2))
  432. }
  433. return func() int32 {
  434. if Xisascii(tls, _c) != 0 {
  435. return BoolInt32(!!(uint64(*(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&X_DefaultRuneLocale)) + 60 + uintptr(_c)*4)))&_f != 0))
  436. }
  437. return BoolInt32(!!(X__maskrune(tls, _c, _f) != 0))
  438. }()
  439. }
  440. func X__isctype(tls *TLS, _c int32, _f uint64) int32 { /* table.c:1681:1: */
  441. if __ccgo_strace {
  442. trc("tls=%v _c=%v _f=%v, (%v:)", tls, _c, _f, origin(2))
  443. }
  444. if _c < 0 || _c >= int32(1)<<8 {
  445. return 0
  446. }
  447. return BoolInt32(!!(uint64(*(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&X_DefaultRuneLocale)) + 60 + uintptr(_c)*4)))&_f != 0))
  448. }
  449. func X__wcwidth(tls *TLS, _c int32) int32 { /* table.c:1700:1: */
  450. if __ccgo_strace {
  451. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  452. }
  453. var _x uint32
  454. if _c == 0 {
  455. return 0
  456. }
  457. _x = uint32(X__maskrune(tls, _c, uint64(0xe0000000|0x00040000)))
  458. if int64(_x)&0xe0000000 != int64(0) {
  459. return int32(int64(_x) & 0xe0000000 >> 30)
  460. }
  461. return func() int32 {
  462. if int64(_x)&0x00040000 != int64(0) {
  463. return 1
  464. }
  465. return -1
  466. }()
  467. }
  468. func Xisalnum(tls *TLS, _c int32) int32 { /* table.c:1718:1: */
  469. if __ccgo_strace {
  470. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  471. }
  472. return X__istype(tls, _c, uint64(0x00000100|0x00000400))
  473. }
  474. func Xisalpha(tls *TLS, _c int32) int32 { /* table.c:1724:1: */
  475. if __ccgo_strace {
  476. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  477. }
  478. return X__istype(tls, _c, uint64(0x00000100))
  479. }
  480. func Xisblank(tls *TLS, _c int32) int32 { /* table.c:1730:1: */
  481. if __ccgo_strace {
  482. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  483. }
  484. return X__istype(tls, _c, uint64(0x00020000))
  485. }
  486. func Xiscntrl(tls *TLS, _c int32) int32 { /* table.c:1736:1: */
  487. if __ccgo_strace {
  488. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  489. }
  490. return X__istype(tls, _c, uint64(0x00000200))
  491. }
  492. func Xisdigit(tls *TLS, _c int32) int32 { /* table.c:1743:1: */
  493. if __ccgo_strace {
  494. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  495. }
  496. return X__isctype(tls, _c, uint64(0x00000400))
  497. }
  498. func Xisgraph(tls *TLS, _c int32) int32 { /* table.c:1749:1: */
  499. if __ccgo_strace {
  500. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  501. }
  502. return X__istype(tls, _c, uint64(0x00000800))
  503. }
  504. func Xislower(tls *TLS, _c int32) int32 { /* table.c:1755:1: */
  505. if __ccgo_strace {
  506. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  507. }
  508. return X__istype(tls, _c, uint64(0x00001000))
  509. }
  510. func Xisprint(tls *TLS, _c int32) int32 { /* table.c:1761:1: */
  511. if __ccgo_strace {
  512. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  513. }
  514. return X__istype(tls, _c, uint64(0x00040000))
  515. }
  516. func Xispunct(tls *TLS, _c int32) int32 { /* table.c:1767:1: */
  517. if __ccgo_strace {
  518. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  519. }
  520. return X__istype(tls, _c, uint64(0x00002000))
  521. }
  522. func Xisupper(tls *TLS, _c int32) int32 { /* table.c:1779:1: */
  523. if __ccgo_strace {
  524. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  525. }
  526. return X__istype(tls, _c, uint64(0x00008000))
  527. }
  528. func Xisxdigit(tls *TLS, _c int32) int32 { /* table.c:1786:1: */
  529. if __ccgo_strace {
  530. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  531. }
  532. return X__isctype(tls, _c, uint64(0x00010000))
  533. }
  534. func Xtoascii(tls *TLS, _c int32) int32 { /* table.c:1792:1: */
  535. if __ccgo_strace {
  536. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  537. }
  538. return _c & 0x7F
  539. }
  540. func Xdigittoint(tls *TLS, _c int32) int32 { /* table.c:1811:1: */
  541. if __ccgo_strace {
  542. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  543. }
  544. return X__maskrune(tls, _c, uint64(0x0F))
  545. }
  546. func Xishexnumber(tls *TLS, _c int32) int32 { /* table.c:1817:1: */
  547. if __ccgo_strace {
  548. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  549. }
  550. return X__istype(tls, _c, uint64(0x00010000))
  551. }
  552. func Xisideogram(tls *TLS, _c int32) int32 { /* table.c:1823:1: */
  553. if __ccgo_strace {
  554. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  555. }
  556. return X__istype(tls, _c, uint64(0x00080000))
  557. }
  558. func Xisnumber(tls *TLS, _c int32) int32 { /* table.c:1829:1: */
  559. if __ccgo_strace {
  560. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  561. }
  562. return X__istype(tls, _c, uint64(0x00000400))
  563. }
  564. func Xisphonogram(tls *TLS, _c int32) int32 { /* table.c:1835:1: */
  565. if __ccgo_strace {
  566. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  567. }
  568. return X__istype(tls, _c, uint64(0x00200000))
  569. }
  570. func Xisrune(tls *TLS, _c int32) int32 { /* table.c:1841:1: */
  571. if __ccgo_strace {
  572. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  573. }
  574. return X__istype(tls, _c, uint64(0xFFFFFFF0))
  575. }
  576. func Xisspecial(tls *TLS, _c int32) int32 { /* table.c:1847:1: */
  577. if __ccgo_strace {
  578. trc("tls=%v _c=%v, (%v:)", tls, _c, origin(2))
  579. }
  580. return X__istype(tls, _c, uint64(0x00100000))
  581. }
  582. func X__maskrune(tls *TLS, _c int32, _f uint64) int32 { /* table.c:1871:2: */
  583. if __ccgo_strace {
  584. trc("tls=%v _c=%v _f=%v, (%v:)", tls, _c, _f, origin(2))
  585. }
  586. return int32(uint32(int32(*(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&X_DefaultRuneLocale)) + 60 + uintptr(_c&0xff)*4)))) & uint32(_f))
  587. }
  588. func X__toupper(tls *TLS, c int32) int32 { /* table.c:1876:20: */
  589. if __ccgo_strace {
  590. trc("tls=%v c=%v, (%v:)", tls, c, origin(2))
  591. }
  592. return Xtoupper(tls, c)
  593. }
  594. func X__tolower(tls *TLS, c int32) int32 { /* table.c:1878:20: */
  595. if __ccgo_strace {
  596. trc("tls=%v c=%v, (%v:)", tls, c, origin(2))
  597. }
  598. return Xtolower(tls, c)
  599. }
  600. var X_DefaultRuneLocale = _RuneLocale{F__magic: [8]int8{int8(82), int8(117), int8(110), int8(101), int8(77), int8(97), int8(103), int8(65)}, F__encoding: [32]int8{int8(78), int8(79), int8(78), int8(69), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0), int8(0)}, F__invalid_rune: 0xfffd, F__runetype: [256]uint32{
  601. uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x24200), uint32(0x4200), uint32(0x4200), uint32(0x4200), uint32(0x4200), uint32(0x200), uint32(0x200),
  602. uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200), uint32(0x200),
  603. uint32(0x64000), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800),
  604. uint32(0x50c00), uint32(0x50c01), uint32(0x50c02), uint32(0x50c03), uint32(0x50c04), uint32(0x50c05), uint32(0x50c06), uint32(0x50c07), uint32(0x50c08), uint32(0x50c09), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800),
  605. uint32(0x42800), uint32(0x5890a), uint32(0x5890b), uint32(0x5890c), uint32(0x5890d), uint32(0x5890e), uint32(0x5890f), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900),
  606. uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x48900), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800),
  607. uint32(0x42800), uint32(0x5190a), uint32(0x5190b), uint32(0x5190c), uint32(0x5190d), uint32(0x5190e), uint32(0x5190f), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900),
  608. uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x41900), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x42800), uint32(0x200),
  609. uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0),
  610. uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0),
  611. uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0),
  612. uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0),
  613. uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0),
  614. uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0),
  615. uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0),
  616. uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0), uint32(0x0),
  617. }, F__maplower: [256]int32{
  618. 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf,
  619. 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
  620. 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
  621. 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
  622. 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
  623. 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
  624. 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
  625. 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
  626. 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
  627. 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
  628. 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
  629. 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
  630. 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
  631. 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
  632. 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
  633. 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
  634. }, F__mapupper: [256]int32{
  635. 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf,
  636. 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
  637. 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
  638. 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
  639. 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
  640. 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
  641. 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
  642. 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
  643. 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
  644. 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
  645. 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
  646. 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
  647. 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
  648. 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
  649. 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
  650. 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
  651. },
  652. } /* table.c:1879:13 */
  653. var X_CurrentRuneLocale uintptr = 0 /* table.c:1940:13 */
  654. type div_t = struct {
  655. Fquot int32
  656. Frem int32
  657. } /* stdlib.h:62:35 */
  658. type ldiv_t = struct {
  659. Fquot int64
  660. Frem int64
  661. } /* stdlib.h:63:36 */
  662. type lldiv_t = struct {
  663. Fquot int64
  664. Frem int64
  665. } /* stdlib.h:64:41 */
  666. type locale_t = uintptr /* alltypes.h:343:32 */
  667. type ssize_t = int64 /* alltypes.h:65:15 */
  668. type intptr_t = int64 /* alltypes.h:70:15 */
  669. type off_t = int64 /* alltypes.h:162:16 */
  670. type pid_t = int32 /* alltypes.h:235:13 */
  671. type uid_t = uint32 /* alltypes.h:245:18 */
  672. type gid_t = uint32 /* alltypes.h:250:18 */
  673. type useconds_t = uint32 /* alltypes.h:260:18 */
  674. func X__putenv(tls *TLS, s uintptr, l size_t, r uintptr) int32 { /* putenv.c:8:5: */
  675. if __ccgo_strace {
  676. trc("tls=%v s=%v l=%v r=%v, (%v:)", tls, s, l, r, origin(2))
  677. }
  678. var i size_t
  679. var newenv uintptr
  680. var tmp uintptr
  681. //TODO for (char **e = __environ; *e; e++, i++)
  682. var e uintptr
  683. i = uint64(0)
  684. if !(Environ() != 0) {
  685. goto __1
  686. }
  687. //TODO for (char **e = __environ; *e; e++, i++)
  688. e = Environ()
  689. __2:
  690. if !(*(*uintptr)(unsafe.Pointer(e)) != 0) {
  691. goto __4
  692. }
  693. if !!(Xstrncmp(tls, s, *(*uintptr)(unsafe.Pointer(e)), l+uint64(1)) != 0) {
  694. goto __5
  695. }
  696. tmp = *(*uintptr)(unsafe.Pointer(e))
  697. *(*uintptr)(unsafe.Pointer(e)) = s
  698. X__env_rm_add(tls, tmp, r)
  699. return 0
  700. __5:
  701. ;
  702. goto __3
  703. __3:
  704. e += 8
  705. i++
  706. goto __2
  707. goto __4
  708. __4:
  709. ;
  710. __1:
  711. ;
  712. if !(Environ() == _soldenv) {
  713. goto __6
  714. }
  715. newenv = Xrealloc(tls, _soldenv, uint64(unsafe.Sizeof(uintptr(0)))*(i+uint64(2)))
  716. if !!(newenv != 0) {
  717. goto __8
  718. }
  719. goto oom
  720. __8:
  721. ;
  722. goto __7
  723. __6:
  724. newenv = Xmalloc(tls, uint64(unsafe.Sizeof(uintptr(0)))*(i+uint64(2)))
  725. if !!(newenv != 0) {
  726. goto __9
  727. }
  728. goto oom
  729. __9:
  730. ;
  731. if !(i != 0) {
  732. goto __10
  733. }
  734. Xmemcpy(tls, newenv, Environ(), uint64(unsafe.Sizeof(uintptr(0)))*i)
  735. __10:
  736. ;
  737. Xfree(tls, _soldenv)
  738. __7:
  739. ;
  740. *(*uintptr)(unsafe.Pointer(newenv + uintptr(i)*8)) = s
  741. *(*uintptr)(unsafe.Pointer(newenv + uintptr(i+uint64(1))*8)) = uintptr(0)
  742. *(*uintptr)(unsafe.Pointer(EnvironP())) = AssignPtrUintptr(uintptr(unsafe.Pointer(&_soldenv)), newenv)
  743. if !(r != 0) {
  744. goto __11
  745. }
  746. X__env_rm_add(tls, uintptr(0), r)
  747. __11:
  748. ;
  749. return 0
  750. oom:
  751. Xfree(tls, r)
  752. return -1
  753. }
  754. var _soldenv uintptr /* putenv.c:22:14: */
  755. func Xputenv(tls *TLS, s uintptr) int32 { /* putenv.c:43:5: */
  756. if __ccgo_strace {
  757. trc("tls=%v s=%v, (%v:)", tls, s, origin(2))
  758. }
  759. var l size_t = size_t((int64(X__strchrnul(tls, s, '=')) - int64(s)) / 1)
  760. if !(l != 0) || !(int32(*(*int8)(unsafe.Pointer(s + uintptr(l)))) != 0) {
  761. return Xunsetenv(tls, s)
  762. }
  763. return X__putenv(tls, s, l, uintptr(0))
  764. }
  765. func X__env_rm_add(tls *TLS, old uintptr, new uintptr) { /* setenv.c:5:6: */
  766. if __ccgo_strace {
  767. trc("tls=%v old=%v new=%v, (%v:)", tls, old, new, origin(2))
  768. }
  769. //TODO for (size_t i=0; i < env_alloced_n; i++)
  770. var i size_t = uint64(0)
  771. for ; i < _senv_alloced_n; i++ {
  772. if *(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8)) == old {
  773. *(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8)) = new
  774. Xfree(tls, old)
  775. return
  776. } else if !(int32(*(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8))) != 0) && new != 0 {
  777. *(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8)) = new
  778. new = uintptr(0)
  779. }
  780. }
  781. if !(new != 0) {
  782. return
  783. }
  784. var t uintptr = Xrealloc(tls, _senv_alloced, uint64(unsafe.Sizeof(uintptr(0)))*(_senv_alloced_n+uint64(1)))
  785. if !(t != 0) {
  786. return
  787. }
  788. *(*uintptr)(unsafe.Pointer(AssignPtrUintptr(uintptr(unsafe.Pointer(&_senv_alloced)), t) + uintptr(PostIncUint64(&_senv_alloced_n, 1))*8)) = new
  789. }
  790. var _senv_alloced uintptr /* setenv.c:7:14: */
  791. var _senv_alloced_n size_t /* setenv.c:8:16: */
  792. func Xsetenv(tls *TLS, var1 uintptr, value uintptr, overwrite int32) int32 { /* setenv.c:26:5: */
  793. if __ccgo_strace {
  794. trc("tls=%v var1=%v value=%v overwrite=%v, (%v:)", tls, var1, value, overwrite, origin(2))
  795. }
  796. var s uintptr
  797. var l1 size_t
  798. var l2 size_t
  799. if !(var1 != 0) || !(int32(AssignUint64(&l1, size_t((int64(X__strchrnul(tls, var1, '='))-int64(var1))/1))) != 0) || *(*int8)(unsafe.Pointer(var1 + uintptr(l1))) != 0 {
  800. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22
  801. return -1
  802. }
  803. if !(overwrite != 0) && Xgetenv(tls, var1) != 0 {
  804. return 0
  805. }
  806. l2 = Xstrlen(tls, value)
  807. s = Xmalloc(tls, l1+l2+uint64(2))
  808. if !(s != 0) {
  809. return -1
  810. }
  811. Xmemcpy(tls, s, var1, l1)
  812. *(*int8)(unsafe.Pointer(s + uintptr(l1))) = int8('=')
  813. Xmemcpy(tls, s+uintptr(l1)+uintptr(1), value, l2+uint64(1))
  814. return X__putenv(tls, s, l1, s)
  815. }
  816. func Xunsetenv(tls *TLS, name uintptr) int32 { /* unsetenv.c:9:5: */
  817. if __ccgo_strace {
  818. trc("tls=%v name=%v, (%v:)", tls, name, origin(2))
  819. }
  820. var l size_t = size_t((int64(X__strchrnul(tls, name, '=')) - int64(name)) / 1)
  821. if !(l != 0) || *(*int8)(unsafe.Pointer(name + uintptr(l))) != 0 {
  822. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22
  823. return -1
  824. }
  825. if Environ() != 0 {
  826. var e uintptr = Environ()
  827. var eo uintptr = e
  828. for ; *(*uintptr)(unsafe.Pointer(e)) != 0; e += 8 {
  829. //TODO if (!strncmp(name, *e, l) && l[*e] == '=')
  830. if !(Xstrncmp(tls, name, *(*uintptr)(unsafe.Pointer(e)), l) != 0) && int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(e)) + uintptr(l)))) == '=' {
  831. X__env_rm_add(tls, *(*uintptr)(unsafe.Pointer(e)), uintptr(0))
  832. } else if eo != e {
  833. *(*uintptr)(unsafe.Pointer(PostIncUintptr(&eo, 8))) = *(*uintptr)(unsafe.Pointer(e))
  834. } else {
  835. eo += 8
  836. }
  837. }
  838. if eo != e {
  839. *(*uintptr)(unsafe.Pointer(eo)) = uintptr(0)
  840. }
  841. }
  842. return 0
  843. }
  844. type uintptr_t = uint64 /* alltypes.h:55:24 */
  845. type int8_t = int8 /* alltypes.h:96:25 */
  846. type int16_t = int16 /* alltypes.h:101:25 */
  847. type int32_t = int32 /* alltypes.h:106:25 */
  848. type int64_t = int64 /* alltypes.h:111:25 */
  849. type intmax_t = int64 /* alltypes.h:116:25 */
  850. type uint8_t = uint8 /* alltypes.h:121:25 */
  851. type uint16_t = uint16 /* alltypes.h:126:25 */
  852. type uint32_t = uint32 /* alltypes.h:131:25 */
  853. type uint64_t = uint64 /* alltypes.h:136:25 */
  854. type uintmax_t = uint64 /* alltypes.h:146:25 */
  855. type int_fast8_t = int8_t /* stdint.h:22:16 */
  856. type int_fast64_t = int64_t /* stdint.h:23:17 */
  857. type int_least8_t = int8_t /* stdint.h:25:17 */
  858. type int_least16_t = int16_t /* stdint.h:26:17 */
  859. type int_least32_t = int32_t /* stdint.h:27:17 */
  860. type int_least64_t = int64_t /* stdint.h:28:17 */
  861. type uint_fast8_t = uint8_t /* stdint.h:30:17 */
  862. type uint_fast64_t = uint64_t /* stdint.h:31:18 */
  863. type uint_least8_t = uint8_t /* stdint.h:33:18 */
  864. type uint_least16_t = uint16_t /* stdint.h:34:18 */
  865. type uint_least32_t = uint32_t /* stdint.h:35:18 */
  866. type uint_least64_t = uint64_t /* stdint.h:36:18 */
  867. type int_fast16_t = int32_t /* stdint.h:1:17 */
  868. type int_fast32_t = int32_t /* stdint.h:2:17 */
  869. type uint_fast16_t = uint32_t /* stdint.h:3:18 */
  870. type uint_fast32_t = uint32_t /* stdint.h:4:18 */
  871. type _IO_FILE = struct {
  872. Fflags uint32
  873. F__ccgo_pad1 [4]byte
  874. Frpos uintptr
  875. Frend uintptr
  876. Fclose uintptr
  877. Fwend uintptr
  878. Fwpos uintptr
  879. Fmustbezero_1 uintptr
  880. Fwbase uintptr
  881. Fread uintptr
  882. Fwrite uintptr
  883. Fseek uintptr
  884. Fbuf uintptr
  885. Fbuf_size size_t
  886. Fprev uintptr
  887. Fnext uintptr
  888. Ffd int32
  889. Fpipe_pid int32
  890. Flockcount int64
  891. Fmode int32
  892. Flock int32
  893. Flbf int32
  894. F__ccgo_pad2 [4]byte
  895. Fcookie uintptr
  896. Foff off_t
  897. Fgetln_buf uintptr
  898. Fmustbezero_2 uintptr
  899. Fshend uintptr
  900. Fshlim off_t
  901. Fshcnt off_t
  902. Fprev_locked uintptr
  903. Fnext_locked uintptr
  904. Flocale uintptr
  905. } /* alltypes.h:320:9 */
  906. type FILE = _IO_FILE /* alltypes.h:320:25 */
  907. type va_list = uintptr /* alltypes.h:326:27 */
  908. type _G_fpos64_t = struct {
  909. F__ccgo_pad1 [0]uint64
  910. F__opaque [16]int8
  911. } /* stdio.h:54:9 */
  912. type fpos_t = _G_fpos64_t /* stdio.h:58:3 */
  913. type float_t = float32 /* alltypes.h:29:15 */
  914. type double_t = float64 /* alltypes.h:34:16 */
  915. func __FLOAT_BITS(tls *TLS, __f float32) uint32 { /* math.h:55:26: */
  916. bp := tls.Alloc(4)
  917. defer tls.Free(4)
  918. // var __u struct {F__f float32;} at bp, 4
  919. *(*float32)(unsafe.Pointer(bp)) = __f
  920. return *(*uint32)(unsafe.Pointer(bp))
  921. }
  922. func __DOUBLE_BITS(tls *TLS, __f float64) uint64 { /* math.h:61:36: */
  923. bp := tls.Alloc(8)
  924. defer tls.Free(8)
  925. // var __u struct {F__f float64;} at bp, 8
  926. *(*float64)(unsafe.Pointer(bp)) = __f
  927. return *(*uint64)(unsafe.Pointer(bp))
  928. }
  929. func __isspace(tls *TLS, _c int32) int32 { /* ctype.h:26:21: */
  930. return Bool32(_c == ' ' || uint32(_c)-uint32('\t') < uint32(5))
  931. }
  932. type syscall_arg_t = int64 /* syscall.h:22:14 */
  933. func scanexp(tls *TLS, f uintptr, pok int32) int64 { /* floatscan.c:37:18: */
  934. var c int32
  935. var x int32
  936. var y int64
  937. var neg int32 = 0
  938. c = func() int32 {
  939. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  940. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  941. }
  942. return X__shgetc(tls, f)
  943. }()
  944. if c == '+' || c == '-' {
  945. neg = Bool32(c == '-')
  946. c = func() int32 {
  947. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  948. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  949. }
  950. return X__shgetc(tls, f)
  951. }()
  952. if uint32(c-'0') >= 10 && pok != 0 {
  953. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  954. (*FILE)(unsafe.Pointer(f)).Frpos--
  955. } else {
  956. }
  957. }
  958. }
  959. if uint32(c-'0') >= 10 {
  960. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  961. (*FILE)(unsafe.Pointer(f)).Frpos--
  962. } else {
  963. }
  964. return -0x7fffffffffffffff - int64(1)
  965. }
  966. for x = 0; uint32(c-'0') < 10 && x < 0x7fffffff/10; c = func() int32 {
  967. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  968. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  969. }
  970. return X__shgetc(tls, f)
  971. }() {
  972. x = 10*x + c - '0'
  973. }
  974. for y = int64(x); uint32(c-'0') < 10 && y < 0x7fffffffffffffff/int64(100); c = func() int32 {
  975. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  976. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  977. }
  978. return X__shgetc(tls, f)
  979. }() {
  980. y = int64(10)*y + int64(c) - int64('0')
  981. }
  982. for ; uint32(c-'0') < 10; c = func() int32 {
  983. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  984. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  985. }
  986. return X__shgetc(tls, f)
  987. }() {
  988. }
  989. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  990. (*FILE)(unsafe.Pointer(f)).Frpos--
  991. } else {
  992. }
  993. if neg != 0 {
  994. return -y
  995. }
  996. return y
  997. }
  998. func decfloat(tls *TLS, f uintptr, c int32, bits int32, emin int32, sign int32, pok int32) float64 { /* floatscan.c:64:20: */
  999. bp := tls.Alloc(512)
  1000. defer tls.Free(512)
  1001. // var x [128]uint32_t at bp, 512
  1002. var i int32
  1003. var j int32
  1004. var k int32
  1005. var a int32
  1006. var z int32
  1007. var lrp int64 = int64(0)
  1008. var dc int64 = int64(0)
  1009. var e10 int64 = int64(0)
  1010. var lnz int32 = 0
  1011. var gotdig int32 = 0
  1012. var gotrad int32 = 0
  1013. var rp int32
  1014. var e2 int32
  1015. var emax int32 = -emin - bits + 3
  1016. var denormal int32 = 0
  1017. var y float64
  1018. var frac float64 = float64(0)
  1019. var bias float64 = float64(0)
  1020. j = 0
  1021. k = 0
  1022. // Don't let leading zeros consume buffer space
  1023. for ; c == '0'; c = func() int32 {
  1024. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1025. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1026. }
  1027. return X__shgetc(tls, f)
  1028. }() {
  1029. gotdig = 1
  1030. }
  1031. if c == '.' {
  1032. gotrad = 1
  1033. for c = func() int32 {
  1034. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1035. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1036. }
  1037. return X__shgetc(tls, f)
  1038. }(); c == '0'; c = func() int32 {
  1039. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1040. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1041. }
  1042. return X__shgetc(tls, f)
  1043. }() {
  1044. gotdig = 1
  1045. lrp--
  1046. }
  1047. }
  1048. *(*uint32_t)(unsafe.Pointer(bp)) = uint32_t(0)
  1049. for ; uint32(c-'0') < 10 || c == '.'; c = func() int32 {
  1050. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1051. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1052. }
  1053. return X__shgetc(tls, f)
  1054. }() {
  1055. if c == '.' {
  1056. if gotrad != 0 {
  1057. break
  1058. }
  1059. gotrad = 1
  1060. lrp = dc
  1061. } else if k < 128-3 {
  1062. dc++
  1063. if c != '0' {
  1064. lnz = int32(dc)
  1065. }
  1066. if j != 0 {
  1067. *(*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')
  1068. } else {
  1069. *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = uint32_t(c - '0')
  1070. }
  1071. if PreIncInt32(&j, 1) == 9 {
  1072. k++
  1073. j = 0
  1074. }
  1075. gotdig = 1
  1076. } else {
  1077. dc++
  1078. if c != '0' {
  1079. lnz = (128 - 4) * 9
  1080. *(*uint32_t)(unsafe.Pointer(bp + 124*4)) |= uint32_t(1)
  1081. }
  1082. }
  1083. }
  1084. if !(gotrad != 0) {
  1085. lrp = dc
  1086. }
  1087. if gotdig != 0 && c|32 == 'e' {
  1088. e10 = scanexp(tls, f, pok)
  1089. if e10 == -0x7fffffffffffffff-int64(1) {
  1090. if pok != 0 {
  1091. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1092. (*FILE)(unsafe.Pointer(f)).Frpos--
  1093. } else {
  1094. }
  1095. } else {
  1096. X__shlim(tls, f, int64(0))
  1097. return float64(0)
  1098. }
  1099. e10 = int64(0)
  1100. }
  1101. lrp = lrp + e10
  1102. } else if c >= 0 {
  1103. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1104. (*FILE)(unsafe.Pointer(f)).Frpos--
  1105. } else {
  1106. }
  1107. }
  1108. if !(gotdig != 0) {
  1109. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22
  1110. X__shlim(tls, f, int64(0))
  1111. return float64(0)
  1112. }
  1113. // Handle zero specially to avoid nasty special cases later
  1114. if !(int32(*(*uint32_t)(unsafe.Pointer(bp))) != 0) {
  1115. return float64(sign) * 0.0
  1116. }
  1117. // Optimize small integers (w/no exponent) and over/under-flow
  1118. if lrp == dc && dc < int64(10) && (bits > 30 || *(*uint32_t)(unsafe.Pointer(bp))>>bits == uint32_t(0)) {
  1119. return float64(sign) * float64(*(*uint32_t)(unsafe.Pointer(bp)))
  1120. }
  1121. if lrp > int64(-emin/2) {
  1122. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  1123. return float64(sign) * 1.79769313486231570815e+308 * 1.79769313486231570815e+308
  1124. }
  1125. if lrp < int64(emin-2*53) {
  1126. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  1127. return float64(sign) * 2.22507385850720138309e-308 * 2.22507385850720138309e-308
  1128. }
  1129. // Align incomplete final B1B digit
  1130. if j != 0 {
  1131. for ; j < 9; j++ {
  1132. *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) *= uint32_t(10)
  1133. }
  1134. k++
  1135. j = 0
  1136. }
  1137. a = 0
  1138. z = k
  1139. e2 = 0
  1140. rp = int32(lrp)
  1141. // Optimize small to mid-size integers (even in exp. notation)
  1142. if lnz < 9 && lnz <= rp && rp < 18 {
  1143. if rp == 9 {
  1144. return float64(sign) * float64(*(*uint32_t)(unsafe.Pointer(bp)))
  1145. }
  1146. if rp < 9 {
  1147. return float64(sign) * float64(*(*uint32_t)(unsafe.Pointer(bp))) / float64(_sp10s[8-rp])
  1148. }
  1149. var bitlim int32 = bits - 3*(rp-9)
  1150. if bitlim > 30 || *(*uint32_t)(unsafe.Pointer(bp))>>bitlim == uint32_t(0) {
  1151. return float64(sign) * float64(*(*uint32_t)(unsafe.Pointer(bp))) * float64(_sp10s[rp-10])
  1152. }
  1153. }
  1154. // Drop trailing zeros
  1155. for ; !(int32(*(*uint32_t)(unsafe.Pointer(bp + uintptr(z-1)*4))) != 0); z-- {
  1156. }
  1157. // Align radix point to B1B digit boundary
  1158. if rp%9 != 0 {
  1159. var rpm9 int32
  1160. if rp >= 0 {
  1161. rpm9 = rp % 9
  1162. } else {
  1163. rpm9 = rp%9 + 9
  1164. }
  1165. var p10 int32 = _sp10s[8-rpm9]
  1166. var carry uint32_t = uint32_t(0)
  1167. for k = a; k != z; k++ {
  1168. var tmp uint32_t = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) % uint32_t(p10)
  1169. *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))/uint32_t(p10) + carry
  1170. carry = uint32_t(1000000000/p10) * tmp
  1171. if k == a && !(int32(*(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))) != 0) {
  1172. a = (a + 1) & (128 - 1)
  1173. rp = rp - 9
  1174. }
  1175. }
  1176. if carry != 0 {
  1177. *(*uint32_t)(unsafe.Pointer(bp + uintptr(PostIncInt32(&z, 1))*4)) = carry
  1178. }
  1179. rp = rp + (9 - rpm9)
  1180. }
  1181. // Upscale until desired number of bits are left of radix point
  1182. for rp < 9*2 || rp == 9*2 && *(*uint32_t)(unsafe.Pointer(bp + uintptr(a)*4)) < _sth[0] {
  1183. var carry uint32_t = uint32_t(0)
  1184. e2 = e2 - 29
  1185. for k = (z - 1) & (128 - 1); ; k = (k - 1) & (128 - 1) {
  1186. var tmp uint64_t = uint64_t(*(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)))<<29 + uint64_t(carry)
  1187. if tmp > uint64(1000000000) {
  1188. carry = uint32_t(tmp / uint64(1000000000))
  1189. *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = uint32_t(tmp % uint64(1000000000))
  1190. } else {
  1191. carry = uint32_t(0)
  1192. *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = uint32_t(tmp)
  1193. }
  1194. if k == (z-1)&(128-1) && k != a && !(int32(*(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))) != 0) {
  1195. z = k
  1196. }
  1197. if k == a {
  1198. break
  1199. }
  1200. }
  1201. if carry != 0 {
  1202. rp = rp + 9
  1203. a = (a - 1) & (128 - 1)
  1204. if a == z {
  1205. z = (z - 1) & (128 - 1)
  1206. *(*uint32_t)(unsafe.Pointer(bp + uintptr((z-1)&(128-1))*4)) |= *(*uint32_t)(unsafe.Pointer(bp + uintptr(z)*4))
  1207. }
  1208. *(*uint32_t)(unsafe.Pointer(bp + uintptr(a)*4)) = carry
  1209. }
  1210. }
  1211. // Downscale until exactly number of bits are left of radix point
  1212. for {
  1213. var carry uint32_t = uint32_t(0)
  1214. var sh int32 = 1
  1215. for i = 0; i < 2; i++ {
  1216. k = (a + i) & (128 - 1)
  1217. if k == z || *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) < _sth[i] {
  1218. i = 2
  1219. break
  1220. }
  1221. if *(*uint32_t)(unsafe.Pointer(bp + uintptr((a+i)&(128-1))*4)) > _sth[i] {
  1222. break
  1223. }
  1224. }
  1225. if i == 2 && rp == 9*2 {
  1226. break
  1227. }
  1228. // FIXME: find a way to compute optimal sh
  1229. if rp > 9+9*2 {
  1230. sh = 9
  1231. }
  1232. e2 = e2 + sh
  1233. for k = a; k != z; k = (k + 1) & (128 - 1) {
  1234. var tmp uint32_t = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) & uint32_t(int32(1)<<sh-1)
  1235. *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4)) = *(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))>>sh + carry
  1236. carry = uint32_t(int32(1000000000)>>sh) * tmp
  1237. if k == a && !(int32(*(*uint32_t)(unsafe.Pointer(bp + uintptr(k)*4))) != 0) {
  1238. a = (a + 1) & (128 - 1)
  1239. i--
  1240. rp = rp - 9
  1241. }
  1242. }
  1243. if carry != 0 {
  1244. if (z+1)&(128-1) != a {
  1245. *(*uint32_t)(unsafe.Pointer(bp + uintptr(z)*4)) = carry
  1246. z = (z + 1) & (128 - 1)
  1247. } else {
  1248. *(*uint32_t)(unsafe.Pointer(bp + uintptr((z-1)&(128-1))*4)) |= uint32_t(1)
  1249. }
  1250. }
  1251. }
  1252. // Assemble desired bits into floating point variable
  1253. for y = float64(AssignInt32(&i, 0)); i < 2; i++ {
  1254. if (a+i)&(128-1) == z {
  1255. *(*uint32_t)(unsafe.Pointer(bp + uintptr(AssignInt32(&z, (z+1)&(128-1))-1)*4)) = uint32_t(0)
  1256. }
  1257. y = 1000000000.0*y + float64(*(*uint32_t)(unsafe.Pointer(bp + uintptr((a+i)&(128-1))*4)))
  1258. }
  1259. y = y * float64(sign)
  1260. // Limit precision for denormal results
  1261. if bits > 53+e2-emin {
  1262. bits = 53 + e2 - emin
  1263. if bits < 0 {
  1264. bits = 0
  1265. }
  1266. denormal = 1
  1267. }
  1268. // Calculate bias term to force rounding, move out lower bits
  1269. if bits < 53 {
  1270. bias = Xcopysignl(tls, Xscalbn(tls, float64(1), 2*53-bits-1), y)
  1271. frac = Xfmodl(tls, y, Xscalbn(tls, float64(1), 53-bits))
  1272. y = y - frac
  1273. y = y + bias
  1274. }
  1275. // Process tail of decimal input so it can affect rounding
  1276. if (a+i)&(128-1) != z {
  1277. var t uint32_t = *(*uint32_t)(unsafe.Pointer(bp + uintptr((a+i)&(128-1))*4))
  1278. if t < uint32_t(500000000) && (t != 0 || (a+i+1)&(128-1) != z) {
  1279. frac = frac + 0.25*float64(sign)
  1280. } else if t > uint32_t(500000000) {
  1281. frac = frac + 0.75*float64(sign)
  1282. } else if t == uint32_t(500000000) {
  1283. if (a+i+1)&(128-1) == z {
  1284. frac = frac + 0.5*float64(sign)
  1285. } else {
  1286. frac = frac + 0.75*float64(sign)
  1287. }
  1288. }
  1289. if 53-bits >= 2 && !(Xfmodl(tls, frac, float64(1)) != 0) {
  1290. frac += 1
  1291. }
  1292. }
  1293. y = y + frac
  1294. y = y - bias
  1295. if (e2+53)&0x7fffffff > emax-5 {
  1296. if Xfabsl(tls, y) >= float64(float64(2))/2.22044604925031308085e-16 {
  1297. if denormal != 0 && bits == 53+e2-emin {
  1298. denormal = 0
  1299. }
  1300. y = y * 0.5
  1301. e2++
  1302. }
  1303. if e2+53 > emax || denormal != 0 && frac != 0 {
  1304. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  1305. }
  1306. }
  1307. return Xscalbnl(tls, y, e2)
  1308. }
  1309. var _sth = [2]uint32_t{uint32_t(9007199), uint32_t(254740991)} /* floatscan.c:67:24 */
  1310. var _sp10s = [8]int32{10, 100, 1000, 10000,
  1311. 100000, 1000000, 10000000, 100000000} /* floatscan.c:80:19 */
  1312. func hexfloat(tls *TLS, f uintptr, bits int32, emin int32, sign int32, pok int32) float64 { /* floatscan.c:315:20: */
  1313. var x uint32_t = uint32_t(0)
  1314. var y float64 = float64(0)
  1315. var scale float64 = float64(1)
  1316. var bias float64 = float64(0)
  1317. var gottail int32 = 0
  1318. var gotrad int32 = 0
  1319. var gotdig int32 = 0
  1320. var rp int64 = int64(0)
  1321. var dc int64 = int64(0)
  1322. var e2 int64 = int64(0)
  1323. var d int32
  1324. var c int32
  1325. c = func() int32 {
  1326. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1327. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1328. }
  1329. return X__shgetc(tls, f)
  1330. }()
  1331. // Skip leading zeros
  1332. for ; c == '0'; c = func() int32 {
  1333. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1334. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1335. }
  1336. return X__shgetc(tls, f)
  1337. }() {
  1338. gotdig = 1
  1339. }
  1340. if c == '.' {
  1341. gotrad = 1
  1342. c = func() int32 {
  1343. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1344. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1345. }
  1346. return X__shgetc(tls, f)
  1347. }()
  1348. // Count zeros after the radix point before significand
  1349. rp = int64(0)
  1350. __1:
  1351. if !(c == '0') {
  1352. goto __3
  1353. }
  1354. gotdig = 1
  1355. goto __2
  1356. __2:
  1357. c = func() int32 {
  1358. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1359. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1360. }
  1361. return X__shgetc(tls, f)
  1362. }()
  1363. rp--
  1364. goto __1
  1365. goto __3
  1366. __3:
  1367. }
  1368. for ; uint32(c-'0') < 10 || uint32(c|32-'a') < 6 || c == '.'; c = func() int32 {
  1369. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1370. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1371. }
  1372. return X__shgetc(tls, f)
  1373. }() {
  1374. if c == '.' {
  1375. if gotrad != 0 {
  1376. break
  1377. }
  1378. rp = dc
  1379. gotrad = 1
  1380. } else {
  1381. gotdig = 1
  1382. if c > '9' {
  1383. d = c | 32 + 10 - 'a'
  1384. } else {
  1385. d = c - '0'
  1386. }
  1387. if dc < int64(8) {
  1388. x = x*uint32_t(16) + uint32_t(d)
  1389. } else if dc < int64(53/4+1) {
  1390. y = y + float64(d)*AssignDivFloat64(&scale, float64(16))
  1391. } else if d != 0 && !(gottail != 0) {
  1392. y = y + 0.5*scale
  1393. gottail = 1
  1394. }
  1395. dc++
  1396. }
  1397. }
  1398. if !(gotdig != 0) {
  1399. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1400. (*FILE)(unsafe.Pointer(f)).Frpos--
  1401. } else {
  1402. }
  1403. if pok != 0 {
  1404. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1405. (*FILE)(unsafe.Pointer(f)).Frpos--
  1406. } else {
  1407. }
  1408. if gotrad != 0 {
  1409. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1410. (*FILE)(unsafe.Pointer(f)).Frpos--
  1411. } else {
  1412. }
  1413. }
  1414. } else {
  1415. X__shlim(tls, f, int64(0))
  1416. }
  1417. return float64(sign) * 0.0
  1418. }
  1419. if !(gotrad != 0) {
  1420. rp = dc
  1421. }
  1422. for dc < int64(8) {
  1423. x = x * uint32_t(16)
  1424. dc++
  1425. }
  1426. if c|32 == 'p' {
  1427. e2 = scanexp(tls, f, pok)
  1428. if e2 == -0x7fffffffffffffff-int64(1) {
  1429. if pok != 0 {
  1430. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1431. (*FILE)(unsafe.Pointer(f)).Frpos--
  1432. } else {
  1433. }
  1434. } else {
  1435. X__shlim(tls, f, int64(0))
  1436. return float64(0)
  1437. }
  1438. e2 = int64(0)
  1439. }
  1440. } else {
  1441. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1442. (*FILE)(unsafe.Pointer(f)).Frpos--
  1443. } else {
  1444. }
  1445. }
  1446. e2 = e2 + (int64(4)*rp - int64(32))
  1447. if !(x != 0) {
  1448. return float64(sign) * 0.0
  1449. }
  1450. if e2 > int64(-emin) {
  1451. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  1452. return float64(sign) * 1.79769313486231570815e+308 * 1.79769313486231570815e+308
  1453. }
  1454. if e2 < int64(emin-2*53) {
  1455. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  1456. return float64(sign) * 2.22507385850720138309e-308 * 2.22507385850720138309e-308
  1457. }
  1458. for x < 0x80000000 {
  1459. if y >= 0.5 {
  1460. x = x + (x + uint32_t(1))
  1461. y = y + (y - float64(1))
  1462. } else {
  1463. x = x + x
  1464. y = y + y
  1465. }
  1466. e2--
  1467. }
  1468. if int64(bits) > int64(32)+e2-int64(emin) {
  1469. bits = int32(int64(32) + e2 - int64(emin))
  1470. if bits < 0 {
  1471. bits = 0
  1472. }
  1473. }
  1474. if bits < 53 {
  1475. bias = Xcopysignl(tls, Xscalbn(tls, float64(1), 32+53-bits-1), float64(sign))
  1476. }
  1477. if bits < 32 && y != 0 && !(x&uint32_t(1) != 0) {
  1478. x++
  1479. y = float64(0)
  1480. }
  1481. y = bias + float64(sign)*float64(x) + float64(sign)*y
  1482. y = y - bias
  1483. if !(y != 0) {
  1484. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  1485. }
  1486. return Xscalbnl(tls, y, int32(e2))
  1487. }
  1488. func X__floatscan(tls *TLS, f uintptr, prec int32, pok int32) float64 { /* floatscan.c:427:13: */
  1489. if __ccgo_strace {
  1490. trc("tls=%v f=%v prec=%v pok=%v, (%v:)", tls, f, prec, pok, origin(2))
  1491. }
  1492. var sign int32 = 1
  1493. var i size_t
  1494. var bits int32
  1495. var emin int32
  1496. var c int32
  1497. switch prec {
  1498. case 0:
  1499. bits = 24
  1500. emin = -125 - bits
  1501. break
  1502. case 1:
  1503. bits = 53
  1504. emin = -1021 - bits
  1505. break
  1506. case 2:
  1507. bits = 53
  1508. emin = -1021 - bits
  1509. break
  1510. default:
  1511. return float64(0)
  1512. }
  1513. for __isspace(tls, AssignInt32(&c, func() int32 {
  1514. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1515. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1516. }
  1517. return X__shgetc(tls, f)
  1518. }())) != 0 {
  1519. }
  1520. if c == '+' || c == '-' {
  1521. sign = sign - 2*Bool32(c == '-')
  1522. c = func() int32 {
  1523. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1524. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1525. }
  1526. return X__shgetc(tls, f)
  1527. }()
  1528. }
  1529. for i = uint64(0); i < uint64(8) && c|32 == int32(*(*int8)(unsafe.Pointer(ts /* "infinity" */ + uintptr(i)))); i++ {
  1530. if i < uint64(7) {
  1531. c = func() int32 {
  1532. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1533. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1534. }
  1535. return X__shgetc(tls, f)
  1536. }()
  1537. }
  1538. }
  1539. if i == uint64(3) || i == uint64(8) || i > uint64(3) && pok != 0 {
  1540. if i != uint64(8) {
  1541. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1542. (*FILE)(unsafe.Pointer(f)).Frpos--
  1543. } else {
  1544. }
  1545. if pok != 0 {
  1546. for ; i > uint64(3); i-- {
  1547. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1548. (*FILE)(unsafe.Pointer(f)).Frpos--
  1549. } else {
  1550. }
  1551. }
  1552. }
  1553. }
  1554. return float64(float32(sign) * X__builtin_inff(tls))
  1555. }
  1556. if !(i != 0) {
  1557. for i = uint64(0); i < uint64(3) && c|32 == int32(*(*int8)(unsafe.Pointer(ts + 9 /* "nan" */ + uintptr(i)))); i++ {
  1558. if i < uint64(2) {
  1559. c = func() int32 {
  1560. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1561. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1562. }
  1563. return X__shgetc(tls, f)
  1564. }()
  1565. }
  1566. }
  1567. }
  1568. if i == uint64(3) {
  1569. if func() int32 {
  1570. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1571. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1572. }
  1573. return X__shgetc(tls, f)
  1574. }() != '(' {
  1575. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1576. (*FILE)(unsafe.Pointer(f)).Frpos--
  1577. } else {
  1578. }
  1579. return float64(X__builtin_nanf(tls, ts+13))
  1580. }
  1581. for i = uint64(1); ; i++ {
  1582. c = func() int32 {
  1583. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1584. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1585. }
  1586. return X__shgetc(tls, f)
  1587. }()
  1588. if uint32(c-'0') < 10 || uint32(c-'A') < 26 || uint32(c-'a') < 26 || c == '_' {
  1589. continue
  1590. }
  1591. if c == ')' {
  1592. return float64(X__builtin_nanf(tls, ts+13))
  1593. }
  1594. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1595. (*FILE)(unsafe.Pointer(f)).Frpos--
  1596. } else {
  1597. }
  1598. if !(pok != 0) {
  1599. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22
  1600. X__shlim(tls, f, int64(0))
  1601. return float64(0)
  1602. }
  1603. for PostDecUint64(&i, 1) != 0 {
  1604. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1605. (*FILE)(unsafe.Pointer(f)).Frpos--
  1606. } else {
  1607. }
  1608. }
  1609. return float64(X__builtin_nanf(tls, ts+13))
  1610. }
  1611. return float64(X__builtin_nanf(tls, ts+13))
  1612. }
  1613. if i != 0 {
  1614. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1615. (*FILE)(unsafe.Pointer(f)).Frpos--
  1616. } else {
  1617. }
  1618. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22
  1619. X__shlim(tls, f, int64(0))
  1620. return float64(0)
  1621. }
  1622. if c == '0' {
  1623. c = func() int32 {
  1624. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1625. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1626. }
  1627. return X__shgetc(tls, f)
  1628. }()
  1629. if c|32 == 'x' {
  1630. return hexfloat(tls, f, bits, emin, sign, pok)
  1631. }
  1632. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1633. (*FILE)(unsafe.Pointer(f)).Frpos--
  1634. } else {
  1635. }
  1636. c = '0'
  1637. }
  1638. return decfloat(tls, f, c, bits, emin, sign, pok)
  1639. }
  1640. // Lookup table for digit values. -1==255>=36 -> invalid
  1641. var table = [257]uint8{Uint8FromInt32(-1),
  1642. 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),
  1643. 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),
  1644. 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),
  1645. 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),
  1646. 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),
  1647. 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),
  1648. 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),
  1649. 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),
  1650. 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),
  1651. 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),
  1652. 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),
  1653. 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),
  1654. 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),
  1655. 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),
  1656. 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),
  1657. 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),
  1658. } /* intscan.c:7:28 */
  1659. func X__intscan(tls *TLS, f uintptr, base uint32, pok int32, lim uint64) uint64 { /* intscan.c:26:20: */
  1660. if __ccgo_strace {
  1661. trc("tls=%v f=%v base=%v pok=%v lim=%v, (%v:)", tls, f, base, pok, lim, origin(2))
  1662. }
  1663. var val uintptr
  1664. var c int32
  1665. var neg int32
  1666. var x uint32
  1667. var y uint64
  1668. var bs int32
  1669. val = uintptr(unsafe.Pointer(&table)) + uintptr(1)
  1670. neg = 0
  1671. if !(base > uint32(36) || base == uint32(1)) {
  1672. goto __1
  1673. }
  1674. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22
  1675. return uint64(0)
  1676. __1:
  1677. ;
  1678. __2:
  1679. if !(__isspace(tls, AssignInt32(&c, func() int32 {
  1680. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1681. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1682. }
  1683. return X__shgetc(tls, f)
  1684. }())) != 0) {
  1685. goto __3
  1686. }
  1687. goto __2
  1688. __3:
  1689. ;
  1690. if !(c == '+' || c == '-') {
  1691. goto __4
  1692. }
  1693. neg = -Bool32(c == '-')
  1694. c = func() int32 {
  1695. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1696. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1697. }
  1698. return X__shgetc(tls, f)
  1699. }()
  1700. __4:
  1701. ;
  1702. if !((base == uint32(0) || base == uint32(16)) && c == '0') {
  1703. goto __5
  1704. }
  1705. c = func() int32 {
  1706. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1707. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1708. }
  1709. return X__shgetc(tls, f)
  1710. }()
  1711. if !(c|32 == 'x') {
  1712. goto __7
  1713. }
  1714. c = func() int32 {
  1715. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1716. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1717. }
  1718. return X__shgetc(tls, f)
  1719. }()
  1720. if !(int32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) >= 16) {
  1721. goto __9
  1722. }
  1723. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1724. (*FILE)(unsafe.Pointer(f)).Frpos--
  1725. } else {
  1726. }
  1727. if !(pok != 0) {
  1728. goto __10
  1729. }
  1730. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1731. (*FILE)(unsafe.Pointer(f)).Frpos--
  1732. } else {
  1733. }
  1734. goto __11
  1735. __10:
  1736. X__shlim(tls, f, int64(0))
  1737. __11:
  1738. ;
  1739. return uint64(0)
  1740. __9:
  1741. ;
  1742. base = uint32(16)
  1743. goto __8
  1744. __7:
  1745. if !(base == uint32(0)) {
  1746. goto __12
  1747. }
  1748. base = uint32(8)
  1749. __12:
  1750. ;
  1751. __8:
  1752. ;
  1753. goto __6
  1754. __5:
  1755. if !(base == uint32(0)) {
  1756. goto __13
  1757. }
  1758. base = uint32(10)
  1759. __13:
  1760. ;
  1761. if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) >= base) {
  1762. goto __14
  1763. }
  1764. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1765. (*FILE)(unsafe.Pointer(f)).Frpos--
  1766. } else {
  1767. }
  1768. X__shlim(tls, f, int64(0))
  1769. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22
  1770. return uint64(0)
  1771. __14:
  1772. ;
  1773. __6:
  1774. ;
  1775. if !(base == uint32(10)) {
  1776. goto __15
  1777. }
  1778. x = uint32(0)
  1779. __17:
  1780. if !(uint32(c-'0') < 10 && x <= 0xffffffff/uint32(10)-uint32(1)) {
  1781. goto __19
  1782. }
  1783. x = x*uint32(10) + uint32(c-'0')
  1784. goto __18
  1785. __18:
  1786. c = func() int32 {
  1787. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1788. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1789. }
  1790. return X__shgetc(tls, f)
  1791. }()
  1792. goto __17
  1793. goto __19
  1794. __19:
  1795. ;
  1796. y = uint64(x)
  1797. __20:
  1798. if !(uint32(c-'0') < 10 && y <= (2*uint64(0x7fffffffffffffff)+uint64(1))/uint64(10) && uint64(10)*y <= 2*uint64(0x7fffffffffffffff)+uint64(1)-uint64(c-'0')) {
  1799. goto __22
  1800. }
  1801. y = y*uint64(10) + uint64(c-'0')
  1802. goto __21
  1803. __21:
  1804. c = func() int32 {
  1805. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1806. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1807. }
  1808. return X__shgetc(tls, f)
  1809. }()
  1810. goto __20
  1811. goto __22
  1812. __22:
  1813. ;
  1814. if !(uint32(c-'0') >= 10) {
  1815. goto __23
  1816. }
  1817. goto done
  1818. __23:
  1819. ;
  1820. goto __16
  1821. __15:
  1822. if !!(base&(base-uint32(1)) != 0) {
  1823. goto __24
  1824. }
  1825. bs = int32(*(*int8)(unsafe.Pointer(ts + 14 + uintptr(uint32(0x17)*base>>5&uint32(7)))))
  1826. x = uint32(0)
  1827. __26:
  1828. if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) < base && x <= 0xffffffff/uint32(32)) {
  1829. goto __28
  1830. }
  1831. x = x<<bs | uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c))))
  1832. goto __27
  1833. __27:
  1834. c = func() int32 {
  1835. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1836. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1837. }
  1838. return X__shgetc(tls, f)
  1839. }()
  1840. goto __26
  1841. goto __28
  1842. __28:
  1843. ;
  1844. y = uint64(x)
  1845. __29:
  1846. if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) < base && y <= uint64(2*uint64(0x7fffffffffffffff)+uint64(1))>>bs) {
  1847. goto __31
  1848. }
  1849. y = y<<bs | uint64(*(*uint8)(unsafe.Pointer(val + uintptr(c))))
  1850. goto __30
  1851. __30:
  1852. c = func() int32 {
  1853. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1854. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1855. }
  1856. return X__shgetc(tls, f)
  1857. }()
  1858. goto __29
  1859. goto __31
  1860. __31:
  1861. ;
  1862. goto __25
  1863. __24:
  1864. x = uint32(0)
  1865. __32:
  1866. if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) < base && x <= 0xffffffff/uint32(36)-uint32(1)) {
  1867. goto __34
  1868. }
  1869. x = x*base + uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c))))
  1870. goto __33
  1871. __33:
  1872. c = func() int32 {
  1873. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1874. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1875. }
  1876. return X__shgetc(tls, f)
  1877. }()
  1878. goto __32
  1879. goto __34
  1880. __34:
  1881. ;
  1882. y = uint64(x)
  1883. __35:
  1884. 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))))) {
  1885. goto __37
  1886. }
  1887. y = y*uint64(base) + uint64(*(*uint8)(unsafe.Pointer(val + uintptr(c))))
  1888. goto __36
  1889. __36:
  1890. c = func() int32 {
  1891. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1892. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1893. }
  1894. return X__shgetc(tls, f)
  1895. }()
  1896. goto __35
  1897. goto __37
  1898. __37:
  1899. ;
  1900. __25:
  1901. ;
  1902. __16:
  1903. ;
  1904. if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) < base) {
  1905. goto __38
  1906. }
  1907. __39:
  1908. if !(uint32(*(*uint8)(unsafe.Pointer(val + uintptr(c)))) < base) {
  1909. goto __41
  1910. }
  1911. goto __40
  1912. __40:
  1913. c = func() int32 {
  1914. if (*FILE)(unsafe.Pointer(f)).Frpos != (*FILE)(unsafe.Pointer(f)).Fshend {
  1915. return int32(*(*uint8)(unsafe.Pointer(PostIncUintptr(&(*FILE)(unsafe.Pointer(f)).Frpos, 1))))
  1916. }
  1917. return X__shgetc(tls, f)
  1918. }()
  1919. goto __39
  1920. goto __41
  1921. __41:
  1922. ;
  1923. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  1924. y = lim
  1925. if !(lim&uint64(1) != 0) {
  1926. goto __42
  1927. }
  1928. neg = 0
  1929. __42:
  1930. ;
  1931. __38:
  1932. ;
  1933. done:
  1934. if (*FILE)(unsafe.Pointer(f)).Fshlim >= int64(0) {
  1935. (*FILE)(unsafe.Pointer(f)).Frpos--
  1936. } else {
  1937. }
  1938. if !(y >= lim) {
  1939. goto __43
  1940. }
  1941. if !(!(lim&uint64(1) != 0) && !(neg != 0)) {
  1942. goto __44
  1943. }
  1944. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  1945. return lim - uint64(1)
  1946. goto __45
  1947. __44:
  1948. if !(y > lim) {
  1949. goto __46
  1950. }
  1951. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 34
  1952. return lim
  1953. __46:
  1954. ;
  1955. __45:
  1956. ;
  1957. __43:
  1958. ;
  1959. return y ^ uint64(neg) - uint64(neg)
  1960. }
  1961. // The shcnt field stores the number of bytes read so far, offset by
  1962. // the value of buf-rpos at the last function call (__shlim or __shgetc),
  1963. // so that between calls the inline shcnt macro can add rpos-buf to get
  1964. // the actual count.
  1965. func X__shlim(tls *TLS, f uintptr, lim off_t) { /* shgetc.c:8:6: */
  1966. if __ccgo_strace {
  1967. trc("tls=%v f=%v lim=%v, (%v:)", tls, f, lim, origin(2))
  1968. }
  1969. (*FILE)(unsafe.Pointer(f)).Fshlim = lim
  1970. (*FILE)(unsafe.Pointer(f)).Fshcnt = (int64((*FILE)(unsafe.Pointer(f)).Fbuf) - int64((*FILE)(unsafe.Pointer(f)).Frpos)) / 1
  1971. // If lim is nonzero, rend must be a valid pointer.
  1972. if lim != 0 && (int64((*FILE)(unsafe.Pointer(f)).Frend)-int64((*FILE)(unsafe.Pointer(f)).Frpos))/1 > lim {
  1973. (*FILE)(unsafe.Pointer(f)).Fshend = (*FILE)(unsafe.Pointer(f)).Frpos + uintptr(lim)
  1974. } else {
  1975. (*FILE)(unsafe.Pointer(f)).Fshend = (*FILE)(unsafe.Pointer(f)).Frend
  1976. }
  1977. }
  1978. func X__shgetc(tls *TLS, f uintptr) int32 { /* shgetc.c:19:5: */
  1979. if __ccgo_strace {
  1980. trc("tls=%v f=%v, (%v:)", tls, f, origin(2))
  1981. }
  1982. var c int32
  1983. var cnt off_t = (*FILE)(unsafe.Pointer(f)).Fshcnt + (int64((*FILE)(unsafe.Pointer(f)).Frpos)-int64((*FILE)(unsafe.Pointer(f)).Fbuf))/1
  1984. if (*FILE)(unsafe.Pointer(f)).Fshlim != 0 && cnt >= (*FILE)(unsafe.Pointer(f)).Fshlim || AssignInt32(&c, X__uflow(tls, f)) < 0 {
  1985. (*FILE)(unsafe.Pointer(f)).Fshcnt = (int64((*FILE)(unsafe.Pointer(f)).Fbuf)-int64((*FILE)(unsafe.Pointer(f)).Frpos))/1 + cnt
  1986. (*FILE)(unsafe.Pointer(f)).Fshend = (*FILE)(unsafe.Pointer(f)).Frpos
  1987. (*FILE)(unsafe.Pointer(f)).Fshlim = int64(-1)
  1988. return -1
  1989. }
  1990. cnt++
  1991. if (*FILE)(unsafe.Pointer(f)).Fshlim != 0 && (int64((*FILE)(unsafe.Pointer(f)).Frend)-int64((*FILE)(unsafe.Pointer(f)).Frpos))/1 > (*FILE)(unsafe.Pointer(f)).Fshlim-cnt {
  1992. (*FILE)(unsafe.Pointer(f)).Fshend = (*FILE)(unsafe.Pointer(f)).Frpos + uintptr((*FILE)(unsafe.Pointer(f)).Fshlim-cnt)
  1993. } else {
  1994. (*FILE)(unsafe.Pointer(f)).Fshend = (*FILE)(unsafe.Pointer(f)).Frend
  1995. }
  1996. (*FILE)(unsafe.Pointer(f)).Fshcnt = (int64((*FILE)(unsafe.Pointer(f)).Fbuf)-int64((*FILE)(unsafe.Pointer(f)).Frpos))/1 + cnt
  1997. if (*FILE)(unsafe.Pointer(f)).Frpos <= (*FILE)(unsafe.Pointer(f)).Fbuf {
  1998. *(*uint8)(unsafe.Pointer((*FILE)(unsafe.Pointer(f)).Frpos + UintptrFromInt32(-1))) = uint8(c)
  1999. }
  2000. return c
  2001. }
  2002. type lconv = struct {
  2003. Fdecimal_point uintptr
  2004. Fthousands_sep uintptr
  2005. Fgrouping uintptr
  2006. Fint_curr_symbol uintptr
  2007. Fcurrency_symbol uintptr
  2008. Fmon_decimal_point uintptr
  2009. Fmon_thousands_sep uintptr
  2010. Fmon_grouping uintptr
  2011. Fpositive_sign uintptr
  2012. Fnegative_sign uintptr
  2013. Fint_frac_digits int8
  2014. Ffrac_digits int8
  2015. Fp_cs_precedes int8
  2016. Fp_sep_by_space int8
  2017. Fn_cs_precedes int8
  2018. Fn_sep_by_space int8
  2019. Fp_sign_posn int8
  2020. Fn_sign_posn int8
  2021. Fint_p_cs_precedes int8
  2022. Fint_p_sep_by_space int8
  2023. Fint_n_cs_precedes int8
  2024. Fint_n_sep_by_space int8
  2025. Fint_p_sign_posn int8
  2026. Fint_n_sign_posn int8
  2027. F__ccgo_pad1 [2]byte
  2028. } /* locale.h:24:1 */
  2029. // Support signed or unsigned plain-char
  2030. // Implementation choices...
  2031. // Arbitrary numbers...
  2032. // POSIX/SUS requirements follow. These numbers come directly
  2033. // from SUS and have nothing to do with the host system.
  2034. var posix_lconv = lconv{Fdecimal_point: ts + 23, Fthousands_sep: ts + 13, Fgrouping: ts + 13, Fint_curr_symbol: ts + 13, Fcurrency_symbol: ts + 13, Fmon_decimal_point: ts + 13, Fmon_thousands_sep: ts + 13, Fmon_grouping: ts + 13, Fpositive_sign: ts + 13, Fnegative_sign: ts + 13, Fint_frac_digits: Int8FromInt32(255), Ffrac_digits: Int8FromInt32(255), Fp_cs_precedes: Int8FromInt32(255), Fp_sep_by_space: Int8FromInt32(255), Fn_cs_precedes: Int8FromInt32(255), Fn_sep_by_space: Int8FromInt32(255), Fp_sign_posn: Int8FromInt32(255), Fn_sign_posn: Int8FromInt32(255), Fint_p_cs_precedes: Int8FromInt32(255), Fint_p_sep_by_space: Int8FromInt32(255), Fint_n_cs_precedes: Int8FromInt32(255), Fint_n_sep_by_space: Int8FromInt32(255), Fint_p_sign_posn: Int8FromInt32(255), Fint_n_sign_posn: Int8FromInt32(255)} /* localeconv.c:4:27 */
  2035. func Xlocaleconv(tls *TLS) uintptr { /* localeconv.c:31:14: */
  2036. if __ccgo_strace {
  2037. trc("tls=%v, (%v:)", tls, origin(2))
  2038. }
  2039. return uintptr(unsafe.Pointer(&posix_lconv))
  2040. }
  2041. func X__fpclassify(tls *TLS, x float64) int32 { /* __fpclassify.c:4:5: */
  2042. if __ccgo_strace {
  2043. trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
  2044. }
  2045. bp := tls.Alloc(8)
  2046. defer tls.Free(8)
  2047. *(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) {
  2048. *(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
  2049. return r
  2050. }()
  2051. var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
  2052. if !(e != 0) {
  2053. if *(*uint64_t)(unsafe.Pointer(bp))<<1 != 0 {
  2054. return 3
  2055. }
  2056. return 2
  2057. }
  2058. if e == 0x7ff {
  2059. if *(*uint64_t)(unsafe.Pointer(bp))<<12 != 0 {
  2060. return 0
  2061. }
  2062. return 1
  2063. }
  2064. return 4
  2065. }
  2066. func X__fpclassifyf(tls *TLS, x float32) int32 { /* __fpclassifyf.c:4:5: */
  2067. if __ccgo_strace {
  2068. trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
  2069. }
  2070. bp := tls.Alloc(4)
  2071. defer tls.Free(4)
  2072. *(*struct{ Ff float32 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float32 }) {
  2073. *(*float32)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
  2074. return r
  2075. }()
  2076. var e int32 = int32(*(*uint32_t)(unsafe.Pointer(bp)) >> 23 & uint32_t(0xff))
  2077. if !(e != 0) {
  2078. if *(*uint32_t)(unsafe.Pointer(bp))<<1 != 0 {
  2079. return 3
  2080. }
  2081. return 2
  2082. }
  2083. if e == 0xff {
  2084. if *(*uint32_t)(unsafe.Pointer(bp))<<9 != 0 {
  2085. return 0
  2086. }
  2087. return 1
  2088. }
  2089. return 4
  2090. }
  2091. func __bswap32(tls *TLS, __x uint32_t) uint32_t { /* endian.h:24:26: */
  2092. return __x>>24 | __x>>8&uint32_t(0xff00) | __x<<8&uint32_t(0xff0000) | __x<<24
  2093. }
  2094. func X__fpclassifyl(tls *TLS, x float64) int32 { /* __fpclassifyl.c:4:5: */
  2095. if __ccgo_strace {
  2096. trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
  2097. }
  2098. return X__fpclassify(tls, x)
  2099. }
  2100. func Xcopysignl(tls *TLS, x float64, y float64) float64 { /* copysignl.c:4:13: */
  2101. if __ccgo_strace {
  2102. trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2))
  2103. }
  2104. return Xcopysign(tls, x, y)
  2105. }
  2106. func Xfabsl(tls *TLS, x float64) float64 { /* fabsl.c:3:13: */
  2107. if __ccgo_strace {
  2108. trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
  2109. }
  2110. return Xfabs(tls, x)
  2111. }
  2112. func Xfmodl(tls *TLS, x float64, y float64) float64 { /* fmodl.c:4:13: */
  2113. if __ccgo_strace {
  2114. trc("tls=%v x=%v y=%v, (%v:)", tls, x, y, origin(2))
  2115. }
  2116. return Xfmod(tls, x, y)
  2117. }
  2118. func Xnanf(tls *TLS, s uintptr) float32 { /* nanf.c:3:7: */
  2119. if __ccgo_strace {
  2120. trc("tls=%v s=%v, (%v:)", tls, s, origin(2))
  2121. }
  2122. return X__builtin_nanf(tls, ts+13)
  2123. }
  2124. var toint double_t = float64(float64(1)) / 2.22044604925031308085e-16 /* rint.c:10:23 */
  2125. func Xrint(tls *TLS, x float64) float64 { /* rint.c:12:8: */
  2126. if __ccgo_strace {
  2127. trc("tls=%v x=%v, (%v:)", tls, x, origin(2))
  2128. }
  2129. bp := tls.Alloc(8)
  2130. defer tls.Free(8)
  2131. *(*struct{ Ff float64 })(unsafe.Pointer(bp)) = func() (r struct{ Ff float64 }) {
  2132. *(*float64)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = x
  2133. return r
  2134. }()
  2135. var e int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 52 & uint64(0x7ff))
  2136. var s int32 = int32(*(*uint64_t)(unsafe.Pointer(bp)) >> 63)
  2137. var y double_t
  2138. if e >= 0x3ff+52 {
  2139. return x
  2140. }
  2141. if s != 0 {
  2142. y = x - toint + toint
  2143. } else {
  2144. y = x + toint - toint
  2145. }
  2146. if y == float64(0) {
  2147. if s != 0 {
  2148. return -Float64FromFloat64(0.0)
  2149. }
  2150. return float64(0)
  2151. }
  2152. return y
  2153. }
  2154. func Xscalbn(tls *TLS, x float64, n int32) float64 { /* scalbn.c:4:8: */
  2155. if __ccgo_strace {
  2156. trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
  2157. }
  2158. bp := tls.Alloc(8)
  2159. defer tls.Free(8)
  2160. // var u struct {Ff float64;} at bp, 8
  2161. var y double_t = x
  2162. if n > 1023 {
  2163. y = y * 0x1p1023
  2164. n = n - 1023
  2165. if n > 1023 {
  2166. y = y * 0x1p1023
  2167. n = n - 1023
  2168. if n > 1023 {
  2169. n = 1023
  2170. }
  2171. }
  2172. } else if n < -1022 {
  2173. // make sure final n < -53 to avoid double
  2174. // rounding in the subnormal range
  2175. y = y * (float64(0x1p-1022) * 0x1p53)
  2176. n = n + (1022 - 53)
  2177. if n < -1022 {
  2178. y = y * (float64(0x1p-1022) * 0x1p53)
  2179. n = n + (1022 - 53)
  2180. if n < -1022 {
  2181. n = -1022
  2182. }
  2183. }
  2184. }
  2185. *(*uint64_t)(unsafe.Pointer(bp)) = uint64_t(0x3ff+n) << 52
  2186. x = y * *(*float64)(unsafe.Pointer(bp))
  2187. return x
  2188. }
  2189. func Xscalbnl(tls *TLS, x float64, n int32) float64 { /* scalbnl.c:4:13: */
  2190. if __ccgo_strace {
  2191. trc("tls=%v x=%v n=%v, (%v:)", tls, x, n, origin(2))
  2192. }
  2193. return Xscalbn(tls, x, n)
  2194. }
  2195. type max_align_t = struct {
  2196. F__ll int64
  2197. F__ld float64
  2198. } /* alltypes.h:41:54 */
  2199. type imaxdiv_t = struct {
  2200. Fquot intmax_t
  2201. Frem intmax_t
  2202. } /* inttypes.h:14:40 */
  2203. type iovec = struct {
  2204. Fiov_base uintptr
  2205. Fiov_len size_t
  2206. } /* alltypes.h:355:1 */
  2207. type socklen_t = uint32 /* alltypes.h:361:18 */
  2208. type sa_family_t = uint16 /* alltypes.h:366:24 */
  2209. type msghdr = struct {
  2210. Fmsg_name uintptr
  2211. Fmsg_namelen socklen_t
  2212. F__ccgo_pad1 [4]byte
  2213. Fmsg_iov uintptr
  2214. Fmsg_iovlen int32
  2215. F__pad1 int32
  2216. Fmsg_control uintptr
  2217. Fmsg_controllen socklen_t
  2218. F__pad2 int32
  2219. Fmsg_flags int32
  2220. F__ccgo_pad2 [4]byte
  2221. } /* socket.h:22:1 */
  2222. type cmsghdr = struct {
  2223. Fcmsg_len socklen_t
  2224. F__pad1 int32
  2225. Fcmsg_level int32
  2226. Fcmsg_type int32
  2227. } /* socket.h:44:1 */
  2228. type linger = struct {
  2229. Fl_onoff int32
  2230. Fl_linger int32
  2231. } /* socket.h:74:1 */
  2232. type sockaddr = struct {
  2233. Fsa_family sa_family_t
  2234. Fsa_data [14]int8
  2235. } /* socket.h:367:1 */
  2236. type sockaddr_storage = struct {
  2237. Fss_family sa_family_t
  2238. F__ss_padding [118]int8
  2239. F__ss_align uint64
  2240. } /* socket.h:372:1 */
  2241. type in_port_t = uint16_t /* in.h:12:18 */
  2242. type in_addr_t = uint32_t /* in.h:13:18 */
  2243. type in_addr = struct{ Fs_addr in_addr_t } /* in.h:14:1 */
  2244. type sockaddr_in = struct {
  2245. Fsin_family sa_family_t
  2246. Fsin_port in_port_t
  2247. Fsin_addr struct{ Fs_addr in_addr_t }
  2248. Fsin_zero [8]uint8_t
  2249. } /* in.h:16:1 */
  2250. type in6_addr = struct {
  2251. F__in6_union struct {
  2252. F__ccgo_pad1 [0]uint32
  2253. F__s6_addr [16]uint8_t
  2254. }
  2255. } /* in.h:23:1 */
  2256. type sockaddr_in6 = struct {
  2257. Fsin6_family sa_family_t
  2258. Fsin6_port in_port_t
  2259. Fsin6_flowinfo uint32_t
  2260. Fsin6_addr struct {
  2261. F__in6_union struct {
  2262. F__ccgo_pad1 [0]uint32
  2263. F__s6_addr [16]uint8_t
  2264. }
  2265. }
  2266. Fsin6_scope_id uint32_t
  2267. } /* in.h:34:1 */
  2268. type ipv6_mreq = struct {
  2269. Fipv6mr_multiaddr struct {
  2270. F__in6_union struct {
  2271. F__ccgo_pad1 [0]uint32
  2272. F__s6_addr [16]uint8_t
  2273. }
  2274. }
  2275. Fipv6mr_interface uint32
  2276. } /* in.h:42:1 */
  2277. type ip_opts = struct {
  2278. Fip_dst struct{ Fs_addr in_addr_t }
  2279. Fip_opts [40]int8
  2280. } /* in.h:229:1 */
  2281. type ip_mreq = struct {
  2282. Fimr_multiaddr struct{ Fs_addr in_addr_t }
  2283. Fimr_interface struct{ Fs_addr in_addr_t }
  2284. } /* in.h:247:1 */
  2285. type ip_mreqn = struct {
  2286. Fimr_multiaddr struct{ Fs_addr in_addr_t }
  2287. Fimr_address struct{ Fs_addr in_addr_t }
  2288. Fimr_ifindex int32
  2289. } /* in.h:252:1 */
  2290. type ip_mreq_source = struct {
  2291. Fimr_multiaddr struct{ Fs_addr in_addr_t }
  2292. Fimr_interface struct{ Fs_addr in_addr_t }
  2293. Fimr_sourceaddr struct{ Fs_addr in_addr_t }
  2294. } /* in.h:258:1 */
  2295. type ip_msfilter = struct {
  2296. Fimsf_multiaddr struct{ Fs_addr in_addr_t }
  2297. Fimsf_interface struct{ Fs_addr in_addr_t }
  2298. Fimsf_fmode uint32_t
  2299. Fimsf_numsrc uint32_t
  2300. Fimsf_slist [1]struct{ Fs_addr in_addr_t }
  2301. } /* in.h:264:1 */
  2302. type group_req = struct {
  2303. Fgr_interface uint32_t
  2304. F__ccgo_pad1 [4]byte
  2305. Fgr_group struct {
  2306. Fss_family sa_family_t
  2307. F__ss_padding [118]int8
  2308. F__ss_align uint64
  2309. }
  2310. } /* in.h:275:1 */
  2311. type group_source_req = struct {
  2312. Fgsr_interface uint32_t
  2313. F__ccgo_pad1 [4]byte
  2314. Fgsr_group struct {
  2315. Fss_family sa_family_t
  2316. F__ss_padding [118]int8
  2317. F__ss_align uint64
  2318. }
  2319. Fgsr_source struct {
  2320. Fss_family sa_family_t
  2321. F__ss_padding [118]int8
  2322. F__ss_align uint64
  2323. }
  2324. } /* in.h:280:1 */
  2325. type group_filter = struct {
  2326. Fgf_interface uint32_t
  2327. F__ccgo_pad1 [4]byte
  2328. Fgf_group struct {
  2329. Fss_family sa_family_t
  2330. F__ss_padding [118]int8
  2331. F__ss_align uint64
  2332. }
  2333. Fgf_fmode uint32_t
  2334. Fgf_numsrc uint32_t
  2335. Fgf_slist [1]struct {
  2336. Fss_family sa_family_t
  2337. F__ss_padding [118]int8
  2338. F__ss_align uint64
  2339. }
  2340. } /* in.h:286:1 */
  2341. type in_pktinfo = struct {
  2342. Fipi_ifindex int32
  2343. Fipi_spec_dst struct{ Fs_addr in_addr_t }
  2344. Fipi_addr struct{ Fs_addr in_addr_t }
  2345. } /* in.h:297:1 */
  2346. type in6_pktinfo = struct {
  2347. Fipi6_addr struct {
  2348. F__in6_union struct {
  2349. F__ccgo_pad1 [0]uint32
  2350. F__s6_addr [16]uint8_t
  2351. }
  2352. }
  2353. Fipi6_ifindex uint32
  2354. } /* in.h:303:1 */
  2355. type ip6_mtuinfo = struct {
  2356. Fip6m_addr struct {
  2357. Fsin6_family sa_family_t
  2358. Fsin6_port in_port_t
  2359. Fsin6_flowinfo uint32_t
  2360. Fsin6_addr struct {
  2361. F__in6_union struct {
  2362. F__ccgo_pad1 [0]uint32
  2363. F__s6_addr [16]uint8_t
  2364. }
  2365. }
  2366. Fsin6_scope_id uint32_t
  2367. }
  2368. Fip6m_mtu uint32_t
  2369. } /* in.h:308:1 */
  2370. type addrinfo = struct {
  2371. Fai_flags int32
  2372. Fai_family int32
  2373. Fai_socktype int32
  2374. Fai_protocol int32
  2375. Fai_addrlen socklen_t
  2376. F__ccgo_pad1 [4]byte
  2377. Fai_addr uintptr
  2378. Fai_canonname uintptr
  2379. Fai_next uintptr
  2380. } /* netdb.h:16:1 */
  2381. // Legacy functions follow (marked OBsolete in SUS)
  2382. type netent = struct {
  2383. Fn_name uintptr
  2384. Fn_aliases uintptr
  2385. Fn_addrtype int32
  2386. Fn_net uint32_t
  2387. } /* netdb.h:62:1 */
  2388. type hostent = struct {
  2389. Fh_name uintptr
  2390. Fh_aliases uintptr
  2391. Fh_addrtype int32
  2392. Fh_length int32
  2393. Fh_addr_list uintptr
  2394. } /* netdb.h:69:1 */
  2395. type servent = struct {
  2396. Fs_name uintptr
  2397. Fs_aliases uintptr
  2398. Fs_port int32
  2399. F__ccgo_pad1 [4]byte
  2400. Fs_proto uintptr
  2401. } /* netdb.h:78:1 */
  2402. type protoent = struct {
  2403. Fp_name uintptr
  2404. Fp_aliases uintptr
  2405. Fp_proto int32
  2406. F__ccgo_pad1 [4]byte
  2407. } /* netdb.h:85:1 */
  2408. type aibuf = struct {
  2409. Fai struct {
  2410. Fai_flags int32
  2411. Fai_family int32
  2412. Fai_socktype int32
  2413. Fai_protocol int32
  2414. Fai_addrlen socklen_t
  2415. F__ccgo_pad1 [4]byte
  2416. Fai_addr uintptr
  2417. Fai_canonname uintptr
  2418. Fai_next uintptr
  2419. }
  2420. Fsa struct {
  2421. Fsin struct {
  2422. Fsin_family sa_family_t
  2423. Fsin_port in_port_t
  2424. Fsin_addr struct{ Fs_addr in_addr_t }
  2425. Fsin_zero [8]uint8_t
  2426. }
  2427. F__ccgo_pad1 [12]byte
  2428. }
  2429. Flock [1]int32
  2430. Fslot int16
  2431. Fref int16
  2432. F__ccgo_pad1 [4]byte
  2433. } /* lookup.h:10:1 */
  2434. type sa = struct {
  2435. Fsin struct {
  2436. Fsin_family sa_family_t
  2437. Fsin_port in_port_t
  2438. Fsin_addr struct{ Fs_addr in_addr_t }
  2439. Fsin_zero [8]uint8_t
  2440. }
  2441. F__ccgo_pad1 [12]byte
  2442. } /* lookup.h:10:1 */
  2443. type address = struct {
  2444. Ffamily int32
  2445. Fscopeid uint32
  2446. Faddr [16]uint8_t
  2447. Fsortkey int32
  2448. } /* lookup.h:20:1 */
  2449. type service = struct {
  2450. Fport uint16_t
  2451. Fproto uint8
  2452. Fsocktype uint8
  2453. } /* lookup.h:27:1 */
  2454. type resolvconf = struct {
  2455. Fns [3]struct {
  2456. Ffamily int32
  2457. Fscopeid uint32
  2458. Faddr [16]uint8_t
  2459. Fsortkey int32
  2460. }
  2461. Fnns uint32
  2462. Fattempts uint32
  2463. Fndots uint32
  2464. Ftimeout uint32
  2465. } /* lookup.h:34:1 */
  2466. func Xfreeaddrinfo(tls *TLS, p uintptr) { /* freeaddrinfo.c:7:6: */
  2467. if __ccgo_strace {
  2468. trc("tls=%v p=%v, (%v:)", tls, p, origin(2))
  2469. }
  2470. var cnt size_t
  2471. cnt = uint64(1)
  2472. __1:
  2473. if !((*addrinfo)(unsafe.Pointer(p)).Fai_next != 0) {
  2474. goto __3
  2475. }
  2476. goto __2
  2477. __2:
  2478. cnt++
  2479. p = (*addrinfo)(unsafe.Pointer(p)).Fai_next
  2480. goto __1
  2481. goto __3
  2482. __3:
  2483. ;
  2484. var b uintptr = p - uintptr(uint64(uintptr(0)))
  2485. b -= 88 * uintptr((*aibuf)(unsafe.Pointer(b)).Fslot)
  2486. //TODO LOCK(b->lock);
  2487. if !(int32(AssignSubPtrInt16(b+82, int16(cnt))) != 0) {
  2488. Xfree(tls, b)
  2489. }
  2490. //TODO else UNLOCK(b->lock);
  2491. }
  2492. type time_t = int64 /* alltypes.h:85:16 */
  2493. type clockid_t = int32 /* alltypes.h:214:13 */
  2494. type timespec = struct {
  2495. Ftv_sec time_t
  2496. Ftv_nsec int64
  2497. } /* alltypes.h:229:1 */
  2498. type pthread_t = uintptr /* alltypes.h:273:26 */
  2499. type pthread_once_t = int32 /* alltypes.h:279:13 */
  2500. type pthread_key_t = uint32 /* alltypes.h:284:18 */
  2501. type pthread_spinlock_t = int32 /* alltypes.h:289:13 */
  2502. type pthread_mutexattr_t = struct{ F__attr uint32 } /* alltypes.h:294:37 */
  2503. type pthread_condattr_t = struct{ F__attr uint32 } /* alltypes.h:299:37 */
  2504. type pthread_barrierattr_t = struct{ F__attr uint32 } /* alltypes.h:304:37 */
  2505. type pthread_rwlockattr_t = struct{ F__attr [2]uint32 } /* alltypes.h:309:40 */
  2506. type __sigset_t = struct{ F__bits [16]uint64 } /* alltypes.h:349:9 */
  2507. type sigset_t = __sigset_t /* alltypes.h:349:71 */
  2508. type pthread_attr_t = struct {
  2509. F__u struct {
  2510. F__ccgo_pad1 [0]uint64
  2511. F__i [14]int32
  2512. }
  2513. } /* alltypes.h:372:147 */
  2514. type pthread_mutex_t = struct {
  2515. F__u struct {
  2516. F__ccgo_pad1 [0]uint64
  2517. F__i [10]int32
  2518. }
  2519. } /* alltypes.h:377:157 */
  2520. type pthread_cond_t = struct {
  2521. F__u struct {
  2522. F__ccgo_pad1 [0]uint64
  2523. F__i [12]int32
  2524. }
  2525. } /* alltypes.h:387:112 */
  2526. type pthread_rwlock_t = struct {
  2527. F__u struct {
  2528. F__ccgo_pad1 [0]uint64
  2529. F__i [14]int32
  2530. }
  2531. } /* alltypes.h:397:139 */
  2532. type pthread_barrier_t = struct {
  2533. F__u struct {
  2534. F__ccgo_pad1 [0]uint64
  2535. F__i [8]int32
  2536. }
  2537. } /* alltypes.h:402:137 */
  2538. type sched_param = struct {
  2539. Fsched_priority int32
  2540. F__reserved1 int32
  2541. F__reserved2 [2]struct {
  2542. F__reserved1 time_t
  2543. F__reserved2 int64
  2544. }
  2545. F__reserved3 int32
  2546. F__ccgo_pad1 [4]byte
  2547. } /* sched.h:19:1 */
  2548. type timer_t = uintptr /* alltypes.h:209:14 */
  2549. type clock_t = int64 /* alltypes.h:219:14 */
  2550. type tm = struct {
  2551. Ftm_sec int32
  2552. Ftm_min int32
  2553. Ftm_hour int32
  2554. Ftm_mday int32
  2555. Ftm_mon int32
  2556. Ftm_year int32
  2557. Ftm_wday int32
  2558. Ftm_yday int32
  2559. Ftm_isdst int32
  2560. F__ccgo_pad1 [4]byte
  2561. Ftm_gmtoff int64
  2562. Ftm_zone uintptr
  2563. } /* time.h:38:1 */
  2564. type itimerspec = struct {
  2565. Fit_interval struct {
  2566. Ftv_sec time_t
  2567. Ftv_nsec int64
  2568. }
  2569. Fit_value struct {
  2570. Ftv_sec time_t
  2571. Ftv_nsec int64
  2572. }
  2573. } /* time.h:80:1 */
  2574. type __ptcb = struct {
  2575. F__f uintptr
  2576. F__x uintptr
  2577. F__next uintptr
  2578. } /* pthread.h:206:1 */
  2579. func Xgetaddrinfo(tls *TLS, host uintptr, serv uintptr, hint uintptr, res uintptr) int32 { /* getaddrinfo.c:12:5: */
  2580. if __ccgo_strace {
  2581. trc("tls=%v host=%v serv=%v hint=%v res=%v, (%v:)", tls, host, serv, hint, res, origin(2))
  2582. }
  2583. bp := tls.Alloc(1608)
  2584. defer tls.Free(1608)
  2585. // var ports [2]service at bp, 8
  2586. // var addrs [48]address at bp+8, 1344
  2587. // var canon [256]int8 at bp+1352, 256
  2588. var outcanon uintptr
  2589. var nservs int32
  2590. var naddrs int32
  2591. var nais int32
  2592. var canon_len int32
  2593. var i int32
  2594. var j int32
  2595. var k int32
  2596. var family int32 = 0
  2597. var flags int32 = 0
  2598. var proto int32 = 0
  2599. var socktype int32 = 0
  2600. var out uintptr
  2601. if !(host != 0) && !(serv != 0) {
  2602. return -2
  2603. }
  2604. if hint != 0 {
  2605. family = (*addrinfo)(unsafe.Pointer(hint)).Fai_family
  2606. flags = (*addrinfo)(unsafe.Pointer(hint)).Fai_flags
  2607. proto = (*addrinfo)(unsafe.Pointer(hint)).Fai_protocol
  2608. socktype = (*addrinfo)(unsafe.Pointer(hint)).Fai_socktype
  2609. var mask int32 = 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x400
  2610. if flags&mask != flags {
  2611. return -1
  2612. }
  2613. switch family {
  2614. case 2:
  2615. fallthrough
  2616. case 10:
  2617. fallthrough
  2618. case 0:
  2619. break
  2620. fallthrough
  2621. default:
  2622. return -6
  2623. }
  2624. }
  2625. if flags&0x20 != 0 {
  2626. Xabort(tls) //TODO-
  2627. // /* Define the "an address is configured" condition for address
  2628. // * families via ability to create a socket for the family plus
  2629. // * routability of the loopback address for the family. */
  2630. // static const struct sockaddr_in lo4 = {
  2631. // .sin_family = AF_INET, .sin_port = 65535,
  2632. // .sin_addr.s_addr = __BYTE_ORDER == __BIG_ENDIAN
  2633. // ? 0x7f000001 : 0x0100007f
  2634. // };
  2635. // static const struct sockaddr_in6 lo6 = {
  2636. // .sin6_family = AF_INET6, .sin6_port = 65535,
  2637. // .sin6_addr = IN6ADDR_LOOPBACK_INIT
  2638. // };
  2639. // int tf[2] = { AF_INET, AF_INET6 };
  2640. // const void *ta[2] = { &lo4, &lo6 };
  2641. // socklen_t tl[2] = { sizeof lo4, sizeof lo6 };
  2642. // for (i=0; i<2; i++) {
  2643. // if (family==tf[1-i]) continue;
  2644. // int s = socket(tf[i], SOCK_CLOEXEC|SOCK_DGRAM,
  2645. // IPPROTO_UDP);
  2646. // if (s>=0) {
  2647. // int cs;
  2648. // pthread_setcancelstate(
  2649. // PTHREAD_CANCEL_DISABLE, &cs);
  2650. // int r = connect(s, ta[i], tl[i]);
  2651. // pthread_setcancelstate(cs, 0);
  2652. // close(s);
  2653. // if (!r) continue;
  2654. // }
  2655. // switch (errno) {
  2656. // case EADDRNOTAVAIL:
  2657. // case EAFNOSUPPORT:
  2658. // case EHOSTUNREACH:
  2659. // case ENETDOWN:
  2660. // case ENETUNREACH:
  2661. // break;
  2662. // default:
  2663. // return EAI_SYSTEM;
  2664. // }
  2665. // if (family == tf[i]) return EAI_NONAME;
  2666. // family = tf[1-i];
  2667. // }
  2668. }
  2669. nservs = X__lookup_serv(tls, bp, serv, proto, socktype, flags)
  2670. if nservs < 0 {
  2671. return nservs
  2672. }
  2673. naddrs = X__lookup_name(tls, bp+8, bp+1352, host, family, flags)
  2674. if naddrs < 0 {
  2675. return naddrs
  2676. }
  2677. nais = nservs * naddrs
  2678. canon_len = int32(Xstrlen(tls, bp+1352))
  2679. out = Xcalloc(tls, uint64(1), uint64(nais)*uint64(unsafe.Sizeof(aibuf{}))+uint64(canon_len)+uint64(1))
  2680. if !(out != 0) {
  2681. return -10
  2682. }
  2683. if canon_len != 0 {
  2684. outcanon = out + uintptr(nais)*88
  2685. Xmemcpy(tls, outcanon, bp+1352, uint64(canon_len+1))
  2686. } else {
  2687. outcanon = uintptr(0)
  2688. }
  2689. for k = AssignInt32(&i, 0); i < naddrs; i++ {
  2690. j = 0
  2691. __1:
  2692. if !(j < nservs) {
  2693. goto __3
  2694. }
  2695. {
  2696. (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fslot = int16(k)
  2697. //TODO out[k].ai = (struct addrinfo){
  2698. //TODO .ai_family = addrs[i].family,
  2699. //TODO .ai_socktype = ports[j].socktype,
  2700. //TODO .ai_protocol = ports[j].proto,
  2701. //TODO .ai_addrlen = addrs[i].family == AF_INET
  2702. //TODO ? sizeof(struct sockaddr_in)
  2703. //TODO : sizeof(struct sockaddr_in6),
  2704. //TODO .ai_addr = (void *)&out[k].sa,
  2705. //TODO .ai_canonname = outcanon };
  2706. (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_family = (*address)(unsafe.Pointer(bp + 8 + uintptr(i)*28)).Ffamily
  2707. (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_socktype = int32((*service)(unsafe.Pointer(bp + uintptr(j)*4)).Fsocktype)
  2708. (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_protocol = int32((*service)(unsafe.Pointer(bp + uintptr(j)*4)).Fproto)
  2709. (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_addrlen = func() uint32 {
  2710. if (*address)(unsafe.Pointer(bp+8+uintptr(i)*28)).Ffamily == 2 {
  2711. return uint32(unsafe.Sizeof(sockaddr_in{}))
  2712. }
  2713. return uint32(unsafe.Sizeof(sockaddr_in6{}))
  2714. }()
  2715. (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_addr = out + uintptr(k)*88 + 48
  2716. (*aibuf)(unsafe.Pointer(out + uintptr(k)*88)).Fai.Fai_canonname = outcanon
  2717. if k != 0 {
  2718. (*aibuf)(unsafe.Pointer(out + uintptr(k-1)*88)).Fai.Fai_next = out + uintptr(k)*88
  2719. }
  2720. switch (*address)(unsafe.Pointer(bp + 8 + uintptr(i)*28)).Ffamily {
  2721. case 2:
  2722. (*sockaddr_in)(unsafe.Pointer(out + uintptr(k)*88 + 48)).Fsin_family = sa_family_t(2)
  2723. (*sockaddr_in)(unsafe.Pointer(out + uintptr(k)*88 + 48)).Fsin_port = Xhtons(tls, (*service)(unsafe.Pointer(bp+uintptr(j)*4)).Fport)
  2724. Xmemcpy(tls, out+uintptr(k)*88+48+4, bp+8+uintptr(i)*28+8, uint64(4))
  2725. break
  2726. case 10:
  2727. (*sockaddr_in6)(unsafe.Pointer(out + uintptr(k)*88 + 48)).Fsin6_family = sa_family_t(10)
  2728. (*sockaddr_in6)(unsafe.Pointer(out + uintptr(k)*88 + 48)).Fsin6_port = Xhtons(tls, (*service)(unsafe.Pointer(bp+uintptr(j)*4)).Fport)
  2729. (*sockaddr_in6)(unsafe.Pointer(out + uintptr(k)*88 + 48)).Fsin6_scope_id = (*address)(unsafe.Pointer(bp + 8 + uintptr(i)*28)).Fscopeid
  2730. Xmemcpy(tls, out+uintptr(k)*88+48+8, bp+8+uintptr(i)*28+8, uint64(16))
  2731. break
  2732. }
  2733. }
  2734. goto __2
  2735. __2:
  2736. j++
  2737. k++
  2738. goto __1
  2739. goto __3
  2740. __3:
  2741. }
  2742. (*aibuf)(unsafe.Pointer(out)).Fref = int16(nais)
  2743. *(*uintptr)(unsafe.Pointer(res)) = out
  2744. return 0
  2745. }
  2746. type ucred = struct {
  2747. Fpid pid_t
  2748. Fuid uid_t
  2749. Fgid gid_t
  2750. } /* socket.h:57:1 */
  2751. type mmsghdr = struct {
  2752. Fmsg_hdr struct {
  2753. Fmsg_name uintptr
  2754. Fmsg_namelen socklen_t
  2755. F__ccgo_pad1 [4]byte
  2756. Fmsg_iov uintptr
  2757. Fmsg_iovlen int32
  2758. F__pad1 int32
  2759. Fmsg_control uintptr
  2760. Fmsg_controllen socklen_t
  2761. F__pad2 int32
  2762. Fmsg_flags int32
  2763. F__ccgo_pad2 [4]byte
  2764. }
  2765. Fmsg_len uint32
  2766. F__ccgo_pad1 [4]byte
  2767. } /* socket.h:63:1 */
  2768. func Xgethostbyaddr(tls *TLS, a uintptr, l socklen_t, af int32) uintptr { /* gethostbyaddr.c:7:16: */
  2769. if __ccgo_strace {
  2770. trc("tls=%v a=%v l=%v af=%v, (%v:)", tls, a, l, af, origin(2))
  2771. }
  2772. bp := tls.Alloc(8)
  2773. defer tls.Free(8)
  2774. var size size_t = uint64(63)
  2775. // var res uintptr at bp, 8
  2776. var err int32
  2777. for __ccgo := true; __ccgo; __ccgo = err == 34 {
  2778. Xfree(tls, _sh)
  2779. _sh = Xmalloc(tls, AssignAddUint64(&size, size+uint64(1)))
  2780. if !(_sh != 0) {
  2781. *(*int32)(unsafe.Pointer(X__h_errno_location(tls))) = 3
  2782. return uintptr(0)
  2783. }
  2784. err = Xgethostbyaddr_r(tls, a, l, af, _sh,
  2785. _sh+uintptr(1)*32, size-size_t(unsafe.Sizeof(hostent{})), bp, X__h_errno_location(tls))
  2786. }
  2787. if err != 0 {
  2788. return uintptr(0)
  2789. }
  2790. return _sh
  2791. }
  2792. var _sh uintptr /* gethostbyaddr.c:9:24: */
  2793. 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: */
  2794. if __ccgo_strace {
  2795. 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))
  2796. }
  2797. bp := tls.Alloc(28)
  2798. defer tls.Free(28)
  2799. //TODO union {
  2800. //TODO struct sockaddr_in sin;
  2801. //TODO struct sockaddr_in6 sin6;
  2802. //TODO } sa = { .sin.sin_family = af };
  2803. *(*struct {
  2804. Fsin sockaddr_in
  2805. F__ccgo_pad1 [12]byte
  2806. })(unsafe.Pointer(bp)) = struct {
  2807. Fsin sockaddr_in
  2808. F__ccgo_pad1 [12]byte
  2809. }{} //TODO-
  2810. (*sockaddr_in)(unsafe.Pointer(bp)).Fsin_family = sa_family_t(af) //TODO-
  2811. var sl socklen_t
  2812. if af == 10 {
  2813. sl = uint32(unsafe.Sizeof(sockaddr_in6{}))
  2814. } else {
  2815. sl = uint32(unsafe.Sizeof(sockaddr_in{}))
  2816. }
  2817. var i int32
  2818. *(*uintptr)(unsafe.Pointer(res)) = uintptr(0)
  2819. // Load address argument into sockaddr structure
  2820. if af == 10 && l == socklen_t(16) {
  2821. Xmemcpy(tls, bp+8, a, uint64(16))
  2822. } else if af == 2 && l == socklen_t(4) {
  2823. Xmemcpy(tls, bp+4, a, uint64(4))
  2824. } else {
  2825. *(*int32)(unsafe.Pointer(err)) = 3
  2826. return 22
  2827. }
  2828. // Align buffer and check for space for pointers and ip address
  2829. i = int32(uintptr_t(buf) & (uint64(unsafe.Sizeof(uintptr(0))) - uint64(1)))
  2830. if !(i != 0) {
  2831. i = int32(unsafe.Sizeof(uintptr(0)))
  2832. }
  2833. if buflen <= uint64(5)*uint64(unsafe.Sizeof(uintptr(0)))-uint64(i)+uint64(l) {
  2834. return 34
  2835. }
  2836. buf += uintptr(uint64(unsafe.Sizeof(uintptr(0))) - uint64(i))
  2837. buflen = buflen - (uint64(5)*uint64(unsafe.Sizeof(uintptr(0))) - uint64(i) + uint64(l))
  2838. (*hostent)(unsafe.Pointer(h)).Fh_addr_list = buf
  2839. buf += uintptr(uint64(2) * uint64(unsafe.Sizeof(uintptr(0))))
  2840. (*hostent)(unsafe.Pointer(h)).Fh_aliases = buf
  2841. buf += uintptr(uint64(2) * uint64(unsafe.Sizeof(uintptr(0))))
  2842. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list)) = buf
  2843. Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list)), a, uint64(l))
  2844. buf += uintptr(l)
  2845. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list + 1*8)) = uintptr(0)
  2846. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases)) = buf
  2847. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)) = uintptr(0)
  2848. switch Xgetnameinfo(tls, bp, sl, buf, uint32(buflen), uintptr(0), uint32(0), 0) {
  2849. case -3:
  2850. *(*int32)(unsafe.Pointer(err)) = 2
  2851. return 11
  2852. case -12:
  2853. return 34
  2854. default:
  2855. fallthrough
  2856. case -10:
  2857. fallthrough
  2858. case -11:
  2859. fallthrough
  2860. case -4:
  2861. *(*int32)(unsafe.Pointer(err)) = 3
  2862. return *(*int32)(unsafe.Pointer(X___errno_location(tls)))
  2863. case 0:
  2864. break
  2865. }
  2866. (*hostent)(unsafe.Pointer(h)).Fh_addrtype = af
  2867. (*hostent)(unsafe.Pointer(h)).Fh_length = int32(l)
  2868. (*hostent)(unsafe.Pointer(h)).Fh_name = *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases))
  2869. *(*uintptr)(unsafe.Pointer(res)) = h
  2870. return 0
  2871. }
  2872. func Xgethostbyname(tls *TLS, name uintptr) uintptr { /* gethostbyname.c:8:16: */
  2873. if __ccgo_strace {
  2874. trc("tls=%v name=%v, (%v:)", tls, name, origin(2))
  2875. }
  2876. return Xgethostbyname2(tls, name, 2)
  2877. }
  2878. func Xgethostbyname2(tls *TLS, name uintptr, af int32) uintptr { /* gethostbyname2.c:8:16: */
  2879. if __ccgo_strace {
  2880. trc("tls=%v name=%v af=%v, (%v:)", tls, name, af, origin(2))
  2881. }
  2882. bp := tls.Alloc(8)
  2883. defer tls.Free(8)
  2884. var size size_t = uint64(63)
  2885. // var res uintptr at bp, 8
  2886. var err int32
  2887. for __ccgo := true; __ccgo; __ccgo = err == 34 {
  2888. Xfree(tls, _sh1)
  2889. _sh1 = Xmalloc(tls, AssignAddUint64(&size, size+uint64(1)))
  2890. if !(_sh1 != 0) {
  2891. *(*int32)(unsafe.Pointer(X__h_errno_location(tls))) = 3
  2892. return uintptr(0)
  2893. }
  2894. err = Xgethostbyname2_r(tls, name, af, _sh1,
  2895. _sh1+uintptr(1)*32, size-size_t(unsafe.Sizeof(hostent{})), bp, X__h_errno_location(tls))
  2896. }
  2897. if err != 0 {
  2898. return uintptr(0)
  2899. }
  2900. return _sh1
  2901. }
  2902. var _sh1 uintptr /* gethostbyname2.c:10:24: */
  2903. 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: */
  2904. if __ccgo_strace {
  2905. 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))
  2906. }
  2907. bp := tls.Alloc(1600)
  2908. defer tls.Free(1600)
  2909. // var addrs [48]address at bp, 1344
  2910. // var canon [256]int8 at bp+1344, 256
  2911. var i int32
  2912. var cnt int32
  2913. var align size_t
  2914. var need size_t
  2915. *(*uintptr)(unsafe.Pointer(res)) = uintptr(0)
  2916. cnt = X__lookup_name(tls, bp, bp+1344, name, af, 0x02)
  2917. if cnt < 0 {
  2918. switch cnt {
  2919. case -2:
  2920. *(*int32)(unsafe.Pointer(err)) = 1
  2921. return 2
  2922. fallthrough
  2923. case -3:
  2924. *(*int32)(unsafe.Pointer(err)) = 2
  2925. return 11
  2926. fallthrough
  2927. default:
  2928. fallthrough
  2929. case -4:
  2930. *(*int32)(unsafe.Pointer(err)) = 3
  2931. return 74
  2932. fallthrough
  2933. case -10:
  2934. fallthrough
  2935. case -11:
  2936. *(*int32)(unsafe.Pointer(err)) = 3
  2937. return *(*int32)(unsafe.Pointer(X___errno_location(tls)))
  2938. }
  2939. }
  2940. (*hostent)(unsafe.Pointer(h)).Fh_addrtype = af
  2941. (*hostent)(unsafe.Pointer(h)).Fh_length = func() int32 {
  2942. if af == 10 {
  2943. return 16
  2944. }
  2945. return 4
  2946. }()
  2947. // Align buffer
  2948. align = -uintptr_t(buf) & (uint64(unsafe.Sizeof(uintptr(0))) - uint64(1))
  2949. need = uint64(4) * uint64(unsafe.Sizeof(uintptr(0)))
  2950. need = need + uint64(cnt+1)*(uint64(unsafe.Sizeof(uintptr(0)))+uint64((*hostent)(unsafe.Pointer(h)).Fh_length))
  2951. need = need + (Xstrlen(tls, name) + uint64(1))
  2952. need = need + (Xstrlen(tls, bp+1344) + uint64(1))
  2953. need = need + align
  2954. if need > buflen {
  2955. return 34
  2956. }
  2957. buf += uintptr(align)
  2958. (*hostent)(unsafe.Pointer(h)).Fh_aliases = buf
  2959. buf += uintptr(uint64(3) * uint64(unsafe.Sizeof(uintptr(0))))
  2960. (*hostent)(unsafe.Pointer(h)).Fh_addr_list = buf
  2961. buf += uintptr(uint64(cnt+1) * uint64(unsafe.Sizeof(uintptr(0))))
  2962. for i = 0; i < cnt; i++ {
  2963. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list + uintptr(i)*8)) = buf
  2964. buf += uintptr((*hostent)(unsafe.Pointer(h)).Fh_length)
  2965. Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list + uintptr(i)*8)), bp+uintptr(i)*28+8, uint64((*hostent)(unsafe.Pointer(h)).Fh_length))
  2966. }
  2967. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_addr_list + uintptr(i)*8)) = uintptr(0)
  2968. (*hostent)(unsafe.Pointer(h)).Fh_name = AssignPtrUintptr((*hostent)(unsafe.Pointer(h)).Fh_aliases, buf)
  2969. Xstrcpy(tls, (*hostent)(unsafe.Pointer(h)).Fh_name, bp+1344)
  2970. buf += uintptr(Xstrlen(tls, (*hostent)(unsafe.Pointer(h)).Fh_name) + uint64(1))
  2971. if Xstrcmp(tls, (*hostent)(unsafe.Pointer(h)).Fh_name, name) != 0 {
  2972. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)) = buf
  2973. Xstrcpy(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)), name)
  2974. buf += uintptr(Xstrlen(tls, *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 1*8))) + uint64(1))
  2975. } else {
  2976. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 1*8)) = uintptr(0)
  2977. }
  2978. *(*uintptr)(unsafe.Pointer((*hostent)(unsafe.Pointer(h)).Fh_aliases + 2*8)) = uintptr(0)
  2979. *(*uintptr)(unsafe.Pointer(res)) = h
  2980. return 0
  2981. }
  2982. type if_nameindex = struct {
  2983. Fif_index uint32
  2984. F__ccgo_pad1 [4]byte
  2985. Fif_name uintptr
  2986. } /* if.h:12:1 */
  2987. type ifaddr = struct {
  2988. Fifa_addr struct {
  2989. Fsa_family sa_family_t
  2990. Fsa_data [14]int8
  2991. }
  2992. Fifa_ifu struct {
  2993. Fifu_broadaddr struct {
  2994. Fsa_family sa_family_t
  2995. Fsa_data [14]int8
  2996. }
  2997. }
  2998. Fifa_ifp uintptr
  2999. Fifa_next uintptr
  3000. } /* if.h:51:1 */
  3001. type ifmap = struct {
  3002. Fmem_start uint64
  3003. Fmem_end uint64
  3004. Fbase_addr uint16
  3005. Firq uint8
  3006. Fdma uint8
  3007. Fport uint8
  3008. F__ccgo_pad1 [3]byte
  3009. } /* if.h:64:1 */
  3010. type ifreq = struct {
  3011. Fifr_ifrn struct{ Fifrn_name [16]int8 }
  3012. Fifr_ifru struct {
  3013. F__ccgo_pad1 [0]uint64
  3014. Fifru_addr struct {
  3015. Fsa_family sa_family_t
  3016. Fsa_data [14]int8
  3017. }
  3018. F__ccgo_pad2 [8]byte
  3019. }
  3020. } /* if.h:76:1 */
  3021. type ifconf = struct {
  3022. Fifc_len int32
  3023. F__ccgo_pad1 [4]byte
  3024. Fifc_ifcu struct{ Fifcu_buf uintptr }
  3025. } /* if.h:116:1 */
  3026. type ns_sect = uint32 /* nameser.h:37:3 */
  3027. type __ns_msg = struct {
  3028. F_msg uintptr
  3029. F_eom uintptr
  3030. F_id uint16_t
  3031. F_flags uint16_t
  3032. F_counts [4]uint16_t
  3033. F__ccgo_pad1 [4]byte
  3034. F_sections [4]uintptr
  3035. F_sect ns_sect
  3036. F_rrnum int32
  3037. F_msg_ptr uintptr
  3038. } /* nameser.h:39:9 */
  3039. type ns_msg = __ns_msg /* nameser.h:46:3 */
  3040. type _ns_flagdata = struct {
  3041. Fmask int32
  3042. Fshift int32
  3043. } /* nameser.h:48:1 */
  3044. type __ns_rr = struct {
  3045. Fname [1025]int8
  3046. F__ccgo_pad1 [1]byte
  3047. Ftype uint16_t
  3048. Frr_class uint16_t
  3049. F__ccgo_pad2 [2]byte
  3050. Fttl uint32_t
  3051. Frdlength uint16_t
  3052. F__ccgo_pad3 [2]byte
  3053. Frdata uintptr
  3054. } /* nameser.h:59:9 */
  3055. type ns_rr = __ns_rr /* nameser.h:66:3 */
  3056. type ns_flag = uint32 /* nameser.h:87:3 */
  3057. type ns_opcode = uint32 /* nameser.h:96:3 */
  3058. type ns_rcode = uint32 /* nameser.h:115:3 */
  3059. type ns_update_operation = uint32 /* nameser.h:121:3 */
  3060. type ns_tsig_key1 = struct {
  3061. Fname [1025]int8
  3062. Falg [1025]int8
  3063. F__ccgo_pad1 [6]byte
  3064. Fdata uintptr
  3065. Flen int32
  3066. F__ccgo_pad2 [4]byte
  3067. } /* nameser.h:123:1 */
  3068. type ns_tsig_key = ns_tsig_key1 /* nameser.h:128:28 */
  3069. type ns_tcp_tsig_state1 = struct {
  3070. Fcounter int32
  3071. F__ccgo_pad1 [4]byte
  3072. Fkey uintptr
  3073. Fctx uintptr
  3074. Fsig [512]uint8
  3075. Fsiglen int32
  3076. F__ccgo_pad2 [4]byte
  3077. } /* nameser.h:130:1 */
  3078. type ns_tcp_tsig_state = ns_tcp_tsig_state1 /* nameser.h:137:34 */
  3079. type ns_type = uint32 /* nameser.h:200:3 */
  3080. type ns_class = uint32 /* nameser.h:219:3 */
  3081. type ns_key_types = uint32 /* nameser.h:226:3 */
  3082. type ns_cert_types = uint32 /* nameser.h:234:3 */
  3083. type HEADER = struct {
  3084. F__ccgo_pad1 [0]uint32
  3085. Fid 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 */
  3086. Fqdcount uint32 /* unsigned qdcount: 16, unsigned ancount: 16 */
  3087. Fnscount uint32 /* unsigned nscount: 16, unsigned arcount: 16 */
  3088. } /* nameser.h:353:3 */
  3089. // unused; purely for broken apps
  3090. type __res_state = struct {
  3091. Fretrans int32
  3092. Fretry int32
  3093. Foptions uint64
  3094. Fnscount int32
  3095. Fnsaddr_list [3]struct {
  3096. Fsin_family sa_family_t
  3097. Fsin_port in_port_t
  3098. Fsin_addr struct{ Fs_addr in_addr_t }
  3099. Fsin_zero [8]uint8_t
  3100. }
  3101. Fid uint16
  3102. F__ccgo_pad1 [2]byte
  3103. Fdnsrch [7]uintptr
  3104. Fdefdname [256]int8
  3105. Fpfcode uint64
  3106. Fndots uint32 /* unsigned ndots: 4, unsigned nsort: 4, unsigned ipv6_unavail: 1, unsigned unused: 23 */
  3107. F__ccgo_pad2 [4]byte
  3108. Fsort_list [10]struct {
  3109. Faddr struct{ Fs_addr in_addr_t }
  3110. Fmask uint32_t
  3111. }
  3112. Fqhook uintptr
  3113. Frhook uintptr
  3114. Fres_h_errno int32
  3115. F_vcsock int32
  3116. F_flags uint32
  3117. F__ccgo_pad3 [4]byte
  3118. F_u struct {
  3119. F__ccgo_pad1 [0]uint64
  3120. Fpad [52]int8
  3121. F__ccgo_pad2 [4]byte
  3122. }
  3123. } /* resolv.h:26:9 */
  3124. // unused; purely for broken apps
  3125. type res_state = uintptr /* resolv.h:62:3 */
  3126. type res_sym = struct {
  3127. Fnumber int32
  3128. F__ccgo_pad1 [4]byte
  3129. Fname uintptr
  3130. Fhumanname uintptr
  3131. } /* resolv.h:70:1 */
  3132. func itoa(tls *TLS, p uintptr, x uint32) uintptr { /* getnameinfo.c:18:13: */
  3133. p += uintptr(uint64(3) * uint64(unsafe.Sizeof(int32(0))))
  3134. *(*int8)(unsafe.Pointer(PreDecUintptr(&p, 1))) = int8(0)
  3135. for __ccgo := true; __ccgo; __ccgo = x != 0 {
  3136. *(*int8)(unsafe.Pointer(PreDecUintptr(&p, 1))) = int8(uint32('0') + x%uint32(10))
  3137. x = x / uint32(10)
  3138. }
  3139. return p
  3140. }
  3141. func mkptr4(tls *TLS, s uintptr, ip uintptr) { /* getnameinfo.c:28:13: */
  3142. bp := tls.Alloc(32)
  3143. defer tls.Free(32)
  3144. Xsprintf(tls, s, ts+25,
  3145. 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)))))
  3146. }
  3147. func mkptr6(tls *TLS, s uintptr, ip uintptr) { /* getnameinfo.c:34:13: */
  3148. var i int32
  3149. for i = 15; i >= 0; i-- {
  3150. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = _sxdigits[int32(*(*uint8)(unsafe.Pointer(ip + uintptr(i))))&15]
  3151. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8('.')
  3152. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = _sxdigits[int32(*(*uint8)(unsafe.Pointer(ip + uintptr(i))))>>4]
  3153. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8('.')
  3154. }
  3155. Xstrcpy(tls, s, ts+50)
  3156. }
  3157. var _sxdigits = *(*[17]int8)(unsafe.Pointer(ts + 59)) /* getnameinfo.c:36:20 */
  3158. func reverse_hosts(tls *TLS, buf uintptr, a uintptr, scopeid uint32, family int32) { /* getnameinfo.c:45:13: */
  3159. bp := tls.Alloc(556)
  3160. defer tls.Free(556)
  3161. // var line [512]int8 at bp+16, 512
  3162. var p uintptr
  3163. var z uintptr
  3164. var _buf [1032]uint8
  3165. _ = _buf
  3166. // var atmp [16]uint8 at bp, 16
  3167. // var iplit address at bp+528, 28
  3168. //TODO FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf);
  3169. var f uintptr = Xfopen(tls, ts+76, ts+87)
  3170. if !(f != 0) {
  3171. return
  3172. }
  3173. if family == 2 {
  3174. Xmemcpy(tls, bp+uintptr(12), a, uint64(4))
  3175. Xmemcpy(tls, bp, ts+90, uint64(12))
  3176. a = bp /* &atmp[0] */
  3177. }
  3178. for Xfgets(tls, bp+16, int32(unsafe.Sizeof([512]int8{})), f) != 0 {
  3179. if AssignUintptr(&p, Xstrchr(tls, bp+16, '#')) != 0 {
  3180. *(*int8)(unsafe.Pointer(PostIncUintptr(&p, 1))) = int8('\n')
  3181. *(*int8)(unsafe.Pointer(p)) = int8(0)
  3182. }
  3183. for p = bp + 16; /* &line[0] */ *(*int8)(unsafe.Pointer(p)) != 0 && !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(p)))) != 0); p++ {
  3184. }
  3185. *(*int8)(unsafe.Pointer(PostIncUintptr(&p, 1))) = int8(0)
  3186. if X__lookup_ipliteral(tls, bp+528, bp+16, 0) <= 0 {
  3187. continue
  3188. }
  3189. if (*address)(unsafe.Pointer(bp+528)).Ffamily == 2 {
  3190. Xmemcpy(tls, bp+528+8+uintptr(12), bp+528+8, uint64(4))
  3191. Xmemcpy(tls, bp+528+8, ts+90, uint64(12))
  3192. (*address)(unsafe.Pointer(bp + 528 /* &iplit */)).Fscopeid = uint32(0)
  3193. }
  3194. if Xmemcmp(tls, a, bp+528+8, uint64(16)) != 0 || (*address)(unsafe.Pointer(bp+528)).Fscopeid != scopeid {
  3195. continue
  3196. }
  3197. for ; *(*int8)(unsafe.Pointer(p)) != 0 && __isspace(tls, int32(*(*int8)(unsafe.Pointer(p)))) != 0; p++ {
  3198. }
  3199. for z = p; *(*int8)(unsafe.Pointer(z)) != 0 && !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(z)))) != 0); z++ {
  3200. }
  3201. *(*int8)(unsafe.Pointer(z)) = int8(0)
  3202. if (int64(z)-int64(p))/1 < int64(256) {
  3203. Xmemcpy(tls, buf, p, uint64((int64(z)-int64(p))/1+int64(1)))
  3204. break
  3205. }
  3206. }
  3207. //TODO __fclose_ca(f);
  3208. Xfclose(tls, f)
  3209. }
  3210. func reverse_services(tls *TLS, buf uintptr, port int32, dgram int32) { /* getnameinfo.c:87:13: */
  3211. Xabort(tls) //TODO-
  3212. // unsigned long svport;
  3213. // char line[128], *p, *z;
  3214. // unsigned char _buf[1032];
  3215. // FILE _f, *f = __fopen_rb_ca("/etc/services", &_f, _buf, sizeof _buf);
  3216. // if (!f) return;
  3217. // while (fgets(line, sizeof line, f)) {
  3218. // if ((p=strchr(line, '#'))) *p++='\n', *p=0;
  3219. // for (p=line; *p && !isspace(*p); p++);
  3220. // if (!*p) continue;
  3221. // *p++ = 0;
  3222. // svport = strtoul(p, &z, 10);
  3223. // if (svport != port || z==p) continue;
  3224. // if (dgram && strncmp(z, "/udp", 4)) continue;
  3225. // if (!dgram && strncmp(z, "/tcp", 4)) continue;
  3226. // if (p-line > 32) continue;
  3227. // memcpy(buf, line, p-line);
  3228. // break;
  3229. // }
  3230. // __fclose_ca(f);
  3231. }
  3232. 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: */
  3233. if __ccgo_strace {
  3234. 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))
  3235. }
  3236. bp := tls.Alloc(347)
  3237. defer tls.Free(347)
  3238. // var ptr [78]int8 at bp, 78
  3239. // var buf [256]int8 at bp+78, 256
  3240. // var num [13]int8 at bp+334, 13
  3241. var af int32 = int32((*sockaddr)(unsafe.Pointer(sa1)).Fsa_family)
  3242. var a uintptr
  3243. var scopeid uint32
  3244. switch af {
  3245. case 2:
  3246. a = sa1 + 4
  3247. if uint64(sl) < uint64(unsafe.Sizeof(sockaddr_in{})) {
  3248. return -6
  3249. }
  3250. mkptr4(tls, bp, a)
  3251. scopeid = uint32(0)
  3252. break
  3253. case 10:
  3254. a = sa1 + 8
  3255. if uint64(sl) < uint64(unsafe.Sizeof(sockaddr_in6{})) {
  3256. return -6
  3257. }
  3258. if Xmemcmp(tls, a, ts+90, uint64(12)) != 0 {
  3259. mkptr6(tls, bp, a)
  3260. } else {
  3261. mkptr4(tls, bp, a+uintptr(12))
  3262. }
  3263. scopeid = (*sockaddr_in6)(unsafe.Pointer(sa1)).Fsin6_scope_id
  3264. break
  3265. default:
  3266. return -6
  3267. }
  3268. if node != 0 && nodelen != 0 {
  3269. *(*int8)(unsafe.Pointer(bp + 78)) = int8(0)
  3270. if !(flags&0x01 != 0) {
  3271. reverse_hosts(tls, bp+78, a, scopeid, af)
  3272. }
  3273. if !(int32(*(*int8)(unsafe.Pointer(bp + 78))) != 0) && !(flags&0x01 != 0) {
  3274. Xabort(tls) //TODO-
  3275. // unsigned char query[18+PTR_MAX], reply[512];
  3276. // int qlen = __res_mkquery(0, ptr, 1, RR_PTR,
  3277. // 0, 0, 0, query, sizeof query);
  3278. // query[3] = 0; /* don't need AD flag */
  3279. // int rlen = __res_send(query, qlen, reply, sizeof reply);
  3280. // buf[0] = 0;
  3281. // if (rlen > 0)
  3282. // __dns_parse(reply, rlen, dns_parse_callback, buf);
  3283. }
  3284. if !(int32(*(*int8)(unsafe.Pointer(bp + 78))) != 0) {
  3285. if flags&0x08 != 0 {
  3286. return -2
  3287. }
  3288. Xinet_ntop(tls, af, a, bp+78, uint32(unsafe.Sizeof([256]int8{})))
  3289. if scopeid != 0 {
  3290. Xabort(tls) //TODO-
  3291. // char *p = 0, tmp[IF_NAMESIZE+1];
  3292. // if (!(flags & NI_NUMERICSCOPE) &&
  3293. // (IN6_IS_ADDR_LINKLOCAL(a) ||
  3294. // IN6_IS_ADDR_MC_LINKLOCAL(a)))
  3295. // p = if_indextoname(scopeid, tmp+1);
  3296. // if (!p)
  3297. // p = itoa(num, scopeid);
  3298. // *--p = '%';
  3299. // strcat(buf, p);
  3300. }
  3301. }
  3302. if Xstrlen(tls, bp+78) >= size_t(nodelen) {
  3303. return -12
  3304. }
  3305. Xstrcpy(tls, node, bp+78)
  3306. }
  3307. if serv != 0 && servlen != 0 {
  3308. var p uintptr = bp + 78 /* buf */
  3309. var port int32 = int32(Xntohs(tls, (*sockaddr_in)(unsafe.Pointer(sa1)).Fsin_port))
  3310. *(*int8)(unsafe.Pointer(bp + 78)) = int8(0)
  3311. if !(flags&0x02 != 0) {
  3312. reverse_services(tls, bp+78, port, flags&0x10)
  3313. }
  3314. if !(int32(*(*int8)(unsafe.Pointer(p))) != 0) {
  3315. p = itoa(tls, bp+334, uint32(port))
  3316. }
  3317. if Xstrlen(tls, p) >= size_t(servlen) {
  3318. return -12
  3319. }
  3320. Xstrcpy(tls, serv, p)
  3321. }
  3322. return 0
  3323. }
  3324. var Xh_errno int32 /* h_errno.c:4:5: */
  3325. func X__h_errno_location(tls *TLS) uintptr { /* h_errno.c:6:5: */
  3326. if __ccgo_strace {
  3327. trc("tls=%v, (%v:)", tls, origin(2))
  3328. }
  3329. return uintptr(unsafe.Pointer(&Xh_errno))
  3330. }
  3331. func X__inet_aton(tls *TLS, s0 uintptr, dest uintptr) int32 { /* inet_aton.c:7:5: */
  3332. if __ccgo_strace {
  3333. trc("tls=%v s0=%v dest=%v, (%v:)", tls, s0, dest, origin(2))
  3334. }
  3335. bp := tls.Alloc(40)
  3336. defer tls.Free(40)
  3337. var s uintptr = s0
  3338. var d uintptr = dest
  3339. *(*[4]uint64)(unsafe.Pointer(bp /* a */)) = [4]uint64{0: uint64(0)}
  3340. // var z uintptr at bp+32, 8
  3341. var i int32
  3342. for i = 0; i < 4; i++ {
  3343. *(*uint64)(unsafe.Pointer(bp + uintptr(i)*8)) = Xstrtoul(tls, s, bp+32, 0)
  3344. 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 {
  3345. if 0 != 0 {
  3346. return Xisdigit(tls, int32(*(*int8)(unsafe.Pointer(s))))
  3347. }
  3348. return Bool32(uint32(*(*int8)(unsafe.Pointer(s)))-uint32('0') < uint32(10))
  3349. }() != 0) {
  3350. return 0
  3351. }
  3352. if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32))))) != 0) {
  3353. break
  3354. }
  3355. s = *(*uintptr)(unsafe.Pointer(bp + 32)) + uintptr(1)
  3356. }
  3357. if i == 4 {
  3358. return 0
  3359. }
  3360. switch i {
  3361. case 0:
  3362. *(*uint64)(unsafe.Pointer(bp + 1*8)) = *(*uint64)(unsafe.Pointer(bp)) & uint64(0xffffff)
  3363. AssignShrPtrUint64(bp, int(24))
  3364. fallthrough
  3365. case 1:
  3366. *(*uint64)(unsafe.Pointer(bp + 2*8)) = *(*uint64)(unsafe.Pointer(bp + 1*8)) & uint64(0xffff)
  3367. AssignShrPtrUint64(bp+1*8, int(16))
  3368. fallthrough
  3369. case 2:
  3370. *(*uint64)(unsafe.Pointer(bp + 3*8)) = *(*uint64)(unsafe.Pointer(bp + 2*8)) & uint64(0xff)
  3371. AssignShrPtrUint64(bp+2*8, int(8))
  3372. }
  3373. for i = 0; i < 4; i++ {
  3374. if *(*uint64)(unsafe.Pointer(bp + uintptr(i)*8)) > uint64(255) {
  3375. return 0
  3376. }
  3377. *(*uint8)(unsafe.Pointer(d + uintptr(i))) = uint8(*(*uint64)(unsafe.Pointer(bp + uintptr(i)*8)))
  3378. }
  3379. return 1
  3380. }
  3381. func Xinet_ntop(tls *TLS, af int32, a0 uintptr, s uintptr, l socklen_t) uintptr { /* inet_ntop.c:7:12: */
  3382. if __ccgo_strace {
  3383. trc("tls=%v af=%v a0=%v s=%v l=%v, (%v:)", tls, af, a0, s, l, origin(2))
  3384. }
  3385. bp := tls.Alloc(276)
  3386. defer tls.Free(276)
  3387. var a uintptr = a0
  3388. var i int32
  3389. var j int32
  3390. var max int32
  3391. var best int32
  3392. // var buf [100]int8 at bp+176, 100
  3393. switch af {
  3394. case 2:
  3395. 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 {
  3396. return s
  3397. }
  3398. break
  3399. case 10:
  3400. if Xmemcmp(tls, a, ts+90, uint64(12)) != 0 {
  3401. Xsnprintf(tls, bp+176, uint64(unsafe.Sizeof([100]int8{})),
  3402. ts+115,
  3403. 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))),
  3404. 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))),
  3405. 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))),
  3406. 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)))))
  3407. } else {
  3408. Xsnprintf(tls, bp+176, uint64(unsafe.Sizeof([100]int8{})),
  3409. ts+139,
  3410. 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))),
  3411. 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))),
  3412. 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))),
  3413. int32(*(*uint8)(unsafe.Pointer(a + 12))), int32(*(*uint8)(unsafe.Pointer(a + 13))), int32(*(*uint8)(unsafe.Pointer(a + 14))), int32(*(*uint8)(unsafe.Pointer(a + 15)))))
  3414. }
  3415. // Replace longest /(^0|:)[:0]{2,}/ with "::"
  3416. i = AssignInt32(&best, 0)
  3417. max = 2
  3418. for ; *(*int8)(unsafe.Pointer(bp + 176 + uintptr(i))) != 0; i++ {
  3419. if i != 0 && int32(*(*int8)(unsafe.Pointer(bp + 176 + uintptr(i)))) != ':' {
  3420. continue
  3421. }
  3422. j = int32(Xstrspn(tls, bp+176+uintptr(i), ts+169))
  3423. if j > max {
  3424. best = i
  3425. max = j
  3426. }
  3427. }
  3428. if max > 3 {
  3429. *(*int8)(unsafe.Pointer(bp + 176 + uintptr(best))) = AssignPtrInt8(bp+176+uintptr(best+1), int8(':'))
  3430. Xmemmove(tls, bp+176+uintptr(best)+uintptr(2), bp+176+uintptr(best)+uintptr(max), uint64(i-best-max+1))
  3431. }
  3432. if Xstrlen(tls, bp+176) < size_t(l) {
  3433. Xstrcpy(tls, s, bp+176)
  3434. return s
  3435. }
  3436. break
  3437. default:
  3438. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 97
  3439. return uintptr(0)
  3440. }
  3441. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 28
  3442. return uintptr(0)
  3443. }
  3444. func hexval(tls *TLS, c uint32) int32 { /* inet_pton.c:7:12: */
  3445. if c-uint32('0') < uint32(10) {
  3446. return int32(c - uint32('0'))
  3447. }
  3448. c = c | uint32(32)
  3449. if c-uint32('a') < uint32(6) {
  3450. return int32(c - uint32('a') + uint32(10))
  3451. }
  3452. return -1
  3453. }
  3454. func Xinet_pton(tls *TLS, af int32, s uintptr, a0 uintptr) int32 { /* inet_pton.c:15:5: */
  3455. if __ccgo_strace {
  3456. trc("tls=%v af=%v s=%v a0=%v, (%v:)", tls, af, s, a0, origin(2))
  3457. }
  3458. bp := tls.Alloc(16)
  3459. defer tls.Free(16)
  3460. // var ip [8]uint16_t at bp, 16
  3461. var a uintptr = a0
  3462. var i int32
  3463. var j int32
  3464. var v int32
  3465. var d int32
  3466. var brk int32 = -1
  3467. var need_v4 int32 = 0
  3468. if af == 2 {
  3469. for i = 0; i < 4; i++ {
  3470. for v = AssignInt32(&j, 0); j < 3 && func() int32 {
  3471. if 0 != 0 {
  3472. return Xisdigit(tls, int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))))
  3473. }
  3474. return Bool32(uint32(*(*int8)(unsafe.Pointer(s + uintptr(j))))-uint32('0') < uint32(10))
  3475. }() != 0; j++ {
  3476. v = 10*v + int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) - '0'
  3477. }
  3478. if j == 0 || j > 1 && int32(*(*int8)(unsafe.Pointer(s))) == '0' || v > 255 {
  3479. return 0
  3480. }
  3481. *(*uint8)(unsafe.Pointer(a + uintptr(i))) = uint8(v)
  3482. if int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) == 0 && i == 3 {
  3483. return 1
  3484. }
  3485. if int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) != '.' {
  3486. return 0
  3487. }
  3488. s += uintptr(j + 1)
  3489. }
  3490. return 0
  3491. } else if af != 10 {
  3492. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 97
  3493. return -1
  3494. }
  3495. if int32(*(*int8)(unsafe.Pointer(s))) == ':' && int32(*(*int8)(unsafe.Pointer(PreIncUintptr(&s, 1)))) != ':' {
  3496. return 0
  3497. }
  3498. for i = 0; ; i++ {
  3499. if int32(*(*int8)(unsafe.Pointer(s))) == ':' && brk < 0 {
  3500. brk = i
  3501. *(*uint16_t)(unsafe.Pointer(bp + uintptr(i&7)*2)) = uint16_t(0)
  3502. if !(int32(*(*int8)(unsafe.Pointer(PreIncUintptr(&s, 1)))) != 0) {
  3503. break
  3504. }
  3505. if i == 7 {
  3506. return 0
  3507. }
  3508. continue
  3509. }
  3510. for v = AssignInt32(&j, 0); j < 4 && AssignInt32(&d, hexval(tls, uint32(*(*int8)(unsafe.Pointer(s + uintptr(j)))))) >= 0; j++ {
  3511. v = 16*v + d
  3512. }
  3513. if j == 0 {
  3514. return 0
  3515. }
  3516. *(*uint16_t)(unsafe.Pointer(bp + uintptr(i&7)*2)) = uint16_t(v)
  3517. if !(int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) != 0) && (brk >= 0 || i == 7) {
  3518. break
  3519. }
  3520. if i == 7 {
  3521. return 0
  3522. }
  3523. if int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) != ':' {
  3524. if int32(*(*int8)(unsafe.Pointer(s + uintptr(j)))) != '.' || i < 6 && brk < 0 {
  3525. return 0
  3526. }
  3527. need_v4 = 1
  3528. i++
  3529. break
  3530. }
  3531. s += uintptr(j + 1)
  3532. }
  3533. if brk >= 0 {
  3534. Xmemmove(tls, bp+uintptr(brk)*2+uintptr(7)*2-uintptr(i)*2, bp+uintptr(brk)*2, uint64(2*(i+1-brk)))
  3535. for j = 0; j < 7-i; j++ {
  3536. *(*uint16_t)(unsafe.Pointer(bp + uintptr(brk+j)*2)) = uint16_t(0)
  3537. }
  3538. }
  3539. for j = 0; j < 8; j++ {
  3540. *(*uint8)(unsafe.Pointer(PostIncUintptr(&a, 1))) = uint8(int32(*(*uint16_t)(unsafe.Pointer(bp + uintptr(j)*2))) >> 8)
  3541. *(*uint8)(unsafe.Pointer(PostIncUintptr(&a, 1))) = uint8(*(*uint16_t)(unsafe.Pointer(bp + uintptr(j)*2)))
  3542. }
  3543. if need_v4 != 0 && Xinet_pton(tls, 2, s, a-uintptr(4)) <= 0 {
  3544. return 0
  3545. }
  3546. return 1
  3547. }
  3548. func X__lookup_ipliteral(tls *TLS, buf uintptr, name uintptr, family int32) int32 { /* lookup_ipliteral.c:12:5: */
  3549. if __ccgo_strace {
  3550. trc("tls=%v buf=%v name=%v family=%v, (%v:)", tls, buf, name, family, origin(2))
  3551. }
  3552. bp := tls.Alloc(96)
  3553. defer tls.Free(96)
  3554. // var a4 in_addr at bp, 4
  3555. // var a6 in6_addr at bp+68, 16
  3556. if X__inet_aton(tls, name, bp) > 0 {
  3557. if family == 10 { // wrong family
  3558. return -2
  3559. }
  3560. Xmemcpy(tls, buf+8, bp, uint64(unsafe.Sizeof(in_addr{})))
  3561. (*address)(unsafe.Pointer(buf)).Ffamily = 2
  3562. (*address)(unsafe.Pointer(buf)).Fscopeid = uint32(0)
  3563. return 1
  3564. }
  3565. // var tmp [64]int8 at bp+4, 64
  3566. var p uintptr = Xstrchr(tls, name, '%')
  3567. // var z uintptr at bp+88, 8
  3568. var scopeid uint64 = uint64(0)
  3569. if p != 0 && (int64(p)-int64(name))/1 < int64(64) {
  3570. Xmemcpy(tls, bp+4, name, uint64((int64(p)-int64(name))/1))
  3571. *(*int8)(unsafe.Pointer(bp + 4 + uintptr((int64(p)-int64(name))/1))) = int8(0)
  3572. name = bp + 4 /* &tmp[0] */
  3573. }
  3574. if Xinet_pton(tls, 10, name, bp+68) <= 0 {
  3575. return 0
  3576. }
  3577. if family == 2 { // wrong family
  3578. return -2
  3579. }
  3580. Xmemcpy(tls, buf+8, bp+68, uint64(unsafe.Sizeof(in6_addr{})))
  3581. (*address)(unsafe.Pointer(buf)).Ffamily = 10
  3582. if p != 0 {
  3583. if func() int32 {
  3584. if 0 != 0 {
  3585. return Xisdigit(tls, int32(*(*int8)(unsafe.Pointer(PreIncUintptr(&p, 1)))))
  3586. }
  3587. return Bool32(uint32(*(*int8)(unsafe.Pointer(PreIncUintptr(&p, 1))))-uint32('0') < uint32(10))
  3588. }() != 0 {
  3589. scopeid = Xstrtoull(tls, p, bp+88, 10)
  3590. } else {
  3591. *(*uintptr)(unsafe.Pointer(bp + 88 /* z */)) = p - uintptr(1)
  3592. }
  3593. if *(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 88)))) != 0 {
  3594. Xabort(tls) //TODO-
  3595. // if (!IN6_IS_ADDR_LINKLOCAL(&a6) &&
  3596. // !IN6_IS_ADDR_MC_LINKLOCAL(&a6))
  3597. // return EAI_NONAME;
  3598. // scopeid = if_nametoindex(p);
  3599. // if (!scopeid) return EAI_NONAME;
  3600. }
  3601. if scopeid > uint64(0xffffffff) {
  3602. return -2
  3603. }
  3604. }
  3605. (*address)(unsafe.Pointer(buf)).Fscopeid = uint32(scopeid)
  3606. return 1
  3607. }
  3608. type mode_t = uint32 /* alltypes.h:152:18 */
  3609. type flock = struct {
  3610. Fl_type int16
  3611. Fl_whence int16
  3612. F__ccgo_pad1 [4]byte
  3613. Fl_start off_t
  3614. Fl_len off_t
  3615. Fl_pid pid_t
  3616. F__ccgo_pad2 [4]byte
  3617. } /* fcntl.h:24:1 */
  3618. func is_valid_hostname(tls *TLS, host uintptr) int32 { /* lookup_name.c:18:12: */
  3619. var s uintptr
  3620. //TODO if (strnlen(host, 255)-1 >= 254 || mbstowcs(0, host, 0) == -1) return 0;
  3621. if Xstrnlen(tls, host, uint64(255))-uint64(1) >= uint64(254) {
  3622. return 0
  3623. }
  3624. 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++ {
  3625. }
  3626. return BoolInt32(!(*(*uint8)(unsafe.Pointer(s)) != 0))
  3627. }
  3628. var Xzero_struct_address address /* lookup_name.c:27:16: */
  3629. func name_from_null(tls *TLS, buf uintptr, name uintptr, family int32, flags int32) int32 { /* lookup_name.c:29:12: */
  3630. var cnt int32 = 0
  3631. if name != 0 {
  3632. return 0
  3633. }
  3634. if flags&0x01 != 0 {
  3635. //TODO if (family != AF_INET6)
  3636. //TODO buf[cnt++] = (struct address){ .family = AF_INET };
  3637. if family != 10 {
  3638. var x = Xzero_struct_address
  3639. x.Ffamily = 2
  3640. *(*address)(unsafe.Pointer(buf + uintptr(PostIncInt32(&cnt, 1))*28)) = x
  3641. }
  3642. //TODO if (family != AF_INET)
  3643. //TODO buf[cnt++] = (struct address){ .family = AF_INET6 };
  3644. if family != 2 {
  3645. var x = Xzero_struct_address
  3646. x.Ffamily = 10
  3647. *(*address)(unsafe.Pointer(buf + uintptr(PostIncInt32(&cnt, 1))*28)) = x
  3648. }
  3649. } else {
  3650. Xabort(tls) //TODO-
  3651. // if (family != AF_INET6)
  3652. // buf[cnt++] = (struct address){ .family = AF_INET, .addr = { 127,0,0,1 } };
  3653. // if (family != AF_INET)
  3654. // buf[cnt++] = (struct address){ .family = AF_INET6, .addr = { [15] = 1 } };
  3655. }
  3656. return cnt
  3657. }
  3658. func name_from_numeric(tls *TLS, buf uintptr, name uintptr, family int32) int32 { /* lookup_name.c:58:12: */
  3659. return X__lookup_ipliteral(tls, buf, name, family)
  3660. }
  3661. func name_from_hosts(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32) int32 { /* lookup_name.c:63:12: */
  3662. bp := tls.Alloc(512)
  3663. defer tls.Free(512)
  3664. // var line [512]int8 at bp, 512
  3665. var l size_t = Xstrlen(tls, name)
  3666. var cnt int32 = 0
  3667. var badfam int32 = 0
  3668. var _buf [1032]uint8
  3669. _ = _buf
  3670. //TODO FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf);
  3671. var _f FILE
  3672. _ = _f
  3673. var f uintptr = Xfopen(tls, ts+76, ts+87)
  3674. if !(f != 0) {
  3675. switch *(*int32)(unsafe.Pointer(X___errno_location(tls))) {
  3676. case 2:
  3677. fallthrough
  3678. case 20:
  3679. fallthrough
  3680. case 13:
  3681. return 0
  3682. fallthrough
  3683. default:
  3684. return -11
  3685. }
  3686. }
  3687. for Xfgets(tls, bp, int32(unsafe.Sizeof([512]int8{})), f) != 0 && cnt < 48 {
  3688. var p uintptr
  3689. var z uintptr
  3690. if AssignUintptr(&p, Xstrchr(tls, bp, '#')) != 0 {
  3691. *(*int8)(unsafe.Pointer(PostIncUintptr(&p, 1))) = int8('\n')
  3692. *(*int8)(unsafe.Pointer(p)) = int8(0)
  3693. }
  3694. 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++ {
  3695. }
  3696. if !(p != 0) {
  3697. continue
  3698. }
  3699. // Isolate IP address to parse
  3700. for p = bp; /* &line[0] */ *(*int8)(unsafe.Pointer(p)) != 0 && !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(p)))) != 0); p++ {
  3701. }
  3702. *(*int8)(unsafe.Pointer(PostIncUintptr(&p, 1))) = int8(0)
  3703. switch name_from_numeric(tls, buf+uintptr(cnt)*28, bp, family) {
  3704. case 1:
  3705. cnt++
  3706. break
  3707. case 0:
  3708. continue
  3709. default:
  3710. badfam = -2
  3711. continue
  3712. }
  3713. // Extract first name as canonical name
  3714. for ; *(*int8)(unsafe.Pointer(p)) != 0 && __isspace(tls, int32(*(*int8)(unsafe.Pointer(p)))) != 0; p++ {
  3715. }
  3716. for z = p; *(*int8)(unsafe.Pointer(z)) != 0 && !(__isspace(tls, int32(*(*int8)(unsafe.Pointer(z)))) != 0); z++ {
  3717. }
  3718. *(*int8)(unsafe.Pointer(z)) = int8(0)
  3719. if is_valid_hostname(tls, p) != 0 {
  3720. Xmemcpy(tls, canon, p, uint64((int64(z)-int64(p))/1+int64(1)))
  3721. }
  3722. }
  3723. //TODO __fclose_ca(f);
  3724. Xfclose(tls, f)
  3725. if cnt != 0 {
  3726. return cnt
  3727. }
  3728. return badfam
  3729. }
  3730. type dpc_ctx = struct {
  3731. Faddrs uintptr
  3732. Fcanon uintptr
  3733. Fcnt int32
  3734. F__ccgo_pad1 [4]byte
  3735. } /* lookup_name.c:112:1 */
  3736. func name_from_dns_search(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32) int32 { /* lookup_name.c:191:12: */
  3737. return -1 //TODO-
  3738. Xabort(tls)
  3739. return int32(0) //TODO-
  3740. // char search[256];
  3741. // struct resolvconf conf;
  3742. // size_t l, dots;
  3743. // char *p, *z;
  3744. // if (__get_resolv_conf(&conf, search, sizeof search) < 0) return -1;
  3745. // /* Count dots, suppress search when >=ndots or name ends in
  3746. // * a dot, which is an explicit request for global scope. */
  3747. // for (dots=l=0; name[l]; l++) if (name[l]=='.') dots++;
  3748. // if (dots >= conf.ndots || name[l-1]=='.') *search = 0;
  3749. // /* Strip final dot for canon, fail if multiple trailing dots. */
  3750. // if (name[l-1]=='.') l--;
  3751. // if (!l || name[l-1]=='.') return EAI_NONAME;
  3752. // /* This can never happen; the caller already checked length. */
  3753. // if (l >= 256) return EAI_NONAME;
  3754. // /* Name with search domain appended is setup in canon[]. This both
  3755. // * provides the desired default canonical name (if the requested
  3756. // * name is not a CNAME record) and serves as a buffer for passing
  3757. // * the full requested name to name_from_dns. */
  3758. // memcpy(canon, name, l);
  3759. // canon[l] = '.';
  3760. // for (p=search; *p; p=z) {
  3761. // for (; isspace(*p); p++);
  3762. // for (z=p; *z && !isspace(*z); z++);
  3763. // if (z==p) break;
  3764. // if (z-p < 256 - l - 1) {
  3765. // memcpy(canon+l+1, p, z-p);
  3766. // canon[z-p+1+l] = 0;
  3767. // int cnt = name_from_dns(buf, canon, canon, family, &conf);
  3768. // if (cnt) return cnt;
  3769. // }
  3770. // }
  3771. // canon[l] = 0;
  3772. // return name_from_dns(buf, canon, name, family, &conf);
  3773. }
  3774. type policy = struct {
  3775. Faddr [16]uint8
  3776. Flen uint8
  3777. Fmask uint8
  3778. Fprec uint8
  3779. Flabel uint8
  3780. } /* lookup_name.c:237:14 */
  3781. var defpolicy = [6]policy{
  3782. {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 172)), Flen: uint8(15), Fmask: uint8(0xff), Fprec: uint8(50)},
  3783. {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 189)), Flen: uint8(11), Fmask: uint8(0xff), Fprec: uint8(35), Flabel: uint8(4)},
  3784. {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 205)), Flen: uint8(1), Fmask: uint8(0xff), Fprec: uint8(30), Flabel: uint8(2)},
  3785. {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 221)), Flen: uint8(3), Fmask: uint8(0xff), Fprec: uint8(5), Flabel: uint8(5)},
  3786. {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 237)), Fmask: uint8(0xfe), Fprec: uint8(3), Flabel: uint8(13)},
  3787. // Last rule must match all addresses to stop loop.
  3788. {Faddr: *(*[16]uint8)(unsafe.Pointer(ts + 253)), Fprec: uint8(40), Flabel: uint8(1)},
  3789. } /* lookup_name.c:241:3 */
  3790. func policyof(tls *TLS, a uintptr) uintptr { /* lookup_name.c:259:28: */
  3791. var i int32
  3792. for i = 0; ; i++ {
  3793. if Xmemcmp(tls, a, uintptr(unsafe.Pointer(&defpolicy))+uintptr(i)*20, uint64(defpolicy[i].Flen)) != 0 {
  3794. continue
  3795. }
  3796. if int32(*(*uint8_t)(unsafe.Pointer(a + uintptr(defpolicy[i].Flen))))&int32(defpolicy[i].Fmask) !=
  3797. int32(*(*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(&defpolicy)) + uintptr(i)*20 + uintptr(defpolicy[i].Flen)))) {
  3798. continue
  3799. }
  3800. return uintptr(unsafe.Pointer(&defpolicy)) + uintptr(i)*20
  3801. }
  3802. return uintptr(0)
  3803. }
  3804. func labelof(tls *TLS, a uintptr) int32 { /* lookup_name.c:272:12: */
  3805. return int32((*policy)(unsafe.Pointer(policyof(tls, a))).Flabel)
  3806. }
  3807. func scopeof(tls *TLS, a uintptr) int32 { /* lookup_name.c:277:12: */
  3808. if int32(*(*uint8_t)(unsafe.Pointer(a))) == 0xff {
  3809. return int32(*(*uint8_t)(unsafe.Pointer(a + 1))) & 15
  3810. }
  3811. if int32(*(*uint8_t)(unsafe.Pointer(a))) == 0xfe && int32(*(*uint8_t)(unsafe.Pointer(a + 1)))&0xc0 == 0x80 {
  3812. return 2
  3813. }
  3814. 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 {
  3815. return 2
  3816. }
  3817. if int32(*(*uint8_t)(unsafe.Pointer(a))) == 0xfe && int32(*(*uint8_t)(unsafe.Pointer(a + 1)))&0xc0 == 0xc0 {
  3818. return 5
  3819. }
  3820. return 14
  3821. }
  3822. func prefixmatch(tls *TLS, s uintptr, d uintptr) int32 { /* lookup_name.c:286:12: */
  3823. // FIXME: The common prefix length should be limited to no greater
  3824. // than the nominal length of the prefix portion of the source
  3825. // address. However the definition of the source prefix length is
  3826. // not clear and thus this limiting is not yet implemented.
  3827. var i uint32
  3828. 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++ {
  3829. }
  3830. return int32(i)
  3831. }
  3832. func addrcmp(tls *TLS, _a uintptr, _b uintptr) int32 { /* lookup_name.c:305:12: */
  3833. var a uintptr = _a
  3834. var b uintptr = _b
  3835. return (*address)(unsafe.Pointer(b)).Fsortkey - (*address)(unsafe.Pointer(a)).Fsortkey
  3836. }
  3837. func X__lookup_name(tls *TLS, buf uintptr, canon uintptr, name uintptr, family int32, flags int32) int32 { /* lookup_name.c:311:5: */
  3838. if __ccgo_strace {
  3839. trc("tls=%v buf=%v canon=%v name=%v family=%v flags=%v, (%v:)", tls, buf, canon, name, family, flags, origin(2))
  3840. }
  3841. bp := tls.Alloc(92)
  3842. defer tls.Free(92)
  3843. var cnt int32 = 0
  3844. var i int32
  3845. var j int32
  3846. _ = j
  3847. *(*int8)(unsafe.Pointer(canon)) = int8(0)
  3848. if name != 0 {
  3849. // reject empty name and check len so it fits into temp bufs
  3850. var l size_t = Xstrnlen(tls, name, uint64(255))
  3851. if l-uint64(1) >= uint64(254) {
  3852. return -2
  3853. }
  3854. Xmemcpy(tls, canon, name, l+uint64(1))
  3855. }
  3856. // Procedurally, a request for v6 addresses with the v4-mapped
  3857. // flag set is like a request for unspecified family, followed
  3858. // by filtering of the results.
  3859. if flags&0x08 != 0 {
  3860. if family == 10 {
  3861. family = 0
  3862. } else {
  3863. flags = flags - 0x08
  3864. }
  3865. }
  3866. // Try each backend until there's at least one result.
  3867. cnt = name_from_null(tls, buf, name, family, flags)
  3868. if !(cnt != 0) {
  3869. cnt = name_from_numeric(tls, buf, name, family)
  3870. }
  3871. if !(cnt != 0) && !(flags&0x04 != 0) {
  3872. cnt = name_from_hosts(tls, buf, canon, name, family)
  3873. if !(cnt != 0) {
  3874. cnt = name_from_dns_search(tls, buf, canon, name, family)
  3875. }
  3876. }
  3877. if cnt <= 0 {
  3878. if cnt != 0 {
  3879. return cnt
  3880. }
  3881. return -2
  3882. }
  3883. // Filter/transform results for v4-mapped lookup, if requested.
  3884. if flags&0x08 != 0 {
  3885. Xabort(tls) //TODO-
  3886. // if (!(flags & AI_ALL)) {
  3887. // /* If any v6 results exist, remove v4 results. */
  3888. // for (i=0; i<cnt && buf[i].family != AF_INET6; i++);
  3889. // if (i<cnt) {
  3890. // for (j=0; i<cnt; i++) {
  3891. // if (buf[i].family == AF_INET6)
  3892. // buf[j++] = buf[i];
  3893. // }
  3894. // cnt = i = j;
  3895. // }
  3896. // }
  3897. // /* Translate any remaining v4 results to v6 */
  3898. // for (i=0; i<cnt; i++) {
  3899. // if (buf[i].family != AF_INET) continue;
  3900. // memcpy(buf[i].addr+12, buf[i].addr, 4);
  3901. // memcpy(buf[i].addr, "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
  3902. // buf[i].family = AF_INET6;
  3903. // }
  3904. }
  3905. // No further processing is needed if there are fewer than 2
  3906. // results or if there are only IPv4 results.
  3907. if cnt < 2 || family == 2 {
  3908. return cnt
  3909. }
  3910. for i = 0; i < cnt; i++ {
  3911. if (*address)(unsafe.Pointer(buf+uintptr(i)*28)).Ffamily != 2 {
  3912. break
  3913. }
  3914. }
  3915. if i == cnt {
  3916. return cnt
  3917. }
  3918. var cs int32
  3919. _ = cs
  3920. //TODO pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
  3921. // The following implements a subset of RFC 3484/6724 destination
  3922. // address selection by generating a single 31-bit sort key for
  3923. // each address. Rules 3, 4, and 7 are omitted for having
  3924. // excessive runtime and code size cost and dubious benefit.
  3925. // So far the label/precedence table cannot be customized.
  3926. for i = 0; i < cnt; i++ {
  3927. var family int32 = (*address)(unsafe.Pointer(buf + uintptr(i)*28)).Ffamily
  3928. var key int32 = 0
  3929. *(*sockaddr_in6)(unsafe.Pointer(bp + 28 /* sa6 */)) = sockaddr_in6{}
  3930. *(*sockaddr_in6)(unsafe.Pointer(bp /* da6 */)) = sockaddr_in6{Fsin6_family: sa_family_t(10), Fsin6_port: in_port_t(65535), Fsin6_scope_id: (*address)(unsafe.Pointer(buf + uintptr(i)*28)).Fscopeid}
  3931. *(*sockaddr_in)(unsafe.Pointer(bp + 72 /* sa4 */)) = sockaddr_in{}
  3932. *(*sockaddr_in)(unsafe.Pointer(bp + 56 /* da4 */)) = sockaddr_in{Fsin_family: sa_family_t(2), Fsin_port: in_port_t(65535)}
  3933. var sa1 uintptr
  3934. var da uintptr
  3935. // var salen socklen_t at bp+88, 4
  3936. var dalen socklen_t
  3937. if family == 10 {
  3938. Xmemcpy(tls, bp+8, buf+uintptr(i)*28+8, uint64(16))
  3939. da = bp /* &da6 */
  3940. dalen = socklen_t(unsafe.Sizeof(sockaddr_in6{}))
  3941. sa1 = bp + 28 /* &sa6 */
  3942. *(*socklen_t)(unsafe.Pointer(bp + 88 /* salen */)) = socklen_t(unsafe.Sizeof(sockaddr_in6{}))
  3943. } else {
  3944. Xmemcpy(tls, bp+28+8,
  3945. ts+90, uint64(12))
  3946. Xmemcpy(tls, bp+8+uintptr(12), buf+uintptr(i)*28+8, uint64(4))
  3947. Xmemcpy(tls, bp+8,
  3948. ts+90, uint64(12))
  3949. Xmemcpy(tls, bp+8+uintptr(12), buf+uintptr(i)*28+8, uint64(4))
  3950. Xmemcpy(tls, bp+56+4, buf+uintptr(i)*28+8, uint64(4))
  3951. da = bp + 56 /* &da4 */
  3952. dalen = socklen_t(unsafe.Sizeof(sockaddr_in{}))
  3953. sa1 = bp + 72 /* &sa4 */
  3954. *(*socklen_t)(unsafe.Pointer(bp + 88 /* salen */)) = socklen_t(unsafe.Sizeof(sockaddr_in{}))
  3955. }
  3956. var dpolicy uintptr = policyof(tls, bp+8)
  3957. var dscope int32 = scopeof(tls, bp+8)
  3958. var dlabel int32 = int32((*policy)(unsafe.Pointer(dpolicy)).Flabel)
  3959. var dprec int32 = int32((*policy)(unsafe.Pointer(dpolicy)).Fprec)
  3960. var prefixlen int32 = 0
  3961. var fd int32 = Xsocket(tls, family, 2|02000000, 17)
  3962. if fd >= 0 {
  3963. if !(Xconnect(tls, fd, da, dalen) != 0) {
  3964. key = key | 0x40000000
  3965. if !(Xgetsockname(tls, fd, sa1, bp+88) != 0) {
  3966. if family == 2 {
  3967. Xmemcpy(tls,
  3968. bp+28+8+uintptr(12),
  3969. bp+72+4, uint64(4))
  3970. }
  3971. if dscope == scopeof(tls, bp+28+8) {
  3972. key = key | 0x20000000
  3973. }
  3974. if dlabel == labelof(tls, bp+28+8) {
  3975. key = key | 0x10000000
  3976. }
  3977. prefixlen = prefixmatch(tls, bp+28+8,
  3978. bp+8)
  3979. }
  3980. }
  3981. Xclose(tls, fd)
  3982. }
  3983. key = key | dprec<<20
  3984. key = key | (15-dscope)<<16
  3985. key = key | prefixlen<<8
  3986. key = key | (48-i)<<0
  3987. (*address)(unsafe.Pointer(buf + uintptr(i)*28)).Fsortkey = key
  3988. }
  3989. Xqsort(tls, buf, uint64(cnt), uint64(unsafe.Sizeof(address{})), *(*uintptr)(unsafe.Pointer(&struct {
  3990. f func(*TLS, uintptr, uintptr) int32
  3991. }{addrcmp})))
  3992. //TODO pthread_setcancelstate(cs, 0);
  3993. return cnt
  3994. }
  3995. func X__lookup_serv(tls *TLS, buf uintptr, name uintptr, proto int32, socktype int32, flags int32) int32 { /* lookup_serv.c:12:5: */
  3996. if __ccgo_strace {
  3997. trc("tls=%v buf=%v name=%v proto=%v socktype=%v flags=%v, (%v:)", tls, buf, name, proto, socktype, flags, origin(2))
  3998. }
  3999. bp := tls.Alloc(8)
  4000. defer tls.Free(8)
  4001. var line [128]int8
  4002. _ = line
  4003. var cnt int32 = 0
  4004. var p uintptr
  4005. _ = p
  4006. *(*uintptr)(unsafe.Pointer(bp /* z */)) = ts + 13 /* "" */
  4007. var port uint64 = uint64(0)
  4008. switch socktype {
  4009. case 1:
  4010. switch proto {
  4011. case 0:
  4012. proto = 6
  4013. fallthrough
  4014. case 6:
  4015. break
  4016. default:
  4017. return -8
  4018. }
  4019. break
  4020. case 2:
  4021. switch proto {
  4022. case 0:
  4023. proto = 17
  4024. fallthrough
  4025. case 17:
  4026. break
  4027. default:
  4028. return -8
  4029. }
  4030. fallthrough
  4031. case 0:
  4032. break
  4033. default:
  4034. if name != 0 {
  4035. return -8
  4036. }
  4037. (*service)(unsafe.Pointer(buf)).Fport = uint16_t(0)
  4038. (*service)(unsafe.Pointer(buf)).Fproto = uint8(proto)
  4039. (*service)(unsafe.Pointer(buf)).Fsocktype = uint8(socktype)
  4040. return 1
  4041. }
  4042. if name != 0 {
  4043. if !(int32(*(*int8)(unsafe.Pointer(name))) != 0) {
  4044. return -8
  4045. }
  4046. port = Xstrtoul(tls, name, bp, 10)
  4047. }
  4048. if !(int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp))))) != 0) {
  4049. if port > uint64(65535) {
  4050. return -8
  4051. }
  4052. if proto != 17 {
  4053. (*service)(unsafe.Pointer(buf + uintptr(cnt)*4)).Fport = uint16_t(port)
  4054. (*service)(unsafe.Pointer(buf + uintptr(cnt)*4)).Fsocktype = uint8(1)
  4055. (*service)(unsafe.Pointer(buf + uintptr(PostIncInt32(&cnt, 1))*4)).Fproto = uint8(6)
  4056. }
  4057. if proto != 6 {
  4058. (*service)(unsafe.Pointer(buf + uintptr(cnt)*4)).Fport = uint16_t(port)
  4059. (*service)(unsafe.Pointer(buf + uintptr(cnt)*4)).Fsocktype = uint8(2)
  4060. (*service)(unsafe.Pointer(buf + uintptr(PostIncInt32(&cnt, 1))*4)).Fproto = uint8(17)
  4061. }
  4062. return cnt
  4063. }
  4064. if flags&0x400 != 0 {
  4065. return -2
  4066. }
  4067. var l size_t = Xstrlen(tls, name)
  4068. _ = l
  4069. Xabort(tls) //TODO-
  4070. // unsigned char _buf[1032];
  4071. // FILE _f, *f = __fopen_rb_ca("/etc/services", &_f, _buf, sizeof _buf);
  4072. // if (!f) switch (errno) {
  4073. // case ENOENT:
  4074. // case ENOTDIR:
  4075. // case EACCES:
  4076. // return EAI_SERVICE;
  4077. // default:
  4078. // return EAI_SYSTEM;
  4079. // }
  4080. Xabort(tls) //TODO-
  4081. // while (fgets(line, sizeof line, f) && cnt < MAXSERVS) {
  4082. // if ((p=strchr(line, '#'))) *p++='\n', *p=0;
  4083. // /* Find service name */
  4084. // for(p=line; (p=strstr(p, name)); p++) {
  4085. // if (p>line && !isspace(p[-1])) continue;
  4086. // if (p[l] && !isspace(p[l])) continue;
  4087. // break;
  4088. // }
  4089. // if (!p) continue;
  4090. // /* Skip past canonical name at beginning of line */
  4091. // for (p=line; *p && !isspace(*p); p++);
  4092. // port = strtoul(p, &z, 10);
  4093. // if (port > 65535 || z==p) continue;
  4094. // if (!strncmp(z, "/udp", 4)) {
  4095. // if (proto == IPPROTO_TCP) continue;
  4096. // buf[cnt].port = port;
  4097. // buf[cnt].socktype = SOCK_DGRAM;
  4098. // buf[cnt++].proto = IPPROTO_UDP;
  4099. // }
  4100. // if (!strncmp(z, "/tcp", 4)) {
  4101. // if (proto == IPPROTO_UDP) continue;
  4102. // buf[cnt].port = port;
  4103. // buf[cnt].socktype = SOCK_STREAM;
  4104. // buf[cnt++].proto = IPPROTO_TCP;
  4105. // }
  4106. // }
  4107. // __fclose_ca(f);
  4108. // return cnt > 0 ? cnt : EAI_SERVICE;
  4109. Xabort(tls)
  4110. return int32(0) //TODO-
  4111. }
  4112. func temper(tls *TLS, x uint32) uint32 { /* rand_r.c:3:17: */
  4113. x = x ^ x>>11
  4114. x = x ^ x<<7&0x9D2C5680
  4115. x = x ^ x<<15&0xEFC60000
  4116. x = x ^ x>>18
  4117. return x
  4118. }
  4119. func Xrand_r(tls *TLS, seed uintptr) int32 { /* rand_r.c:12:5: */
  4120. if __ccgo_strace {
  4121. trc("tls=%v seed=%v, (%v:)", tls, seed, origin(2))
  4122. }
  4123. return int32(temper(tls, AssignPtrUint32(seed, *(*uint32)(unsafe.Pointer(seed))*uint32(1103515245)+uint32(12345))) / uint32(2))
  4124. }
  4125. func X__toread(tls *TLS, f uintptr) int32 { /* __toread.c:3:5: */
  4126. if __ccgo_strace {
  4127. trc("tls=%v f=%v, (%v:)", tls, f, origin(2))
  4128. }
  4129. *(*int32)(unsafe.Pointer(f + 136)) |= (*FILE)(unsafe.Pointer(f)).Fmode - 1
  4130. if (*FILE)(unsafe.Pointer(f)).Fwpos != (*FILE)(unsafe.Pointer(f)).Fwbase {
  4131. (*struct {
  4132. f func(*TLS, uintptr, uintptr, size_t) size_t
  4133. })(unsafe.Pointer(&struct{ uintptr }{(*FILE)(unsafe.Pointer(f)).Fwrite})).f(tls, f, uintptr(0), uint64(0))
  4134. }
  4135. (*FILE)(unsafe.Pointer(f)).Fwpos = AssignPtrUintptr(f+56, AssignPtrUintptr(f+32, uintptr(0)))
  4136. if (*FILE)(unsafe.Pointer(f)).Fflags&uint32(4) != 0 {
  4137. *(*uint32)(unsafe.Pointer(f)) |= uint32(32)
  4138. return -1
  4139. }
  4140. (*FILE)(unsafe.Pointer(f)).Frpos = AssignPtrUintptr(f+16, (*FILE)(unsafe.Pointer(f)).Fbuf+uintptr((*FILE)(unsafe.Pointer(f)).Fbuf_size))
  4141. if (*FILE)(unsafe.Pointer(f)).Fflags&uint32(16) != 0 {
  4142. return -1
  4143. }
  4144. return 0
  4145. }
  4146. func X__toread_needs_stdio_exit(tls *TLS) { /* __toread.c:16:13: */
  4147. if __ccgo_strace {
  4148. trc("tls=%v, (%v:)", tls, origin(2))
  4149. }
  4150. X__builtin_abort(tls) //TODO-
  4151. // __stdio_exit_needed();
  4152. }
  4153. // This function assumes it will never be called if there is already
  4154. // data buffered for reading.
  4155. func X__uflow(tls *TLS, f uintptr) int32 { /* __uflow.c:6:5: */
  4156. if __ccgo_strace {
  4157. trc("tls=%v f=%v, (%v:)", tls, f, origin(2))
  4158. }
  4159. bp := tls.Alloc(1)
  4160. defer tls.Free(1)
  4161. // var c uint8 at bp, 1
  4162. if !(X__toread(tls, f) != 0) && (*struct {
  4163. f func(*TLS, uintptr, uintptr, size_t) size_t
  4164. })(unsafe.Pointer(&struct{ uintptr }{(*FILE)(unsafe.Pointer(f)).Fread})).f(tls, f, bp, uint64(1)) == uint64(1) {
  4165. return int32(*(*uint8)(unsafe.Pointer(bp)))
  4166. }
  4167. return -1
  4168. }
  4169. func Xbsearch(tls *TLS, key uintptr, base uintptr, nel size_t, width size_t, cmp uintptr) uintptr { /* bsearch.c:3:6: */
  4170. if __ccgo_strace {
  4171. trc("tls=%v key=%v base=%v nel=%v width=%v cmp=%v, (%v:)", tls, key, base, nel, width, cmp, origin(2))
  4172. }
  4173. var try uintptr
  4174. var sign int32
  4175. for nel > uint64(0) {
  4176. try = base + uintptr(width*(nel/uint64(2)))
  4177. sign = (*struct {
  4178. f func(*TLS, uintptr, uintptr) int32
  4179. })(unsafe.Pointer(&struct{ uintptr }{cmp})).f(tls, key, try)
  4180. if sign < 0 {
  4181. nel = nel / uint64(2)
  4182. } else if sign > 0 {
  4183. base = try + uintptr(width)
  4184. nel = nel - (nel/uint64(2) + uint64(1))
  4185. } else {
  4186. return try
  4187. }
  4188. }
  4189. return uintptr(0)
  4190. }
  4191. func strtox(tls *TLS, s uintptr, p uintptr, prec int32) float64 { /* strtod.c:6:20: */
  4192. bp := tls.Alloc(232)
  4193. defer tls.Free(232)
  4194. // var f FILE at bp, 232
  4195. (*FILE)(unsafe.Pointer(bp)).Fbuf = AssignPtrUintptr(bp+8, s)
  4196. (*FILE)(unsafe.Pointer(bp)).Frend = UintptrFromInt32(-1)
  4197. X__shlim(tls, bp, int64(0))
  4198. var y float64 = X__floatscan(tls, bp, prec, 1)
  4199. var cnt off_t = (*FILE)(unsafe.Pointer(bp)).Fshcnt + (int64((*FILE)(unsafe.Pointer(bp)).Frpos)-int64((*FILE)(unsafe.Pointer(bp)).Fbuf))/1
  4200. if p != 0 {
  4201. *(*uintptr)(unsafe.Pointer(p)) = func() uintptr {
  4202. if cnt != 0 {
  4203. return s + uintptr(cnt)
  4204. }
  4205. return s
  4206. }()
  4207. }
  4208. return y
  4209. }
  4210. func Xstrtof(tls *TLS, s uintptr, p uintptr) float32 { /* strtod.c:17:7: */
  4211. if __ccgo_strace {
  4212. trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2))
  4213. }
  4214. return float32(strtox(tls, s, p, 0))
  4215. }
  4216. func Xstrtod(tls *TLS, s uintptr, p uintptr) float64 { /* strtod.c:22:8: */
  4217. if __ccgo_strace {
  4218. trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2))
  4219. }
  4220. return strtox(tls, s, p, 1)
  4221. }
  4222. func Xstrtold(tls *TLS, s uintptr, p uintptr) float64 { /* strtod.c:27:13: */
  4223. if __ccgo_strace {
  4224. trc("tls=%v s=%v p=%v, (%v:)", tls, s, p, origin(2))
  4225. }
  4226. return strtox(tls, s, p, 2)
  4227. }
  4228. func strtox1(tls *TLS, s uintptr, p uintptr, base int32, lim uint64) uint64 { /* strtol.c:8:27: */
  4229. bp := tls.Alloc(232)
  4230. defer tls.Free(232)
  4231. // var f FILE at bp, 232
  4232. (*FILE)(unsafe.Pointer(bp)).Fbuf = AssignPtrUintptr(bp+8, s)
  4233. (*FILE)(unsafe.Pointer(bp)).Frend = UintptrFromInt32(-1)
  4234. X__shlim(tls, bp, int64(0))
  4235. var y uint64 = X__intscan(tls, bp, uint32(base), 1, lim)
  4236. if p != 0 {
  4237. var cnt size_t = size_t((*FILE)(unsafe.Pointer(bp)).Fshcnt + (int64((*FILE)(unsafe.Pointer(bp)).Frpos)-int64((*FILE)(unsafe.Pointer(bp)).Fbuf))/1)
  4238. *(*uintptr)(unsafe.Pointer(p)) = s + uintptr(cnt)
  4239. }
  4240. return y
  4241. }
  4242. func Xstrtoull(tls *TLS, s uintptr, p uintptr, base int32) uint64 { /* strtol.c:21:20: */
  4243. if __ccgo_strace {
  4244. trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2))
  4245. }
  4246. return strtox1(tls, s, p, base, 2*uint64(0x7fffffffffffffff)+uint64(1))
  4247. }
  4248. func Xstrtoll(tls *TLS, s uintptr, p uintptr, base int32) int64 { /* strtol.c:26:11: */
  4249. if __ccgo_strace {
  4250. trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2))
  4251. }
  4252. return int64(strtox1(tls, s, p, base, Uint64FromInt64(-0x7fffffffffffffff-int64(1))))
  4253. }
  4254. func Xstrtoul(tls *TLS, s uintptr, p uintptr, base int32) uint64 { /* strtol.c:31:15: */
  4255. if __ccgo_strace {
  4256. trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2))
  4257. }
  4258. return uint64(strtox1(tls, s, p, base, 2*uint64(0x7fffffffffffffff)+uint64(1)))
  4259. }
  4260. func Xstrtol(tls *TLS, s uintptr, p uintptr, base int32) int64 { /* strtol.c:36:6: */
  4261. if __ccgo_strace {
  4262. trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2))
  4263. }
  4264. return int64(strtox1(tls, s, p, base, 0+Uint64FromInt64(Int64(-Int64(0x7fffffffffffffff))-Int64FromInt32(1))))
  4265. }
  4266. func Xstrtoimax(tls *TLS, s uintptr, p uintptr, base int32) intmax_t { /* strtol.c:41:10: */
  4267. if __ccgo_strace {
  4268. trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2))
  4269. }
  4270. return intmax_t(Xstrtoll(tls, s, p, base))
  4271. }
  4272. func Xstrtoumax(tls *TLS, s uintptr, p uintptr, base int32) uintmax_t { /* strtol.c:46:11: */
  4273. if __ccgo_strace {
  4274. trc("tls=%v s=%v p=%v base=%v, (%v:)", tls, s, p, base, origin(2))
  4275. }
  4276. return uintmax_t(Xstrtoull(tls, s, p, base))
  4277. }
  4278. // Support signed or unsigned plain-char
  4279. // Implementation choices...
  4280. // Arbitrary numbers...
  4281. // POSIX/SUS requirements follow. These numbers come directly
  4282. // from SUS and have nothing to do with the host system.
  4283. func X__strchrnul(tls *TLS, s uintptr, c int32) uintptr { /* strchrnul.c:10:6: */
  4284. if __ccgo_strace {
  4285. trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2))
  4286. }
  4287. c = int32(uint8(c))
  4288. if !(c != 0) {
  4289. return s + uintptr(Xstrlen(tls, s))
  4290. }
  4291. var w uintptr
  4292. for ; uintptr_t(s)%uintptr_t(unsafe.Sizeof(size_t(0))) != 0; s++ {
  4293. if !(int32(*(*int8)(unsafe.Pointer(s))) != 0) || int32(*(*uint8)(unsafe.Pointer(s))) == c {
  4294. return s
  4295. }
  4296. }
  4297. var k size_t = Uint64(Uint64FromInt32(-1)) / uint64(255) * size_t(c)
  4298. for w = s; !((*(*uint64)(unsafe.Pointer(w))-Uint64(Uint64FromInt32(-1))/uint64(255)) & ^*(*uint64)(unsafe.Pointer(w)) & (Uint64(Uint64FromInt32(-1))/uint64(255)*uint64(255/2+1)) != 0) && !((*(*uint64)(unsafe.Pointer(w))^k-Uint64(Uint64FromInt32(-1))/uint64(255)) & ^(*(*uint64)(unsafe.Pointer(w))^k) & (Uint64(Uint64FromInt32(-1))/uint64(255)*uint64(255/2+1)) != 0); w += 8 {
  4299. }
  4300. s = w
  4301. for ; *(*int8)(unsafe.Pointer(s)) != 0 && int32(*(*uint8)(unsafe.Pointer(s))) != c; s++ {
  4302. }
  4303. return s
  4304. }
  4305. func Xstrdup(tls *TLS, s uintptr) uintptr { /* strdup.c:4:6: */
  4306. if __ccgo_strace {
  4307. trc("tls=%v s=%v, (%v:)", tls, s, origin(2))
  4308. }
  4309. var l size_t = Xstrlen(tls, s)
  4310. var d uintptr = Xmalloc(tls, l+uint64(1))
  4311. if !(d != 0) {
  4312. return uintptr(0)
  4313. }
  4314. return Xmemcpy(tls, d, s, l+uint64(1))
  4315. }
  4316. func Xstrlcat(tls *TLS, d uintptr, s uintptr, n size_t) size_t { /* strlcat.c:4:8: */
  4317. if __ccgo_strace {
  4318. trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2))
  4319. }
  4320. var l size_t = Xstrnlen(tls, d, n)
  4321. if l == n {
  4322. return l + Xstrlen(tls, s)
  4323. }
  4324. return l + Xstrlcpy(tls, d+uintptr(l), s, n-l)
  4325. }
  4326. // Support signed or unsigned plain-char
  4327. // Implementation choices...
  4328. // Arbitrary numbers...
  4329. // POSIX/SUS requirements follow. These numbers come directly
  4330. // from SUS and have nothing to do with the host system.
  4331. func Xstrlcpy(tls *TLS, d uintptr, s uintptr, n size_t) size_t { /* strlcpy.c:11:8: */
  4332. if __ccgo_strace {
  4333. trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2))
  4334. }
  4335. var d0 uintptr
  4336. var wd uintptr
  4337. var ws uintptr
  4338. d0 = d
  4339. if !!(int32(PostDecUint64(&n, 1)) != 0) {
  4340. goto __1
  4341. }
  4342. goto finish
  4343. __1:
  4344. ;
  4345. if !(uintptr_t(s)&(uint64(unsafe.Sizeof(size_t(0)))-uint64(1)) == uintptr_t(d)&(uint64(unsafe.Sizeof(size_t(0)))-uint64(1))) {
  4346. goto __2
  4347. }
  4348. __3:
  4349. if !(uintptr_t(s)&(uint64(unsafe.Sizeof(size_t(0)))-uint64(1)) != 0 && n != 0 && AssignPtrInt8(d, *(*int8)(unsafe.Pointer(s))) != 0) {
  4350. goto __5
  4351. }
  4352. goto __4
  4353. __4:
  4354. n--
  4355. s++
  4356. d++
  4357. goto __3
  4358. goto __5
  4359. __5:
  4360. ;
  4361. if !(n != 0 && *(*int8)(unsafe.Pointer(s)) != 0) {
  4362. goto __6
  4363. }
  4364. wd = d
  4365. ws = s
  4366. __7:
  4367. 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)) {
  4368. goto __9
  4369. }
  4370. *(*size_t)(unsafe.Pointer(wd)) = *(*uint64)(unsafe.Pointer(ws))
  4371. goto __8
  4372. __8:
  4373. n = n - size_t(unsafe.Sizeof(size_t(0)))
  4374. ws += 8
  4375. wd += 8
  4376. goto __7
  4377. goto __9
  4378. __9:
  4379. ;
  4380. d = wd
  4381. s = ws
  4382. __6:
  4383. ;
  4384. __2:
  4385. ;
  4386. __10:
  4387. if !(n != 0 && AssignPtrInt8(d, *(*int8)(unsafe.Pointer(s))) != 0) {
  4388. goto __12
  4389. }
  4390. goto __11
  4391. __11:
  4392. n--
  4393. s++
  4394. d++
  4395. goto __10
  4396. goto __12
  4397. __12:
  4398. ;
  4399. *(*int8)(unsafe.Pointer(d)) = int8(0)
  4400. finish:
  4401. return size_t((int64(d)-int64(d0))/1) + Xstrlen(tls, s)
  4402. }
  4403. func Xstrncasecmp(tls *TLS, _l uintptr, _r uintptr, n size_t) int32 { /* strncasecmp.c:4:5: */
  4404. if __ccgo_strace {
  4405. trc("tls=%v _l=%v _r=%v n=%v, (%v:)", tls, _l, _r, n, origin(2))
  4406. }
  4407. var l uintptr = _l
  4408. var r uintptr = _r
  4409. if !(int32(PostDecUint64(&n, 1)) != 0) {
  4410. return 0
  4411. }
  4412. __1:
  4413. 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)))))) {
  4414. goto __3
  4415. }
  4416. goto __2
  4417. __2:
  4418. l++
  4419. r++
  4420. n--
  4421. goto __1
  4422. goto __3
  4423. __3:
  4424. ;
  4425. return Xtolower(tls, int32(*(*uint8)(unsafe.Pointer(l)))) - Xtolower(tls, int32(*(*uint8)(unsafe.Pointer(r))))
  4426. }
  4427. func X__strncasecmp_l(tls *TLS, l uintptr, r uintptr, n size_t, loc locale_t) int32 { /* strncasecmp.c:12:5: */
  4428. if __ccgo_strace {
  4429. trc("tls=%v l=%v r=%v n=%v loc=%v, (%v:)", tls, l, r, n, loc, origin(2))
  4430. }
  4431. return Xstrncasecmp(tls, l, r, n)
  4432. }
  4433. func Xstrncat(tls *TLS, d uintptr, s uintptr, n size_t) uintptr { /* strncat.c:3:6: */
  4434. if __ccgo_strace {
  4435. trc("tls=%v d=%v s=%v n=%v, (%v:)", tls, d, s, n, origin(2))
  4436. }
  4437. var a uintptr = d
  4438. d += uintptr(Xstrlen(tls, d))
  4439. for n != 0 && *(*int8)(unsafe.Pointer(s)) != 0 {
  4440. n--
  4441. *(*int8)(unsafe.Pointer(PostIncUintptr(&d, 1))) = *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1)))
  4442. }
  4443. *(*int8)(unsafe.Pointer(PostIncUintptr(&d, 1))) = int8(0)
  4444. return a
  4445. }
  4446. func Xstrnlen(tls *TLS, s uintptr, n size_t) size_t { /* strnlen.c:3:8: */
  4447. if __ccgo_strace {
  4448. trc("tls=%v s=%v n=%v, (%v:)", tls, s, n, origin(2))
  4449. }
  4450. var p uintptr = Xmemchr(tls, s, 0, n)
  4451. if p != 0 {
  4452. return uint64((int64(p) - int64(s)) / 1)
  4453. }
  4454. return n
  4455. }
  4456. func Xstrspn(tls *TLS, s uintptr, c uintptr) size_t { /* strspn.c:6:8: */
  4457. if __ccgo_strace {
  4458. trc("tls=%v s=%v c=%v, (%v:)", tls, s, c, origin(2))
  4459. }
  4460. bp := tls.Alloc(32)
  4461. defer tls.Free(32)
  4462. var a uintptr = s
  4463. *(*[4]size_t)(unsafe.Pointer(bp /* byteset */)) = [4]size_t{0: uint64(0)}
  4464. if !(int32(*(*int8)(unsafe.Pointer(c))) != 0) {
  4465. return uint64(0)
  4466. }
  4467. if !(int32(*(*int8)(unsafe.Pointer(c + 1))) != 0) {
  4468. for ; int32(*(*int8)(unsafe.Pointer(s))) == int32(*(*int8)(unsafe.Pointer(c))); s++ {
  4469. }
  4470. return size_t((int64(s) - int64(a)) / 1)
  4471. }
  4472. 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++ {
  4473. }
  4474. 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++ {
  4475. }
  4476. return size_t((int64(s) - int64(a)) / 1)
  4477. }
  4478. func Xstrtok(tls *TLS, s uintptr, sep uintptr) uintptr { /* strtok.c:3:6: */
  4479. if __ccgo_strace {
  4480. trc("tls=%v s=%v sep=%v, (%v:)", tls, s, sep, origin(2))
  4481. }
  4482. if !(s != 0) && !(int32(AssignUintptr(&s, _sp)) != 0) {
  4483. return uintptr(0)
  4484. }
  4485. s += uintptr(Xstrspn(tls, s, sep))
  4486. if !(int32(*(*int8)(unsafe.Pointer(s))) != 0) {
  4487. return AssignPtrUintptr(uintptr(unsafe.Pointer(&_sp)), uintptr(0))
  4488. }
  4489. _sp = s + uintptr(Xstrcspn(tls, s, sep))
  4490. if *(*int8)(unsafe.Pointer(_sp)) != 0 {
  4491. *(*int8)(unsafe.Pointer(PostIncUintptr(&_sp, 1))) = int8(0)
  4492. } else {
  4493. _sp = uintptr(0)
  4494. }
  4495. return s
  4496. }
  4497. var _sp uintptr /* strtok.c:5:14: */
  4498. func init() {
  4499. *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&X_CurrentRuneLocale)) + 0)) = uintptr(unsafe.Pointer(&X_DefaultRuneLocale)) // table.c:1940:35:
  4500. *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&X_CurrentRuneLocale)) + 0)) = uintptr(unsafe.Pointer(&X_DefaultRuneLocale)) // table.c:1940:35:
  4501. }
  4502. 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"
  4503. var ts = (*reflect.StringHeader)(unsafe.Pointer(&ts1)).Data