use a union cast to assert alignment of string constant. trunk
authorchristos <christos@NetBSD.org>
Fri, 17 May 2019 20:27:48 +0000
branchtrunk
changeset 451359 efceab0edae9
parent 451358 c6194b9c1643
child 451360 a65b289c282b
use a union cast to assert alignment of string constant.
sys/external/bsd/acpica/dist/events/evregion.c
sys/external/bsd/acpica/dist/include/actypes.h
--- a/sys/external/bsd/acpica/dist/events/evregion.c	Fri May 17 18:50:40 2019 +0000
+++ b/sys/external/bsd/acpica/dist/events/evregion.c	Fri May 17 20:27:48 2019 +0000
@@ -581,7 +581,7 @@
     ACPI_EVALUATE_INFO      *Info;
     ACPI_OPERAND_OBJECT     *Args[3];
     ACPI_OPERAND_OBJECT     *RegionObj2;
-    const ACPI_NAME         *RegNamePtr = ACPI_CAST_PTR (ACPI_NAME, METHOD_NAME__REG);
+    const ACPI_NAME         *RegNamePtr = ACPI_ALIGNED_STR_UNION (ACPI_NAME, METHOD_NAME__REG);
     ACPI_NAMESPACE_NODE     *MethodNode;
     ACPI_NAMESPACE_NODE     *Node;
     ACPI_STATUS             Status;
--- a/sys/external/bsd/acpica/dist/include/actypes.h	Fri May 17 18:50:40 2019 +0000
+++ b/sys/external/bsd/acpica/dist/include/actypes.h	Fri May 17 20:27:48 2019 +0000
@@ -540,6 +540,10 @@
 
 #define ACPI_ARRAY_LENGTH(x)            (sizeof(x) / sizeof((x)[0]))
 
+/* Use a union to align  string s to type t */
+#define ACPI_ALIGNED_STR_UNION(t, s)	\
+    (&((const union { char _s[sizeof(t)]; t _t; }){ s }._t))
+
 /* Pointer manipulation */
 
 #define ACPI_CAST_PTR(t, p)             ((t *) (ACPI_UINTPTR_T) (p))