Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for arm-linux-musleabihf #7859

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Add more bindings to arm-linux-musleabihf
  • Loading branch information
j8r committed Aug 31, 2019
commit cc0b879e6e9a7ce8ed4ec5e56398dc06f8ef3099
10 changes: 6 additions & 4 deletions src/lib_c/arm-linux-musleabihf/c/dirent.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ require "./sys/types"
lib LibC
type DIR = Void

DT_DIR = 4

struct Dirent
d_ino : InoT
d_off : OffT
Expand All @@ -11,8 +13,8 @@ lib LibC
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
fun closedir(dirp : DIR*) : Int
fun opendir(name : Char*) : DIR*
fun readdir(dirp : DIR*) : Dirent*
fun rewinddir(dirp : DIR*) : Void
end
26 changes: 26 additions & 0 deletions src/lib_c/arm-linux-musleabihf/c/netinet/in.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ require "../stdint"

lib LibC
IPPROTO_IP = 0
IPPROTO_IPV6 = 41
IPPROTO_ICMP = 1
IPPROTO_RAW = 255
IPPROTO_TCP = 6
Expand Down Expand Up @@ -39,4 +40,29 @@ lib LibC
sin6_addr : In6Addr
sin6_scope_id : UInt32T
end

IP_MULTICAST_IF = 32
IPV6_MULTICAST_IF = 17

IP_MULTICAST_TTL = 33
IPV6_MULTICAST_HOPS = 18

IP_MULTICAST_LOOP = 34
IPV6_MULTICAST_LOOP = 19

IP_ADD_MEMBERSHIP = 35
IPV6_JOIN_GROUP = 20

IP_DROP_MEMBERSHIP = 36
IPV6_LEAVE_GROUP = 21

struct IpMreq
imr_multiaddr : InAddr
imr_interface : InAddr
end

struct Ipv6Mreq
ipv6mr_multiaddr : In6Addr
ipv6mr_interface : UInt
end
end
39 changes: 26 additions & 13 deletions src/lib_c/arm-linux-musleabihf/c/pthread.cr
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
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
PTHREAD_MUTEX_ERRORCHECK = 2

fun pthread_attr_destroy(attr : PthreadAttrT*) : Int
fun pthread_attr_getstack(addr : PthreadAttrT*, stackaddr : Void**, stacksize : SizeT*) : Int
fun pthread_condattr_destroy(attr : PthreadCondattrT*) : Int
fun pthread_condattr_init(attr : PthreadCondattrT*) : Int
fun pthread_condattr_setclock(attr : PthreadCondattrT*, type : ClockidT) : Int
fun pthread_cond_broadcast(cond : PthreadCondT*) : Int
fun pthread_cond_destroy(cond : PthreadCondT*) : Int
fun pthread_cond_init(cond : PthreadCondT*, cond_attr : PthreadCondattrT*) : Int
fun pthread_cond_signal(cond : PthreadCondT*) : Int
fun pthread_cond_timedwait(cond : PthreadCondT*, mutex : PthreadMutexT*, abstime : Timespec*) : Int
fun pthread_cond_wait(cond : PthreadCondT*, mutex : PthreadMutexT*) : Int
fun pthread_create(newthread : PthreadT*, attr : PthreadAttrT*, start_routine : Void* -> Void*, arg : Void*) : Int
fun pthread_detach(th : PthreadT) : Int
fun pthread_getattr_np(thread : PthreadT, attr : PthreadAttrT*) : Int
fun pthread_equal(thread1 : PthreadT, thread2 : PthreadT) : Int
fun pthread_join(th : PthreadT, thread_return : Void**) : Int
fun pthread_mutexattr_destroy(attr : PthreadMutexattrT*) : Int
fun pthread_mutexattr_init(attr : PthreadMutexattrT*) : Int
fun pthread_mutexattr_settype(attr : PthreadMutexattrT*, type : Int) : Int
fun pthread_mutex_destroy(mutex : PthreadMutexT*) : Int
fun pthread_mutex_init(mutex : PthreadMutexT*, mutexattr : PthreadMutexattrT*) : Int
fun pthread_mutex_lock(mutex : PthreadMutexT*) : Int
fun pthread_mutex_trylock(mutex : PthreadMutexT*) : Int
fun pthread_mutex_unlock(mutex : PthreadMutexT*) : Int
fun pthread_self : PthreadT
end
3 changes: 3 additions & 0 deletions src/lib_c/arm-linux-musleabihf/c/sched.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lib LibC
fun sched_yield : Int
end
12 changes: 12 additions & 0 deletions src/lib_c/arm-linux-musleabihf/c/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,22 @@ lib LibC
SIGSTKFLT = 16
SIGUNUSED = LibC::SIGSYS

