Skip to content

Commit

Permalink
Auto merge of #1335 - leo60228:patch-1, r=gnzlbg
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed May 13, 2019
2 parents 39ca01c + a92266b commit 23046f8
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 12 deletions.
21 changes: 21 additions & 0 deletions .travis.yml
Expand Up @@ -207,6 +207,27 @@ matrix:
- env: TARGET=wasm32-unknown-wasi
rust: nightly
stage: tier2
- name: "Nintendo Switch - build libcore only"
rust: nightly
stage: tier2
install:
- rustup component add rust-src
- (test -x $HOME/.cargo/bin/cargo-xbuild || cargo install cargo-xbuild)
script:
- mkdir -p target
- cd target
- wget https://github.com/devkitPro/pacman/releases/download/devkitpro-pacman-1.0.1/devkitpro-pacman.deb
- sudo dpkg -i devkitpro-pacman.deb
- sudo dkp-pacman -Sy
- sudo dkp-pacman -Syu
- sudo dkp-pacman -S -v --noconfirm switch-dev devkitA64
- export PATH="$PATH:/opt/devkitpro/devkitA64/bin"
- export PATH="$PATH:/opt/devkitpro/tools/bin"
- cd ..
# Pull the target spec up into the current directory and then build
- mv ci/switch.json switch.json
- cargo xbuild --target switch.json


allow_failures:
# FIXME: android build bots time out irregularly
Expand Down
37 changes: 37 additions & 0 deletions ci/switch.json
@@ -0,0 +1,37 @@
{
"family": "unix",
"env": "newlib",
"target-env": "newlib",
"target-family": "unix",
"target-c-int-width": "32",
"target-endian": "little",
"target-pointer-width": "64",
"os": "horizon",
"arch": "aarch64",
"panic-strategy": "unwind",
"abi-blacklist": [
"stdcall",
"fastcall",
"vectorcall",
"thiscall",
"win64",
"sysv64"
],
"dynamic-linking" : false,
"features": "+a53,+strict-align",
"data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128",
"executables": true,
"position-independent-executables" : true,
"linker-flavor": "gcc",
"llvm-target": "aarch64-unknown-none",
"has-elf-tls" : false,
"linker-is-gnu" : true,
"disable-redzone" : true,
"relocation-model" : "pic",
"max-atomic-width": 128,
"exe-suffix": ".elf",
"staticlib-suffix" : ".a",
"trap-unreachable" : true,
"emit-debug-gdb-scripts" : true,
"requires-uwtable" : true
}
67 changes: 55 additions & 12 deletions src/unix/newlib/mod.rs
Expand Up @@ -406,7 +406,8 @@ pub const SEEK_SET: ::c_int = 0;
pub const SEEK_CUR: ::c_int = 1;
pub const SEEK_END: ::c_int = 2;

pub const FIONBIO: ::c_int = 1;
pub const FIONBIO: ::c_ulong = 1;
pub const FIOCLEX: ::c_ulong = 0x20006601;

pub const S_BLKSIZE: ::mode_t = 1024;
pub const S_IREAD: ::mode_t = 256;
Expand Down Expand Up @@ -457,15 +458,41 @@ pub const SHUT_RD: ::c_int = 0;
pub const SHUT_WR: ::c_int = 1;
pub const SHUT_RDWR: ::c_int = 2;

