crosstool-ng/packages/picolibc/1.4.6/0000-libc-Create-a-macro-for-errno-so-that-GCC-tsystem.h-.patch
Keith Packard c15de32ec6 Add picolibc support [v2]
This adds support for using picolibc instead of newlib on embedded
systems.

Signed-off-by: Keith Packard <keithp@keithp.com>

v2:
	Add check for meson and ninja
	Sync option default values with current picolibc defaults
	Remove xtensa sys header file install as those aren't in picolibc
2020-09-01 09:42:53 -07:00

34 lines
1.1 KiB
Diff

From 1ce74e28ba8d6f91aca5830bfbc15897b68fcfac Mon Sep 17 00:00:00 2001
From: Keith Packard <keithp@keithp.com>
Date: Sun, 16 Aug 2020 12:44:31 -0700
Subject: [PATCH] libc: Create a macro for 'errno' so that GCC tsystem.h works
GCC's tsystem.h adds a declaration for errno if it isn't a CPP symbol,
which it isn't in picolibc as it's just a regular global (thread
local) variable. Create a function macro with no arguments so that
Signed-off-by: Keith Packard <keithp@keithp.com>
---
newlib/libc/include/sys/errno.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/newlib/libc/include/sys/errno.h b/newlib/libc/include/sys/errno.h
index 0da73f44e..64f179bc0 100644
--- a/newlib/libc/include/sys/errno.h
+++ b/newlib/libc/include/sys/errno.h
@@ -59,6 +59,11 @@ extern NEWLIB_THREAD_LOCAL_ERRNO int errno;
#define __errno_r(ptr) (errno)
#define __errno() (&errno)
+/*
+ * This lets applications check for #ifdef errno without requiring
+ * that errno be a parameter-less macro
+ */
+#define errno() (errno)
#define EPERM 1 /* Not owner */
#define ENOENT 2 /* No such file or directory */
--
2.28.0