/******************************************************************************
*
- * Module Name: cmclib - Local implementation of C library functions
+ * Module Name: utclib - ACPICA implementations of C library functions
*
*****************************************************************************/
*
*****************************************************************************/
+#define ACPI_CLIBRARY
#include "acpi.h"
#include "accommon.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
+ * This module contains implementations of the standard C library functions
+ * that are required by the ACPICA code at both application level and kernel
+ * level.
+ *
+ * The module is an optional feature that can be used if a local/system
+ * C library is not available. Some operating system kernels may not have
+ * an internal C library.
+ *
+ * In general, these functions are less efficient than an inline or assembly
+ * code implementation.
+ *
+ * These C functions and the associated prototypes are enabled by default
+ * unless the ACPI_USE_SYSTEM_CLIBRARY symbol is defined. This is usually
+ * automatically defined for the ACPICA applications such as iASL and
+ * AcpiExec, so that these user-level applications use the local C library
+ * instead of the functions in this module.
*/
-#define _COMPONENT ACPI_UTILITIES
- ACPI_MODULE_NAME ("cmclib")
+/*******************************************************************************
+ *
+ * Functions implemented in this module:
+ *
+ * FUNCTION: memcmp
+ * FUNCTION: memcpy
+ * FUNCTION: memset
+ * FUNCTION: strlen
+ * FUNCTION: strcpy
+ * FUNCTION: strncpy
+ * FUNCTION: strcmp
+ * FUNCTION: strchr
+ * FUNCTION: strncmp
+ * FUNCTION: strcat
+ * FUNCTION: strncat
+ * FUNCTION: strstr
+ * FUNCTION: strtoul
+ * FUNCTION: toupper
+ * FUNCTION: tolower
+ * FUNCTION: is* functions
+ *
+ ******************************************************************************/
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utclib")
-#ifndef ACPI_USE_SYSTEM_CLIBRARY
-#define NEGATIVE 1
-#define POSITIVE 0
+#ifndef ACPI_USE_SYSTEM_CLIBRARY /* Entire module */
/*******************************************************************************
*
- * FUNCTION: AcpiUtMemcmp (memcmp)
+ * FUNCTION: memcmp
*
* PARAMETERS: Buffer1 - First Buffer
* Buffer2 - Second Buffer
* DESCRIPTION: Compare two Buffers, with a maximum length
*
******************************************************************************/
-
+#ifdef __REACTOS__
int
-AcpiUtMemcmp (
- const char *Buffer1,
- const char *Buffer2,
+memcmp (
+ const void *VBuffer1,
+ const void *VBuffer2,
ACPI_SIZE Count)
+#else /* __REACTOS__ */
+int
+memcmp (
+ void *VBuffer1,
+ void *VBuffer2,
+ ACPI_SIZE Count)
+#endif /* __REACTOS__ */
{
+ char *Buffer1 = (char *) VBuffer1;
+ char *Buffer2 = (char *) VBuffer2;
+
for ( ; Count-- && (*Buffer1 == *Buffer2); Buffer1++, Buffer2++)
{
/*******************************************************************************
*
- * FUNCTION: AcpiUtMemcpy (memcpy)
+ * FUNCTION: memcpy
*
* PARAMETERS: Dest - Target of the copy
* Src - Source buffer to copy
******************************************************************************/
void *
-AcpiUtMemcpy (
+memcpy (
void *Dest,
const void *Src,
ACPI_SIZE Count)
/*******************************************************************************
*
- * FUNCTION: AcpiUtMemset (memset)
+ * FUNCTION: memset
*
* PARAMETERS: Dest - Buffer to set
* Value - Value to set each byte of memory
******************************************************************************/
void *
-AcpiUtMemset (
+memset (
void *Dest,
- UINT8 Value,
+ int Value,
ACPI_SIZE Count)
{
char *New = (char *) Dest;
/*******************************************************************************
*
- * FUNCTION: AcpiUtStrlen (strlen)
+ * FUNCTION: strlen
*
* PARAMETERS: String - Null terminated string
*
ACPI_SIZE
-AcpiUtStrlen (
+strlen (
const char *String)
{
UINT32 Length = 0;
/*******************************************************************************
*
- * FUNCTION: AcpiUtStrcpy (strcpy)
+ * FUNCTION: strcpy
*
* PARAMETERS: DstString - Target of the copy
* SrcString - The source string to copy
******************************************************************************/
char *
-AcpiUtStrcpy (
+strcpy (
char *DstString,
const char *SrcString)
{
/*******************************************************************************
*
- * FUNCTION: AcpiUtStrncpy (strncpy)
+ * FUNCTION: strncpy
*
* PARAMETERS: DstString - Target of the copy
* SrcString - The source string to copy
******************************************************************************/
char *
-AcpiUtStrncpy (
+strncpy (
char *DstString,
const char *SrcString,
ACPI_SIZE Count)
/*******************************************************************************
*
- * FUNCTION: AcpiUtStrcmp (strcmp)
+ * FUNCTION: strcmp
*
* PARAMETERS: String1 - First string
* String2 - Second string
******************************************************************************/
int
-AcpiUtStrcmp (
+strcmp (
const char *String1,
const char *String2)
{
/*******************************************************************************
*
- * FUNCTION: AcpiUtStrchr (strchr)
+ * FUNCTION: strchr
*
* PARAMETERS: String - Search string
* ch - character to search for
******************************************************************************/
char *
-AcpiUtStrchr (
+strchr (
const char *String,
int ch)
{
/*******************************************************************************
*
- * FUNCTION: AcpiUtStrncmp (strncmp)
+ * FUNCTION: strncmp
*
* PARAMETERS: String1 - First string
* String2 - Second string
******************************************************************************/
int
-AcpiUtStrncmp (
+strncmp (
const char *String1,
const char *String2,
ACPI_SIZE Count)
/*******************************************************************************
*
- * FUNCTION: AcpiUtStrcat (Strcat)
+ * FUNCTION: strcat
*
* PARAMETERS: DstString - Target of the copy
* SrcString - The source string to copy
******************************************************************************/
char *
-AcpiUtStrcat (
+strcat (
char *DstString,
const char *SrcString)
{
/*******************************************************************************
*
- * FUNCTION: AcpiUtStrncat (strncat)
+ * FUNCTION: strncat
*
* PARAMETERS: DstString - Target of the copy
* SrcString - The source string to copy
******************************************************************************/
char *
-AcpiUtStrncat (
+strncat (
char *DstString,
const char *SrcString,
ACPI_SIZE Count)
/*******************************************************************************
*
- * FUNCTION: AcpiUtStrstr (strstr)
+ * FUNCTION: strstr
*
* PARAMETERS: String1 - Target string
* String2 - Substring to search for
*
******************************************************************************/
+#ifdef __REACTOS__
char *
-AcpiUtStrstr (
+strstr (
+ const char *String1,
+ const char *String2)
+#else /* __REACTOS **/
+char *
+strstr (
char *String1,
char *String2)
+#endif /* __REACTOS__ */
{
UINT32 Length;
- Length = AcpiUtStrlen (String2);
+ Length = strlen (String2);
if (!Length)
{
+#ifdef __REACTOS__
+ return (char *)(String1);
+#else /* __REACTOS__ */
return (String1);
+#endif /* __REACTOS__ */
}
- while (AcpiUtStrlen (String1) >= Length)
+ while (strlen (String1) >= Length)
{
- if (AcpiUtMemcmp (String1, String2, Length) == 0)
+ if (memcmp (String1, String2, Length) == 0)
{
+#ifdef __REACTOS__
+ return (char *)(String1);
+#else /* __REACTOS__ */
return (String1);
+#endif /* __REACTOS__ */
}
String1++;
}
/*******************************************************************************
*
- * FUNCTION: AcpiUtStrtoul (strtoul)
+ * FUNCTION: strtoul
*
* PARAMETERS: String - Null terminated string
* Terminater - Where a pointer to the terminating byte is
* RETURN: Converted value
*
* DESCRIPTION: Convert a string into a 32-bit unsigned value.
- * Note: use AcpiUtStrtoul64 for 64-bit integers.
+ * Note: use strtoul64 for 64-bit integers.
*
******************************************************************************/
UINT32
-AcpiUtStrtoul (
+strtoul (
const char *String,
char **Terminator,
UINT32 Base)
* skip over any white space in the buffer:
*/
StringStart = String;
- while (ACPI_IS_SPACE (*String) || *String == '\t')
+ while (isspace (*String) || *String == '\t')
{
++String;
}
*/
if (*String == '-')
{
- sign = NEGATIVE;
+ sign = ACPI_SIGN_NEGATIVE;
++String;
}
else if (*String == '+')
{
++String;
- sign = POSITIVE;
+ sign = ACPI_SIGN_POSITIVE;
}
else
{
- sign = POSITIVE;
+ sign = ACPI_SIGN_POSITIVE;
}
/*
{
if (*String == '0')
{
- if (AcpiUtToLower (*(++String)) == 'x')
+ if (tolower (*(++String)) == 'x')
{
Base = 16;
++String;
if (Base == 16 &&
*String == '0' &&
- AcpiUtToLower (*(++String)) == 'x')
+ tolower (*(++String)) == 'x')
{
String++;
}
*/
while (*String)
{
- if (ACPI_IS_DIGIT (*String))
+ if (isdigit (*String))
{
index = (UINT32) ((UINT8) *String - '0');
}
else
{
- index = (UINT32) AcpiUtToUpper (*String);
- if (ACPI_IS_UPPER (index))
+ index = (UINT32) toupper (*String);
+ if (isupper (index))
{
index = index - 'A' + 10;
}
/*
* If a minus sign was present, then "the conversion is negated":
*/
- if (sign == NEGATIVE)
+ if (sign == ACPI_SIGN_NEGATIVE)
{
ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1;
}
/*******************************************************************************
*
- * FUNCTION: AcpiUtToUpper (TOUPPER)
+ * FUNCTION: toupper
*
* PARAMETERS: c - Character to convert
*
******************************************************************************/
int
-AcpiUtToUpper (
+toupper (
int c)
{
- return (ACPI_IS_LOWER(c) ? ((c)-0x20) : (c));
+ return (islower(c) ? ((c)-0x20) : (c));
}
/*******************************************************************************
*
- * FUNCTION: AcpiUtToLower (TOLOWER)
+ * FUNCTION: tolower
*
* PARAMETERS: c - Character to convert
*
******************************************************************************/
int
-AcpiUtToLower (
+tolower (
int c)
{
- return (ACPI_IS_UPPER(c) ? ((c)+0x20) : (c));
+ return (isupper(c) ? ((c)+0x20) : (c));
}
/*******************************************************************************
*
- * FUNCTION: is* functions
+ * FUNCTION: is* function array
*
* DESCRIPTION: is* functions use the ctype table below
*
******************************************************************************/
-const UINT8 _acpi_ctype[257] = {
+const UINT8 AcpiGbl_Ctypes[257] = {
_ACPI_CN, /* 0x00 0 NUL */
_ACPI_CN, /* 0x01 1 SOH */
_ACPI_CN, /* 0x02 2 STX */