blob: 5aabc62c05f2fe0c47cb12c000f2bb839bc9d581 [file]
// Copyright 2026 The IREE Authors
//
// Licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// <errno.h> for wasm32.
#ifndef IREE_WASM_LIBC_ERRNO_H_
#define IREE_WASM_LIBC_ERRNO_H_
// errno is a plain global — wasm threads share memory but each thread
// could get its own errno via TLS once wasm TLS is available.
extern int errno;
// Error numbers. Values follow the Linux/musl convention for consistency
// with wasm-ld's expectations and to avoid surprises when cross-referencing
// error codes between wasm and host.
// POSIX base.
#define EPERM 1
#define ENOENT 2
#define ESRCH 3
#define EINTR 4
#define EIO 5
#define ENXIO 6
#define E2BIG 7
#define ENOEXEC 8
#define EBADF 9
#define ECHILD 10
#define EAGAIN 11
#define ENOMEM 12
#define EACCES 13
#define EFAULT 14
#define ENOTBLK 15
#define EBUSY 16
#define EEXIST 17
#define EXDEV 18
#define ENODEV 19
#define ENOTDIR 20
#define EISDIR 21
#define EINVAL 22
#define ENFILE 23
#define EMFILE 24
#define ENOTTY 25
#define ETXTBSY 26
#define EFBIG 27
#define ENOSPC 28
#define ESPIPE 29
#define EROFS 30
#define EMLINK 31
#define EPIPE 32
#define EDOM 33
#define ERANGE 34
#define EDEADLK 35
#define ENAMETOOLONG 36
#define ENOLCK 37
#define ENOSYS 38
#define ENOTEMPTY 39
#define ELOOP 40
#define ENOMSG 42
#define EIDRM 43
#define ECHRNG 44
#define ENOSTR 60
#define ENODATA 61
#define ETIME 62
#define ENOSR 63
#define ENONET 64
#define ENOPKG 65
#define ENOLINK 67
#define ECOMM 70
#define EOVERFLOW 75
#define ENOTUNIQ 76
#define EBADFD 77
#define EILSEQ 84
#define ENOMEDIUM 123
#define EISNAM 120
#define ENOKEY 126
#define EUNATCH 49
#define EUSERS 87
// Networking (POSIX).
#define ENOTSOCK 88
#define EDESTADDRREQ 89
#define EMSGSIZE 90
#define EPROTOTYPE 91
#define ENOPROTOOPT 92
#define EPROTONOSUPPORT 93
#define ESOCKTNOSUPPORT 94
#define ENOTSUP 95
#define EPFNOSUPPORT 96
#define EAFNOSUPPORT 97
#define EADDRINUSE 98
#define EADDRNOTAVAIL 99
#define ENETDOWN 100
#define ENETUNREACH 101
#define ENETRESET 102
#define ECONNABORTED 103
#define ECONNRESET 104
#define ENOBUFS 105
#define EISCONN 106
#define ENOTCONN 107
#define ESHUTDOWN 108
#define ETIMEDOUT 110
#define ECONNREFUSED 111
#define EHOSTDOWN 112
#define EHOSTUNREACH 113
#define EALREADY 114
#define EINPROGRESS 115
#define ESTALE 116
#define EDQUOT 122
#define ECANCELED 125
// Aliases.
#define EWOULDBLOCK EAGAIN
#define EOPNOTSUPP ENOTSUP
#define EDEADLOCK EDEADLK
#endif // IREE_WASM_LIBC_ERRNO_H_