musl_openbsd_amd64.go 121 KB

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