refactor(c/libuv): Move some func due to libuv doc

doc: https://docs.libuv.org/en/v1.x/
This commit is contained in:
hackerchai
2024-08-06 15:58:15 +08:00
parent 9b12e9819c
commit 9a61e374b5
2 changed files with 34 additions and 29 deletions

View File

@@ -103,10 +103,6 @@ type Poll struct {
/* Request types. */
type Shutdown struct {
Unused [0]byte
}
type Buf struct {
Base *c.Char
Len uintptr
@@ -135,9 +131,6 @@ type GetaddrinfoCb func(req *GetAddrInfo, status c.Int, res *net.AddrInfo)
// llgo:type C
type GetnameinfoCb func(req *GetNameInfo, status c.Int, hostname *c.Char, service *c.Char)
// llgo:type C
type ShutdownCb func(req *Shutdown, status c.Int)
// llgo:type C
type WalkCb func(handle *Handle, arg c.Pointer)
@@ -158,16 +151,6 @@ func LibraryShutdown()
//go:linkname ReplaceAllocator C.uv_replace_allocator
func ReplaceAllocator(mallocFunc MallocFunc, reallocFunc ReallocFunc, callocFunc CallocFunc, freeFunc FreeFunc) c.Int
//go:linkname Close C.uv_close
func Close(handle *Handle, closeCb CloseCb)
// ----------------------------------------------
// llgo:link (*Shutdown).Shutdown C.uv_shutdown
func (shutdown *Shutdown) Shutdown(stream *Stream, shutdownCb ShutdownCb) c.Int {
return 0
}
// ----------------------------------------------
/* Loop related functions and method. */
@@ -202,20 +185,20 @@ func LoopInit(loop *Loop) c.Int
//go:linkname LoopNew C.uv_loop_new
func LoopNew() *Loop
//go:linkname LoopNow C.uv_now
func LoopNow(loop *Loop) c.UlongLong
//go:linkname Now C.uv_now
func Now(loop *Loop) c.UlongLong
//go:linkname LoopUpdateTime C.uv_update_time
func LoopUpdateTime(loop *Loop)
//go:linkname UpdateTime C.uv_update_time
func UpdateTime(loop *Loop)
//go:linkname LoopBackendFd C.uv_backend_fd
func LoopBackendFd(loop *Loop) c.Int
//go:linkname BackendFd C.uv_backend_fd
func BackendFd(loop *Loop) c.Int
//go:linkname LoopBackendTimeout C.uv_backend_timeout
func LoopBackendTimeout(loop *Loop) c.Int
//go:linkname BackendTimeout C.uv_backend_timeout
func BackendTimeout(loop *Loop) c.Int
//go:linkname LoopWalk C.uv_walk
func LoopWalk(loop *Loop, walkCb WalkCb, arg c.Pointer)
//go:linkname Walk C.uv_walk
func Walk(loop *Loop, walkCb WalkCb, arg c.Pointer)
// ----------------------------------------------

View File

@@ -70,11 +70,12 @@ type UdpFlags c.Int
/* Handle types. */
type Tcp C.uv_tcp_t
// TODO(spongehah): Handle
type Handle struct {
Data c.Pointer
Unused [88]byte
// TODO(spongehah): Stream
// TODO(spongehah): Stream
}
type Stream struct {
@@ -82,6 +83,9 @@ type Stream struct {
Unused [256]byte
}
type Shutdown struct {
Unused [0]byte
}
type Udp struct {
Unused [0]byte
@@ -97,12 +101,12 @@ type UdpSend struct {
Unused [0]byte
}
// TODO(spongehah): Connect
type Connect struct {
Data c.Pointer
Unused [88]byte
}
// TODO(spongehah): Write
type Write struct {
Data c.Pointer
@@ -142,6 +146,9 @@ type WriteCb func(req *Write, status c.Int)
// llgo:type C
type ConnectionCb func(server *Stream, status c.Int)
// llgo:type C
type ShutdownCb func(req *Shutdown, status c.Int)
// ----------------------------------------------
/* Handle related function and method */
@@ -219,6 +226,16 @@ func (handle *Handle) IsClosing() c.Int {
return 0
}
// llgo:link (*Handle).IsReadable C.uv_is_readable
func (handle *Handle) IsReadable() c.Int {
return 0
}
// llgo:link (*Handle).IsWritable C.uv_is_writable
func (handle *Handle) IsWritable() c.Int {
return 0
}
// ----------------------------------------------
/* Req related function and method */
@@ -306,6 +323,11 @@ func (stream *Stream) SetBlocking(blocking c.Int) c.Int {
return 0
}
//go:linkname StreamShutdown C.uv_shutdown
func StreamShutdown(shutdown *Shutdown, stream *Stream, shutdownCb ShutdownCb) c.Int {
return 0
}
// ----------------------------------------------
/* Tcp related function and method */