musl_darwin_arm64.go 147 KB

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