source: code/trunk/vendor/modernc.org/libc/musl_windows_amd64.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: 30.8 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_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
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:343:9 */
229
230type locale_t = uintptr /* alltypes.h:343: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:65:15 */
317
318type intptr_t = int32 /* alltypes.h:70:15 */
319
320type off_t = int32 /* alltypes.h:162:16 */
321
322type pid_t = int32 /* alltypes.h:235:13 */
323
324type uid_t = uint32 /* alltypes.h:245:18 */
325
326type gid_t = uint32 /* alltypes.h:250:18 */
327
328type useconds_t = uint32 /* alltypes.h:260: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:198:18 */
495
496type wctype_t = uint32 /* alltypes.h:203:23 */
497
498type __mbstate_t = struct {
499 __opaque1 uint32
500 __opaque2 uint32
501} /* alltypes.h:337:9 */
502
503type mbstate_t = __mbstate_t /* alltypes.h:337: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:55:24 */
520
521type int8_t = int8 /* alltypes.h:96:25 */
522
523type int16_t = int16 /* alltypes.h:101:25 */
524
525type int32_t = int32 /* alltypes.h:106:25 */
526
527type int64_t = int32 /* alltypes.h:111:25 */
528
529type intmax_t = int32 /* alltypes.h:116:25 */
530
531type uint8_t = uint8 /* alltypes.h:121:25 */
532
533type uint16_t = uint16 /* alltypes.h:126:25 */
534
535type uint32_t = uint32 /* alltypes.h:131:25 */
536
537type uint64_t = uint32 /* alltypes.h:136:25 */
538
539type uintmax_t = uint32 /* alltypes.h:146: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:343: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:85:16 */
647
648type clockid_t = int32 /* alltypes.h:214:13 */
649
650type timespec = struct {
651 tv_sec time_t
652 tv_nsec int32
653} /* alltypes.h:229: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:273:9 */
696
697type pthread_t = uintptr /* alltypes.h:273:26 */
698
699type pthread_once_t = int32 /* alltypes.h:279:13 */
700
701type pthread_key_t = uint32 /* alltypes.h:284:18 */
702
703type pthread_spinlock_t = int32 /* alltypes.h:289:13 */
704
705type pthread_mutexattr_t = struct{ __attr uint32 } /* alltypes.h:294:37 */
706
707type pthread_condattr_t = struct{ __attr uint32 } /* alltypes.h:299:37 */
708
709type pthread_barrierattr_t = struct{ __attr uint32 } /* alltypes.h:304:37 */
710
711type pthread_rwlockattr_t = struct{ __attr [2]uint32 } /* alltypes.h:309:40 */
712
713type __sigset_t = struct{ __bits [32]uint32 } /* alltypes.h:349:9 */
714
715type sigset_t = __sigset_t /* alltypes.h:349:71 */
716
717type pthread_attr_t = struct{ __u struct{ __i [9]int32 } } /* alltypes.h:372:147 */
718
719type pthread_mutex_t = struct {
720 __u struct {
721 _ [0]uint64
722 __i [6]int32
723 _ [24]byte
724 }
725} /* alltypes.h:377:157 */
726
727type pthread_cond_t = struct {
728 __u struct {
729 _ [0]uint64
730 __i [12]int32
731 }
732} /* alltypes.h:387:112 */
733
734type pthread_rwlock_t = struct {
735 __u struct {
736 _ [0]uint64
737 __i [8]int32
738 _ [32]byte
739 }
740} /* alltypes.h:397:139 */
741
742type pthread_barrier_t = struct {
743 __u struct {
744 _ [0]uint64
745 __i [5]int32
746 _ [20]byte
747 }
748} /* alltypes.h:402: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:209:14 */
761
762type clock_t = int32 /* alltypes.h:219: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:273: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 = int64 /* signal.h:59:19 */
805type gregset_t = [23]int64 /* signal.h:59:27 */
806type _fpstate = struct {
807 cwd uint16
808 swd uint16
809 ftw uint16
810 fop uint16
811 rip uint64
812 rdp uint64
813 mxcsr uint32
814 mxcr_mask uint32
815 _st [8]struct {
816 significand [4]uint16
817 exponent uint16
818 padding [3]uint16
819 }
820 _xmm [16]struct{ element [4]uint32 }
821 padding [24]uint32
822} /* signal.h:60:9 */
823
824type fpregset_t = uintptr /* signal.h:71:3 */
825type sigcontext = struct {
826 r8 uint32
827 r9 uint32
828 r10 uint32
829 r11 uint32
830 r12 uint32
831 r13 uint32
832 r14 uint32
833 r15 uint32
834 rdi uint32
835 rsi uint32
836 rbp uint32
837 rbx uint32
838 rdx uint32
839 rax uint32
840 rcx uint32
841 rsp uint32
842 rip uint32
843 eflags uint32
844 cs uint16
845 gs uint16
846 fs uint16
847 __pad0 uint16
848 err uint32
849 trapno uint32
850 oldmask uint32
851 cr2 uint32
852 fpstate uintptr
853 __reserved1 [8]uint32
854} /* signal.h:72:1 */
855
856type mcontext_t = struct {
857 gregs gregset_t
858 fpregs fpregset_t
859 __reserved1 [8]uint64
860} /* signal.h:84:3 */
861
862type __ucontext = struct {
863 uc_flags uint32
864 _ [4]byte
865 uc_link uintptr
866 uc_stack stack_t
867 uc_mcontext mcontext_t
868 uc_sigmask sigset_t
869 __fpregs_mem [64]uint32
870} /* signal.h:97:9 */
871
872type ucontext_t = __ucontext /* signal.h:104:3 */
873
874type sigval = struct {
875 _ [0]uint64
876 sival_int int32
877 _ [4]byte
878} /* time.h:107:1 */
879
880type siginfo_t = struct {
881 si_signo int32
882 si_errno int32
883 si_code int32
884 _ [4]byte
885 __si_fields struct {
886 _ [0]uint64
887 __pad [116]int8
888 _ [4]byte
889 }
890} /* signal.h:145:3 */
891
892type sigaction = struct {
893 __sa_handler struct{ sa_handler uintptr }
894 sa_mask sigset_t
895 sa_flags int32
896 _ [4]byte
897 sa_restorer uintptr
898} /* signal.h:167:1 */
899
900type sig_t = uintptr /* signal.h:251:14 */
901
902type sig_atomic_t = int32 /* signal.h:269:13 */
903
904type mode_t = uint32 /* alltypes.h:152:18 */
905
906type syscall_arg_t = int32 /* syscall.h:22:14 */
907
908func a_cas(tls *TLS, p uintptr, t int32, s int32) int32 { /* atomic_arch.h:2:19: */
909 panic(`arch\x86_64\atomic_arch.h:4:2: assembler statements not supported`)
910 return t
911}
912
913func a_or(tls *TLS, p uintptr, v int32) { /* atomic_arch.h:46:20: */
914 panic(`arch\x86_64\atomic_arch.h:48:2: assembler statements not supported`)
915}
916
917func a_or_64(tls *TLS, p uintptr, v uint64_t) { /* atomic_arch.h:62:20: */
918 panic(`arch\x86_64\atomic_arch.h:64:2: assembler statements not supported`)
919}
920
921func a_ctz_64(tls *TLS, x uint64_t) int32 { /* atomic_arch.h:112:19: */
922 panic(`arch\x86_64\atomic_arch.h:114:2: assembler statements not supported`)
923 return int32(x)
924}
925
926func a_ctz_32(tls *TLS, x uint32_t) int32 { /* atomic.h:256:19: */
927 return int32(_sdebruijn32[x&-x*uint32_t(0x076be629)>>27])
928}
929
930var _sdebruijn32 = [32]int8{
931 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),
932 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),
933} /* atomic.h:261:20 */
934
935type __timer = struct {
936 timerid int32
937 _ [4]byte
938 thread pthread_t
939} /* pthread_impl.h:64:1 */
940
941func __pthread_self(tls *TLS) uintptr { /* pthread_arch.h:1:30: */
942 var self uintptr
943 panic(`arch\x86_64\pthread_arch.h:4:2: assembler statements not supported`)
944 return self
945}
946
947func Xwcrtomb(tls *TLS, s uintptr, wc wchar_t, st uintptr) size_t { /* wcrtomb.c:6:8: */
948 if !(s != 0) {
949 return uint64(1)
950 }
951 if uint32(wc) < uint32(0x80) {
952 *(*int8)(unsafe.Pointer(s)) = int8(wc)
953 return uint64(1)
954 } else if func() int32 {
955 if !!(int32(*(*uintptr)(unsafe.Pointer((*__pthread)(unsafe.Pointer(__pthread_self(tls))).locale))) != 0) {
956 return 4
957 }
958 return 1
959 }() == 1 {
960 if !(uint32(wc)-uint32(0xdf80) < uint32(0x80)) {
961 *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 84
962 return Uint64FromInt32(-1)
963 }
964 *(*int8)(unsafe.Pointer(s)) = int8(wc)
965 return uint64(1)
966 } else if uint32(wc) < uint32(0x800) {
967 *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0xc0 | int32(wc)>>6)
968 *(*int8)(unsafe.Pointer(s)) = int8(0x80 | int32(wc)&0x3f)
969 return uint64(2)
970 } else if uint32(wc) < uint32(0xd800) || uint32(wc)-uint32(0xe000) < uint32(0x2000) {
971 *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0xe0 | int32(wc)>>12)
972 *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0x80 | int32(wc)>>6&0x3f)
973 *(*int8)(unsafe.Pointer(s)) = int8(0x80 | int32(wc)&0x3f)
974 return uint64(3)
975 } else if uint32(wc)-uint32(0x10000) < uint32(0x100000) {
976 *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0xf0 | int32(wc)>>18)
977 *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0x80 | int32(wc)>>12&0x3f)
978 *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(0x80 | int32(wc)>>6&0x3f)
979 *(*int8)(unsafe.Pointer(s)) = int8(0x80 | int32(wc)&0x3f)
980 return uint64(4)
981 }
982 *(*int32)(unsafe.Pointer(X___errno_location(tls))) = 84
983 return Uint64FromInt32(-1)
984}
985
986func Xwcsrtombs(tls *TLS, s uintptr, ws uintptr, n size_t, st uintptr) size_t { /* wcsrtombs.c:3:8: */
987 bp := tls.Alloc(4)
988 defer tls.Free(4)
989
990 var ws2 uintptr
991 // var buf [4]int8 at bp, 4
992
993 var N size_t = n
994 var l size_t
995 if !(s != 0) {
996 n = uint64(0)
997 ws2 = *(*uintptr)(unsafe.Pointer(ws))
998 for ; *(*wchar_t)(unsafe.Pointer(ws2)) != 0; ws2 += 2 {
999 if uint32(*(*wchar_t)(unsafe.Pointer(ws2))) >= 0x80 {
1000 l = Xwcrtomb(tls, bp, *(*wchar_t)(unsafe.Pointer(ws2)), uintptr(0))
1001 if !(l+uint64(1) != 0) {
1002 return Uint64FromInt32(-1)
1003 }
1004 n = n + l
1005 } else {
1006 n++
1007 }
1008 }
1009 return n
1010 }
1011 for n >= uint64(4) {
1012 if uint32(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))))-1 >= 0x7f {
1013 if !(int32(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws))))) != 0) {
1014 *(*int8)(unsafe.Pointer(s)) = int8(0)
1015 *(*uintptr)(unsafe.Pointer(ws)) = uintptr(0)
1016 return N - n
1017 }
1018 l = Xwcrtomb(tls, s, *(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))), uintptr(0))
1019 if !(l+uint64(1) != 0) {
1020 return Uint64FromInt32(-1)
1021 }
1022 s += uintptr(l)
1023 n = n - l
1024 } else {
1025 *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))))
1026 n--
1027 }
1028 *(*uintptr)(unsafe.Pointer(ws)) += 2
1029 }
1030 for n != 0 {
1031 if uint32(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))))-1 >= 0x7f {
1032 if !(int32(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws))))) != 0) {
1033 *(*int8)(unsafe.Pointer(s)) = int8(0)
1034 *(*uintptr)(unsafe.Pointer(ws)) = uintptr(0)
1035 return N - n
1036 }
1037 l = Xwcrtomb(tls, bp, *(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))), uintptr(0))
1038 if !(l+uint64(1) != 0) {
1039 return Uint64FromInt32(-1)
1040 }
1041 if l > n {
1042 return N - n
1043 }
1044 Xwcrtomb(tls, s, *(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))), uintptr(0))
1045 s += uintptr(l)
1046 n = n - l
1047 } else {
1048 *(*int8)(unsafe.Pointer(PostIncUintptr(&s, 1))) = int8(*(*wchar_t)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ws)))))
1049 n--
1050 }
1051 *(*uintptr)(unsafe.Pointer(ws)) += 2
1052 }
1053 return N
1054}
1055
1056func Xwcstombs(tls *TLS, s uintptr, ws uintptr, n size_t) size_t { /* wcstombs.c:4:8: */
1057 bp := tls.Alloc(8)
1058 defer tls.Free(8)
1059 *(*uintptr)(unsafe.Pointer(bp)) = ws
1060
1061 //TODO return wcsrtombs(s, &(const wchar_t *){ws}, n, 0);
1062 return Xwcsrtombs(tls, s, bp, n, uintptr(0))
1063}
1064
1065func Xbsearch(tls *TLS, key uintptr, base uintptr, nel size_t, width size_t, cmp uintptr) uintptr { /* bsearch.c:3:6: */
1066 var try uintptr
1067 var sign int32
1068 for nel > uint64(0) {
1069 try = base + uintptr(width*(nel/uint64(2)))
1070 sign = (*struct {
1071 f func(*TLS, uintptr, uintptr) int32
1072 })(unsafe.Pointer(&struct{ uintptr }{cmp})).f(tls, key, try)
1073 if sign < 0 {
1074 nel = nel / uint64(2)
1075 } else if sign > 0 {
1076 base = try + uintptr(width)
1077 nel = nel - (nel/uint64(2) + uint64(1))
1078 } else {
1079 return try
1080 }
1081 }
1082 return uintptr(0)
1083}
1084
1085// Support signed or unsigned plain-char
1086
1087// Implementation choices...
1088
1089// Arbitrary numbers...
1090
1091// POSIX/SUS requirements follow. These numbers come directly
1092// from SUS and have nothing to do with the host system.
1093
1094func X__strchrnul(tls *TLS, s uintptr, c int32) uintptr { /* strchrnul.c:10:6: */
1095 c = int32(uint8(c))
1096 if !(c != 0) {
1097 return s + uintptr(Xstrlen(tls, s))
1098 }
1099 var w uintptr
1100 for ; uint64(s)%uint64(unsafe.Sizeof(size_t(0))) != 0; s++ {
1101 if !(int32(*(*int8)(unsafe.Pointer(s))) != 0) || int32(*(*uint8)(unsafe.Pointer(s))) == c {
1102 return s
1103 }
1104 }
1105 var k size_t = Uint64(Uint64FromInt32(-1)) / uint64(255) * size_t(c)
1106 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 {
1107 }
1108 s = w
1109 for ; *(*int8)(unsafe.Pointer(s)) != 0 && int32(*(*uint8)(unsafe.Pointer(s))) != c; s++ {
1110 }
1111 return s
1112}
1113
1114func Xstrdup(tls *TLS, s uintptr) uintptr { /* strdup.c:4:6: */
1115 var l size_t = Xstrlen(tls, s)
1116 var d uintptr = Xmalloc(tls, l+uint64(1))
1117 if !(d != 0) {
1118 return uintptr(0)
1119 }
1120 return Xmemcpy(tls, d, s, l+uint64(1))
1121}
Note: See TracBrowser for help on using the repository browser.