Skip to content
This repository was archived by the owner on Feb 8, 2024. It is now read-only.

Commit f1c440c

Browse files
committed
Add DragonFly support to ldc:druntime/src/core/sys/posix
1 parent 9f60973 commit f1c440c

38 files changed

+2481
-1
lines changed

src/core/sys/posix/arpa/inet.d

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,31 @@ else version( FreeBSD )
124124
const(char)* inet_ntop(int, in void*, char*, socklen_t);
125125
int inet_pton(int, in char*, void*);
126126
}
127+
else version( DragonFlyBSD )
128+
{
129+
alias uint16_t in_port_t;
130+
alias uint32_t in_addr_t;
131+
132+
struct in_addr
133+
{
134+
in_addr_t s_addr;
135+
}
136+
137+
enum INET_ADDRSTRLEN = 16;
138+
139+
@trusted pure
140+
{
141+
uint32_t htonl(uint32_t);
142+
uint16_t htons(uint16_t);
143+
uint32_t ntohl(uint32_t);
144+
uint16_t ntohs(uint16_t);
145+
}
146+
147+
in_addr_t inet_addr(in char*);
148+
char* inet_ntoa(in_addr);
149+
const(char)* inet_ntop(int, in void*, char*, socklen_t);
150+
int inet_pton(int, in char*, void*);
151+
}
127152
else version( Solaris )
128153
{
129154
alias uint16_t in_port_t;
@@ -235,6 +260,10 @@ else version( FreeBSD )
235260
{
236261
enum INET6_ADDRSTRLEN = 46;
237262
}
263+
else version( DragonFlyBSD )
264+
{
265+
enum INET6_ADDRSTRLEN = 46;
266+
}
238267
else version( Solaris )
239268
{
240269
enum INET6_ADDRSTRLEN = 46;

src/core/sys/posix/dirent.d

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,36 @@ else version( FreeBSD )
142142

143143
dirent* readdir(DIR*);
144144
}
145+
else version( DragonFlyBSD )
146+
{
147+
enum
148+
{
149+
DT_UNKNOWN = 0,
150+
DT_FIFO = 1,
151+
DT_CHR = 2,
152+
DT_DIR = 4,
153+
DT_BLK = 6,
154+
DT_REG = 8,
155+
DT_LNK = 10,
156+
DT_SOCK = 12,
157+
DT_WHT = 14,
158+
DT_DBF = 15, /* database record file */
159+
}
160+
161+
struct dirent
162+
{
163+
ino_t d_fileno; /* file number of entry */
164+
ushort d_reclen; /* strlen(d_name) */
165+
ubyte d_type; /* file type, see blow */
166+
ubyte d_unused1; /* padding, reserved */
167+
uint d_unused2; /* reserved */
168+
char[256] d_name; /* name, NUL-terminated */
169+
}
170+
171+
alias void* DIR;
172+
173+
dirent* readdir(DIR*);
174+
}
145175
else version (Solaris)
146176
{
147177
struct dirent
@@ -245,6 +275,10 @@ else version( FreeBSD )
245275
{
246276
int readdir_r(DIR*, dirent*, dirent**);
247277
}
278+
else version( DragonFlyBSD )
279+
{
280+
int readdir_r(DIR*, dirent*, dirent**);
281+
}
248282
else version (Solaris)
249283
{
250284
static if (__USE_LARGEFILE64)
@@ -284,6 +318,11 @@ else version( FreeBSD )
284318
void seekdir(DIR*, c_long);
285319
c_long telldir(DIR*);
286320
}
321+
else version( DragonFlyBSD )
322+
{
323+
void seekdir(DIR*, c_long);
324+
c_long telldir(DIR*);
325+
}
287326
else version (OSX)
288327
{
289328
}

src/core/sys/posix/dlfcn.d

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,27 @@ else version( FreeBSD )
165165
void* dli_saddr;
166166
}
167167
}
168+
else version( DragonFlyBSD )
169+
{
170+
enum RTLD_LAZY = 1;
171+
enum RTLD_NOW = 2;
172+
enum RTLD_GLOBAL = 0x100;
173+
enum RTLD_LOCAL = 0;
174+
175+
int dlclose(void*);
176+
char* dlerror();
177+
void* dlopen(in char*, int);
178+
void* dlsym(void*, in char*);
179+
int dladdr(const(void)* addr, Dl_info* info);
180+
181+
struct Dl_info
182+
{
183+
const(char)* dli_fname;
184+
void* dli_fbase;
185+
const(char)* dli_sname;
186+
void* dli_saddr;
187+
}
188+
}
168189
else version( Solaris )
169190
{
170191
enum RTLD_LAZY = 1;

src/core/sys/posix/fcntl.d

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,95 @@ else version( FreeBSD )
367367
int creat(in char*, mode_t);
368368
int open(in char*, int, ...);
369369
}
370+
else version( DragonFlyBSD )
371+
{
372+
enum O_RDONLY = 0x0000;
373+
enum O_WRONLY = 0x0001;
374+
enum O_RDWR = 0x0002;
375+
enum O_ACCMODE = 0x0003;
376+
377+
enum FREAD = 0x0001;
378+
enum FWRITE = 0x0002;
379+
enum O_NONBLOCK = 0x0000004;
380+
enum O_APPEND = 0x0000008;
381+
enum O_SHLOCK = 0x0000010;
382+
enum O_EXLOCK = 0x0000020;
383+
enum O_ASYNC = 0x0000040;
384+
enum O_FSYNC = 0x0000080;
385+
enum O_SYNC = 0x0000080;
386+
enum O_NOFOLLOW = 0x0000100;
387+
enum O_CREAT = 0x0000200;
388+
enum O_TRUNC = 0x0000400;
389+
enum O_EXCL = 0x0000800;
390+
enum O_NOCTTY = 0x0008000;
391+
enum O_DIRECT = 0x0010000;
392+
enum O_CLOEXEC = 0x0020000;
393+
enum O_FBLOCKING = 0x0040000;
394+
enum O_FNONBLOCKING = 0x0080000;
395+
enum O_FAPPEND = 0x0100000;
396+
enum O_FOFFSET = 0x0200000;
397+
enum O_FSYNCWRITE = 0x0400000;
398+
enum O_FASYNCWRITE = 0x0800000;
399+
enum O_DIRECTORY = 0x8000000;
400+
401+
enum FAPPEND = O_APPEND;
402+
enum FASYNC = O_ASYNC;
403+
enum FFSYNC = O_FSYNC;
404+
enum FNONBLOCK = O_NONBLOCK;
405+
enum FNDELAY = O_NONBLOCK;
406+
enum O_NDELAY = O_NONBLOCK;
407+
enum FPOSIXSHM = O_NOFOLLOW;
408+
409+
enum FCNTLFLAGS = (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FPOSIXSHM|O_DIRECT);
410+
411+
enum F_DUPFD = 0;
412+
enum F_GETFD = 1;
413+
enum F_SETFD = 2;
414+
enum F_GETFL = 3;
415+
enum F_SETFL = 4;
416+
enum F_GETOWN = 5;
417+
enum F_SETOWN = 6;
418+
enum F_GETLK = 7;
419+
// enum F_SETLK = 8;
420+
enum F_SETLK = 8;
421+
enum F_SETLKW = 9;
422+
enum F_OGETLK = F_GETLK;
423+
enum F_OSETLK = F_SETLK;
424+
enum F_OSETLKW = F_SETLKW;
425+
enum F_DUP2FD = 10;
426+
//enum F_GETLK = 11;
427+
//enum F_SETLK = 12;
428+
//enum F_SETLKW = 13;
429+
enum F_DUPFD_CLOEXEC = 17;
430+
enum F_DUP2FD_CLOEXEC = 18;
431+
432+
enum FD_CLOEXEC = 1;
433+
434+
enum F_RDLCK = 1;
435+
enum F_UNLCK = 2;
436+
enum F_WRLCK = 3;
437+
438+
enum LOCK_SH = 0x01;
439+
enum LOCK_EX = 0x02;
440+
enum LOCK_NB = 0x04;
441+
enum LOCK_UN = 0x08;
442+
443+
struct flock
444+
{
445+
off_t l_start;
446+
off_t l_len;
447+
pid_t l_pid;
448+
short l_type;
449+
short l_whence;
450+
}
451+
452+
alias oflock = flock;
453+
454+
int creat(in char*, mode_t);
455+
int open(in char*, int, ...);
456+
//int fcntl(int, int, ...); /*defined below*/
457+
//int flock(int, int);
458+
}
370459
else version (Solaris)
371460
{
372461
enum F_DUPFD = 0;

src/core/sys/posix/grp.d

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ else version( FreeBSD )
6868
char** gr_mem;
6969
}
7070
}
71+
else version( DragonFlyBSD )
72+
{
73+
struct group
74+
{
75+
char* gr_name;
76+
char* gr_passwd;
77+
gid_t gr_gid;
78+
char** gr_mem;
79+
}
80+
}
7181
else version( Solaris )
7282
{
7383
struct group
@@ -119,6 +129,11 @@ else version( FreeBSD )
119129
int getgrnam_r(in char*, group*, char*, size_t, group**);
120130
int getgrgid_r(gid_t, group*, char*, size_t, group**);
121131
}
132+
else version( DragonFlyBSD )
133+
{
134+
int getgrnam_r(in char*, group*, char*, size_t, group**);
135+
int getgrgid_r(gid_t, group*, char*, size_t, group**);
136+
}
122137
else version( Solaris )
123138
{
124139
int getgrnam_r(in char*, group*, char*, int, group**);
@@ -159,6 +174,12 @@ else version( FreeBSD )
159174
@trusted void endgrent();
160175
@trusted void setgrent();
161176
}
177+
else version( DragonFlyBSD )
178+
{
179+
group* getgrent();
180+
@trusted void endgrent();
181+
@trusted void setgrent();
182+
}
162183
else version( Solaris )
163184
{
164185
group* getgrent();

src/core/sys/posix/net/if_.d

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ else version( FreeBSD )
8282
if_nameindex_t* if_nameindex();
8383
void if_freenameindex(if_nameindex_t*);
8484
}
85+
else version( DragonFlyBSD )
86+
{
87+
struct if_nameindex_t
88+
{
89+
uint if_index;
90+
char* if_name;
91+
}
92+
93+
enum IF_NAMESIZE = 16;
94+
95+
uint if_nametoindex(in char*);
96+
char* if_indextoname(uint, char*);
97+
if_nameindex_t* if_nameindex();
98+
void if_freenameindex(if_nameindex_t*);
99+
}
85100
else version( CRuntime_Bionic )
86101
{
87102
enum IF_NAMESIZE = 16;

src/core/sys/posix/netdb.d

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,107 @@ else version( FreeBSD )
387387
enum EAI_SYSTEM = 11;
388388
enum EAI_OVERFLOW = 14;
389389
}
390+
else version( DragonFlyBSD )
391+
{
392+
/*
393+
* Error return codes from gethostbyname() and gethostbyaddr()
394+
* (left in h_errno).
395+
*/
396+
struct hostent
397+
{
398+
char* h_name;
399+
char** h_aliases;
400+
int h_addrtype;
401+
int h_length;
402+
char** h_addr_list;
403+
extern (D) char* h_addr() @property { return h_addr_list[0]; } // non-standard
404+
}
405+
406+
struct netent
407+
{
408+
char* n_name;
409+
char** n_aliases;
410+
int n_addrtype;
411+
uint32_t n_net;
412+
}
413+
414+
struct protoent
415+
{
416+
char* p_name;
417+
char** p_aliases;
418+
int p_proto;
419+
}
420+
421+
struct servent
422+
{
423+
char* s_name;
424+
char** s_aliases;
425+
int s_port;
426+
char* s_proto;
427+
}
428+
429+
struct addrinfo
430+
{
431+
int ai_flags;
432+
int ai_family;
433+
int ai_socktype = SOCK_STREAM; /* socktype default value required to be able to perform getAddrInfo on DragonFlyBSD
434+
* without socktype set, you get 'servname not supported for ai_socktype'
435+
*/
436+
int ai_protocol;
437+
socklen_t ai_addrlen;
438+
char* ai_canonname;
439+
sockaddr* ai_addr;
440+
addrinfo* ai_next;
441+
}
442+
443+
enum IPPORT_RESERVED = 1024;
444+
445+
enum NETDB_INTERNAL = -1;
446+
enum NETDB_SUCCESS = 0;
447+
enum HOST_NOT_FOUND = 1;
448+
enum TRY_AGAIN = 2;
449+
enum NO_RECOVERY = 3;
450+
enum NO_DATA = 4;
451+
enum NO_ADDRESS = NO_DATA;
452+
453+
//enum EAI_ADDRFAMILY = 1; // deprecated
454+
enum EAI_AGAIN = 2;
455+
enum EAI_BADFLAGS = 3;
456+
enum EAI_FAIL = 4;
457+
enum EAI_FAMILY = 5;
458+
enum EAI_MEMORY = 6;
459+
//enum EAI_NODATA = 7; // deprecated
460+
enum EAI_NONAME = 8;
461+
enum EAI_SERVICE = 9;
462+
enum EAI_SOCKTYPE = 10;
463+
enum EAI_SYSTEM = 11;
464+
enum EAI_BADHINTS = 12;
465+
enum EAI_PROTOCOL = 13;
466+
enum EAI_OVERFLOW = 14;
467+
468+
enum AI_PASSIVE = 0x001;
469+
enum AI_CANONNAME = 0x002;
470+
enum AI_NUMERICHOST = 0x004;
471+
enum AI_NUMERICSERV = 0x008;
472+
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)
473+
enum AI_ALL = 0x100;
474+
enum AI_V4MAPPED_CFG = 0x200;
475+
enum AI_ADDRCONFIG = 0x400;
476+
enum AI_V4MAPPED = 0x800;
477+
enum AI_DEFAULT = (AI_V4MAPPED_CFG | AI_ADDRCONFIG);
478+
479+
enum NI_MAXHOST = 1025; // non-standard
480+
enum NI_MAXSERV = 32; // non-standard
481+
482+
enum NI_NOFQDN = 0x01;
483+
enum NI_NUMERICHOST = 0x02;
484+
enum NI_NAMEREQD = 0x04;
485+
enum NI_NUMERICSERV = 0x08;
486+
enum NI_DGRAM = 0x10;
487+
//enum NI_WITHSCOPEID = 0x20; // deprecated
488+
enum NI_NUMERICSCOPE = 0x40;
489+
490+
}
390491
else version (Solaris)
391492
{
392493
struct hostent

0 commit comments

Comments
 (0)