llgo/c/hyper-related c lib
This commit is contained in:
13
c/fddef/_wrap/fddef.c
Normal file
13
c/fddef/_wrap/fddef.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
int fd_isset(int n, fd_set *fd) {
|
||||
return FD_ISSET(n, fd);
|
||||
}
|
||||
|
||||
void fdSet(int n, fd_set *fd) {
|
||||
FD_SET(n, fd);
|
||||
}
|
||||
|
||||
void fd_zero(fd_set *fd) {
|
||||
FD_ZERO(fd);
|
||||
}
|
||||
24
c/fddef/fddef.go
Normal file
24
c/fddef/fddef.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package fddef
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
_ "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
LLGoFiles = "_wrap/fddef.c"
|
||||
LLGoPackage = "link: c"
|
||||
)
|
||||
|
||||
type FdSet struct {
|
||||
Unused [8]byte
|
||||
}
|
||||
|
||||
//go:linkname FdZero C.fd_zero
|
||||
func FdZero(fdSet *FdSet)
|
||||
|
||||
//go:linkname Fdset C.fdSet
|
||||
func Fdset(fd c.Int, fdSet *FdSet)
|
||||
|
||||
//go:linkname FdIsset C.fd_isset
|
||||
func FdIsset(fd c.Int, fdSet *FdSet) c.Int
|
||||
29
c/netdb/netdb.go
Normal file
29
c/netdb/netdb.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package netdb
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c/socket"
|
||||
_ "unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
const (
|
||||
LLGoPackage = "decl"
|
||||
)
|
||||
|
||||
type AddrInfo struct {
|
||||
AiFlags c.Int
|
||||
AiFamily c.Int
|
||||
AiSockType c.Int
|
||||
AiProtocol c.Int
|
||||
AiAddrLen c.Uint
|
||||
AiCanOnName *c.Char
|
||||
AiAddr *socket.SockAddr
|
||||
AiNext *AddrInfo
|
||||
}
|
||||
|
||||
//go:linkname Getaddrinfo C.getaddrinfo
|
||||
func Getaddrinfo(host *c.Char, port *c.Char, addrInfo *AddrInfo, result **AddrInfo) c.Int
|
||||
|
||||
//go:linkname Freeaddrinfo C.freeaddrinfo
|
||||
func Freeaddrinfo(addrInfo *AddrInfo) c.Int
|
||||
@@ -58,6 +58,10 @@ const (
|
||||
O_TRUNC = 0x00000400
|
||||
)
|
||||
|
||||
const (
|
||||
EAGAIN = 35
|
||||
)
|
||||
|
||||
type (
|
||||
ModeT C.mode_t
|
||||
UidT C.uid_t
|
||||
|
||||
22
c/select/select.go
Normal file
22
c/select/select.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package _select
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c/fddef"
|
||||
_ "unsafe"
|
||||
|
||||
"github.com/goplus/llgo/c"
|
||||
)
|
||||
|
||||
const (
|
||||
LLGoPackage = "decl"
|
||||
)
|
||||
|
||||
// (TODO) merge to timeval
|
||||
//
|
||||
type TimeVal struct {
|
||||
TvSec c.Long
|
||||
TvUSec c.Int
|
||||
}
|
||||
|
||||
//go:linkname Select C.select
|
||||
func Select(n c.Int, r *fddef.FdSet, w *fddef.FdSet, e *fddef.FdSet, timeout *TimeVal) c.Int
|
||||
@@ -142,3 +142,14 @@ func SwapInt16(data uint16) uint16 {
|
||||
func Htons(x uint16) uint16 {
|
||||
return SwapInt16(x)
|
||||
}
|
||||
|
||||
// (TODO) merge to netdb
|
||||
//
|
||||
//go:linkname InetAddr C.inet_addr
|
||||
func InetAddr(s *c.Char) c.Uint
|
||||
|
||||
//go:linkname Send C.send
|
||||
func Send(c.Int, c.Pointer, uintptr, c.Int) c.Long
|
||||
|
||||
//go:linkname Recv C.recv
|
||||
func Recv(c.Int, c.Pointer, uintptr, c.Int) c.Long
|
||||
|
||||
Reference in New Issue
Block a user