Skip to content

Commit

Permalink
Add support for target aarch64-linux-musl
Browse files Browse the repository at this point in the history
  • Loading branch information
jirutka authored and ysbaddaden committed Mar 26, 2018
1 parent 9adbb92 commit 9980a1f
Show file tree
Hide file tree
Showing 31 changed files with 870 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib_c/aarch64-linux-musl/c/arpa/inet.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "../netinet/in"
require "../stdint"

lib LibC
fun htons(x0 : UInt16T) : UInt16T
fun ntohs(x0 : UInt16T) : UInt16T
fun inet_ntop(x0 : Int, x1 : Void*, x2 : Char*, x3 : SocklenT) : Char*
fun inet_pton(x0 : Int, x1 : Char*, x2 : Void*) : Int
end
18 changes: 18 additions & 0 deletions src/lib_c/aarch64-linux-musl/c/dirent.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require "./sys/types"

lib LibC
type DIR = Void

struct Dirent
d_ino : InoT
d_off : OffT
d_reclen : UShort
d_type : Char
d_name : StaticArray(Char, 256)
end

fun closedir(x0 : DIR*) : Int
fun opendir(x0 : Char*) : DIR*
fun readdir(x0 : DIR*) : Dirent*
fun rewinddir(x0 : DIR*) : Void
end
21 changes: 21 additions & 0 deletions src/lib_c/aarch64-linux-musl/c/dlfcn.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
lib LibC
RTLD_LAZY = 1
RTLD_NOW = 2
RTLD_GLOBAL = 256
RTLD_LOCAL = 0
RTLD_DEFAULT = Pointer(Void).new(0)
RTLD_NEXT = Pointer(Void).new(-1)

struct DlInfo
dli_fname : Char*
dli_fbase : Void*
dli_sname : Char*
dli_saddr : Void*
end

fun dlclose(x0 : Void*) : Int
fun dlerror : Char*
fun dlopen(x0 : Char*, x1 : Int) : Void*
fun dlsym(x0 : Void*, x1 : Char*) : Void*
fun dladdr(x0 : Void*, x1 : DlInfo*) : Int
end
83 changes: 83 additions & 0 deletions src/lib_c/aarch64-linux-musl/c/errno.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
lib LibC
E2BIG = 7
EACCES = 13
EADDRINUSE = 98
EADDRNOTAVAIL = 99
EAFNOSUPPORT = 97
EAGAIN = 11
EALREADY = 114
EBADF = 9
EBADMSG = 74
EBUSY = 16
ECANCELED = 125
ECHILD = 10
ECONNABORTED = 103
ECONNREFUSED = 111
ECONNRESET = 104
EDEADLK = 35
EDESTADDRREQ = 89
EDOM = 33
EDQUOT = 122
EEXIST = 17
EFAULT = 14
EFBIG = 27
EHOSTUNREACH = 113
EIDRM = 43
EILSEQ = 84
EINPROGRESS = 115
EINTR = 4
EINVAL = 22
EIO = 5
EISCONN = 106
EISDIR = 21
ELOOP = 40
EMFILE = 24
EMLINK = 31
EMSGSIZE = 90
EMULTIHOP = 72
ENAMETOOLONG = 36
ENETDOWN = 100
ENETRESET = 102
ENETUNREACH = 101
ENFILE = 23
ENOBUFS = 105
ENODEV = 19
ENOENT = 2
ENOEXEC = 8
ENOLCK = 37
ENOLINK = 67
ENOMEM = 12
ENOMSG = 42
ENOPROTOOPT = 92
ENOSPC = 28
ENOSYS = 38
ENOTCONN = 107
ENOTDIR = 20
ENOTEMPTY = 39
ENOTRECOVERABLE = 131
ENOTSOCK = 88
ENOTSUP = LibC::EOPNOTSUPP
ENOTTY = 25
ENXIO = 6
EOPNOTSUPP = 95
EOVERFLOW = 75
EOWNERDEAD = 130
EPERM = 1
EPIPE = 32
EPROTO = 71
EPROTONOSUPPORT = 93
EPROTOTYPE = 91
ERANGE = 34
EROFS = 30
ESPIPE = 29
ESRCH = 3
ESTALE = 116
ETIMEDOUT = 110
ETXTBSY = 26
EWOULDBLOCK = LibC::EAGAIN
EXDEV = 18
ENODATA = 61
ENOSR = 63
ENOSTR = 60
ETIME = 62
end
32 changes: 32 additions & 0 deletions src/lib_c/aarch64-linux-musl/c/fcntl.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require "./sys/types"
require "./sys/stat"
require "./unistd"

