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

Commit

Permalink
add static asserts for constants of untested architectures
Browse files Browse the repository at this point in the history
- also remove version (X86 || X86_64) idiom
  • Loading branch information
MartinNowak committed Feb 14, 2013
1 parent e7b3de4 commit b47fd19
Show file tree
Hide file tree
Showing 5 changed files with 267 additions and 149 deletions.
33 changes: 24 additions & 9 deletions src/core/sys/posix/fcntl.d
Expand Up @@ -101,20 +101,20 @@ version( linux )
enum F_UNLCK = 2;
enum F_WRLCK = 1;

version (MIPS)
version (X86)
{
enum O_CREAT = 0x0100;
enum O_EXCL = 0x0400;
enum O_NOCTTY = 0x0800;
enum O_TRUNC = 0x0200;
enum O_CREAT = 0x40; // octal 0100
enum O_EXCL = 0x80; // octal 0200
enum O_NOCTTY = 0x100; // octal 0400
enum O_TRUNC = 0x200; // octal 01000

enum O_APPEND = 0x0008;
enum O_APPEND = 0x400; // octal 02000
enum O_NONBLOCK = 0x800; // octal 04000
enum O_SYNC = 0x1000; // octal 010000
enum O_DSYNC = O_SYNC;
enum O_NONBLOCK = 0x0080;
enum O_RSYNC = O_SYNC;
enum O_SYNC = 0x0010;
}
else
else version (X86_64)
{
enum O_CREAT = 0x40; // octal 0100
enum O_EXCL = 0x80; // octal 0200
Expand All @@ -127,6 +127,21 @@ version( linux )
enum O_DSYNC = O_SYNC;
enum O_RSYNC = O_SYNC;
}
else version (MIPS32)
{
enum O_CREAT = 0x0100;
enum O_EXCL = 0x0400;
enum O_NOCTTY = 0x0800;
enum O_TRUNC = 0x0200;

enum O_APPEND = 0x0008;
enum O_DSYNC = O_SYNC;
enum O_NONBLOCK = 0x0080;
enum O_RSYNC = O_SYNC;
enum O_SYNC = 0x0010;
}
else
static assert(0, "unimplemented");

enum O_ACCMODE = 0x3;
enum O_RDONLY = 0x0;
Expand Down
81 changes: 60 additions & 21 deletions src/core/sys/posix/signal.d
Expand Up @@ -113,13 +113,13 @@ version( Posix )

