musl_netbsd_amd64.go 122 KB

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