musl_netbsd_arm.go 117 KB

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