diff options
author | Robert Moore <Robert.Moore@intel.com> | 2016-06-15 10:33:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-15 10:33:47 -0700 |
commit | 8aac0be3c840747a032b63e7365c99190e2a0ba9 (patch) | |
tree | c667316883055dd53603d5343436465a14283f10 /source/components/utilities/utclib.c | |
parent | f78ce8644e4b13f7d092348ff33e3bf9d36eeffa (diff) | |
parent | cc7c7ebe27537840b6e0109d8ef1435c306669bc (diff) | |
download | acpica-8aac0be3c840747a032b63e7365c99190e2a0ba9.tar.gz |
Merge pull request #143 from zetalog/efi-edk2
Efi edk2
Diffstat (limited to 'source/components/utilities/utclib.c')
-rw-r--r-- | source/components/utilities/utclib.c | 146 |
1 files changed, 144 insertions, 2 deletions
diff --git a/source/components/utilities/utclib.c b/source/components/utilities/utclib.c index 26fbaf958..2f4f4ffdb 100644 --- a/source/components/utilities/utclib.c +++ b/source/components/utilities/utclib.c @@ -163,7 +163,7 @@ ACPI_MODULE_NAME ("utclib") -#ifndef ACPI_USE_SYSTEM_CLIBRARY /* Entire module */ +#if defined(ACPI_USE_SYSTEM_CLIBRARY) && !defined(ACPI_USE_STANDARD_HEADERS) /******************************************************************************* @@ -201,6 +201,61 @@ memcmp ( /******************************************************************************* * + * FUNCTION: memmove + * + * PARAMETERS: Dest - Target of the copy + * Src - Source buffer to copy + * Count - Number of bytes to copy + * + * RETURN: Dest + * + * DESCRIPTION: Copy arbitrary bytes of memory with respect to the overlapping + * + ******************************************************************************/ + +void * +memmove ( + void *Dest, + const void *Src, + ACPI_SIZE Count) +{ + char *New = (char *) Dest; + char *Old = (char *) Src; + + + if (Old > New) + { + /* Copy from the beginning */ + + while (Count) + { + *New = *Old; + New++; + Old++; + Count--; + } + } + else if (Old < New) + { + /* Copy from the end */ + + New = New + Count - 1; + Old = Old + Count - 1; + while (Count) + { + *New = *Old; + New--; + Old--; + Count--; + } + } + + return (Dest); +} + + +/******************************************************************************* + * * FUNCTION: memcpy * * PARAMETERS: Dest - Target of the copy @@ -303,6 +358,93 @@ strlen ( /******************************************************************************* * + * FUNCTION: strpbrk + * + * PARAMETERS: String - Null terminated string + * Delimiters - Delimiters to match + * + * RETURN: The first occurance in the string of any of the bytes in the + * delimiters + * + * DESCRIPTION: Search a string for any of a set of the delimiters + * + ******************************************************************************/ + +char * +strpbrk ( + const char *String, + const char *Delimiters) +{ + const char *Delimiter; + + + for ( ; *String != '\0'; ++String) + { + for (Delimiter = Delimiters; *Delimiter != '\0'; Delimiter++) + { + if (*String == *Delimiter) + { + return (ACPI_CAST_PTR (char, String)); + } + } + } + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: strtok + * + * PARAMETERS: String - Null terminated string + * Delimiters - Delimiters to match + * + * RETURN: Pointer to the next token + * + * DESCRIPTION: Split string into tokens + * + ******************************************************************************/ + +char* +strtok ( + char *String, + const char *Delimiters) +{ + char *Begin = String; + static char *SavedPtr; + + + if (Begin == NULL) + { + if (SavedPtr == NULL) + { + return (NULL); + } + Begin = SavedPtr; + } + + SavedPtr = strpbrk (Begin, Delimiters); + while (SavedPtr == Begin) + { + *Begin++ = '\0'; + SavedPtr = strpbrk (Begin, Delimiters); + } + + if (SavedPtr) + { + *SavedPtr++ = '\0'; + return (Begin); + } + else + { + return (NULL); + } +} + + +/******************************************************************************* + * * FUNCTION: strcpy * * PARAMETERS: DstString - Target of the copy @@ -987,4 +1129,4 @@ const UINT8 AcpiGbl_Ctypes[257] = { }; -#endif /* ACPI_USE_SYSTEM_CLIBRARY */ +#endif /* ACPI_USE_SYSTEM_CLIBRARY && !ACPI_USE_STANDARD_HEADERS */ |