pub const SO_REUSEADDR: ::c_int = 4;
pub const SO_LINGER: ::c_int = 128;
pub const SO_OOBINLINE: ::c_int = 256;
pub const SO_SNDBUF: ::c_int = 4097;
pub const SO_RCVBUF: ::c_int = 4098;
pub const SO_SNDLOWAT: ::c_int = 4099;
pub const SO_RCVLOWAT: ::c_int = 4100;
pub const SO_TYPE: ::c_int = 4104;
pub const SO_ERROR: ::c_int = 4105;
pub const SO_BINTIME: ::c_int = 0x2000;
pub const SO_NO_OFFLOAD: ::c_int = 0x4000;
pub const SO_NO_DDP: ::c_int = 0x8000;
pub const SO_REUSEPORT_LB: ::c_int = 0x10000;
pub const SO_LABEL: ::c_int = 0x1009;
pub const SO_PEERLABEL: ::c_int = 0x1010;
pub const SO_LISTENQLIMIT: ::c_int = 0x1011;
pub const SO_LISTENQLEN: ::c_int = 0x1012;
pub const SO_LISTENINCQLEN: ::c_int = 0x1013;
pub const SO_SETFIB: ::c_int = 0x1014;
pub const SO_USER_COOKIE: ::c_int = 0x1015;
pub const SO_PROTOCOL: ::c_int = 0x1016;
pub const SO_PROTOTYPE: ::c_int = SO_PROTOCOL;
pub const SO_VENDOR: ::c_int = 0x80000000;
pub const SO_DEBUG: ::c_int = 0x01;
pub const SO_ACCEPTCONN: ::c_int = 0x0002;
pub const SO_REUSEADDR: ::c_int = 0x0004;
pub const SO_KEEPALIVE: ::c_int = 0x0008;
pub const SO_DONTROUTE: ::c_int = 0x0010;
pub const SO_BROADCAST: ::c_int = 0x0020;
pub const SO_USELOOPBACK: ::c_int = 0x0040;
pub const SO_LINGER: ::c_int = 0x0080;
pub const SO_OOBINLINE: ::c_int = 0x0100;
pub const SO_REUSEPORT: ::c_int = 0x0200;
pub const SO_TIMESTAMP: ::c_int = 0x0400;
pub const SO_NOSIGPIPE: ::c_int = 0x0800;
pub const SO_ACCEPTFILTER: ::c_int = 0x1000;
pub const SO_SNDBUF: ::c_int = 0x1001;
pub const SO_RCVBUF: ::c_int = 0x1002;
pub const SO_SNDLOWAT: ::c_int = 0x1003;
pub const SO_RCVLOWAT: ::c_int = 0x1004;
pub const SO_SNDTIMEO: ::c_int = 0x1005;
pub const SO_RCVTIMEO: ::c_int = 0x1006;
pub const SO_ERROR: ::c_int = 0x1007;
pub const SO_TYPE: ::c_int = 0x1008;

pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;

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

pub const TCP_NODELAY: ::c_int = 8193;
pub const TCP_MAXSEG: ::c_int = 8194;
pub const TCP_NOPUSH: ::c_int = 4;
pub const TCP_NOOPT: ::c_int = 8;
pub const TCP_KEEPIDLE: ::c_int = 256;
pub const TCP_KEEPINTVL: ::c_int = 512;
pub const TCP_KEEPCNT: ::c_int = 1024;

pub const IP_TOS: ::c_int = 7;
pub const IP_TOS: ::c_int = 3;
pub const IP_TTL: ::c_int = 8;
pub const IP_MULTICAST_LOOP: ::c_int = 9;
pub const IP_MULTICAST_IF: ::c_int = 9;
pub const IP_MULTICAST_TTL: ::c_int = 10;
pub const IP_MULTICAST_LOOP: ::c_int = 11;
pub const IP_ADD_MEMBERSHIP: ::c_int = 11;
pub const IP_DROP_MEMBERSHIP: ::c_int = 12;

pub const IPV6_UNICAST_HOPS: ::c_int = 4;
pub const IPV6_MULTICAST_IF: ::c_int = 9;
pub const IPV6_MULTICAST_HOPS: ::c_int = 10;
pub const IPV6_MULTICAST_LOOP: ::c_int = 11;
pub const IPV6_V6ONLY: ::c_int = 27;
pub const IPV6_JOIN_GROUP: ::c_int = 12;
pub const IPV6_LEAVE_GROUP: ::c_int = 13;
pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12;
pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13;

pub const HOST_NOT_FOUND: ::c_int = 1;
pub const NO_DATA: ::c_int = 2;
pub const NO_ADDRESS: ::c_int = 2;
Expand Down

0 comments on commit 23046f8

Please sign in to comment.