Merge branch 'vendor/OPENSSH'
[dragonfly.git] / sys / contrib / dev / acpica / source / include / acclib.h
1 /******************************************************************************
2  *
3  * Name: acclib.h -- C library support. Prototypes for the (optional) local
4  *                   implementations of required C library functions.
5  *
6  *****************************************************************************/
7
8 /*
9  * Copyright (C) 2000 - 2016, Intel Corp.
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions, and the following disclaimer,
17  *    without modification.
18  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19  *    substantially similar to the "NO WARRANTY" disclaimer below
20  *    ("Disclaimer") and any redistribution must be conditioned upon
21  *    including a substantially similar Disclaimer requirement for further
22  *    binary redistribution.
23  * 3. Neither the names of the above-listed copyright holders nor the names
24  *    of any contributors may be used to endorse or promote products derived
25  *    from this software without specific prior written permission.
26  *
27  * Alternatively, this software may be distributed under the terms of the
28  * GNU General Public License ("GPL") version 2 as published by the Free
29  * Software Foundation.
30  *
31  * NO WARRANTY
32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42  * POSSIBILITY OF SUCH DAMAGES.
43  */
44
45 #ifndef _ACCLIB_H
46 #define _ACCLIB_H
47
48
49 /*
50  * Prototypes and macros for local implementations of C library functions
51  */
52
53 /* is* functions. The AcpiGbl_Ctypes array is defined in utclib.c */
54
55 extern const UINT8 AcpiGbl_Ctypes[];
56
57 #define _ACPI_XA     0x00    /* extra alphabetic - not supported */
58 #define _ACPI_XS     0x40    /* extra space */
59 #define _ACPI_BB     0x00    /* BEL, BS, etc. - not supported */
60 #define _ACPI_CN     0x20    /* CR, FF, HT, NL, VT */
61 #define _ACPI_DI     0x04    /* '0'-'9' */
62 #define _ACPI_LO     0x02    /* 'a'-'z' */
63 #define _ACPI_PU     0x10    /* punctuation */
64 #define _ACPI_SP     0x08    /* space, tab, CR, LF, VT, FF */
65 #define _ACPI_UP     0x01    /* 'A'-'Z' */
66 #define _ACPI_XD     0x80    /* '0'-'9', 'A'-'F', 'a'-'f' */
67
68 #define isdigit(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_DI))
69 #define isspace(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_SP))
70 #define isxdigit(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_XD))
71 #define isupper(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_UP))
72 #define islower(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO))
73 #define isprint(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU))
74 #define isalpha(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
75
76 /* Error code */
77
78 #define EPERM            1 /* Operation not permitted */
79 #define ENOENT           2 /* No such file or directory */
80 #define EINTR            4 /* Interrupted system call */
81 #define EIO              5 /* I/O error */
82 #define EBADF            9 /* Bad file number */
83 #define EAGAIN          11 /* Try again */
84 #define ENOMEM          12 /* Out of memory */
85 #define EACCES          13 /* Permission denied */
86 #define EFAULT          14 /* Bad address */
87 #define EBUSY           16 /* Device or resource busy */
88 #define EEXIST          17 /* File exists */
89 #define ENODEV          19 /* No such device */
90 #define EINVAL          22 /* Invalid argument */
91 #define EPIPE           32 /* Broken pipe */
92 #define ERANGE          34 /* Math result not representable */
93
94 /* Strings */
95
96 char *
97 strcat (
98     char                    *DstString,
99     const char              *SrcString);
100
101 char *
102 strchr (
103     const char              *String,
104     int                     ch);
105
106 char *
107 strcpy (
108     char                    *DstString,
109     const char              *SrcString);
110
111 int
112 strcmp (
113     const char              *String1,
114     const char              *String2);
115
116 ACPI_SIZE
117 strlen (
118     const char              *String);
119
120 char *
121 strncat (
122     char                    *DstString,
123     const char              *SrcString,
124     ACPI_SIZE               Count);
125
126 int
127 strncmp (
128     const char              *String1,
129     const char              *String2,
130     ACPI_SIZE               Count);
131
132 char *
133 strncpy (
134     char                    *DstString,
135     const char              *SrcString,
136     ACPI_SIZE               Count);
137
138 char *
139 strstr (
140     char                    *String1,
141     char                    *String2);
142
143
144 /* Conversion */
145
146 UINT32
147 strtoul (
148     const char              *String,
149     char                    **Terminator,
150     UINT32                  Base);
151
152
153 /* Memory */
154
155 int
156 memcmp (
157     void                    *Buffer1,
158     void                    *Buffer2,
159     ACPI_SIZE               Count);
160
161 void *
162 memcpy (
163     void                    *Dest,
164     const void              *Src,
165     ACPI_SIZE               Count);
166
167 void *
168 memset (
169     void                    *Dest,
170     int                     Value,
171     ACPI_SIZE               Count);
172
173
174 /* upper/lower case */
175
176 int
177 tolower (
178     int                     c);
179
180 int
181 toupper (
182     int                     c);
183
184 /*
185  * utprint - printf/vprintf output functions
186  */
187 const char *
188 AcpiUtScanNumber (
189     const char              *String,
190     UINT64                  *NumberPtr);
191
192 const char *
193 AcpiUtPrintNumber (
194     char                    *String,
195     UINT64                  Number);
196
197 int
198 vsnprintf (
199     char                    *String,
200     ACPI_SIZE               Size,
201     const char              *Format,
202     va_list                 Args);
203
204 int
205 snprintf (
206     char                    *String,
207     ACPI_SIZE               Size,
208     const char              *Format,
209     ...);
210
211 int
212 sprintf (
213     char                    *String,
214     const char              *Format,
215     ...);
216
217 #ifdef ACPI_APPLICATION
218 #define SEEK_SET            0
219 #define SEEK_CUR            1
220 #define SEEK_END            2
221
222 /*
223  * NOTE: Currently we only need to update errno for file IOs. Other
224  *       Clibrary invocations in ACPICA do not make descisions according to
225  *       the errno.
226  */
227 extern int errno;
228
229 int
230 vprintf (
231     const char              *Format,
232     va_list                 Args);
233
234 int
235 printf (
236     const char              *Format,
237     ...);
238
239 int
240 vfprintf (
241     FILE                    *File,
242     const char              *Format,
243     va_list                 Args);
244
245 int
246 fprintf (
247     FILE                    *File,
248     const char              *Format,
249     ...);
250
251 FILE *
252 fopen (
253     const char              *Path,
254     const char              *Modes);
255
256 void
257 fclose (
258     FILE                    *File);
259
260 int
261 fread (
262     void                    *Buffer,
263     ACPI_SIZE               Size,
264     ACPI_SIZE               Count,
265     FILE                    *File);
266
267 int
268 fwrite (
269     void                    *Buffer,
270     ACPI_SIZE               Size,
271     ACPI_SIZE               Count,
272     FILE                    *File);
273
274 int
275 fseek (
276     FILE                    *File,
277     long                    Offset,
278     int                     From);
279
280 long
281 ftell (
282     FILE                    *File);
283 #endif
284
285 #endif /* _ACCLIB_H */