Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Commit

Permalink
Make arch-specific constants dependent on sys.info().machine
Browse files Browse the repository at this point in the history
Values such as socket constants and types are arch-specific and can
only be resolved at runtime.

Patch by RT-RK.

BUG= #496
TEST= ninja -C out/DebugXMIPS
R=erikcorry@google.com

Review URL: https://codereview.chromium.org/2203023002 .

Patch from "RT-RK" <petarj@mips.com>.
  • Loading branch information
petar-jovanovic authored and ErikCorryGoogle committed Aug 10, 2016
1 parent 534503c commit f747120
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions pkg/os/lib/src/errno.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ abstract class _PosixErrnos extends Errnos {
}

class _LinuxErrnos extends _PosixErrnos {
int get EADDRNOTAVAIL => 99;
int get EINPROGRESS => 115;
static final bool isMips = sys.info().machine == 'mips';
int get EADDRNOTAVAIL => isMips ? 126 : 99;
int get EINPROGRESS => isMips ? 150 : 115;
}

class _MacOSErrnos extends _PosixErrnos {
Expand Down
14 changes: 8 additions & 6 deletions pkg/os/lib/src/system_linux.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ class LinuxSystem extends PosixSystem {
static final ForeignFunction _openLinux =
ForeignLibrary.main.lookup("open64");

static final bool isMips = sys.info().machine == 'mips';

int get AF_INET6 => 10;

int get O_CREAT => 64;
int get O_CREAT => isMips ? 256 : 64;
int get O_TRUNC => 512;
int get O_APPEND => 1024;
int get O_NONBLOCK => 2048;
int get O_APPEND => isMips ? 8 : 1024;
int get O_NONBLOCK => isMips ? 128 : 2048;
int get O_CLOEXEC => 524288;

int get FIONREAD => 0x541B;
int get FIONREAD => isMips ? 0x467f : 0x541b;

int get SOL_SOCKET => 1;
int get SOL_SOCKET => isMips ? 65535 : 1;

int get SO_REUSEADDR => 2;
int get SO_REUSEADDR => isMips ? 4 : 2;

// The size of fields and the struct used by uname.
// From /usr/include/sys/utsname.h
Expand Down
6 changes: 4 additions & 2 deletions pkg/os/lib/src/system_posix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ abstract class PosixSystem implements System {
static final ForeignFunction _uname =
ForeignLibrary.main.lookup("uname");

static final bool isMips = sys.info().machine == 'mips';

int get AF_INET => 2;
int get AF_INET6;

int get SOCK_STREAM => 1;
int get SOCK_DGRAM => 2;
int get SOCK_STREAM => isMips ? 2 : 1;
int get SOCK_DGRAM => isMips ? 1 : 2;

int get O_RDONLY => 0;
int get O_WRONLY => 1;
Expand Down

0 comments on commit f747120

Please sign in to comment.