musl_netbsd_arm.go 121 KB

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