Skip to content

Commit 8b14a7e

Browse files
committed
Auto merge of #1335 - leo60228:patch-1, r=gnzlbg
Improve newlib constants This is necessary to set socket options on the Nintendo Switch, which uses a socket implementation directly ported from FreeBSD. Reopened from #1334 because I accidentally closed that.
2 parents 5408b10 + a92266b commit 8b14a7e

File tree

3 files changed

+113
-12
lines changed

3 files changed

+113
-12
lines changed

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,27 @@ matrix:
207207
- env: TARGET=wasm32-wasi
208208
rust: nightly
209209
stage: tier2
210+
- name: "Nintendo Switch - build libcore only"
211+
rust: nightly
212+
stage: tier2
213+
install:
214+
- rustup component add rust-src
215+
- (test -x $HOME/.cargo/bin/cargo-xbuild || cargo install cargo-xbuild)
216+
script:
217+
- mkdir -p target
218+
- cd target
219+
- wget https://github.com/devkitPro/pacman/releases/download/devkitpro-pacman-1.0.1/devkitpro-pacman.deb
220+
- sudo dpkg -i devkitpro-pacman.deb
221+
- sudo dkp-pacman -Sy
222+
- sudo dkp-pacman -Syu
223+
- sudo dkp-pacman -S -v --noconfirm switch-dev devkitA64
224+
- export PATH="$PATH:/opt/devkitpro/devkitA64/bin"
225+
- export PATH="$PATH:/opt/devkitpro/tools/bin"
226+
- cd ..
227+
# Pull the target spec up into the current directory and then build
228+
- mv ci/switch.json switch.json
229+
- cargo xbuild --target switch.json
230+
210231

211232
allow_failures:
212233
# FIXME: android build bots time out irregularly

ci/switch.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"family": "unix",
3+
"env": "newlib",
4+
"target-env": "newlib",
5+
"target-family": "unix",
6+
"target-c-int-width": "32",
7+
"target-endian": "little",
8+
"target-pointer-width": "64",
9+
"os": "horizon",
10+
"arch": "aarch64",
11+
"panic-strategy": "unwind",
12+
"abi-blacklist": [
13+
"stdcall",
14+
"fastcall",
15+
"vectorcall",
16+
"thiscall",
17+
"win64",
18+
"sysv64"
19+
],
20+
"dynamic-linking" : false,
21+
"features": "+a53,+strict-align",
22+
"data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
23+
"executables": true,
24+
"position-independent-executables" : true,
25+
"linker-flavor": "gcc",
26+
"llvm-target": "aarch64-unknown-none",
27+
"has-elf-tls" : false,
28+
"linker-is-gnu" : true,
29+
"disable-redzone" : true,
30+
"relocation-model" : "pic",
31+
"max-atomic-width": 128,
32+
"exe-suffix": ".elf",
33+
"staticlib-suffix" : ".a",
34+
"trap-unreachable" : true,
35+
"emit-debug-gdb-scripts" : true,
36+
"requires-uwtable" : true
37+
}

src/unix/newlib/mod.rs

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ pub const SEEK_SET: ::c_int = 0;
406406
pub const SEEK_CUR: ::c_int = 1;
407407
pub const SEEK_END: ::c_int = 2;
408408

409-
pub const FIONBIO: ::c_int = 1;
409+
pub const FIONBIO: ::c_ulong = 1;
410+
pub const FIOCLEX: ::c_ulong = 0x20006601;
410411

411412
pub const S_BLKSIZE: ::mode_t = 1024;
412413
pub const S_IREAD: ::mode_t = 256;
@@ -457,15 +458,41 @@ pub const SHUT_RD: ::c_int = 0;
457458
pub const SHUT_WR: ::c_int = 1;
458459
pub const SHUT_RDWR: ::c_int = 2;
459460

