summaryrefslogtreecommitdiff
path: root/libc/include
diff options
context:
space:
mode:
authorSiva Chandra Reddy <sivachandra@google.com>2022-12-20 08:45:50 +0000
committerSiva Chandra Reddy <sivachandra@google.com>2022-12-20 19:04:13 +0000
commit5e750b86caf152c9f7a97ec5693c666806754cb6 (patch)
tree88389477782a3c1c2ccee8f07c71e7a55bdd0961 /libc/include
parent35887eab19740c038b5c95ac0815a86bda83057e (diff)
downloadllvm-5e750b86caf152c9f7a97ec5693c666806754cb6.tar.gz
[libc] Simplify generation of errno.h.
Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D140375
Diffstat (limited to 'libc/include')
-rw-r--r--libc/include/CMakeLists.txt6
-rw-r--r--libc/include/errno.h.def35
-rw-r--r--libc/include/llvm-libc-macros/CMakeLists.txt6
-rw-r--r--libc/include/llvm-libc-macros/generic-error-number-macros.h47
4 files changed, 88 insertions, 6 deletions
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 40adef0d051e..91ef75739178 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -128,11 +128,9 @@ add_gen_header(
add_gen_header(
errno
DEF_FILE errno.h.def
- PARAMS
- platform_errno=../config/${LIBC_TARGET_OS}/errno.h.in
GEN_HDR errno.h
- DATA_FILES
- ../config/${LIBC_TARGET_OS}/errno.h.in
+ DEPENDS
+ .llvm-libc-macros.generic_error_number_macros
)
add_gen_header(
diff --git a/libc/include/errno.h.def b/libc/include/errno.h.def
index da60aed19dbd..580a53f6a771 100644
--- a/libc/include/errno.h.def
+++ b/libc/include/errno.h.def
@@ -11,8 +11,39 @@
#include <__llvm-libc-common.h>
-%%include_file(${platform_errno})
+#ifdef __linux__
-%%public_api()
+#include <linux/errno.h>
+
+#ifndef ERFKILL
+#define ERFKILL 132
+#endif // ERFKILL
+
+#ifndef EOWNERDEAD
+#define EOWNERDEAD 130
+#endif // EOWNERDEAD
+
+#ifndef EHWPOISON
+#define EHWPOISON 133
+#endif // EHWPOISON
+
+#ifndef ECANCELED
+#define ECANCELED 125
+#endif // ECANCELED
+
+#ifndef ENOTSUP
+#define ENOTSUP EOPNOTSUPP
+#endif // ENOTSUP
+
+#ifndef ENOTRECOVERABLE
+#define ENOTRECOVERABLE 131
+#endif // ENOTRECOVERABLE
+
+#else // __linux__
+#include <llvm-libc-macros/generic-error-number-macros.h>
+#endif
+
+extern _Thread_local int __llvmlibc_errno;
+#define errno __llvmlibc_errno
#endif // LLVM_LIBC_ERRNO_H
diff --git a/libc/include/llvm-libc-macros/CMakeLists.txt b/libc/include/llvm-libc-macros/CMakeLists.txt
index fe2652a01d8d..1cab22a8930e 100644
--- a/libc/include/llvm-libc-macros/CMakeLists.txt
+++ b/libc/include/llvm-libc-macros/CMakeLists.txt
@@ -1,6 +1,12 @@
add_subdirectory(linux)
add_header(
+ generic_error_number_macros
+ HDR
+ generic-error-number-macros.h
+)
+
+add_header(
fcntl_macros
HDR
fcntl-macros.h
diff --git a/libc/include/llvm-libc-macros/generic-error-number-macros.h b/libc/include/llvm-libc-macros/generic-error-number-macros.h
new file mode 100644
index 000000000000..e652c6044d03
--- /dev/null
+++ b/libc/include/llvm-libc-macros/generic-error-number-macros.h
@@ -0,0 +1,47 @@
+//===-- Definition of generic error number macros -------------------------===//
+//
+// Part of the LLVM Project, 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __LLVM_LIBC_MACROS_GENERIC_ERROR_NUMBER_MACROS_H
+#define __LLVM_LIBC_MACROS_GENERIC_ERROR_NUMBER_MACROS_H
+
+#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
+
+#endif // __LLVM_LIBC_MACROS_GENERIC_ERROR_NUMBER_MACROS_H