path: root/src/multibyte
diff options
authorRich Felker <>2012-09-06 22:44:55 -0400
committerRich Felker <>2012-09-06 22:44:55 -0400
commit400c5e5c8307a2ebe44ef1f203f5a15669f20347 (patch)
tree087a48dc8251fa05f6866af8ebf96b69450b15ab /src/multibyte
parentbac03cdde1137c16b4c194e137310e2748661dcc (diff)
use restrict everywhere it's required by c99 and/or posix 2008
to deal with the fact that the public headers may be used with pre-c99 compilers, __restrict is used in place of restrict, and defined appropriately for any supported compiler. we also avoid the form [restrict] since older versions of gcc rejected it due to a bug in the original c99 standard, and instead use the form *restrict.
Diffstat (limited to 'src/multibyte')
10 files changed, 12 insertions, 11 deletions
diff --git a/src/multibyte/mbrlen.c b/src/multibyte/mbrlen.c
index c9a9f033..c9714ef8 100644
--- a/src/multibyte/mbrlen.c
+++ b/src/multibyte/mbrlen.c
@@ -11,7 +11,7 @@
#include "internal.h"
-size_t mbrlen(const char *s, size_t n, mbstate_t *st)
+size_t mbrlen(const char *restrict s, size_t n, mbstate_t *restrict st)
static unsigned internal;
return mbrtowc(0, s, n, st ? st : (mbstate_t *)&internal);
diff --git a/src/multibyte/mbrtowc.c b/src/multibyte/mbrtowc.c
index 291537f8..cc497810 100644
--- a/src/multibyte/mbrtowc.c
+++ b/src/multibyte/mbrtowc.c
@@ -11,7 +11,7 @@
#include "internal.h"
-size_t mbrtowc(wchar_t *wc, const char *src, size_t n, mbstate_t *st)
+size_t mbrtowc(wchar_t *restrict wc, const char *restrict src, size_t n, mbstate_t *restrict st)
static unsigned internal_state;
unsigned c;
diff --git a/src/multibyte/mbsnrtowcs.c b/src/multibyte/mbsnrtowcs.c
index f42e30d9..33457f95 100644
--- a/src/multibyte/mbsnrtowcs.c
+++ b/src/multibyte/mbsnrtowcs.c
@@ -12,7 +12,7 @@
#include "internal.h"
-size_t mbsnrtowcs(wchar_t *wcs, const char **src, size_t n, size_t wn, mbstate_t *st)
+size_t mbsnrtowcs(wchar_t *restrict wcs, const char **restrict src, size_t n, size_t wn, mbstate_t *restrict st)
size_t l, cnt=0, n2;
wchar_t *ws, wbuf[256];
diff --git a/src/multibyte/mbsrtowcs.c b/src/multibyte/mbsrtowcs.c
index ebf0d6c9..8313d37b 100644
--- a/src/multibyte/mbsrtowcs.c
+++ b/src/multibyte/mbsrtowcs.c
@@ -11,7 +11,7 @@
#include "internal.h"
-size_t mbsrtowcs(wchar_t *ws, const char **src, size_t wn, mbstate_t *st)
+size_t mbsrtowcs(wchar_t *restrict ws, const char **restrict src, size_t wn, mbstate_t *restrict st)
unsigned c;
const unsigned char *s = (const void *)*src;
diff --git a/src/multibyte/mbstowcs.c b/src/multibyte/mbstowcs.c
index 23e1d925..5071baf7 100644
--- a/src/multibyte/mbstowcs.c
+++ b/src/multibyte/mbstowcs.c
@@ -11,7 +11,7 @@
#include "internal.h"
-size_t mbstowcs(wchar_t *ws, const char *s, size_t wn)
+size_t mbstowcs(wchar_t *restrict ws, const char *restrict s, size_t wn)
mbstate_t st = { 0 };
return mbsrtowcs(ws, (void*)&s, wn, &st);
diff --git a/src/multibyte/mbtowc.c b/src/multibyte/mbtowc.c
index bdcaeb3c..b5dd7e3c 100644
--- a/src/multibyte/mbtowc.c
+++ b/src/multibyte/mbtowc.c
@@ -11,7 +11,7 @@
#include "internal.h"
-int mbtowc(wchar_t *wc, const char *s, size_t n)
+int mbtowc(wchar_t *restrict wc, const char *restrict s, size_t n)
mbstate_t st = { 0 };
n = mbrtowc(wc, s, n, &st);
diff --git a/src/multibyte/wcrtomb.c b/src/multibyte/wcrtomb.c
index 36180c8f..250649f5 100644
--- a/src/multibyte/wcrtomb.c
+++ b/src/multibyte/wcrtomb.c
@@ -11,7 +11,7 @@
#include "internal.h"
-size_t wcrtomb(char *s, wchar_t wc, mbstate_t *st)
+size_t wcrtomb(char *restrict s, wchar_t wc, mbstate_t *restrict st)
if (!s) return 1;
if ((unsigned)wc < 0x80) {
diff --git a/src/multibyte/wcsnrtombs.c b/src/multibyte/wcsnrtombs.c
index 70b0cacb..a2e308b3 100644
--- a/src/multibyte/wcsnrtombs.c
+++ b/src/multibyte/wcsnrtombs.c
@@ -11,7 +11,7 @@
#include "internal.h"
-size_t wcsnrtombs(char *dst, const wchar_t **wcs, size_t wn, size_t n, mbstate_t *st)
+size_t wcsnrtombs(char *restrict dst, const wchar_t **restrict wcs, size_t wn, size_t n, mbstate_t *restrict st)
size_t l, cnt=0, n2;
char *s, buf[256];
diff --git a/src/multibyte/wcsrtombs.c b/src/multibyte/wcsrtombs.c
index 3c48d65b..2582ac2f 100644
--- a/src/multibyte/wcsrtombs.c
+++ b/src/multibyte/wcsrtombs.c
@@ -11,7 +11,7 @@
#include "internal.h"
-size_t wcsrtombs(char *s, const wchar_t **ws, size_t n, mbstate_t *st)
+size_t wcsrtombs(char *restrict s, const wchar_t **restrict ws, size_t n, mbstate_t *restrict st)
const wchar_t *ws2;
char buf[4];
diff --git a/src/multibyte/wcstombs.c b/src/multibyte/wcstombs.c
index b9c1b18a..b6ae4732 100644
--- a/src/multibyte/wcstombs.c
+++ b/src/multibyte/wcstombs.c
@@ -11,7 +11,8 @@
#include "internal.h"
-size_t wcstombs(char *s, const wchar_t *ws, size_t n)
+size_t wcstombs(char *restrict s, const wchar_t *restrict ws, size_t n)
- return wcsrtombs(s, &ws, n, 0);
+ const wchar_t * x = ws;
+ return wcsrtombs(s, &x, n, 0);