github.com/aykevl/tinygo@v0.5.0/src/syscall/syscall_baremetal.go (about)

     1  // +build avr cortexm
     2  
     3  package syscall
     4  
     5  // Most code here has been copied from the Go sources:
     6  //   https://github.com/golang/go/blob/go1.12/src/syscall/syscall_js.go
     7  // It has the following copyright note:
     8  //
     9  //     Copyright 2018 The Go Authors. All rights reserved.
    10  //     Use of this source code is governed by a BSD-style
    11  //     license that can be found in the LICENSE file.
    12  
    13  // A Signal is a number describing a process signal.
    14  // It implements the os.Signal interface.
    15  type Signal int
    16  
    17  const (
    18  	_ Signal = iota
    19  	SIGCHLD
    20  	SIGINT
    21  	SIGKILL
    22  	SIGTRAP
    23  	SIGQUIT
    24  	SIGTERM
    25  )
    26  
    27  // File system
    28  
    29  const (
    30  	Stdin  = 0
    31  	Stdout = 1
    32  	Stderr = 2
    33  )
    34  
    35  const (
    36  	O_RDONLY = 0
    37  	O_WRONLY = 1
    38  	O_RDWR   = 2
    39  
    40  	O_CREAT  = 0100
    41  	O_CREATE = O_CREAT
    42  	O_TRUNC  = 01000
    43  	O_APPEND = 02000
    44  	O_EXCL   = 0200
    45  	O_SYNC   = 010000
    46  
    47  	O_CLOEXEC = 0
    48  )
    49  
    50  func Getenv(key string) (value string, found bool) {
    51  	return "", false // stub
    52  }
    53  
    54  func Open(path string, mode int, perm uint32) (fd int, err error) {
    55  	return 0, ENOSYS
    56  }
    57  
    58  func Read(fd int, p []byte) (n int, err error) {
    59  	return 0, ENOSYS
    60  }
    61  
    62  func Seek(fd int, offset int64, whence int) (off int64, err error) {
    63  	return 0, ENOSYS
    64  }
    65  
    66  func Close(fd int) (err error) {
    67  	return ENOSYS
    68  }
    69  
    70  // Processes
    71  
    72  type WaitStatus uint32
    73  
    74  func (w WaitStatus) Exited() bool       { return false }
    75  func (w WaitStatus) ExitStatus() int    { return 0 }
    76  func (w WaitStatus) Signaled() bool     { return false }
    77  func (w WaitStatus) Signal() Signal     { return 0 }
    78  func (w WaitStatus) CoreDump() bool     { return false }
    79  func (w WaitStatus) Stopped() bool      { return false }
    80  func (w WaitStatus) Continued() bool    { return false }
    81  func (w WaitStatus) StopSignal() Signal { return 0 }
    82  func (w WaitStatus) TrapCause() int     { return 0 }
    83  
    84  // XXX made up
    85  type Rusage struct {
    86  	Utime Timeval
    87  	Stime Timeval
    88  }
    89  
    90  // XXX made up
    91  type ProcAttr struct {
    92  	Dir   string
    93  	Env   []string
    94  	Files []uintptr
    95  	Sys   *SysProcAttr
    96  }
    97  
    98  type SysProcAttr struct {
    99  }
   100  
   101  func Getegid() int                      { return 1 }
   102  func Geteuid() int                      { return 1 }
   103  func Getgid() int                       { return 1 }
   104  func Getgroups() ([]int, error)         { return []int{1}, nil }
   105  func Getppid() int                      { return 2 }
   106  func Getpid() int                       { return 3 }
   107  func Gettimeofday(tv *Timeval) error    { return ENOSYS }
   108  func Getuid() int                       { return 1 }
   109  func Kill(pid int, signum Signal) error { return ENOSYS }
   110  func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
   111  	return 0, ENOSYS
   112  }
   113  func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle uintptr, err error) {
   114  	return 0, 0, ENOSYS
   115  }
   116  func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
   117  	return 0, ENOSYS
   118  }
   119  
   120  type Timeval struct {
   121  	Sec  int64
   122  	Usec int64
   123  }