musl_windows_amd64.go 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121
  1. // Code generated by 'ccgo -D__environ=environ -export-externs X -hide __syscall0,__syscall1,__syscall2,__syscall3,__syscall4,__syscall5,__syscall6 -nostdinc -nostdlib -o ../musl_windows_amd64.go -pkgname libc -static-locals-prefix _s -Iarch\x86_64 -Iarch/generic -Iobj/src/internal -Isrc/include -Isrc/internal -Iobj/include -Iinclude copyright.c 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:343:9 */
  219. type locale_t = uintptr /* alltypes.h:343: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:65:15 */
  290. type intptr_t = int32 /* alltypes.h:70:15 */
  291. type off_t = int32 /* alltypes.h:162:16 */
  292. type pid_t = int32 /* alltypes.h:235:13 */
  293. type uid_t = uint32 /* alltypes.h:245:18 */
  294. type gid_t = uint32 /* alltypes.h:250:18 */
  295. type useconds_t = uint32 /* alltypes.h:260: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:198:18 */
  452. type wctype_t = uint32 /* alltypes.h:203:23 */
  453. type __mbstate_t = struct {
  454. __opaque1 uint32
  455. __opaque2 uint32
  456. } /* alltypes.h:337:9 */
  457. type mbstate_t = __mbstate_t /* alltypes.h:337: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:55:24 */
  472. type int8_t = int8 /* alltypes.h:96:25 */
  473. type int16_t = int16 /* alltypes.h:101:25 */
  474. type int32_t = int32 /* alltypes.h:106:25 */
  475. type int64_t = int32 /* alltypes.h:111:25 */
  476. type intmax_t = int32 /* alltypes.h:116:25 */
  477. type uint8_t = uint8 /* alltypes.h:121:25 */
  478. type uint16_t = uint16 /* alltypes.h:126:25 */
  479. type uint32_t = uint32 /* alltypes.h:131:25 */
  480. type uint64_t = uint32 /* alltypes.h:136:25 */
  481. type uintmax_t = uint32 /* alltypes.h:146: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:343: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:85:16 */
  569. type clockid_t = int32 /* alltypes.h:214:13 */
  570. type timespec = struct {
  571. tv_sec time_t
  572. tv_nsec int32
  573. } /* alltypes.h:229: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:273:9 */
  615. type pthread_t = uintptr /* alltypes.h:273:26 */
  616. type pthread_once_t = int32 /* alltypes.h:279:13 */
  617. type pthread_key_t = uint32 /* alltypes.h:284:18 */
  618. type pthread_spinlock_t = int32 /* alltypes.h:289:13 */
  619. type pthread_mutexattr_t = struct{ __attr uint32 } /* alltypes.h:294:37 */
  620. type pthread_condattr_t = struct{ __attr uint32 } /* alltypes.h:299:37 */
  621. type pthread_barrierattr_t = struct{ __attr uint32 } /* alltypes.h:304:37 */
  622. type pthread_rwlockattr_t = struct{ __attr [2]uint32 } /* alltypes.h:309:40 */
  623. type __sigset_t = struct{ __bits [32]uint32 } /* alltypes.h:349:9 */
  624. type sigset_t = __sigset_t /* alltypes.h:349:71 */
  625. type pthread_attr_t = struct{ __u struct{ __i [9]int32 } } /* alltypes.h:372:147 */
  626. type pthread_mutex_t = struct {
  627. __u struct {
  628. _ [0]uint64
  629. __i [6]int32
  630. _ [24]byte
  631. }
  632. } /* alltypes.h:377:157 */
  633. type pthread_cond_t = struct {
  634. __u struct {
  635. _ [0]uint64
  636. __i [12]int32
  637. }
  638. } /* alltypes.h:387:112 */
  639. type pthread_rwlock_t = struct {
  640. __u struct {
  641. _ [0]uint64
  642. __i [8]int32
  643. _ [32]byte
  644. }
  645. } /* alltypes.h:397:139 */
  646. type pthread_barrier_t = struct {
  647. __u struct {
  648. _ [0]uint64
  649. __i [5]int32
  650. _ [20]byte
  651. }
  652. } /* alltypes.h:402: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:209:14 */
  663. type clock_t = int32 /* alltypes.h:219: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:273: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 = int64 /* signal.h:59:19 */
  700. type gregset_t = [23]int64 /* signal.h:59:27 */
  701. type _fpstate = struct {
  702. cwd uint16
  703. swd uint16
  704. ftw uint16
  705. fop uint16
  706. rip uint64
  707. rdp uint64
  708. mxcsr uint32
  709. mxcr_mask uint32
  710. _st [8]struct {
  711. significand [4]uint16
  712. exponent uint16
  713. padding [3]uint16
  714. }
  715. _xmm [16]struct{ element [4]uint32 }
  716. padding [24]uint32
  717. } /* signal.h:60:9 */
  718. type fpregset_t = uintptr /* signal.h:71:3 */
  719. type sigcontext = struct {
  720. r8 uint32
  721. r9 uint32
  722. r10 uint32
  723. r11 uint32
  724. r12 uint32
  725. r13 uint32
  726. r14 uint32
  727. r15 uint32
  728. rdi uint32
  729. rsi uint32
  730. rbp uint32
  731. rbx uint32
  732. rdx uint32
  733. rax uint32
  734. rcx uint32
  735. rsp uint32
  736. rip uint32
  737. eflags uint32
  738. cs uint16
  739. gs uint16
  740. fs uint16
  741. __pad0 uint16
  742. err uint32
  743. trapno uint32
  744. oldmask uint32
  745. cr2 uint32
  746. fpstate uintptr
  747. __reserved1 [8]uint32
  748. } /* signal.h:72:1 */
  749. type mcontext_t = struct {
  750. gregs gregset_t
  751. fpregs fpregset_t
  752. __reserved1 [8]uint64
  753. } /* signal.h:84:3 */
  754. type __ucontext = struct {
  755. uc_flags uint32
  756. _ [4]byte
  757. uc_link uintptr
  758. uc_stack stack_t
  759. uc_mcontext mcontext_t
  760. uc_sigmask sigset_t
  761. __fpregs_mem [64]uint32
  762. } /* signal.h:97:9 */
  763. type ucontext_t = __ucontext /* signal.h:104:3 */
  764. type sigval = struct {
  765. _ [0]uint64
  766. sival_int int32
  767. _ [4]byte
  768. } /* time.h:107:1 */
  769. type siginfo_t = struct {
  770. si_signo int32
  771. si_errno int32
  772. si_code int32
  773. _ [4]byte
  774. __si_fields struct {
  775. _ [0]uint64
  776. __pad [116]int8
  777. _ [4]byte
  778. }
  779. } /* signal.h:145:3 */
  780. type sigaction = struct {
  781. __sa_handler struct{ sa_handler uintptr }
  782. sa_mask sigset_t
  783. sa_flags int32
  784. _ [4]byte
  785. sa_restorer uintptr
  786. } /* signal.h:167:1 */
  787. type sig_t = uintptr /* signal.h:251:14 */
  788. type sig_atomic_t = int32 /* signal.h:269:13 */
  789. type mode_t = uint32 /* alltypes.h:152:18 */
  790. type syscall_arg_t = int32 /* syscall.h:22:14 */
  791. func a_cas(tls *TLS, p uintptr, t int32, s int32) int32 { /* atomic_arch.h:2:19: */
  792. panic(`arch\x86_64\atomic_arch.h:4:2: assembler statements not supported`)
  793. return t
  794. }
  795. func a_or(tls *TLS, p uintptr, v int32) { /* atomic_arch.h:46:20: */
  796. panic(`arch\x86_64\atomic_arch.h:48:2: assembler statements not supported`)
  797. }
  798. func a_or_64(tls *TLS, p uintptr, v uint64_t) { /* atomic_arch.h:62:20: */
  799. panic(`arch\x86_64\atomic_arch.h:64:2: assembler statements not supported`)
  800. }
  801. func a_ctz_64(tls *TLS, x uint64_t) int32 { /* atomic_arch.h:112:19: */
  802. panic(`arch\x86_64\atomic_arch.h:114:2: assembler statements not supported`)
  803. return int32(x)
  804. }
  805. func a_ctz_32(tls *TLS, x uint32_t) int32 { /* atomic.h:256:19: */
  806. return int32(_sdebruijn32[x&-x*uint32_t(0x076be629)>>27])
  807. }
  808. var _sdebruijn32 = [32]int8{
  809. 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),
  810. 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),
  811. } /* atomic.h:261:20 */
  812. type __timer = struct {
  813. timerid int32
  814. _ [4]byte
  815. thread pthread_t
  816. } /* pthread_impl.h:64:1 */
  817. func __pthread_self(tls *TLS) uintptr { /* pthread_arch.h:1:30: */
  818. var self uintptr
  819. panic(`arch\x86_64\pthread_arch.h:4:2: assembler statements not supported`)
  820. return self
  821. }
  822. func Xwcrtomb(tls *TLS, s uintptr, wc wchar_t, st uintptr) size_t { /* wcrtomb.c:6:8: */
  823. if !(s != 0) {
  824. return uint64(1)
  825. }
  826. if uint32(wc) < uint32(0x80) {
  827. *(*int8)(unsafe.Pointer(s)) = int8(wc)
  828. return uint64(1)
  829. } else if func() int32 {
  830. if !!(int32(*(*uintptr)(unsafe.Pointer((*__pthread)(unsafe.Pointer(__pthread_self(tls))).locale))) != 0) {
  831. return 4
  832. }
  833. return 1
  834. }() == 1 {
  835. if !(uint32(wc)-uint32(0xdf80) < uint32(0x80)) {
  836. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 84
  837. return Uint64FromInt32(-1)
  838. }
  839. *(*int8)(unsafe.Pointer(s)) = int8(wc)
  840. return uint64(1)
  841. } else if uint32(wc) < uint32(0x800) {
  842. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0xc0 | int32(wc)>>6)
  843. *(*int8)(unsafe.Pointer(s)) = int8(0x80 | int32(wc)&0x3f)
  844. return uint64(2)
  845. } else if uint32(wc) < uint32(0xd800) || uint32(wc)-uint32(0xe000) < uint32(0x2000) {
  846. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0xe0 | int32(wc)>>12)
  847. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0x80 | int32(wc)>>6&0x3f)
  848. *(*int8)(unsafe.Pointer(s)) = int8(0x80 | int32(wc)&0x3f)
  849. return uint64(3)
  850. } else if uint32(wc)-uint32(0x10000) < uint32(0x100000) {
  851. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0xf0 | int32(wc)>>18)
  852. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0x80 | int32(wc)>>12&0x3f)
  853. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0x80 | int32(wc)>>6&0x3f)
  854. *(*int8)(unsafe.Pointer(s)) = int8(0x80 | int32(wc)&0x3f)
  855. return uint64(4)
  856. }
  857. *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 84
  858. return Uint64FromInt32(-1)
  859. }
  860. func Xwcsrtombs(tls *TLS, s uintptr, ws uintptr, n size_t, st uintptr) size_t { /* wcsrtombs.c:3:8: */
  861. bp := tls.Alloc(4)
  862. defer tls.Free(4)
  863. var ws2 uintptr
  864. // var buf [4]int8 at bp, 4
  865. var N size_t = n
  866. var l size_t
  867. if !(s != 0) {
  868. n = uint64(0)
  869. ws2 = *(*uintptr)(unsafe.Pointer(ws))
  870. for ; *(*wchar_t)(unsafe.Pointer(ws2)) != 0; ws2 += 2 {
  871. if uint32(*(*wchar_t)(unsafe.Pointer(ws2))) >= 0x80 {
  872. l = Xwcrtomb(tls, bp, *(*wchar_t)(unsafe.Pointer(ws2)), uintptr(0))
  873. if !(l+uint64(1) != 0) {
  874. return Uint64FromInt32(-1)
  875. }
  876. n = n + l
  877. } else {
  878. n++
  879. }
  880. }
  881. return n
  882. }
  883. for n >= uint64(4) {
  884. if uint32(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))))-1 >= 0x7f {
  885. if !(int32(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws))))) != 0) {
  886. *(*int8)(unsafe.Pointer(s)) = int8(0)
  887. *(*uintptr)(unsafe.Pointer(ws)) = uintptr(0)
  888. return N - n
  889. }
  890. l = Xwcrtomb(tls, s, *(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))), uintptr(0))
  891. if !(l+uint64(1) != 0) {
  892. return Uint64FromInt32(-1)
  893. }
  894. s += uintptr(l)
  895. n = n - l
  896. } else {
  897. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))))
  898. n--
  899. }
  900. *(*uintptr)(unsafe.Pointer(ws)) += 2
  901. }
  902. for n != 0 {
  903. if uint32(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))))-1 >= 0x7f {
  904. if !(int32(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws))))) != 0) {
  905. *(*int8)(unsafe.Pointer(s)) = int8(0)
  906. *(*uintptr)(unsafe.Pointer(ws)) = uintptr(0)
  907. return N - n
  908. }
  909. l = Xwcrtomb(tls, bp, *(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))), uintptr(0))
  910. if !(l+uint64(1) != 0) {
  911. return Uint64FromInt32(-1)
  912. }
  913. if l > n {
  914. return N - n
  915. }
  916. Xwcrtomb(tls, s, *(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))), uintptr(0))
  917. s += uintptr(l)
  918. n = n - l
  919. } else {
  920. *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))))
  921. n--
  922. }
  923. *(*uintptr)(unsafe.Pointer(ws)) += 2
  924. }
  925. return N
  926. }
  927. func Xwcstombs(tls *TLS, s uintptr, ws uintptr, n size_t) size_t { /* wcstombs.c:4:8: */
  928. bp := tls.Alloc(8)
  929. defer tls.Free(8)
  930. *(*uintptr)(unsafe.Pointer(bp)) = ws
  931. //TODO return wcsrtombs(s, &(const wchar_t *){ws}, n, 0);
  932. return Xwcsrtombs(tls, s, bp, n, uintptr(0))
  933. }
  934. func Xbsearch(tls *TLS, key uintptr, base uintptr, nel size_t, width size_t, cmp uintptr) uintptr { /* bsearch.c:3:6: */
  935. var try uintptr
  936. var sign int32
  937. for nel > uint64(0) {
  938. try = base + uintptr(width*(nel/uint64(2)))
  939. sign = (*struct {
  940. f func(*TLS, uintptr, uintptr) int32
  941. })(unsafe.Pointer(&struct{ uintptr }{cmp})).f(tls, key, try)
  942. if sign < 0 {
  943. nel = nel / uint64(2)
  944. } else if sign > 0 {
  945. base = try + uintptr(width)
  946. nel = nel - (nel/uint64(2) + uint64(1))
  947. } else {
  948. return try
  949. }
  950. }
  951. return uintptr(0)
  952. }
  953. // Support signed or unsigned plain-char
  954. // Implementation choices...
  955. // Arbitrary numbers...
  956. // POSIX/SUS requirements follow. These numbers come directly
  957. // from SUS and have nothing to do with the host system.
  958. func X__strchrnul(tls *TLS, s uintptr, c int32) uintptr { /* strchrnul.c:10:6: */
  959. c = int32(uint8(c))
  960. if !(c != 0) {
  961. return s + uintptr(Xstrlen(tls, s))
  962. }
  963. var w uintptr
  964. for ; uint64(s)%uint64(unsafe.Sizeof(size_t(0))) != 0; s++ {
  965. if !(int32(*(*int8)(unsafe.Pointer(s))) != 0) || int32(*(*uint8)(unsafe.Pointer(s))) == c {
  966. return s
  967. }
  968. }
  969. var k size_t = Uint64(Uint64FromInt32(-1)) / uint64(255) * size_t(c)
  970. 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 {
  971. }
  972. s = w
  973. for ; *(*int8)(unsafe.Pointer(s)) != 0 && int32(*(*uint8)(unsafe.Pointer(s))) != c; s++ {
  974. }
  975. return s
  976. }
  977. func Xstrdup(tls *TLS, s uintptr) uintptr { /* strdup.c:4:6: */
  978. var l size_t = Xstrlen(tls, s)
  979. var d uintptr = Xmalloc(tls, l+uint64(1))
  980. if !(d != 0) {
  981. return uintptr(0)
  982. }
  983. return Xmemcpy(tls, d, s, l+uint64(1))
  984. }