SIG_SETMASK = 2

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)

struct SigsetT
val : ULong[16] # 128 / sizeof(long)
end

fun kill(x0 : PidT, x1 : Int) : Int
fun pthread_sigmask(Int, SigsetT*, SigsetT*) : Int
fun signal(x0 : Int, x1 : Int -> Void) : Int -> Void
fun sigemptyset(SigsetT*) : Int
fun sigfillset(SigsetT*) : Int
fun sigaddset(SigsetT*, Int) : Int
fun sigdelset(SigsetT*, Int) : Int
fun sigismember(SigsetT*, Int) : Int
end
53 changes: 29 additions & 24 deletions src/lib_c/arm-linux-musleabihf/c/unistd.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,38 @@ lib LibC
SC_CLK_TCK = 2
SC_NPROCESSORS_ONLN = 84

fun access(x0 : Char*, x1 : Int) : Int
fun chdir(x0 : Char*) : Int
fun chown(x0 : Char*, x1 : UidT, x2 : GidT) : Int
fun close(x0 : Int) : Int
fun dup2(x0 : Int, x1 : Int) : Int
fun _exit(x0 : Int) : NoReturn
fun execvp(x0 : Char*, x1 : Char**) : Int
fun chroot(path : Char*) : Int
fun access(name : Char*, type : Int) : Int
fun chdir(path : Char*) : Int
fun chown(file : Char*, owner : UidT, group : GidT) : Int
fun close(fd : Int) : Int
fun dup2(fd : Int, fd2 : Int) : Int
fun _exit(status : Int) : NoReturn
fun execvp(file : Char*, argv : Char**) : Int
fun fdatasync(fd : Int) : Int
@[ReturnsTwice]
fun fork : PidT
fun ftruncate(x0 : Int, x1 : OffT) : Int
fun getcwd(x0 : Char*, x1 : SizeT) : Char*
fun gethostname(x0 : Char*, x1 : SizeT) : Int
fun getpgid(x0 : PidT) : PidT
fun fsync(fd : Int) : Int
fun ftruncate(fd : Int, length : OffT) : Int
fun getcwd(buf : Char*, size : SizeT) : Char*
fun gethostname(name : Char*, len : SizeT) : Int
fun getpgid(pid : PidT) : PidT
fun getpid : PidT
fun getppid : PidT
fun isatty(x0 : Int) : Int
fun lchown(x0 : Char*, x1 : UidT, x2 : GidT) : Int
fun link(x0 : Char*, x1 : Char*) : Int
fun lockf(x0 : Int, x1 : Int, x2 : OffT) : Int
fun lseek(x0 : Int, x1 : OffT, x2 : Int) : OffT
fun pipe(x0 : StaticArray(Int, 2)) : Int
fun read(x0 : Int, x1 : Void*, x2 : SizeT) : SSizeT
fun isatty(fd : Int) : Int
fun ttyname_r(fd : Int, buf : Char*, buffersize : SizeT) : Int
fun lchown(file : Char*, owner : UidT, group : GidT) : Int
fun link(from : Char*, to : Char*) : Int
fun lockf(fd : Int, cmd : Int, len : OffT) : Int
fun lseek(fd : Int, offset : OffT, whence : Int) : OffT
fun pipe(pipedes : StaticArray(Int, 2)) : Int
fun read(fd : Int, buf : Void*, nbytes : SizeT) : SSizeT
fun pread(x0 : Int, x1 : Void*, x2 : SizeT, x3 : OffT) : SSizeT
fun rmdir(x0 : Char*) : Int
fun symlink(x0 : Char*, x1 : Char*) : Int
fun syscall(x0 : Long, ...) : Long
fun sysconf(x0 : Int) : Long
fun unlink(x0 : Char*) : Int
fun write(x0 : Int, x1 : Void*, x2 : SizeT) : SSizeT
fun rmdir(path : Char*) : Int
fun symlink(from : Char*, to : Char*) : Int
fun readlink(path : Char*, buf : Char*, size : SizeT) : SSizeT
fun syscall(sysno : Long, ...) : Long
fun sysconf(name : Int) : Long
fun unlink(name : Char*) : Int
fun write(fd : Int, buf : Void*, n : SizeT) : SSizeT
end