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