source: code/trunk/vendor/modernc.org/libc/musl_openbsd_386.go@ 822

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