lib LibC
F_GETFD = 1
F_SETFD = 2
F_GETFL = 3
F_SETFL = 4
FD_CLOEXEC = 1
O_CLOEXEC = 0o2000000
O_CREAT = 0o100
O_NOFOLLOW = 0o100000
O_TRUNC = 0o1000
O_APPEND = 0o2000
O_NONBLOCK = 0o4000
O_SYNC = 0o4010000
O_RDONLY = 0o0
O_RDWR = 0o2
O_WRONLY = 0o1

struct Flock
l_type : Short
l_whence : Short
l_start : OffT
l_len : OffT
l_pid : PidT
end

fun fcntl(x0 : Int, x1 : Int, ...) : Int
fun open(x0 : Char*, x1 : Int, ...) : Int
end
9 changes: 9 additions & 0 deletions src/lib_c/aarch64-linux-musl/c/iconv.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "./stddef"

lib LibC
type IconvT = Void*

fun iconv(x0 : IconvT, x1 : Char**, x2 : SizeT*, x3 : Char**, x4 : SizeT*) : SizeT
fun iconv_close(x0 : IconvT) : Int
fun iconv_open(x0 : Char*, x1 : Char*) : IconvT
end
39 changes: 39 additions & 0 deletions src/lib_c/aarch64-linux-musl/c/netdb.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require "./netinet/in"
require "./sys/socket"
require "./stdint"

lib LibC
AI_PASSIVE = 0x01
AI_CANONNAME = 0x02
AI_NUMERICHOST = 0x04
AI_NUMERICSERV = 0x400
AI_V4MAPPED = 0x08
AI_ALL = 0x10
AI_ADDRCONFIG = 0x20
EAI_AGAIN = -3
EAI_BADFLAGS = -1
EAI_FAIL = -4
EAI_FAMILY = -6
EAI_MEMORY = -10
EAI_NONAME = -2
EAI_SERVICE = -8
EAI_SOCKTYPE = -7
EAI_SYSTEM = -11
EAI_OVERFLOW = -12

struct Addrinfo
ai_flags : Int
ai_family : Int
ai_socktype : Int
ai_protocol : Int
ai_addrlen : SocklenT
ai_addr : Sockaddr*
ai_canonname : Char*
ai_next : Addrinfo*
end

fun freeaddrinfo(x0 : Addrinfo*) : Void
fun gai_strerror(x0 : Int) : Char*
fun getaddrinfo(x0 : Char*, x1 : Char*, x2 : Addrinfo*, x3 : Addrinfo**) : Int
fun getnameinfo(x0 : Sockaddr*, x1 : SocklenT, x2 : Char*, x3 : SocklenT, x4 : Char*, x5 : SocklenT, x6 : Int) : Int
end
42 changes: 42 additions & 0 deletions src/lib_c/aarch64-linux-musl/c/netinet/in.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require "../sys/socket"
require "../stdint"

lib LibC
IPPROTO_IP = 0
IPPROTO_ICMP = 1
IPPROTO_RAW = 255
IPPROTO_TCP = 6
IPPROTO_UDP = 17

alias InPortT = UInt16T
alias InAddrT = UInt32T

struct InAddr
s_addr : InAddrT
end

union In6AddrIn6Union
__s6_addr : StaticArray(UInt8T, 16)
__s6_addr16 : StaticArray(UInt16T, 8)
__s6_addr32 : StaticArray(UInt32T, 4)
end

struct In6Addr
__in6_union : In6AddrIn6Union
end

struct SockaddrIn
sin_family : SaFamilyT
sin_port : InPortT
sin_addr : InAddr
sin_zero : StaticArray(UInt8T, 8)
end

struct SockaddrIn6
sin6_family : SaFamilyT
sin6_port : InPortT
sin6_flowinfo : UInt32T
sin6_addr : In6Addr
sin6_scope_id : UInt32T
end
end
6 changes: 6 additions & 0 deletions src/lib_c/aarch64-linux-musl/c/netinet/tcp.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
lib LibC
TCP_NODELAY = 1
TCP_KEEPIDLE = 4
TCP_KEEPINTVL = 5
TCP_KEEPCNT = 6
end
18 changes: 18 additions & 0 deletions src/lib_c/aarch64-linux-musl/c/pthread.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require "./sys/types"

