opnsense-src/sys/contrib/dev/acpica/include
Dimitry Andric 7dfb8e02e3 Fix acpica macros that subtract null pointers
Clang 13.0.0 produces a new -Werror warning about the ACPI_TO_INTEGER(p)
and ACPI_OFFSET(d, f) macros in acpica's actypes.h:

    sys/contrib/dev/acpica/components/dispatcher/dsopcode.c:708:31: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
        ObjDesc->Region.Address = ACPI_PTR_TO_PHYSADDR (Table);
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    sys/contrib/dev/acpica/include/actypes.h:664:41: note: expanded from macro 'ACPI_PTR_TO_PHYSADDR'
    #define ACPI_PTR_TO_PHYSADDR(i)         ACPI_TO_INTEGER(i)
                                            ^~~~~~~~~~~~~~~~~~
    sys/contrib/dev/acpica/include/actypes.h:661:41: note: expanded from macro 'ACPI_TO_INTEGER'
    #define ACPI_TO_INTEGER(p)              ACPI_PTR_DIFF (p, (void *) 0)
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    sys/contrib/dev/acpica/include/actypes.h:656:82: note: expanded from macro 'ACPI_PTR_DIFF'
    #define ACPI_PTR_DIFF(a, b)             ((ACPI_SIZE) (ACPI_CAST_PTR (UINT8, (a)) - ACPI_CAST_PTR (UINT8, (b))))
                                                                                     ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.

This problem of undefined behavior was also reported to acpica by @cem
in 2018: https://github.com/acpica/acpica/issues/407, but it seems there
was never any fix committed for it upstream.

Instead fix these locally, for ACPI_TO_INTEGER by simply casting the
incoming pointer to ACPI_SIZE (which corresponds roughly to uintptr_t
and size_t), and for ACPI_OFFSET by reusing our __offsetof definition
from sys/cdefs.h.

Reviewed by:	emaste, kib, imp
Differential Revision: https://reviews.freebsd.org/D31710

(cherry picked from commit 130a690ae1)
2021-09-02 23:53:18 +02:00
..
platform MFV: r356607 2020-01-10 22:49:14 +00:00
acapps.h MFV: r356607 2020-01-10 22:49:14 +00:00
acbuffer.h MFV: r356607 2020-01-10 22:49:14 +00:00
acclib.h MFV: r356607 2020-01-10 22:49:14 +00:00
accommon.h MFV: r367652 2020-11-13 22:45:26 +00:00
acconfig.h MFV: r366539 2020-10-09 05:27:02 +00:00
acconvert.h MFV: r357927 2020-02-15 03:47:25 +00:00
acdebug.h MFV: r366539 2020-10-09 05:27:02 +00:00
acdisasm.h Merge ACPICA 20200326. 2020-03-27 00:29:33 +00:00
acdispat.h MFV: r356607 2020-01-10 22:49:14 +00:00
acevents.h MFV: r356607 2020-01-10 22:49:14 +00:00
acexcep.h MFV: r366539 2020-10-09 05:27:02 +00:00
acglobal.h MFV: r360512 2020-05-01 01:26:36 +00:00
achware.h MFV: r357927 2020-02-15 03:47:25 +00:00
acinterp.h MFV: r356607 2020-01-10 22:49:14 +00:00
aclocal.h MFV: r356607 2020-01-10 22:49:14 +00:00
acmacros.h MFV: r357927 2020-02-15 03:47:25 +00:00
acnames.h MFV: r356607 2020-01-10 22:49:14 +00:00
acnamesp.h Merge ACPICA 20200326. 2020-03-27 00:29:33 +00:00
acobject.h MFV: r356607 2020-01-10 22:49:14 +00:00
acopcode.h MFV: r356607 2020-01-10 22:49:14 +00:00
acoutput.h MFV: r356607 2020-01-10 22:49:14 +00:00
acparser.h MFV: r356607 2020-01-10 22:49:14 +00:00
acpi.h MFV: r356607 2020-01-10 22:49:14 +00:00
acpiosxf.h MFV: r356607 2020-01-10 22:49:14 +00:00
acpixf.h MFV: r367652 2020-11-13 22:45:26 +00:00
acpredef.h MFV: r366539 2020-10-09 05:27:02 +00:00
acresrc.h MFV: r356607 2020-01-10 22:49:14 +00:00
acrestyp.h MFV: r356607 2020-01-10 22:49:14 +00:00
acstruct.h MFV: r356607 2020-01-10 22:49:14 +00:00
actables.h MFV: r356607 2020-01-10 22:49:14 +00:00
actbinfo.h Merge ACPICA 20200326. 2020-03-27 00:29:33 +00:00
actbl.h MFV: r356607 2020-01-10 22:49:14 +00:00
actbl1.h MFV: r366539 2020-10-09 05:27:02 +00:00
actbl2.h Merge ACPICA 20200326. 2020-03-27 00:29:33 +00:00
actbl3.h Merge ACPICA 20200326. 2020-03-27 00:29:33 +00:00
actypes.h Fix acpica macros that subtract null pointers 2021-09-02 23:53:18 +02:00
acutils.h MFV: r356607 2020-01-10 22:49:14 +00:00
acuuid.h MFV: r367652 2020-11-13 22:45:26 +00:00
amlcode.h MFV: r356607 2020-01-10 22:49:14 +00:00
amlresrc.h MFV: r356607 2020-01-10 22:49:14 +00:00