Deploy ACPI_MOVE_NAME across ACPICA source base.

Replaces instances of strncpy(...,4) for ACPI_NAMEs.
ACPI_MOVE_NAME optimizes these to a single 32-bit copy on machines
that support misaligned transfers.
This commit is contained in:
Robert Moore 2012-10-12 12:54:03 -07:00
parent d4fa24b0bf
commit ef898130ec
12 changed files with 28 additions and 30 deletions

View File

@ -726,8 +726,8 @@ AcpiDmLoadDescendingOp (
while (AcpiGbl_PreDefinedNames[PreDefineIndex].Name)
{
if (!ACPI_STRNCMP (Node->Name.Ascii,
AcpiGbl_PreDefinedNames[PreDefineIndex].Name, 4))
if (ACPI_COMPARE_NAME (Node->Name.Ascii,
AcpiGbl_PreDefinedNames[PreDefineIndex].Name))
{
PreDefined = TRUE;
break;

View File

@ -517,7 +517,7 @@ CgWriteTableHeader (
/* Compiler ID */
strncpy (TableHeader.AslCompilerId, ASL_CREATOR_ID, 4);
ACPI_MOVE_NAME (TableHeader.AslCompilerId, ASL_CREATOR_ID);
/* Compiler version */

View File

@ -326,12 +326,11 @@ OptBuildShortestPath (
{
/* Compare two single NameSegs */
if (ACPI_STRNCMP (
&((char *) TargetPath->Pointer)[(NumCommonSegments *
ACPI_PATH_SEGMENT_LENGTH) + 1],
&((char *) CurrentPath->Pointer)[(NumCommonSegments *
ACPI_PATH_SEGMENT_LENGTH) + 1],
ACPI_NAME_SIZE))
if (!ACPI_COMPARE_NAME (
&((char *) TargetPath->Pointer)[
(NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1],
&((char *) CurrentPath->Pointer)[
(NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1]))
{
/* Mismatch */

View File

@ -908,7 +908,7 @@ UtAttachNameseg (
UtPadNameWithUnderscores (Name, PaddedNameSeg);
}
strncpy (Op->Asl.NameSeg, PaddedNameSeg, 4);
ACPI_MOVE_NAME (Op->Asl.NameSeg, PaddedNameSeg);
}

View File

@ -400,9 +400,9 @@ AcpiDbReadTable (
#ifdef ACPI_OBSOLETE_CODE
/* We only support a limited number of table types */
if (ACPI_STRNCMP ((char *) TableHeader.Signature, DSDT_SIG, 4) &&
ACPI_STRNCMP ((char *) TableHeader.Signature, PSDT_SIG, 4) &&
ACPI_STRNCMP ((char *) TableHeader.Signature, SSDT_SIG, 4))
if (!ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_DSDT) &&
!ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_PSDT) &&
!ACPI_COMPARE_NAME ((char *) TableHeader.Signature, ACPI_SIG_SSDT))
{
AcpiOsPrintf ("Table signature [%4.4s] is invalid or not supported\n",
(char *) TableHeader.Signature);

View File

@ -299,8 +299,7 @@ AcpiGetName (
/* Just copy the ACPI name from the Node and zero terminate it */
ACPI_STRNCPY (Buffer->Pointer, AcpiUtGetNodeName (Node),
ACPI_NAME_SIZE);
ACPI_MOVE_NAME (Buffer->Pointer, AcpiUtGetNodeName (Node));
((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0;
Status = AE_OK;

View File

@ -158,7 +158,7 @@ AcpiTbFindTable (
/* Normalize the input strings */
ACPI_MEMSET (&Header, 0, sizeof (ACPI_TABLE_HEADER));
ACPI_STRNCPY (Header.Signature, Signature, ACPI_NAME_SIZE);
ACPI_MOVE_NAME (Header.Signature, Signature);
ACPI_STRNCPY (Header.OemId, OemId, ACPI_OEM_ID_SIZE);
ACPI_STRNCPY (Header.OemTableId, OemTableId, ACPI_OEM_TABLE_ID_SIZE);

View File

@ -340,8 +340,8 @@ AcpiOsTableOverride (
/* Construct a null-terminated string from table signature */
ACPI_MOVE_NAME (TableName, ExistingTable->Signature);
TableName[ACPI_NAME_SIZE] = 0;
ACPI_STRNCPY (TableName, ExistingTable->Signature, ACPI_NAME_SIZE);
*NewTable = OsGetTable (TableName);
if (*NewTable)

View File

@ -743,7 +743,7 @@ AbExtractAmlFile (
{
/* The 4-char ACPI signature appears at the beginning of a line */
if (!strncmp (Buffer, TableSig, 4))
if (ACPI_COMPARE_NAME (Buffer, TableSig))
{
printf ("Found table [%4.4s]\n", TableSig);

View File

@ -245,7 +245,7 @@ AeBuildLocalTables (
}
ACPI_MEMSET (LocalXSDT, 0, XsdtSize);
ACPI_STRNCPY (LocalXSDT->Header.Signature, ACPI_SIG_XSDT, 4);
ACPI_MOVE_NAME (LocalXSDT->Header.Signature, ACPI_SIG_XSDT);
LocalXSDT->Header.Length = XsdtSize;
LocalXSDT->Header.Revision = 1;
@ -379,7 +379,7 @@ AeBuildLocalTables (
* Build a local FADT so we can test the hardware/event init
*/
ACPI_MEMSET (&LocalFADT, 0, sizeof (ACPI_TABLE_FADT));
ACPI_STRNCPY (LocalFADT.Header.Signature, ACPI_SIG_FADT, 4);
ACPI_MOVE_NAME (LocalFADT.Header.Signature, ACPI_SIG_FADT);
/* Setup FADT header and DSDT/FACS addresses */
@ -430,7 +430,7 @@ AeBuildLocalTables (
/* Build a FACS */
ACPI_MEMSET (&LocalFACS, 0, sizeof (ACPI_TABLE_FACS));
ACPI_STRNCPY (LocalFACS.Signature, ACPI_SIG_FACS, 4);
ACPI_MOVE_NAME (LocalFACS.Signature, ACPI_SIG_FACS);
LocalFACS.Length = sizeof (ACPI_TABLE_FACS);
LocalFACS.GlobalLock = 0x11AA0011;
@ -440,7 +440,7 @@ AeBuildLocalTables (
* ACPICA core ignores it
*/
ACPI_MEMSET (&LocalTEST, 0, sizeof (ACPI_TABLE_HEADER));
ACPI_STRNCPY (LocalTEST.Signature, "TEST", 4);
ACPI_MOVE_NAME (LocalTEST.Signature, "TEST");
LocalTEST.Revision = 1;
LocalTEST.Length = sizeof (ACPI_TABLE_HEADER);
@ -452,7 +452,7 @@ AeBuildLocalTables (
* sure that the ACPICA core ignores it
*/
ACPI_MEMSET (&LocalBADTABLE, 0, sizeof (ACPI_TABLE_HEADER));
ACPI_STRNCPY (LocalBADTABLE.Signature, "BAD!", 4);
ACPI_MOVE_NAME (LocalBADTABLE.Signature, "BAD!");
LocalBADTABLE.Revision = 1;
LocalBADTABLE.Length = sizeof (ACPI_TABLE_HEADER);

View File

@ -201,7 +201,7 @@ AeBuildLocalTables (
}
ACPI_MEMSET (LocalXSDT, 0, XsdtSize);
ACPI_STRNCPY (LocalXSDT->Header.Signature, ACPI_SIG_XSDT, 4);
ACPI_MOVE_NAME (LocalXSDT->Header.Signature, ACPI_SIG_XSDT);
LocalXSDT->Header.Length = XsdtSize;
LocalXSDT->Header.Revision = 1;
@ -294,7 +294,7 @@ AeBuildLocalTables (
* Build a local FADT so we can test the hardware/event init
*/
ACPI_MEMSET (&LocalFADT, 0, sizeof (ACPI_TABLE_FADT));
ACPI_STRNCPY (LocalFADT.Header.Signature, ACPI_SIG_FADT, 4);
ACPI_MOVE_NAME (LocalFADT.Header.Signature, ACPI_SIG_FADT);
/* Setup FADT header and DSDT/FACS addresses */
@ -345,7 +345,7 @@ AeBuildLocalTables (
/* Build a FACS */
ACPI_MEMSET (&LocalFACS, 0, sizeof (ACPI_TABLE_FACS));
ACPI_STRNCPY (LocalFACS.Signature, ACPI_SIG_FACS, 4);
ACPI_MOVE_NAME (LocalFACS.Signature, ACPI_SIG_FACS);
LocalFACS.Length = sizeof (ACPI_TABLE_FACS);
LocalFACS.GlobalLock = 0x11AA0011;

View File

@ -424,7 +424,7 @@ AxCountTableInstances (
}
AxNormalizeSignature (InstanceBuffer);
if (!strncmp (InstanceBuffer, Signature, 4))
if (ACPI_COMPARE_NAME (InstanceBuffer, Signature))
{
Instances++;
}
@ -599,13 +599,13 @@ AxExtractTables (
}
AxNormalizeSignature (LineBuffer);
strncpy (ThisSignature, LineBuffer, 4);
ACPI_MOVE_NAME (ThisSignature, LineBuffer);
if (Signature)
{
/* Ignore signatures that don't match */
if (strncmp (ThisSignature, Signature, 4))
if (!ACPI_COMPARE_NAME (ThisSignature, Signature))
{
continue;
}
@ -788,7 +788,7 @@ AxListTables (
/* FACS has only signature and length */
if (!strncmp (TableHeader->Signature, "FACS", 4))
if (ACPI_COMPARE_NAME (TableHeader->Signature, "FACS"))
{
printf ("\n");
continue;