musl_openbsd_386.go 125 KB

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