summaryrefslogtreecommitdiffstats
path: root/libc/config/linux
diff options
context:
space:
mode:
authorSiva Chandra Reddy <sivachandra@google.com>2019-12-05 12:09:24 -0800
committerSiva Chandra Reddy <sivachandra@google.com>2019-12-09 13:34:08 -0800
commit453c85ff0f96048ea31037fed905ef6a06ac3fcc (patch)
treeb68302cd170298c457658a451005540a4c82cc4d /libc/config/linux
parentaf52d5a04cb3c488af06c50806d15f1ee9252cc7 (diff)
downloadbcm5719-llvm-453c85ff0f96048ea31037fed905ef6a06ac3fcc.tar.gz
bcm5719-llvm-453c85ff0f96048ea31037fed905ef6a06ac3fcc.zip
[libc] Add implementation of errno and define the other macros of errno.h.
Reviewers: stanshebs, alexbrachet Subscribers: mgorny, MaskRay, tschuett, libc-commits Tags: #libc-project Differential Revision: https://reviews.llvm.org/D71094
Diffstat (limited to 'libc/config/linux')
-rw-r--r--libc/config/linux/api.td28
-rw-r--r--libc/config/linux/errno.h.in11
2 files changed, 39 insertions, 0 deletions
diff --git a/libc/config/linux/api.td b/libc/config/linux/api.td
index e0d4df8324a..7568620b700 100644
--- a/libc/config/linux/api.td
+++ b/libc/config/linux/api.td
@@ -1,5 +1,7 @@
include "config/public_api.td"
+include "spec/linux.td"
+include "spec/posix.td"
include "spec/stdc.td"
def FloatT : TypeDecl<"float_t"> {
@@ -28,6 +30,13 @@ def NullMacro : MacroDef<"NULL"> {
}];
}
+def ErrnoMacro : MacroDef<"errno"> {
+ let Defn = [{
+ int *__errno_location();
+ #define errno (*__errno_location())
+ }];
+}
+
def MathAPI : PublicAPI<"math.h"> {
let Functions = [
"acos",
@@ -83,3 +92,22 @@ def StdIOAPI : PublicAPI<"stdio.h"> {
"snprintf",
];
}
+
+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">,
+ ];
+}
diff --git a/libc/config/linux/errno.h.in b/libc/config/linux/errno.h.in
new file mode 100644
index 00000000000..793f0f6affd
--- /dev/null
+++ b/libc/config/linux/errno.h.in
@@ -0,0 +1,11 @@
+//===---------------- 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>
OpenPOWER on IntegriCloud