musl_openbsd_386.go 120 KB

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