Skip to content

Commit

Permalink
Linux is 128 bytes so directly inline the functions
Browse files Browse the repository at this point in the history
  • Loading branch information
TotallyGamerJet committed Jan 4, 2025
1 parent be741aa commit 930961d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions internal/fakecgo/go_libinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ func _cgo_try_pthread_create(thread *pthread_t, attr *pthread_attr_t, pfn unsafe
var err int

for tries = 0; tries < 20; tries++ {
err = int(pthread_create(thread, attr, pfn, unsafe.Pointer(arg)))
err = int(call5(pthread_createABI0, uintptr(unsafe.Pointer(thread)), uintptr(unsafe.Pointer(attr)), uintptr(pfn), uintptr(unsafe.Pointer(arg)), 0))
if err == 0 {
pthread_detach(*thread)
call5(pthread_detachABI0, uintptr(*thread), 0, 0, 0, 0)
return 0
}
if err != int(syscall.EAGAIN) {
return err
}
ts.Sec = 0
ts.Nsec = (tries + 1) * 1000 * 1000 // Milliseconds.
nanosleep(&ts, nil)
call5(nanosleepABI0, uintptr(unsafe.Pointer(&ts)), 0, 0, 0, 0)
}
return int(syscall.EAGAIN)
}
7 changes: 4 additions & 3 deletions internal/fakecgo/libcgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ package fakecgo
type (
size_t uintptr
// Sources:
// Darwin - https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/_types.h#L74
// FreeBSD - https://github.com/DoctorWkt/xv6-freebsd/blob/d2a294c2a984baed27676068b15ed9a29b06ab6f/include/signal.h#L98C9-L98C21
sigset_t [32]byte
// Darwin (32 bytes) - https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/_types.h#L74
// FreeBSD (32 bytes) - https://github.com/DoctorWkt/xv6-freebsd/blob/d2a294c2a984baed27676068b15ed9a29b06ab6f/include/signal.h#L98C9-L98C21
// Linux (128 bytes) - https://github.com/torvalds/linux/blob/ab75170520d4964f3acf8bb1f91d34cbc650688e/arch/x86/include/asm/signal.h#L25
sigset_t [128]byte
pthread_attr_t [64]byte
pthread_t int
pthread_key_t uint64
Expand Down

0 comments on commit 930961d

Please sign in to comment.