aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-09-01 21:07:54 +0200
committerMattias Andrée <maandree@operamail.com>2015-09-01 21:07:54 +0200
commitac044784a6ce64ff15610d4b70750065a7f01b80 (patch)
tree8ac8629c0089099f21be9107a5d3779963d33ca0 /include
parentadd memfrob (diff)
downloadslibc-ac044784a6ce64ff15610d4b70750065a7f01b80.tar.gz
slibc-ac044784a6ce64ff15610d4b70750065a7f01b80.tar.bz2
slibc-ac044784a6ce64ff15610d4b70750065a7f01b80.tar.xz
start on makefile and fixing warnings and errors
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'include')
-rw-r--r--include/assert.h19
-rw-r--r--include/bits/types.h2
-rw-r--r--include/ctype.h60
-rw-r--r--include/err.h2
-rw-r--r--include/error.h4
-rw-r--r--include/stddef.h2
-rw-r--r--include/stdlib.h2
-rw-r--r--include/string.h60
-rw-r--r--include/strings.h10
-rw-r--r--include/wchar.h67
10 files changed, 132 insertions, 96 deletions
diff --git a/include/assert.h b/include/assert.h
index 6315ae1..838a9bf 100644
--- a/include/assert.h
+++ b/include/assert.h
@@ -56,7 +56,7 @@
#define static_assert _Static_assert
-#ifndef __PORTABLE
+#if (defined(_SLIBC_SOURCE) || defined(_GNU_SOURCE)) && !defined(__PORTABLE)
/**
* Unless `NDEBUG` is defined, print an error message
* and abort the process, if `errnum` is non-zero.
@@ -65,15 +65,15 @@
*
* `assert_perror` is a GNU extension.
*/
-#if defined(_SLIBC_SOURCE) || defined(_GNU_SOURCE)
-#ifdef assert_perror
-# undef assert_perror
-#endif
-#ifdef NDEBUG
-# define assert_perror(errnum) ((void)0)
-#else
-# define assert_perror(errnum) \
+# ifdef assert_perror
+# undef assert_perror
+# endif
+# ifdef NDEBUG
+# define assert_perror(errnum) ((void)0)
+# else
+# define assert_perror(errnum) \
((void)((errnum == 0) ? 0 : (__assert_fail(NULL, errnum, __FILE__, __LINE__, __func__), 0)))
+# endif
#endif
@@ -89,7 +89,6 @@
*/
void __assert_fail(const char*, int, const char*, int, const char*)
__noreturn __GCC_ONLY(__attribute__((nonnull(3, 4, 5))));
-#endif
diff --git a/include/bits/types.h b/include/bits/types.h
index e594e44..7a2244e 100644
--- a/include/bits/types.h
+++ b/include/bits/types.h
@@ -32,7 +32,7 @@
#ifndef __MAX_OF
# define __MAX_OF(type) \
(((type)1) << sizeof(type))
-#define
+#endif
/**
diff --git a/include/ctype.h b/include/ctype.h
index f01ad57..f98705d 100644
--- a/include/ctype.h
+++ b/include/ctype.h
@@ -35,7 +35,8 @@
* @return Whether the character is in
* ['0', '9'], ['A', 'Z'], or ['a', 'z'].
*/
-int (isalnum)(int); /* [0x30, 0x39], [0x41, 0x5A], [0x61, 0x7A] */
+int (isalnum)(int) /* [0x30, 0x39], [0x41, 0x5A], [0x61, 0x7A] */
+ __GCC_ONLY(__attribute__((const)));
#if defined (__GNUC__)
# define isalnum(c) \
({ int __c = (c); (isalpha(__c) || isdigit(__c)); })
@@ -49,7 +50,8 @@ int (isalnum)(int); /* [0x30, 0x39], [0x41, 0x5A], [0x61, 0x7A] */
* @return Whether the character is in
* ['A', 'Z'] or ['a', 'z'].
*/
-int (isalpha)(int); /* [0x41, 0x5A], [0x61, 0x7A] */
+int (isalpha)(int) /* [0x41, 0x5A], [0x61, 0x7A] */
+ __GCC_ONLY(__attribute__((const)));
#define isalpha(c) (islower(tolower(a)))
@@ -63,7 +65,8 @@ int (isalpha)(int); /* [0x41, 0x5A], [0x61, 0x7A] */
* @param c The character.
* @return Whether the character is a ' ' or a '\t'.
*/
-int (isblank)(int); /* ' ', '\t' */
+int (isblank)(int) /* ' ', '\t' */
+ __GCC_ONLY(__attribute__((const)));
# if defined(__GNUC__)
# define isblank(c) \
({ int __c = (c); ((__c == ' ') || (__c == '\t')); })
@@ -79,7 +82,8 @@ int (isblank)(int); /* ' ', '\t' */
* @return Whether the character is lower than ' ',
* or is 0x7F.
*/
-int (iscntrl)(int); /* [0x00, 0x1F], 0x7F */
+int (iscntrl)(int) /* [0x00, 0x1F], 0x7F */
+ __GCC_ONLY(__attribute__((const)));
#if defined(__GNUC__)
# define iscntrl(c) \
({ int __c = (c); (((unsigned)__c < ' ') || (c__ == 0x7F)); })
@@ -92,7 +96,8 @@ int (iscntrl)(int); /* [0x00, 0x1F], 0x7F */
* @param c The character.
* @return Whether the character is in ['0', '9'].
*/
-int (isdigit)(int); /* [0x30, 0x39] */
+int (isdigit)(int) /* [0x30, 0x39] */
+ __GCC_ONLY(__attribute__((const)));
#define isdigit(c) ((unsigned)((c) - '0') < 10)
@@ -103,7 +108,8 @@ int (isdigit)(int); /* [0x30, 0x39] */
* @return Whether the character is greater
* than ' ', but is not 0x7F.
*/
-int (isgraph)(int); /* [0x21, 0x7E] */
+int (isgraph)(int) /* [0x21, 0x7E] */
+ __GCC_ONLY(__attribute__((const)));
#define isgraph(c) ((unsigned)(c - 0x21) < 0x5E)
@@ -114,7 +120,8 @@ int (isgraph)(int); /* [0x21, 0x7E] */
* @param c The character.
* @return Whether the character is in ['a', 'z'].
*/
-int (islower)(int); /* [0x61, 0x7A] */
+int (islower)(int) /* [0x61, 0x7A] */
+ __GCC_ONLY(__attribute__((const)));
#define islower(c) ((unsigned)((c) - 'a') < 26)
@@ -126,7 +133,8 @@ int (islower)(int); /* [0x61, 0x7A] */
* @return Whether the character is at least
* as great as ' ', but is not 0x7F.
*/
-int (isprint)(int); /* [0x20, 0x7E] */
+int (isprint)(int) /* [0x20, 0x7E] */
+ __GCC_ONLY(__attribute__((const)));
#define isprint(c) ((unsigned)(c - 0x20) < 0x5F)
@@ -138,7 +146,8 @@ int (isprint)(int); /* [0x20, 0x7E] */
* @param c The character.
* @return Whether the character is a punctuation.
*/
-int (ispunct)(int); /* isprint && !isalnum && !isspace) */
+int (ispunct)(int) /* isprint && !isalnum && !isspace) */
+ __GCC_ONLY(__attribute__((const)));
#if defined (__GNUC__)
# define ispunk(c) \
({ int __c = (c); (isprint(__c) && !isalnum(__c) && !isspace(__c)); })
@@ -152,7 +161,8 @@ int (ispunct)(int); /* isprint && !isalnum && !isspace) */
* @return Whether the character is a ' ', '\f',
* '\n', '\r', '\t', or '\v'.
*/
-int (isspace)(int); /* 0x20, [0x09, 0x0D] */
+int (isspace)(int) /* 0x20, [0x09, 0x0D] */
+ __GCC_ONLY(__attribute__((const)));
#if defined (__GNUC__)
# define isspace(c) \
({ int __c = (c); ((__c == ' ') || ((unsigned)(__c - '\t') < 5)); })
@@ -166,7 +176,8 @@ int (isspace)(int); /* 0x20, [0x09, 0x0D] */
* @param c The character.
* @return Whether the character is in ['A', 'Z'].
*/
-int (isupper)(int); /* [0x41, 0x5A] */
+int (isupper)(int) /* [0x41, 0x5A] */
+ __GCC_ONLY(__attribute__((const)));
#define isupper(c) ((unsigned)((c) - 'A') < 26)
@@ -179,7 +190,8 @@ int (isupper)(int); /* [0x41, 0x5A] */
* @return Whether the character is in
* ['0', '9'], ['A', 'Z'], or ['a', 'z'].
*/
-int (isxdigit)(int); /* [0x30, 0x39], [0x41, 0x46], [0x61, 0x66] */
+int (isxdigit)(int) /* [0x30, 0x39], [0x41, 0x46], [0x61, 0x66] */
+ __GCC_ONLY(__attribute__((const)));
#if defined (__GNUC__)
# define isxdigit(c) \
({ int __c = (c); (isdigit(__c) && (tolower(__c) - 'a' < 6)); })
@@ -201,8 +213,9 @@ int (isxdigit)(int); /* [0x30, 0x39], [0x41, 0x46], [0x61, 0x66] */
* Guaranteed to be unchanged if the
* character already is in lowercase.
*/
-int (tolower)(int); /* [0x41, 0x5A] -> [0x61, 0x7A] */
-#define tolower(c) ((c) | 0x20)
+int (tolower)(int) /* [0x41, 0x5A] -> [0x61, 0x7A] */
+ __GCC_ONLY(__attribute__((const)));
+#define tolower(c) ((unsigned)(c) | 0x20)
/**
* Convert a lowercase ASCII character to
@@ -218,8 +231,9 @@ int (tolower)(int); /* [0x41, 0x5A] -> [0x61, 0x7A] */
* Guaranteed to be unchanged if the
* character already is in lowercase.
*/
-int (toupper)(int); /* [0x61, 0x7A] -> [0x41, 0x5A] */
-#define toupper(c) ((c) & ~0x20)
+int (toupper)(int) /* [0x61, 0x7A] -> [0x41, 0x5A] */
+ __GCC_ONLY(__attribute__((const)));
+#define toupper(c) ((unsigned)(c) & ~0x20)
@@ -229,7 +243,8 @@ int (toupper)(int); /* [0x61, 0x7A] -> [0x41, 0x5A] */
* @param c The character
* @return - Whether the character is an ASCII character.
*/
-int (isascii)(int); /* [0x00, 0x7E] */
+int (isascii)(int) /* [0x00, 0x7E] */
+ __GCC_ONLY(__attribute__((const)));
#define isascii(c) ((unsigned)(c) < 0x7F)
/**
@@ -242,9 +257,10 @@ int (isascii)(int); /* [0x00, 0x7E] */
* @param c The character with the 8:th bit cleared.
*/
int (toascii)(int)
- __warning("Using 'toascii' is, generally, unwise.");
+ __warning("Using 'toascii' is, generally, unwise.")
+ __GCC_ONLY(__attribute__((const)));
#if defined(_SLIBC_SUPPRESS_WARNINGS)
-# define toascii(c) ((c) & 0x7F)
+# define toascii(c) ((unsigned)(c) & 0x7F)
#endif
/**
@@ -252,14 +268,16 @@ int (toascii)(int)
* It is provided for backwards-compatibility with SVID.
*/
int _tolower(int)
- __deprecated("Use 'tolower' instead.");
+ __deprecated("Use 'tolower' instead.")
+ __GCC_ONLY(__attribute__((const)));
/**
* This function is identical to `tolower`.
* It is provided for backwards-compatibility with SVID.
*/
int _toupper(int)
- __deprecated("Use 'toupper' instead.");
+ __deprecated("Use 'toupper' instead.")
+ __GCC_ONLY(__attribute__((const)));
diff --git a/include/err.h b/include/err.h
index 6e9b828..c4b241a 100644
--- a/include/err.h
+++ b/include/err.h
@@ -87,7 +87,7 @@ void vwarnx(const char*, va_list);
* @param ... Formatting-arguments.
*/
void err(int, const char*, ...)
- __noreturn __GCC_ONLY(__attribute__((format(printf, 2, 3))));
+ __GCC_ONLY(__attribute__((format(printf, 2, 3)))) __noreturn;
/**
* Print an error message to stderr, followed by a
diff --git a/include/error.h b/include/error.h
index f38ee44..37d8328 100644
--- a/include/error.h
+++ b/include/error.h
@@ -26,7 +26,7 @@
#endif
-#include <slibc/features.h>
+#include <stdarg.h>
@@ -140,7 +140,7 @@ extern volatile int error_one_per_line;
*
* This is a GNU extension.
*/
-extern volatile void (*error_print_progname)(void);
+extern void (*volatile error_print_progname)(void);
diff --git a/include/stddef.h b/include/stddef.h
index 26286f5..871a618 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -44,7 +44,7 @@
*/
#ifndef NULL
# define NULL ((void*)0)
-#define
+#endif
/**
diff --git a/include/stdlib.h b/include/stdlib.h
index 3151947..c02e094 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -39,7 +39,7 @@
*/
#ifndef NULL
# define NULL ((void*)0)
-#define
+#endif
diff --git a/include/string.h b/include/string.h
index c43b41d..fe1b930 100644
--- a/include/string.h
+++ b/include/string.h
@@ -22,6 +22,14 @@
+/**
+ * `NULL`'s canonical header is <stddef.h>
+ */
+#ifndef NULL
+# define NULL ((void*)0)
+#endif
+
+
#define __NEED_size_t
#define __NEED_locale_t /* TODO not defined */
@@ -66,11 +74,13 @@ char* strerror(int)
* `LC_GLOBAL_LOCALE`, lest the behaviour is undefined.
* @return A description of the error.
*/
+/* TODO strerror_l
char* strerror_l(int, locale_t)
__GCC_ONLY(__attribute__((warn_unused_result)));
+*/
-#if !defined(__PORTABLE) && !defined(_SLIBC_SOURCE)
+#if !defined(__PORTABLE)
/**
* Reenterant variant of `strerror`.
*
@@ -125,7 +135,7 @@ char* __gnu_strerror_r(int, char*, size_t); /* GNU-specific strerror_r */
* @return The number of bytes before the first NUL byte.
*/
size_t strlen(const char*)
- __GCC_ONLY(__attribute__((nonnull, warn_unused_result)));
+ __GCC_ONLY(__attribute__((nonnull, warn_unused_result, pure)));
#if (defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) || \
defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || \
@@ -140,7 +150,7 @@ size_t strlen(const char*)
* `maxlen` if no NUL byte was found.
*/
size_t strnlen(const char*, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result)));
+ __GCC_ONLY(__attribute__((warn_unused_result, pure)));
#endif
@@ -716,7 +726,7 @@ void* memdup(const void*, size_t)
* see the specifications for `a` and `b`.
*/
int memcmp(const void*, const void*, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result)));
+ __GCC_ONLY(__attribute__((warn_unused_result, pure)));
/**
* Compare two strings alphabetically in a case sensitive manner.
@@ -727,7 +737,7 @@ int memcmp(const void*, const void*, size_t)
* see the specifications for `a` and `b`.
*/
int strcmp(const char*, const char*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
* Compare two strings alphabetically in a case sensitive manner.
@@ -739,12 +749,12 @@ int strcmp(const char*, const char*)
* see the specifications for `a` and `b`.
*/
int strncmp(const char*, const char*, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
#if defined(_GNU_SOURCE) && !defined(__PORTABLE)
int strverscmp(const char*, const char*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/* TODO document and implement strverscmp */
#endif
@@ -759,7 +769,7 @@ int strverscmp(const char*, const char*)
* `NULL` if none were found.
*/
void* memchr(const void*, int, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result)));
+ __GCC_ONLY(__attribute__((warn_unused_result, pure)));
#if (defined(_GNU_SOURCE) || defined(_SLIBC_SOURCE)) && !defined(__PORTABLE)
/**
@@ -773,7 +783,7 @@ void* memchr(const void*, int, size_t)
* @return Pointer to the first occurrence of `c`.
*/
void* rawmemchr(const void*, int)
- __GCC_ONLY(__attribute__((warn_unused_result, returns_nonnull, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, returns_nonnull, nonnull, pure)));
#endif
/**
@@ -790,7 +800,7 @@ void* rawmemchr(const void*, int)
* `NULL` if none were found.
*/
void* memrchr(const void*, int, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result)));
+ __GCC_ONLY(__attribute__((warn_unused_result, pure)));
/**
* Find the first occurrence of a byte in a string.
@@ -806,7 +816,7 @@ void* memrchr(const void*, int, size_t)
* `NULL` if none were found.
*/
char* strchr(const char*, int)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
#if (defined(_GNU_SOURCE) || defined(_SLIBC_SOURCE)) && !defined(__PORTABLE)
/**
@@ -824,7 +834,7 @@ char* strchr(const char*, int)
* if none were found.
*/
char* strchrnul(const char*, int)
- __GCC_ONLY(__attribute__((warn_unused_result, returns_nonnull, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, returns_nonnull, nonnull, pure)));
#endif
/**
@@ -842,7 +852,7 @@ char* strchrnul(const char*, int)
* `NULL` if none were found.
*/
char* strrchr(const char*, int)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/* TODO Add case insensitive character searching functions. */
@@ -858,7 +868,7 @@ char* strrchr(const char*, int)
* substring, `NULL` if not found.
*/
char* strstr(const char*, const char*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
* Finds the first occurrence of a substring.
@@ -870,7 +880,7 @@ char* strstr(const char*, const char*)
* substring, `NULL` if not found.
*/
char* strcasestr(const char*, const char*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
#if defined(_SLIBC_SOURCE) && !defined(__PORTABLE)
/**
@@ -887,7 +897,7 @@ char* strcasestr(const char*, const char*)
* substring, `NULL` if not found.
*/
char* strnstr(const char*, const char*, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
* Finds the first occurrence of a substring.
@@ -902,7 +912,7 @@ char* strnstr(const char*, const char*, size_t)
* substring, `NULL` if not found.
*/
char* strncasestr(const char*, const char*, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
* Finds the first occurrence of a substring.
@@ -916,7 +926,7 @@ char* strncasestr(const char*, const char*, size_t)
* @return Pointer to the first occurrence of the substring.
*/
char* rawstrstr(const char*, const char*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull, returns_nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, returns_nonnull, pure)));
/**
* Finds the first occurrence of a substring.
@@ -930,7 +940,7 @@ char* rawstrstr(const char*, const char*)
* @return Pointer to the first occurrence of the substring.
*/
char* rawstrcasestr(const char*, const char*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull, returns_nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, returns_nonnull, pure)));
/**
* Finds the first occurrence of a substring
@@ -947,7 +957,7 @@ char* rawstrcasestr(const char*, const char*)
* the substring, `NULL` if not found.
*/
void* memcasemem(const void*, size_t, const void*, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result)));
+ __GCC_ONLY(__attribute__((warn_unused_result, pure)));
#endif
#if (defined(_GNU_SOURCE) || defined(_SLIBC_SOURCE)) && !defined(__PORTABLE)
@@ -966,7 +976,7 @@ void* memcasemem(const void*, size_t, const void*, size_t)
* the substring, `NULL` if not found.
*/
void* memmem(const void*, size_t, const void*, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result)));
+ __GCC_ONLY(__attribute__((warn_unused_result, pure)));
#endif
@@ -983,7 +993,7 @@ void* memmem(const void*, size_t, const void*, size_t)
* @return The length of the substring.
*/
size_t strspn(const char*, const char*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
* Returns length of the initial substring
@@ -995,7 +1005,7 @@ size_t strspn(const char*, const char*)
* @return The length of the substring.
*/
size_t strcspn(const char*, const char*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
* This function works like `strcspn`,
@@ -1010,7 +1020,7 @@ size_t strcspn(const char*, const char*)
* `NULL` is returned if none is found.
*/
char* stpbrk(const char*, const char*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
@@ -1086,7 +1096,7 @@ char* strsep(char** restrict, const char* restrict)
* so it must not freed or edited.
*/
char* __gnu_basename(const char*)
- __GCC_ONLY(__attribute__((warn_unused_result)));
+ __GCC_ONLY(__attribute__((warn_unused_result, pure)));
# define basename __gnu_basename
#endif
diff --git a/include/strings.h b/include/strings.h
index 2044fa6..a06a167 100644
--- a/include/strings.h
+++ b/include/strings.h
@@ -64,7 +64,7 @@ void bcopy(const void*, void*, size_t)
*/
int bcmp(const void*, const void*, size_t)
__deprecated("Use 'memcmp' instead.")
- __GCC_ONLY(__attribute__((warn_unused_result)));
+ __GCC_ONLY(__attribute__((warn_unused_result, pure)));
/**
@@ -78,7 +78,7 @@ int bcmp(const void*, const void*, size_t)
* see the specifications for `a` and `b`.
*/
int strcasecmp(const char*, const char*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
* Compare two strings alphabetically in a case insensitive manner.
@@ -92,7 +92,7 @@ int strcasecmp(const char*, const char*)
* see the specifications for `a` and `b`.
*/
int strncasecmp(const char*, const char*, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
@@ -102,7 +102,7 @@ int strncasecmp(const char*, const char*, size_t)
*/
char* index(const char*, int)
__deprecated("Use 'strchr' instead.")
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
* This function is identical to `strrchr`.
@@ -111,7 +111,7 @@ char* index(const char*, int)
*/
char* rindex(const char*, int)
__deprecated("Use 'strrchr' instead.")
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
diff --git a/include/wchar.h b/include/wchar.h
index faf9275..12b1de9 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -23,6 +23,14 @@
+/**
+ * `NULL`'s canonical header is <stddef.h>
+ */
+#ifndef NULL
+# define NULL ((void*)0)
+#endif
+
+
#define __NEED_size_t
#define __NEED_wchar_t
@@ -37,7 +45,7 @@
* first NUL character.
*/
size_t wcslen(const wchar_t*)
- __GCC_ONLY(__attribute__((nonnull, warn_unused_result)));
+ __GCC_ONLY(__attribute__((nonnull, warn_unused_result, pure)));
#if (defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) || \
defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || \
@@ -52,7 +60,7 @@ size_t wcslen(const wchar_t*)
* NUL character was found.
*/
size_t wcsnlen(const wchar_t*, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result)));
+ __GCC_ONLY(__attribute__((warn_unused_result, pure)));
#endif
@@ -200,7 +208,7 @@ wchar_t* wcpcpy(wchar_t* restrict, const wchar_t* restrict)
* one character passed the last written non-NUL
* character.
*/
-wchar_t* wcsccpy(wchar_t* restrict, const wchar_t* restrict, wchat_t)
+wchar_t* wcsccpy(wchar_t* restrict, const wchar_t* restrict, wchar_t)
__GCC_ONLY(__attribute__((nonnull)));
/**
@@ -286,7 +294,7 @@ wchar_t* wcpncpy(wchar_t* restrict, const wchar_t* restrict, size_t)
* one character passed the last written non-NUL
* character.
*/
-wchar_t* wcscncpy(wchar_t* restrict, const wchar_t* restrict, wchat_t, size_t)
+wchar_t* wcscncpy(wchar_t* restrict, const wchar_t* restrict, wchar_t, size_t)
__GCC_ONLY(__attribute__((nonnull)));
/**
@@ -361,7 +369,7 @@ wchar_t* wcpmove(wchar_t*, const wchar_t*)
* one character passed the last written non-NUL
* character.
*/
-wchar_t* wcscmove(wchar_t*, const wchar_t*, wchat_t)
+wchar_t* wcscmove(wchar_t*, const wchar_t*, wchar_t)
__GCC_ONLY(__attribute__((nonnull)));
/**
@@ -446,7 +454,7 @@ wchar_t* wcpnmove(wchar_t*, const wchar_t*, size_t)
* one character passed the last written non-NUL
* character.
*/
-wchar_t* wcscnmove(wchar_t*, const wchar_t*, wchat_t, size_t)
+wchar_t* wcscnmove(wchar_t*, const wchar_t*, wchar_t, size_t)
__GCC_ONLY(__attribute__((nonnull)));
/**
@@ -641,7 +649,7 @@ wchar_t* wmemdup(const wchar_t*, size_t)
* see the specifications for `a` and `b`.
*/
int wmemcmp(const wchar_t*, const wchar_t*, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result)));
+ __GCC_ONLY(__attribute__((warn_unused_result, pure)));
/**
* Compare two strings alphabetically in a case sensitive manner.
@@ -652,7 +660,7 @@ int wmemcmp(const wchar_t*, const wchar_t*, size_t)
* see the specifications for `a` and `b`.
*/
int wcscmp(const wchar_t*, const wchar_t*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
#if (defined(_GNU_SOURCE) || defined(_SLIBC_SOURCE)) && !defined(__PORTABLE)
/**
@@ -668,7 +676,7 @@ int wcscmp(const wchar_t*, const wchar_t*)
* see the specifications for `a` and `b`.
*/
int wcscasecmp(const wchar_t*, const wchar_t*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
* Compare two strings alphabetically in a case sensitive manner.
@@ -682,7 +690,7 @@ int wcscasecmp(const wchar_t*, const wchar_t*)
* see the specifications for `a` and `b`.
*/
int wcsncmp(const wchar_t*, const wchar_t*, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
* Compare two strings alphabetically in a case insensitive manner.
@@ -698,7 +706,7 @@ int wcsncmp(const wchar_t*, const wchar_t*, size_t)
* see the specifications for `a` and `b`.
*/
int wcsncasecmp(const wchar_t*, const wchar_t*, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
#endif
@@ -713,7 +721,7 @@ int wcsncasecmp(const wchar_t*, const wchar_t*, size_t)
* `NULL` if none were found.
*/
wchar_t* wmemchr(const wchar_t*, wchar_t, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result)));
+ __GCC_ONLY(__attribute__((warn_unused_result, pure)));
#if defined(_SLIBC_SOURCE) && !defined(__PORTABLE)
/**
@@ -728,7 +736,7 @@ wchar_t* wmemchr(const wchar_t*, wchar_t, size_t)
* @return Pointer to the first occurrence of `c`.
*/
wchar_t* rawwmemchr(const wchar_t*, wchar_t)
- __GCC_ONLY(__attribute__((warn_unused_result, returns_nonnull, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, returns_nonnull, nonnull, pure)));
/**
* Find the last occurrence of a wide character in
@@ -747,7 +755,7 @@ wchar_t* rawwmemchr(const wchar_t*, wchar_t)
* `NULL` if none were found.
*/
wchar_t* wmemrchr(const wchar_t*, wchar_t, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result)));
+ __GCC_ONLY(__attribute__((warn_unused_result, pure)));
#endif
/**
@@ -761,7 +769,7 @@ wchar_t* wmemrchr(const wchar_t*, wchar_t, size_t)
* `NULL` if none were found.
*/
wchar_t* wcschr(const wchar_t*, wchar_t)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
#if (defined(_GNU_SOURCE) || defined(_SLIBC_SOURCE)) && !defined(__PORTABLE)
/**
@@ -780,7 +788,7 @@ wchar_t* wcschr(const wchar_t*, wchar_t)
* if none were found.
*/
wchar_t* wcschrnul(const wchar_t*, wchar_t)
- __GCC_ONLY(__attribute__((warn_unused_result, returns_nonnull, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, returns_nonnull, nonnull, pure)));
#endif
/**
@@ -798,7 +806,7 @@ wchar_t* wcschrnul(const wchar_t*, wchar_t)
* `NULL` if none were found.
*/
wchar_t* wcsrchr(const wchar_t*, wchar_t)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/* TODO Add case insensitive character searching functions. */
@@ -808,7 +816,7 @@ wchar_t* wcsrchr(const wchar_t*, wchar_t)
* This function is identical to `wcsstr`.
*/
wchar_t* wcswcs(const wchar_t*, const wchar_t*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)))
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)))
__deprecated("Use 'wcsstr' instead.");
/**
@@ -821,7 +829,7 @@ wchar_t* wcswcs(const wchar_t*, const wchar_t*)
* substring, `NULL` if not found.
*/
wchar_t* wcsstr(const wchar_t*, const wchar_t*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
#if defined(_SLIBC_SOURCE) && !defined(__PORTABLE)
/**
@@ -836,7 +844,7 @@ wchar_t* wcsstr(const wchar_t*, const wchar_t*)
* substring, `NULL` if not found.
*/
wchar_t* wcscasestr(const wchar_t*, const wchar_t*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
* Finds the first occurrence of a substring.
@@ -852,7 +860,7 @@ wchar_t* wcscasestr(const wchar_t*, const wchar_t*)
* substring, `NULL` if not found.
*/
wchar_t* wcsnstr(const wchar_t*, const wchar_t*, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
* Finds the first occurrence of a substring.
@@ -867,7 +875,7 @@ wchar_t* wcsnstr(const wchar_t*, const wchar_t*, size_t)
* substring, `NULL` if not found.
*/
wchar_t* wcsncasestr(const wchar_t*, const wchar_t*, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
* Finds the first occurrence of a substring.
@@ -881,7 +889,7 @@ wchar_t* wcsncasestr(const wchar_t*, const wchar_t*, size_t)
* @return Pointer to the first occurrence of the substring.
*/
wchar_t* rawwcsstr(const wchar_t*, const wchar_t*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull, returns_nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, returns_nonnull, pure)));
/**
* Finds the first occurrence of a substring.
@@ -895,7 +903,7 @@ wchar_t* rawwcsstr(const wchar_t*, const wchar_t*)
* @return Pointer to the first occurrence of the substring.
*/
wchar_t* rawwcscasestr(const wchar_t*, const wchar_t*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull, returns_nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, returns_nonnull, pure)));
/**
* Finds the first occurrence of a substring
@@ -911,7 +919,8 @@ wchar_t* rawwcscasestr(const wchar_t*, const wchar_t*)
* @return Pointer to the first occurrence of
* the substring, `NULL` if not found.
*/
-wchar_t* wmemcasemem(const wchar_t*, size_t, const wchar_t*, size_t);
+wchar_t* wmemcasemem(const wchar_t*, size_t, const wchar_t*, size_t)
+ __GCC_ONLY(__attribute__((warn_unused_result, pure)));
#endif
#if (defined(_GNU_SOURCE) || defined(_SLIBC_SOURCE)) && !defined(__PORTABLE)
@@ -931,7 +940,7 @@ wchar_t* wmemcasemem(const wchar_t*, size_t, const wchar_t*, size_t);
* the substring, `NULL` if not found.
*/
wchar_t* wmemmem(const wchar_t*, size_t, const wchar_t*, size_t)
- __GCC_ONLY(__attribute__((warn_unused_result)));
+ __GCC_ONLY(__attribute__((warn_unused_result, pure)));
#endif
@@ -948,7 +957,7 @@ wchar_t* wmemmem(const wchar_t*, size_t, const wchar_t*, size_t)
* @return The length of the substring.
*/
size_t wcsspn(const wchar_t*, const wchar_t*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
* Returns length of the initial substring
@@ -960,7 +969,7 @@ size_t wcsspn(const wchar_t*, const wchar_t*)
* @return The length of the substring.
*/
size_t wcscspn(const wchar_t*, const wchar_t*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**
* This function works like `strcspn`,
@@ -975,7 +984,7 @@ size_t wcscspn(const wchar_t*, const wchar_t*)
* `NULL` is returned if none is found.
*/
wchar_t* wcpbrk(const wchar_t*, const wchar_t*)
- __GCC_ONLY(__attribute__((warn_unused_result, nonnull)));
+ __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure)));
/**