lib LibC
fun pthread_cond_broadcast(x0 : PthreadCondT*) : Int
fun pthread_cond_destroy(x0 : PthreadCondT*) : Int
fun pthread_cond_init(x0 : PthreadCondT*, x1 : PthreadCondattrT*) : Int
fun pthread_cond_signal(x0 : PthreadCondT*) : Int
fun pthread_cond_wait(x0 : PthreadCondT*, x1 : PthreadMutexT*) : Int
fun pthread_create(x0 : PthreadT*, x1 : PthreadAttrT*, x2 : Void* -> Void*, x3 : Void*) : Int
fun pthread_detach(x0 : PthreadT) : Int
fun pthread_join(x0 : PthreadT, x1 : Void**) : Int
fun pthread_mutex_destroy(x0 : PthreadMutexT*) : Int
fun pthread_mutex_init(x0 : PthreadMutexT*, x1 : PthreadMutexattrT*) : Int
fun pthread_mutex_lock(x0 : PthreadMutexT*) : Int
fun pthread_mutex_trylock(x0 : PthreadMutexT*) : Int
fun pthread_mutex_unlock(x0 : PthreadMutexT*) : Int
fun pthread_self : PthreadT
end
44 changes: 44 additions & 0 deletions src/lib_c/aarch64-linux-musl/c/signal.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
require "./sys/types"
require "./time"

lib LibC
SIGHUP = 1
SIGINT = 2
SIGQUIT = 3
SIGILL = 4
SIGTRAP = 5
SIGIOT = LibC::SIGABRT
SIGABRT = 6
SIGFPE = 8
SIGKILL = 9
SIGBUS = 7
SIGSEGV = 11
SIGSYS = 31
SIGPIPE = 13
SIGALRM = 14
SIGTERM = 15
SIGURG = 23
SIGSTOP = 19
SIGTSTP = 20
SIGCONT = 18
SIGCHLD = 17
SIGTTIN = 21
SIGTTOU = 22
SIGIO = 29
SIGXCPU = 24
SIGXFSZ = 25
SIGVTALRM = 26
SIGUSR1 = 10
SIGUSR2 = 12
SIGWINCH = 28
SIGPWR = 30
SIGSTKFLT = 16
SIGUNUSED = LibC::SIGSYS

alias SighandlerT = Int ->
SIG_DFL = SighandlerT.new(Pointer(Void).new(0_u64), Pointer(Void).null)
SIG_IGN = SighandlerT.new(Pointer(Void).new(1_u64), Pointer(Void).null)

fun kill(x0 : PidT, x1 : Int) : Int
fun signal(x0 : Int, x1 : Int -> Void) : Int -> Void
end
10 changes: 10 additions & 0 deletions src/lib_c/aarch64-linux-musl/c/stdarg.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
lib LibC
struct VaListTag
gp_offset : UInt
fp_offset : UInt
overflow_arg_area : Void*
reg_save_area : Void*
end

type VaList = VaListTag[1]
end
3 changes: 3 additions & 0 deletions src/lib_c/aarch64-linux-musl/c/stddef.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lib LibC
alias SizeT = ULong
end
10 changes: 10 additions & 0 deletions src/lib_c/aarch64-linux-musl/c/stdint.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
lib LibC
alias Int8T = SChar
alias Int16T = Short
alias Int32T = Int
alias Int64T = Long
alias UInt8T = Char
alias UInt16T = UShort
alias UInt32T = UInt
alias UInt64T = ULong
end
9 changes: 9 additions & 0 deletions src/lib_c/aarch64-linux-musl/c/stdio.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "./sys/types"
require "./stddef"

lib LibC
fun printf(x0 : Char*, ...) : Int
fun dprintf(fd : Int, format : Char*, ...) : Int
fun rename(x0 : Char*, x1 : Char*) : Int
fun snprintf(x0 : Char*, x1 : SizeT, x2 : Char*, ...) : Int
end
25 changes: 25 additions & 0 deletions src/lib_c/aarch64-linux-musl/c/stdlib.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require "./stddef"
require "./sys/wait"

lib LibC
struct DivT
quot : Int
rem : Int
end

fun atof(x0 : Char*) : Double
fun div(x0 : Int, x1 : Int) : DivT
fun exit(x0 : Int) : NoReturn
fun free(x0 : Void*) : Void
fun getenv(x0 : Char*) : Char*
fun malloc(x0 : SizeT) : Void*
fun mkstemp(x0 : Char*) : Int
fun mkstemps(x0 : Char*, x1 : Int) : Int
fun putenv(x0 : Char*) : Int
fun realloc(x0 : Void*, x1 : SizeT) : Void*
fun realpath(x0 : Char*, x1 : Char*) : Char*
fun setenv(x0 : Char*, x1 : Char*, x2 : Int) : Int
fun strtof(x0 : Char*, x1 : Char**) : Float
fun strtod(x0 : Char*, x1 : Char**) : Double
fun unsetenv(x0 : Char*) : Int
end
Loading

0 comments on commit 9980a1f

Please sign in to comment.