build: separate compiler and libs

This commit is contained in:
Li Jie
2025-01-07 21:49:08 +08:00
parent b0123567cd
commit 1172e5bdce
559 changed files with 190 additions and 176 deletions

View File

@@ -0,0 +1,71 @@
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build unix
package syscall
import (
"unsafe"
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/syscall"
"github.com/goplus/llgo/compiler/internal/lib/internal/oserror"
)
var (
Stdin = 0
Stdout = 1
Stderr = 2
)
type Errno uintptr
func (e Errno) Error() string {
ret := c.Strerror(c.Int(e))
return unsafe.String((*byte)(unsafe.Pointer(ret)), c.Strlen(ret))
}
func (e Errno) Is(target error) bool {
switch target {
case oserror.ErrPermission:
return e == Errno(syscall.EACCES) || e == Errno(syscall.EPERM)
case oserror.ErrExist:
return e == Errno(syscall.EEXIST) || e == Errno(syscall.ENOTEMPTY)
case oserror.ErrNotExist:
return e == Errno(syscall.ENOENT)
// TODO(xsw): go1.21
// case errors.ErrUnsupported:
// return e == ENOSYS || e == ENOTSUP || e == EOPNOTSUPP
}
return false
}
func (e Errno) Temporary() bool {
return e == Errno(syscall.EINTR) || e == Errno(syscall.EMFILE) ||
e == Errno(syscall.ENFILE) || e.Timeout()
}
func (e Errno) Timeout() bool {
return e == Errno(syscall.EAGAIN) || e == Errno(syscall.EWOULDBLOCK) || e == Errno(syscall.ETIMEDOUT)
}
// A Signal is a number describing a process signal.
// It implements the os.Signal interface.
type Signal int
func (s Signal) Signal() {}
func (s Signal) String() string {
/*
if 0 <= s && int(s) < len(signals) {
str := signals[s]
if str != "" {
return str
}
}
return "signal " + itoa.Itoa(int(s))
*/
panic("todo: syscall.Signal.String")
}