ia64/xen-unstable

annotate extras/mini-os/include/ctype.h @ 6714:df1348e72390

Xenbus implementation ported from Linux to Mini-os, simple thread support introduced
to simplify the porting. 64 bit version of Mini-os now compiles, but does not work
because of the pagetables and some bits of scheduler not being written.

Signed-off-by: Grzegorz Milos <gm281@cam.ac.uk>
author kaf24@firebug.cl.cam.ac.uk
date Fri Sep 09 09:24:25 2005 +0000 (2005-09-09)
parents
children cdfa7dd00c44
rev   line source
kaf24@6714 1 #ifndef _CTYPE_H
kaf24@6714 2 #define _CTYPE_H
kaf24@6714 3
kaf24@6714 4 /*
kaf24@6714 5 * NOTE! This ctype does not handle EOF like the standard C
kaf24@6714 6 * library is required to.
kaf24@6714 7 */
kaf24@6714 8
kaf24@6714 9 #define _U 0x01 /* upper */
kaf24@6714 10 #define _L 0x02 /* lower */
kaf24@6714 11 #define _D 0x04 /* digit */
kaf24@6714 12 #define _C 0x08 /* cntrl */
kaf24@6714 13 #define _P 0x10 /* punct */
kaf24@6714 14 #define _S 0x20 /* white space (space/lf/tab) */
kaf24@6714 15 #define _X 0x40 /* hex digit */
kaf24@6714 16 #define _SP 0x80 /* hard space (0x20) */
kaf24@6714 17
kaf24@6714 18
kaf24@6714 19 unsigned char _ctype[] = {
kaf24@6714 20 _C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */
kaf24@6714 21 _C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */
kaf24@6714 22 _C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */
kaf24@6714 23 _C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */
kaf24@6714 24 _S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */
kaf24@6714 25 _P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */
kaf24@6714 26 _D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */
kaf24@6714 27 _D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */
kaf24@6714 28 _P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */
kaf24@6714 29 _U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */
kaf24@6714 30 _U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */
kaf24@6714 31 _U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */
kaf24@6714 32 _P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */
kaf24@6714 33 _L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */
kaf24@6714 34 _L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */
kaf24@6714 35 _L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */
kaf24@6714 36 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */
kaf24@6714 37 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */
kaf24@6714 38 _S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 160-175 */
kaf24@6714 39 _P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 176-191 */
kaf24@6714 40 _U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U, /* 192-207 */
kaf24@6714 41 _U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L, /* 208-223 */
kaf24@6714 42 _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */
kaf24@6714 43 _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */
kaf24@6714 44
kaf24@6714 45 #define __ismask(x) (_ctype[(int)(unsigned char)(x)])
kaf24@6714 46
kaf24@6714 47 #define isalnum(c) ((__ismask(c)&(_U|_L|_D)) != 0)
kaf24@6714 48 #define isalpha(c) ((__ismask(c)&(_U|_L)) != 0)
kaf24@6714 49 #define iscntrl(c) ((__ismask(c)&(_C)) != 0)
kaf24@6714 50 #define isdigit(c) ((__ismask(c)&(_D)) != 0)
kaf24@6714 51 #define isgraph(c) ((__ismask(c)&(_P|_U|_L|_D)) != 0)
kaf24@6714 52 #define islower(c) ((__ismask(c)&(_L)) != 0)
kaf24@6714 53 #define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0)
kaf24@6714 54 #define ispunct(c) ((__ismask(c)&(_P)) != 0)
kaf24@6714 55 #define isspace(c) ((__ismask(c)&(_S)) != 0)
kaf24@6714 56 #define isupper(c) ((__ismask(c)&(_U)) != 0)
kaf24@6714 57 #define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0)
kaf24@6714 58
kaf24@6714 59 #define isascii(c) (((unsigned char)(c))<=0x7f)
kaf24@6714 60 #define toascii(c) (((unsigned char)(c))&0x7f)
kaf24@6714 61
kaf24@6714 62 static inline unsigned char __tolower(unsigned char c)
kaf24@6714 63 {
kaf24@6714 64 if (isupper(c))
kaf24@6714 65 c -= 'A'-'a';
kaf24@6714 66 return c;
kaf24@6714 67 }
kaf24@6714 68
kaf24@6714 69 static inline unsigned char __toupper(unsigned char c)
kaf24@6714 70 {
kaf24@6714 71 if (islower(c))
kaf24@6714 72 c -= 'a'-'A';
kaf24@6714 73 return c;
kaf24@6714 74 }
kaf24@6714 75
kaf24@6714 76 #define tolower(c) __tolower(c)
kaf24@6714 77 #define toupper(c) __toupper(c)
kaf24@6714 78
kaf24@6714 79 #endif