460-
pub const SO_REUSEADDR: ::c_int = 4;
461-
pub const SO_LINGER: ::c_int = 128;
462-
pub const SO_OOBINLINE: ::c_int = 256;
463-
pub const SO_SNDBUF: ::c_int = 4097;
464-
pub const SO_RCVBUF: ::c_int = 4098;
465-
pub const SO_SNDLOWAT: ::c_int = 4099;
466-
pub const SO_RCVLOWAT: ::c_int = 4100;
467-
pub const SO_TYPE: ::c_int = 4104;
468-
pub const SO_ERROR: ::c_int = 4105;
461+
pub const SO_BINTIME: ::c_int = 0x2000;
462+
pub const SO_NO_OFFLOAD: ::c_int = 0x4000;
463+
pub const SO_NO_DDP: ::c_int = 0x8000;
464+
pub const SO_REUSEPORT_LB: ::c_int = 0x10000;
465+
pub const SO_LABEL: ::c_int = 0x1009;
466+
pub const SO_PEERLABEL: ::c_int = 0x1010;
467+
pub const SO_LISTENQLIMIT: ::c_int = 0x1011;
468+
pub const SO_LISTENQLEN: ::c_int = 0x1012;
469+
pub const SO_LISTENINCQLEN: ::c_int = 0x1013;
470+
pub const SO_SETFIB: ::c_int = 0x1014;
471+
pub const SO_USER_COOKIE: ::c_int = 0x1015;
472+
pub const SO_PROTOCOL: ::c_int = 0x1016;
473+
pub const SO_PROTOTYPE: ::c_int = SO_PROTOCOL;
474+
pub const SO_VENDOR: ::c_int = 0x80000000;
475+
pub const SO_DEBUG: ::c_int = 0x01;
476+
pub const SO_ACCEPTCONN: ::c_int = 0x0002;
477+
pub const SO_REUSEADDR: ::c_int = 0x0004;
478+
pub const SO_KEEPALIVE: ::c_int = 0x0008;
479+
pub const SO_DONTROUTE: ::c_int = 0x0010;
480+
pub const SO_BROADCAST: ::c_int = 0x0020;
481+
pub const SO_USELOOPBACK: ::c_int = 0x0040;
482+
pub const SO_LINGER: ::c_int = 0x0080;
483+
pub const SO_OOBINLINE: ::c_int = 0x0100;
484+
pub const SO_REUSEPORT: ::c_int = 0x0200;
485+
pub const SO_TIMESTAMP: ::c_int = 0x0400;
486+
pub const SO_NOSIGPIPE: ::c_int = 0x0800;
487+
pub const SO_ACCEPTFILTER: ::c_int = 0x1000;
488+
pub const SO_SNDBUF: ::c_int = 0x1001;
489+
pub const SO_RCVBUF: ::c_int = 0x1002;
490+
pub const SO_SNDLOWAT: ::c_int = 0x1003;
491+
pub const SO_RCVLOWAT: ::c_int = 0x1004;
492+
pub const SO_SNDTIMEO: ::c_int = 0x1005;
493+
pub const SO_RCVTIMEO: ::c_int = 0x1006;
494+
pub const SO_ERROR: ::c_int = 0x1007;
495+
pub const SO_TYPE: ::c_int = 0x1008;
469496

470497
pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
471498

@@ -493,14 +520,30 @@ pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
493520

494521
pub const TCP_NODELAY: ::c_int = 8193;
495522
pub const TCP_MAXSEG: ::c_int = 8194;
523+
pub const TCP_NOPUSH: ::c_int = 4;
524+
pub const TCP_NOOPT: ::c_int = 8;
525+
pub const TCP_KEEPIDLE: ::c_int = 256;
526+
pub const TCP_KEEPINTVL: ::c_int = 512;
527+
pub const TCP_KEEPCNT: ::c_int = 1024;
496528

497-
pub const IP_TOS: ::c_int = 7;
529+
pub const IP_TOS: ::c_int = 3;
498530
pub const IP_TTL: ::c_int = 8;
499-
pub const IP_MULTICAST_LOOP: ::c_int = 9;
531+
pub const IP_MULTICAST_IF: ::c_int = 9;
500532
pub const IP_MULTICAST_TTL: ::c_int = 10;
533+
pub const IP_MULTICAST_LOOP: ::c_int = 11;
501534
pub const IP_ADD_MEMBERSHIP: ::c_int = 11;
502535
pub const IP_DROP_MEMBERSHIP: ::c_int = 12;
503536

537+
pub const IPV6_UNICAST_HOPS: ::c_int = 4;
538+
pub const IPV6_MULTICAST_IF: ::c_int = 9;
539+
pub const IPV6_MULTICAST_HOPS: ::c_int = 10;
540+
pub const IPV6_MULTICAST_LOOP: ::c_int = 11;
541+
pub const IPV6_V6ONLY: ::c_int = 27;
542+
pub const IPV6_JOIN_GROUP: ::c_int = 12;
543+
pub const IPV6_LEAVE_GROUP: ::c_int = 13;
544+
pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12;
545+
pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13;
546+
504547
pub const HOST_NOT_FOUND: ::c_int = 1;
505548
pub const NO_DATA: ::c_int = 2;
506549
pub const NO_ADDRESS: ::c_int = 2;

0 commit comments

Comments
 (0)