os/errno:fix os.Errno 's nil pointer derefer in linux

This commit is contained in:
luoliwoshang
2024-10-12 11:58:53 +08:00
parent 9ea88fe247
commit e9177c8932
10 changed files with 54 additions and 22 deletions

View File

@@ -1,4 +1,5 @@
#include <stdlib.h>
#include <errno.h>
int llgoClearenv() {
extern char **environ;
@@ -7,3 +8,5 @@ int llgoClearenv() {
}
return 0;
}
int llgoErrno() { return errno; }

View File

@@ -70,8 +70,8 @@ type (
StatT = syscall.Stat_t
)
//go:linkname Errno errno
var Errno c.Int
//go:linkname Errno C.llgoErrno
func Errno() c.Int
//go:linkname Umask C.umask
func Umask(cmask ModeT) ModeT

View File

@@ -21,7 +21,8 @@ package os
import "C"
const (
LLGoPackage = "decl"
LLGoFiles = "_os/os.c"
LLGoPackage = "link"
)
//go:linkname Clearenv C.clearenv