acclib.h revision 1.1 1 1.1 christos /******************************************************************************
2 1.1 christos *
3 1.1 christos * Name: acclib.h -- C library support. Prototypes for the (optional) local
4 1.1 christos * implementations of required C library functions.
5 1.1 christos *
6 1.1 christos *****************************************************************************/
7 1.1 christos
8 1.1 christos /*
9 1.1 christos * Copyright (C) 2000 - 2015, Intel Corp.
10 1.1 christos * All rights reserved.
11 1.1 christos *
12 1.1 christos * Redistribution and use in source and binary forms, with or without
13 1.1 christos * modification, are permitted provided that the following conditions
14 1.1 christos * are met:
15 1.1 christos * 1. Redistributions of source code must retain the above copyright
16 1.1 christos * notice, this list of conditions, and the following disclaimer,
17 1.1 christos * without modification.
18 1.1 christos * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 1.1 christos * substantially similar to the "NO WARRANTY" disclaimer below
20 1.1 christos * ("Disclaimer") and any redistribution must be conditioned upon
21 1.1 christos * including a substantially similar Disclaimer requirement for further
22 1.1 christos * binary redistribution.
23 1.1 christos * 3. Neither the names of the above-listed copyright holders nor the names
24 1.1 christos * of any contributors may be used to endorse or promote products derived
25 1.1 christos * from this software without specific prior written permission.
26 1.1 christos *
27 1.1 christos * Alternatively, this software may be distributed under the terms of the
28 1.1 christos * GNU General Public License ("GPL") version 2 as published by the Free
29 1.1 christos * Software Foundation.
30 1.1 christos *
31 1.1 christos * NO WARRANTY
32 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 1.1 christos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 1.1 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 1.1 christos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 1.1 christos * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 1.1 christos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 1.1 christos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 1.1 christos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 1.1 christos * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 1.1 christos * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 1.1 christos * POSSIBILITY OF SUCH DAMAGES.
43 1.1 christos */
44 1.1 christos
45 1.1 christos #ifndef _ACCLIB_H
46 1.1 christos #define _ACCLIB_H
47 1.1 christos
48 1.1 christos
49 1.1 christos /*
50 1.1 christos * Prototypes and macros for local implementations of C library functions
51 1.1 christos */
52 1.1 christos
53 1.1 christos /* is* functions. The AcpiGbl_Ctypes array is defined in utclib.c */
54 1.1 christos
55 1.1 christos extern const UINT8 AcpiGbl_Ctypes[];
56 1.1 christos
57 1.1 christos #define _ACPI_XA 0x00 /* extra alphabetic - not supported */
58 1.1 christos #define _ACPI_XS 0x40 /* extra space */
59 1.1 christos #define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */
60 1.1 christos #define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */
61 1.1 christos #define _ACPI_DI 0x04 /* '0'-'9' */
62 1.1 christos #define _ACPI_LO 0x02 /* 'a'-'z' */
63 1.1 christos #define _ACPI_PU 0x10 /* punctuation */
64 1.1 christos #define _ACPI_SP 0x08 /* space, tab, CR, LF, VT, FF */
65 1.1 christos #define _ACPI_UP 0x01 /* 'A'-'Z' */
66 1.1 christos #define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */
67 1.1 christos
68 1.1 christos #define isdigit(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_DI))
69 1.1 christos #define isspace(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_SP))
70 1.1 christos #define isxdigit(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_XD))
71 1.1 christos #define isupper(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_UP))
72 1.1 christos #define islower(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO))
73 1.1 christos #define isprint(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU))
74 1.1 christos #define isalpha(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
75 1.1 christos
76 1.1 christos
77 1.1 christos /* Strings */
78 1.1 christos
79 1.1 christos char *
80 1.1 christos strcat (
81 1.1 christos char *DstString,
82 1.1 christos const char *SrcString);
83 1.1 christos
84 1.1 christos char *
85 1.1 christos strchr (
86 1.1 christos const char *String,
87 1.1 christos int ch);
88 1.1 christos
89 1.1 christos char *
90 1.1 christos strcpy (
91 1.1 christos char *DstString,
92 1.1 christos const char *SrcString);
93 1.1 christos
94 1.1 christos int
95 1.1 christos strcmp (
96 1.1 christos const char *String1,
97 1.1 christos const char *String2);
98 1.1 christos
99 1.1 christos ACPI_SIZE
100 1.1 christos strlen (
101 1.1 christos const char *String);
102 1.1 christos
103 1.1 christos char *
104 1.1 christos strncat (
105 1.1 christos char *DstString,
106 1.1 christos const char *SrcString,
107 1.1 christos ACPI_SIZE Count);
108 1.1 christos
109 1.1 christos int
110 1.1 christos strncmp (
111 1.1 christos const char *String1,
112 1.1 christos const char *String2,
113 1.1 christos ACPI_SIZE Count);
114 1.1 christos
115 1.1 christos char *
116 1.1 christos strncpy (
117 1.1 christos char *DstString,
118 1.1 christos const char *SrcString,
119 1.1 christos ACPI_SIZE Count);
120 1.1 christos
121 1.1 christos char *
122 1.1 christos strstr (
123 1.1 christos char *String1,
124 1.1 christos char *String2);
125 1.1 christos
126 1.1 christos
127 1.1 christos /* Conversion */
128 1.1 christos
129 1.1 christos UINT32
130 1.1 christos strtoul (
131 1.1 christos const char *String,
132 1.1 christos char **Terminator,
133 1.1 christos UINT32 Base);
134 1.1 christos
135 1.1 christos
136 1.1 christos /* Memory */
137 1.1 christos
138 1.1 christos int
139 1.1 christos memcmp (
140 1.1 christos void *Buffer1,
141 1.1 christos void *Buffer2,
142 1.1 christos ACPI_SIZE Count);
143 1.1 christos
144 1.1 christos void *
145 1.1 christos memcpy (
146 1.1 christos void *Dest,
147 1.1 christos const void *Src,
148 1.1 christos ACPI_SIZE Count);
149 1.1 christos
150 1.1 christos void *
151 1.1 christos memset (
152 1.1 christos void *Dest,
153 1.1 christos int Value,
154 1.1 christos ACPI_SIZE Count);
155 1.1 christos
156 1.1 christos
157 1.1 christos /* upper/lower case */
158 1.1 christos
159 1.1 christos int
160 1.1 christos tolower (
161 1.1 christos int c);
162 1.1 christos
163 1.1 christos int
164 1.1 christos toupper (
165 1.1 christos int c);
166 1.1 christos
167 1.1 christos #endif /* _ACCLIB_H */
168