source: code/trunk/vendor/modernc.org/libc/musl_windows_arm64.go@ 823

Last change on this file since 823 was 822, checked in by yakumo.izuru, 22 months ago

Prefer immortal.run over runit and rc.d, use vendored modules
for convenience.

Signed-off-by: Izuru Yakumo <yakumo.izuru@…>

File size: 32.4 KB
Line 
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
3package libc
4
5import (
6 "math"
7 "reflect"
8 "sync/atomic"
9 "unsafe"
10)
11
12var _ = math.Pi
13var _ reflect.Kind
14var _ atomic.Value
15var _ unsafe.Pointer
16
17// musl as a whole is licensed under the following standard MIT license:
18//
19// ----------------------------------------------------------------------
20// Copyright © 2005-2020 Rich Felker, et al.
21//
22// Permission is hereby granted, free of charge, to any person obtaining
23// a copy of this software and associated documentation files (the
24// "Software"), to deal in the Software without restriction, including
25// without limitation the rights to use, copy, modify, merge, publish,
26// distribute, sublicense, and/or sell copies of the Software, and to
27// permit persons to whom the Software is furnished to do so, subject to
28// the following conditions:
29//
30// The above copyright notice and this permission notice shall be
31// included in all copies or substantial portions of the Software.
32//
33// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
34// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
35// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
36// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
37// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
38// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
39// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40// ----------------------------------------------------------------------
41//
42// Authors/contributors include:
43//
44// A. Wilcox
45// Ada Worcester
46// Alex Dowad
47// Alex Suykov
48// Alexander Monakov
49// Andre McCurdy
50// Andrew Kelley
51// Anthony G. Basile
52// Aric Belsito
53// Arvid Picciani
54// Bartosz Brachaczek
55// Benjamin Peterson
56// Bobby Bingham
57// Boris Brezillon
58// Brent Cook
59// Chris Spiegel
60// Clément Vasseur
61// Daniel Micay
62// Daniel Sabogal
63// Daurnimator
64// David Carlier
65// David Edelsohn
66// Denys Vlasenko
67// Dmitry Ivanov
68// Dmitry V. Levin
69// Drew DeVault
70// Emil Renner Berthing
71// Fangrui Song
72// Felix Fietkau
73// Felix Janda
74// Gianluca Anzolin
75// Hauke Mehrtens
76// He X
77// Hiltjo Posthuma
78// Isaac Dunham
79// Jaydeep Patil
80// Jens Gustedt
81// Jeremy Huntwork
82// Jo-Philipp Wich
83// Joakim Sindholt
84// John Spencer
85// Julien Ramseier
86// Justin Cormack
87// Kaarle Ritvanen
88// Khem Raj
89// Kylie McClain
90// Leah Neukirchen
91// Luca Barbato
92// Luka Perkov
93// M Farkas-Dyck (Strake)
94// Mahesh Bodapati
95// Markus Wichmann
96// Masanori Ogino
97// Michael Clark
98// Michael Forney
99// Mikhail Kremnyov
100// Natanael Copa
101// Nicholas J. Kain
102// orc
103// Pascal Cuoq
104// Patrick Oppenlander
105// Petr Hosek
106// Petr Skocik
107// Pierre Carrier
108// Reini Urban
109// Rich Felker
110// Richard Pennington
111// Ryan Fairfax
112// Samuel Holland
113// Segev Finer
114// Shiz
115// sin
116// Solar Designer
117// Stefan Kristiansson
118// Stefan O'Rear
119// Szabolcs Nagy
120// Timo Teräs
121// Trutz Behn
122// Valentin Ochs
123// Will Dietz
124// William Haddon
125// William Pitcock
126//
127// Portions of this software are derived from third-party works licensed
128// under terms compatible with the above MIT license:
129//
130// The TRE regular expression implementation (src/regex/reg* and
131// src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed
132// under a 2-clause BSD license (license text in the source files). The
133// included version has been heavily modified by Rich Felker in 2012, in
134// the interests of size, simplicity, and namespace cleanliness.
135//
136// Much of the math library code (src/math/* and src/complex/*) is
137// Copyright © 1993,2004 Sun Microsystems or
138// Copyright © 2003-2011 David Schultz or
139// Copyright © 2003-2009 Steven G. Kargl or
140// Copyright © 2003-2009 Bruce D. Evans or
141// Copyright © 2008 Stephen L. Moshier or
142// Copyright © 2017-2018 Arm Limited
143// and labelled as such in comments in the individual source files. All
144// have been licensed under extremely permissive terms.
145//
146// The ARM memcpy code (src/string/arm/memcpy.S) is Copyright © 2008
147// The Android Open Source Project and is licensed under a two-clause BSD
148// license. It was taken from Bionic libc, used on Android.
149//
150// The AArch64 memcpy and memset code (src/string/aarch64/*) are
151// Copyright © 1999-2019, Arm Limited.
152//
153// The implementation of DES for crypt (src/crypt/crypt_des.c) is
154// Copyright © 1994 David Burren. It is licensed under a BSD license.
155//
156// The implementation of blowfish crypt (src/crypt/crypt_blowfish.c) was
157// originally written by Solar Designer and placed into the public
158// domain. The code also comes with a fallback permissive license for use
159// in jurisdictions that may not recognize the public domain.
160//
161// The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011
162// Valentin Ochs and is licensed under an MIT-style license.
163//
164// The x86_64 port was written by Nicholas J. Kain and is licensed under
165// the standard MIT terms.
166//
167// The mips and microblaze ports were originally written by Richard
168// Pennington for use in the ellcc project. The original code was adapted
169// by Rich Felker for build system and code conventions during upstream
170// integration. It is licensed under the standard MIT terms.
171//
172// The mips64 port was contributed by Imagination Technologies and is
173// licensed under the standard MIT terms.
174//
175// The powerpc port was also originally written by Richard Pennington,
176// and later supplemented and integrated by John Spencer. It is licensed
177// under the standard MIT terms.
178//
179// All other files which have no copyright comments are original works
180// produced specifically for use as part of this library, written either
181// by Rich Felker, the main author of the library, or by one or more
182// contibutors listed above. Details on authorship of individual files
183// can be found in the git version control history of the project. The
184// omission of copyright and license comments in each file is in the
185// interest of source tree size.
186//
187// In addition, permission is hereby granted for all public header files
188// (include/* and arch/*/bits/*) and crt files intended to be linked into
189// applications (crt/*, ldso/dlstart.c, and arch/*/crt_arch.h) to omit
190// the copyright notice and permission notice otherwise required by the
191// license, and to use these files without any requirement of
192// attribution. These files include substantial contributions from:
193//
194// Bobby Bingham
195// John Spencer
196// Nicholas J. Kain
197// Rich Felker
198// Richard Pennington
199// Stefan Kristiansson
200// Szabolcs Nagy
201//
202// all of whom have explicitly granted such permission.
203//
204// This file previously contained text expressing a belief that most of
205// the files covered by the above exception were sufficiently trivial not
206// to be subject to copyright, resulting in confusion over whether it
207// negated the permissions granted in the license. In the spirit of
208// permissive licensing, and of not having licensing issues being an
209// obstacle to adoption, that text has been removed.
210const ( /* copyright.c:194:1: */
211 __musl__copyright__ = 0
212)
213
214const ( /* pthread_impl.h:58:1: */
215 DT_EXITING = 0
216 DT_JOINABLE = 1
217 DT_DETACHED = 2
218)
219
220type ptrdiff_t = int64 /* <builtin>:3:26 */
221
222type size_t = uint64 /* <builtin>:9:23 */
223
224type wchar_t = uint16 /* <builtin>:15:24 */
225
226type va_list = uintptr /* <builtin>:50:27 */
227
228type __locale_struct = struct{ cat [6]uintptr } /* alltypes.h:351:9 */
229
230type locale_t = uintptr /* alltypes.h:351:32 */
231
232func Xisalnum(tls *TLS, c int32) int32 { /* isalnum.c:3:5: */
233 return Bool32(func() int32 {
234 if 0 != 0 {
235 return Xisalpha(tls, c)
236 }
237 return Bool32(uint32(c)|uint32(32)-uint32('a') < uint32(26))
238 }() != 0 || func() int32 {
239 if 0 != 0 {
240 return Xisdigit(tls, c)
241 }
242 return Bool32(uint32(c)-uint32('0') < uint32(10))
243 }() != 0)
244}
245
246func X__isalnum_l(tls *TLS, c int32, l locale_t) int32 { /* isalnum.c:8:5: */
247 return Xisalnum(tls, c)
248}
249
250func Xisalpha(tls *TLS, c int32) int32 { /* isalpha.c:4:5: */
251 return Bool32(uint32(c)|uint32(32)-uint32('a') < uint32(26))
252}
253
254func X__isalpha_l(tls *TLS, c int32, l locale_t) int32 { /* isalpha.c:9:5: */
255 return Xisalpha(tls, c)
256}
257
258func Xisdigit(tls *TLS, c int32) int32 { /* isdigit.c:4:5: */
259 return Bool32(uint32(c)-uint32('0') < uint32(10))
260}
261
262func X__isdigit_l(tls *TLS, c int32, l locale_t) int32 { /* isdigit.c:9:5: */
263 return Xisdigit(tls, c)
264}
265
266func Xislower(tls *TLS, c int32) int32 { /* islower.c:4:5: */
267 return Bool32(uint32(c)-uint32('a') < uint32(26))
268}
269
270func X__islower_l(tls *TLS, c int32, l locale_t) int32 { /* islower.c:9:5: */
271 return Xislower(tls, c)
272}
273
274func Xisprint(tls *TLS, c int32) int32 { /* isprint.c:4:5: */
275 return Bool32(uint32(c)-uint32(0x20) < uint32(0x5f))
276}
277
278func X__isprint_l(tls *TLS, c int32, l locale_t) int32 { /* isprint.c:9:5: */
279 return Xisprint(tls, c)
280}
281
282func Xisspace(tls *TLS, c int32) int32 { /* isspace.c:4:5: */
283 return Bool32(c == ' ' || uint32(c)-uint32('\t') < uint32(5))
284}
285
286func X__isspace_l(tls *TLS, c int32, l locale_t) int32 { /* isspace.c:9:5: */
287 return Xisspace(tls, c)
288}
289
290func Xisxdigit(tls *TLS, c int32) int32 { /* isxdigit.c:3:5: */
291 return Bool32(func() int32 {
292 if 0 != 0 {
293 return Xisdigit(tls, c)
294 }
295 return Bool32(uint32(c)-uint32('0') < uint32(10))
296 }() != 0 || uint32(c)|uint32(32)-uint32('a') < uint32(6))
297}
298
299func X__isxdigit_l(tls *TLS, c int32, l locale_t) int32 { /* isxdigit.c:8:5: */
300 return Xisxdigit(tls, c)
301}
302
303type div_t = struct {
304 quot int32
305 rem int32
306} /* stdlib.h:62:35 */
307type ldiv_t = struct {
308 quot int32
309 rem int32
310} /* stdlib.h:63:36 */
311type lldiv_t = struct {
312 quot int64
313 rem int64
314} /* stdlib.h:64:41 */
315
316type ssize_t = int32 /* alltypes.h:73:15 */
317
318type intptr_t = int32 /* alltypes.h:78:15 */
319
320type off_t = int32 /* alltypes.h:170:16 */
321
322type pid_t = int32 /* alltypes.h:243:13 */
323
324type uid_t = uint32 /* alltypes.h:253:18 */
325
326type gid_t = uint32 /* alltypes.h:258:18 */
327
328type useconds_t = uint32 /* alltypes.h:268:18 */
329
330func X__putenv(tls *TLS, s uintptr, l size_t, r uintptr) int32 { /* putenv.c:8:5: */
331 var i size_t
332 var newenv uintptr
333 var tmp uintptr
334 //TODO for (char **e = __environ; *e; e++, i++)
335 var e uintptr
336 i = uint64(0)
337 if !(Environ() != 0) {
338 goto __1
339 }
340 //TODO for (char **e = __environ; *e; e++, i++)
341 e = Environ()
342__2:
343 if !(*(*uintptr)(unsafe.Pointer(e)) != 0) {
344 goto __4
345 }
346 if !!(Xstrncmp(tls, s, *(*uintptr)(unsafe.Pointer(e)), l+uint64(1)) != 0) {
347 goto __5
348 }
349 tmp = *(*uintptr)(unsafe.Pointer(e))
350 *(*uintptr)(unsafe.Pointer(e)) = s
351 X__env_rm_add(tls, tmp, r)
352 return 0
353__5:
354 ;
355 goto __3
356__3:
357 e += 8
358 i++
359 goto __2
360 goto __4
361__4:
362 ;
363__1:
364 ;
365 if !(Environ() == _soldenv) {
366 goto __6
367 }
368 newenv = Xrealloc(tls, _soldenv, uint64(unsafe.Sizeof(uintptr(0)))*(i+uint64(2)))
369 if !!(newenv != 0) {
370 goto __8
371 }
372 goto oom
373__8:
374 ;
375 goto __7
376__6:
377 newenv = Xmalloc(tls, uint64(unsafe.Sizeof(uintptr(0)))*(i+uint64(2)))
378 if !!(newenv != 0) {
379 goto __9
380 }
381 goto oom
382__9:
383 ;
384 if !(i != 0) {
385 goto __10
386 }
387 Xmemcpy(tls, newenv, Environ(), uint64(unsafe.Sizeof(uintptr(0)))*i)
388__10:
389 ;
390 Xfree(tls, _soldenv)
391__7:
392 ;
393 *(*uintptr)(unsafe.Pointer(newenv + uintptr(i)*8)) = s
394 *(*uintptr)(unsafe.Pointer(newenv + uintptr(i+uint64(1))*8)) = uintptr(0)
395 *(*uintptr)(unsafe.Pointer(EnvironP())) = AssignPtrUintptr(uintptr(unsafe.Pointer(&_soldenv)), newenv)
396 if !(r != 0) {
397 goto __11
398 }
399 X__env_rm_add(tls, uintptr(0), r)
400__11:
401 ;
402 return 0
403oom:
404 Xfree(tls, r)
405 return -1
406}
407
408var _soldenv uintptr /* putenv.c:22:14: */
409
410func Xputenv(tls *TLS, s uintptr) int32 { /* putenv.c:43:5: */
411 var l size_t = size_t((int64(X__strchrnul(tls, s, '=')) - int64(s)) / 1)
412 if !(l != 0) || !(int32(*(*int8)(unsafe.Pointer(s + uintptr(l)))) != 0) {
413 return Xunsetenv(tls, s)
414 }
415 return X__putenv(tls, s, l, uintptr(0))
416}
417
418func X__env_rm_add(tls *TLS, old uintptr, new uintptr) { /* setenv.c:5:6: */
419 //TODO for (size_t i=0; i < env_alloced_n; i++)
420 var i size_t = uint64(0)
421 for ; i < _senv_alloced_n; i++ {
422 if *(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8)) == old {
423 *(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8)) = new
424 Xfree(tls, old)
425 return
426 } else if !(int32(*(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8))) != 0) && new != 0 {
427 *(*uintptr)(unsafe.Pointer(_senv_alloced + uintptr(i)*8)) = new
428 new = uintptr(0)
429 }
430 }
431 if !(new != 0) {
432 return
433 }
434 var t uintptr = Xrealloc(tls, _senv_alloced, uint64(unsafe.Sizeof(uintptr(0)))*(_senv_alloced_n+uint64(1)))
435 if !(t != 0) {
436 return
437 }
438 *(*uintptr)(unsafe.Pointer(AssignPtrUintptr(uintptr(unsafe.Pointer(&_senv_alloced)), t) + uintptr(PostIncUint64(&_senv_alloced_n, 1))*8)) = new
439}
440
441var _senv_alloced uintptr /* setenv.c:7:14: */
442var _senv_alloced_n size_t /* setenv.c:8:16: */
443
444func Xsetenv(tls *TLS, var1 uintptr, value uintptr, overwrite int32) int32 { /* setenv.c:26:5: */
445 var s uintptr
446 var l1 size_t
447 var l2 size_t
448
449 if !(var1 != 0) || !(int32(AssignUint64(&l1, size_t((int64(X__strchrnul(tls, var1, '='))-int64(var1))/1))) != 0) || *(*int8)(unsafe.Pointer(var1 + uintptr(l1))) != 0 {
450 *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22
451 return -1
452 }
453 if !(overwrite != 0) && Xgetenv(tls, var1) != 0 {
454 return 0
455 }
456
457 l2 = Xstrlen(tls, value)
458 s = Xmalloc(tls, l1+l2+uint64(2))
459 if !(s != 0) {
460 return -1
461 }
462 Xmemcpy(tls, s, var1, l1)
463 *(*int8)(unsafe.Pointer(s + uintptr(l1))) = int8('=')
464 Xmemcpy(tls, s+uintptr(l1)+uintptr(1), value, l2+uint64(1))
465 return X__putenv(tls, s, l1, s)
466}
467
468func Xunsetenv(tls *TLS, name uintptr) int32 { /* unsetenv.c:9:5: */
469 var l size_t = size_t((int64(X__strchrnul(tls, name, '=')) - int64(name)) / 1)
470 if !(l != 0) || *(*int8)(unsafe.Pointer(name + uintptr(l))) != 0 {
471 *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 22
472 return -1
473 }
474 if Environ() != 0 {
475 var e uintptr = Environ()
476 var eo uintptr = e
477 for ; *(*uintptr)(unsafe.Pointer(e)) != 0; e += 8 {
478 //TODO if (!strncmp(name, *e, l) && l[*e] == '=')
479 if !(Xstrncmp(tls, name, *(*uintptr)(unsafe.Pointer(e)), l) != 0) && int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(e)) + uintptr(l)))) == '=' {
480 X__env_rm_add(tls, *(*uintptr)(unsafe.Pointer(e)), uintptr(0))
481 } else if eo != e {
482 *(*uintptr)(unsafe.Pointer(PostIncUintptr(&eo, 8))) = *(*uintptr)(unsafe.Pointer(e))
483 } else {
484 eo += 8
485 }
486 }
487 if eo != e {
488 *(*uintptr)(unsafe.Pointer(eo)) = uintptr(0)
489 }
490 }
491 return 0
492}
493
494type wint_t = uint32 /* alltypes.h:21:18 */
495
496type wctype_t = uint32 /* alltypes.h:211:23 */
497
498type __mbstate_t = struct {
499 __opaque1 uint32
500 __opaque2 uint32
501} /* alltypes.h:345:9 */
502
503type mbstate_t = __mbstate_t /* alltypes.h:345:63 */
504
505type tm = struct {
506 tm_sec int32
507 tm_min int32
508 tm_hour int32
509 tm_mday int32
510 tm_mon int32
511 tm_year int32
512 tm_wday int32
513 tm_yday int32
514 tm_isdst int32
515 tm_gmtoff int32
516 tm_zone uintptr
517} /* wchar.h:138:1 */
518
519type uintptr_t = uint32 /* alltypes.h:63:24 */
520
521type int8_t = int8 /* alltypes.h:104:25 */
522
523type int16_t = int16 /* alltypes.h:109:25 */
524
525type int32_t = int32 /* alltypes.h:114:25 */
526
527type int64_t = int32 /* alltypes.h:119:25 */
528
529type intmax_t = int32 /* alltypes.h:124:25 */
530
531type uint8_t = uint8 /* alltypes.h:129:25 */
532
533type uint16_t = uint16 /* alltypes.h:134:25 */
534
535type uint32_t = uint32 /* alltypes.h:139:25 */
536
537type uint64_t = uint32 /* alltypes.h:144:25 */
538
539type uintmax_t = uint32 /* alltypes.h:154:25 */
540
541type int_fast8_t = int8_t /* stdint.h:22:16 */
542type int_fast64_t = int64_t /* stdint.h:23:17 */
543
544type int_least8_t = int8_t /* stdint.h:25:17 */
545type int_least16_t = int16_t /* stdint.h:26:17 */
546type int_least32_t = int32_t /* stdint.h:27:17 */
547type int_least64_t = int64_t /* stdint.h:28:17 */
548
549type uint_fast8_t = uint8_t /* stdint.h:30:17 */
550type uint_fast64_t = uint64_t /* stdint.h:31:18 */
551
552type uint_least8_t = uint8_t /* stdint.h:33:18 */
553type uint_least16_t = uint16_t /* stdint.h:34:18 */
554type uint_least32_t = uint32_t /* stdint.h:35:18 */
555type uint_least64_t = uint64_t /* stdint.h:36:18 */
556
557type int_fast16_t = int32_t /* stdint.h:1:17 */
558type int_fast32_t = int32_t /* stdint.h:2:17 */
559type uint_fast16_t = uint32_t /* stdint.h:3:18 */
560type uint_fast32_t = uint32_t /* stdint.h:4:18 */
561
562// Upper 6 state bits are a negative integer offset to bound-check next byte
563// equivalent to: ( (b-0x80) | (b+offset) ) & ~0x3f
564
565// Interval [a,b). Either a must be 80 or b must be c0, lower 3 bits clear.
566
567// Arbitrary encoding for representing code units instead of characters.
568
569// Get inline definition of MB_CUR_MAX.
570
571type lconv = struct {
572 decimal_point uintptr
573 thousands_sep uintptr
574 grouping uintptr
575 int_curr_symbol uintptr
576 currency_symbol uintptr
577 mon_decimal_point uintptr
578 mon_thousands_sep uintptr
579 mon_grouping uintptr
580 positive_sign uintptr
581 negative_sign uintptr
582 int_frac_digits int8
583 frac_digits int8
584 p_cs_precedes int8
585 p_sep_by_space int8
586 n_cs_precedes int8
587 n_sep_by_space int8
588 p_sign_posn int8
589 n_sign_posn int8
590 int_p_cs_precedes int8
591 int_p_sep_by_space int8
592 int_n_cs_precedes int8
593 int_n_sep_by_space int8
594 int_p_sign_posn int8
595 int_n_sign_posn int8
596 _ [2]byte
597} /* locale.h:24:1 */
598
599type _G_fpos64_t = struct {
600 _ [0]uint64
601 __opaque [16]int8
602} /* stdio.h:54:9 */
603
604type fpos_t = _G_fpos64_t /* stdio.h:58:3 */
605
606// Support signed or unsigned plain-char
607
608// Implementation choices...
609
610// Arbitrary numbers...
611
612// POSIX/SUS requirements follow. These numbers come directly
613// from SUS and have nothing to do with the host system.
614
615type __locale_map = struct {
616 __map uintptr
617 map_size size_t
618 name [24]int8
619 next uintptr
620} /* alltypes.h:351:9 */
621
622type tls_module = struct {
623 next uintptr
624 image uintptr
625 len size_t
626 size size_t
627 align size_t
628 offset size_t
629} /* libc.h:14:1 */
630
631type __libc = struct {
632 can_do_threads int8
633 threaded int8
634 secure int8
635 need_locks int8
636 threads_minus_1 int32
637 auxv uintptr
638 tls_head uintptr
639 tls_size size_t
640 tls_align size_t
641 tls_cnt size_t
642 page_size size_t
643 global_locale struct{ cat [6]uintptr }
644} /* libc.h:20:1 */
645
646type time_t = int32 /* alltypes.h:93:16 */
647
648type clockid_t = int32 /* alltypes.h:222:13 */
649
650type timespec = struct {
651 tv_sec time_t
652 tv_nsec int32
653} /* alltypes.h:237:1 */
654
655type __pthread = struct {
656 self uintptr
657 dtv uintptr
658 prev uintptr
659 next uintptr
660 sysinfo uintptr_t
661 canary uintptr_t
662 canary2 uintptr_t
663 tid int32
664 errno_val int32
665 detach_state int32
666 cancel int32
667 canceldisable uint8
668 cancelasync uint8
669 tsd_used uint8 /* unsigned char tsd_used: 1, unsigned char dlerror_flag: 1 */
670 _ [1]byte
671 map_base uintptr
672 map_size size_t
673 stack uintptr
674 stack_size size_t
675 guard_size size_t
676 result uintptr
677 cancelbuf uintptr
678 tsd uintptr
679 robust_list struct {
680 head uintptr
681 off int32
682 _ [4]byte
683 pending uintptr
684 }
685 timer_id int32
686 _ [4]byte
687 locale locale_t
688 killlock [1]int32
689 _ [4]byte
690 dlerror_buf uintptr
691 stdio_locks uintptr
692 canary_at_end uintptr_t
693 _ [4]byte
694 dtv_copy uintptr
695} /* alltypes.h:281:9 */
696
697type pthread_t = uintptr /* alltypes.h:281:26 */
698
699type pthread_once_t = int32 /* alltypes.h:287:13 */
700
701type pthread_key_t = uint32 /* alltypes.h:292:18 */
702
703type pthread_spinlock_t = int32 /* alltypes.h:297:13 */
704
705type pthread_mutexattr_t = struct{ __attr uint32 } /* alltypes.h:302:37 */
706
707type pthread_condattr_t = struct{ __attr uint32 } /* alltypes.h:307:37 */
708
709type pthread_barrierattr_t = struct{ __attr uint32 } /* alltypes.h:312:37 */
710
711type pthread_rwlockattr_t = struct{ __attr [2]uint32 } /* alltypes.h:317:40 */
712
713type __sigset_t = struct{ __bits [32]uint32 } /* alltypes.h:357:9 */
714
715type sigset_t = __sigset_t /* alltypes.h:357:71 */
716
717type pthread_attr_t = struct{ __u struct{ __i [9]int32 } } /* alltypes.h:380:147 */
718
719type pthread_mutex_t = struct {
720 __u struct {
721 _ [0]uint64
722 __i [6]int32
723 _ [24]byte
724 }
725} /* alltypes.h:385:157 */
726
727type pthread_cond_t = struct {
728 __u struct {
729 _ [0]uint64
730 __i [12]int32
731 }
732} /* alltypes.h:395:112 */
733
734type pthread_rwlock_t = struct {
735 __u struct {
736 _ [0]uint64
737 __i [8]int32
738 _ [32]byte
739 }
740} /* alltypes.h:405:139 */
741
742type pthread_barrier_t = struct {
743 __u struct {
744 _ [0]uint64
745 __i [5]int32
746 _ [20]byte
747 }
748} /* alltypes.h:410:137 */
749
750type sched_param = struct {
751 sched_priority int32
752 __reserved1 int32
753 __reserved2 [2]struct {
754 __reserved1 time_t
755 __reserved2 int32
756 }
757 __reserved3 int32
758} /* sched.h:19:1 */
759
760type timer_t = uintptr /* alltypes.h:217:14 */
761
762type clock_t = int32 /* alltypes.h:227:14 */
763
764type itimerspec = struct {
765 it_interval struct {
766 tv_sec time_t
767 tv_nsec int32
768 }
769 it_value struct {
770 tv_sec time_t
771 tv_nsec int32
772 }
773} /* time.h:80:1 */
774
775type sigevent = struct {
776 sigev_value struct {
777 _ [0]uint64
778 sival_int int32
779 _ [4]byte
780 }
781 sigev_signo int32
782 sigev_notify int32
783 sigev_notify_function uintptr
784 sigev_notify_attributes uintptr
785 __pad [44]int8
786 _ [4]byte
787} /* time.h:107:1 */
788
789type __ptcb = struct {
790 __f uintptr
791 __x uintptr
792 __next uintptr
793} /* alltypes.h:281:9 */
794
795type sigaltstack = struct {
796 ss_sp uintptr
797 ss_flags int32
798 _ [4]byte
799 ss_size size_t
800} /* signal.h:44:9 */
801
802type stack_t = sigaltstack /* signal.h:44:28 */
803
804type greg_t = uint32 /* signal.h:10:23 */
805type gregset_t = [34]uint32 /* signal.h:11:23 */
806
807type fpregset_t = struct {
808 vregs [32]float64
809 fpsr uint32
810 fpcr uint32
811} /* signal.h:17:3 */
812type sigcontext = struct {
813 fault_address uint32
814 regs [31]uint32
815 sp uint32
816 pc uint32
817 pstate uint32
818 _ [4]byte
819 __reserved [256]float64
820} /* signal.h:18:9 */
821
822type mcontext_t = sigcontext /* signal.h:23:3 */
823
824type _aarch64_ctx = struct {
825 magic uint32
826 size uint32
827} /* signal.h:29:1 */
828
829type fpsimd_context = struct {
830 head struct {
831 magic uint32
832 size uint32
833 }
834 fpsr uint32
835 fpcr uint32
836 vregs [32]float64
837} /* signal.h:33:1 */
838
839type esr_context = struct {
840 head struct {
841 magic uint32
842 size uint32
843 }
844 esr uint32
845} /* signal.h:39:1 */
846
847type extra_context = struct {
848 head struct {
849 magic uint32
850 size uint32
851 }
852 datap uint32
853 size uint32
854 __reserved [3]uint32
855} /* signal.h:43:1 */
856
857type sve_context = struct {
858 head struct {
859 magic uint32
860 size uint32
861 }
862 vl uint16
863 __reserved [3]uint16
864} /* signal.h:49:1 */
865
866type __ucontext = struct {
867 uc_flags uint32
868 _ [4]byte
869 uc_link uintptr
870 uc_stack stack_t
871 uc_sigmask sigset_t
872 uc_mcontext mcontext_t
873} /* signal.h:99:9 */
874
875type ucontext_t = __ucontext /* signal.h:105:3 */
876
877type sigval = struct {
878 _ [0]uint64
879 sival_int int32
880 _ [4]byte
881} /* time.h:107:1 */
882
883type siginfo_t = struct {
884 si_signo int32
885 si_errno int32
886 si_code int32
887 _ [4]byte
888 __si_fields struct {
889 _ [0]uint64
890 __pad [116]int8
891 _ [4]byte
892 }
893} /* signal.h:145:3 */
894
895type sigaction = struct {
896 __sa_handler struct{ sa_handler uintptr }
897 sa_mask sigset_t
898 sa_flags int32
899 _ [4]byte
900 sa_restorer uintptr
901} /* signal.h:167:1 */
902
903type sig_t = uintptr /* signal.h:251:14 */
904
905type sig_atomic_t = int32 /* signal.h:269:13 */
906
907type mode_t = uint32 /* alltypes.h:160:18 */
908
909type syscall_arg_t = int32 /* syscall.h:22:14 */
910
911func a_ll(tls *TLS, p uintptr) int32 { /* atomic_arch.h:2:19: */
912 var v int32
913 panic(`arch\aarch64\atomic_arch.h:5:2: assembler statements not supported`)
914 return v
915}
916
917func a_sc(tls *TLS, p uintptr, v int32) int32 { /* atomic_arch.h:10:19: */
918 var r int32
919 panic(`arch\aarch64\atomic_arch.h:13:2: assembler statements not supported`)
920 return BoolInt32(!(r != 0))
921}
922
923func a_barrier(tls *TLS) { /* atomic_arch.h:18:20: */
924 panic(`arch\aarch64\atomic_arch.h:20:2: assembler statements not supported`)
925}
926
927func a_ll_p(tls *TLS, p uintptr) uintptr { /* atomic_arch.h:38:20: */
928 var v uintptr
929 panic(`arch\aarch64\atomic_arch.h:41:2: assembler statements not supported`)
930 return v
931}
932
933func a_sc_p(tls *TLS, p uintptr, v uintptr) int32 { /* atomic_arch.h:46:19: */
934 var r int32
935 panic(`arch\aarch64\atomic_arch.h:49:2: assembler statements not supported`)
936 return BoolInt32(!(r != 0))
937}
938
939func a_ctz_64(tls *TLS, x uint64_t) int32 { /* atomic_arch.h:68:19: */
940 panic(`arch\aarch64\atomic_arch.h:70:2: assembler statements not supported`)
941 return int32(x)
942}
943
944func a_fetch_add(tls *TLS, p uintptr, v int32) int32 { /* atomic.h:46:19: */
945 var old int32
946
947 for __ccgo := true; __ccgo; __ccgo = !(a_sc(tls, p, int32(uint32(old)+uint32(v))) != 0) {
948 old = a_ll(tls, p)
949 }
950
951 return old
952}
953
954func a_fetch_and(tls *TLS, p uintptr, v int32) int32 { /* atomic.h:59:19: */
955 var old int32
956
957 for __ccgo := true; __ccgo; __ccgo = !(a_sc(tls, p, old&v) != 0) {
958 old = a_ll(tls, p)
959 }
960
961 return old
962}
963
964func a_fetch_or(tls *TLS, p uintptr, v int32) int32 { /* atomic.h:72:19: */
965 var old int32
966
967 for __ccgo := true; __ccgo; __ccgo = !(a_sc(tls, p, old|v) != 0) {
968 old = a_ll(tls, p)
969 }
970
971 return old
972}
973
974func a_and(tls *TLS, p uintptr, v int32) { /* atomic.h:151:20: */
975 a_fetch_and(tls, p, v)
976}
977
978func a_or(tls *TLS, p uintptr, v int32) { /* atomic.h:159:20: */
979 a_fetch_or(tls, p, v)
980}
981
982func a_or_64(tls *TLS, p uintptr, v uint64_t) { /* atomic.h:220:20: */
983 bp := tls.Alloc(8)
984 defer tls.Free(8)
985
986 *(*struct {
987 v uint64_t
988 _ [4]byte
989 })(unsafe.Pointer(bp)) = func() (r struct {
990 v uint64_t
991 _ [4]byte
992 }) {
993 *(*uint64_t)(unsafe.Pointer(uintptr(unsafe.Pointer(&r)) + 0)) = v
994 return r
995 }()
996 if *(*uint32_t)(unsafe.Pointer(bp)) != 0 {
997 a_or(tls, p, int32(*(*uint32_t)(unsafe.Pointer(bp))))
998 }
999 if *(*uint32_t)(unsafe.Pointer(bp + 1*4)) != 0 {
1000 a_or(tls, p+uintptr(1)*4, int32(*(*uint32_t)(unsafe.Pointer(bp + 1*4))))
1001 }
1002}
1003
1004func a_ctz_32(tls *TLS, x uint32_t) int32 { /* atomic.h:256:19: */
1005 return int32(_sdebruijn32[x&-x*uint32_t(0x076be629)>>27])
1006}
1007
1008var _sdebruijn32 = [32]int8{
1009 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),
1010 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),
1011} /* atomic.h:261:20 */
1012
1013type __timer = struct {
1014 timerid int32
1015 _ [4]byte
1016 thread pthread_t
1017} /* pthread_impl.h:64:1 */
1018
1019func __pthread_self(tls *TLS) uintptr { /* pthread_arch.h:1:30: */
1020 var self uintptr
1021 panic(`arch\aarch64\pthread_arch.h:4:2: assembler statements not supported`)
1022 return self - uintptr(uint64(unsafe.Sizeof(__pthread{})))
1023}
1024
1025func Xwcrtomb(tls *TLS, s uintptr, wc wchar_t, st uintptr) size_t { /* wcrtomb.c:6:8: */
1026 if !(s != 0) {
1027 return uint64(1)
1028 }
1029 if uint32(wc) < uint32(0x80) {
1030 *(*int8)(unsafe.Pointer(s)) = int8(wc)
1031 return uint64(1)
1032 } else if func() int32 {
1033 if !!(int32(*(*uintptr)(unsafe.Pointer((*__pthread)(unsafe.Pointer(__pthread_self(tls))).locale))) != 0) {
1034 return 4
1035 }
1036 return 1
1037 }() == 1 {
1038 if !(uint32(wc)-uint32(0xdf80) < uint32(0x80)) {
1039 *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 84
1040 return Uint64FromInt32(-1)
1041 }
1042 *(*int8)(unsafe.Pointer(s)) = int8(wc)
1043 return uint64(1)
1044 } else if uint32(wc) < uint32(0x800) {
1045 *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0xc0 | int32(wc)>>6)
1046 *(*int8)(unsafe.Pointer(s)) = int8(0x80 | int32(wc)&0x3f)
1047 return uint64(2)
1048 } else if uint32(wc) < uint32(0xd800) || uint32(wc)-uint32(0xe000) < uint32(0x2000) {
1049 *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0xe0 | int32(wc)>>12)
1050 *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0x80 | int32(wc)>>6&0x3f)
1051 *(*int8)(unsafe.Pointer(s)) = int8(0x80 | int32(wc)&0x3f)
1052 return uint64(3)
1053 } else if uint32(wc)-uint32(0x10000) < uint32(0x100000) {
1054 *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0xf0 | int32(wc)>>18)
1055 *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0x80 | int32(wc)>>12&0x3f)
1056 *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0x80 | int32(wc)>>6&0x3f)
1057 *(*int8)(unsafe.Pointer(s)) = int8(0x80 | int32(wc)&0x3f)
1058 return uint64(4)
1059 }
1060 *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 84
1061 return Uint64FromInt32(-1)
1062}
1063
1064func Xwcsrtombs(tls *TLS, s uintptr, ws uintptr, n size_t, st uintptr) size_t { /* wcsrtombs.c:3:8: */
1065 bp := tls.Alloc(4)
1066 defer tls.Free(4)
1067
1068 var ws2 uintptr
1069 // var buf [4]int8 at bp, 4
1070
1071 var N size_t = n
1072 var l size_t
1073 if !(s != 0) {
1074 n = uint64(0)
1075 ws2 = *(*uintptr)(unsafe.Pointer(ws))
1076 for ; *(*wchar_t)(unsafe.Pointer(ws2)) != 0; ws2 += 2 {
1077 if uint32(*(*wchar_t)(unsafe.Pointer(ws2))) >= 0x80 {
1078 l = Xwcrtomb(tls, bp, *(*wchar_t)(unsafe.Pointer(ws2)), uintptr(0))
1079 if !(l+uint64(1) != 0) {
1080 return Uint64FromInt32(-1)
1081 }
1082 n = n + l
1083 } else {
1084 n++
1085 }
1086 }
1087 return n
1088 }
1089 for n >= uint64(4) {
1090 if uint32(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))))-1 >= 0x7f {
1091 if !(int32(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws))))) != 0) {
1092 *(*int8)(unsafe.Pointer(s)) = int8(0)
1093 *(*uintptr)(unsafe.Pointer(ws)) = uintptr(0)
1094 return N - n
1095 }
1096 l = Xwcrtomb(tls, s, *(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))), uintptr(0))
1097 if !(l+uint64(1) != 0) {
1098 return Uint64FromInt32(-1)
1099 }
1100 s += uintptr(l)
1101 n = n - l
1102 } else {
1103 *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))))
1104 n--
1105 }
1106 *(*uintptr)(unsafe.Pointer(ws)) += 2
1107 }
1108 for n != 0 {
1109 if uint32(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))))-1 >= 0x7f {
1110 if !(int32(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws))))) != 0) {
1111 *(*int8)(unsafe.Pointer(s)) = int8(0)
1112 *(*uintptr)(unsafe.Pointer(ws)) = uintptr(0)
1113 return N - n
1114 }
1115 l = Xwcrtomb(tls, bp, *(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))), uintptr(0))
1116 if !(l+uint64(1) != 0) {
1117 return Uint64FromInt32(-1)
1118 }
1119 if l > n {
1120 return N - n
1121 }
1122 Xwcrtomb(tls, s, *(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))), uintptr(0))
1123 s += uintptr(l)
1124 n = n - l
1125 } else {
1126 *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))))
1127 n--
1128 }
1129 *(*uintptr)(unsafe.Pointer(ws)) += 2
1130 }
1131 return N
1132}
1133
1134func Xwcstombs(tls *TLS, s uintptr, ws uintptr, n size_t) size_t { /* wcstombs.c:4:8: */
1135 bp := tls.Alloc(8)
1136 defer tls.Free(8)
1137 *(*uintptr)(unsafe.Pointer(bp)) = ws
1138
1139 //TODO return wcsrtombs(s, &(const wchar_t *){ws}, n, 0);
1140 return Xwcsrtombs(tls, s, bp, n, uintptr(0))
1141}
1142
1143func Xbsearch(tls *TLS, key uintptr, base uintptr, nel size_t, width size_t, cmp uintptr) uintptr { /* bsearch.c:3:6: */
1144 var try uintptr
1145 var sign int32
1146 for nel > uint64(0) {
1147 try = base + uintptr(width*(nel/uint64(2)))
1148 sign = (*struct {
1149 f func(*TLS, uintptr, uintptr) int32
1150 })(unsafe.Pointer(&struct{ uintptr }{cmp})).f(tls, key, try)
1151 if sign < 0 {
1152 nel = nel / uint64(2)
1153 } else if sign > 0 {
1154 base = try + uintptr(width)
1155 nel = nel - (nel/uint64(2) + uint64(1))
1156 } else {
1157 return try
1158 }
1159 }
1160 return uintptr(0)
1161}
1162
1163// Support signed or unsigned plain-char
1164
1165// Implementation choices...
1166
1167// Arbitrary numbers...
1168
1169// POSIX/SUS requirements follow. These numbers come directly
1170// from SUS and have nothing to do with the host system.
1171
1172func X__strchrnul(tls *TLS, s uintptr, c int32) uintptr { /* strchrnul.c:10:6: */
1173 c = int32(uint8(c))
1174 if !(c != 0) {
1175 return s + uintptr(Xstrlen(tls, s))
1176 }
1177 var w uintptr
1178 for ; uint64(s)%uint64(unsafe.Sizeof(size_t(0))) != 0; s++ {
1179 if !(int32(*(*int8)(unsafe.Pointer(s))) != 0) || int32(*(*uint8)(unsafe.Pointer(s))) == c {
1180 return s
1181 }
1182 }
1183 var k size_t = Uint64(Uint64FromInt32(-1)) / uint64(255) * size_t(c)
1184 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 {
1185 }
1186 s = w
1187 for ; *(*int8)(unsafe.Pointer(s)) != 0 && int32(*(*uint8)(unsafe.Pointer(s))) != c; s++ {
1188 }
1189 return s
1190}
1191
1192func Xstrdup(tls *TLS, s uintptr) uintptr { /* strdup.c:4:6: */
1193 var l size_t = Xstrlen(tls, s)
1194 var d uintptr = Xmalloc(tls, l+uint64(1))
1195 if !(d != 0) {
1196 return uintptr(0)
1197 }
1198 return Xmemcpy(tls, d, s, l+uint64(1))
1199}
Note: See TracBrowser for help on using the repository browser.