}];
}
-def ErrnoMacro : MacroDef<"errno"> {
- let Defn = [{
- extern _Thread_local int __llvmlibc_errno;
- #define errno __llvmlibc_errno
- }];
-}
-
def AssertAPI : PublicAPI<"assert.h"> {
let Macros = [
AssertMacro,
];
}
-def ErrnoAPI : PublicAPI<"errno.h"> {
- let Macros = [
- ErrnoMacro,
- // We largely depend on linux/errno.h to give us the
- // various error macro definitions. However, some libc
- // implementations have chosen to provide definitions
- // for some of the error macros to account for the ones
- // missing in linux/errno.h. There is no harm in doing
- // the same here if we define the macros only when they
- // are not already defined.
- MacroDefineIfNot<"ENOTSUP", "EOPNOTSUPP">,
- MacroDefineIfNot<"ECANCELED", "125">,
- MacroDefineIfNot<"EOWNERDEAD", "130">,
- MacroDefineIfNot<"ENOTRECOVERABLE", "131">,
- MacroDefineIfNot<"ERFKILL", "132">,
- MacroDefineIfNot<"EHWPOISON", "133">,
- ];
-}
-
def SchedAPI : PublicAPI<"sched.h"> {
let Types = ["pid_t", "size_t", "cpu_set_t"];
}
+++ /dev/null
-//===-- Linux specific errno.h definitions --------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-%%begin()
-
-#include <linux/errno.h>
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(
#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
add_subdirectory(linux)
add_header(
+ generic_error_number_macros
+ HDR
+ generic-error-number-macros.h
+)
+
+add_header(
fcntl_macros
HDR
fcntl-macros.h
--- /dev/null
+//===-- 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