summaryrefslogtreecommitdiff
path: root/packages/picolibc/1.4.6/0000-libc-Create-a-macro-for-errno-so-that-GCC-tsystem.h-.patch
blob: da26864053a7a26f969957f5dbee0b38a3034bfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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