public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] sys/cdefs.h: introduce __restrict_arr, as in glibc
@ 2023-08-07 14:09 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2023-08-07 14:09 UTC (permalink / raw)
To: newlib-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e66c63be6b800ae19ff21fe2f5c12e231986acb6
commit e66c63be6b800ae19ff21fe2f5c12e231986acb6
Author: Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Mon Aug 7 15:59:42 2023 +0200
Commit: Corinna Vinschen <corinna@vinschen.de>
CommitDate: Mon Aug 7 15:59:42 2023 +0200
sys/cdefs.h: introduce __restrict_arr, as in glibc
C99 allows to define arrays as non-overlappiung using the restrict
keyword. This is supported by GCC 3.1 and later, but it's not
allowed in C++.
This is in preparation of fixing a Cygwin build problem introduce by
commit 3c75fac130b5.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
newlib/libc/include/sys/cdefs.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h
index cc1a8a1ccbf5..d13a92a79ee1 100644
--- a/newlib/libc/include/sys/cdefs.h
+++ b/newlib/libc/include/sys/cdefs.h
@@ -423,6 +423,19 @@
#define __restrict
#endif
+/*
+ * Additionally, we allow to use `__restrict_arr' for declaring arrays as
+ * non-overlapping per C99. That's supported since gcc 3.1, but it's not
+ * allowed in C++.
+ */
+#if defined(__cplusplus) || !__GNUC_PREREQ__(3, 1)
+#define __restrict_arr
+#elif defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+#define __restrict_arr restrict
+#else
+#define __restrict_arr
+#endif
+
/*
* GNU C version 2.96 adds explicit branch prediction so that
* the CPU back-end can hint the processor and also so that
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-08-07 14:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07 14:09 [newlib-cygwin/main] sys/cdefs.h: introduce __restrict_arr, as in glibc Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).