github.com/gotranspile/cxgo@v0.3.7/libs/errno.go (about)

     1  package libs
     2  
     3  import (
     4  	"github.com/gotranspile/cxgo/runtime/libc"
     5  	"github.com/gotranspile/cxgo/types"
     6  )
     7  
     8  // https://pubs.opengroup.org/onlinepubs/9699919799/
     9  
    10  func init() {
    11  	RegisterLibrary("errno.h", func(c *Env) *Library {
    12  		gint := c.Go().Int()
    13  		return &Library{
    14  			Header: `
    15  #include <` + BuiltinH + `>
    16  
    17  _cxgo_go_int errno = 0;
    18  
    19  char* strerror (_cxgo_go_int errnum);
    20  
    21  // Argument list too long.
    22  #define E2BIG 2
    23  // Permission denied.
    24  #define EACCES 3
    25  // Address in use.
    26  #define EADDRINUSE 4
    27  // Address not available.
    28  #define EADDRNOTAVAIL 5
    29  // Address family not supported.
    30  #define EAFNOSUPPORT 6
    31  // Resource unavailable, try again (may be the same value as EWOULDBLOCK).
    32  #define EAGAIN 7
    33  // Connection already in progress.
    34  #define EALREADY 8
    35  // Bad file descriptor.
    36  #define EBADF 9
    37  // Bad message.
    38  #define EBADMSG 10
    39  // Device or resource busy.
    40  #define EBUSY 11
    41  // Operation canceled.
    42  #define ECANCELED 12
    43  // No child processes.
    44  #define ECHILD 13
    45  // Connection aborted.
    46  #define ECONNABORTED 14
    47  // Connection refused.
    48  #define ECONNREFUSED 15
    49  // Connection reset.
    50  #define ECONNRESET 16
    51  // Resource deadlock would occur.
    52  #define EDEADLK 17
    53  // Destination address required.
    54  #define EDESTADDRREQ 18
    55  // Mathematics argument out of domain of function.
    56  #define EDOM 19
    57  // Reserved.
    58  #define EDQUOT 20
    59  // File exists.
    60  #define EEXIST 21
    61  // Bad address.
    62  #define EFAULT 22
    63  // File too large.
    64  #define EFBIG 23
    65  // Host is unreachable.
    66  #define EHOSTUNREACH 24
    67  // Identifier removed.
    68  #define EIDRM 25
    69  // Illegal byte sequence.
    70  #define EILSEQ 26
    71  // Operation in progress.
    72  #define EINPROGRESS 27
    73  // Interrupted function.
    74  #define EINTR 28
    75  // Invalid argument.
    76  #define EINVAL 29
    77  // I/O error.
    78  #define EIO 30
    79  // Socket is connected.
    80  #define EISCONN 31
    81  // Is a directory.
    82  #define EISDIR 32
    83  // Too many levels of symbolic links.
    84  #define ELOOP 33
    85  // File descriptor value too large.
    86  #define EMFILE 34
    87  // Too many links.
    88  #define EMLINK 35
    89  // Message too large.
    90  #define EMSGSIZE 36
    91  // Reserved.
    92  #define EMULTIHOP 37
    93  // Filename too long.
    94  #define ENAMETOOLONG 38
    95  // Network is down.
    96  #define ENETDOWN 39
    97  // Connection aborted by network.
    98  #define ENETRESET 40
    99  // Network unreachable.
   100  #define ENETUNREACH 41
   101  // Too many files open in system.
   102  #define ENFILE 42
   103  // No buffer space available.
   104  #define ENOBUFS 43
   105  // No message is available on the STREAM head read queue.
   106  #define ENODATA 44
   107  // No such device.
   108  #define ENODEV 45
   109  // No such file or directory.
   110  #define ENOENT 46
   111  // Executable file format error.
   112  #define ENOEXEC 47
   113  // No locks available.
   114  #define ENOLCK 48
   115  // Reserved.
   116  #define ENOLINK 49
   117  // Not enough space.
   118  #define ENOMEM 50
   119  // No message of the desired type.
   120  #define ENOMSG 51
   121  // Protocol not available.
   122  #define ENOPROTOOPT 52
   123  // No space left on device.
   124  #define ENOSPC 53
   125  // No STREAM resources.
   126  #define ENOSR 54
   127  // Not a STREAM.
   128  #define ENOSTR 55
   129  // Functionality not supported.
   130  #define ENOSYS 56
   131  // The socket is not connected.
   132  #define ENOTCONN 57
   133  // Not a directory or a symbolic link to a directory.
   134  #define ENOTDIR 58
   135  // Directory not empty.
   136  #define ENOTEMPTY 59
   137  // Env not recoverable.
   138  #define ENOTRECOVERABLE 60
   139  // Not a socket.
   140  #define ENOTSOCK 61
   141  // Not supported (may be the same value as EOPNOTSUPP).
   142  #define ENOTSUP 62
   143  // Inappropriate I/O control operation.
   144  #define ENOTTY 63
   145  // No such device or address.
   146  #define ENXIO 64
   147  // Operation not supported on socket (may be the same value as ENOTSUP).
   148  #define EOPNOTSUPP 65
   149  // Value too large to be stored in data type.
   150  #define EOVERFLOW 66
   151  // Previous owner died.
   152  #define EOWNERDEAD 67
   153  // Operation not permitted.
   154  #define EPERM 68
   155  // Broken pipe.
   156  #define EPIPE 69
   157  // Protocol error.
   158  #define EPROTO 79
   159  // Protocol not supported.
   160  #define EPROTONOSUPPORT 80
   161  // Protocol wrong type for socket.
   162  #define EPROTOTYPE 81
   163  // Result too large.
   164  #define ERANGE 82
   165  // Read-only file system.
   166  #define EROFS 83
   167  // Invalid seek.
   168  #define ESPIPE 84
   169  // No such process.
   170  #define ESRCH 85
   171  // Reserved.
   172  #define ESTALE 86
   173  // Stream ioctl() timeout.
   174  #define ETIME 87
   175  // Connection timed out.
   176  #define ETIMEDOUT 88
   177  // Text file busy.
   178  #define ETXTBSY 89
   179  // Operation would block (may be the same value as EAGAIN).
   180  #define EWOULDBLOCK 90
   181  // Cross-device link. 
   182  #define EXDEV 91
   183  `,
   184  			Imports: map[string]string{
   185  				"libc": RuntimeLibc,
   186  			},
   187  			Idents: map[string]*types.Ident{
   188  				"errno":    c.NewIdent("errno", "libc.Errno", libc.Errno, gint),
   189  				"strerror": c.NewIdent("strerror", "libc.StrError", libc.StrError, c.FuncTT(c.C().String(), gint)),
   190  			},
   191  		}
   192  	})
   193  }