Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/core/sys/posix/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ version (CRuntime_Glibc)
else
enum __WORDSIZE=32;
}
else version (CRuntime_Musl)
{
enum _FILE_OFFSET_BITS = 64;

enum __REDIRECT = false;

enum __USE_FILE_OFFSET64 = _FILE_OFFSET_BITS == 64;
enum __USE_LARGEFILE = __USE_FILE_OFFSET64 && !__REDIRECT;
enum __USE_LARGEFILE64 = __USE_FILE_OFFSET64 && !__REDIRECT;

enum __WORDSIZE=64;
}
else version (Solaris)
{
enum _FILE_OFFSET_BITS = 64;
Expand Down
45 changes: 45 additions & 0 deletions src/core/sys/posix/dirent.d
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,44 @@ else version( CRuntime_Bionic )

dirent* readdir(DIR*);
}
else version( CRuntime_Musl )
{
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
}

struct dirent
{
ino_t d_ino;
off_t d_off;
ushort d_reclen;
ubyte d_type;
char[256] d_name;
}

struct DIR
{
}

static if( __USE_FILE_OFFSET64 )
{
dirent* readdir64(DIR*);
alias readdir64 readdir;
}
else
{
dirent* readdir(DIR*);
}
}
else
{
static assert(false, "Unsupported platform");
Expand Down Expand Up @@ -415,6 +453,10 @@ else version (Solaris)
else version( CRuntime_Bionic )
{
int readdir_r(DIR*, dirent*, dirent**);
}
else version( CRuntime_Musl )
{

}
else
{
Expand Down Expand Up @@ -485,6 +527,9 @@ else version (Solaris)
else version (CRuntime_Bionic)
{
}
else version (CRuntime_Musl)
{
}
else
{
static assert(false, "Unsupported platform");
Expand Down
60 changes: 60 additions & 0 deletions src/core/sys/posix/fcntl.d
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,66 @@ else version( CRuntime_Bionic )

enum AT_FDCWD = -100;
}
else version( CRuntime_Musl )
{
enum {
O_CREAT = 0x40, // octal 0100
O_EXCL = 0x80, // octal 0200
O_NOCTTY = 0x100, // octal 0400
O_TRUNC = 0x200, // octal 01000

O_APPEND = 0x400, // octal 02000
O_NONBLOCK = 0x800, // octal 04000
O_DSYNC = 0x1000, // octal 010000
O_SYNC = 0x101000, // octal 04010000
O_RSYNC = O_SYNC,
O_DIRECTORY = 0x10000,
O_NOFOLLOW = 0x20000,
O_CLOEXEC = 0x80000,

O_ASYNC = 0x2000,
O_DIRECT = 0x4000,
O_LARGEFILE = 0,
O_NOATIME = 0x40000,
O_PATH = 0x200000,
O_TMPFILE = 0x410000,
O_NDELAY = O_NONBLOCK,
O_SEARCH = O_PATH,
O_EXEC = O_PATH,

O_ACCMODE = (03|O_SEARCH),
O_RDONLY = 00,
O_WRONLY = 01,
O_RDWR = 02,
}
enum {
F_DUPFD = 0,
F_GETFD = 1,
F_SETFD = 2,
F_GETFL = 3,
F_SETFL = 4,
F_GETLK = 5,
F_SETLK = 6,
F_SETLKW = 7,
F_SETOWN = 8,
F_GETOWN = 9,
}
enum {
F_RDLCK = 0,
F_WRLCK = 1,
F_UNLCK = 2,
}
struct flock
{
short l_type;
short l_whence;
off_t l_start;
off_t l_len;
pid_t l_pid;
}
enum FD_CLOEXEC = 1;
int open(in char*, int, ...);
}
else
{
static assert(false, "Unsupported platform");
Expand Down
75 changes: 75 additions & 0 deletions src/core/sys/posix/netdb.d
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,81 @@ else version( CRuntime_Bionic )
enum EAI_SYSTEM = 11;
enum EAI_OVERFLOW = 14;
}
else version( CRuntime_Musl )
{
struct hostent
{
char* h_name;
char** h_aliases;
int h_addrtype;
int h_length;
char** h_addr_list;
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;
int ai_protocol;
socklen_t ai_addrlen;
sockaddr* ai_addr;
char* ai_canonname;
addrinfo* ai_next;
}

enum {
AI_PASSIVE = 0x1,
AI_CANONNAME = 0x2,
AI_NUMERICHOST = 0x4,
AI_NUMERICSERV = 0x8
}
enum {
NI_NUMERICHOST = 1,
NI_NUMERICSERV = 2,
NI_NOFQDN = 4,
NI_NAMEREQD = 8,
NI_DGRAM = 16,
NI_MAXSERV = 32,
NI_MAXHOST = 255,
}
enum {
EAI_BADFLAGS = -1,
EAI_NONAME = -2,
EAI_AGAIN = -3,
EAI_FAIL = -4,
EAI_FAMILY = -6,
EAI_SOCKTYPE = -7,
EAI_SERVICE = -8,
EAI_MEMORY = -10,
EAI_SYSTEM = -11,
EAI_OVERFLOW = -12,
}
}
else
{
static assert(false, "Unsupported platform");
Expand Down
34 changes: 33 additions & 1 deletion src/core/sys/posix/netinet/in_.d
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ else version( linux )
IPPROTO_TCP = 6,
IPPROTO_PUP = 12,
IPPROTO_UDP = 17,
IPPROTO_IDP = 22
IPPROTO_IDP = 22,
IPPROTO_IPV6 = 41
}

enum : c_ulong
Expand Down Expand Up @@ -1333,6 +1334,37 @@ else version( CRuntime_Bionic )
}
}
}
else version( CRuntime_Musl )
{

struct in6_addr {
union {
uint8_t[16] s6_addr;
uint16_t[8] s6_addr16;
uint32_t[4] s6_addr32;
}
}
struct sockaddr_in6 {
sa_family_t sin6_family;
in_port_t sin6_port;
uint32_t sin6_flowinfo;
in6_addr sin6_addr;
uint32_t sin6_scope_id;
}

enum : uint
{
IPV6_UNICAST_HOPS = 16,
IPV6_MULTICAST_IF = 17,
IPV6_MULTICAST_HOPS = 18,
IPV6_MULTICAST_LOOP = 19,
IPV6_JOIN_GROUP = 20,
IPV6_LEAVE_GROUP = 21,
IPV6_V6ONLY = 26
}
extern __gshared immutable in6_addr in6addr_any;
extern __gshared immutable in6_addr in6addr_loopback;
}


//
Expand Down
Loading