musl_netbsd_amd64.go 118 KB

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