github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/syscall/syscall_libc_nintendoswitch.go (about)

     1  //go:build nintendoswitch
     2  
     3  package syscall
     4  
     5  import (
     6  	"internal/itoa"
     7  )
     8  
     9  // A Signal is a number describing a process signal.
    10  // It implements the os.Signal interface.
    11  type Signal int
    12  
    13  const (
    14  	_ Signal = iota
    15  	SIGCHLD
    16  	SIGINT
    17  	SIGKILL
    18  	SIGTRAP
    19  	SIGQUIT
    20  	SIGTERM
    21  )
    22  
    23  func (s Signal) Signal() {}
    24  
    25  func (s Signal) String() string {
    26  	if 0 <= s && int(s) < len(signals) {
    27  		str := signals[s]
    28  		if str != "" {
    29  			return str
    30  		}
    31  	}
    32  	return "signal " + itoa.Itoa(int(s))
    33  }
    34  
    35  var signals = [...]string{}
    36  
    37  // File system
    38  
    39  const (
    40  	Stdin  = 0
    41  	Stdout = 1
    42  	Stderr = 2
    43  )
    44  
    45  const (
    46  	O_RDONLY = 0
    47  	O_WRONLY = 1
    48  	O_RDWR   = 2
    49  
    50  	O_CREAT  = 0100
    51  	O_TRUNC  = 01000
    52  	O_APPEND = 02000
    53  	O_EXCL   = 0200
    54  	O_SYNC   = 010000
    55  
    56  	O_CLOEXEC = 0
    57  )
    58  
    59  //go:extern errno
    60  var libcErrno uintptr
    61  
    62  func getErrno() error {
    63  	return Errno(libcErrno)
    64  }
    65  
    66  func Pipe2(p []int, flags int) (err error) {
    67  	return ENOSYS // TODO
    68  }
    69  
    70  func Getpagesize() int {
    71  	return 4096 // TODO
    72  }
    73  
    74  type RawSockaddrInet4 struct {
    75  	// stub
    76  }
    77  
    78  type RawSockaddrInet6 struct {
    79  	// stub
    80  }
    81  
    82  func Chmod(path string, mode uint32) (err error) {
    83  	data := cstring(path)
    84  	fail := int(libc_chmod(&data[0], mode))
    85  	if fail < 0 {
    86  		err = getErrno()
    87  	}
    88  	return
    89  }
    90  
    91  // int open(const char *pathname, int flags, mode_t mode);
    92  //
    93  //export open
    94  func libc_open(pathname *byte, flags int32, mode uint32) int32