[PATCH v2 0/7] Don't use BIT() macro in UAPI headers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Joe Richey <joerichey@xxxxxxxxxx>

The BIT(n) macro is used in the kernel as an alias for (1 << n).
However, it is not defined in the UAPI headers, they should instead use
the _BITUL(n) macro. This patch chages all existing usages in UAPI
headers and updates ./scripts/checkpatch.pl to properly reccomend the
correct macro depending on context.

Running the below commands shows no more incorrect macro usages:
    rg "BIT\(" **/uapi/**
    rg "BIT_ULL\(" **/uapi/**

Tested by building a basic kernel. Changes are trivial.

I encountered this issue when compiling the following program:
    #include <sys/auxv.h>
    #include <asm/hwcap2.h>
    // Detect if FSGSBASE instructions are enabled
    int main() {
        unsigned long val = getauxval(AT_HWCAP2);
        return !(val & HWCAP2_FSGSBASE);

Resulting in the following likner error:
    /usr/bin/ld: /tmp/cceFpAdR.o: in function `main':
    gs.c:(.text+0x21): undefined reference to `BIT'

Changes from V1 to V2:
  - Use _BITUL() macro instead of open-coding
  - Fixup HWCAP2_RING3MWAIT as well
  - Shorten commits and added "Fixes" per reviewer comments
  - checkpatch: Broaden UAPI regex
  - checkpatch: Reccomend _BITULL()/_BITUL() for UAPI headers

Joe Richey (7):
  x86/elf: Use _BITUL() macro in UAPI headers
  KVM: X86: Use _BITUL() macro in UAPI headers
  drivers: firmware: psci:  Use _BITUL() macro in UAPI headers
  uacce: Use _BITUL() macro in UAPI headers
  media: vicodec: Use _BITUL() macro in UAPI headers
  tools headers UAPI: Sync pkt_sched.h with the kernel sources
  checkpatch: suggest _BITULL() and _BITUL() for UAPI headers

 arch/x86/include/uapi/asm/hwcap2.h   |   6 +-
 include/uapi/linux/kvm.h             |   5 +-
 include/uapi/linux/psci.h            |   4 +-
 include/uapi/linux/v4l2-controls.h   |  23 ++---
 include/uapi/misc/uacce/uacce.h      |   3 +-
 scripts/checkpatch.pl                |  16 ++--
 tools/include/uapi/linux/kvm.h       |   5 +-
 tools/include/uapi/linux/pkt_sched.h | 122 ++++++++++++++++++++++++---
 8 files changed, 148 insertions(+), 36 deletions(-)


[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux