diff options
-rw-r--r-- | include/bits/types.h | 12 | ||||
-rw-r--r-- | include/inttypes.h | 3 | ||||
-rw-r--r-- | include/stdlib.h | 17 | ||||
-rw-r--r-- | include/string.h | 3 | ||||
-rw-r--r-- | src/string/strfry.c | 2 | ||||
-rw-r--r-- | src/wchar/wcsmove.c | 2 | ||||
-rw-r--r-- | src/wchar/wcstok.c | 2 |
7 files changed, 32 insertions, 9 deletions
diff --git a/include/bits/types.h b/include/bits/types.h index 5d99e4f..83087b5 100644 --- a/include/bits/types.h +++ b/include/bits/types.h @@ -362,3 +362,15 @@ typedef struct { } imaxdiv_t; #endif + +/** + * Locale datatype. + */ +#if defined(__NEED_locale_t) && !defined(__DEFINED_locale_t) +# define __DEFINED_locale_t +typedef struct __locale locale_t; /* TODO not implemented */ +#endif +#ifndef __INTMAX_MAX +# define __INTMAX_MAX INT64_MAX +#endif + diff --git a/include/inttypes.h b/include/inttypes.h index dac5e27..3f24e9b 100644 --- a/include/inttypes.h +++ b/include/inttypes.h @@ -37,7 +37,8 @@ * @return The quotient in `.quot`, and * the remainder in `.rem`. */ -imaxdiv_t imaxdiv(intmax_t, intmax_t); +imaxdiv_t imaxdiv(intmax_t, intmax_t) + __GCC_ONLY(__attribute__((const))); diff --git a/include/stdlib.h b/include/stdlib.h index fd78d27..9340201 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -65,7 +65,8 @@ * @return The quotient in `.quot`, and * the remainder in `.rem`. */ -div_t div(int, int); +div_t div(int, int) + __GCC_ONLY(__attribute__((const))); /** * Perform an integer division and return @@ -76,7 +77,8 @@ div_t div(int, int); * @return The quotient in `.quot`, and * the remainder in `.rem`. */ -ldiv_t ldiv(long, long); +ldiv_t ldiv(long, long) + __GCC_ONLY(__attribute__((const))); /** * Perform an integer division and return @@ -87,7 +89,16 @@ ldiv_t ldiv(long, long); * @return The quotient in `.quot`, and * the remainder in `.rem`. */ -lldiv_t lldiv(long long, long long); +lldiv_t lldiv(long long, long long) + __GCC_ONLY(__attribute__((const))); + + + +/* TODO implement rand-functions */ +#define RAND_MAX 1 +int rand(void); +int rand_r(unsigned int* seed); +void srand(unsigned int seed); diff --git a/include/string.h b/include/string.h index 483b49b..53aaca6 100644 --- a/include/string.h +++ b/include/string.h @@ -31,8 +31,7 @@ #define __NEED_size_t -#define __NEED_locale_t /* TODO not defined */ - +#define __NEED_locale_t #include <bits/types.h> diff --git a/src/string/strfry.c b/src/string/strfry.c index cf8d643..da6d0ac 100644 --- a/src/string/strfry.c +++ b/src/string/strfry.c @@ -41,7 +41,7 @@ char* strfry(char* anagram) for (i = strlen(anagram); --i;) { r = rand(); - j = (int)((double)r / (RAND_MAX + 1)); + j = (size_t)((double)r / (RAND_MAX + 1) * (double)i); t = anagram[i], anagram[i] = anagram[j], anagram[j] = t; } return anagram; diff --git a/src/wchar/wcsmove.c b/src/wchar/wcsmove.c index 041d194..4e2f773 100644 --- a/src/wchar/wcsmove.c +++ b/src/wchar/wcsmove.c @@ -212,7 +212,7 @@ wchar_t* wcscnmove(wchar_t* whither, const wchar_t* whence, wchar_t c, size_t ma * one character passed the last written non-NUL * character. */ -wchar_t* wcswcsnmove(wchar_t* whither, const wchar_t* whence, const wchar_t* restrict str, size_t maxlen) +wchar_t* wcsstrnmove(wchar_t* whither, const wchar_t* whence, const wchar_t* restrict str, size_t maxlen) { const wchar_t* stop = wcsnstr(whence, str, maxlen); size_t n = stop == NULL ? wcsnlen(whence, maxlen) : (size_t)(stop - whence); diff --git a/src/wchar/wcstok.c b/src/wchar/wcstok.c index 9ca3929..583defd 100644 --- a/src/wchar/wcstok.c +++ b/src/wchar/wcstok.c @@ -79,7 +79,7 @@ wchar_t* wcssep(wchar_t** restrict string, const wchar_t* restrict delimiters) if (r == NULL) return NULL; - next = wcrpbrk(r, delimiters); + next = wcspbrk(r, delimiters); if (next != NULL) *next++ = 0; *string = next; |