acclib.h revision 284563
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 - 2015, 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 55extern 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 77/* Strings */ 78 79char * 80strcat ( 81 char *DstString, 82 const char *SrcString); 83 84char * 85strchr ( 86 const char *String, 87 int ch); 88 89char * 90strcpy ( 91 char *DstString, 92 const char *SrcString); 93 94int 95strcmp ( 96 const char *String1, 97 const char *String2); 98 99ACPI_SIZE 100strlen ( 101 const char *String); 102 103char * 104strncat ( 105 char *DstString, 106 const char *SrcString, 107 ACPI_SIZE Count); 108 109int 110strncmp ( 111 const char *String1, 112 const char *String2, 113 ACPI_SIZE Count); 114 115char * 116strncpy ( 117 char *DstString, 118 const char *SrcString, 119 ACPI_SIZE Count); 120 121char * 122strstr ( 123 char *String1, 124 char *String2); 125 126 127/* Conversion */ 128 129UINT32 130strtoul ( 131 const char *String, 132 char **Terminator, 133 UINT32 Base); 134 135 136/* Memory */ 137 138int 139memcmp ( 140 void *Buffer1, 141 void *Buffer2, 142 ACPI_SIZE Count); 143 144void * 145memcpy ( 146 void *Dest, 147 const void *Src, 148 ACPI_SIZE Count); 149 150void * 151memset ( 152 void *Dest, 153 int Value, 154 ACPI_SIZE Count); 155 156 157/* upper/lower case */ 158 159int 160tolower ( 161 int c); 162 163int 164toupper ( 165 int c); 166 167#endif /* _ACCLIB_H */ 168