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

Commit

Permalink
Merge pull request #893 from joakim-noah/deprecate_std_c
Browse files Browse the repository at this point in the history
Move declarations here from std.c.* before deprecating it
  • Loading branch information
yebblies committed Oct 15, 2014
2 parents 393cb29 + 2f06c5a commit 54216d5
Show file tree
Hide file tree
Showing 11 changed files with 624 additions and 25 deletions.
3 changes: 3 additions & 0 deletions mak/COPY
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ COPY=\
$(IMPDIR)\core\sys\linux\link.d \
$(IMPDIR)\core\sys\linux\termios.d \
$(IMPDIR)\core\sys\linux\time.d \
$(IMPDIR)\core\sys\linux\tipc.d \
\
$(IMPDIR)\core\sys\linux\sys\inotify.d \
$(IMPDIR)\core\sys\linux\sys\mman.d \
Expand Down Expand Up @@ -125,9 +126,11 @@ COPY=\
$(IMPDIR)\core\sys\solaris\sys\priocntl.d \
$(IMPDIR)\core\sys\solaris\execinfo.d \
\
$(IMPDIR)\core\sys\windows\com.d \
$(IMPDIR)\core\sys\windows\dbghelp.d \
$(IMPDIR)\core\sys\windows\dll.d \
$(IMPDIR)\core\sys\windows\stacktrace.d \
$(IMPDIR)\core\sys\windows\stat.d \
$(IMPDIR)\core\sys\windows\threadaux.d \
$(IMPDIR)\core\sys\windows\windows.d \
\
Expand Down
3 changes: 3 additions & 0 deletions mak/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ MANIFEST=\
src\core\sys\linux\link.d \
src\core\sys\linux\termios.d \
src\core\sys\linux\time.d \
src\core\sys\linux\tipc.d \
\
src\core\sys\linux\sys\inotify.d \
src\core\sys\linux\sys\mman.d \
Expand Down Expand Up @@ -156,9 +157,11 @@ MANIFEST=\
src\core\sys\solaris\sys\types.d \
src\core\sys\solaris\execinfo.d \
\
src\core\sys\windows\com.d \
src\core\sys\windows\dbghelp.d \
src\core\sys\windows\dll.d \
src\core\sys\windows\stacktrace.d \
src\core\sys\windows\stat.d \
src\core\sys\windows\threadaux.d \
src\core\sys\windows\windows.d \
\
Expand Down
4 changes: 4 additions & 0 deletions mak/SRCS
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ SRCS=\
src\core\sys\freebsd\execinfo.d \
src\core\sys\freebsd\sys\event.d \
\
src\core\sys\linux\tipc.d \
\
src\core\sys\posix\signal.d \
src\core\sys\posix\dirent.d \
src\core\sys\posix\sys\resource.d \
Expand All @@ -62,9 +64,11 @@ SRCS=\
src\core\sys\solaris\sys\types.d \
src\core\sys\solaris\sys\procset.d \
\
src\core\sys\windows\com.d \
src\core\sys\windows\dbghelp.d \
src\core\sys\windows\dll.d \
src\core\sys\windows\stacktrace.d \
src\core\sys\windows\stat.d \
src\core\sys\windows\threadaux.d \
src\core\sys\windows\windows.d \
\
Expand Down
2 changes: 1 addition & 1 deletion src/core/stdc/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ version(CRuntime_DigitalMars)
private extern __gshared int[_MAX_SEMAPHORES] _iSemThreadIds;
private extern __gshared int[_MAX_SEMAPHORES] _iSemNestCount;
private extern __gshared HANDLE[_NFILE] _osfhnd;
private extern __gshared ubyte[_NFILE] __fhnd_info;
extern shared ubyte[_NFILE] __fhnd_info;

private void _WaitSemaphore(int iSemaphore);
private void _ReleaseSemaphore(int iSemaphore);
Expand Down
210 changes: 210 additions & 0 deletions src/core/sys/linux/tipc.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
/**
* Interface for Linux TIPC sockets, /usr/include/linux/tipc.h
*
* Copyright: Public Domain
* License: Public Domain
* Authors: Leandro Lucarella
*/

