summaryrefslogtreecommitdiff
path: root/include/acpi/actypes.h
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2022-01-11 16:55:25 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2022-01-25 18:41:23 +0100
commitae57857b9b6341096ddfd9c0cf26fb640c561160 (patch)
tree91295591eaeefcd5a5fa0c0198a859fa87c3e3e2 /include/acpi/actypes.h
parente783362eb54cd99b2cac8b3a9aeac942e6f6ac07 (diff)
ACPICA: Use uintptr_t and offsetof() in Linux kernel builds
To avoid "performing pointer subtraction with a null pointer has undefined behavior" compiler warnings, use uintptr_t and offsetof() that are always available during Linux kernel builds to define acpi_uintptr_t and the ACPI_TO_INTEGER() and ACPI_OFFSET() macros. Based on earlier proposal from Arnd Bergmann. Link: https://lore.kernel.org/linux-acpi/20210927121338.938994-1-arnd@kernel.org Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'include/acpi/actypes.h')
-rw-r--r--include/acpi/actypes.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 69e89d572b9e..02c1fa16e638 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -507,8 +507,12 @@ typedef u64 acpi_integer;
/* Pointer/Integer type conversions */
#define ACPI_TO_POINTER(i) ACPI_CAST_PTR (void, (acpi_size) (i))
+#ifndef ACPI_TO_INTEGER
#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) 0)
+#endif
+#ifndef ACPI_OFFSET
#define ACPI_OFFSET(d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0)
+#endif
#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i)
/* Optimizations for 4-character (32-bit) acpi_name manipulation */