summaryrefslogtreecommitdiff
path: root/libgo/go/runtime/internal/syscall/errno.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/runtime/internal/syscall/errno.c')
-rw-r--r--libgo/go/runtime/internal/syscall/errno.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libgo/go/runtime/internal/syscall/errno.c b/libgo/go/runtime/internal/syscall/errno.c
new file mode 100644
index 00000000000..2bc59007b31
--- /dev/null
+++ b/libgo/go/runtime/internal/syscall/errno.c
@@ -0,0 +1,27 @@
+/* errno.c -- functions for getting and setting errno
+
+ Copyright 2022 The Go Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style
+ license that can be found in the LICENSE file. */
+#include <errno.h>
+#include <stdint.h>
+
+#include "runtime.h"
+
+/* errno is typically a macro. These functions set and get errno
+ specific to the libc being used. */
+
+uintptr_t getErrno(void) __asm__ (GOSYM_PREFIX "runtime_1internal_1syscall.getErrno");
+void setErrno(uintptr_t) __asm__ (GOSYM_PREFIX "runtime_1internal_1syscall.setErrno");
+
+uintptr_t
+getErrno(void)
+{
+ return (uintptr_t) errno;
+}
+
+void
+setErrno(uintptr_t value)
+{
+ errno = (int) value;
+}