* ctype/ctype.h (__ctype_b, __ctype_toupper, __ctype_tolower):
[platform/upstream/glibc.git] / include / ctype.h
1 #ifndef _CTYPE_H
2
3 extern int __isctype (int __c, int __mask);
4
5 # ifndef NOT_IN_libc
6
7 /* These accessors are used by the optimized macros to find the
8    thread-local cache of ctype information from the current thread's
9    locale.  For inside libc, define them as inlines using the _NL_CURRENT
10    accessors.  We don't use _NL_CURRENT_LOCALE->__ctype_b here because we
11    want to cause a link-time ref to _nl_current_LC_CTYPE under
12    NL_CURRENT_INDIRECT.  */
13
14 #  include "../locale/localeinfo.h"
15 #  include <bits/libc-tsd.h>
16
17 #  ifndef CTYPE_EXTERN_INLINE   /* Used by ctype/ctype-info.c, which see.  */
18 #   define CTYPE_EXTERN_INLINE extern inline
19 #  endif
20
21 __libc_tsd_define (extern, CTYPE_B)
22 __libc_tsd_define (extern, CTYPE_TOUPPER)
23 __libc_tsd_define (extern, CTYPE_TOLOWER)
24
25 CTYPE_EXTERN_INLINE const uint16_t ** __attribute__ ((const))
26 __ctype_b_loc (void)
27 {
28   const uint16_t **tablep =
29     (const uint16_t **) __libc_tsd_address (CTYPE_B);
30   if (__builtin_expect (*tablep == NULL, 0))
31     *tablep = (const uint16_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_CLASS) + 128;
32   return tablep;
33 }
34
35 CTYPE_EXTERN_INLINE const int32_t ** __attribute__ ((const))
36 __ctype_toupper_loc (void)
37 {
38   const int32_t **tablep =
39     (const int32_t **) __libc_tsd_address (CTYPE_TOUPPER);
40   if (__builtin_expect (*tablep == NULL, 0))
41     *tablep = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOUPPER) + 128);
42   return tablep;
43 }
44
45 CTYPE_EXTERN_INLINE const int32_t ** __attribute__ ((const))
46 __ctype_tolower_loc (void)
47 {
48   const int32_t **tablep =
49     (const int32_t **) __libc_tsd_address (CTYPE_TOLOWER);
50   if (__builtin_expect (*tablep == NULL, 0))
51     *tablep = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOLOWER) + 128);
52   return tablep;
53 }
54
55 # endif /* Not NOT_IN_libc.  */
56
57 # include <ctype/ctype.h>
58
59 #endif /* ctype.h */