• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/usr/include/bits/
1/*  Copyright (C) 2002     Manuel Novoa III
2 *
3 *  This library is free software; you can redistribute it and/or
4 *  modify it under the terms of the GNU Lesser General Public
5 *  License as published by the Free Software Foundation; either
6 *  version 2.1 of the License, or (at your option) any later version.
7 *
8 *  The GNU C Library is distributed in the hope that it will be useful,
9 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 *  Lesser General Public License for more details.
12 *
13 *  You should have received a copy of the GNU Lesser General Public
14 *  License along with the GNU C Library; if not, write to the Free
15 *  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
16 *  02111-1307 USA.
17 */
18
19/*  ATTENTION!   ATTENTION!   ATTENTION!   ATTENTION!   ATTENTION!
20 *
21 *  Besides uClibc, I'm using this code in my libc for elks, which is
22 *  a 16-bit environment with a fairly limited compiler.  It would make
23 *  things much easier for me if this file isn't modified unnecessarily.
24 *  In particular, please put any new or replacement functions somewhere
25 *  else, and modify the makefile to use your version instead.
26 *  Thanks.  Manuel
27 *
28 *  ATTENTION!   ATTENTION!   ATTENTION!   ATTENTION!   ATTENTION! */
29
30#if !defined(_CTYPE_H) && !defined(_WCTYPE_H)
31#error Always include <{w}ctype.h> rather than <bits/uClibc_ctype.h>
32#endif
33
34#ifndef _BITS_UCLIBC_CTYPE_H
35#define _BITS_UCLIBC_CTYPE_H
36
37
38/* Define some ctype macros valid for the C/POSIX locale. */
39
40/* ASCII ords of \t, \f, \n, \r, and \v are 9, 12, 10, 13, 11 respectively. */
41#define __C_isspace(c) \
42	((sizeof(c) == sizeof(char)) \
43	 ? ((((c) == ' ') || (((unsigned char)((c) - 9)) <= (13 - 9)))) \
44	 : ((((c) == ' ') || (((unsigned int)((c) - 9)) <= (13 - 9)))))
45#define __C_isblank(c) (((c) == ' ') || ((c) == '\t'))
46#define __C_isdigit(c) \
47	((sizeof(c) == sizeof(char)) \
48	 ? (((unsigned char)((c) - '0')) < 10) \
49	 : (((unsigned int)((c) - '0')) < 10))
50#define __C_isxdigit(c) \
51	(__C_isdigit(c) \
52	 || ((sizeof(c) == sizeof(char)) \
53		 ? (((unsigned char)((((c)) | 0x20) - 'a')) < 6) \
54		 : (((unsigned int)((((c)) | 0x20) - 'a')) < 6)))
55#define __C_iscntrl(c) \
56	((sizeof(c) == sizeof(char)) \
57	 ? ((((unsigned char)(c)) < 0x20) || ((c) == 0x7f)) \
58	 : ((((unsigned int)(c)) < 0x20) || ((c) == 0x7f)))
59#define __C_isalpha(c) \
60	((sizeof(c) == sizeof(char)) \
61	 ? (((unsigned char)(((c) | 0x20) - 'a')) < 26) \
62	 : (((unsigned int)(((c) | 0x20) - 'a')) < 26))
63#define __C_isalnum(c) (__C_isalpha(c) || __C_isdigit(c))
64#define __C_isprint(c) \
65	((sizeof(c) == sizeof(char)) \
66	 ? (((unsigned char)((c) - 0x20)) <= (0x7e - 0x20)) \
67	 : (((unsigned int)((c) - 0x20)) <= (0x7e - 0x20)))
68#define __C_islower(c) \
69	((sizeof(c) == sizeof(char)) \
70	 ? (((unsigned char)((c) - 'a')) < 26) \
71	 : (((unsigned int)((c) - 'a')) < 26))
72#define __C_isupper(c) \
73	((sizeof(c) == sizeof(char)) \
74	 ? (((unsigned char)((c) - 'A')) < 26) \
75	 : (((unsigned int)((c) - 'A')) < 26))
76#define __C_ispunct(c) \
77	((!__C_isalnum(c)) \
78	 && ((sizeof(c) == sizeof(char)) \
79		 ? (((unsigned char)((c) - 0x21)) <= (0x7e - 0x21)) \
80		 : (((unsigned int)((c) - 0x21)) <= (0x7e - 0x21))))
81#define __C_isgraph(c) \
82	((sizeof(c) == sizeof(char)) \
83	 ? (((unsigned char)((c) - 0x21)) <= (0x7e - 0x21)) \
84	 : (((unsigned int)((c) - 0x21)) <= (0x7e - 0x21)))
85
86#define __C_tolower(c) (__C_isupper(c) ? ((c) | 0x20) : (c))
87#define __C_toupper(c) (__C_islower(c) ? ((c) ^ 0x20) : (c))
88
89/**********************************************************************/
90__BEGIN_DECLS
91
92
93/* Now some non-ansi/iso c99 macros. */
94
95#ifdef __UCLIBC_SUSV4_LEGACY__
96#define __isascii(c) (((c) & ~0x7f) == 0)
97#define __toascii(c) ((c) & 0x7f)
98/* Works correctly *only* on lowercase letters! */
99#define _toupper(c) ((c) ^ 0x20)
100/* Works correctly *only* on letters (of any case) and numbers */
101#define _tolower(c) ((c) | 0x20)
102#endif
103
104__END_DECLS
105
106/**********************************************************************/
107#ifdef __GNUC__
108
109# define __body_C_macro(f,args)  __C_ ## f args
110
111# define __body(f,c) \
112(__extension__ ({ \
113	int __res; \
114	if (sizeof(c) > sizeof(char)) { \
115		int __c = (c); \
116		__res = __body_C_macro(f,(__c)); \
117	} else { \
118		unsigned char __c = (c); \
119		__res = __body_C_macro(f,(__c)); \
120	} \
121	__res; \
122}))
123
124# define __isspace(c)   __body(isspace,c)
125# define __isblank(c)   __body(isblank,c)
126# define __isdigit(c)   __body(isdigit,c)
127# define __isxdigit(c)  __body(isxdigit,c)
128# define __iscntrl(c)   __body(iscntrl,c)
129# define __isalpha(c)   __body(isalpha,c)
130# define __isalnum(c)   __body(isalnum,c)
131# define __isprint(c)   __body(isprint,c)
132# define __islower(c)   __body(islower,c)
133# define __isupper(c)   __body(isupper,c)
134# define __ispunct(c)   __body(ispunct,c)
135# define __isgraph(c)   __body(isgraph,c)
136
137/*locale-aware ctype.h has no __tolower, why stub locale
138 *tries to have it? remove after 0.9.31
139 *# define __tolower(c) __body(tolower,c)
140 *# define __toupper(c) __body(toupper,c)
141 */
142
143/* Do not combine in one #if - unifdef tool is not that clever */
144# ifndef __cplusplus
145
146#  define isspace(c)    __isspace(c)
147#  define isblank(c)    __isblank(c)
148#  define isdigit(c)    __isdigit(c)
149#  define isxdigit(c)   __isxdigit(c)
150#  define iscntrl(c)    __iscntrl(c)
151#  define isalpha(c)    __isalpha(c)
152#  define isalnum(c)    __isalnum(c)
153#  define isprint(c)    __isprint(c)
154#  define islower(c)    __islower(c)
155#  define isupper(c)    __isupper(c)
156#  define ispunct(c)    __ispunct(c)
157#  define isgraph(c)    __isgraph(c)
158
159#  define tolower(c)    __body(tolower,c)
160#  define toupper(c)    __body(toupper,c)
161
162# endif
163
164#else  /* !_GNUC__ */
165
166# ifndef __cplusplus
167
168/* These macros should be safe from side effects!
169 * (not all __C_xxx macros are) */
170#  define isdigit(c)    __C_isdigit(c)
171#  define isalpha(c)    __C_isalpha(c)
172#  define isprint(c)    __C_isprint(c)
173#  define islower(c)    __C_islower(c)
174#  define isupper(c)    __C_isupper(c)
175#  define isgraph(c)    __C_isgraph(c)
176
177# endif
178
179#endif /* __GNUC__ */
180/**********************************************************************/
181
182
183#endif /* _BITS_UCLIBC_CTYPE_H */
184