[PATCH 1/1] libgloss: remove explicit "extern int errno; " from riscv/semihost*.c
H. Peter Anvin
hpa@zytor.com
Thu Dec 3 18:10:19 GMT 2026
When building with TLS, errno is a macro for _tls_errno, which is
broken when using an explicit "extern int errno;".
In the C files it is completely redundant anyway since <errno.h> is
included; add <errno.h> to semihost_syscall.h to make it independent.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
libgloss/riscv/semihost-sys_fdtable.c | 1 -
libgloss/riscv/semihost-sys_lseek.c | 2 --
libgloss/riscv/semihost-sys_open.c | 2 --
libgloss/riscv/semihost_syscall.h | 2 +-
4 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/libgloss/riscv/semihost-sys_fdtable.c b/libgloss/riscv/semihost-sys_fdtable.c
index d62e3f9708fe..1d9f37ba860c 100644
--- a/libgloss/riscv/semihost-sys_fdtable.c
+++ b/libgloss/riscv/semihost-sys_fdtable.c
@@ -11,7 +11,6 @@
#define RISCV_MAX_OPEN_FILES 16
#endif
-extern int errno;
extern int _open (const char *, int, ...);
/* fdtable keeps track of the position of each file and is used to map stdin,
diff --git a/libgloss/riscv/semihost-sys_lseek.c b/libgloss/riscv/semihost-sys_lseek.c
index 68fccf2fffdb..baa1721fed10 100644
--- a/libgloss/riscv/semihost-sys_lseek.c
+++ b/libgloss/riscv/semihost-sys_lseek.c
@@ -9,8 +9,6 @@
#include "semihost_syscall.h"
#include "semihost_fdtable.h"
-extern int errno;
-
/* Set position in a file. */
off_t
_lseek (int file, off_t offset, int dir)
diff --git a/libgloss/riscv/semihost-sys_open.c b/libgloss/riscv/semihost-sys_open.c
index 22f1d8206f4f..c717c236c909 100644
--- a/libgloss/riscv/semihost-sys_open.c
+++ b/libgloss/riscv/semihost-sys_open.c
@@ -9,8 +9,6 @@
#include <string.h>
#include <fcntl.h>
-extern int errno;
-
#define SEMIHOST_MODE_R 0
#define SEMIHOST_MODE_RPLUS 2
#define SEMIHOST_MODE_W 4
diff --git a/libgloss/riscv/semihost_syscall.h b/libgloss/riscv/semihost_syscall.h
index 50e731b40fcc..1a37ed4dcdb2 100644
--- a/libgloss/riscv/semihost_syscall.h
+++ b/libgloss/riscv/semihost_syscall.h
@@ -5,7 +5,7 @@
#ifndef _INTERNAL_SYSCALL_H
#define _INTERNAL_SYSCALL_H
-extern int errno;
+#include <errno.h>
static inline long
__semihost_syscall (long id, long *data_block)
--
2.56.1
More information about the Newlib
mailing list