Skip to content
Draft
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
25 changes: 25 additions & 0 deletions c/sys/generated_native_llgo_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//go:build llgo && ((darwin && arm64 && !ios) || (linux && (amd64 || arm64) && !android))

package sys

import (
"testing"
"unsafe"
)

func TestGeneratedGettimeofday(t *testing.T) {
var timeout Timeval
if result := Select(0, nil, nil, nil, &timeout); result != 0 {
t.Fatalf("select with zero timeout = %d", result)
}
var value Timeval
if unsafe.Sizeof(value) != 16 || unsafe.Alignof(value) != 8 {
t.Fatalf("timeval layout = %d/%d", unsafe.Sizeof(value), unsafe.Alignof(value))
}
if result := Gettimeofday(&value, nil); result != 0 {
t.Fatalf("gettimeofday = %d", result)
}
if value.Sec <= 0 || value.Usec < 0 || value.Usec >= 1000000 {
t.Fatalf("invalid timeval %v", value)
}
}
76 changes: 76 additions & 0 deletions c/sys/libc_darwin_arm64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

108 changes: 108 additions & 0 deletions c/sys/libc_linux_amd64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

108 changes: 108 additions & 0 deletions c/sys/libc_linux_arm64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions c/sys/llcppg.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Dir": ".sysroot/include"
}
8 changes: 8 additions & 0 deletions c/sys/llcppg.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
D github.com/goplus/lib/c/signal
D github.com/goplus/lib/c/time
T __itimer_which X__ItimerWhich
T __timezone_ptr_t X__TimezonePtrT
T fd_set FdSet
T itimerval Itimerval
T timeval Timeval
T timezone Timezone
15 changes: 12 additions & 3 deletions c/sys/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ func FD_SET(fd c.Int, fds *FdSet)
//go:linkname FD_ISSET C.llgo_FD_ISSET
func FD_ISSET(fd c.Int, fds *FdSet) c.Int

//go:linkname Select C.select
func Select(n c.Int, fdsRead, fdsWrite, fdsError *FdSet, timeout *Timeval) c.Int

// -----------------------------------------------------------------------------

// Check the first NFDS descriptors each in READFDS (if not NULL) for read
// readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS
// (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out
// after waiting the interval specified therein. Returns the number of ready
// descriptors, or -1 for errors.
//
// This function is a cancellation point and therefore not marked with
// __THROW.
//
//go:linkname Select C.select
func Select(__nfds c.Int, __readfds *FdSet, __writefds *FdSet, __exceptfds *FdSet, __timeout *Timeval) c.Int
Loading