module core.sys.linux.tipc;

version (linux):
extern (C) nothrow @nogc:

struct tipc_portid
{
uint ref_;
uint node;
}

struct tipc_name
{
uint type;
uint instance;
}

struct tipc_name_seq
{
uint type;
uint lower;
uint upper;
}

struct tipc_subscr
{
tipc_name_seq seq;
uint timeout;
uint filter;
ubyte[8] usr_handle;
}

struct tipc_event
{
uint event;
uint found_lower;
uint found_upper;
tipc_portid port;
tipc_subscr s;
}

struct sockaddr_tipc
{
ushort family;
ubyte addrtype;
byte scope_;
union Addr
{
tipc_portid id;
tipc_name_seq nameseq;
static struct Name
{
tipc_name name;
uint domain;
}
Name name;
}
Addr addr;
}

uint tipc_addr(uint zone, uint cluster, uint node)
{
return (zone << 24) | (cluster << 12) | node;
}

unittest
{
assert (tipc_addr(0, 0, 0) == 0);
assert (tipc_addr(1, 1, 1) == 16781313);
assert (tipc_addr(2, 1, 27) == 33558555);
assert (tipc_addr(3, 1, 63) == 50335807);
}

uint tipc_zone(uint addr)
{
return addr >> 24;
}

unittest
{
assert (tipc_zone(0u) == 0);
assert (tipc_zone(16781313u) == 1);
assert (tipc_zone(33558555u) == 2);
assert (tipc_zone(50335807u) == 3);
}

uint tipc_cluster(uint addr)
{
return (addr >> 12) & 0xfff;
}

unittest
{
assert (tipc_cluster(0u) == 0);
assert (tipc_cluster(16781313u) == 1);
assert (tipc_cluster(33558555u) == 1);
assert (tipc_cluster(50335807u) == 1);
}

uint tipc_node(uint addr)
{
return addr & 0xfff;
}

unittest
{
assert (tipc_node(0u) == 0);
assert (tipc_node(16781313u) == 1);
assert (tipc_node(33558555u) == 27);
assert (tipc_node(50335807u) == 63);
}

enum: int
{
TIPC_CFG_SRV = 0,
TIPC_TOP_SRV = 1,
TIPC_RESERVED_TYPES = 64,
}

enum: int
{
TIPC_ZONE_SCOPE = 1,
TIPC_CLUSTER_SCOPE = 2,
TIPC_NODE_SCOPE = 3,
}

enum: int
{
TIPC_MAX_USER_MSG_SIZE = 66000,
}

enum: int
{
TIPC_LOW_IMPORTANCE = 0,
TIPC_MEDIUM_IMPORTANCE = 1,
TIPC_HIGH_IMPORTANCE = 2,
TIPC_CRITICAL_IMPORTANCE = 3,
}

enum: int
{
TIPC_OK = 0,
TIPC_ERR_NO_NAME = 1,
TIPC_ERR_NO_PORT = 2,
TIPC_ERR_NO_NODE = 3,
TIPC_ERR_OVERLOAD = 4,
TIPC_CONN_SHUTDOWN = 5,
}

enum: int
{
TIPC_SUB_PORTS = 0x01,
TIPC_SUB_SERVICE = 0x02,
TIPC_SUB_CANCEL = 0x04,
}

version (none) enum: int
{
TIPC_SUB_NO_BIND_EVTS = 0x04,
TIPC_SUB_NO_UNBIND_EVTS = 0x08,
TIPC_SUB_SINGLE_EVT = 0x10,
}

enum: int
{
TIPC_WAIT_FOREVER = ~0,
}

enum: int
{

TIPC_PUBLISHED = 1,
TIPC_WITHDRAWN = 2,
TIPC_SUBSCR_TIMEOUT = 3,
}

enum: int
{
AF_TIPC = 30,
PF_TIPC = 30,
SOL_TIPC = 271,
TIPC_ADDR_NAMESEQ = 1,
TIPC_ADDR_MCAST = 1,
TIPC_ADDR_NAME = 2,
TIPC_ADDR_ID = 3,
}

