mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-13 15:33:40 +00:00
linux: add runtime.fcntl function
This is needed for the internal/syscall/unix package. Signed-off-by: leongross <leon.gross@9elements.com>
This commit is contained in:
@@ -926,6 +926,7 @@ endif
|
|||||||
@cp -rp lib/musl/src/env build/release/tinygo/lib/musl/src
|
@cp -rp lib/musl/src/env build/release/tinygo/lib/musl/src
|
||||||
@cp -rp lib/musl/src/errno build/release/tinygo/lib/musl/src
|
@cp -rp lib/musl/src/errno build/release/tinygo/lib/musl/src
|
||||||
@cp -rp lib/musl/src/exit build/release/tinygo/lib/musl/src
|
@cp -rp lib/musl/src/exit build/release/tinygo/lib/musl/src
|
||||||
|
@cp -rp lib/musl/src/fcntl build/release/tinygo/lib/musl/src
|
||||||
@cp -rp lib/musl/src/include build/release/tinygo/lib/musl/src
|
@cp -rp lib/musl/src/include build/release/tinygo/lib/musl/src
|
||||||
@cp -rp lib/musl/src/internal build/release/tinygo/lib/musl/src
|
@cp -rp lib/musl/src/internal build/release/tinygo/lib/musl/src
|
||||||
@cp -rp lib/musl/src/legacy build/release/tinygo/lib/musl/src
|
@cp -rp lib/musl/src/legacy build/release/tinygo/lib/musl/src
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ var libMusl = Library{
|
|||||||
"env/*.c",
|
"env/*.c",
|
||||||
"errno/*.c",
|
"errno/*.c",
|
||||||
"exit/*.c",
|
"exit/*.c",
|
||||||
|
"fcntl/*.c",
|
||||||
"internal/defsysinfo.c",
|
"internal/defsysinfo.c",
|
||||||
"internal/libc.c",
|
"internal/libc.c",
|
||||||
"internal/syscall_ret.c",
|
"internal/syscall_ret.c",
|
||||||
|
|||||||
+19
-1
@@ -5,7 +5,9 @@ package runtime
|
|||||||
// This file is for systems that are _actually_ Linux (not systems that pretend
|
// This file is for systems that are _actually_ Linux (not systems that pretend
|
||||||
// to be Linux, like baremetal systems).
|
// to be Linux, like baremetal systems).
|
||||||
|
|
||||||
import "unsafe"
|
import (
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
const GOOS = "linux"
|
const GOOS = "linux"
|
||||||
|
|
||||||
@@ -83,6 +85,11 @@ type elfProgramHeader32 struct {
|
|||||||
//go:extern __ehdr_start
|
//go:extern __ehdr_start
|
||||||
var ehdr_start elfHeader
|
var ehdr_start elfHeader
|
||||||
|
|
||||||
|
// int *__errno_location(void);
|
||||||
|
//
|
||||||
|
//export __errno_location
|
||||||
|
func libc_errno_location() *int32
|
||||||
|
|
||||||
// findGlobals finds globals in the .data/.bss sections.
|
// findGlobals finds globals in the .data/.bss sections.
|
||||||
// It parses the ELF program header to find writable segments.
|
// It parses the ELF program header to find writable segments.
|
||||||
func findGlobals(found func(start, end uintptr)) {
|
func findGlobals(found func(start, end uintptr)) {
|
||||||
@@ -139,3 +146,14 @@ func hardwareRand() (n uint64, ok bool) {
|
|||||||
//
|
//
|
||||||
//export getrandom
|
//export getrandom
|
||||||
func libc_getrandom(buf unsafe.Pointer, buflen uintptr, flags uint32) uint32
|
func libc_getrandom(buf unsafe.Pointer, buflen uintptr, flags uint32) uint32
|
||||||
|
|
||||||
|
// int fcntl(int fd, int cmd, int arg);
|
||||||
|
//
|
||||||
|
//export fcntl
|
||||||
|
func libc_fcntl(fd int, cmd int, arg int) (ret int)
|
||||||
|
|
||||||
|
func fcntl(fd int32, cmd int32, arg int32) (ret int32, errno int32) {
|
||||||
|
ret = int32(libc_fcntl(int(fd), int(cmd), int(arg)))
|
||||||
|
errno = *libc_errno_location()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user