musl_windows_arm64.go 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  1. // Code generated by 'ccgo -D__environ=environ -export-externs X -hide __syscall0,__syscall1,__syscall2,__syscall3,__syscall4,__syscall5,__syscall6 -nostdinc -nostdlib -o ../musl_windows_arm64.go -pkgname libc -static-locals-prefix _s -Iarch\aarch64 -Iarch/generic -Iobj/src/internal -Isrc/include -Isrc/internal -Iobj/include -Iinclude copyright.c src/ctype/isalnum.c src/ctype/isalpha.c src/ctype/isdigit.c src/ctype/islower.c src/ctype/isprint.c src/ctype/isspace.c src/ctype/isxdigit.c src/env/putenv.c src/env/setenv.c src/env/unsetenv.c src/multibyte/wcrtomb.c src/multibyte/wcsrtombs.c src/multibyte/wcstombs.c src/stdlib/bsearch.c src/string/strchrnul.c src/string/strdup.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 ( /* pthread_impl.h:58:1: */
  210. DT_EXITING = 0
  211. DT_JOINABLE = 1
  212. DT_DETACHED = 2
  213. )
  214. type ptrdiff_t = int64 /* <builtin>:3:26 */
  215. type size_t = uint64 /* <builtin>:9:23 */
  216. type wchar_t = uint16 /* <builtin>:15:24 */
  217. type va_list = uintptr /* <builtin>:50:27 */
  218. type __locale_struct = struct{ cat [6]uintptr } /* alltypes.h:351:9 */
  219. type locale_t = uintptr /* alltypes.h:351:32 */
  220. func Xisalnum(tls *TLS, c int32) int32 { /* isalnum.c:3:5: */
  221. return Bool32(func() int32 {
  222. if 0 != 0 {
  223. return Xisalpha(tls, c)
  224. }
  225. return Bool32(uint32(c)|uint32(32)-uint32('a') < uint32(26))
  226. }() != 0 || func() int32 {
  227. if 0 != 0 {
  228. return Xisdigit(tls, c)
  229. }
  230. return Bool32(uint32(c)-uint32('0') < uint32(10))
  231. }() != 0)
  232. }
  233. func X__isalnum_l(tls *TLS, c int32, l locale_t) int32 { /* isalnum.c:8:5: */
  234. return Xisalnum(tls, c)
  235. }
  236. func Xisalpha(tls *TLS, c int32) int32 { /* isalpha.c:4:5: */
  237. return Bool32(uint32(c)|uint32(32)-uint32('a') < uint32(26))
  238. }
  239. func X__isalpha_l(tls *TLS, c int32, l locale_t) int32 { /* isalpha.c:9:5: */
  240. return Xisalpha(tls, c)
  241. }
  242. func Xisdigit(tls *TLS, c int32) int32 { /* isdigit.c:4:5: */
  243. return Bool32(uint32(c)-uint32('0') < uint32(10))
  244. }
  245. func X__isdigit_l(tls *TLS, c int32, l locale_t) int32 { /* isdigit.c:9:5: */
  246. return Xisdigit(tls, c)
  247. }
  248. func Xislower(tls *TLS, c int32) int32 { /* islower.c:4:5: */
  249. return Bool32(uint32(c)-uint32('a') < uint32(26))
  250. }
  251. func X__islower_l(tls *TLS, c int32, l locale_t) int32 { /* islower.c:9:5: */
  252. return Xislower(tls, c)
  253. }
  254. func Xisprint(tls *TLS, c int32) int32 { /* isprint.c:4:5: */
  255. return Bool32(uint32(c)-uint32(0x20) < uint32(0x5f))
  256. }
  257. func X__isprint_l(tls *TLS, c int32, l locale_t) int32 { /* isprint.c:9:5: */
  258. return Xisprint(tls, c)
  259. }
  260. func Xisspace(tls *TLS, c int32) int32 { /* isspace.c:4:5: */
  261. return Bool32(c == ' ' || uint32(c)-uint32('\t') < uint32(5))
  262. }
  263. func X__isspace_l(tls *TLS, c int32, l locale_t) int32 { /* isspace.c:9:5: */
  264. return Xisspace(tls, c)
  265. }
  266. func Xisxdigit(tls *TLS, c int32) int32 { /* isxdigit.c:3:5: */
  267. return Bool32(func() int32 {
  268. if 0 != 0 {
  269. return Xisdigit(tls, c)
  270. }
  271. return Bool32(uint32(c)-uint32('0') < uint32(10))
  272. }() != 0 || uint32(c)|uint32(32)-uint32('a') < uint32(6))
  273. }
  274. func X__isxdigit_l(tls *TLS, c int32, l locale_t) int32 { /* isxdigit.c:8:5: */
  275. return Xisxdigit(tls, c)
  276. }
  277. type div_t = struct {
  278. quot int32
  279. rem int32
  280. } /* stdlib.h:62:35 */
  281. type ldiv_t = struct {
  282. quot int32
  283. rem int32
  284. } /* stdlib.h:63:36 */
  285. type lldiv_t = struct {
  286. quot int64
  287. rem int64
  288. } /* stdlib.h:64:41 */
  289. type ssize_t = int32 /* alltypes.h:73:15 */
  290. type intptr_t = int32 /* alltypes.h:78:15 */
  291. type off_t = int32 /* alltypes.h:170:16 */
  292. type pid_t = int32 /* alltypes.h:243:13 */
  293. type uid_t = uint32 /* alltypes.h:253:18 */
  294. type gid_t = uint32 /* alltypes.h:258:18 */
  295. type useconds_t = uint32 /* alltypes.h:268:18 */
  296. func X__putenv(tls *TLS, s uintptr, l size_t, r uintptr) int32 { /* putenv.c:8:5: */
  297. var i size_t
  298. var newenv uintptr
  299. var tmp uintptr
  300. //TODO for (char **e = __environ; *e; e++, i++)
  301. var e uintptr
  302. i = uint64(0)
  303. if !(Environ() != 0) {
  304. goto __1
  305. }
  306. //TODO for (char **e = __environ; *e; e++, i++)
  307. e = Environ()
  308. __2:
  309. if !(*(*uintptr)(unsafe.Pointer(e)) != 0) {
  310. goto __4
  311. }
  312. if !!(Xstrncmp(tls, s, *(*uintptr)(unsafe.Pointer(e)), l+uint64(1)) != 0) {
  313. goto __5
  314. }
  315. tmp = *(*uintptr)(unsafe.Pointer(e))
  316. *(*uintptr)(unsafe.Pointer(e)) = s
  317. X__env_rm_add(tls, tmp, r)
  318. return 0
  319. __5:
  320. ;
  321. goto __3
  322. __3:
  323. e += 8
  324. i++
  325. goto __2
  326. goto __4
  327. __4:
  328. ;
  329. __1:
  330. ;
  331. if !(Environ() == _soldenv) {
  332. goto __6
  333. }
  334. newenv = Xrealloc(tls, _soldenv, uint64(unsafe.Sizeof(uintptr(0)))*(i+uint64(2)))
  335. if !!(newenv != 0) {
  336. goto __8
  337. }
  338. goto oom
  339. __8:
  340. ;
  341. goto __7
  342. __6:
  343. newenv = Xmalloc(tls, uint64(unsafe.Sizeof(uintptr(0)))*(i+uint64(2)))
  344. if !!(newenv != 0) {
  345. goto __9
  346. }
  347. goto oom
  348. __9:
  349. ;
  350. if !(i != 0) {
  351. goto __10
  352. }
  353. Xmemcpy(tls, newenv, Environ(), uint64(unsafe.Sizeof(uintptr(0)))*i)
  354. __10:
  355. ;
  356. Xfree(tls, _soldenv)
  357. __7:
  358. ;
  359. *(*uintptr)(unsafe.Pointer(newenv + uintptr(i)*8)) = s
  360. *(*uintptr)(unsafe.Pointer(newenv + uintptr(i+uint64(1))*8)) = uintptr(0)
  361. *(*uintptr)(unsafe.Pointer(EnvironP())) = AssignPtrUintptr(uintptr(unsafe.Pointer(&_soldenv)), newenv)
  362. if !(r != 0) {
  363. goto __11
  364. }
  365. X__env_rm_add(tls, uintptr(0), r)
  366. __11:
  367. ;
  368. return 0
  369. oom:
  370. Xfree(tls, r)
  371. return -1
  372. }
  373. var _soldenv uintptr /* putenv.c:22:14: */
  374. func Xputenv(tls *TLS, s uintptr) int32 { /* putenv.c:43:5: */
  375. var l size_t = size_t((int64(X__strchrnul(tls, s, '=')) - int64(s)) / 1)
  376. if !(l != 0) || !(int32(*(*int8)(unsafe.Pointer(s + uintptr(l)))) != 0) {
  377. return Xunsetenv(tls, s)
  378. }
  379. return X__putenv(tls, s, l, uintptr(0))
  380. }
  381. func X__env_rm_add(tls *TLS, old uintptr, new uintptr) { /* setenv.c:5:6: */
  382. //TODO for (size_t i=0; i < env_alloced_n; i++)
  383. var i size_t = uint64(0)
  384. for ; i < _senv_alloced_n; i++ {
  385. if *(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8)) == old {
  386. *(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8)) = new
  387. Xfree(tls, old)
  388. return
  389. } else if !(int32(*(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8))) != 0) && new != 0 {
  390. *(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8)) = new
  391. new = uintptr(0)
  392. }
  393. }
  394. if !(new != 0) {
  395. return
  396. }
  397. var t uintptr = Xrealloc(tls, _senv_alloced, uint64(unsafe.Sizeof(uintptr(0)))*(_senv_alloced_n+uint64(1)))
  398. if !(t != 0) {
  399. return
  400. }
  401. *(*uintptr)(unsafe.Pointer(AssignPtrUintptr(uintptr(unsafe.Pointer(&_senv_alloced)), t) + uintptr(PostIncUint64(&_senv_alloced_n, 1))*8)) = new
  402. }
  403. var _senv_alloced uintptr /* setenv.c:7:14: */
  404. var _senv_alloced_n size_t /* setenv.c:8:16: */
  405. func Xsetenv(tls *TLS, var1 uintptr, value uintptr, overwrite int32) int32 { /* setenv.c:26:5: */
  406. var s uintptr
  407. var l1 size_t
  408. var l2 size_t
  409. if !(var1 != 0) || !(int32(AssignUint64(&l1, size_t((int64(X__strchrnul(tls, var1, '='))-int64(var1))/1))) != 0) || *(*int8)(unsafe.Pointer(var1 + uintptr(l1))) != 0 {
  410. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22
  411. return -1
  412. }
  413. if !(overwrite != 0) && Xgetenv(tls, var1) != 0 {
  414. return 0
  415. }
  416. l2 = Xstrlen(tls, value)
  417. s = Xmalloc(tls, l1+l2+uint64(2))
  418. if !(s != 0) {
  419. return -1
  420. }
  421. Xmemcpy(tls, s, var1, l1)
  422. *(*int8)(unsafe.Pointer(s + uintptr(l1))) = int8('=')
  423. Xmemcpy(tls, s+uintptr(l1)+uintptr(1), value, l2+uint64(1))
  424. return X__putenv(tls, s, l1, s)
  425. }
  426. func Xunsetenv(tls *TLS, name uintptr) int32 { /* unsetenv.c:9:5: */
  427. var l size_t = size_t((int64(X__strchrnul(tls, name, '=')) - int64(name)) / 1)
  428. if !(l != 0) || *(*int8)(unsafe.Pointer(name + uintptr(l))) != 0 {
  429. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22
  430. return -1
  431. }
  432. if Environ() != 0 {
  433. var e uintptr = Environ()
  434. var eo uintptr = e
  435. for ; *(*uintptr)(unsafe.Pointer(e)) != 0; e += 8 {
  436. //TODO if (!strncmp(name, *e, l) && l[*e] == '=')
  437. if !(Xstrncmp(tls, name, *(*uintptr)(unsafe.Pointer(e)), l) != 0) && int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(e)) + uintptr(l)))) == '=' {
  438. X__env_rm_add(tls, *(*uintptr)(unsafe.Pointer(e)), uintptr(0))
  439. } else if eo != e {
  440. *(*uintptr)(unsafe.Pointer(PostIncUintptr(&eo, 8))) = *(*uintptr)(unsafe.Pointer(e))
  441. } else {
  442. eo += 8
  443. }
  444. }
  445. if eo != e {
  446. *(*uintptr)(unsafe.Pointer(eo)) = uintptr(0)
  447. }
  448. }
  449. return 0
  450. }
  451. type wint_t = uint32 /* alltypes.h:21:18 */
  452. type wctype_t = uint32 /* alltypes.h:211:23 */
  453. type __mbstate_t = struct {
  454. __opaque1 uint32
  455. __opaque2 uint32
  456. } /* alltypes.h:345:9 */
  457. type mbstate_t = __mbstate_t /* alltypes.h:345:63 */
  458. type tm = struct {
  459. tm_sec int32
  460. tm_min int32
  461. tm_hour int32
  462. tm_mday int32
  463. tm_mon int32
  464. tm_year int32
  465. tm_wday int32
  466. tm_yday int32
  467. tm_isdst int32
  468. tm_gmtoff int32
  469. tm_zone uintptr
  470. } /* wchar.h:138:1 */
  471. type uintptr_t = uint32 /* alltypes.h:63:24 */
  472. type int8_t = int8 /* alltypes.h:104:25 */
  473. type int16_t = int16 /* alltypes.h:109:25 */
  474. type int32_t = int32 /* alltypes.h:114:25 */
  475. type int64_t = int32 /* alltypes.h:119:25 */
  476. type intmax_t = int32 /* alltypes.h:124:25 */
  477. type uint8_t = uint8 /* alltypes.h:129:25 */
  478. type uint16_t = uint16 /* alltypes.h:134:25 */
  479. type uint32_t = uint32 /* alltypes.h:139:25 */
  480. type uint64_t = uint32 /* alltypes.h:144:25 */
  481. type uintmax_t = uint32 /* alltypes.h:154:25 */
  482. type int_fast8_t = int8_t /* stdint.h:22:16 */
  483. type int_fast64_t = int64_t /* stdint.h:23:17 */
  484. type int_least8_t = int8_t /* stdint.h:25:17 */
  485. type int_least16_t = int16_t /* stdint.h:26:17 */
  486. type int_least32_t = int32_t /* stdint.h:27:17 */
  487. type int_least64_t = int64_t /* stdint.h:28:17 */
  488. type uint_fast8_t = uint8_t /* stdint.h:30:17 */
  489. type uint_fast64_t = uint64_t /* stdint.h:31:18 */
  490. type uint_least8_t = uint8_t /* stdint.h:33:18 */
  491. type uint_least16_t = uint16_t /* stdint.h:34:18 */
  492. type uint_least32_t = uint32_t /* stdint.h:35:18 */
  493. type uint_least64_t = uint64_t /* stdint.h:36:18 */
  494. type int_fast16_t = int32_t /* stdint.h:1:17 */
  495. type int_fast32_t = int32_t /* stdint.h:2:17 */
  496. type uint_fast16_t = uint32_t /* stdint.h:3:18 */
  497. type uint_fast32_t = uint32_t /* stdint.h:4:18 */
  498. // Upper 6 state bits are a negative integer offset to bound-check next byte
  499. // equivalent to: ( (b-0x80) | (b+offset) ) & ~0x3f
  500. // Interval [a,b). Either a must be 80 or b must be c0, lower 3 bits clear.
  501. // Arbitrary encoding for representing code units instead of characters.
  502. // Get inline definition of MB_CUR_MAX.
  503. type lconv = struct {
  504. decimal_point uintptr
  505. thousands_sep uintptr
  506. grouping uintptr
  507. int_curr_symbol uintptr
  508. currency_symbol uintptr
  509. mon_decimal_point uintptr
  510. mon_thousands_sep uintptr
  511. mon_grouping uintptr
  512. positive_sign uintptr
  513. negative_sign uintptr
  514. int_frac_digits int8
  515. frac_digits int8
  516. p_cs_precedes int8
  517. p_sep_by_space int8
  518. n_cs_precedes int8
  519. n_sep_by_space int8
  520. p_sign_posn int8
  521. n_sign_posn int8
  522. int_p_cs_precedes int8
  523. int_p_sep_by_space int8
  524. int_n_cs_precedes int8
  525. int_n_sep_by_space int8
  526. int_p_sign_posn int8
  527. int_n_sign_posn int8
  528. _ [2]byte
  529. } /* locale.h:24:1 */
  530. type _G_fpos64_t = struct {
  531. _ [0]uint64
  532. __opaque [16]int8
  533. } /* stdio.h:54:9 */
  534. type fpos_t = _G_fpos64_t /* stdio.h:58:3 */
  535. // Support signed or unsigned plain-char
  536. // Implementation choices...
  537. // Arbitrary numbers...
  538. // POSIX/SUS requirements follow. These numbers come directly
  539. // from SUS and have nothing to do with the host system.
  540. type __locale_map = struct {
  541. __map uintptr
  542. map_size size_t
  543. name [24]int8
  544. next uintptr
  545. } /* alltypes.h:351:9 */
  546. type tls_module = struct {
  547. next uintptr
  548. image uintptr
  549. len size_t
  550. size size_t
  551. align size_t
  552. offset size_t
  553. } /* libc.h:14:1 */
  554. type __libc = struct {
  555. can_do_threads int8
  556. threaded int8
  557. secure int8
  558. need_locks int8
  559. threads_minus_1 int32
  560. auxv uintptr
  561. tls_head uintptr
  562. tls_size size_t
  563. tls_align size_t
  564. tls_cnt size_t
  565. page_size size_t
  566. global_locale struct{ cat [6]uintptr }
  567. } /* libc.h:20:1 */
  568. type time_t = int32 /* alltypes.h:93:16 */
  569. type clockid_t = int32 /* alltypes.h:222:13 */
  570. type timespec = struct {
  571. tv_sec time_t
  572. tv_nsec int32
  573. } /* alltypes.h:237:1 */
  574. type __pthread = struct {
  575. self uintptr
  576. dtv uintptr
  577. prev uintptr
  578. next uintptr
  579. sysinfo uintptr_t
  580. canary uintptr_t
  581. canary2 uintptr_t
  582. tid int32
  583. errno_val int32
  584. detach_state int32
  585. cancel int32
  586. canceldisable uint8
  587. cancelasync uint8
  588. tsd_used uint8 /* unsigned char tsd_used: 1, unsigned char dlerror_flag: 1 */
  589. _ [1]byte
  590. map_base uintptr
  591. map_size size_t
  592. stack uintptr
  593. stack_size size_t
  594. guard_size size_t
  595. result uintptr
  596. cancelbuf uintptr
  597. tsd uintptr
  598. robust_list struct {
  599. head uintptr
  600. off int32
  601. _ [4]byte
  602. pending uintptr
  603. }
  604. timer_id int32
  605. _ [4]byte
  606. locale locale_t
  607. killlock [1]int32
  608. _ [4]byte
  609. dlerror_buf uintptr
  610. stdio_locks uintptr
  611. canary_at_end uintptr_t
  612. _ [4]byte
  613. dtv_copy uintptr
  614. } /* alltypes.h:281:9 */
  615. type pthread_t = uintptr /* alltypes.h:281:26 */
  616. type pthread_once_t = int32 /* alltypes.h:287:13 */
  617. type pthread_key_t = uint32 /* alltypes.h:292:18 */
  618. type pthread_spinlock_t = int32 /* alltypes.h:297:13 */
  619. type pthread_mutexattr_t = struct{ __attr uint32 } /* alltypes.h:302:37 */
  620. type pthread_condattr_t = struct{ __attr uint32 } /* alltypes.h:307:37 */
  621. type pthread_barrierattr_t = struct{ __attr uint32 } /* alltypes.h:312:37 */
  622. type pthread_rwlockattr_t = struct{ __attr [2]uint32 } /* alltypes.h:317:40 */
  623. type __sigset_t = struct{ __bits [32]uint32 } /* alltypes.h:357:9 */
  624. type sigset_t = __sigset_t /* alltypes.h:357:71 */
  625. type pthread_attr_t = struct{ __u struct{ __i [9]int32 } } /* alltypes.h:380:147 */
  626. type pthread_mutex_t = struct {
  627. __u struct {
  628. _ [0]uint64
  629. __i [6]int32
  630. _ [24]byte
  631. }
  632. } /* alltypes.h:385:157 */
  633. type pthread_cond_t = struct {
  634. __u struct {
  635. _ [0]uint64
  636. __i [12]int32
  637. }
  638. } /* alltypes.h:395:112 */
  639. type pthread_rwlock_t = struct {
  640. __u struct {
  641. _ [0]uint64
  642. __i [8]int32
  643. _ [32]byte
  644. }
  645. } /* alltypes.h:405:139 */
  646. type pthread_barrier_t = struct {
  647. __u struct {
  648. _ [0]uint64
  649. __i [5]int32
  650. _ [20]byte
  651. }
  652. } /* alltypes.h:410:137 */
  653. type sched_param = struct {
  654. sched_priority int32
  655. __reserved1 int32
  656. __reserved2 [2]struct {
  657. __reserved1 time_t
  658. __reserved2 int32
  659. }
  660. __reserved3 int32
  661. } /* sched.h:19:1 */
  662. type timer_t = uintptr /* alltypes.h:217:14 */
  663. type clock_t = int32 /* alltypes.h:227:14 */
  664. type itimerspec = struct {
  665. it_interval struct {
  666. tv_sec time_t
  667. tv_nsec int32
  668. }
  669. it_value struct {
  670. tv_sec time_t
  671. tv_nsec int32
  672. }
  673. } /* time.h:80:1 */
  674. type sigevent = struct {
  675. sigev_value struct {
  676. _ [0]uint64
  677. sival_int int32
  678. _ [4]byte
  679. }
  680. sigev_signo int32
  681. sigev_notify int32
  682. sigev_notify_function uintptr
  683. sigev_notify_attributes uintptr
  684. __pad [44]int8
  685. _ [4]byte
  686. } /* time.h:107:1 */
  687. type __ptcb = struct {
  688. __f uintptr
  689. __x uintptr
  690. __next uintptr
  691. } /* alltypes.h:281:9 */
  692. type sigaltstack = struct {
  693. ss_sp uintptr
  694. ss_flags int32
  695. _ [4]byte
  696. ss_size size_t
  697. } /* signal.h:44:9 */
  698. type stack_t = sigaltstack /* signal.h:44:28 */
  699. type greg_t = uint32 /* signal.h:10:23 */
  700. type gregset_t = [34]uint32 /* signal.h:11:23 */
  701. type fpregset_t = struct {
  702. vregs [32]float64
  703. fpsr uint32
  704. fpcr uint32
  705. } /* signal.h:17:3 */
  706. type sigcontext = struct {
  707. fault_address uint32
  708. regs [31]uint32
  709. sp uint32
  710. pc uint32
  711. pstate uint32
  712. _ [4]byte
  713. __reserved [256]float64
  714. } /* signal.h:18:9 */
  715. type mcontext_t = sigcontext /* signal.h:23:3 */
  716. type _aarch64_ctx = struct {
  717. magic uint32
  718. size uint32
  719. } /* signal.h:29:1 */
  720. type fpsimd_context = struct {
  721. head struct {
  722. magic uint32
  723. size uint32
  724. }
  725. fpsr uint32
  726. fpcr uint32
  727. vregs [32]float64
  728. } /* signal.h:33:1 */
  729. type esr_context = struct {
  730. head struct {
  731. magic uint32
  732. size uint32
  733. }
  734. esr uint32
  735. } /* signal.h:39:1 */
  736. type extra_context = struct {
  737. head struct {
  738. magic uint32
  739. size uint32
  740. }
  741. datap uint32
  742. size uint32
  743. __reserved [3]uint32
  744. } /* signal.h:43:1 */
  745. type sve_context = struct {
  746. head struct {
  747. magic uint32
  748. size uint32
  749. }
  750. vl uint16
  751. __reserved [3]uint16
  752. } /* signal.h:49:1 */
  753. type __ucontext = struct {
  754. uc_flags uint32
  755. _ [4]byte
  756. uc_link uintptr
  757. uc_stack stack_t
  758. uc_sigmask sigset_t
  759. uc_mcontext mcontext_t
  760. } /* signal.h:99:9 */
  761. type ucontext_t = __ucontext /* signal.h:105:3 */
  762. type sigval = struct {
  763. _ [0]uint64
  764. sival_int int32
  765. _ [4]byte
  766. } /* time.h:107:1 */
  767. type siginfo_t = struct {
  768. si_signo int32
  769. si_errno int32
  770. si_code int32
  771. _ [4]byte
  772. __si_fields struct {
  773. _ [0]uint64
  774. __pad [116]int8
  775. _ [4]byte
  776. }
  777. } /* signal.h:145:3 */
  778. type sigaction = struct {
  779. __sa_handler struct{ sa_handler uintptr }
  780. sa_mask sigset_t
  781. sa_flags int32
  782. _ [4]byte
  783. sa_restorer uintptr
  784. } /* signal.h:167:1 */
  785. type sig_t = uintptr /* signal.h:251:14 */
  786. type sig_atomic_t = int32 /* signal.h:269:13 */
  787. type mode_t = uint32 /* alltypes.h:160:18 */
  788. type syscall_arg_t = int32 /* syscall.h:22:14 */
  789. func a_ll(tls *TLS, p uintptr) int32 { /* atomic_arch.h:2:19: */
  790. var v int32
  791. panic(`arch\aarch64\atomic_arch.h:5:2: assembler statements not supported`)
  792. return v
  793. }
  794. func a_sc(tls *TLS, p uintptr, v int32) int32 { /* atomic_arch.h:10:19: */
  795. var r int32
  796. panic(`arch\aarch64\atomic_arch.h:13:2: assembler statements not supported`)
  797. return BoolInt32(!(r != 0))
  798. }
  799. func a_barrier(tls *TLS) { /* atomic_arch.h:18:20: */
  800. panic(`arch\aarch64\atomic_arch.h:20:2: assembler statements not supported`)
  801. }
  802. func a_ll_p(tls *TLS, p uintptr) uintptr { /* atomic_arch.h:38:20: */
  803. var v uintptr
  804. panic(`arch\aarch64\atomic_arch.h:41:2: assembler statements not supported`)
  805. return v
  806. }
  807. func a_sc_p(tls *TLS, p uintptr, v uintptr) int32 { /* atomic_arch.h:46:19: */
  808. var r int32
  809. panic(`arch\aarch64\atomic_arch.h:49:2: assembler statements not supported`)
  810. return BoolInt32(!(r != 0))
  811. }
  812. func a_ctz_64(tls *TLS, x uint64_t) int32 { /* atomic_arch.h:68:19: */
  813. panic(`arch\aarch64\atomic_arch.h:70:2: assembler statements not supported`)
  814. return int32(x)
  815. }
  816. func a_fetch_add(tls *TLS, p uintptr, v int32) int32 { /* atomic.h:46:19: */
  817. var old int32
  818. for __ccgo := true; __ccgo; __ccgo = !(a_sc(tls, p, int32(uint32(old)+uint32(v))) != 0) {
  819. old = a_ll(tls, p)
  820. }
  821. return old
  822. }
  823. func a_fetch_and(tls *TLS, p uintptr, v int32) int32 { /* atomic.h:59:19: */
  824. var old int32
  825. for __ccgo := true; __ccgo; __ccgo = !(a_sc(tls, p, old&v) != 0) {
  826. old = a_ll(tls, p)
  827. }
  828. return old
  829. }
  830. func a_fetch_or(tls *TLS, p uintptr, v int32) int32 { /* atomic.h:72:19: */
  831. var old int32
  832. for __ccgo := true; __ccgo; __ccgo = !(a_sc(tls, p, old|v) != 0) {
  833. old = a_ll(tls, p)
  834. }
  835. return old
  836. }
  837. func a_and(tls *TLS, p uintptr, v int32) { /* atomic.h:151:20: */
  838. a_fetch_and(tls, p, v)
  839. }
  840. func a_or(tls *TLS, p uintptr, v int32) { /* atomic.h:159:20: */
  841. a_fetch_or(tls, p, v)
  842. }
  843. func a_or_64(tls *TLS, p uintptr, v uint64_t) { /* atomic.h:220:20: */
  844. bp := tls.Alloc(8)
  845. defer tls.Free(8)
  846. *(*struct {
  847. v uint64_t
  848. _ [4]byte
  849. })(unsafe.Pointer(bp)) = func() (r struct {
  850. v uint64_t
  851. _ [4]byte
  852. }) {
  853. *(*uint64_t)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = v
  854. return r
  855. }()
  856. if *(*uint32_t)(unsafe.Pointer(bp)) != 0 {
  857. a_or(tls, p, int32(*(*uint32_t)(unsafe.Pointer(bp))))
  858. }
  859. if *(*uint32_t)(unsafe.Pointer(bp + 1*4)) != 0 {
  860. a_or(tls, p+uintptr(1)*4, int32(*(*uint32_t)(unsafe.Pointer(bp + 1*4))))
  861. }
  862. }
  863. func a_ctz_32(tls *TLS, x uint32_t) int32 { /* atomic.h:256:19: */
  864. return int32(_sdebruijn32[x&-x*uint32_t(0x076be629)>>27])
  865. }
  866. var _sdebruijn32 = [32]int8{
  867. int8(0), int8(1), int8(23), int8(2), int8(29), int8(24), int8(19), int8(3), int8(30), int8(27), int8(25), int8(11), int8(20), int8(8), int8(4), int8(13),
  868. int8(31), int8(22), int8(28), int8(18), int8(26), int8(10), int8(7), int8(12), int8(21), int8(17), int8(9), int8(6), int8(16), int8(5), int8(15), int8(14),
  869. } /* atomic.h:261:20 */
  870. type __timer = struct {
  871. timerid int32
  872. _ [4]byte
  873. thread pthread_t
  874. } /* pthread_impl.h:64:1 */
  875. func __pthread_self(tls *TLS) uintptr { /* pthread_arch.h:1:30: */
  876. var self uintptr
  877. panic(`arch\aarch64\pthread_arch.h:4:2: assembler statements not supported`)
  878. return self - uintptr(uint64(unsafe.Sizeof(__pthread{})))
  879. }
  880. func Xwcrtomb(tls *TLS, s uintptr, wc wchar_t, st uintptr) size_t { /* wcrtomb.c:6:8: */
  881. if !(s != 0) {
  882. return uint64(1)
  883. }
  884. if uint32(wc) < uint32(0x80) {
  885. *(*int8)(unsafe.Pointer(s)) = int8(wc)
  886. return uint64(1)
  887. } else if func() int32 {
  888. if !!(int32(*(*uintptr)(unsafe.Pointer((*__pthread)(unsafe.Pointer(__pthread_self(tls))).locale))) != 0) {
  889. return 4
  890. }
  891. return 1
  892. }() == 1 {
  893. if !(uint32(wc)-uint32(0xdf80) < uint32(0x80)) {
  894. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 84
  895. return Uint64FromInt32(-1)
  896. }
  897. *(*int8)(unsafe.Pointer(s)) = int8(wc)
  898. return uint64(1)
  899. } else if uint32(wc) < uint32(0x800) {
  900. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0xc0 | int32(wc)>>6)
  901. *(*int8)(unsafe.Pointer(s)) = int8(0x80 | int32(wc)&0x3f)
  902. return uint64(2)
  903. } else if uint32(wc) < uint32(0xd800) || uint32(wc)-uint32(0xe000) < uint32(0x2000) {
  904. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0xe0 | int32(wc)>>12)
  905. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0x80 | int32(wc)>>6&0x3f)
  906. *(*int8)(unsafe.Pointer(s)) = int8(0x80 | int32(wc)&0x3f)
  907. return uint64(3)
  908. } else if uint32(wc)-uint32(0x10000) < uint32(0x100000) {
  909. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0xf0 | int32(wc)>>18)
  910. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0x80 | int32(wc)>>12&0x3f)
  911. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0x80 | int32(wc)>>6&0x3f)
  912. *(*int8)(unsafe.Pointer(s)) = int8(0x80 | int32(wc)&0x3f)
  913. return uint64(4)
  914. }
  915. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 84
  916. return Uint64FromInt32(-1)
  917. }
  918. func Xwcsrtombs(tls *TLS, s uintptr, ws uintptr, n size_t, st uintptr) size_t { /* wcsrtombs.c:3:8: */
  919. bp := tls.Alloc(4)
  920. defer tls.Free(4)
  921. var ws2 uintptr
  922. // var buf [4]int8 at bp, 4
  923. var N size_t = n
  924. var l size_t
  925. if !(s != 0) {
  926. n = uint64(0)
  927. ws2 = *(*uintptr)(unsafe.Pointer(ws))
  928. for ; *(*wchar_t)(unsafe.Pointer(ws2)) != 0; ws2 += 2 {
  929. if uint32(*(*wchar_t)(unsafe.Pointer(ws2))) >= 0x80 {
  930. l = Xwcrtomb(tls, bp, *(*wchar_t)(unsafe.Pointer(ws2)), uintptr(0))
  931. if !(l+uint64(1) != 0) {
  932. return Uint64FromInt32(-1)
  933. }
  934. n = n + l
  935. } else {
  936. n++
  937. }
  938. }
  939. return n
  940. }
  941. for n >= uint64(4) {
  942. if uint32(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))))-1 >= 0x7f {
  943. if !(int32(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws))))) != 0) {
  944. *(*int8)(unsafe.Pointer(s)) = int8(0)
  945. *(*uintptr)(unsafe.Pointer(ws)) = uintptr(0)
  946. return N - n
  947. }
  948. l = Xwcrtomb(tls, s, *(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))), uintptr(0))
  949. if !(l+uint64(1) != 0) {
  950. return Uint64FromInt32(-1)
  951. }
  952. s += uintptr(l)
  953. n = n - l
  954. } else {
  955. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))))
  956. n--
  957. }
  958. *(*uintptr)(unsafe.Pointer(ws)) += 2
  959. }
  960. for n != 0 {
  961. if uint32(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))))-1 >= 0x7f {
  962. if !(int32(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws))))) != 0) {
  963. *(*int8)(unsafe.Pointer(s)) = int8(0)
  964. *(*uintptr)(unsafe.Pointer(ws)) = uintptr(0)
  965. return N - n
  966. }
  967. l = Xwcrtomb(tls, bp, *(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))), uintptr(0))
  968. if !(l+uint64(1) != 0) {
  969. return Uint64FromInt32(-1)
  970. }
  971. if l > n {
  972. return N - n
  973. }
  974. Xwcrtomb(tls, s, *(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))), uintptr(0))
  975. s += uintptr(l)
  976. n = n - l
  977. } else {
  978. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))))
  979. n--
  980. }
  981. *(*uintptr)(unsafe.Pointer(ws)) += 2
  982. }
  983. return N
  984. }
  985. func Xwcstombs(tls *TLS, s uintptr, ws uintptr, n size_t) size_t { /* wcstombs.c:4:8: */
  986. bp := tls.Alloc(8)
  987. defer tls.Free(8)
  988. *(*uintptr)(unsafe.Pointer(bp)) = ws
  989. //TODO return wcsrtombs(s, &(const wchar_t *){ws}, n, 0);
  990. return Xwcsrtombs(tls, s, bp, n, uintptr(0))
  991. }
  992. func Xbsearch(tls *TLS, key uintptr, base uintptr, nel size_t, width size_t, cmp uintptr) uintptr { /* bsearch.c:3:6: */
  993. var try uintptr
  994. var sign int32
  995. for nel > uint64(0) {
  996. try = base + uintptr(width*(nel/uint64(2)))
  997. sign = (*struct {
  998. f func(*TLS, uintptr, uintptr) int32
  999. })(unsafe.Pointer(&struct{ uintptr }{cmp})).f(tls, key, try)
  1000. if sign < 0 {
  1001. nel = nel / uint64(2)
  1002. } else if sign > 0 {
  1003. base = try + uintptr(width)
  1004. nel = nel - (nel/uint64(2) + uint64(1))
  1005. } else {
  1006. return try
  1007. }
  1008. }
  1009. return uintptr(0)
  1010. }
  1011. // Support signed or unsigned plain-char
  1012. // Implementation choices...
  1013. // Arbitrary numbers...
  1014. // POSIX/SUS requirements follow. These numbers come directly
  1015. // from SUS and have nothing to do with the host system.
  1016. func X__strchrnul(tls *TLS, s uintptr, c int32) uintptr { /* strchrnul.c:10:6: */
  1017. c = int32(uint8(c))
  1018. if !(c != 0) {
  1019. return s + uintptr(Xstrlen(tls, s))
  1020. }
  1021. var w uintptr
  1022. for ; uint64(s)%uint64(unsafe.Sizeof(size_t(0))) != 0; s++ {
  1023. if !(int32(*(*int8)(unsafe.Pointer(s))) != 0) || int32(*(*uint8)(unsafe.Pointer(s))) == c {
  1024. return s
  1025. }
  1026. }
  1027. var k size_t = Uint64(Uint64FromInt32(-1)) / uint64(255) * size_t(c)
  1028. 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 {
  1029. }
  1030. s = w
  1031. for ; *(*int8)(unsafe.Pointer(s)) != 0 && int32(*(*uint8)(unsafe.Pointer(s))) != c; s++ {
  1032. }
  1033. return s
  1034. }
  1035. func Xstrdup(tls *TLS, s uintptr) uintptr { /* strdup.c:4:6: */
  1036. var l size_t = Xstrlen(tls, s)
  1037. var d uintptr = Xmalloc(tls, l+uint64(1))
  1038. if !(d != 0) {
  1039. return uintptr(0)
  1040. }
  1041. return Xmemcpy(tls, d, s, l+uint64(1))
  1042. }