diff --git a/src/core/sys/posix/arpa/inet.d b/src/core/sys/posix/arpa/inet.d index f2e7d653fe..c8ae85d17e 100644 --- a/src/core/sys/posix/arpa/inet.d +++ b/src/core/sys/posix/arpa/inet.d @@ -124,6 +124,31 @@ else version( FreeBSD ) const(char)* inet_ntop(int, in void*, char*, socklen_t); int inet_pton(int, in char*, void*); } +else version( DragonFlyBSD ) +{ + alias uint16_t in_port_t; + alias uint32_t in_addr_t; + + struct in_addr + { + in_addr_t s_addr; + } + + enum INET_ADDRSTRLEN = 16; + + @trusted pure + { + uint32_t htonl(uint32_t); + uint16_t htons(uint16_t); + uint32_t ntohl(uint32_t); + uint16_t ntohs(uint16_t); + } + + in_addr_t inet_addr(in char*); + char* inet_ntoa(in_addr); + const(char)* inet_ntop(int, in void*, char*, socklen_t); + int inet_pton(int, in char*, void*); +} else version( Solaris ) { alias uint16_t in_port_t; @@ -235,6 +260,10 @@ else version( FreeBSD ) { enum INET6_ADDRSTRLEN = 46; } +else version( DragonFlyBSD ) +{ + enum INET6_ADDRSTRLEN = 46; +} else version( Solaris ) { enum INET6_ADDRSTRLEN = 46; diff --git a/src/core/sys/posix/dirent.d b/src/core/sys/posix/dirent.d index 3fc6b072d3..80ed39120b 100644 --- a/src/core/sys/posix/dirent.d +++ b/src/core/sys/posix/dirent.d @@ -142,6 +142,36 @@ else version( FreeBSD ) dirent* readdir(DIR*); } +else version( DragonFlyBSD ) +{ + enum + { + DT_UNKNOWN = 0, + DT_FIFO = 1, + DT_CHR = 2, + DT_DIR = 4, + DT_BLK = 6, + DT_REG = 8, + DT_LNK = 10, + DT_SOCK = 12, + DT_WHT = 14, + DT_DBF = 15, /* database record file */ + } + + struct dirent + { + ino_t d_fileno; /* file number of entry */ + ushort d_reclen; /* strlen(d_name) */ + ubyte d_type; /* file type, see blow */ + ubyte d_unused1; /* padding, reserved */ + uint d_unused2; /* reserved */ + char[256] d_name; /* name, NUL-terminated */ + } + + alias void* DIR; + + dirent* readdir(DIR*); +} else version (Solaris) { struct dirent @@ -245,6 +275,10 @@ else version( FreeBSD ) { int readdir_r(DIR*, dirent*, dirent**); } +else version( DragonFlyBSD ) +{ + int readdir_r(DIR*, dirent*, dirent**); +} else version (Solaris) { static if (__USE_LARGEFILE64) @@ -284,6 +318,11 @@ else version( FreeBSD ) void seekdir(DIR*, c_long); c_long telldir(DIR*); } +else version( DragonFlyBSD ) +{ + void seekdir(DIR*, c_long); + c_long telldir(DIR*); +} else version (OSX) { } diff --git a/src/core/sys/posix/dlfcn.d b/src/core/sys/posix/dlfcn.d index bd5b8eab70..34a7bfd4c1 100644 --- a/src/core/sys/posix/dlfcn.d +++ b/src/core/sys/posix/dlfcn.d @@ -165,6 +165,27 @@ else version( FreeBSD ) void* dli_saddr; } } +else version( DragonFlyBSD ) +{ + enum RTLD_LAZY = 1; + enum RTLD_NOW = 2; + enum RTLD_GLOBAL = 0x100; + enum RTLD_LOCAL = 0; + + int dlclose(void*); + char* dlerror(); + void* dlopen(in char*, int); + void* dlsym(void*, in char*); + int dladdr(const(void)* addr, Dl_info* info); + + struct Dl_info + { + const(char)* dli_fname; + void* dli_fbase; + const(char)* dli_sname; + void* dli_saddr; + } +} else version( Solaris ) { enum RTLD_LAZY = 1; diff --git a/src/core/sys/posix/fcntl.d b/src/core/sys/posix/fcntl.d index 94f5e85295..cf73213374 100644 --- a/src/core/sys/posix/fcntl.d +++ b/src/core/sys/posix/fcntl.d @@ -367,6 +367,95 @@ else version( FreeBSD ) int creat(in char*, mode_t); int open(in char*, int, ...); } +else version( DragonFlyBSD ) +{ + enum O_RDONLY = 0x0000; + enum O_WRONLY = 0x0001; + enum O_RDWR = 0x0002; + enum O_ACCMODE = 0x0003; + + enum FREAD = 0x0001; + enum FWRITE = 0x0002; + enum O_NONBLOCK = 0x0000004; + enum O_APPEND = 0x0000008; + enum O_SHLOCK = 0x0000010; + enum O_EXLOCK = 0x0000020; + enum O_ASYNC = 0x0000040; + enum O_FSYNC = 0x0000080; + enum O_SYNC = 0x0000080; + enum O_NOFOLLOW = 0x0000100; + enum O_CREAT = 0x0000200; + enum O_TRUNC = 0x0000400; + enum O_EXCL = 0x0000800; + enum O_NOCTTY = 0x0008000; + enum O_DIRECT = 0x0010000; + enum O_CLOEXEC = 0x0020000; + enum O_FBLOCKING = 0x0040000; + enum O_FNONBLOCKING = 0x0080000; + enum O_FAPPEND = 0x0100000; + enum O_FOFFSET = 0x0200000; + enum O_FSYNCWRITE = 0x0400000; + enum O_FASYNCWRITE = 0x0800000; + enum O_DIRECTORY = 0x8000000; + + enum FAPPEND = O_APPEND; + enum FASYNC = O_ASYNC; + enum FFSYNC = O_FSYNC; + enum FNONBLOCK = O_NONBLOCK; + enum FNDELAY = O_NONBLOCK; + enum O_NDELAY = O_NONBLOCK; + enum FPOSIXSHM = O_NOFOLLOW; + + enum FCNTLFLAGS = (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FPOSIXSHM|O_DIRECT); + + enum F_DUPFD = 0; + enum F_GETFD = 1; + enum F_SETFD = 2; + enum F_GETFL = 3; + enum F_SETFL = 4; + enum F_GETOWN = 5; + enum F_SETOWN = 6; + enum F_GETLK = 7; +// enum F_SETLK = 8; + enum F_SETLK = 8; + enum F_SETLKW = 9; + enum F_OGETLK = F_GETLK; + enum F_OSETLK = F_SETLK; + enum F_OSETLKW = F_SETLKW; + enum F_DUP2FD = 10; + //enum F_GETLK = 11; + //enum F_SETLK = 12; + //enum F_SETLKW = 13; + enum F_DUPFD_CLOEXEC = 17; + enum F_DUP2FD_CLOEXEC = 18; + + enum FD_CLOEXEC = 1; + + enum F_RDLCK = 1; + enum F_UNLCK = 2; + enum F_WRLCK = 3; + + enum LOCK_SH = 0x01; + enum LOCK_EX = 0x02; + enum LOCK_NB = 0x04; + enum LOCK_UN = 0x08; + + struct flock + { + off_t l_start; + off_t l_len; + pid_t l_pid; + short l_type; + short l_whence; + } + + alias oflock = flock; + + int creat(in char*, mode_t); + int open(in char*, int, ...); + //int fcntl(int, int, ...); /*defined below*/ + //int flock(int, int); +} else version (Solaris) { enum F_DUPFD = 0; diff --git a/src/core/sys/posix/grp.d b/src/core/sys/posix/grp.d index d930242775..6f07c758ad 100644 --- a/src/core/sys/posix/grp.d +++ b/src/core/sys/posix/grp.d @@ -68,6 +68,16 @@ else version( FreeBSD ) char** gr_mem; } } +else version( DragonFlyBSD ) +{ + struct group + { + char* gr_name; + char* gr_passwd; + gid_t gr_gid; + char** gr_mem; + } +} else version( Solaris ) { struct group @@ -119,6 +129,11 @@ else version( FreeBSD ) int getgrnam_r(in char*, group*, char*, size_t, group**); int getgrgid_r(gid_t, group*, char*, size_t, group**); } +else version( DragonFlyBSD ) +{ + int getgrnam_r(in char*, group*, char*, size_t, group**); + int getgrgid_r(gid_t, group*, char*, size_t, group**); +} else version( Solaris ) { int getgrnam_r(in char*, group*, char*, int, group**); @@ -159,6 +174,12 @@ else version( FreeBSD ) @trusted void endgrent(); @trusted void setgrent(); } +else version( DragonFlyBSD ) +{ + group* getgrent(); + @trusted void endgrent(); + @trusted void setgrent(); +} else version( Solaris ) { group* getgrent(); diff --git a/src/core/sys/posix/net/if_.d b/src/core/sys/posix/net/if_.d index 4cdd8300ce..dc281d79a6 100644 --- a/src/core/sys/posix/net/if_.d +++ b/src/core/sys/posix/net/if_.d @@ -82,6 +82,21 @@ else version( FreeBSD ) if_nameindex_t* if_nameindex(); void if_freenameindex(if_nameindex_t*); } +else version( DragonFlyBSD ) +{ + struct if_nameindex_t + { + uint if_index; + char* if_name; + } + + enum IF_NAMESIZE = 16; + + uint if_nametoindex(in char*); + char* if_indextoname(uint, char*); + if_nameindex_t* if_nameindex(); + void if_freenameindex(if_nameindex_t*); +} else version( CRuntime_Bionic ) { enum IF_NAMESIZE = 16; diff --git a/src/core/sys/posix/netdb.d b/src/core/sys/posix/netdb.d index 26a6d20f6a..00b6408dc3 100644 --- a/src/core/sys/posix/netdb.d +++ b/src/core/sys/posix/netdb.d @@ -387,6 +387,107 @@ else version( FreeBSD ) enum EAI_SYSTEM = 11; enum EAI_OVERFLOW = 14; } +else version( DragonFlyBSD ) +{ + /* + * Error return codes from gethostbyname() and gethostbyaddr() + * (left in h_errno). + */ + struct hostent + { + char* h_name; + char** h_aliases; + int h_addrtype; + int h_length; + char** h_addr_list; + extern (D) char* h_addr() @property { return h_addr_list[0]; } // non-standard + } + + struct netent + { + char* n_name; + char** n_aliases; + int n_addrtype; + uint32_t n_net; + } + + struct protoent + { + char* p_name; + char** p_aliases; + int p_proto; + } + + struct servent + { + char* s_name; + char** s_aliases; + int s_port; + char* s_proto; + } + + struct addrinfo + { + int ai_flags; + int ai_family; + int ai_socktype = SOCK_STREAM; /* socktype default value required to be able to perform getAddrInfo on DragonFlyBSD + * without socktype set, you get 'servname not supported for ai_socktype' + */ + int ai_protocol; + socklen_t ai_addrlen; + char* ai_canonname; + sockaddr* ai_addr; + addrinfo* ai_next; + } + + enum IPPORT_RESERVED = 1024; + + enum NETDB_INTERNAL = -1; + enum NETDB_SUCCESS = 0; + enum HOST_NOT_FOUND = 1; + enum TRY_AGAIN = 2; + enum NO_RECOVERY = 3; + enum NO_DATA = 4; + enum NO_ADDRESS = NO_DATA; + + //enum EAI_ADDRFAMILY = 1; // deprecated + enum EAI_AGAIN = 2; + enum EAI_BADFLAGS = 3; + enum EAI_FAIL = 4; + enum EAI_FAMILY = 5; + enum EAI_MEMORY = 6; + //enum EAI_NODATA = 7; // deprecated + enum EAI_NONAME = 8; + enum EAI_SERVICE = 9; + enum EAI_SOCKTYPE = 10; + enum EAI_SYSTEM = 11; + enum EAI_BADHINTS = 12; + enum EAI_PROTOCOL = 13; + enum EAI_OVERFLOW = 14; + + enum AI_PASSIVE = 0x001; + enum AI_CANONNAME = 0x002; + enum AI_NUMERICHOST = 0x004; + enum AI_NUMERICSERV = 0x008; + enum AI_MASK = (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG); // valid flags for addrinfo (not a standard def, apps should not use it) + enum AI_ALL = 0x100; + enum AI_V4MAPPED_CFG = 0x200; + enum AI_ADDRCONFIG = 0x400; + enum AI_V4MAPPED = 0x800; + enum AI_DEFAULT = (AI_V4MAPPED_CFG | AI_ADDRCONFIG); + + enum NI_MAXHOST = 1025; // non-standard + enum NI_MAXSERV = 32; // non-standard + + enum NI_NOFQDN = 0x01; + enum NI_NUMERICHOST = 0x02; + enum NI_NAMEREQD = 0x04; + enum NI_NUMERICSERV = 0x08; + enum NI_DGRAM = 0x10; + //enum NI_WITHSCOPEID = 0x20; // deprecated + enum NI_NUMERICSCOPE = 0x40; + +} else version (Solaris) { struct hostent diff --git a/src/core/sys/posix/netinet/in_.d b/src/core/sys/posix/netinet/in_.d index e145eb8a4c..f3cc293ed3 100644 --- a/src/core/sys/posix/netinet/in_.d +++ b/src/core/sys/posix/netinet/in_.d @@ -202,6 +202,49 @@ else version( FreeBSD ) //enum INET_ADDRSTRLEN = 16; } +else version( DragonFlyBSD ) +{ + //alias uint16_t in_port_t; + //alias uint32_t in_addr_t; + + //struct in_addr + //{ + // in_addr_t s_addr; + //} + + struct sockaddr_in + { + ubyte sin_len; + sa_family_t sin_family; + in_port_t sin_port; + in_addr sin_addr; + ubyte[8] sin_zero; + } + + enum + { + IPPROTO_IP = 0, + IPPROTO_ICMP = 1, + IPPROTO_IGMP = 2, + IPPROTO_GGP = 3, + IPPROTO_TCP = 6, + IPPROTO_PUP = 12, + IPPROTO_UDP = 17, + IPPROTO_IDP = 22, + IPPROTO_ND = 77, + IPPROTO_MAX = 256 + } + + enum : uint + { + INADDR_ANY = 0x00000000, + INADDR_LOOPBACK = 0x7f000001, + INADDR_BROADCAST = 0xffffffff, + INADDR_NONE = 0xffffffff, + } + + //enum INET_ADDRSTRLEN = 16; +} else version( Solaris ) { struct sockaddr_in @@ -713,6 +756,145 @@ else version( FreeBSD ) __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL; } } +else version( DragonFlyBSD ) +{ + struct in6_addr + { + union + { + uint8_t[16] s6_addr; + uint16_t[8] s6_addr16; + uint32_t[4] s6_addr32; + } + } + + struct sockaddr_in6 + { + uint8_t sin6_len; + sa_family_t sin6_family; + in_port_t sin6_port; + uint32_t sin6_flowinfo; + in6_addr sin6_addr; + uint32_t sin6_scope_id; + } + + extern __gshared immutable in6_addr in6addr_any; + extern __gshared immutable in6_addr in6addr_loopback; + + struct ipv6_mreq + { + in6_addr ipv6mr_multiaddr; + uint ipv6mr_interface; + } + + enum : uint + { + IPPROTO_IPV6 = 41, + + //INET6_ADDRSTRLEN = 46, + + IPV6_JOIN_GROUP = 12, + IPV6_LEAVE_GROUP = 13, + IPV6_MULTICAST_HOPS = 10, + IPV6_MULTICAST_IF = 9, + IPV6_MULTICAST_LOOP = 11, + IPV6_UNICAST_HOPS = 4, + IPV6_V6ONLY = 27, + } + + private enum + { + __IPV6_ADDR_SCOPE_NODELOCAL = 0x01, + __IPV6_ADDR_SCOPE_INTFACELOCAL = 0x01, + __IPV6_ADDR_SCOPE_LINKLOCAL = 0x02, + __IPV6_ADDR_SCOPE_SITELOCAL = 0x05, + __IPV6_ADDR_SCOPE_ORGLOCAL = 0x08, + __IPV6_ADDR_SCOPE_GLOBAL = 0x0e, + } + + // macros + extern (D) int IN6_IS_ADDR_UNSPECIFIED( in in6_addr* a ) pure + { + return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) && + (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) && + (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == 0) && + (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == 0); + } + + extern (D) int IN6_IS_ADDR_LOOPBACK( in in6_addr* a ) pure + { + return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) && + (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) && + (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == 0) && + (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == ntohl(1)); + } + + extern (D) int IN6_IS_ADDR_V4COMPAT( in in6_addr* a ) pure + { + return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) && + (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) && + (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == 0) && + (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) != 0) && + (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) != ntohl(1)); + } + + extern (D) int IN6_IS_ADDR_V4MAPPED( in in6_addr* a ) pure + { + return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) && + (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) && + (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == ntohl(0x0000ffff)); + } + + extern (D) int IN6_IS_ADDR_LINKLOCAL( in in6_addr* a ) pure + { + return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0x80; + } + + extern (D) int IN6_IS_ADDR_SITELOCAL( in in6_addr* a ) pure + { + return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0xc0; + } + + extern (D) int IN6_IS_ADDR_MULTICAST( in in6_addr* a ) pure + { + return a.s6_addr[0] == 0xff; + } + + extern (D) uint8_t __IPV6_ADDR_MC_SCOPE( in in6_addr* a ) pure + { + return a.s6_addr[1] & 0x0f; + } + + extern (D) int IN6_IS_ADDR_MC_NODELOCAL( in in6_addr* a ) pure + { + return IN6_IS_ADDR_MULTICAST(a) && + __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL; + } + + extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( in in6_addr* a ) pure + { + return IN6_IS_ADDR_MULTICAST(a) && + __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL; + } + + extern (D) int IN6_IS_ADDR_MC_SITELOCAL( in in6_addr* a ) pure + { + return IN6_IS_ADDR_MULTICAST(a) && + __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL; + } + + extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( in in6_addr* a ) pure + { + return IN6_IS_ADDR_MULTICAST(a) && + __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL; + } + + extern (D) int IN6_IS_ADDR_MC_GLOBAL( in in6_addr* a ) pure + { + return IN6_IS_ADDR_MULTICAST(a) && + __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL; + } +} else version( Solaris ) { struct in6_addr @@ -989,6 +1171,10 @@ else version( FreeBSD ) { enum uint IPPROTO_RAW = 255; } +else version( DragonFlyBSD ) +{ + enum uint IPPROTO_RAW = 255; +} else version( Solaris ) { enum uint IPPROTO_RAW = 255; diff --git a/src/core/sys/posix/netinet/tcp.d b/src/core/sys/posix/netinet/tcp.d index 5c40915f45..e50c980f6f 100644 --- a/src/core/sys/posix/netinet/tcp.d +++ b/src/core/sys/posix/netinet/tcp.d @@ -38,6 +38,10 @@ else version( FreeBSD ) { enum TCP_NODELAY = 1; } +else version( DragonFlyBSD ) +{ + enum TCP_NODELAY = 1; +} else version( Solaris ) { enum TCP_NODELAY = 1; diff --git a/src/core/sys/posix/poll.d b/src/core/sys/posix/poll.d index c98bcfcb7a..fc12b2678d 100644 --- a/src/core/sys/posix/poll.d +++ b/src/core/sys/posix/poll.d @@ -143,6 +143,40 @@ else version( FreeBSD ) int poll(pollfd*, nfds_t, int); } +else version( DragonFlyBSD ) +{ + alias uint nfds_t; + + struct pollfd + { + int fd; + short events; + short revents; + }; + + enum + { + POLLIN = 0x0001, + POLLPRI = 0x0002, + POLLOUT = 0x0004, + POLLRDNORM = 0x0040, + POLLWRNORM = POLLOUT, + POLLRDBAND = 0x0080, + POLLWRBAND = 0x0100, + //POLLEXTEND = 0x0200, + //POLLATTRIB = 0x0400, + //POLLNLINK = 0x0800, + //POLLWRITE = 0x1000, + POLLERR = 0x0008, + POLLHUP = 0x0010, + POLLNVAL = 0x0020, + + POLLSTANDARD = (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND| + POLLWRBAND|POLLERR|POLLHUP|POLLNVAL) + } + + int poll(pollfd*, nfds_t, int); +} else version( Solaris ) { alias c_ulong nfds_t; diff --git a/src/core/sys/posix/pthread.d b/src/core/sys/posix/pthread.d index 074bd5cca9..fe30838be0 100644 --- a/src/core/sys/posix/pthread.d +++ b/src/core/sys/posix/pthread.d @@ -209,6 +209,46 @@ else version( FreeBSD ) enum PTHREAD_COND_INITIALIZER = null; enum PTHREAD_RWLOCK_INITIALIZER = null; } +else version( DragonFlyBSD ) +{ + enum + { + PTHREAD_DETACHED = 0x1, + //PTHREAD_SCOPE_SYSTEM = 0x2, // defined below + PTHREAD_INHERIT_SCHED = 0x4, + PTHREAD_NOFLOAT = 0x8, + + PTHREAD_CREATE_DETACHED = PTHREAD_DETACHED, + PTHREAD_CREATE_JOINABLE = 0, + //PTHREAD_SCOPE_PROCESS = 0, // defined below + PTHREAD_EXPLICIT_SCHED = 0, + } + + enum + { + PTHREAD_PROCESS_PRIVATE = 0, + PTHREAD_PROCESS_SHARED = 1, + } + + enum + { + PTHREAD_CANCEL_ENABLE = 0, + PTHREAD_CANCEL_DISABLE = 1, + PTHREAD_CANCEL_DEFERRED = 0, + PTHREAD_CANCEL_ASYNCHRONOUS = 2, + } + + enum PTHREAD_CANCELED = cast(void*) -1; + + enum PTHREAD_NEEDS_INIT = 0; + enum PTHREAD_DONE_INIT = 1; + + enum PTHREAD_MUTEX_INITIALIZER = null; + //enum PTHREAD_ONCE_INIT = { PTHREAD_NEEDS_INIT, NULL }; + enum PTHREAD_ONCE_INIT = pthread_once_t.init; + enum PTHREAD_COND_INITIALIZER = null; + enum PTHREAD_RWLOCK_INITIALIZER = null; +} else version (Solaris) { enum @@ -362,6 +402,33 @@ else version( FreeBSD ) void __pthread_cleanup_push_imp(_pthread_cleanup_routine, void*, _pthread_cleanup_info*); void __pthread_cleanup_pop_imp(int); } +else version( DragonFlyBSD ) +{ + alias void function(void*) _pthread_cleanup_routine; + + struct _pthread_cleanup_info + { + uintptr_t[8] pthread_cleanup_pad; + } + + struct pthread_cleanup + { + _pthread_cleanup_info __cleanup_info__ = void; + + extern (D) void push()( _pthread_cleanup_routine cleanup_routine, void* cleanup_arg ) + { + _pthread_cleanup_push( cleanup_routine, cleanup_arg, &__cleanup_info__ ); + } + + extern (D) void pop()( int execute ) + { + _pthread_cleanup_pop( execute ); + } + } + + void _pthread_cleanup_push(_pthread_cleanup_routine, void*, _pthread_cleanup_info*); + void _pthread_cleanup_pop(int); +} else version (Solaris) { alias void function(void*) _pthread_cleanup_routine; @@ -507,6 +574,21 @@ else version( FreeBSD ) int pthread_barrierattr_init(pthread_barrierattr_t*); int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int); } +else version( DragonFlyBSD ) +{ + enum PTHREAD_BARRIER_SERIAL_THREAD = -1; + enum PTHREAD_KEYS_MAX = 256; + enum PTHREAD_STACK_MIN = 16384; + enum PTHREAD_THREADS_MAX = c_ulong.max; + + int pthread_barrier_destroy(pthread_barrier_t*); + int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint); + int pthread_barrier_wait(pthread_barrier_t*); + int pthread_barrierattr_destroy(pthread_barrierattr_t*); + int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*); + int pthread_barrierattr_init(pthread_barrierattr_t*); + int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int); +} else version (OSX) { } @@ -565,6 +647,14 @@ else version( FreeBSD ) int pthread_spin_trylock(pthread_spinlock_t*); int pthread_spin_unlock(pthread_spinlock_t*); } +else version( DragonFlyBSD ) +{ + int pthread_spin_init(pthread_spinlock_t*, int); + int pthread_spin_destroy(pthread_spinlock_t*); + int pthread_spin_lock(pthread_spinlock_t*); + int pthread_spin_trylock(pthread_spinlock_t*); + int pthread_spin_unlock(pthread_spinlock_t*); +} else version (OSX) { } @@ -648,6 +738,24 @@ else version( FreeBSD ) int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted; int pthread_setconcurrency(int); } +else version( DragonFlyBSD ) +{ + enum + { + PTHREAD_MUTEX_ERRORCHECK = 1, + PTHREAD_MUTEX_RECURSIVE = 2, + PTHREAD_MUTEX_NORMAL = 3, + PTHREAD_MUTEX_TYPE_MAX + } + enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_ERRORCHECK; + + int pthread_attr_getguardsize(in pthread_attr_t*, size_t*); + int pthread_attr_setguardsize(pthread_attr_t*, size_t); + int pthread_getconcurrency(); + int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*); + int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted; + int pthread_setconcurrency(int); +} else version (Solaris) { enum @@ -698,6 +806,10 @@ else version( FreeBSD ) { int pthread_getcpuclockid(pthread_t, clockid_t*); } +else version( DragonFlyBSD ) +{ + int pthread_getcpuclockid(pthread_t, clockid_t*); +} else version (OSX) { } @@ -740,6 +852,12 @@ else version( FreeBSD ) int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*); int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*); } +else version( DragonFlyBSD ) +{ + int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*); + int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*); + int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*); +} else version (Solaris) { int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*); @@ -876,6 +994,23 @@ else version( FreeBSD ) int pthread_setschedparam(pthread_t, int, sched_param*); // int pthread_setschedprio(pthread_t, int); // not implemented } +else version( DragonFlyBSD ) +{ + enum + { + PTHREAD_SCOPE_PROCESS = 0, + PTHREAD_SCOPE_SYSTEM = 0x2 + } + + int pthread_attr_getinheritsched(in pthread_attr_t*, int*); + int pthread_attr_getschedpolicy(in pthread_attr_t*, int*); + int pthread_attr_getscope(in pthread_attr_t*, int*); + int pthread_attr_setinheritsched(pthread_attr_t*, int); + int pthread_attr_setschedpolicy(pthread_attr_t*, int); + int pthread_attr_setscope(in pthread_attr_t*, int); + int pthread_getschedparam(pthread_t, int*, sched_param*); + int pthread_setschedparam(pthread_t, int, sched_param*); +} else version (Solaris) { enum @@ -953,6 +1088,15 @@ else version( FreeBSD ) int pthread_attr_setstackaddr(pthread_attr_t*, void*); int pthread_attr_setstacksize(pthread_attr_t*, size_t); } +else version( DragonFlyBSD ) +{ + int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*); + int pthread_attr_getstackaddr(in pthread_attr_t*, void**); + int pthread_attr_getstacksize(in pthread_attr_t*, size_t*); + int pthread_attr_setstack(pthread_attr_t*, void*, size_t); + int pthread_attr_setstackaddr(pthread_attr_t*, void*); + int pthread_attr_setstacksize(pthread_attr_t*, size_t); +} else version (Solaris) { int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*); @@ -1006,6 +1150,15 @@ else version( FreeBSD ) int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*); int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int); } +else version( DragonFlyBSD ) +{ + int pthread_condattr_getpshared(in pthread_condattr_t*, int*); + int pthread_condattr_setpshared(pthread_condattr_t*, int); + int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*); + int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int); + int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*); + int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int); +} else version( OSX ) { int pthread_condattr_getpshared(in pthread_condattr_t*, int*); diff --git a/src/core/sys/posix/pwd.d b/src/core/sys/posix/pwd.d index 69dcd3021f..3133b36af1 100644 --- a/src/core/sys/posix/pwd.d +++ b/src/core/sys/posix/pwd.d @@ -85,6 +85,23 @@ else version( FreeBSD ) int pw_fields; /* internal: fields filled in */ } } +else version( DragonFlyBSD ) +{ + struct passwd + { + char* pw_name; /* user name */ + char* pw_passwd; /* encrypted password */ + uid_t pw_uid; /* user uid */ + gid_t pw_gid; /* user gid */ + time_t pw_change; /* password change time */ + char* pw_class; /* user access class */ + char* pw_gecos; /* Honeywell login info */ + char* pw_dir; /* home directory */ + char* pw_shell; /* default shell */ + time_t pw_expire; /* account expiration */ + int pw_fields; /* internal: fields filled in */ + } +} else version (Solaris) { struct passwd @@ -143,6 +160,11 @@ else version( FreeBSD ) int getpwnam_r(in char*, passwd*, char*, size_t, passwd**); int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**); } +else version( DragonFlyBSD ) +{ + int getpwnam_r(in char*, passwd*, char*, size_t, passwd**); + int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**); +} else version (Solaris) { int getpwnam_r(in char*, passwd*, char*, size_t, passwd**); @@ -183,6 +205,12 @@ else version ( FreeBSD ) passwd* getpwent(); void setpwent(); } +else version ( DragonFlyBSD ) +{ + void endpwent(); + passwd* getpwent(); + void setpwent(); +} else version (Solaris) { void endpwent(); diff --git a/src/core/sys/posix/sched.d b/src/core/sys/posix/sched.d index 4d7639d4da..429bf589f4 100644 --- a/src/core/sys/posix/sched.d +++ b/src/core/sys/posix/sched.d @@ -86,6 +86,17 @@ else version( FreeBSD ) enum SCHED_OTHER = 2; enum SCHED_RR = 3; } +else version( DragonFlyBSD ) +{ + struct sched_param + { + int sched_priority; + } + + enum SCHED_FIFO = 1; + enum SCHED_OTHER = 2; + enum SCHED_RR = 3; +} else version (Solaris) { struct sched_param @@ -144,6 +155,10 @@ else version( FreeBSD ) { int sched_yield(); } +else version( DragonFlyBSD ) +{ + int sched_yield(); +} else version (Solaris) { int sched_yield(); @@ -184,6 +199,12 @@ else version( FreeBSD ) int sched_get_priority_max(int); int sched_rr_get_interval(pid_t, timespec*); } +else version( DragonFlyBSD ) +{ + int sched_get_priority_min(int); + int sched_get_priority_max(int); + int sched_rr_get_interval(pid_t, timespec*); +} else version (Solaris) { int sched_get_priority_max(int); diff --git a/src/core/sys/posix/semaphore.d b/src/core/sys/posix/semaphore.d index 2ce8f30f2c..e5d5f32e45 100644 --- a/src/core/sys/posix/semaphore.d +++ b/src/core/sys/posix/semaphore.d @@ -81,6 +81,21 @@ else version( FreeBSD ) enum SEM_FAILED = cast(sem_t*) null; } +else version( DragonFlyBSD ) +{ + struct sem_t + { + uint _magic; + struct _usem + { + shared uint _has_waiters; + shared uint _count; + uint _flags; + } _usem _kern; + } + + enum SEM_FAILED = cast(sem_t*) null; +} else version (Solaris) { struct sem_t @@ -137,6 +152,10 @@ else version( FreeBSD ) { int sem_timedwait(sem_t*, in timespec*); } +else version( DragonFlyBSD ) +{ + int sem_timedwait(sem_t*, in timespec*); +} else version (Solaris) { int sem_timedwait(sem_t*, in timespec*); diff --git a/src/core/sys/posix/setjmp.d b/src/core/sys/posix/setjmp.d index e5758c524b..318dd186df 100644 --- a/src/core/sys/posix/setjmp.d +++ b/src/core/sys/posix/setjmp.d @@ -170,6 +170,21 @@ else version( FreeBSD ) int setjmp(ref jmp_buf); void longjmp(ref jmp_buf, int); } +else version( DragonFlyBSD ) +{ + // + version( X86_64) + { + enum _JBLEN = 12; + struct _jmp_buf { c_long[_JBLEN] _jb; } + } + else + static assert(0); + alias _jmp_buf[1] jmp_buf; + + int setjmp(ref jmp_buf); + void longjmp(ref jmp_buf, int); +} else version( CRuntime_Bionic ) { // @@ -238,6 +253,20 @@ else version( FreeBSD ) int sigsetjmp(ref sigjmp_buf); void siglongjmp(ref sigjmp_buf, int); } +else version( DragonFlyBSD ) +{ + // + version( X86_64) + { + struct _sigjmp_buf { c_long[_JBLEN] _sjb; } + } + else + static assert(0); + alias _sigjmp_buf[1] sigjmp_buf; + + int sigsetjmp(ref sigjmp_buf); + void siglongjmp(ref sigjmp_buf, int); +} else version( CRuntime_Bionic ) { alias c_long[_JBLEN + 1] sigjmp_buf; @@ -264,6 +293,11 @@ else version( FreeBSD ) int _setjmp(ref jmp_buf); void _longjmp(ref jmp_buf, int); } +else version( DragonFlyBSD ) +{ + int _setjmp(ref jmp_buf); + void _longjmp(ref jmp_buf, int); +} else version( CRuntime_Bionic ) { int _setjmp(ref jmp_buf); diff --git a/src/core/sys/posix/signal.d b/src/core/sys/posix/signal.d index e39707bb2c..342929f8be 100644 --- a/src/core/sys/posix/signal.d +++ b/src/core/sys/posix/signal.d @@ -114,6 +114,10 @@ version( Solaris ) alias _sigrtmin SIGRTMIN; alias _sigrtmax SIGRTMAX; } +else version (DragonFlyBSD) { + enum SIGRTMIN = 35; + enum SIGRTMAX = 126; +} else version( Posix ) { private extern (C) nothrow @nogc @@ -395,6 +399,30 @@ else version( FreeBSD ) enum SIGUSR2 = 31; enum SIGURG = 16; } +else version( DragonFlyBSD ) +{ + //SIGABRT (defined in core.stdc.signal) + enum SIGALRM = 14; + enum SIGBUS = 10; + enum SIGCHLD = 20; + enum SIGCONT = 19; + //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 = 17; + //SIGTERM (defined in core.stdc.signal) + enum SIGTSTP = 18; + enum SIGTTIN = 21; + enum SIGTTOU = 22; + enum SIGUSR1 = 30; + enum SIGUSR2 = 31; + enum SIGURG = 16; +} else version (Solaris) { enum SIGALRM = 14; @@ -453,6 +481,19 @@ else version( FreeBSD ) sigset_t sa_mask; } } +else version( DragonFlyBSD ) +{ + struct sigaction_t + { + union + { + sigfn_t sa_handler; + sigactfn_t sa_sigaction; + } + int sa_flags; + sigset_t sa_mask; + } +} else version (Solaris) { struct sigaction_t @@ -855,6 +896,55 @@ else version( FreeBSD ) int sigsuspend(in sigset_t *); int sigwait(in sigset_t*, int*); } +else version( DragonFlyBSD ) +{ + enum SIG_CATCH = cast(sigfn_t2) 2; + enum SIG_HOLD = cast(sigfn_t2) 3; + + struct sigset_t + { + uint[4] __bits; + } + + enum SA_NOCLDSTOP = 8; + + enum SIG_BLOCK = 1; + enum SIG_UNBLOCK = 2; + enum SIG_SETMASK = 3; + + struct siginfo_t + { + int si_signo; + int si_errno; + int si_code; + int si_pid; + uint si_uid; + int si_status; + void* si_addr; + sigval si_value; + c_long si_band; + int[7] __spare; + } + + enum SI_UNDEFINED = 0x00000; + enum SI_USER = 0; + enum SI_QUEUE = -1; + enum SI_TIMER = -2; + enum SI_ASYNCIO = -3; + enum SI_MESGQ = -4; + + int kill(pid_t, int); + int sigaction(int, in sigaction_t*, sigaction_t*); + int sigaddset(sigset_t*, int); + int sigdelset(sigset_t*, int); + int sigemptyset(sigset_t *); + int sigfillset(sigset_t *); + int sigismember(in sigset_t *, int); + int sigpending(sigset_t *); + int sigprocmask(int, in sigset_t*, sigset_t*); + int sigsuspend(in sigset_t *); + int sigwait(in sigset_t*, int*); +} else version (Solaris) { enum SIG_HOLD = cast(sigfn_t2)2; @@ -1626,6 +1716,130 @@ else version( FreeBSD ) int sigpause(int); int sigrelse(int); } +else version( DragonFlyBSD ) +{ + // No SIGPOLL on *BSD + enum SIGPROF = 27; + enum SIGSYS = 12; + enum SIGTRAP = 5; + enum SIGVTALRM = 26; + enum SIGXCPU = 24; + enum SIGXFSZ = 25; + + enum + { + SA_ONSTACK = 0x0001, + SA_RESTART = 0x0002, + SA_RESETHAND = 0x0004, + SA_NODEFER = 0x0010, + SA_NOCLDWAIT = 0x0020, + SA_SIGINFO = 0x0040, + } + + enum + { + SS_ONSTACK = 0x0001, + SS_DISABLE = 0x0004, + } + + enum MINSIGSTKSZ = 8192; + enum SIGSTKSZ = (MINSIGSTKSZ + 32768); +; + //ucontext_t (defined in core.sys.posix.ucontext) + //mcontext_t (defined in core.sys.posix.ucontext) + + struct stack_t + { + void* ss_sp; + size_t ss_size; + int ss_flags; + } + + struct sigstack + { + void* ss_sp; + int ss_onstack; + } + + enum + { + ILL_ILLOPC = 1, + ILL_ILLOPN, + ILL_ILLADR, + ILL_ILLTRP, + ILL_PRVOPC, + ILL_PRVREG, + ILL_COPROC, + ILL_BADSTK, + } + + enum + { + BUS_ADRALN = 1, + BUS_ADRERR, + BUS_OBJERR, + } + + enum + { + SEGV_MAPERR = 1, + SEGV_ACCERR, + } + + enum + { + FPE_INTOVF = 1, + FPE_INTDIV, + FPE_FLTDIV, + FPE_FLTOVF, + FPE_FLTUND, + FPE_FLTRES, + FPE_FLTINV, + FPE_FLTSUB, + } + + enum + { + TRAP_BRKPT = 1, + TRAP_TRACE, + } + + enum + { + CLD_EXITED = 1, + CLD_KILLED, + CLD_DUMPED, + CLD_TRAPPED, + CLD_STOPPED, + CLD_CONTINUED, + } + + enum + { + POLL_IN = 1, + POLL_OUT, + POLL_MSG, + POLL_ERR, + POLL_PRI, + POLL_HUP, + } + + //sigfn_t bsd_signal(int sig, sigfn_t func); + sigfn_t sigset(int sig, sigfn_t func); + + nothrow: + @nogc: + //sigfn_t2 bsd_signal(int sig, sigfn_t2 func); + sigfn_t2 sigset(int sig, sigfn_t2 func); + + int killpg(pid_t, int); + int sigaltstack(in stack_t*, stack_t*); + int sighold(int); + int sigignore(int); + int siginterrupt(int, int); + int sigpause(int); + int sigrelse(int); +} else version (Solaris) { enum SIGPOLL = 22; @@ -1929,6 +2143,14 @@ else version( FreeBSD ) c_long tv_nsec; } } +else version( DragonFlyBSD ) +{ + struct timespec + { + time_t tv_sec; + c_long tv_nsec; + } +} else version (Solaris) { struct timespec @@ -2024,6 +2246,33 @@ else version( FreeBSD ) int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*); int sigwaitinfo(in sigset_t*, siginfo_t*); } +else version( DragonFlyBSD ) +{ + union _sigev_un_t + { + int sigev_signo; + int sigev_notify_kqueue; + void /*pthread_attr_t*/ * sigev_notify_attributes; + }; + union _sigval_t + { + int sival_int; + void * sival_ptr; + int sigval_int; + void * sigval_ptr; + }; + struct sigevent + { + int sigev_notify; + _sigev_un_t sigev_un; + _sigval_t sigev_value; + void function(_sigval_t) sigev_notify_function; + } + + int sigqueue(pid_t, int, in sigval); + int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*); + int sigwaitinfo(in sigset_t*, siginfo_t*); +} else version (OSX) { } @@ -2097,6 +2346,11 @@ else version( FreeBSD ) int pthread_kill(pthread_t, int); int pthread_sigmask(int, in sigset_t*, sigset_t*); } +else version( DragonFlyBSD ) +{ + int pthread_kill(pthread_t, int); + int pthread_sigmask(int, in sigset_t*, sigset_t*); +} else version (Solaris) { int pthread_kill(pthread_t, int); diff --git a/src/core/sys/posix/stdio.d b/src/core/sys/posix/stdio.d index 122cba07ef..9cee5f5695 100644 --- a/src/core/sys/posix/stdio.d +++ b/src/core/sys/posix/stdio.d @@ -204,6 +204,8 @@ version( CRuntime_Glibc ) // as of glibc 1.0x version = HaveMemstream; else version( FreeBSD ) // as of FreeBSD 9.2 version = HaveMemstream; +else version( DragonFlyBSD ) // for DragonFlyBSD + version = HaveMemstream; else version( OpenBSD ) // as of OpenBSD 5.4 version = HaveMemstream; @@ -272,6 +274,10 @@ version( FreeBSD ) { enum P_tmpdir = "/var/tmp/"; } +version( DragonFlyBSD ) +{ + enum P_tmpdir = "/var/tmp/"; +} version( Solaris ) { enum P_tmpdir = "/var/tmp/"; diff --git a/src/core/sys/posix/stdlib.d b/src/core/sys/posix/stdlib.d index 189cef6dd1..453760aa91 100644 --- a/src/core/sys/posix/stdlib.d +++ b/src/core/sys/posix/stdlib.d @@ -91,6 +91,10 @@ else version( FreeBSD ) { int posix_memalign(void**, size_t, size_t); } +else version( DragonFlyBSD ) +{ + int posix_memalign(void**, size_t, size_t); +} else version( Solaris ) { int posix_memalign(void**, size_t, size_t); @@ -125,6 +129,13 @@ else version( FreeBSD ) void* valloc(size_t); // LEGACY non-standard } +else version( DragonFlyBSD ) +{ + int setenv(in char*, in char*, int); + int unsetenv(in char*); + + void* valloc(size_t); // LEGACY non-standard +} else version( CRuntime_Bionic ) { int setenv(in char*, in char*, int); @@ -159,6 +170,10 @@ else version( FreeBSD ) { int rand_r(uint*); } +else version( DragonFlyBSD ) +{ + int rand_r(uint*); +} else version( Solaris ) { int rand_r(uint*); @@ -342,6 +357,47 @@ else version( FreeBSD ) void srandom(uint); int unlockpt(int); } +else version( DragonFlyBSD ) +{ + //WNOHANG (defined in core.sys.posix.sys.wait) + //WUNTRACED (defined in core.sys.posix.sys.wait) + //WEXITSTATUS (defined in core.sys.posix.sys.wait) + //WIFEXITED (defined in core.sys.posix.sys.wait) + //WIFSIGNALED (defined in core.sys.posix.sys.wait) + //WIFSTOPPED (defined in core.sys.posix.sys.wait) + //WSTOPSIG (defined in core.sys.posix.sys.wait) + //WTERMSIG (defined in core.sys.posix.sys.wait) + + c_long a64l(in char*); + double drand48(); + //char* ecvt(double, int, int *, int *); // LEGACY + double erand48(ref ushort[3]); + //char* fcvt(double, int, int *, int *); // LEGACY + //char* gcvt(double, int, char*); // LEGACY + int getsubopt(char**, in char**, char**); + int grantpt(int); + char* initstate(uint, char*, size_t); + c_long jrand48(ref ushort[3]); + char* l64a(c_long); + void lcong48(ref ushort[7]); + c_long lrand48(); + char* mktemp(char*); // LEGACY + int mkstemp(char*); + char* mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition + c_long mrand48(); + c_long nrand48(ref ushort[3]); + int posix_openpt(int); + char* ptsname(int); + int putenv(char*); + c_long random(); + char* realpath(in char*, char*); + ushort *seed48(ref ushort[3]); + void setkey(in char*); + char* setstate(in char*); + void srand48(c_long); + void srandom(uint); + int unlockpt(int); +} else version( CRuntime_Bionic ) { double drand48(); diff --git a/src/core/sys/posix/sys/ioctl.d b/src/core/sys/posix/sys/ioctl.d index 13168f719c..251d646d79 100644 --- a/src/core/sys/posix/sys/ioctl.d +++ b/src/core/sys/posix/sys/ioctl.d @@ -359,6 +359,24 @@ else version (FreeBSD) int ioctl(int, c_ulong, ...); } +else version (DragonFlyBSD) +{ + struct fiodgname_arg + { + int len; + void* buf; + } + + struct winsize + { + ushort ws_row; + ushort ws_col; + ushort ws_xpixel; + ushort ws_ypixel; + } + + int ioctl(int, c_ulong, ...); +} else version (Solaris) { int ioctl(int fildes, int request, ...); diff --git a/src/core/sys/posix/sys/ipc.d b/src/core/sys/posix/sys/ipc.d index 07892a060d..c7dc30d3b7 100644 --- a/src/core/sys/posix/sys/ipc.d +++ b/src/core/sys/posix/sys/ipc.d @@ -115,6 +115,31 @@ else version( FreeBSD ) key_t ftok(in char*, int); } +else version( DragonFlyBSD ) +{ + struct ipc_perm + { + uid_t cuid; + gid_t cgid; + uid_t uid; + gid_t gid; + mode_t mode; + ushort seq; + key_t key; + } + + enum IPC_CREAT = 0x0200; // 01000 + enum IPC_EXCL = 0x0400; // 02000 + enum IPC_NOWAIT = 0x0800; // 04000 + + enum key_t IPC_PRIVATE = 0; + + enum IPC_RMID = 0; + enum IPC_SET = 1; + enum IPC_STAT = 2; + + key_t ftok(in char*, int); +} else version( CRuntime_Bionic ) { // All except ftok are from the linux kernel headers. diff --git a/src/core/sys/posix/sys/mman.d b/src/core/sys/posix/sys/mman.d index 36cfaeb572..fd6d465c0a 100644 --- a/src/core/sys/posix/sys/mman.d +++ b/src/core/sys/posix/sys/mman.d @@ -76,6 +76,15 @@ else version( FreeBSD ) enum POSIX_MADV_DONTNEED = 4; int posix_madvise(void *addr, size_t len, int advice); } +else version( DragonFlyBSD ) +{ + enum POSIX_MADV_NORMAL = 0; + enum POSIX_MADV_RANDOM = 1; + enum POSIX_MADV_SEQUENTIAL = 2; + enum POSIX_MADV_WILLNEED = 3; + enum POSIX_MADV_DONTNEED = 4; + int posix_madvise(void *addr, size_t len, int advice); +} else version (Solaris) { } @@ -118,6 +127,13 @@ else version( FreeBSD ) enum PROT_WRITE = 0x02; enum PROT_EXEC = 0x04; } +else version( DragonFlyBSD ) +{ + enum PROT_NONE = 0x00; + enum PROT_READ = 0x01; + enum PROT_WRITE = 0x02; + enum PROT_EXEC = 0x04; +} else version (Solaris) { enum PROT_NONE = 0x00; @@ -164,6 +180,11 @@ else version( FreeBSD ) void* mmap(void*, size_t, int, int, int, off_t); int munmap(void*, size_t); } +else version( DragonFlyBSD ) +{ + void* mmap(void*, size_t, int, int, int, off_t); + int munmap(void*, size_t); +} else version (Solaris) { void* mmap(void*, size_t, int, int, int, off_t); @@ -318,6 +339,21 @@ else version( FreeBSD ) int msync(void*, size_t, int); } +else version( DragonFlyBSD ) +{ + enum MAP_SHARED = 0x0001; + enum MAP_PRIVATE = 0x0002; + enum MAP_FIXED = 0x0010; + enum MAP_ANON = 0x1000; + + enum MAP_FAILED = cast(void*)-1; + + enum MS_SYNC = 0x0000; + enum MS_ASYNC = 0x0001; + enum MS_INVALIDATE = 0x0002; + + int msync(void*, size_t, int); +} else version (Solaris) { enum MAP_SHARED = 0x0001; @@ -429,6 +465,14 @@ else version( FreeBSD ) int mlockall(int); int munlockall(); } +else version( DragonFlyBSD ) +{ + enum MCL_CURRENT = 0x0001; + enum MCL_FUTURE = 0x0002; + + int mlockall(int); + int munlockall(); +} else version (Solaris) { enum MCL_CURRENT = 0x0001; @@ -473,6 +517,11 @@ else version( FreeBSD ) int mlock(in void*, size_t); int munlock(in void*, size_t); } +else version( DragonFlyBSD ) +{ + int mlock(in void*, size_t); + int munlock(in void*, size_t); +} else version (Solaris) { int mlock(in void*, size_t); @@ -507,6 +556,10 @@ else version( FreeBSD ) { int mprotect(void*, size_t, int); } +else version( DragonFlyBSD ) +{ + int mprotect(void*, size_t, int); +} else version (Solaris) { int mprotect(void*, size_t, int); @@ -543,6 +596,11 @@ else version( FreeBSD ) int shm_open(in char*, int, mode_t); int shm_unlink(in char*); } +else version( DragonFlyBSD ) +{ + int shm_open(in char*, int, mode_t); + int shm_unlink(in char*); +} else version (Solaris) { int shm_open(in char*, int, mode_t); diff --git a/src/core/sys/posix/sys/resource.d b/src/core/sys/posix/sys/resource.d index f7b58e0ab3..3c5e868601 100644 --- a/src/core/sys/posix/sys/resource.d +++ b/src/core/sys/posix/sys/resource.d @@ -234,6 +234,64 @@ else version (FreeBSD) RLIMIT_AS = 10, } } +else version (DragonFlyBSD) +{ + enum + { + PRIO_PROCESS = 0, + PRIO_PGRP = 1, + PRIO_USER = 2, + } + + alias long rlim_t; + + enum + { + RLIM_INFINITY = (cast(rlim_t)((cast(ulong) 1 << 63) - 1)), + // DragonFlyBSD explicitly does not define the following: + //RLIM_SAVED_MAX, + //RLIM_SAVED_CUR, + } + + enum + { + RUSAGE_SELF = 0, + RUSAGE_CHILDREN = -1, + } + + struct rusage + { + timeval ru_utime; + timeval ru_stime; + c_long ru_maxrss; + alias ru_ixrss ru_first; + c_long ru_ixrss; + c_long ru_idrss; + c_long ru_isrss; + c_long ru_minflt; + c_long ru_majflt; + c_long ru_nswap; + c_long ru_inblock; + c_long ru_oublock; + c_long ru_msgsnd; + c_long ru_msgrcv; + c_long ru_nsignals; + c_long ru_nvcsw; + c_long ru_nivcsw; + alias ru_nivcsw ru_last; + } + + enum + { + RLIMIT_CORE = 4, + RLIMIT_CPU = 0, + RLIMIT_DATA = 2, + RLIMIT_FSIZE = 1, + RLIMIT_NOFILE = 8, + RLIMIT_STACK = 3, + RLIMIT_AS = 10, + } +} else version (Solaris) { enum @@ -356,6 +414,11 @@ else version (FreeBSD) int getpriority(int, int); int setpriority(int, int, int); } +else version (DragonFlyBSD) +{ + int getpriority(int, int); + int setpriority(int, int, int); +} else version (CRuntime_Bionic) { int getpriority(int, int); @@ -406,6 +469,12 @@ else version (FreeBSD) int getrusage(int, rusage*); int setrlimit(int, in rlimit*); } +else version (DragonFlyBSD) +{ + int getrlimit(int, rlimit*); + int getrusage(int, rusage*); + int setrlimit(int, in rlimit*); +} else version (Solaris) { int getrlimit(int, rlimit*); diff --git a/src/core/sys/posix/sys/select.d b/src/core/sys/posix/sys/select.d index cb0c982163..7fa3bf19ad 100644 --- a/src/core/sys/posix/sys/select.d +++ b/src/core/sys/posix/sys/select.d @@ -218,6 +218,55 @@ else version( FreeBSD ) int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*); int select(int, fd_set*, fd_set*, fd_set*, timeval*); } +else version( DragonFlyBSD ) +{ + private + { + alias c_ulong __fd_mask; + enum _NFDBITS = __fd_mask.sizeof * 8; + } + + enum uint FD_SETSIZE = 1024; + + struct fd_set + { + __fd_mask[(FD_SETSIZE + (_NFDBITS - 1)) / _NFDBITS] __fds_bits; + } + + extern (D) __fd_mask __fdset_mask(uint n) + { + return cast(__fd_mask) 1 << (n % _NFDBITS); + } + + extern (D) void FD_CLR( int n, fd_set* p ) + { + p.__fds_bits[n / _NFDBITS] &= ~__fdset_mask(n); + } + + extern (D) bool FD_ISSET( int n, const(fd_set)* p ) + { + return (p.__fds_bits[n / _NFDBITS] & __fdset_mask(n)) != 0; + } + + extern (D) void FD_SET( int n, fd_set* p ) + { + p.__fds_bits[n / _NFDBITS] |= __fdset_mask(n); + } + + extern (D) void FD_ZERO( fd_set* p ) + { + fd_set *_p; + size_t _n; + + _p = p; + _n = (FD_SETSIZE + (_NFDBITS - 1)) / _NFDBITS; + while (_n > 0) + _p.__fds_bits[--_n] = 0; + } + + int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*); + int select(int, fd_set*, fd_set*, fd_set*, timeval*); +} else version (Solaris) { private diff --git a/src/core/sys/posix/sys/shm.d b/src/core/sys/posix/sys/shm.d index de16d236dd..a5bb6f40a9 100644 --- a/src/core/sys/posix/sys/shm.d +++ b/src/core/sys/posix/sys/shm.d @@ -121,6 +121,32 @@ else version( FreeBSD ) int shmdt(in void*); int shmget(key_t, size_t, int); } +else version( DragonFlyBSD ) +{ + enum SHM_RDONLY = 0x01000; // 010000 + enum SHM_RND = 0x02000; // 020000 + enum SHMLBA = 1 << 12; // PAGE_SIZE = (1< + { + enum _ALIGNBYTES = /+c_int+/ int.sizeof - 1; + extern (D) size_t _ALIGN( size_t p ) { return (p + _ALIGNBYTES) & ~_ALIGNBYTES; } + } + + extern (D) ubyte* CMSG_DATA( cmsghdr* cmsg ) + { + return cast(ubyte*) cmsg + _ALIGN( cmsghdr.sizeof ); + } + + extern (D) cmsghdr* CMSG_NXTHDR( msghdr* mhdr, cmsghdr* cmsg ) + { + if( cmsg == null ) + { + return CMSG_FIRSTHDR( mhdr ); + } + else + { + if( cast(ubyte*) cmsg + _ALIGN( cmsg.cmsg_len ) + _ALIGN( cmsghdr.sizeof ) > + cast(ubyte*) mhdr.msg_control + mhdr.msg_controllen ) + return null; + else + return cast(cmsghdr*) (cast(ubyte*) cmsg + _ALIGN( cmsg.cmsg_len )); + } + } + + extern (D) cmsghdr* CMSG_FIRSTHDR( msghdr* mhdr ) + { + return mhdr.msg_controllen >= cmsghdr.sizeof ? cast(cmsghdr*) mhdr.msg_control : null; + } + + enum + { + SHUT_RD = 0, + SHUT_WR = 1, + SHUT_RDWR = 2 + } + +/* + /+ sendfile(2) header/trailer struct +/ + struct sf_hdtr { + iovec * headers; + int hdr_cnt; + iovec * trailers; + int trl_cnt; + }; +*/ + + int accept(int, sockaddr*, socklen_t*); +// int accept4(int, sockaddr*, socklen_t*, int); + int bind(int, in sockaddr*, socklen_t); + int connect(int, in sockaddr*, socklen_t); +// int extconnect(int, int, sockaddr*, socklen_t); + int getpeername(int, sockaddr*, socklen_t*); + int getsockname(int, sockaddr*, socklen_t*); + int getsockopt(int, int, int, void*, socklen_t*); + int listen(int, int); + ssize_t recv(int, void*, size_t, int); + ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*); + ssize_t recvmsg(int, msghdr*, int); + ssize_t send(int, in void*, size_t, int); + ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t); + ssize_t sendmsg(int, in msghdr*, int); +// int sendfile(int, int, off_t, size_t, sf_hdtr *, off_t *, int); + int setsockopt(int, int, int, in void*, socklen_t); + int shutdown(int, int); + int sockatmark(int); + int socket(int, int, int); + int socketpair(int, int, int, ref int[2]); +// void pfctlinput(int, struct sockaddr *); +} else version (Solaris) { alias uint socklen_t; @@ -1311,6 +1614,13 @@ else version( FreeBSD ) AF_INET6 = 28 } } +else version( DragonFlyBSD ) +{ + enum + { + AF_INET6 = 28 + } +} else version (Solaris) { enum @@ -1358,6 +1668,13 @@ else version( FreeBSD ) SOCK_RAW = 3 } } +else version( DragonFlyBSD ) +{ + enum + { + SOCK_RAW = 3 + } +} else version (Solaris) { enum diff --git a/src/core/sys/posix/sys/stat.d b/src/core/sys/posix/sys/stat.d index b2cb663a26..dad1b52296 100644 --- a/src/core/sys/posix/sys/stat.d +++ b/src/core/sys/posix/sys/stat.d @@ -777,6 +777,68 @@ else version( FreeBSD ) extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); } extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); } } +else version( DragonFlyBSD ) +{ + struct stat_t { + ino_t st_ino; /* inode's number */ + nlink_t st_nlink; /* number of hard links */ + dev_t st_dev; /* inode's device */ + mode_t st_mode; /* inode protection mode */ + uint16_t st_padding1; + uid_t st_uid; /* user ID of the file's owner */ + gid_t st_gid; /* group ID of the file's group */ + dev_t st_rdev; /* device type */ + time_t st_atime; + c_long __st_atimensec; + time_t st_mtime; + c_long __st_mtimensec; + time_t st_ctime; + c_long __st_ctimensec; + off_t st_size; /* file size, in bytes */ + int64_t st_blocks; /* blocks allocated for file */ + uint32_t st_blksize; /* optimal blocksize for I/O */ + uint32_t st_flags; /* user defined flags for file */ + uint32_t st_gen; /* file generation number */ + int32_t st_lspare; + int64_t st_qspare1; /* was recursive change detect */ + int64_t st_qspare2; + }; + + enum S_IRUSR = 0x100; // octal 0000400 + enum S_IWUSR = 0x080; // octal 0000200 + enum S_IXUSR = 0x040; // octal 0000100 + enum S_IRWXU = 0x1C0; // octal 0000700 + + enum S_IRGRP = 0x020; // octal 0000040 + enum S_IWGRP = 0x010; // octal 0000020 + enum S_IXGRP = 0x008; // octal 0000010 + enum S_IRWXG = 0x038; // octal 0000070 + + enum S_IROTH = 0x4; // 0000004 + enum S_IWOTH = 0x2; // 0000002 + enum S_IXOTH = 0x1; // 0000001 + enum S_IRWXO = 0x7; // 0000007 + + enum S_ISUID = 0x800; // octal 0004000 + enum S_ISGID = 0x400; // octal 0002000 + enum S_ISVTX = 0x200; // octal 0001000 + + private + { + extern (D) bool S_ISTYPE( mode_t mode, uint mask ) + { + return ( mode & S_IFMT ) == mask; + } + } + + extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); } + extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); } + extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); } + extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); } + extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); } + extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); } + extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); } +} else version (Solaris) { private enum _ST_FSTYPSZ = 16; @@ -1105,6 +1167,12 @@ else version( FreeBSD ) int lstat(in char*, stat_t*); int stat(in char*, stat_t*); } +else version( DragonFlyBSD ) +{ + int fstat(int, stat_t*); + int lstat(in char*, stat_t*); + int stat(in char*, stat_t*); +} else version( CRuntime_Bionic ) { int fstat(int, stat_t*) @trusted; @@ -1174,6 +1242,19 @@ else version( FreeBSD ) int mknod(in char*, mode_t, dev_t); } +else version( DragonFlyBSD ) +{ + enum S_IFMT = 0xF000; // octal 0170000 + enum S_IFBLK = 0x6000; // octal 0060000 + enum S_IFCHR = 0x2000; // octal 0020000 + enum S_IFIFO = 0x1000; // octal 0010000 + enum S_IFREG = 0x8000; // octal 0100000 + enum S_IFDIR = 0x4000; // octal 0040000 + enum S_IFLNK = 0xA000; // octal 0120000 + enum S_IFSOCK = 0xC000; // octal 0140000 + + int mknod(in char*, mode_t, dev_t); +} else version (Solaris) { enum S_IFMT = 0xF000; diff --git a/src/core/sys/posix/sys/time.d b/src/core/sys/posix/sys/time.d index dbeb58a9f4..b5ebad6650 100644 --- a/src/core/sys/posix/sys/time.d +++ b/src/core/sys/posix/sys/time.d @@ -123,6 +123,32 @@ else version( FreeBSD ) int setitimer(int, in itimerval*, itimerval*); int utimes(in char*, ref const(timeval)[2]); } +else version( DragonFlyBSD ) +{ + struct timeval + { + time_t tv_sec; + suseconds_t tv_usec; + } + + struct itimerval + { + timeval it_interval; + timeval it_value; + } + + // non-standard + struct timezone_t + { + int tz_minuteswest; + int tz_dsttime; + } + + int getitimer(int, itimerval*); + int gettimeofday(timeval*, timezone_t*); // timezone_t* is normally void* + int setitimer(int, in itimerval*, itimerval*); + int utimes(in char*, ref const(timeval)[2]); +} else version (Solaris) { struct timeval diff --git a/src/core/sys/posix/sys/types.d b/src/core/sys/posix/sys/types.d index 6e1adef62f..0078ddd4be 100644 --- a/src/core/sys/posix/sys/types.d +++ b/src/core/sys/posix/sys/types.d @@ -138,6 +138,21 @@ else version( FreeBSD ) alias uint uid_t; alias uint fflags_t; } +else version( DragonFlyBSD ) +{ + alias long blkcnt_t; + alias long blksize_t; + alias uint dev_t; + alias uint gid_t; + alias long ino_t; + alias ushort mode_t; + alias uint nlink_t; + alias long off_t; //__off_t (defined in /usr/include/sys/stdint.h -> core.stdc.stddef) + alias int pid_t; // size_t (defined in /usr/include/sys/stdint.h -> core.stdc.stddef) + alias c_long ssize_t; + alias long time_t; + alias uint uid_t; +} else version (Solaris) { alias char* caddr_t; @@ -269,6 +284,16 @@ else version( FreeBSD ) alias c_long suseconds_t; alias uint useconds_t; } +else version( DragonFlyBSD ) +{ + alias ulong fsblkcnt_t; + alias ulong fsfilcnt_t; + alias c_long clock_t; + alias long id_t; + alias c_long key_t; + alias c_long suseconds_t; + alias uint useconds_t; +} else version (Solaris) { static if (__USE_FILE_OFFSET64) @@ -645,6 +670,21 @@ else version( FreeBSD ) alias void* pthread_rwlockattr_t; alias void* pthread_t; } +else version( DragonFlyBSD ) +{ + alias int lwpid_t; + + alias void* pthread_attr_t; + alias void* pthread_cond_t; + alias void* pthread_condattr_t; + alias void* pthread_key_t; + alias void* pthread_mutex_t; + alias void* pthread_mutexattr_t; + alias void* pthread_once_t; + alias void* pthread_rwlock_t; + alias void* pthread_rwlockattr_t; + alias void* pthread_t; +} else version (Solaris) { alias uint pthread_t; @@ -809,6 +849,11 @@ else version( FreeBSD ) alias void* pthread_barrier_t; alias void* pthread_barrierattr_t; } +else version( DragonFlyBSD ) +{ + alias void* pthread_barrier_t; + alias void* pthread_barrierattr_t; +} else version( OSX ) { } @@ -852,6 +897,10 @@ else version( FreeBSD ) { alias void* pthread_spinlock_t; } +else version( DragonFlyBSD ) +{ + alias void* pthread_spinlock_t; +} else version (Solaris) { alias pthread_mutex_t pthread_spinlock_t; diff --git a/src/core/sys/posix/sys/uio.d b/src/core/sys/posix/sys/uio.d index e0c50f4f5f..cc228e0df7 100644 --- a/src/core/sys/posix/sys/uio.d +++ b/src/core/sys/posix/sys/uio.d @@ -70,6 +70,17 @@ else version( FreeBSD ) ssize_t readv(int, in iovec*, int); ssize_t writev(int, in iovec*, int); } +else version( DragonFlyBSD ) +{ + struct iovec + { + void* iov_base; + size_t iov_len; + } + + ssize_t readv(int, in iovec*, int); + ssize_t writev(int, in iovec*, int); +} else version (Solaris) { struct iovec diff --git a/src/core/sys/posix/sys/un.d b/src/core/sys/posix/sys/un.d index 9b46fc1ff7..8b8aa70e11 100644 --- a/src/core/sys/posix/sys/un.d +++ b/src/core/sys/posix/sys/un.d @@ -60,6 +60,15 @@ else version( FreeBSD ) byte[104] sun_path; } } +else version( DragonFlyBSD ) +{ + struct sockaddr_un + { + ubyte sun_len; + sa_family_t sun_family; + byte[104] sun_path; + } +} else version( Solaris ) { struct sockaddr_un diff --git a/src/core/sys/posix/sys/utsname.d b/src/core/sys/posix/sys/utsname.d index 2cffd63f2f..61b8c29950 100644 --- a/src/core/sys/posix/sys/utsname.d +++ b/src/core/sys/posix/sys/utsname.d @@ -69,6 +69,22 @@ else version(Solaris) int uname(utsname* __name); } +else version(DragonFlyBSD) +{ + private enum utsNameLength = 32; + + struct utsname + { + char[utsNameLength] sysname; + char[utsNameLength] nodename; + char[utsNameLength] release; + // The field name is version but version is a keyword in D. + char[utsNameLength] update; + char[utsNameLength] machine; + } + + int uname(utsname* __name); +} else version(CRuntime_Bionic) { private enum SYS_NMLN = 65; diff --git a/src/core/sys/posix/sys/wait.d b/src/core/sys/posix/sys/wait.d index ed42ba8597..def1638fe1 100644 --- a/src/core/sys/posix/sys/wait.d +++ b/src/core/sys/posix/sys/wait.d @@ -113,6 +113,28 @@ else version( FreeBSD ) extern (D) int WSTOPSIG( int status ) { return status >> 8; } extern (D) int WTERMSIG( int status ) { return _WSTATUS( status ); } } +else version( DragonFlyBSD ) +{ + enum WNOHANG = 1; + enum WUNTRACED = 2; + + private + { + enum _WSTOPPED = 0x7F; // octal 0177 + } + + extern (D) int _WSTATUS(int status) { return (status & 0x7F); } + extern (D) int WEXITSTATUS( int status ) { return (status >> 8); } + extern (D) int WIFCONTINUED( int status ) { return status == 0x13; } + extern (D) bool WIFEXITED( int status ) { return _WSTATUS(status) == 0; } + extern (D) bool WIFSIGNALED( int status ) + { + return _WSTATUS( status ) != _WSTOPPED && _WSTATUS( status ) != 0; + } + extern (D) bool WIFSTOPPED( int status ) { return _WSTATUS( status ) == _WSTOPPED; } + extern (D) int WSTOPSIG( int status ) { return status >> 8; } + extern (D) int WTERMSIG( int status ) { return _WSTATUS( status ); } +} else version (Solaris) { enum WNOHANG = 64; @@ -205,6 +227,12 @@ else version (FreeBSD) // http://www.freebsd.org/projects/c99/ } +else version (DragonFlyBSD) +{ + enum WSTOPPED = WUNTRACED; + enum WCONTINUED = 4; + enum WNOWAIT = 8; +} else version (Solaris) { enum WEXITED = 1; diff --git a/src/core/sys/posix/syslog.d b/src/core/sys/posix/syslog.d index 7c849f6e32..9b1287caf4 100644 --- a/src/core/sys/posix/syslog.d +++ b/src/core/sys/posix/syslog.d @@ -152,7 +152,7 @@ else version( FreeBSD ) LOG_INFO = 6, /* informational */ LOG_DEBUG = 7, /* debug-level messages */ }; - + //OPTIONS enum { LOG_PID = 0x01, /* log the pid with each message */ @@ -162,7 +162,7 @@ else version( FreeBSD ) LOG_NOWAIT = 0x10, /* don't wait for console forks: DEPRECATED */ LOG_PERROR = 0x20, /* log to stderr as well */ }; - + //FACILITY enum { LOG_KERN = (0<<3), /* kernel messages */ @@ -180,7 +180,7 @@ else version( FreeBSD ) LOG_NTP = (12<<3), /* NTP subsystem */ LOG_SECURITY = (13<<3), /* security subsystems (firewalling, etc.) */ LOG_CONSOLE = (14<<3), /* /dev/console output */ - + /* other codes through 15 reserved for system use */ LOG_LOCAL0 = (16<<3), /* reserved for local use */ LOG_LOCAL1 = (17<<3), /* reserved for local use */ @@ -190,11 +190,74 @@ else version( FreeBSD ) LOG_LOCAL5 = (21<<3), /* reserved for local use */ LOG_LOCAL6 = (22<<3), /* reserved for local use */ LOG_LOCAL7 = (23<<3), /* reserved for local use */ + + LOG_NFACILITIES = 24, /* current number of facilities */ + }; + + int LOG_MASK(int pri) { return 1 << pri; } /* mask for one priority */ + int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; } /* all priorities through pri */ + + void openlog (const char *, int __option, int __facility); + int setlogmask (int __mask); + void syslog (int __pri, const char *__fmt, ...); + void closelog(); +} +else version( DragonFlyBSD ) +{ + //PRIORITY + enum { + LOG_EMERG = 0, /* system is unusable */ + LOG_ALERT = 1, /* action must be taken immediately */ + LOG_CRIT = 2, /* critical conditions */ + LOG_ERR = 3, /* error conditions */ + LOG_WARNING = 4, /* warning conditions */ + LOG_NOTICE = 5, /* normal but significant condition */ + LOG_INFO = 6, /* informational */ + LOG_DEBUG = 7, /* debug-level messages */ + }; + + //OPTIONS + enum { + LOG_PID = 0x01, /* log the pid with each message */ + LOG_CONS = 0x02, /* log on the console if errors in sending */ + LOG_ODELAY = 0x04, /* delay open until first syslog() (default) */ + LOG_NDELAY = 0x08, /* don't delay open */ + LOG_NOWAIT = 0x10, /* don't wait for console forks: DEPRECATED */ + LOG_PERROR = 0x20, /* log to stderr as well */ + }; + + //FACILITY + enum { + LOG_KERN = (0<<3), /* kernel messages */ + LOG_USER = (1<<3), /* random user-level messages */ + LOG_MAIL = (2<<3), /* mail system */ + LOG_DAEMON = (3<<3), /* system daemons */ + LOG_AUTH = (4<<3), /* security/authorization messages */ + LOG_SYSLOG = (5<<3), /* messages generated internally by syslogd */ + LOG_LPR = (6<<3), /* line printer subsystem */ + LOG_NEWS = (7<<3), /* network news subsystem */ + LOG_UUCP = (8<<3), /* UUCP subsystem */ + LOG_CRON = (9<<3), /* clock daemon */ + LOG_AUTHPRIV= (10<<3), /* security/authorization messages (private), */ + LOG_FTP = (11<<3), /* ftp daemon */ + LOG_NTP = (12<<3), /* NTP subsystem */ + LOG_SECURITY= (13<<3), /* security subsystems (firewalling, etc.) */ + LOG_CONSOLE = (14<<3), /* /dev/console output */ + + /* other codes through 15 reserved for system use */ + LOG_LOCAL0 = (16<<3), /* reserved for local use */ + LOG_LOCAL1 = (17<<3), /* reserved for local use */ + LOG_LOCAL2 = (18<<3), /* reserved for local use */ + LOG_LOCAL3 = (19<<3), /* reserved for local use */ + LOG_LOCAL4 = (20<<3), /* reserved for local use */ + LOG_LOCAL5 = (21<<3), /* reserved for local use */ + LOG_LOCAL6 = (22<<3), /* reserved for local use */ + LOG_LOCAL7 = (23<<3), /* reserved for local use */ LOG_NFACILITIES = 24, /* current number of facilities */ }; - int LOG_MASK(int pri) { return 1 << pri; } /* mask for one priority */ + int LOG_MASK(int pri) { return 1 << pri; } /* mask for one priority */ int LOG_UPTO(int pri) { return (1 << (pri+1)) - 1; } /* all priorities through pri */ void openlog (const char *, int __option, int __facility); diff --git a/src/core/sys/posix/termios.d b/src/core/sys/posix/termios.d index 85061d1db4..b579dfe991 100644 --- a/src/core/sys/posix/termios.d +++ b/src/core/sys/posix/termios.d @@ -457,7 +457,114 @@ else version ( FreeBSD ) int tcgetattr(int, termios*); int tcsendbreak(int, int); int tcsetattr(int, int, in termios*); +} +else version ( DragonFlyBSD ) +{ + alias ubyte cc_t; + alias uint speed_t; + alias uint tcflag_t; + + enum NCCS = 20; + + struct termios + { + tcflag_t c_iflag; + tcflag_t c_oflag; + tcflag_t c_cflag; + tcflag_t c_lflag; + cc_t[NCCS] c_cc; + speed_t c_ispeed; + speed_t c_ospeed; + } + + enum VEOF = 0; + enum VEOL = 1; + enum VERASE = 3; + enum VINTR = 8; + enum VKILL = 5; + enum VMIN = 16; + enum VQUIT = 9; + enum VSTART = 12; + enum VSTOP = 13; + enum VSUSP = 10; + enum VTIME = 17; + + enum BRKINT = 0x0000002; + enum ICRNL = 0x0000100; + enum IGNBRK = 0x0000001; + enum IGNCR = 0x0000080; + enum IGNPAR = 0x0000004; + enum INLCR = 0x0000040; + enum INPCK = 0x0000010; + enum ISTRIP = 0x0000020; + enum IXOFF = 0x0000400; + enum IXON = 0x0000200; + enum PARMRK = 0x0000008; + + enum OPOST = 0x0000001; + + enum B0 = 0; + enum B50 = 50; + enum B75 = 75; + enum B110 = 110; + enum B134 = 134; + enum B150 = 150; + enum B200 = 200; + enum B300 = 300; + enum B600 = 600; + enum B1200 = 1200; + enum B1800 = 1800; + enum B2400 = 2400; + enum B4800 = 4800; + enum B9600 = 9600; + enum B19200 = 19200; + enum B38400 = 38400; + + enum CSIZE = 0x0000300; + enum CS5 = 0x0000000; + enum CS6 = 0x0000100; + enum CS7 = 0x0000200; + enum CS8 = 0x0000300; + enum CSTOPB = 0x0000400; + enum CREAD = 0x0000800; + enum PARENB = 0x0001000; + enum PARODD = 0x0002000; + enum HUPCL = 0x0004000; + enum CLOCAL = 0x0008000; + + enum ECHO = 0x00000008; + enum ECHOE = 0x00000002; + enum ECHOK = 0x00000004; + enum ECHONL = 0x00000010; + enum ICANON = 0x00000100; + enum IEXTEN = 0x00000400; + enum ISIG = 0x00000080; + enum NOFLSH = 0x80000000; + enum TOSTOP = 0x00400000; + + enum TCSANOW = 0; + enum TCSADRAIN = 1; + enum TCSAFLUSH = 2; + enum TCIFLUSH = 1; + enum TCOFLUSH = 2; + enum TCIOFLUSH = 3; + + enum TCIOFF = 3; + enum TCION = 4; + enum TCOOFF = 1; + enum TCOON = 2; + + speed_t cfgetispeed(in termios*); + speed_t cfgetospeed(in termios*); + int cfsetispeed(termios*, speed_t); + int cfsetospeed(termios*, speed_t); + int tcdrain(int); + int tcflow(int, int); + int tcflush(int, int); + int tcgetattr(int, termios*); + int tcsendbreak(int, int); + int tcsetattr(int, int, in termios*); } // @@ -601,4 +708,37 @@ else version( FreeBSD ) pid_t tcgetsid(int); } +else version( DragonFlyBSD ) +{ + enum IXANY = 0x00000800; + + enum ONLCR = 0x00000002; + enum OCRNL = 0x00000010; + enum ONOCR = 0x00000020; + enum ONLRET = 0x00000040; + //enum OFILL + //enum NLDLY + //enum NL0 + //enum NL1 + //enum CRDLY + //enum CR0 + //enum CR1 + //enum CR2 + //enum CR3 + enum TABDLY = 0x00000004; + enum TAB0 = 0x00000000; + //enum TAB1 + //enum TAB2 + enum TAB3 = 0x00000004; + //enum BSDLY + //enum BS0 + //enum BS1 + //enum VTDLY + //enum VT0 + //enum VT1 + //enum FFDLY + //enum FF0 + //enum FF1 + pid_t tcgetsid(int); +} diff --git a/src/core/sys/posix/time.d b/src/core/sys/posix/time.d index bd54f610fe..1c74c34867 100644 --- a/src/core/sys/posix/time.d +++ b/src/core/sys/posix/time.d @@ -52,6 +52,10 @@ else version( FreeBSD ) { time_t timegm(tm*); // non-standard } +else version( DragonFlyBSD ) +{ + time_t timegm(tm*); // non-standard +} else version (Solaris) { time_t timegm(tm*); // non-standard @@ -115,6 +119,16 @@ else version (FreeBSD) deprecated("Please import it from core.sys.freebsd.time instead.") alias CLOCK_MONOTONIC_FAST = core.sys.freebsd.time.CLOCK_MONOTONIC_FAST; } +else version (DragonFlyBSD) +{ // time.h + enum CLOCK_MONOTONIC = 4; + // To be removed in December 2015. + static import core.sys.dragonflybsd.time; + deprecated("Please import it from core.sys.dragonflybsd.time instead.") + alias CLOCK_MONOTONIC_PRECISE = core.sys.dragonflybsd.time.CLOCK_MONOTONIC_PRECISE; + deprecated("Please import it from core.sys.dragonflybsd.time instead.") + alias CLOCK_MONOTONIC_FAST = core.sys.dragonflybsd.time.CLOCK_MONOTONIC_FAST; +} else version (OSX) { // No CLOCK_MONOTONIC defined @@ -245,6 +259,32 @@ else version( FreeBSD ) int timer_getoverrun(timer_t); int timer_settime(timer_t, int, in itimerspec*, itimerspec*); } +else version( DragonFlyBSD ) +{ + enum CLOCK_THREAD_CPUTIME_ID = 15; + + struct itimerspec + { + timespec it_interval; + timespec it_value; + } + + enum CLOCK_REALTIME = 0; + enum TIMER_ABSTIME = 0x01; + + alias int clockid_t; // + alias int timer_t; + + int clock_getres(clockid_t, timespec*); + int clock_gettime(clockid_t, timespec*); + int clock_settime(clockid_t, in timespec*); + int nanosleep(in timespec*, timespec*); + int timer_create(clockid_t, sigevent*, timer_t*); + int timer_delete(timer_t); + int timer_gettime(timer_t, itimerspec*); + int timer_getoverrun(timer_t); + int timer_settime(timer_t, int, in itimerspec*, itimerspec*); +} else version (Solaris) { enum CLOCK_PROCESS_CPUTIME_ID = 5; // @@ -338,6 +378,13 @@ else version( FreeBSD ) tm* gmtime_r(in time_t*, tm*); tm* localtime_r(in time_t*, tm*); } +else version( DragonFlyBSD ) +{ + char* asctime_r(in tm*, char*); + char* ctime_r(in time_t*, char*); + tm* gmtime_r(in time_t*, tm*); + tm* localtime_r(in time_t*, tm*); +} else version (Solaris) { char* asctime_r(in tm*, char*); @@ -391,6 +438,11 @@ else version( FreeBSD ) //tm* getdate(in char*); char* strptime(in char*, in char*, tm*); } +else version( DragonFlyBSD ) +{ + //tm* getdate(in char*); + char* strptime(in char*, in char*, tm*); +} else version (Solaris) { extern __gshared c_long timezone, altzone; diff --git a/src/core/sys/posix/ucontext.d b/src/core/sys/posix/ucontext.d index 54e6cc095b..cfc47e7c3a 100644 --- a/src/core/sys/posix/ucontext.d +++ b/src/core/sys/posix/ucontext.d @@ -701,6 +701,71 @@ else version( FreeBSD ) int[4] __spare__; } } +else version( DragonFlyBSD ) +{ + // + version( X86_64 ) + { + alias long __register_t; + alias uint __uint32_t; + alias ushort __uint16_t; + + struct mcontext_t { + __register_t mc_onstack; + __register_t mc_rdi; + __register_t mc_rsi; + __register_t mc_rdx; + __register_t mc_rcx; + __register_t mc_r8; + __register_t mc_r9; + __register_t mc_rax; + __register_t mc_rbx; + __register_t mc_rbp; + __register_t mc_r10; + __register_t mc_r11; + __register_t mc_r12; + __register_t mc_r13; + __register_t mc_r14; + __register_t mc_r15; + __register_t mc_xflags; + __register_t mc_trapno; + __register_t mc_addr; + __register_t mc_flags; + __register_t mc_err; + __register_t mc_rip; + __register_t mc_cs; + __register_t mc_rflags; + __register_t mc_rsp; + __register_t mc_ss; + + uint mc_len; + uint mc_fpformat; + uint mc_ownedfp; + uint mc_reserved; + uint[8] mc_unused; + int[256] mc_fpregs; + }; // __attribute__((aligned(64))); + } + else + { + static assert(0, "Only X86_64 support on DragonFlyBSD"); + } + + // + enum UCF_SWAPPED = 0x00000001; + + struct ucontext_t + { + sigset_t uc_sigmask; + mcontext_t uc_mcontext; + + ucontext_t* uc_link; + stack_t uc_stack; + void function(ucontext_t *, void *) uc_cofunc; + void* uc_arg; + int[4] __spare__; + } +} else version ( Solaris ) { alias uint[4] upad128_t; diff --git a/src/core/sys/posix/unistd.d b/src/core/sys/posix/unistd.d index 8495c602b0..4ceb79b4d0 100644 --- a/src/core/sys/posix/unistd.d +++ b/src/core/sys/posix/unistd.d @@ -116,6 +116,11 @@ else version( FreeBSD ) off_t lseek(int, off_t, int) @trusted; int ftruncate(int, off_t) @trusted; } +else version( DragonFlyBSD ) +{ + off_t lseek(int, off_t, int) @trusted; + int ftruncate(int, off_t) @trusted; +} else version( Solaris ) { version ( D_LP64 ) @@ -808,6 +813,161 @@ else version( FreeBSD ) _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS = 14, } } +else version( DragonFlyBSD ) +{ + enum F_OK = 0; + enum R_OK = 0x04; + enum W_OK = 0x02; + enum X_OK = 0x01; + + enum F_ULOCK = 0; + enum F_LOCK = 1; + enum F_TLOCK = 2; + enum F_TEST = 3; + + enum + { + _SC_ARG_MAX = 1, + _SC_CHILD_MAX = 2, + _SC_CLK_TCK = 3, + _SC_NGROUPS_MAX = 4, + _SC_OPEN_MAX = 5, + _SC_JOB_CONTROL = 6, + _SC_SAVED_IDS = 7, + _SC_VERSION = 8, + _SC_BC_BASE_MAX = 9, + _SC_BC_DIM_MAX = 10, + _SC_BC_SCALE_MAX = 11, + _SC_BC_STRING_MAX = 12, + _SC_COLL_WEIGHTS_MAX = 13, + _SC_EXPR_NEST_MAX = 14, + _SC_LINE_MAX = 15, + _SC_RE_DUP_MAX = 16, + _SC_2_VERSION = 17, + _SC_2_C_BIND = 18, + _SC_2_C_DEV = 19, + _SC_2_CHAR_TERM = 20, + _SC_2_FORT_DEV = 21, + _SC_2_FORT_RUN = 22, + _SC_2_LOCALEDEF = 23, + _SC_2_SW_DEV = 24, + _SC_2_UPE = 25, + _SC_STREAM_MAX = 26, + _SC_TZNAME_MAX = 27, + _SC_ASYNCHRONOUS_IO = 28, + _SC_MAPPED_FILES = 29, + _SC_MEMLOCK = 30, + _SC_MEMLOCK_RANGE = 31, + _SC_MEMORY_PROTECTION = 32, + _SC_MESSAGE_PASSING = 33, + _SC_PRIORITIZED_IO = 34, + _SC_PRIORITY_SCHEDULING = 35, + _SC_REALTIME_SIGNALS = 36, + _SC_SEMAPHORES = 37, + _SC_FSYNC = 38, + _SC_SHARED_MEMORY_OBJECTS = 39, + _SC_SYNCHRONIZED_IO = 40, + _SC_TIMERS = 41, + _SC_AIO_LISTIO_MAX = 42, + _SC_AIO_MAX = 43, + _SC_AIO_PRIO_DELTA_MAX = 44, + _SC_DELAYTIMER_MAX = 45, + _SC_MQ_OPEN_MAX = 46, + _SC_PAGESIZE = 47, + _SC_RTSIG_MAX = 48, + _SC_SEM_NSEMS_MAX = 49, + _SC_SEM_VALUE_MAX = 50, + _SC_SIGQUEUE_MAX = 51, + _SC_TIMER_MAX = 52, + _SC_IOV_MAX = 56, + _SC_NPROCESSORS_CONF = 57, + _SC_NPROCESSORS_ONLN = 58, + _SC_2_PBS = 59, + _SC_2_PBS_ACCOUNTING = 60, + _SC_2_PBS_CHECKPOINT = 61, + _SC_2_PBS_LOCATE = 62, + _SC_2_PBS_MESSAGE = 63, + _SC_2_PBS_TRACK = 64, + _SC_ADVISORY_INFO = 65, + _SC_BARRIERS = 66, + _SC_CLOCK_SELECTION = 67, + _SC_CPUTIME = 68, + _SC_FILE_LOCKING = 69, + _SC_GETGR_R_SIZE_MAX = 70, + _SC_GETPW_R_SIZE_MAX = 71, + _SC_HOST_NAME_MAX = 72, + _SC_LOGIN_NAME_MAX = 73, + _SC_MONOTONIC_CLOCK = 74, + _SC_MQ_PRIO_MAX = 75, + _SC_READER_WRITER_LOCKS = 76, + _SC_REGEXP = 77, + _SC_SHELL = 78, + _SC_SPAWN = 79, + _SC_SPIN_LOCKS = 80, + _SC_SPORADIC_SERVER = 81, + _SC_THREAD_ATTR_STACKADDR = 82, + _SC_THREAD_ATTR_STACKSIZE = 83, + _SC_THREAD_CPUTIME = 84, + _SC_THREAD_DESTRUCTOR_ITERATIONS = 85, + _SC_THREAD_KEYS_MAX = 86, + _SC_THREAD_PRIO_INHERIT = 87, + _SC_THREAD_PRIO_PROTECT = 88, + _SC_THREAD_PRIORITY_SCHEDULING = 89, + _SC_THREAD_PROCESS_SHARED = 90, + _SC_THREAD_SAFE_FUNCTIONS = 91, + _SC_THREAD_SPORADIC_SERVER = 92, + _SC_THREAD_STACK_MIN = 93, + _SC_THREAD_THREADS_MAX = 94, + _SC_TIMEOUTS = 95, + _SC_THREADS = 96, + _SC_TRACE = 97, + _SC_TRACE_EVENT_FILTER = 98, + _SC_TRACE_INHERIT = 99, + _SC_TRACE_LOG = 100, + _SC_TTY_NAME_MAX = 101, + _SC_TYPED_MEMORY_OBJECTS = 102, + _SC_V6_ILP32_OFF32 = 103, + _SC_V6_ILP32_OFFBIG = 104, + _SC_V6_LP64_OFF64 = 105, + _SC_V6_LPBIG_OFFBIG = 106, + _SC_IPV6 = 118, + _SC_RAW_SOCKETS = 119, + _SC_SYMLOOP_MAX = 120, + _SC_ATEXIT_MAX = 107, + _SC_XOPEN_CRYPT = 108, + _SC_XOPEN_ENH_I18N = 109, + _SC_XOPEN_LEGACY = 110, + _SC_XOPEN_REALTIME = 111, + _SC_XOPEN_REALTIME_THREADS = 112, + _SC_XOPEN_SHM = 113, + _SC_XOPEN_STREAMS = 114, + _SC_XOPEN_UNIX = 115, + _SC_XOPEN_VERSION = 116, + _SC_XOPEN_XCU_VERSION = 117, + _SC_CPUSET_SIZE = 122, + _SC_PHYS_PAGES = 121, + } + + enum _SC_PAGE_SIZE = _SC_PAGESIZE; + + enum + { + _CS_PATH = 1, + _CS_POSIX_V6_ILP32_OFF32_CFLAGS = 2, + _CS_POSIX_V6_ILP32_OFF32_LDFLAGS = 3, + _CS_POSIX_V6_ILP32_OFF32_LIBS = 4, + _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS = 5, + _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS = 6, + _CS_POSIX_V6_ILP32_OFFBIG_LIBS = 7, + _CS_POSIX_V6_LP64_OFF64_CFLAGS = 8, + _CS_POSIX_V6_LP64_OFF64_LDFLAGS = 9, + _CS_POSIX_V6_LP64_OFF64_LIBS = 10, + _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS = 11, + _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS = 12, + _CS_POSIX_V6_LPBIG_OFFBIG_LIBS = 13, + _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS = 14, + } +} else version( CRuntime_Bionic ) { enum F_OK = 0; @@ -1106,6 +1266,10 @@ else version( FreeBSD ) { int fsync(int) @trusted; } +else version( DragonFlyBSD ) +{ + int fsync(int) @trusted; +} else version( CRuntime_Bionic ) { int fsync(int) @trusted; @@ -1260,6 +1424,31 @@ else version( FreeBSD ) int usleep(useconds_t) @trusted; pid_t vfork(); } +else version( DragonFlyBSD ) +{ + char* crypt(in char*, in char*); + //char* ctermid(char*); + void encrypt(ref char[64], int) @trusted; + int fchdir(int) @trusted; + c_long gethostid() @trusted; + int getpgid(pid_t) @trusted; + int getsid(pid_t) @trusted; + char* getwd(char*); // LEGACY + int lchown(in char*, uid_t, gid_t); + int lockf(int, int, off_t) @trusted; + int nice(int) @trusted; + ssize_t pread(int, void*, size_t, off_t); + ssize_t pwrite(int, in void*, size_t, off_t); + int setpgrp(pid_t, pid_t) @trusted; + int setregid(gid_t, gid_t) @trusted; + int setreuid(uid_t, uid_t) @trusted; + void swab(in void*, void*, ssize_t); + void sync() @trusted; + int truncate(in char*, off_t); + useconds_t ualarm(useconds_t, useconds_t) @trusted; + int usleep(useconds_t) @trusted; + pid_t vfork(); +} else version( CRuntime_Bionic ) { int fchdir(int) @trusted; diff --git a/src/core/sys/posix/utime.d b/src/core/sys/posix/utime.d index 7a05d415a5..f99ea91fc9 100644 --- a/src/core/sys/posix/utime.d +++ b/src/core/sys/posix/utime.d @@ -65,6 +65,16 @@ else version( FreeBSD ) int utime(in char*, in utimbuf*); } +else version( DragonFlyBSD ) +{ + struct utimbuf + { + time_t actime; + time_t modtime; + } + + int utime(in char*, in utimbuf*); +} else version( Solaris ) { struct utimbuf