Source file src/syscall/tables_wasip1.go

     1  // Copyright 2023 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build wasip1
     6  
     7  package syscall
     8  
     9  import "runtime"
    10  
    11  // TODO: Auto-generate some day. (Hard-coded in binaries so not likely to change.)
    12  const (
    13  	E2BIG           Errno = 1
    14  	EACCES          Errno = 2
    15  	EADDRINUSE      Errno = 3
    16  	EADDRNOTAVAIL   Errno = 4
    17  	EAFNOSUPPORT    Errno = 5
    18  	EAGAIN          Errno = 6
    19  	EALREADY        Errno = 7
    20  	EBADF           Errno = 8
    21  	EBADMSG         Errno = 9
    22  	EBUSY           Errno = 10
    23  	ECANCELED       Errno = 11
    24  	ECHILD          Errno = 12
    25  	ECONNABORTED    Errno = 13
    26  	ECONNREFUSED    Errno = 14
    27  	ECONNRESET      Errno = 15
    28  	EDEADLK         Errno = 16
    29  	EDESTADDRREQ    Errno = 17
    30  	EDOM            Errno = 18
    31  	EDQUOT          Errno = 19
    32  	EEXIST          Errno = 20
    33  	EFAULT          Errno = 21
    34  	EFBIG           Errno = 22
    35  	EHOSTUNREACH    Errno = 23
    36  	EIDRM           Errno = 24
    37  	EILSEQ          Errno = 25
    38  	EINPROGRESS     Errno = 26
    39  	EINTR           Errno = 27
    40  	EINVAL          Errno = 28
    41  	EIO             Errno = 29
    42  	EISCONN         Errno = 30
    43  	EISDIR          Errno = 31
    44  	ELOOP           Errno = 32
    45  	EMFILE          Errno = 33
    46  	EMLINK          Errno = 34
    47  	EMSGSIZE        Errno = 35
    48  	EMULTIHOP       Errno = 36
    49  	ENAMETOOLONG    Errno = 37
    50  	ENETDOWN        Errno = 38
    51  	ENETRESET       Errno = 39
    52  	ENETUNREACH     Errno = 40
    53  	ENFILE          Errno = 41
    54  	ENOBUFS         Errno = 42
    55  	ENODEV          Errno = 43
    56  	ENOENT          Errno = 44
    57  	ENOEXEC         Errno = 45
    58  	ENOLCK          Errno = 46
    59  	ENOLINK         Errno = 47
    60  	ENOMEM          Errno = 48
    61  	ENOMSG          Errno = 49
    62  	ENOPROTOOPT     Errno = 50
    63  	ENOSPC          Errno = 51
    64  	ENOSYS          Errno = 52
    65  	ENOTCONN        Errno = 53
    66  	ENOTDIR         Errno = 54
    67  	ENOTEMPTY       Errno = 55
    68  	ENOTRECOVERABLE Errno = 56
    69  	ENOTSOCK        Errno = 57
    70  	ENOTSUP         Errno = 58
    71  	ENOTTY          Errno = 59
    72  	ENXIO           Errno = 60
    73  	EOVERFLOW       Errno = 61
    74  	EOWNERDEAD      Errno = 62
    75  	EPERM           Errno = 63
    76  	EPIPE           Errno = 64
    77  	EPROTO          Errno = 65
    78  	EPROTONOSUPPORT Errno = 66
    79  	EPROTOTYPE      Errno = 67
    80  	ERANGE          Errno = 68
    81  	EROFS           Errno = 69
    82  	ESPIPE          Errno = 70
    83  	ESRCH           Errno = 71
    84  	ESTALE          Errno = 72
    85  	ETIMEDOUT       Errno = 73
    86  	ETXTBSY         Errno = 74
    87  	EXDEV           Errno = 75
    88  	ENOTCAPABLE     Errno = 76
    89  	// needed by src/net/error_unix_test.go
    90  	EOPNOTSUPP = ENOTSUP
    91  )
    92  
    93  // TODO: Auto-generate some day. (Hard-coded in binaries so not likely to change.)
    94  var errorstr = [...]string{
    95  	E2BIG:           "Argument list too long",
    96  	EACCES:          "Permission denied",
    97  	EADDRINUSE:      "Address already in use",
    98  	EADDRNOTAVAIL:   "Address not available",
    99  	EAFNOSUPPORT:    "Address family not supported by protocol family",
   100  	EAGAIN:          "Try again",
   101  	EALREADY:        "Socket already connected",
   102  	EBADF:           "Bad file number",
   103  	EBADMSG:         "Trying to read unreadable message",
   104  	EBUSY:           "Device or resource busy",
   105  	ECANCELED:       "Operation canceled.",
   106  	ECHILD:          "No child processes",
   107  	ECONNABORTED:    "Connection aborted",
   108  	ECONNREFUSED:    "Connection refused",
   109  	ECONNRESET:      "Connection reset by peer",
   110  	EDEADLK:         "Deadlock condition",
   111  	EDESTADDRREQ:    "Destination address required",
   112  	EDOM:            "Math arg out of domain of func",
   113  	EDQUOT:          "Quota exceeded",
   114  	EEXIST:          "File exists",
   115  	EFAULT:          "Bad address",
   116  	EFBIG:           "File too large",
   117  	EHOSTUNREACH:    "Host is unreachable",
   118  	EIDRM:           "Identifier removed",
   119  	EILSEQ:          "EILSEQ",
   120  	EINPROGRESS:     "Connection already in progress",
   121  	EINTR:           "Interrupted system call",
   122  	EINVAL:          "Invalid argument",
   123  	EIO:             "I/O error",
   124  	EISCONN:         "Socket is already connected",
   125  	EISDIR:          "Is a directory",
   126  	ELOOP:           "Too many symbolic links",
   127  	EMFILE:          "Too many open files",
   128  	EMLINK:          "Too many links",
   129  	EMSGSIZE:        "Message too long",
   130  	EMULTIHOP:       "Multihop attempted",
   131  	ENAMETOOLONG:    "File name too long",
   132  	ENETDOWN:        "Network interface is not configured",
   133  	ENETRESET:       "Network dropped connection on reset",
   134  	ENETUNREACH:     "Network is unreachable",
   135  	ENFILE:          "File table overflow",
   136  	ENOBUFS:         "No buffer space available",
   137  	ENODEV:          "No such device",
   138  	ENOENT:          "No such file or directory",
   139  	ENOEXEC:         "Exec format error",
   140  	ENOLCK:          "No record locks available",
   141  	ENOLINK:         "The link has been severed",
   142  	ENOMEM:          "Out of memory",
   143  	ENOMSG:          "No message of desired type",
   144  	ENOPROTOOPT:     "Protocol not available",
   145  	ENOSPC:          "No space left on device",
   146  	ENOSYS:          "Not implemented on " + runtime.GOOS,
   147  	ENOTCONN:        "Socket is not connected",
   148  	ENOTDIR:         "Not a directory",
   149  	ENOTEMPTY:       "Directory not empty",
   150  	ENOTRECOVERABLE: "State not recoverable",
   151  	ENOTSOCK:        "Socket operation on non-socket",
   152  	ENOTSUP:         "Not supported",
   153  	ENOTTY:          "Not a typewriter",
   154  	ENXIO:           "No such device or address",
   155  	EOVERFLOW:       "Value too large for defined data type",
   156  	EOWNERDEAD:      "Owner died",
   157  	EPERM:           "Operation not permitted",
   158  	EPIPE:           "Broken pipe",
   159  	EPROTO:          "Protocol error",
   160  	EPROTONOSUPPORT: "Unknown protocol",
   161  	EPROTOTYPE:      "Protocol wrong type for socket",
   162  	ERANGE:          "Math result not representable",
   163  	EROFS:           "Read-only file system",
   164  	ESPIPE:          "Illegal seek",
   165  	ESRCH:           "No such process",
   166  	ESTALE:          "Stale file handle",
   167  	ETIMEDOUT:       "Connection timed out",
   168  	ETXTBSY:         "Text file busy",
   169  	EXDEV:           "Cross-device link",
   170  	ENOTCAPABLE:     "Capabilities insufficient",
   171  }
   172  
   173  // Do the interface allocations only once for common
   174  // Errno values.
   175  var (
   176  	errEAGAIN error = EAGAIN
   177  	errEINVAL error = EINVAL
   178  	errENOENT error = ENOENT
   179  )
   180  
   181  // errnoErr returns common boxed Errno values, to prevent
   182  // allocations at runtime.
   183  //
   184  // We set both noinline and nosplit to reduce code size, this function has many
   185  // call sites in the syscall package, inlining it causes a significant increase
   186  // of the compiled code; the function call ultimately does not make a difference
   187  // in the performance of syscall functions since the time is dominated by calls
   188  // to the imports and path resolution.
   189  //
   190  //go:noinline
   191  //go:nosplit
   192  func errnoErr(e Errno) error {
   193  	switch e {
   194  	case 0:
   195  		return nil
   196  	case EAGAIN:
   197  		return errEAGAIN
   198  	case EINVAL:
   199  		return errEINVAL
   200  	case ENOENT:
   201  		return errENOENT
   202  	}
   203  	return e
   204  }
   205  

View as plain text