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