version( linux )
{
version (MIPS)
version (X86)
{
//SIGABRT (defined in core.stdc.signal)
enum SIGALRM = 14;
enum SIGBUS = 10;
enum SIGCHLD = 18;
enum SIGCONT = 25;
enum SIGBUS = 7;
enum SIGCHLD = 17;
enum SIGCONT = 18;
//SIGFPE (defined in core.stdc.signal)
enum SIGHUP = 1;
//SIGILL (defined in core.stdc.signal)
Expand All @@ -128,16 +128,16 @@ version( linux )
enum SIGPIPE = 13;
enum SIGQUIT = 3;
//SIGSEGV (defined in core.stdc.signal)
enum SIGSTOP = 23;
enum SIGSTOP = 19;
//SIGTERM (defined in core.stdc.signal)
enum SIGTSTP = 24;
enum SIGTTIN = 26;
enum SIGTTOU = 27;
enum SIGUSR1 = 16;
enum SIGUSR2 = 17;
enum SIGURG = 21;
enum SIGTSTP = 20;
enum SIGTTIN = 21;
enum SIGTTOU = 22;
enum SIGUSR1 = 10;
enum SIGUSR2 = 12;
enum SIGURG = 23;
}
else
else version (X86_64)
{
//SIGABRT (defined in core.stdc.signal)
enum SIGALRM = 14;
Expand All @@ -161,6 +161,32 @@ version( linux )
enum SIGUSR2 = 12;
enum SIGURG = 23;
}
else version (MIPS32)
{
//SIGABRT (defined in core.stdc.signal)
enum SIGALRM = 14;
enum SIGBUS = 10;
enum SIGCHLD = 18;
enum SIGCONT = 25;
//SIGFPE (defined in core.stdc.signal)
enum SIGHUP = 1;
//SIGILL (defined in core.stdc.signal)
//SIGINT (defined in core.stdc.signal)
enum SIGKILL = 9;
enum SIGPIPE = 13;
enum SIGQUIT = 3;
//SIGSEGV (defined in core.stdc.signal)
enum SIGSTOP = 23;
//SIGTERM (defined in core.stdc.signal)
enum SIGTSTP = 24;
enum SIGTTIN = 26;
enum SIGTTOU = 27;
enum SIGUSR1 = 16;
enum SIGUSR2 = 17;
enum SIGURG = 21;
}
else
static assert(0, "unimplemented");
}
else version( OSX )
{
Expand Down Expand Up @@ -804,17 +830,17 @@ int sigrelse(int);

version( linux )
{
version (MIPS)
version (X86)
{
enum SIGPOLL = 22;
enum SIGPROF = 29;
enum SIGSYS = 12;
enum SIGTRAP = 5;
enum SIGVTALRM = 28;
enum SIGXCPU = 30;
enum SIGXFSZ = 31;
enum SIGPOLL = 29;
enum SIGPROF = 27;
enum SIGSYS = 31;
enum SIGTRAP = 5;
enum SIGVTALRM = 26;
enum SIGXCPU = 24;
enum SIGXFSZ = 25;
}
else
else version (X86_64)
{
enum SIGPOLL = 29;
enum SIGPROF = 27;
Expand All @@ -824,6 +850,19 @@ version( linux )
enum SIGXCPU = 24;
enum SIGXFSZ = 25;
}
else version (MIPS32)
{
enum SIGPOLL = 22;
enum SIGPROF = 29;
enum SIGSYS = 12;
enum SIGTRAP = 5;
enum SIGVTALRM = 28;
enum SIGXCPU = 30;
enum SIGXFSZ = 31;
}
else
static assert(0, "unimplemented");

enum SA_ONSTACK = 0x08000000;
enum SA_RESETHAND = 0x80000000;
enum SA_RESTART = 0x10000000;
Expand Down
8 changes: 6 additions & 2 deletions src/core/sys/posix/sys/mman.d
Expand Up @@ -184,10 +184,14 @@ version( linux )
enum MAP_PRIVATE = 0x02;
enum MAP_FIXED = 0x10;

version (MIPS)
version (X86)
enum MAP_ANON = 0x20; // non-standard
else version (X86_64)
enum MAP_ANON = 0x20; // non-standard
else version (MIPS32)
enum MAP_ANON = 0x0800; // non-standard
else
enum MAP_ANON = 0x20; // non-standard
static assert(0, "unimplemented");

enum MAP_FAILED = cast(void*) -1;

Expand Down
78 changes: 57 additions & 21 deletions src/core/sys/posix/sys/socket.d
Expand Up @@ -208,41 +208,41 @@ version( linux )
int l_linger;
}

version (MIPS)
version (X86)
{
enum
{
SOCK_DGRAM = 1,
SOCK_DGRAM = 2,
SOCK_SEQPACKET = 5,
SOCK_STREAM = 2,
SOCK_STREAM = 1
}

enum
{
SOL_SOCKET = 0xffff
SOL_SOCKET = 1
}

enum
{
SO_ACCEPTCONN = 0x1009,
SO_BROADCAST = 0x0020,
SO_DEBUG = 0x0001,
SO_DONTROUTE = 0x0010,
SO_ERROR = 0x1007,
SO_KEEPALIVE = 0x0008,
SO_LINGER = 0x0080,
SO_OOBINLINE = 0x0100,
SO_RCVBUF = 0x1002,
SO_RCVLOWAT = 0x1004,
SO_RCVTIMEO = 0x1006,
SO_REUSEADDR = 0x0004,
SO_SNDBUF = 0x1001,
SO_SNDLOWAT = 0x1003,
SO_SNDTIMEO = 0x1005,
SO_TYPE = 0x1008,
SO_ACCEPTCONN = 30,
SO_BROADCAST = 6,
SO_DEBUG = 1,
SO_DONTROUTE = 5,
SO_ERROR = 4,
SO_KEEPALIVE = 9,
SO_LINGER = 13,
SO_OOBINLINE = 10,
SO_RCVBUF = 8,
SO_RCVLOWAT = 18,
SO_RCVTIMEO = 20,
SO_REUSEADDR = 2,
SO_SNDBUF = 7,
SO_SNDLOWAT = 19,
SO_SNDTIMEO = 21,
SO_TYPE = 3
}
}
else
else version (X86_64)
{
enum
{
Expand Down Expand Up @@ -276,6 +276,42 @@ version( linux )
SO_TYPE = 3
}
}
else version (MIPS32)
{
enum
{
SOCK_DGRAM = 1,
SOCK_SEQPACKET = 5,
SOCK_STREAM = 2,
}

enum
{
SOL_SOCKET = 0xffff
}

enum
{
SO_ACCEPTCONN = 0x1009,
SO_BROADCAST = 0x0020,
SO_DEBUG = 0x0001,
SO_DONTROUTE = 0x0010,
SO_ERROR = 0x1007,
SO_KEEPALIVE = 0x0008,
SO_LINGER = 0x0080,
SO_OOBINLINE = 0x0100,
SO_RCVBUF = 0x1002,
SO_RCVLOWAT = 0x1004,
SO_RCVTIMEO = 0x1006,
SO_REUSEADDR = 0x0004,
SO_SNDBUF = 0x1001,
SO_SNDLOWAT = 0x1003,
SO_SNDTIMEO = 0x1005,
SO_TYPE = 0x1008,
}
}
else
static assert(0, "unimplemented");

enum
{
Expand Down

0 comments on commit b47fd19

Please sign in to comment.