aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>2014-09-27 13:52:35 +0100
committerChristopher Li <sparse@chrisli.org>2014-10-10 22:43:37 +0800
commitb6c1d2fe571a8c0b023d17f0557774c8af93fe85 (patch)
tree7c0b3bf65227b0108f471ddbefc96788abfc9dc6 /validation
parentc1763a249aba0a40bd326c845c2a146132a02448 (diff)
downloadsparse-dev-b6c1d2fe571a8c0b023d17f0557774c8af93fe85.tar.gz
Add the __restrict__ keyword
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'validation')
-rw-r--r--validation/alternate-keywords.c46
-rw-r--r--validation/reserved.c1
-rw-r--r--validation/restrict-array.c25
3 files changed, 72 insertions, 0 deletions
diff --git a/validation/alternate-keywords.c b/validation/alternate-keywords.c
new file mode 100644
index 00000000..2e91a354
--- /dev/null
+++ b/validation/alternate-keywords.c
@@ -0,0 +1,46 @@
+
+extern float strtof(const char *__restrict__ ptr, char **__restrict__ endptr);
+extern double strtod(const char *__restrict ptr, char **__restrict endptr);
+/* restrict: -std=c99 or -std=gnu99 or -std=c11 */
+extern long double strtold(const char *restrict ptr, char **restrict endptr);
+
+extern int (*funcs[])(void);
+
+/* typeof: no -std or -std=gnu90 or -std=gnu99 or -std=gnu11 */
+extern typeof (funcs[0]) f0;
+extern __typeof (funcs[1]) f1;
+extern __typeof__(funcs[2]) f2;
+
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+
+static __inline__ uint16_t swap16(uint16_t val)
+{
+ return ((((uint16_t)(val) & (uint16_t)0x00ffU) << 8) |
+ (((uint16_t)(val) & (uint16_t)0xff00U) >> 8));
+}
+
+static __inline uint32_t swap32(uint32_t val)
+{
+ return ((((uint32_t)(val) & (uint32_t)0x000000ffUL) << 24) |
+ (((uint32_t)(val) & (uint32_t)0x0000ff00UL) << 8) |
+ (((uint32_t)(val) & (uint32_t)0x00ff0000UL) >> 8) |
+ (((uint32_t)(val) & (uint32_t)0xff000000UL) >> 24));
+}
+
+/* inline: no -std or -std=gnu90 or -std=c99 or -std=c11 */
+static inline uint64_t swap64(uint64_t val)
+{
+ return ((((uint64_t)(val) & (uint64_t)0x00000000000000ffULL) << 56) |
+ (((uint64_t)(val) & (uint64_t)0x000000000000ff00ULL) << 40) |
+ (((uint64_t)(val) & (uint64_t)0x0000000000ff0000ULL) << 24) |
+ (((uint64_t)(val) & (uint64_t)0x00000000ff000000ULL) << 8) |
+ (((uint64_t)(val) & (uint64_t)0x000000ff00000000ULL) >> 8) |
+ (((uint64_t)(val) & (uint64_t)0x0000ff0000000000ULL) >> 24) |
+ (((uint64_t)(val) & (uint64_t)0x00ff000000000000ULL) >> 40) |
+ (((uint64_t)(val) & (uint64_t)0xff00000000000000ULL) >> 56));
+}
+/*
+ * check-name: alternate keywords
+ */
diff --git a/validation/reserved.c b/validation/reserved.c
index caacd21f..e5d7af86 100644
--- a/validation/reserved.c
+++ b/validation/reserved.c
@@ -30,6 +30,7 @@ reserved.c:8:12: error: Trying to use reserved word '__const' as identifier
reserved.c:9:12: error: Trying to use reserved word '__const__' as identifier
reserved.c:10:12: error: Trying to use reserved word 'restrict' as identifier
reserved.c:11:12: error: Trying to use reserved word '__restrict' as identifier
+reserved.c:12:12: error: Trying to use reserved word '__restrict__' as identifier
reserved.c:13:12: error: Trying to use reserved word 'typedef' as identifier
reserved.c:14:12: error: Trying to use reserved word '__typeof' as identifier
reserved.c:15:12: error: Trying to use reserved word '__typeof__' as identifier
diff --git a/validation/restrict-array.c b/validation/restrict-array.c
index 3facebf4..04bfdad9 100644
--- a/validation/restrict-array.c
+++ b/validation/restrict-array.c
@@ -7,6 +7,31 @@ extern int lio_listio64 (int __mode,
struct aiocb64 *__const __list[__restrict_arr],
int __nent, struct sigevent *__restrict __sig);
+#undef __restrict_arr
+#define __restrict_arr __restrict__
+
+struct gaicb;
+
+extern int getaddrinfo_a (int __mode, struct gaicb *__list[__restrict_arr],
+ int __ent, struct sigevent *__restrict __sig);
+
+#undef __restrict_arr
+#define __restrict_arr restrict
+
+typedef struct re_pattern_buffer regex_t;
+typedef int regoff_t;
+typedef struct
+{
+ regoff_t rm_so; /* Byte offset from string's start to substring's start. */
+ regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
+} regmatch_t;
+typedef unsigned long int size_t;
+
+extern int regexec (const regex_t *__restrict __preg,
+ const char *__restrict __string, size_t __nmatch,
+ regmatch_t __pmatch[__restrict_arr],
+ int __eflags);
+
/*
* check-name: restrict array attribute
*/