Patch - Add restrict to regex.h
Joel Sherrill
joel.sherrill@oarcorp.com
Wed Nov 20 15:57:00 GMT 2013
Hi
Another patch in the restrict series from Google Code-In
students.
I am building sparc-rtems and "make info".
How does this look?2013-11-20 Chirayu Desai <chirayudesai1@gmail.com>
* libc/include/regex.h, libc/posix/regcomp.c,
libc/posix/regerror.c, libc/posix/regex.3
libc/posix/regexec.c: Add restrict keyword.
--
Joel Sherrill, Ph.D. Director of Research & Development
joel.sherrill@OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
-------------- next part --------------
? libc/libc.info
? libm/libm.info
Index: libc/include/regex.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/regex.h,v
retrieving revision 1.1
diff -u -r1.1 regex.h
--- libc/include/regex.h 31 Oct 2008 21:03:41 -0000 1.1
+++ libc/include/regex.h 20 Nov 2013 15:45:40 -0000
@@ -93,9 +93,10 @@
#define REG_BACKR 02000 /* force use of backref code */
__BEGIN_DECLS
-int regcomp(regex_t *, const char *, int);
-size_t regerror(int, const regex_t *, char *, size_t);
-int regexec(const regex_t *, const char *, size_t, regmatch_t [], int);
+int regcomp(regex_t *__restrict, const char *__restrict, int);
+size_t regerror(int, const regex_t *__restrict, char *__restrict, size_t);
+int regexec(const regex_t *__restrict, const char *__restrict,
+ size_t, regmatch_t [__restrict], int);
void regfree(regex_t *);
__END_DECLS
Index: libc/posix/regcomp.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/posix/regcomp.c,v
retrieving revision 1.2
diff -u -r1.2 regcomp.c
--- libc/posix/regcomp.c 8 Aug 2012 11:04:17 -0000 1.2
+++ libc/posix/regcomp.c 20 Nov 2013 15:45:43 -0000
@@ -174,7 +174,7 @@
/*
- regcomp - interface for parser and compilation
- = extern int regcomp(regex_t *, const char *, int);
+ = extern int regcomp(regex_t *__restrict, const char *__restrict, int);
= #define REG_BASIC 0000
= #define REG_EXTENDED 0001
= #define REG_ICASE 0002
@@ -186,8 +186,8 @@
*/
int /* 0 success, otherwise REG_something */
regcomp(preg, pattern, cflags)
-regex_t *preg;
-const char *pattern;
+regex_t *__restrict preg;
+const char *__restrict pattern;
int cflags;
{
struct parse pa;
Index: libc/posix/regerror.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/posix/regerror.c,v
retrieving revision 1.1
diff -u -r1.1 regerror.c
--- libc/posix/regerror.c 31 Oct 2008 21:03:41 -0000 1.1
+++ libc/posix/regerror.c 20 Nov 2013 15:45:43 -0000
@@ -107,14 +107,15 @@
/*
- regerror - the interface to error numbers
- = extern size_t regerror(int, const regex_t *, char *, size_t);
+ = extern size_t regerror(int, const regex_t *__restrict,
+ = char *__restrict, size_t);
*/
/* ARGSUSED */
size_t
regerror(errcode, preg, errbuf, errbuf_size)
int errcode;
-const regex_t *preg;
-char *errbuf;
+const regex_t *__restrict preg;
+char *__restrict errbuf;
size_t errbuf_size;
{
struct rerr *r;
Index: libc/posix/regex.3
===================================================================
RCS file: /cvs/src/src/newlib/libc/posix/regex.3,v
retrieving revision 1.1
diff -u -r1.1 regex.3
--- libc/posix/regex.3 31 Oct 2008 21:03:41 -0000 1.1
+++ libc/posix/regex.3 20 Nov 2013 15:45:44 -0000
@@ -51,16 +51,16 @@
.In sys/types.h
.In regex.h
.Ft int
-.Fn regcomp "regex_t *preg" "const char *pattern" "int cflags"
+.Fn regcomp "regex_t *__restrict preg" "const char *__restrictpattern" "int cflags"
.Ft int
.Fo regexec
-.Fa "const regex_t *preg" "const char *string"
-.Fa "size_t nmatch" "regmatch_t pmatch[]" "int eflags"
+.Fa "const regex_t *__restrict preg" "const char *__restrict string"
+.Fa "size_t nmatch" "regmatch_t pmatch[__restrict]" "int eflags"
.Fc
.Ft size_t
.Fo regerror
-.Fa "int errcode" "const regex_t *preg"
-.Fa "char *errbuf" "size_t errbuf_size"
+.Fa "int errcode" "const regex_t *__restrict preg"
+.Fa "char *__restrict errbuf" "size_t errbuf_size"
.Fc
.Ft void
.Fn regfree "regex_t *preg"
Index: libc/posix/regexec.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/posix/regexec.c,v
retrieving revision 1.2
diff -u -r1.2 regexec.c
--- libc/posix/regexec.c 23 Aug 2011 11:59:56 -0000 1.2
+++ libc/posix/regexec.c 20 Nov 2013 15:45:44 -0000
@@ -140,8 +140,8 @@
/*
- regexec - interface for matching
- = extern int regexec(const regex_t *, const char *, size_t, \
- = regmatch_t [], int);
+ = extern int regexec(const regex_t *__restrict, const char *__restrict,
+ = size_t, regmatch_t [__restrict], int);
= #define REG_NOTBOL 00001
= #define REG_NOTEOL 00002
= #define REG_STARTEND 00004
@@ -155,10 +155,10 @@
*/
int /* 0 success, REG_NOMATCH failure */
regexec(preg, string, nmatch, pmatch, eflags)
-const regex_t *preg;
-const char *string;
+const regex_t *__restrict preg;
+const char *__restrict string;
size_t nmatch;
-regmatch_t pmatch[];
+regmatch_t pmatch[__restrict];
int eflags;
{
struct re_guts *g = preg->re_g;
More information about the Newlib
mailing list