1 /* Copyright (C) 2002 Manuel Novoa III
2 * From my (incomplete) stdlib library for linux and (soon) elks.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, see
16 * <http://www.gnu.org/licenses/>.
19 /* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
21 * This code is currently under development. Also, I plan to port
22 * it to elks which is a 16-bit environment with a fairly limited
23 * compiler. Therefore, please refrain from modifying this code
24 * and, instead, pass any bug-fixes, etc. to me. Thanks. Manuel
26 * ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */
29 * Fix a couple of 'restrict' bugs in mbstowcs and wcstombs.
32 * Add wscto{inttype} functions.
47 #ifdef __UCLIBC_HAS_WCHAR__
51 #include <bits/uClibc_uwchar.h>
53 /* TODO: clean up the following... */
55 #if WCHAR_MAX > 0xffffUL
56 #define UTF_8_MAX_LEN 6
58 #define UTF_8_MAX_LEN 3
61 #ifdef __UCLIBC_HAS_LOCALE__
63 #define ENCODING (__UCLIBC_CURLOCALE->encoding)
64 #ifndef __CTYPE_HAS_UTF_8_LOCALES
67 #warning __CTYPE_HAS_UTF_8_LOCALES not set!
71 #else /* __UCLIBC_HAS_LOCALE__ */
73 #ifdef __UCLIBC_MJN3_ONLY__
79 #ifdef __CTYPE_HAS_8_BIT_LOCALES
80 #error __CTYPE_HAS_8_BIT_LOCALES is defined!
82 #ifdef __CTYPE_HAS_UTF_8_LOCALES
83 #error __CTYPE_HAS_UTF_8_LOCALES is defined!
87 #endif /* __UCLIBC_HAS_LOCALE__ */
89 /**********************************************************************/
90 #ifdef __UCLIBC_HAS_XLOCALE__
93 _stdlib_strto_l_l(register const char * __restrict str,
94 char ** __restrict endptr, int base, int sflag,
95 __locale_t locale_arg) attribute_hidden;
97 #if defined(ULLONG_MAX)
98 extern unsigned long long
99 _stdlib_strto_ll_l(register const char * __restrict str,
100 char ** __restrict endptr, int base, int sflag,
101 __locale_t locale_arg) attribute_hidden;
104 #ifdef __UCLIBC_HAS_WCHAR__
106 _stdlib_wcsto_l_l(register const wchar_t * __restrict str,
107 wchar_t ** __restrict endptr, int base, int sflag,
108 __locale_t locale_arg) attribute_hidden;
110 #if defined(ULLONG_MAX)
111 extern unsigned long long
112 _stdlib_wcsto_ll_l(register const wchar_t * __restrict str,
113 wchar_t ** __restrict endptr, int base, int sflag,
114 __locale_t locale_arg) attribute_hidden;
116 #endif /* __UCLIBC_HAS_WCHAR__ */
118 #endif /* __UCLIBC_HAS_XLOCALE__ */
123 _stdlib_strto_l(register const char * __restrict str,
124 char ** __restrict endptr, int base, int sflag) attribute_hidden;
126 #if defined(ULLONG_MAX)
127 extern unsigned long long
128 _stdlib_strto_ll(register const char * __restrict str,
129 char ** __restrict endptr, int base, int sflag) attribute_hidden;
132 #ifdef __UCLIBC_HAS_WCHAR__
134 _stdlib_wcsto_l(register const wchar_t * __restrict str,
135 wchar_t ** __restrict endptr, int base, int sflag) attribute_hidden;
137 #if defined(ULLONG_MAX)
138 extern unsigned long long
139 _stdlib_wcsto_ll(register const wchar_t * __restrict str,
140 wchar_t ** __restrict endptr, int base, int sflag) attribute_hidden;
142 #endif /* __UCLIBC_HAS_WCHAR__ */
143 /**********************************************************************/
147 double atof(const char *nptr)
149 return strtod(nptr, (char **) NULL);
153 /**********************************************************************/
156 #if INT_MAX < LONG_MAX
160 return (j >= 0) ? j : -j;
163 #endif /* INT_MAX < LONG_MAX */
166 /**********************************************************************/
169 long int labs(long int j)
171 return (j >= 0) ? j : -j;
174 #if UINT_MAX == ULONG_MAX
175 strong_alias_untyped(labs,abs)
178 #if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
179 strong_alias_untyped(labs,llabs)
182 #if ULONG_MAX == UINTMAX_MAX
183 strong_alias_untyped(labs,imaxabs)
187 /**********************************************************************/
190 #if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
192 long long int llabs(long long int j)
194 return (j >= 0) ? j : -j;
197 #if (ULLONG_MAX == UINTMAX_MAX)
198 strong_alias_untyped(llabs,imaxabs)
201 #endif /* defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX) */
204 /**********************************************************************/
207 #if INT_MAX < LONG_MAX
210 int atoi(const char *nptr)
212 return (int) strtol(nptr, (char **) NULL, 10);
214 libc_hidden_def(atoi)
216 #endif /* INT_MAX < LONG_MAX */
219 /**********************************************************************/
223 long atol(const char *nptr)
225 return strtol(nptr, (char **) NULL, 10);
228 #if UINT_MAX == ULONG_MAX
229 strong_alias_untyped(atol,atoi)
230 libc_hidden_def(atoi)
233 #if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
234 strong_alias_untyped(atol,atoll)
238 /**********************************************************************/
241 #if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
244 long long atoll(const char *nptr)
246 return strtoll(nptr, (char **) NULL, 10);
249 #endif /* defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX) */
252 /**********************************************************************/
254 int rpmatch (const char *__response)
256 return (__response[0] == 'y' || __response[0] == 'Y') ? 1 :
257 (__response[0] == 'n' || __response[0] == 'N') ? 0 : -1;
260 /**********************************************************************/
261 #if defined(L_strtol) || defined(L_strtol_l)
263 long __XL_NPP(strtol)(const char * __restrict str, char ** __restrict endptr,
264 int base __LOCALE_PARAM)
266 return __XL_NPP(_stdlib_strto_l)(str, endptr, base, 1 __LOCALE_ARG);
268 libc_hidden_def(__XL_NPP(strtol))
270 #if (ULONG_MAX == UINTMAX_MAX) && !defined(L_strtol_l)
271 strong_alias(strtol,strtoimax)
274 #if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
275 strong_alias_untyped(__XL_NPP(strtol),__XL_NPP(strtoll))
277 libc_hidden_def(__XL_NPP(strtoll))
278 strong_alias(strtol,strtoq)
283 /**********************************************************************/
284 #if defined(L_strtoll) || defined(L_strtoll_l)
286 #if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
288 long long __XL_NPP(strtoll)(const char * __restrict str,
289 char ** __restrict endptr, int base
292 return (long long) __XL_NPP(_stdlib_strto_ll)(str, endptr, base, 1 __LOCALE_ARG);
295 libc_hidden_def(__XL_NPP(strtoll))
296 #if (ULLONG_MAX == UINTMAX_MAX)
297 strong_alias(strtoll,strtoimax)
299 strong_alias(strtoll,strtoq)
302 #endif /* defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX) */
305 /**********************************************************************/
306 #if defined(L_strtoul) || defined(L_strtoul_l)
308 unsigned long __XL_NPP(strtoul)(const char * __restrict str,
309 char ** __restrict endptr, int base
312 return __XL_NPP(_stdlib_strto_l)(str, endptr, base, 0 __LOCALE_ARG);
314 libc_hidden_def(__XL_NPP(strtoul))
316 #if (ULONG_MAX == UINTMAX_MAX) && !defined(L_strtoul_l)
317 strong_alias(strtoul,strtoumax)
320 #if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
321 strong_alias_untyped(__XL_NPP(strtoul),__XL_NPP(strtoull))
322 #if !defined(L_strtoul_l)
323 strong_alias(strtoul,strtouq)
329 /**********************************************************************/
330 #if defined(L_strtoull) || defined(L_strtoull_l)
332 #if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
334 unsigned long long __XL_NPP(strtoull)(const char * __restrict str,
335 char ** __restrict endptr, int base
338 return __XL_NPP(_stdlib_strto_ll)(str, endptr, base, 0 __LOCALE_ARG);
341 #if !defined(L_strtoull_l)
342 #if (ULLONG_MAX == UINTMAX_MAX)
343 strong_alias(strtoull,strtoumax)
345 strong_alias(strtoull,strtouq)
348 #endif /* defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX) */
351 /**********************************************************************/
352 /* Support routines follow */
353 /**********************************************************************/
354 /* Set if we want errno set appropriately. */
355 /* NOTE: Implies _STRTO_ENDPTR below */
356 #define _STRTO_ERRNO 1
358 /* Set if we want support for the endptr arg. */
359 /* Implied by _STRTO_ERRNO. */
360 #define _STRTO_ENDPTR 1
364 #define _STRTO_ENDPTR 1
365 #define SET_ERRNO(X) __set_errno(X)
367 #define SET_ERRNO(X) ((void)(X)) /* keep side effects */
370 /**********************************************************************/
371 #if defined(L__stdlib_wcsto_l) || defined(L__stdlib_wcsto_l_l)
372 #ifndef L__stdlib_strto_l
373 #define L__stdlib_strto_l
377 #if defined(L__stdlib_strto_l) || defined(L__stdlib_strto_l_l)
379 #if defined(L__stdlib_wcsto_l) || defined(L__stdlib_wcsto_l_l)
381 #define _stdlib_strto_l _stdlib_wcsto_l
382 #define _stdlib_strto_l_l _stdlib_wcsto_l_l
383 #define Wchar wchar_t
384 #define Wuchar __uwchar_t
385 #ifdef __UCLIBC_DO_XLOCALE
386 #define ISSPACE(C) iswspace_l((C), locale_arg)
388 #define ISSPACE(C) iswspace((C))
391 #else /* defined(L__stdlib_wcsto_l) || defined(L__stdlib_wcsto_l_l) */
394 #define Wuchar unsigned char
395 #ifdef __UCLIBC_DO_XLOCALE
396 #define ISSPACE(C) isspace_l((C), locale_arg)
398 #define ISSPACE(C) isspace((C))
401 #endif /* defined(L__stdlib_wcsto_l) || defined(L__stdlib_wcsto_l_l) */
403 #if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
405 unsigned long attribute_hidden _stdlib_strto_l(register const Wchar * __restrict str,
406 Wchar ** __restrict endptr, int base,
409 return _stdlib_strto_l_l(str, endptr, base, sflag, __UCLIBC_CURLOCALE);
413 #else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
415 /* This is the main work fuction which handles both strtol (sflag = 1) and
416 * strtoul (sflag = 0). */
418 unsigned long attribute_hidden __XL_NPP(_stdlib_strto_l)(register const Wchar * __restrict str,
419 Wchar ** __restrict endptr, int base,
420 int sflag __LOCALE_PARAM)
422 unsigned long number, cutoff;
424 const Wchar *fail_char;
425 #define SET_FAIL(X) fail_char = (X)
427 #define SET_FAIL(X) ((void)(X)) /* Keep side effects. */
429 unsigned char negative, digit, cutoff_digit;
431 assert(((unsigned int)sflag) <= 1);
435 while (ISSPACE(*str)) { /* Skip leading whitespace. */
439 /* Handle optional sign. */
442 case '-': negative = 1; /* Fall through to increment str. */
446 if (!(base & ~0x10)) { /* Either dynamic (base = 0) or base 16. */
447 base += 10; /* Default is 10 (26). */
450 base -= 2; /* Now base is 8 or 16 (24). */
451 if ((0x20|(*str)) == 'x') { /* WARNING: assumes ascii. */
453 base += base; /* Base is 16 (16 or 48). */
457 if (base > 16) { /* Adjust in case base wasn't dynamic. */
464 if (((unsigned)(base - 2)) < 35) { /* Legal base. */
465 cutoff_digit = ULONG_MAX % base;
466 cutoff = ULONG_MAX / base;
468 digit = ((Wuchar)(*str - '0') <= 9)
469 ? /* 0..9 */ (*str - '0')
470 : /* else */ (((Wuchar)(0x20 | *str) >= 'a') /* WARNING: assumes ascii. */
471 ? /* >= A/a */ ((Wuchar)(0x20 | *str) - ('a' - 10))
472 : /* else */ 40 /* bad value */);
480 if ((number > cutoff)
481 || ((number == cutoff) && (digit > cutoff_digit))) {
486 number = number * base + digit;
493 *endptr = (Wchar *) fail_char;
498 unsigned long tmp = (negative
499 ? ((unsigned long)(-(1+LONG_MIN)))+1
501 if (sflag && (number > tmp)) {
507 return negative ? (unsigned long)(-((long)number)) : number;
510 #endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
514 /**********************************************************************/
515 #if defined(L__stdlib_wcsto_ll) || defined(L__stdlib_wcsto_ll_l)
516 #ifndef L__stdlib_strto_ll
517 #define L__stdlib_strto_ll
521 #if defined(L__stdlib_strto_ll) || defined(L__stdlib_strto_ll_l)
523 #if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
525 #if defined(L__stdlib_wcsto_ll) || defined(L__stdlib_wcsto_ll_l)
526 #define _stdlib_strto_ll _stdlib_wcsto_ll
527 #define _stdlib_strto_ll_l _stdlib_wcsto_ll_l
528 #define Wchar wchar_t
529 #define Wuchar __uwchar_t
530 #ifdef __UCLIBC_DO_XLOCALE
531 #define ISSPACE(C) iswspace_l((C), locale_arg)
533 #define ISSPACE(C) iswspace((C))
536 #else /* defined(L__stdlib_wcsto_ll) || defined(L__stdlib_wcsto_ll_l) */
539 #define Wuchar unsigned char
540 #ifdef __UCLIBC_DO_XLOCALE
541 #define ISSPACE(C) isspace_l((C), locale_arg)
543 #define ISSPACE(C) isspace((C))
546 #endif /* defined(L__stdlib_wcsto_ll) || defined(L__stdlib_wcsto_ll_l) */
548 #if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
550 unsigned long long attribute_hidden _stdlib_strto_ll(register const Wchar * __restrict str,
551 Wchar ** __restrict endptr, int base,
554 return _stdlib_strto_ll_l(str, endptr, base, sflag, __UCLIBC_CURLOCALE);
558 #else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
560 /* This is the main work fuction which handles both strtoll (sflag = 1) and
561 * strtoull (sflag = 0). */
563 unsigned long long attribute_hidden __XL_NPP(_stdlib_strto_ll)(register const Wchar * __restrict str,
564 Wchar ** __restrict endptr, int base,
565 int sflag __LOCALE_PARAM)
567 unsigned long long number;
569 const Wchar *fail_char;
570 #define SET_FAIL(X) fail_char = (X)
572 #define SET_FAIL(X) ((void)(X)) /* Keep side effects. */
575 unsigned char negative, digit;
577 assert(((unsigned int)sflag) <= 1);
581 while (ISSPACE(*str)) { /* Skip leading whitespace. */
585 /* Handle optional sign. */
588 case '-': negative = 1; /* Fall through to increment str. */
592 if (!(base & ~0x10)) { /* Either dynamic (base = 0) or base 16. */
593 base += 10; /* Default is 10 (26). */
596 base -= 2; /* Now base is 8 or 16 (24). */
597 if ((0x20|(*str)) == 'x') { /* WARNING: assumes ascii. */
599 base += base; /* Base is 16 (16 or 48). */
603 if (base > 16) { /* Adjust in case base wasn't dynamic. */
610 if (((unsigned)(base - 2)) < 35) { /* Legal base. */
612 digit = ((Wuchar)(*str - '0') <= 9)
613 ? /* 0..9 */ (*str - '0')
614 : /* else */ (((Wuchar)(0x20 | *str) >= 'a') /* WARNING: assumes ascii. */
615 ? /* >= A/a */ ((Wuchar)(0x20 | *str) - ('a' - 10))
616 : /* else */ 40 /* bad value */);
625 /* Optional, but speeds things up in the usual case. */
626 if (number <= (ULLONG_MAX >> 6)) {
627 number = number * base + digit;
631 n1 = ((unsigned char) number) * base + digit;
632 number = (number >> CHAR_BIT) * base;
634 if (number + (n1 >> CHAR_BIT) <= (ULLONG_MAX >> CHAR_BIT)) {
635 number = (number << CHAR_BIT) + n1;
636 } else { /* Overflow. */
648 *endptr = (Wchar *) fail_char;
653 unsigned long long tmp = ((negative)
654 ? ((unsigned long long)(-(1+LLONG_MIN)))+1
656 if (sflag && (number > tmp)) {
662 return negative ? (unsigned long long)(-((long long)number)) : number;
665 #endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
667 #endif /* defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX) */
673 void *bsearch(const void *key, const void *base, size_t /* nmemb */ high,
674 size_t size, int (*compar)(const void *, const void *))
681 if (size > 0) { /* TODO: change this to an assert?? */
684 mid = low + ((high - low) >> 1); /* Avoid possible overflow here. */
685 p = ((char *)base) + mid * size; /* Could overflow here... */
686 r = (*compar)(key, p); /* but that's an application problem! */
700 /**********************************************************************/
703 /* This code is derived from a public domain shell sort routine by
704 * Ray Gardner and found in Bob Stout's snippets collection. The
705 * original code is included below in an #if 0/#endif block.
707 * I modified it to avoid the possibility of overflow in the wgap
708 * calculation, as well as to reduce the generated code size with
711 void qsort_r(void *base,
714 __compar_d_fn_t comp,
717 size_t wgap, i, j, k;
720 if ((nel > 1) && (width > 0)) {
721 assert(nel <= ((size_t)(-1)) / width); /* check for overflow */
725 } while (wgap < (nel-1)/3);
726 /* From the above, we know that either wgap == 1 < nel or */
727 /* ((wgap-1)/3 < (int) ((nel-1)/3) <= (nel-1)/3 ==> wgap < nel. */
728 wgap *= width; /* So this can not overflow if wnel doesn't. */
729 nel *= width; /* Convert nel to 'wnel' */
739 a = j + ((char *)base);
741 if ((*comp)(a, b, arg) <= 0) {
753 wgap = (wgap - width)/3;
757 libc_hidden_def(qsort_r)
759 /* ---------- original snippets version below ---------- */
763 ** ssort() -- Fast, small, qsort()-compatible Shell sort
765 ** by Ray Gardner, public domain 5/90
770 void ssort(void *base,
773 int (*comp)(const void *, const void *))
775 size_t wnel, gap, wgap, i, j, k;
779 for (gap = 0; ++gap < nel;)
781 while ((gap /= 3) != 0) {
783 for (i = wgap; i < wnel; i += width) {
784 for (j = i - wgap; ;j -= wgap) {
785 a = j + (char *)base;
787 if ((*comp)(a, b) <= 0)
806 void qsort(void *base,
811 return qsort_r (base, nel, width, (__compar_d_fn_t) comp, NULL);
813 libc_hidden_def(qsort)
816 /**********************************************************************/
817 #ifdef L__stdlib_mb_cur_max
819 size_t _stdlib_mb_cur_max(void)
821 #ifdef __CTYPE_HAS_UTF_8_LOCALES
822 return __UCLIBC_CURLOCALE->mb_cur_max;
824 #ifdef __CTYPE_HAS_8_BIT_LOCALES
825 #ifdef __UCLIBC_MJN3_ONLY__
826 #warning need to change this when/if transliteration is implemented
832 libc_hidden_def(_stdlib_mb_cur_max)
836 #ifdef __UCLIBC_HAS_LOCALE__
838 * The following function return 1 if the encoding is stateful, 0 if stateless.
839 * To note, until now all the supported encoding are stateless.
842 static __always_inline int is_stateful(unsigned char encoding)
846 case __ctype_encoding_7_bit:
847 case __ctype_encoding_utf8:
848 case __ctype_encoding_8_bit:
856 #define is_stateful(encoding) 0
859 /**********************************************************************/
863 int mblen(register const char *s, size_t n)
865 static mbstate_t state;
871 In this case we have to return 0 because the only multibyte supported encoding
872 is utf-8, that is a stateless encoding. See mblen() documentation.
874 return is_stateful(ENCODING);
878 /* According to the ISO C 89 standard this is the expected behaviour. */
881 if ((r = mbrlen(s, n, &state)) == (size_t) -2) {
882 /* TODO: Should we set an error state? */
883 state.__wc = 0xffffU; /* Make sure we're in an error state. */
884 return -1; /* TODO: Change error code above? */
890 /**********************************************************************/
894 int mbtowc(wchar_t *__restrict pwc, register const char *__restrict s, size_t n)
896 static mbstate_t state;
902 In this case we have to return 0 because the only multibyte supported encoding
903 is utf-8, that is a stateless encoding. See mbtowc() documentation.
906 return is_stateful(ENCODING);
910 /* According to the ISO C 89 standard this is the expected behaviour. */
913 if ((r = mbrtowc(pwc, s, n, &state)) == (size_t) -2) {
914 /* TODO: Should we set an error state? */
915 state.__wc = 0xffffU; /* Make sure we're in an error state. */
916 return -1; /* TODO: Change error code above? */
922 /**********************************************************************/
925 /* Note: We completely ignore state in all currently supported conversions. */
928 int wctomb(register char *__restrict s, wchar_t swc)
933 In this case we have to return 0 because the only multibyte supported encoding
934 is utf-8, that is a stateless encoding. See wctomb() documentation.
937 is_stateful(ENCODING)
938 : ((ssize_t) wcrtomb(s, swc, NULL));
942 /**********************************************************************/
946 size_t mbstowcs(wchar_t * __restrict pwcs, const char * __restrict s, size_t n)
949 const char *e = s; /* Needed because of restrict. */
951 state.__mask = 0; /* Always start in initial shift state. */
952 return mbsrtowcs(pwcs, &e, n, &state);
956 /**********************************************************************/
959 /* Note: We completely ignore state in all currently supported conversions. */
962 size_t wcstombs(char * __restrict s, const wchar_t * __restrict pwcs, size_t n)
964 const wchar_t *e = pwcs; /* Needed because of restrict. */
966 return wcsrtombs(s, &e, n, NULL);
970 /**********************************************************************/
971 #if defined(L_wcstol) || defined(L_wcstol_l)
973 long __XL_NPP(wcstol)(const wchar_t * __restrict str,
974 wchar_t ** __restrict endptr, int base __LOCALE_PARAM)
976 return __XL_NPP(_stdlib_wcsto_l)(str, endptr, base, 1 __LOCALE_ARG);
979 #if (ULONG_MAX == UINTMAX_MAX) && !defined(L_wcstol_l)
980 strong_alias(wcstol,wcstoimax)
983 #if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
984 strong_alias_untyped(__XL_NPP(wcstol),__XL_NPP(wcstoll))
988 /**********************************************************************/
989 #if defined(L_wcstoll) || defined(L_wcstoll_l)
991 #if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
993 long long __XL_NPP(wcstoll)(const wchar_t * __restrict str,
994 wchar_t ** __restrict endptr, int base
997 return (long long) __XL_NPP(_stdlib_wcsto_ll)(str, endptr, base, 1 __LOCALE_ARG);
1000 #if !defined(L_wcstoll_l)
1001 #if (ULLONG_MAX == UINTMAX_MAX)
1002 strong_alias(wcstoll,wcstoimax)
1004 strong_alias(wcstoll,wcstoq)
1007 #endif /* defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX) */
1010 /**********************************************************************/
1011 #if defined(L_wcstoul) || defined(L_wcstoul_l)
1013 unsigned long __XL_NPP(wcstoul)(const wchar_t * __restrict str,
1014 wchar_t ** __restrict endptr, int base
1017 return __XL_NPP(_stdlib_wcsto_l)(str, endptr, base, 0 __LOCALE_ARG);
1020 #if (ULONG_MAX == UINTMAX_MAX) && !defined(L_wcstoul_l)
1021 strong_alias(wcstoul,wcstoumax)
1024 #if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
1025 strong_alias_untyped(__XL_NPP(wcstoul),__XL_NPP(wcstoull))
1029 /**********************************************************************/
1030 #if defined(L_wcstoull) || defined(L_wcstoull_l)
1032 #if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
1034 unsigned long long __XL_NPP(wcstoull)(const wchar_t * __restrict str,
1035 wchar_t ** __restrict endptr, int base
1038 return __XL_NPP(_stdlib_wcsto_ll)(str, endptr, base, 0 __LOCALE_ARG);
1041 #if !defined(L_wcstoull_l)
1042 #if (ULLONG_MAX == UINTMAX_MAX)
1043 strong_alias(wcstoull,wcstoumax)
1045 strong_alias(wcstoull,wcstouq)
1048 #endif /* defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX) */
1051 /**********************************************************************/