From c57f8fa38a537bd6043f6d67eff1bb7cc1d9ea90 Mon Sep 17 00:00:00 2001 From: aystarik Date: Wed, 29 Jun 2005 19:00:53 +0000 Subject: [PATCH] Renamed Clib functions to uppercase macros date 99.10.12.20.28.00; author rmoore1; state Exp; --- source/components/utilities/utalloc.c | 6 +- source/components/utilities/utclib.c | 719 ++++++++++++-------------- source/components/utilities/utcopy.c | 32 +- 3 files changed, 346 insertions(+), 411 deletions(-) diff --git a/source/components/utilities/utalloc.c b/source/components/utilities/utalloc.c index fce2bebd1..6ed978150 100644 --- a/source/components/utilities/utalloc.c +++ b/source/components/utilities/utalloc.c @@ -250,7 +250,7 @@ CmAddElementToAllocList ( Gbl_TailAllocPtr->AllocType = AllocType; Gbl_TailAllocPtr->Component = Component; Gbl_TailAllocPtr->Line = Line; - strcpy (Gbl_TailAllocPtr->Module, Module); + STRCPY (Gbl_TailAllocPtr->Module, Module); CmReleaseMutex (MTX_MEMORY); return_VOID; @@ -418,7 +418,7 @@ CmDumpCurrentAllocations ( for (i = 1; ; i++) /* Just a counter */ { if ((Element->Component & Component) && - ((Module == NULL) || (0 == strcmp (Module, Element->Module)))) + ((Module == NULL) || (0 == STRCMP (Module, Element->Module)))) { DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, ("%p: Length %04x %10.10s Line %d", @@ -686,7 +686,7 @@ CmInitStaticObject ( /* * Clear the entire descriptor */ - memset ((void *) ObjDesc, 0, sizeof (ACPI_OBJECT_INTERNAL)); + MEMSET ((void *) ObjDesc, 0, sizeof (ACPI_OBJECT_INTERNAL)); /* diff --git a/source/components/utilities/utclib.c b/source/components/utilities/utclib.c index 51ccfbb55..c2c95896b 100644 --- a/source/components/utilities/utclib.c +++ b/source/components/utilities/utclib.c @@ -1,7 +1,7 @@ + /****************************************************************************** - * + * * Module Name: cmclib - Local implementation of C library functions - * $Revision: 1.49 $ * *****************************************************************************/ @@ -9,8 +9,8 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. - * All rights reserved. + * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights + * reserved. * * 2. License * @@ -38,9 +38,9 @@ * The above copyright and patent license is granted only if the following * conditions are met: * - * 3. Conditions + * 3. Conditions * - * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * 3.1. Redistribution of Source with Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification with rights to further distribute source must include * the above Copyright Notice, the above License, this list of Conditions, @@ -48,11 +48,11 @@ * Licensee must cause all Covered Code to which Licensee contributes to * contain a file documenting the changes Licensee made to create that Covered * Code and the date of any change. Licensee must include in that file the - * documentation of any changes made by any predecessor Licensee. Licensee + * documentation of any changes made by any predecessor Licensee. Licensee * must include a prominent statement that the modification is derived, * directly or indirectly, from Original Intel Code. * - * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification without rights to further distribute source must * include the following Disclaimer and Export Compliance provision in the @@ -86,7 +86,7 @@ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A - * PARTICULAR PURPOSE. + * PARTICULAR PURPOSE. * * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR @@ -117,40 +117,39 @@ #define __CMCLIB_C__ -#include "acpi.h" - -/* - * These implementations of standard C Library routines can optionally be - * used if a C library is not available. In general, they are less efficient - * than an inline or assembly implementation - */ - -#define _COMPONENT ACPI_UTILITIES - ACPI_MODULE_NAME ("cmclib") +#include +#include +#include +#include +#include +#include -#ifndef ACPI_USE_SYSTEM_CLIBRARY +#define _THIS_MODULE "cmclib.c" +#define _COMPONENT MISCELLANEOUS + /******************************************************************************* * - * FUNCTION: strlen + * FUNCTION: * - * PARAMETERS: String - Null terminated string + * PARAMETERS: None * - * RETURN: Length + * RETURN: Status * - * DESCRIPTION: Returns the length of the input string + * DESCRIPTION: * ******************************************************************************/ ACPI_SIZE -AcpiUtStrlen ( +_strlen ( const char *String) { UINT32 Length = 0; + /* Count the string until a null is encountered */ while (*String) @@ -159,31 +158,33 @@ AcpiUtStrlen ( String++; } - return (Length); + return Length; + } /******************************************************************************* * - * FUNCTION: strcpy + * FUNCTION: * - * PARAMETERS: DstString - Target of the copy - * SrcString - The source string to copy + * PARAMETERS: None * - * RETURN: DstString + * RETURN: Status * - * DESCRIPTION: Copy a null terminated string + * DESCRIPTION: * ******************************************************************************/ + char * -AcpiUtStrcpy ( - char *DstString, +_strcpy ( + char *DstString, const char *SrcString) { char *String = DstString; + /* Move bytes brute force */ while (*SrcString) @@ -197,37 +198,36 @@ AcpiUtStrcpy ( /* Null terminate */ *String = 0; - return (DstString); + + return DstString; } /******************************************************************************* * - * FUNCTION: strncpy + * FUNCTION: * - * PARAMETERS: DstString - Target of the copy - * SrcString - The source string to copy - * Count - Maximum # of bytes to copy + * PARAMETERS: None * - * RETURN: DstString + * RETURN: Status * - * DESCRIPTION: Copy a null terminated string, with a maximum length + * DESCRIPTION: * ******************************************************************************/ char * -AcpiUtStrncpy ( - char *DstString, - const char *SrcString, +_strncpy ( + char *DstString, + const char *SrcString, ACPI_SIZE Count) { char *String = DstString; + /* Copy the string */ - for (String = DstString; - Count && (Count--, (*String++ = *SrcString++)); ) + for (String = DstString; Count && (Count--, (*String++ = *SrcString++)); ) {;} /* Pad with nulls if necessary */ @@ -240,60 +240,26 @@ AcpiUtStrncpy ( /* Return original pointer */ - return (DstString); + return DstString; } /******************************************************************************* * - * FUNCTION: strcmp + * FUNCTION: * - * PARAMETERS: String1 - First string - * String2 - Second string + * PARAMETERS: None * - * RETURN: Index where strings mismatched, or 0 if strings matched + * RETURN: Status * - * DESCRIPTION: Compare two null terminated strings + * DESCRIPTION: * ******************************************************************************/ -int -AcpiUtStrcmp ( - const char *String1, - const char *String2) -{ - - - for ( ; (*String1 == *String2); String2++) - { - if (!*String1++) - { - return (0); - } - } - - return ((unsigned char) *String1 - (unsigned char) *String2); -} - - -/******************************************************************************* - * - * FUNCTION: strncmp - * - * PARAMETERS: String1 - First string - * String2 - Second string - * Count - Maximum # of bytes to compare - * - * RETURN: Index where strings mismatched, or 0 if strings matched - * - * DESCRIPTION: Compare two null terminated strings, with a maximum length - * - ******************************************************************************/ - -int -AcpiUtStrncmp ( - const char *String1, - const char *String2, +UINT32 +_strncmp ( + const char *String1, + const char *String2, ACPI_SIZE Count) { @@ -302,74 +268,103 @@ AcpiUtStrncmp ( { if (!*String1++) { - return (0); + return 0; } } - return ((Count == ACPI_SIZE_MAX) ? 0 : ((unsigned char) *String1 - - (unsigned char) *String2)); + return (Count == -1) ? 0 : ((unsigned char) *String1 - (unsigned char) *String2); } /******************************************************************************* * - * FUNCTION: Strcat + * FUNCTION: * - * PARAMETERS: DstString - Target of the copy - * SrcString - The source string to copy + * PARAMETERS: None * - * RETURN: DstString + * RETURN: Status * - * DESCRIPTION: Append a null terminated string to a null terminated string + * DESCRIPTION: + * + ******************************************************************************/ + +UINT32 +_strcmp ( + const char *String1, + const char *String2) +{ + + + for ( ; (*String1 == *String2); String2++) + { + if (!*String1++) + { + return 0; + } + } + + + return (unsigned char) *String1 - (unsigned char) *String2; +} + + +/******************************************************************************* + * + * FUNCTION: + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: * ******************************************************************************/ char * -AcpiUtStrcat ( +_strcat ( char *DstString, const char *SrcString) { char *String; + /* Find end of the destination string */ for (String = DstString; *String++; ) { ; } - /* Concatenate the string */ + /* Concatinate the string */ for (--String; (*String++ = *SrcString++); ) { ; } - return (DstString); + return DstString; } /******************************************************************************* * - * FUNCTION: strncat + * FUNCTION: * - * PARAMETERS: DstString - Target of the copy - * SrcString - The source string to copy - * Count - Maximum # of bytes to copy + * PARAMETERS: None * - * RETURN: DstString + * RETURN: Status * - * DESCRIPTION: Append a null terminated string to a null terminated string, - * with a maximum count. + * DESCRIPTION: * ******************************************************************************/ char * -AcpiUtStrncat ( - char *DstString, - const char *SrcString, +_strncat ( + char *DstString, + const char *SrcString, ACPI_SIZE Count) { char *String; + if (Count) { /* Find end of the destination string */ @@ -377,7 +372,7 @@ AcpiUtStrncat ( for (String = DstString; *String++; ) { ; } - /* Concatenate the string */ + /* Concatinate the string */ for (--String; (*String++ = *SrcString++) && --Count; ) { ; } @@ -390,34 +385,33 @@ AcpiUtStrncat ( } } - return (DstString); + return DstString; } /******************************************************************************* * - * FUNCTION: memcpy + * FUNCTION: * - * PARAMETERS: Dest - Target of the copy - * Src - Source buffer to copy - * Count - Number of bytes to copy + * PARAMETERS: None * - * RETURN: Dest + * RETURN: Status * - * DESCRIPTION: Copy arbitrary bytes of memory + * DESCRIPTION: * ******************************************************************************/ void * -AcpiUtMemcpy ( - void *Dest, - const void *Src, +_memcpy ( + void *Dest, + const void *Src, ACPI_SIZE Count) { char *New = (char *) Dest; char *Old = (char *) Src; + while (Count) { *New = *Old; @@ -426,33 +420,32 @@ AcpiUtMemcpy ( Count--; } - return (Dest); + return Dest; } /******************************************************************************* * - * FUNCTION: memset + * FUNCTION: * - * PARAMETERS: Dest - Buffer to set - * Value - Value to set each byte of memory - * Count - Number of bytes to set + * PARAMETERS: None * - * RETURN: Dest + * RETURN: Status * - * DESCRIPTION: Initialize a buffer to a known value. + * DESCRIPTION: * ******************************************************************************/ void * -AcpiUtMemset ( +_memset ( void *Dest, - NATIVE_UINT Value, + INT32 Value, ACPI_SIZE Count) { char *New = (char *) Dest; + while (Count) { *New = (char) Value; @@ -460,143 +453,157 @@ AcpiUtMemset ( Count--; } - return (Dest); + return Dest; } #define NEGATIVE 1 #define POSITIVE 0 -const UINT8 _acpi_ctype[257] = { - _ACPI_CN, /* 0x0 0. */ - _ACPI_CN, /* 0x1 1. */ - _ACPI_CN, /* 0x2 2. */ - _ACPI_CN, /* 0x3 3. */ - _ACPI_CN, /* 0x4 4. */ - _ACPI_CN, /* 0x5 5. */ - _ACPI_CN, /* 0x6 6. */ - _ACPI_CN, /* 0x7 7. */ - _ACPI_CN, /* 0x8 8. */ - _ACPI_CN|_ACPI_SP, /* 0x9 9. */ - _ACPI_CN|_ACPI_SP, /* 0xA 10. */ - _ACPI_CN|_ACPI_SP, /* 0xB 11. */ - _ACPI_CN|_ACPI_SP, /* 0xC 12. */ - _ACPI_CN|_ACPI_SP, /* 0xD 13. */ - _ACPI_CN, /* 0xE 14. */ - _ACPI_CN, /* 0xF 15. */ - _ACPI_CN, /* 0x10 16. */ - _ACPI_CN, /* 0x11 17. */ - _ACPI_CN, /* 0x12 18. */ - _ACPI_CN, /* 0x13 19. */ - _ACPI_CN, /* 0x14 20. */ - _ACPI_CN, /* 0x15 21. */ - _ACPI_CN, /* 0x16 22. */ - _ACPI_CN, /* 0x17 23. */ - _ACPI_CN, /* 0x18 24. */ - _ACPI_CN, /* 0x19 25. */ - _ACPI_CN, /* 0x1A 26. */ - _ACPI_CN, /* 0x1B 27. */ - _ACPI_CN, /* 0x1C 28. */ - _ACPI_CN, /* 0x1D 29. */ - _ACPI_CN, /* 0x1E 30. */ - _ACPI_CN, /* 0x1F 31. */ - _ACPI_XS|_ACPI_SP, /* 0x20 32. ' ' */ - _ACPI_PU, /* 0x21 33. '!' */ - _ACPI_PU, /* 0x22 34. '"' */ - _ACPI_PU, /* 0x23 35. '#' */ - _ACPI_PU, /* 0x24 36. '$' */ - _ACPI_PU, /* 0x25 37. '%' */ - _ACPI_PU, /* 0x26 38. '&' */ - _ACPI_PU, /* 0x27 39. ''' */ - _ACPI_PU, /* 0x28 40. '(' */ - _ACPI_PU, /* 0x29 41. ')' */ - _ACPI_PU, /* 0x2A 42. '*' */ - _ACPI_PU, /* 0x2B 43. '+' */ - _ACPI_PU, /* 0x2C 44. ',' */ - _ACPI_PU, /* 0x2D 45. '-' */ - _ACPI_PU, /* 0x2E 46. '.' */ - _ACPI_PU, /* 0x2F 47. '/' */ - _ACPI_XD|_ACPI_DI, /* 0x30 48. '0' */ - _ACPI_XD|_ACPI_DI, /* 0x31 49. '1' */ - _ACPI_XD|_ACPI_DI, /* 0x32 50. '2' */ - _ACPI_XD|_ACPI_DI, /* 0x33 51. '3' */ - _ACPI_XD|_ACPI_DI, /* 0x34 52. '4' */ - _ACPI_XD|_ACPI_DI, /* 0x35 53. '5' */ - _ACPI_XD|_ACPI_DI, /* 0x36 54. '6' */ - _ACPI_XD|_ACPI_DI, /* 0x37 55. '7' */ - _ACPI_XD|_ACPI_DI, /* 0x38 56. '8' */ - _ACPI_XD|_ACPI_DI, /* 0x39 57. '9' */ - _ACPI_PU, /* 0x3A 58. ':' */ - _ACPI_PU, /* 0x3B 59. ';' */ - _ACPI_PU, /* 0x3C 60. '<' */ - _ACPI_PU, /* 0x3D 61. '=' */ - _ACPI_PU, /* 0x3E 62. '>' */ - _ACPI_PU, /* 0x3F 63. '?' */ - _ACPI_PU, /* 0x40 64. '@' */ - _ACPI_XD|_ACPI_UP, /* 0x41 65. 'A' */ - _ACPI_XD|_ACPI_UP, /* 0x42 66. 'B' */ - _ACPI_XD|_ACPI_UP, /* 0x43 67. 'C' */ - _ACPI_XD|_ACPI_UP, /* 0x44 68. 'D' */ - _ACPI_XD|_ACPI_UP, /* 0x45 69. 'E' */ - _ACPI_XD|_ACPI_UP, /* 0x46 70. 'F' */ - _ACPI_UP, /* 0x47 71. 'G' */ - _ACPI_UP, /* 0x48 72. 'H' */ - _ACPI_UP, /* 0x49 73. 'I' */ - _ACPI_UP, /* 0x4A 74. 'J' */ - _ACPI_UP, /* 0x4B 75. 'K' */ - _ACPI_UP, /* 0x4C 76. 'L' */ - _ACPI_UP, /* 0x4D 77. 'M' */ - _ACPI_UP, /* 0x4E 78. 'N' */ - _ACPI_UP, /* 0x4F 79. 'O' */ - _ACPI_UP, /* 0x50 80. 'P' */ - _ACPI_UP, /* 0x51 81. 'Q' */ - _ACPI_UP, /* 0x52 82. 'R' */ - _ACPI_UP, /* 0x53 83. 'S' */ - _ACPI_UP, /* 0x54 84. 'T' */ - _ACPI_UP, /* 0x55 85. 'U' */ - _ACPI_UP, /* 0x56 86. 'V' */ - _ACPI_UP, /* 0x57 87. 'W' */ - _ACPI_UP, /* 0x58 88. 'X' */ - _ACPI_UP, /* 0x59 89. 'Y' */ - _ACPI_UP, /* 0x5A 90. 'Z' */ - _ACPI_PU, /* 0x5B 91. '[' */ - _ACPI_PU, /* 0x5C 92. '\' */ - _ACPI_PU, /* 0x5D 93. ']' */ - _ACPI_PU, /* 0x5E 94. '^' */ - _ACPI_PU, /* 0x5F 95. '_' */ - _ACPI_PU, /* 0x60 96. '`' */ - _ACPI_XD|_ACPI_LO, /* 0x61 97. 'a' */ - _ACPI_XD|_ACPI_LO, /* 0x62 98. 'b' */ - _ACPI_XD|_ACPI_LO, /* 0x63 99. 'c' */ - _ACPI_XD|_ACPI_LO, /* 0x64 100. 'd' */ - _ACPI_XD|_ACPI_LO, /* 0x65 101. 'e' */ - _ACPI_XD|_ACPI_LO, /* 0x66 102. 'f' */ - _ACPI_LO, /* 0x67 103. 'g' */ - _ACPI_LO, /* 0x68 104. 'h' */ - _ACPI_LO, /* 0x69 105. 'i' */ - _ACPI_LO, /* 0x6A 106. 'j' */ - _ACPI_LO, /* 0x6B 107. 'k' */ - _ACPI_LO, /* 0x6C 108. 'l' */ - _ACPI_LO, /* 0x6D 109. 'm' */ - _ACPI_LO, /* 0x6E 110. 'n' */ - _ACPI_LO, /* 0x6F 111. 'o' */ - _ACPI_LO, /* 0x70 112. 'p' */ - _ACPI_LO, /* 0x71 113. 'q' */ - _ACPI_LO, /* 0x72 114. 'r' */ - _ACPI_LO, /* 0x73 115. 's' */ - _ACPI_LO, /* 0x74 116. 't' */ - _ACPI_LO, /* 0x75 117. 'u' */ - _ACPI_LO, /* 0x76 118. 'v' */ - _ACPI_LO, /* 0x77 119. 'w' */ - _ACPI_LO, /* 0x78 120. 'x' */ - _ACPI_LO, /* 0x79 121. 'y' */ - _ACPI_LO, /* 0x7A 122. 'z' */ - _ACPI_PU, /* 0x7B 123. '{' */ - _ACPI_PU, /* 0x7C 124. '|' */ - _ACPI_PU, /* 0x7D 125. '}' */ - _ACPI_PU, /* 0x7E 126. '~' */ - _ACPI_CN, /* 0x7F 127. */ + + +#define _XA 0x00 /* extra alphabetic - not supported */ +#define _XS 0x40 /* extra space */ +#define _BB 0x00 /* BEL, BS, etc. - not supported */ +#define _CN 0x20 /* CR, FF, HT, NL, VT */ +#define _DI 0x04 /* '0'-'9' */ +#define _LO 0x02 /* 'a'-'z' */ +#define _PU 0x10 /* punctuation */ +#define _SP 0x08 /* space */ +#define _UP 0x01 /* 'A'-'Z' */ +#define _XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */ + +const unsigned char _ctype[257] = { + _CN, /* 0x0 0. */ + _CN, /* 0x1 1. */ + _CN, /* 0x2 2. */ + _CN, /* 0x3 3. */ + _CN, /* 0x4 4. */ + _CN, /* 0x5 5. */ + _CN, /* 0x6 6. */ + _CN, /* 0x7 7. */ + _CN, /* 0x8 8. */ + _CN|_SP, /* 0x9 9. */ + _CN|_SP, /* 0xA 10. */ + _CN|_SP, /* 0xB 11. */ + _CN|_SP, /* 0xC 12. */ + _CN|_SP, /* 0xD 13. */ + _CN, /* 0xE 14. */ + _CN, /* 0xF 15. */ + _CN, /* 0x10 16. */ + _CN, /* 0x11 17. */ + _CN, /* 0x12 18. */ + _CN, /* 0x13 19. */ + _CN, /* 0x14 20. */ + _CN, /* 0x15 21. */ + _CN, /* 0x16 22. */ + _CN, /* 0x17 23. */ + _CN, /* 0x18 24. */ + _CN, /* 0x19 25. */ + _CN, /* 0x1A 26. */ + _CN, /* 0x1B 27. */ + _CN, /* 0x1C 28. */ + _CN, /* 0x1D 29. */ + _CN, /* 0x1E 30. */ + _CN, /* 0x1F 31. */ + _XS|_SP, /* 0x20 32. ' ' */ + _PU, /* 0x21 33. '!' */ + _PU, /* 0x22 34. '"' */ + _PU, /* 0x23 35. '#' */ + _PU, /* 0x24 36. '$' */ + _PU, /* 0x25 37. '%' */ + _PU, /* 0x26 38. '&' */ + _PU, /* 0x27 39. ''' */ + _PU, /* 0x28 40. '(' */ + _PU, /* 0x29 41. ')' */ + _PU, /* 0x2A 42. '*' */ + _PU, /* 0x2B 43. '+' */ + _PU, /* 0x2C 44. ',' */ + _PU, /* 0x2D 45. '-' */ + _PU, /* 0x2E 46. '.' */ + _PU, /* 0x2F 47. '/' */ + _XD|_DI, /* 0x30 48. '0' */ + _XD|_DI, /* 0x31 49. '1' */ + _XD|_DI, /* 0x32 50. '2' */ + _XD|_DI, /* 0x33 51. '3' */ + _XD|_DI, /* 0x34 52. '4' */ + _XD|_DI, /* 0x35 53. '5' */ + _XD|_DI, /* 0x36 54. '6' */ + _XD|_DI, /* 0x37 55. '7' */ + _XD|_DI, /* 0x38 56. '8' */ + _XD|_DI, /* 0x39 57. '9' */ + _PU, /* 0x3A 58. ':' */ + _PU, /* 0x3B 59. ';' */ + _PU, /* 0x3C 60. '<' */ + _PU, /* 0x3D 61. '=' */ + _PU, /* 0x3E 62. '>' */ + _PU, /* 0x3F 63. '?' */ + _PU, /* 0x40 64. '@' */ + _XD|_UP, /* 0x41 65. 'A' */ + _XD|_UP, /* 0x42 66. 'B' */ + _XD|_UP, /* 0x43 67. 'C' */ + _XD|_UP, /* 0x44 68. 'D' */ + _XD|_UP, /* 0x45 69. 'E' */ + _XD|_UP, /* 0x46 70. 'F' */ + _UP, /* 0x47 71. 'G' */ + _UP, /* 0x48 72. 'H' */ + _UP, /* 0x49 73. 'I' */ + _UP, /* 0x4A 74. 'J' */ + _UP, /* 0x4B 75. 'K' */ + _UP, /* 0x4C 76. 'L' */ + _UP, /* 0x4D 77. 'M' */ + _UP, /* 0x4E 78. 'N' */ + _UP, /* 0x4F 79. 'O' */ + _UP, /* 0x50 80. 'P' */ + _UP, /* 0x51 81. 'Q' */ + _UP, /* 0x52 82. 'R' */ + _UP, /* 0x53 83. 'S' */ + _UP, /* 0x54 84. 'T' */ + _UP, /* 0x55 85. 'U' */ + _UP, /* 0x56 86. 'V' */ + _UP, /* 0x57 87. 'W' */ + _UP, /* 0x58 88. 'X' */ + _UP, /* 0x59 89. 'Y' */ + _UP, /* 0x5A 90. 'Z' */ + _PU, /* 0x5B 91. '[' */ + _PU, /* 0x5C 92. '\' */ + _PU, /* 0x5D 93. ']' */ + _PU, /* 0x5E 94. '^' */ + _PU, /* 0x5F 95. '_' */ + _PU, /* 0x60 96. '`' */ + _XD|_LO, /* 0x61 97. 'a' */ + _XD|_LO, /* 0x62 98. 'b' */ + _XD|_LO, /* 0x63 99. 'c' */ + _XD|_LO, /* 0x64 100. 'd' */ + _XD|_LO, /* 0x65 101. 'e' */ + _XD|_LO, /* 0x66 102. 'f' */ + _LO, /* 0x67 103. 'g' */ + _LO, /* 0x68 104. 'h' */ + _LO, /* 0x69 105. 'i' */ + _LO, /* 0x6A 106. 'j' */ + _LO, /* 0x6B 107. 'k' */ + _LO, /* 0x6C 108. 'l' */ + _LO, /* 0x6D 109. 'm' */ + _LO, /* 0x6E 110. 'n' */ + _LO, /* 0x6F 111. 'o' */ + _LO, /* 0x70 112. 'p' */ + _LO, /* 0x71 113. 'q' */ + _LO, /* 0x72 114. 'r' */ + _LO, /* 0x73 115. 's' */ + _LO, /* 0x74 116. 't' */ + _LO, /* 0x75 117. 'u' */ + _LO, /* 0x76 118. 'v' */ + _LO, /* 0x77 119. 'w' */ + _LO, /* 0x78 120. 'x' */ + _LO, /* 0x79 121. 'y' */ + _LO, /* 0x7A 122. 'z' */ + _PU, /* 0x7B 123. '{' */ + _PU, /* 0x7C 124. '|' */ + _PU, /* 0x7D 125. '}' */ + _PU, /* 0x7E 126. '~' */ + _CN, /* 0x7F 127. */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80 to 0x8F */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90 to 0x9F */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xA0 to 0xAF */ @@ -607,122 +614,46 @@ const UINT8 _acpi_ctype[257] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xF0 to 0x100 */ }; -#define IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP)) -#define IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) -#define IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI)) -#define IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP)) -#define IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD)) +#define IS_UPPER(c) (_ctype[(unsigned char)(c)] & (_UP)) +#define IS_LOWER(c) (_ctype[(unsigned char)(c)] & (_LO)) +#define IS_DIGIT(c) (_ctype[(unsigned char)(c)] & (_DI)) +#define IS_SPACE(c) (_ctype[(unsigned char)(c)] & (_SP)) +//#define ToUpper(c) (IS_LOWER(c) ? ((c)-0x20) : (c)) +//#define ToLower(c) (IS_UPPER(c) ? ((c)+0x20) : (c)) - -/******************************************************************************* - * - * FUNCTION: AcpiUtToUpper - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: Convert character to uppercase - * - ******************************************************************************/ - -int -AcpiUtToUpper ( - int c) +INT32 +ToUpper (INT32 c) { - return (IS_LOWER(c) ? ((c)-0x20) : (c)); } -/******************************************************************************* - * - * FUNCTION: AcpiUtToLower - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: Convert character to lowercase - * - ******************************************************************************/ - -int -AcpiUtToLower ( - int c) +INT32 +ToLower (INT32 c) { - return (IS_UPPER(c) ? ((c)+0x20) : (c)); } - /******************************************************************************* * - * FUNCTION: strstr + * FUNCTION: * - * PARAMETERS: String1 - - * String2 + * PARAMETERS: None * - * RETURN: + * RETURN: Status * - * DESCRIPTION: Checks if String2 occurs in String1. This is not really a - * full implementation of strstr, only sufficient for command - * matching - * - ******************************************************************************/ - -char * -AcpiUtStrstr ( - char *String1, - char *String2) -{ - char *String; - - - if (AcpiUtStrlen (String2) > AcpiUtStrlen (String1)) - { - return (NULL); - } - - /* Walk entire string, comparing the letters */ - - for (String = String1; *String2; ) - { - if (*String2 != *String) - { - return (NULL); - } - - String2++; - String++; - } - - return (String1); -} - - -/******************************************************************************* - * - * FUNCTION: strtoul - * - * PARAMETERS: String - Null terminated string - * Terminater - Where a pointer to the terminating byte is returned - * Base - Radix of the string - * - * RETURN: Converted value - * - * DESCRIPTION: Convert a string into an unsigned value. + * DESCRIPTION: * ******************************************************************************/ UINT32 -AcpiUtStrtoul ( - const char *String, - char **Terminator, - UINT32 Base) +_strtoul ( + const char *String, + char **Terminator, + INT32 Base) { UINT32 converted = 0; - UINT32 index; + INT32 index; UINT32 sign; const char *StringStart; UINT32 ReturnValue = 0; @@ -735,7 +666,7 @@ AcpiUtStrtoul ( * skip over any white space in the buffer: */ StringStart = String; - while (IS_SPACE (*String) || *String == '\t') + while (IS_SPACE (*String) || *String == '\t') { ++String; } @@ -744,17 +675,19 @@ AcpiUtStrtoul ( * The buffer may contain an optional plus or minus sign. * If it does, then skip over it but remember what is was: */ - if (*String == '-') + if (*String == '-') { sign = NEGATIVE; ++String; - } - else if (*String == '+') + } + + else if (*String == '+') { ++String; sign = POSITIVE; } - else + + else { sign = POSITIVE; } @@ -763,26 +696,29 @@ AcpiUtStrtoul ( * If the input parameter Base is zero, then we need to * determine if it is octal, decimal, or hexadecimal: */ - if (Base == 0) + if (Base == 0) { - if (*String == '0') + if (*String == '0') { - if (AcpiUtToLower (*(++String)) == 'x') + if (ToLower (*(++String)) == 'x') { Base = 16; ++String; } - else + + else { Base = 8; } } - else + + else { Base = 10; } } - else if (Base < 2 || Base > 36) + + else if (Base < 2 || Base > 36) { /* * The specified Base parameter is not in the domain of @@ -799,10 +735,8 @@ AcpiUtStrtoul ( { String++; } - - if (Base == 16 && - *String == '0' && - AcpiUtToLower (*(++String)) == 'x') + + if (Base == 16 && *String == '0' && ToLower (*(++String)) == 'x') { String++; } @@ -811,26 +745,28 @@ AcpiUtStrtoul ( /* * Main loop: convert the string to an unsigned long: */ - while (*String) + while (*String) { - if (IS_DIGIT (*String)) + if (IS_DIGIT (*String)) { - index = (UINT32) ((UINT8) *String - '0'); - } - else + index = *String - '0'; + } + + else { - index = (UINT32) AcpiUtToUpper (*String); - if (IS_UPPER (index)) + index = ToUpper (*String); + if (IS_UPPER (index)) { index = index - 'A' + 10; - } - else + } + + else { goto done; } } - if (index >= Base) + if (index >= Base) { goto done; } @@ -839,13 +775,14 @@ AcpiUtStrtoul ( * Check to see if value is out of range: */ - if (ReturnValue > ((ACPI_UINT32_MAX - (UINT32) index) / - (UINT32) Base)) + if (ReturnValue > ((ACPI_UINT_MAX - (UINT32) index) / + (UINT32) Base)) { Status = AE_ERROR; - ReturnValue = 0; /* reset */ + ReturnValue = 0L; /* reset */ } - else + + else { ReturnValue *= Base; ReturnValue += index; @@ -858,14 +795,15 @@ AcpiUtStrtoul ( done: /* * If appropriate, update the caller's pointer to the next - * unconverted character in the buffer. + * unconverted character in the buffer. */ - if (Terminator) + if (Terminator) { - if (converted == 0 && ReturnValue == 0 && String != NULL) + if (converted == 0 && ReturnValue == 0L && String != NULL) { *Terminator = (char *) StringStart; } + else { *Terminator = (char *) String; @@ -874,19 +812,16 @@ done: if (Status == AE_ERROR) { - ReturnValue = ACPI_UINT32_MAX; + ReturnValue = ACPI_UINT_MAX; } /* * If a minus sign was present, then "the conversion is negated": */ - if (sign == NEGATIVE) + if (sign == NEGATIVE) { - ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1; + ReturnValue = (ACPI_UINT_MAX - ReturnValue) + 1; } return (ReturnValue); } - -#endif /* ACPI_USE_SYSTEM_CLIBRARY */ - diff --git a/source/components/utilities/utcopy.c b/source/components/utilities/utcopy.c index ca8bd49da..0cd0c16be 100644 --- a/source/components/utilities/utcopy.c +++ b/source/components/utilities/utcopy.c @@ -176,7 +176,7 @@ CmBuildExternalSimpleObject ( switch (ExternalObj->Type) { - case TYPE_String: + case ACPI_TYPE_String: Length = InternalObj->String.Length; ExternalObj->String.Length = InternalObj->String.Length; @@ -185,7 +185,7 @@ CmBuildExternalSimpleObject ( break; - case TYPE_Buffer: + case ACPI_TYPE_Buffer: Length = InternalObj->Buffer.Length; ExternalObj->Buffer.Length = InternalObj->Buffer.Length; @@ -194,7 +194,7 @@ CmBuildExternalSimpleObject ( break; - case TYPE_Number: + case ACPI_TYPE_Number: ExternalObj->Number.Value= InternalObj->Number.Value; break; @@ -211,7 +211,7 @@ CmBuildExternalSimpleObject ( /* * Copy the return data to the caller's buffer */ - memcpy ((void *) DataSpace, (void *) SourcePtr, Length); + MEMCPY ((void *) DataSpace, (void *) SourcePtr, Length); } @@ -276,7 +276,7 @@ CmBuildExternalPackageObject ( * Initialize the working variables */ - memset ((void *) Level, 0, sizeof (Level)); + MEMSET ((void *) Level, 0, sizeof (Level)); Level[0].InternalObj = InternalObj; Level[0].ExternalObj = ExternalObj; @@ -303,7 +303,7 @@ CmBuildExternalPackageObject ( ThisInternalObj = (ACPI_OBJECT_INTERNAL *) LevelPtr->InternalObj->Package.Elements[ThisIndex]; ThisExternalObj = (ACPI_OBJECT *) &LevelPtr->ExternalObj->Package.Elements[ThisIndex]; - if (ThisInternalObj->Common.Type == TYPE_Package) + if (VALID_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_Package)) { /* * If this object is a package then we go one deeper @@ -321,7 +321,7 @@ CmBuildExternalPackageObject ( /* * Build the package object */ - ThisExternalObj->Type = TYPE_Package; + ThisExternalObj->Type = ACPI_TYPE_Package; ThisExternalObj->Package.Count = ThisInternalObj->Package.Count; ThisExternalObj->Package.Elements = (ACPI_OBJECT *) FreeSpace; @@ -417,7 +417,7 @@ CmBuildExternalObject ( FUNCTION_TRACE ("CmBuildExternalObject"); - if (InternalObj->Common.Type == TYPE_Package) + if (VALID_OBJECT_TYPE (InternalObj, ACPI_TYPE_Package)) { /* * Package objects contain other objects (which can be objects) @@ -477,21 +477,21 @@ CmBuildInternalSimpleObject ( switch (ExternalObj->Type) { - case TYPE_String: + case ACPI_TYPE_String: InternalObj->String.Length = ExternalObj->String.Length; InternalObj->String.Pointer = ExternalObj->String.Pointer; break; - case TYPE_Buffer: + case ACPI_TYPE_Buffer: InternalObj->Buffer.Length = ExternalObj->Buffer.Length; InternalObj->Buffer.Pointer = ExternalObj->Buffer.Pointer; break; - case TYPE_Number: + case ACPI_TYPE_Number: /* * Number is included in the object itself */ @@ -565,7 +565,7 @@ CmBuildInternalPackageObject ( * Initialize the working variables */ - memset ((void *) Level, 0, sizeof(Level)); + MEMSET ((void *) Level, 0, sizeof(Level)); Level[0].InternalObj = InternalObj; Level[0].ExternalObj = ExternalObj; @@ -591,7 +591,7 @@ CmBuildInternalPackageObject ( ThisInternalObj = (ACPI_OBJECT_INTERNAL *) &LevelPtr->InternalObj->Package.Elements[ThisIndex]; ThisExternalObj = (ACPI_OBJECT *) &LevelPtr->ExternalObj->Package.Elements[ThisIndex]; - if (ThisInternalObj->Common.Type == TYPE_Package) + if (VALID_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_Package)) { /* * If this object is a package then we go one deeper @@ -609,7 +609,7 @@ CmBuildInternalPackageObject ( /* * Build the package object */ - ThisExternalObj->Type = TYPE_Package; + ThisExternalObj->Type = ACPI_TYPE_Package; ThisExternalObj->Package.Count = ThisInternalObj->Package.Count; ThisExternalObj->Package.Elements = (ACPI_OBJECT *) FreeSpace; @@ -617,7 +617,7 @@ CmBuildInternalPackageObject ( * Save space for the array of objects (Package elements) * update the buffer length counter */ - ObjectSpace = ThisExternalObj->Package.Count * sizeof(ACPI_OBJECT); + ObjectSpace = ThisExternalObj->Package.Count * sizeof (ACPI_OBJECT); FreeSpace += ObjectSpace; Length += ObjectSpace; @@ -705,7 +705,7 @@ CmBuildInternalObject ( FUNCTION_TRACE ("CmBuildInternalObject"); - if (ExternalObj->Type == TYPE_Package) + if (ExternalObj->Type == ACPI_TYPE_Package) { /* * Package objects contain other objects (which can be objects)