Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:41

0001 /******************************************************************************
0002  *
0003  * Name: acclib.h -- C library support. Prototypes for the (optional) local
0004  *                   implementations of required C library functions.
0005  *
0006  *****************************************************************************/
0007 
0008 /******************************************************************************
0009  *
0010  * 1. Copyright Notice
0011  *
0012  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
0013  * All rights reserved.
0014  *
0015  * 2. License
0016  *
0017  * 2.1. This is your license from Intel Corp. under its intellectual property
0018  * rights. You may have additional license terms from the party that provided
0019  * you this software, covering your right to use that party's intellectual
0020  * property rights.
0021  *
0022  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0023  * copy of the source code appearing in this file ("Covered Code") an
0024  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0025  * base code distributed originally by Intel ("Original Intel Code") to copy,
0026  * make derivatives, distribute, use and display any portion of the Covered
0027  * Code in any form, with the right to sublicense such rights; and
0028  *
0029  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0030  * license (with the right to sublicense), under only those claims of Intel
0031  * patents that are infringed by the Original Intel Code, to make, use, sell,
0032  * offer to sell, and import the Covered Code and derivative works thereof
0033  * solely to the minimum extent necessary to exercise the above copyright
0034  * license, and in no event shall the patent license extend to any additions
0035  * to or modifications of the Original Intel Code. No other license or right
0036  * is granted directly or by implication, estoppel or otherwise;
0037  *
0038  * The above copyright and patent license is granted only if the following
0039  * conditions are met:
0040  *
0041  * 3. Conditions
0042  *
0043  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0044  * Redistribution of source code of any substantial portion of the Covered
0045  * Code or modification with rights to further distribute source must include
0046  * the above Copyright Notice, the above License, this list of Conditions,
0047  * and the following Disclaimer and Export Compliance provision. In addition,
0048  * Licensee must cause all Covered Code to which Licensee contributes to
0049  * contain a file documenting the changes Licensee made to create that Covered
0050  * Code and the date of any change. Licensee must include in that file the
0051  * documentation of any changes made by any predecessor Licensee. Licensee
0052  * must include a prominent statement that the modification is derived,
0053  * directly or indirectly, from Original Intel Code.
0054  *
0055  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0056  * Redistribution of source code of any substantial portion of the Covered
0057  * Code or modification without rights to further distribute source must
0058  * include the following Disclaimer and Export Compliance provision in the
0059  * documentation and/or other materials provided with distribution. In
0060  * addition, Licensee may not authorize further sublicense of source of any
0061  * portion of the Covered Code, and must include terms to the effect that the
0062  * license from Licensee to its licensee is limited to the intellectual
0063  * property embodied in the software Licensee provides to its licensee, and
0064  * not to intellectual property embodied in modifications its licensee may
0065  * make.
0066  *
0067  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0068  * substantial portion of the Covered Code or modification must reproduce the
0069  * above Copyright Notice, and the following Disclaimer and Export Compliance
0070  * provision in the documentation and/or other materials provided with the
0071  * distribution.
0072  *
0073  * 3.4. Intel retains all right, title, and interest in and to the Original
0074  * Intel Code.
0075  *
0076  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0077  * Intel shall be used in advertising or otherwise to promote the sale, use or
0078  * other dealings in products derived from or relating to the Covered Code
0079  * without prior written authorization from Intel.
0080  *
0081  * 4. Disclaimer and Export Compliance
0082  *
0083  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0084  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0085  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
0086  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
0087  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
0088  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0089  * PARTICULAR PURPOSE.
0090  *
0091  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0092  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0093  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0094  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0095  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0096  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
0097  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0098  * LIMITED REMEDY.
0099  *
0100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0101  * software or system incorporating such software without first obtaining any
0102  * required license or other approval from the U. S. Department of Commerce or
0103  * any other agency or department of the United States Government. In the
0104  * event Licensee exports any such software from the United States or
0105  * re-exports any such software from a foreign destination, Licensee shall
0106  * ensure that the distribution and export/re-export of the software is in
0107  * compliance with all laws, regulations, orders, or other restrictions of the
0108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0109  * any of its subsidiaries will export/re-export any technical data, process,
0110  * software, or service, directly or indirectly, to any country for which the
0111  * United States government or any agency thereof requires an export license,
0112  * other governmental approval, or letter of assurance, without first obtaining
0113  * such license, approval or letter.
0114  *
0115  *****************************************************************************
0116  *
0117  * Alternatively, you may choose to be licensed under the terms of the
0118  * following license:
0119  *
0120  * Redistribution and use in source and binary forms, with or without
0121  * modification, are permitted provided that the following conditions
0122  * are met:
0123  * 1. Redistributions of source code must retain the above copyright
0124  *    notice, this list of conditions, and the following disclaimer,
0125  *    without modification.
0126  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
0127  *    substantially similar to the "NO WARRANTY" disclaimer below
0128  *    ("Disclaimer") and any redistribution must be conditioned upon
0129  *    including a substantially similar Disclaimer requirement for further
0130  *    binary redistribution.
0131  * 3. Neither the names of the above-listed copyright holders nor the names
0132  *    of any contributors may be used to endorse or promote products derived
0133  *    from this software without specific prior written permission.
0134  *
0135  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0136  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0137  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0138  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0139  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0140  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0141  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0142  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0143  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0144  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0145  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0146  *
0147  * Alternatively, you may choose to be licensed under the terms of the
0148  * GNU General Public License ("GPL") version 2 as published by the Free
0149  * Software Foundation.
0150  *
0151  *****************************************************************************/
0152 
0153 #ifndef _ACCLIB_H
0154 #define _ACCLIB_H
0155 
0156 
0157 /*
0158  * Prototypes and macros for local implementations of C library functions
0159  */
0160 
0161 /* is* functions. The AcpiGbl_Ctypes array is defined in utclib.c */
0162 
0163 extern const UINT8 AcpiGbl_Ctypes[];
0164 
0165 #define _ACPI_XA     0x00    /* extra alphabetic - not supported */
0166 #define _ACPI_XS     0x40    /* extra space */
0167 #define _ACPI_BB     0x00    /* BEL, BS, etc. - not supported */
0168 #define _ACPI_CN     0x20    /* CR, FF, HT, NL, VT */
0169 #define _ACPI_DI     0x04    /* '0'-'9' */
0170 #define _ACPI_LO     0x02    /* 'a'-'z' */
0171 #define _ACPI_PU     0x10    /* punctuation */
0172 #define _ACPI_SP     0x08    /* space, tab, CR, LF, VT, FF */
0173 #define _ACPI_UP     0x01    /* 'A'-'Z' */
0174 #define _ACPI_XD     0x80    /* '0'-'9', 'A'-'F', 'a'-'f' */
0175 
0176 #define isdigit(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_DI))
0177 #define isspace(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_SP))
0178 #define isxdigit(c) (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_XD))
0179 #define isupper(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_UP))
0180 #define islower(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO))
0181 #define isprint(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU))
0182 #define isalpha(c)  (AcpiGbl_Ctypes[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
0183 
0184 /* Error code */
0185 
0186 #define EPERM            1 /* Operation not permitted */
0187 #define ENOENT           2 /* No such file or directory */
0188 #define EINTR            4 /* Interrupted system call */
0189 #define EIO              5 /* I/O error */
0190 #define EBADF            9 /* Bad file number */
0191 #define EAGAIN          11 /* Try again */
0192 #define ENOMEM          12 /* Out of memory */
0193 #define EACCES          13 /* Permission denied */
0194 #define EFAULT          14 /* Bad address */
0195 #define EBUSY           16 /* Device or resource busy */
0196 #define EEXIST          17 /* File exists */
0197 #define ENODEV          19 /* No such device */
0198 #define EINVAL          22 /* Invalid argument */
0199 #define EPIPE           32 /* Broken pipe */
0200 #define ERANGE          34 /* Math result not representable */
0201 
0202 /* Strings */
0203 
0204 char *
0205 strcat (
0206     char                    *DstString,
0207     const char              *SrcString);
0208 
0209 char *
0210 strchr (
0211     const char              *String,
0212     int                     ch);
0213 
0214 char *
0215 strpbrk (
0216     const char              *String,
0217     const char              *Delimiters);
0218 
0219 char *
0220 strtok (
0221     char                    *String,
0222     const char              *Delimiters);
0223 
0224 char *
0225 strcpy (
0226     char                    *DstString,
0227     const char              *SrcString);
0228 
0229 int
0230 strcmp (
0231     const char              *String1,
0232     const char              *String2);
0233 
0234 ACPI_SIZE
0235 strlen (
0236     const char              *String);
0237 
0238 char *
0239 strncat (
0240     char                    *DstString,
0241     const char              *SrcString,
0242     ACPI_SIZE               Count);
0243 
0244 int
0245 strncmp (
0246     const char              *String1,
0247     const char              *String2,
0248     ACPI_SIZE               Count);
0249 
0250 char *
0251 strncpy (
0252     char                    *DstString,
0253     const char              *SrcString,
0254     ACPI_SIZE               Count);
0255 
0256 char *
0257 strstr (
0258     char                    *String1,
0259     char                    *String2);
0260 
0261 
0262 /* Conversion */
0263 
0264 UINT32
0265 strtoul (
0266     const char              *String,
0267     char                    **Terminator,
0268     UINT32                  Base);
0269 
0270 
0271 /* Memory */
0272 
0273 int
0274 memcmp (
0275     void                    *Buffer1,
0276     void                    *Buffer2,
0277     ACPI_SIZE               Count);
0278 
0279 void *
0280 memcpy (
0281     void                    *Dest,
0282     const void              *Src,
0283     ACPI_SIZE               Count);
0284 
0285 void *
0286 memmove (
0287     void                    *Dest,
0288     const void              *Src,
0289     ACPI_SIZE               Count);
0290 
0291 void *
0292 memset (
0293     void                    *Dest,
0294     int                     Value,
0295     ACPI_SIZE               Count);
0296 
0297 
0298 /* upper/lower case */
0299 
0300 int
0301 tolower (
0302     int                     c);
0303 
0304 int
0305 toupper (
0306     int                     c);
0307 
0308 /*
0309  * utprint - printf/vprintf output functions
0310  */
0311 const char *
0312 AcpiUtScanNumber (
0313     const char              *String,
0314     UINT64                  *NumberPtr);
0315 
0316 const char *
0317 AcpiUtPrintNumber (
0318     char                    *String,
0319     UINT64                  Number);
0320 
0321 int
0322 vsnprintf (
0323     char                    *String,
0324     ACPI_SIZE               Size,
0325     const char              *Format,
0326     va_list                 Args);
0327 
0328 int
0329 snprintf (
0330     char                    *String,
0331     ACPI_SIZE               Size,
0332     const char              *Format,
0333     ...);
0334 
0335 int
0336 sprintf (
0337     char                    *String,
0338     const char              *Format,
0339     ...);
0340 
0341 #ifdef ACPI_APPLICATION
0342 #define SEEK_SET            0
0343 #define SEEK_CUR            1
0344 #define SEEK_END            2
0345 
0346 /*
0347  * NOTE: Currently we only need to update errno for file IOs. Other
0348  *       Clibrary invocations in ACPICA do not make decisions according to
0349  *       the errno.
0350  */
0351 extern int errno;
0352 
0353 #ifndef EOF
0354 #define EOF                 (-1)
0355 #endif
0356 
0357 #define putchar(c)          fputc(stdout, c)
0358 #define getchar(c)          fgetc(stdin)
0359 
0360 int
0361 vprintf (
0362     const char              *Format,
0363     va_list                 Args);
0364 
0365 int
0366 printf (
0367     const char              *Format,
0368     ...);
0369 
0370 int
0371 vfprintf (
0372     FILE                    *File,
0373     const char              *Format,
0374     va_list                 Args);
0375 
0376 int
0377 fprintf (
0378     FILE                    *File,
0379     const char              *Format,
0380     ...);
0381 
0382 FILE *
0383 fopen (
0384     const char              *Path,
0385     const char              *Modes);
0386 
0387 void
0388 fclose (
0389     FILE                    *File);
0390 
0391 int
0392 fread (
0393     void                    *Buffer,
0394     ACPI_SIZE               Size,
0395     ACPI_SIZE               Count,
0396     FILE                    *File);
0397 
0398 int
0399 fwrite (
0400     void                    *Buffer,
0401     ACPI_SIZE               Size,
0402     ACPI_SIZE               Count,
0403     FILE                    *File);
0404 
0405 int
0406 fseek (
0407     FILE                    *File,
0408     long                    Offset,
0409     int                     From);
0410 
0411 long
0412 ftell (
0413     FILE                    *File);
0414 
0415 int
0416 fgetc (
0417     FILE                    *File);
0418 
0419 int
0420 fputc (
0421     FILE                    *File,
0422     char                    c);
0423 
0424 char *
0425 fgets (
0426     char                    *s,
0427     ACPI_SIZE               Size,
0428     FILE                    *File);
0429 #endif
0430 
0431 #endif /* _ACCLIB_H */