enum: int
{
TIPC_ERRINFO = 1,
TIPC_RETDATA = 2,
TIPC_DESTNAME = 3,
}

enum: int
{
TIPC_IMPORTANCE = 127,
TIPC_SRC_DROPPABLE = 128,
TIPC_DEST_DROPPABLE = 129,
TIPC_CONN_TIMEOUT = 130,
}

64 changes: 52 additions & 12 deletions src/core/sys/posix/netinet/in_.d
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,23 @@ version( linux )
{
IPPROTO_IP = 0,
IPPROTO_ICMP = 1,
IPPROTO_IGMP = 2,
IPPROTO_GGP = 3,
IPPROTO_TCP = 6,
IPPROTO_UDP = 17
IPPROTO_PUP = 12,
IPPROTO_UDP = 17,
IPPROTO_IDP = 22,
IPPROTO_ND = 77,
IPPROTO_MAX = 256
}

enum uint INADDR_ANY = 0x00000000;
enum uint INADDR_BROADCAST = 0xffffffff;
enum : uint
{
INADDR_ANY = 0x00000000,
INADDR_BROADCAST = 0xffffffff,
INADDR_LOOPBACK = 0x7F000001,
INADDR_NONE = 0xFFFFFFFF
}

//enum INET_ADDRSTRLEN = 16;
}
Expand Down Expand Up @@ -125,12 +136,23 @@ else version( OSX )
{
IPPROTO_IP = 0,
IPPROTO_ICMP = 1,
IPPROTO_IGMP = 2,
IPPROTO_GGP = 3,
IPPROTO_TCP = 6,
IPPROTO_UDP = 17
IPPROTO_PUP = 12,
IPPROTO_UDP = 17,
IPPROTO_IDP = 22,
IPPROTO_ND = 77,
IPPROTO_MAX = 256
}

enum uint INADDR_ANY = 0x00000000;
enum uint INADDR_BROADCAST = 0xffffffff;
enum : uint
{
INADDR_ANY = 0x00000000,
INADDR_BROADCAST = 0xffffffff,
INADDR_LOOPBACK = 0x7F000001,
INADDR_NONE = 0xFFFFFFFF
}

//enum INET_ADDRSTRLEN = 16;
}
Expand All @@ -157,12 +179,23 @@ else version( FreeBSD )
{
IPPROTO_IP = 0,
IPPROTO_ICMP = 1,
IPPROTO_IGMP = 2,
IPPROTO_GGP = 3,
IPPROTO_TCP = 6,
IPPROTO_UDP = 17
IPPROTO_PUP = 12,
IPPROTO_UDP = 17,
IPPROTO_IDP = 22,
IPPROTO_ND = 77,
IPPROTO_MAX = 256
}

enum uint INADDR_ANY = 0x00000000;
enum uint INADDR_BROADCAST = 0xffffffff;
enum : uint
{
INADDR_ANY = 0x00000000,
INADDR_BROADCAST = 0xffffffff,
INADDR_LOOPBACK = 0x7f000001,
INADDR_NONE = 0xffffffff
}

//enum INET_ADDRSTRLEN = 16;
}
Expand All @@ -185,12 +218,19 @@ else version( Android )
{
IPPROTO_IP = 0,
IPPROTO_ICMP = 1,
IPPROTO_IGMP = 2,
IPPROTO_TCP = 6,
IPPROTO_UDP = 17
IPPROTO_PUP = 12,
IPPROTO_UDP = 17,
IPPROTO_IDP = 22
}

enum c_ulong INADDR_ANY = 0x00000000;
enum c_ulong INADDR_BROADCAST = 0xffffffff;
enum : c_ulong
{
INADDR_ANY = 0x00000000,
INADDR_BROADCAST = 0xffffffff,
INADDR_NONE = 0xFFFFFFFF
}
}


Expand Down
Loading

0 comments on commit 54216d5

Please sign in to comment.