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