acclib.h revision 284563
1284563Sjkim/******************************************************************************
2284563Sjkim *
3284563Sjkim * Name: acclib.h -- C library support. Prototypes for the (optional) local
4284563Sjkim *                   implementations of required C library functions.
5284563Sjkim *
6284563Sjkim *****************************************************************************/
7284563Sjkim
8284563Sjkim/*
9284563Sjkim * Copyright (C) 2000 - 2015, Intel Corp.
10284563Sjkim * All rights reserved.
11284563Sjkim *
12284563Sjkim * Redistribution and use in source and binary forms, with or without
13284563Sjkim * modification, are permitted provided that the following conditions
14284563Sjkim * are met:
15284563Sjkim * 1. Redistributions of source code must retain the above copyright
16284563Sjkim *    notice, this list of conditions, and the following disclaimer,
17284563Sjkim *    without modification.
18284563Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19284563Sjkim *    substantially similar to the "NO WARRANTY" disclaimer below
20284563Sjkim *    ("Disclaimer") and any redistribution must be conditioned upon
21284563Sjkim *    including a substantially similar Disclaimer requirement for further
22284563Sjkim *    binary redistribution.
23284563Sjkim * 3. Neither the names of the above-listed copyright holders nor the names
24284563Sjkim *    of any contributors may be used to endorse or promote products derived
25284563Sjkim *    from this software without specific prior written permission.
26284563Sjkim *
27284563Sjkim * Alternatively, this software may be distributed under the terms of the
28284563Sjkim * GNU General Public License ("GPL") version 2 as published by the Free
29284563Sjkim * Software Foundation.
30284563Sjkim *
31284563Sjkim * NO WARRANTY
32284563Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33284563Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34284563Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35284563Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36284563Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37284563Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38284563Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39284563Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40284563Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41284563Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42284563Sjkim * POSSIBILITY OF SUCH DAMAGES.
43284563Sjkim */
44284563Sjkim
45284563Sjkim#ifndef _ACCLIB_H
46284563Sjkim#define _ACCLIB_H
47284563Sjkim
48284563Sjkim
49284563Sjkim/*
50284563Sjkim * Prototypes and macros for local implementations of C library functions
51284563Sjkim */
52284563Sjkim
53284563Sjkim/* is* functions. The AcpiGbl_Ctypes array is defined in utclib.c */
54284563Sjkim
55284563Sjkimextern const UINT8 AcpiGbl_Ctypes[];
56284563Sjkim
57284563Sjkim#define _ACPI_XA     0x00    /* extra alphabetic - not supported */
58284563Sjkim#define _ACPI_XS     0x40    /* extra space */
59284563Sjkim#define _ACPI_BB     0x00    /* BEL, BS, etc. - not supported */
60284563Sjkim#define _ACPI_CN     0x20    /* CR, FF, HT, NL, VT */
61284563Sjkim#define _ACPI_DI     0x04    /* '0'-'9' */
62284563Sjkim#define _ACPI_LO     0x02    /* 'a'-'z' */
63284563Sjkim#define _ACPI_PU     0x10    /* punctuation */
64284563Sjkim#define _ACPI_SP     0x08    /* space, tab, CR, LF, VT, FF */
65284563Sjkim#define _ACPI_UP     0x01    /* 'A'-'Z' */
66284563Sjkim#define _ACPI_XD     0x80    /* '0'-'9', 'A'-'F', 'a'-'f' */
67284563Sjkim
68284563Sjkim#define isdigit(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_DI))
69284563Sjkim#define isspace(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_SP))
70284563Sjkim#define isxdigit(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_XD))
71284563Sjkim#define isupper(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_UP))
72284563Sjkim#define islower(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO))
73284563Sjkim#define isprint(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU))
74284563Sjkim#define isalpha(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
75284563Sjkim
76284563Sjkim
77284563Sjkim/* Strings */
78284563Sjkim
79284563Sjkimchar *
80284563Sjkimstrcat (
81284563Sjkim    char                    *DstString,
82284563Sjkim    const char              *SrcString);
83284563Sjkim
84284563Sjkimchar *
85284563Sjkimstrchr (
86284563Sjkim    const char              *String,
87284563Sjkim    int                     ch);
88284563Sjkim
89284563Sjkimchar *
90284563Sjkimstrcpy (
91284563Sjkim    char                    *DstString,
92284563Sjkim    const char              *SrcString);
93284563Sjkim
94284563Sjkimint
95284563Sjkimstrcmp (
96284563Sjkim    const char              *String1,
97284563Sjkim    const char              *String2);
98284563Sjkim
99284563SjkimACPI_SIZE
100284563Sjkimstrlen (
101284563Sjkim    const char              *String);
102284563Sjkim
103284563Sjkimchar *
104284563Sjkimstrncat (
105284563Sjkim    char                    *DstString,
106284563Sjkim    const char              *SrcString,
107284563Sjkim    ACPI_SIZE               Count);
108284563Sjkim
109284563Sjkimint
110284563Sjkimstrncmp (
111284563Sjkim    const char              *String1,
112284563Sjkim    const char              *String2,
113284563Sjkim    ACPI_SIZE               Count);
114284563Sjkim
115284563Sjkimchar *
116284563Sjkimstrncpy (
117284563Sjkim    char                    *DstString,
118284563Sjkim    const char              *SrcString,
119284563Sjkim    ACPI_SIZE               Count);
120284563Sjkim
121284563Sjkimchar *
122284563Sjkimstrstr (
123284563Sjkim    char                    *String1,
124284563Sjkim    char                    *String2);
125284563Sjkim
126284563Sjkim
127284563Sjkim/* Conversion */
128284563Sjkim
129284563SjkimUINT32
130284563Sjkimstrtoul (
131284563Sjkim    const char              *String,
132284563Sjkim    char                    **Terminator,
133284563Sjkim    UINT32                  Base);
134284563Sjkim
135284563Sjkim
136284563Sjkim/* Memory */
137284563Sjkim
138284563Sjkimint
139284563Sjkimmemcmp (
140284563Sjkim    void                    *Buffer1,
141284563Sjkim    void                    *Buffer2,
142284563Sjkim    ACPI_SIZE               Count);
143284563Sjkim
144284563Sjkimvoid *
145284563Sjkimmemcpy (
146284563Sjkim    void                    *Dest,
147284563Sjkim    const void              *Src,
148284563Sjkim    ACPI_SIZE               Count);
149284563Sjkim
150284563Sjkimvoid *
151284563Sjkimmemset (
152284563Sjkim    void                    *Dest,
153284563Sjkim    int                     Value,
154284563Sjkim    ACPI_SIZE               Count);
155284563Sjkim
156284563Sjkim
157284563Sjkim/* upper/lower case */
158284563Sjkim
159284563Sjkimint
160284563Sjkimtolower (
161284563Sjkim    int                     c);
162284563Sjkim
163284563Sjkimint
164284563Sjkimtoupper (
165284563Sjkim    int                     c);
166284563Sjkim
167284563Sjkim#endif /* _ACCLIB_H */
168