uapi: Make generic uapi headers compile standalone.
Subsystems (17)
PATCH 1/1 uapi: Make generic uapi headers compile standalone.
In order for static analysis tools to analyze each of the uapi headers, we need to enable them to compile stand-alone. Some uapi headers were missing dependencies which would not make them compile stand-alone in user-land. This patch adds those dependencies.
Test: make defconfig; make -j64
Test: make ARCH=arm64 defconfig;
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make -j64 all
Test: ran header-abi-dumper[1] on all the affected headers with
appropriate include paths[2] for arm64. eg: for drm_fourcc.h,
$HEADER_ABI_DUMPER -o drm_fourcc.h.sdump \include/uapi/drm/drm_fourcc.h -- -target aarch64-linux-android -std=gnu99 \
-isystem $CLANG_INCLUDE_PATH \
-I include/uapi/ -I arch/arm64/include/generated/uapi \
-I arch/arm64/include/uapi -I private-compiler-headers
-I include/generated/uapi \
-I include/uapi/../../arch/arm/include/uapi
where
HEADER_ABI_DUMPER=\
$ANDROID_BUILD_TOP/prebuilts/clang-tools/linux-x86/bin/header-abi-dumper
CLANG_INCLUDE_PATH=\
$ANDROID_BUILD_TOP/prebuilts/clang/host/linux-x86/clang-3289846/bin/../lib64/clang/3.8/include
on a lunched aosp tree [3]
[1]
header-abi-dumper is a clang based static analysis tool, used by android's build system which parses a C/C++ source file and emits information about the data types included in the source. More information can be found at
https://android.googlesource.com/platform/development/+/master/vndk/tools/header-checker/README.md
[2]
Some headers, eg: compiler_types.h, compiler.h, sys/socket.h are not in the set of uapi headers, even though they are included by uapi headers( include/uapi/linux/types.h, include/uapi/asm-generic/signal-defs.h etc). The 'private-compiler-headers' in the test clause was included with private copies of these headers. libc distributions (eg: bionic) often have their copies of these headers as well.
[3]
https://source.android.com/setup/build/downloading
--- include/uapi/asm-generic/ipcbuf.h | 2 ++ include/uapi/asm-generic/msgbuf.h | 3 +++ include/uapi/asm-generic/sembuf.h | 2 ++ include/uapi/asm-generic/shmbuf.h | 2 ++ include/uapi/asm-generic/ucontext.h | 5 +++++ include/uapi/linux/agpgart.h | 1 - include/uapi/linux/android/binder.h | 1 + include/uapi/linux/chio.h | 6 ++++++ include/uapi/linux/coda_psdev.h | 1 + include/uapi/linux/dvb/dmx.h | 3 --- include/uapi/linux/dvb/video.h | 3 --- include/uapi/linux/errqueue.h | 1 + include/uapi/linux/kexec.h | 1 + include/uapi/linux/kfd_ioctl.h | 1 + include/uapi/linux/lightnvm.h | 1 - include/uapi/linux/ndctl.h | 1 + include/uapi/linux/netfilter_bridge/ebtables.h | 1 + include/uapi/linux/nfs4_mount.h | 3 +++ include/uapi/linux/psp-sev.h | 1 + include/uapi/linux/scc.h | 2 +- include/uapi/linux/sctp.h | 3 +++ include/uapi/linux/sdla.h | 2 ++ include/uapi/linux/socket.h | 4 ++++ include/uapi/linux/stddef.h | 5 +++++ include/uapi/linux/sysctl.h | 1 + include/uapi/linux/types.h | 1 + include/uapi/linux/vbox_vmmdev_types.h | 1 + include/uapi/linux/vboxguest.h | 1 + include/uapi/rdma/hfi/hfi1_user.h | 1 + include/uapi/scsi/scsi_bsg_fc.h | 2 ++ include/uapi/scsi/scsi_netlink.h | 1 + include/uapi/sound/asound.h | 2 +- 32 files changed, 55 insertions(+), 10 deletions(-)
include/uapi/asm-generic/ipcbuf.h +2 -0
@@ -2,6 +2,8 @@#ifndef __ASM_GENERIC_IPCBUF_H#define __ASM_GENERIC_IPCBUF_H +#include <linux/posix_types.h> +/* * The generic ipc64_perm structure: * Note extra padding because this structure is passed back and forth
include/uapi/asm-generic/msgbuf.h +3 -0
@@ -3,6 +3,9 @@#define __ASM_GENERIC_MSGBUF_H#include <asm/bitsperlong.h> +#include <asm-generic/ipcbuf.h> +#include <linux/posix_types.h> +/* * generic msqid64_ds structure. *
include/uapi/asm-generic/sembuf.h +2 -0
@@ -3,6 +3,8 @@#define __ASM_GENERIC_SEMBUF_H#include <asm/bitsperlong.h> +#include <asm-generic/ipcbuf.h> +#include <linux/posix_types.h> /* * The semid64_ds structure for x86 architecture.
include/uapi/asm-generic/shmbuf.h +2 -0
@@ -3,6 +3,8 @@#define __ASM_GENERIC_SHMBUF_H#include <asm/bitsperlong.h> +#include <asm-generic/ipcbuf.h> +#include <stddef.h> /* * The shmid64_ds structure for x86 architecture.
include/uapi/asm-generic/ucontext.h +5 -0
@@ -2,6 +2,11 @@ #ifndef __ASM_GENERIC_UCONTEXT_H #define __ASM_GENERIC_UCONTEXT_H +#ifndef __KERNEL__ +#include <asm-generic/signal.h> +#include <asm/sigcontext.h> +#endif + struct ucontext { unsigned long uc_flags; struct ucontext *uc_link;
include/uapi/linux/agpgart.h +0 -1
@@ -52,7 +52,6 @@ #ifndef __KERNEL__ #include <linux/types.h> -#include <stdlib.h> struct agp_version { __u16 major;
include/uapi/linux/android/binder.h +1 -0
@@ -23,6 +23,7 @@#include <linux/types.h> #include <linux/ioctl.h> +#include <sys/types.h> #define B_PACK_CHARS (c1, c2, c3, c4) \ ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4))
include/uapi/linux/chio.h +6 -0
@@ -3,6 +3,11 @@* ioctl interface for the scsi media changer driver */ +#ifndef _UAPI_CHIO_H +#define _UAPI_CHIO_H + +#include <linux/compiler.h> +/* changer element types */ #define CHET_MT 0/* media transport element (robot) */ #define CHET_ST 1/* storage element (media slots) */
@@ -167,3 +172,4 @@ struct changer_set_voltag {* c-basic-offset: 8 * End: */ +#endif
include/uapi/linux/coda_psdev.h +1 -0
@@ -3,6 +3,7 @@#define _UAPI__CODA_PSDEV_H#include <linux/magic.h> +#include <sys/types.h> #define CODA_PSDEV_MAJOR 67#define MAX_CODADEVS 5/* how many do we allow */
include/uapi/linux/dvb/dmx.h +0 -3
@@ -26,9 +26,6 @@#define _UAPI_DVBDMX_H_#include <linux/types.h> -#ifndef __KERNEL__ -#include <time.h> -#endif #define DMX_FILTER_SIZE 16
include/uapi/linux/dvb/video.h +0 -3
@@ -26,9 +26,6 @@#define _UAPI_DVBVIDEO_H_#include <linux/types.h> -#ifndef __KERNEL__ -#include <time.h> -#endif typedef enum { VIDEO_FORMAT_4_3, /* Select 4:3 format */
include/uapi/linux/errqueue.h +1 -0
@@ -2,6 +2,7 @@#ifndef _UAPI_LINUX_ERRQUEUE_H#define _UAPI_LINUX_ERRQUEUE_H +#include <linux/time.h> #include <linux/types.h> struct sock_extended_err {
include/uapi/linux/kexec.h +1 -0
@@ -8,6 +8,7 @@*/ #include <linux/types.h> +#include <stddef.h> /* kexec flags for different usage scenarios */ #define KEXEC_ON_CRASH 0x00000001
include/uapi/linux/kfd_ioctl.h +1 -0
@@ -25,6 +25,7 @@#include <drm/drm.h> #include <linux/ioctl.h> +#include <stdint.h> #define KFD_IOCTL_MAJOR_VERSION 1#define KFD_IOCTL_MINOR_VERSION 1
include/uapi/linux/lightnvm.h +0 -1
@@ -24,7 +24,6 @@#include <linux/kernel.h> #include <linux/ioctl.h> #else /* __KERNEL__ */ -#include <stdio.h> #include <sys/ioctl.h> #define DISK_NAME_LEN 32#endif /* __KERNEL__ */
include/uapi/linux/ndctl.h +1 -0
@@ -13,6 +13,7 @@#ifndef __NDCTL_H__#define __NDCTL_H__ +#include <linux/compiler.h> #include <linux/types.h> struct nd_cmd_dimm_flags {
include/uapi/linux/netfilter_bridge/ebtables.h +1 -0
@@ -16,6 +16,7 @@#include <linux/types.h> #include <linux/if.h> #include <linux/netfilter_bridge.h> +#include <stdint.h> #define EBT_TABLE_MAXNAMELEN 32#define EBT_CHAIN_MAXNAMELEN EBT_TABLE_MAXNAMELEN
include/uapi/linux/nfs4_mount.h +3 -0
@@ -19,6 +19,9 @@*/ #define NFS4_MOUNT_VERSION 1 +#include <linux/socket.h> /* for struct sockaddr. */ +#include <linux/compiler.h> +struct nfs_string {unsigned int len;const char __user * data;
include/uapi/linux/psp-sev.h +1 -0
@@ -18,6 +18,7 @@#define __PSP_SEV_USER_H__#include <linux/types.h> +#include <linux/compiler.h> /** * SEV platform commands
include/uapi/linux/scc.h +1 -1
@@ -4,7 +4,7 @@#ifndef _UAPI_SCC_H#define _UAPI_SCC_H - +#include <linux/sockios.h> /* selection of hardware types */ #define PA0HZP 0x00/* hardware type for PA0HZP SCC card and compatible */
include/uapi/linux/sctp.h +3 -0
@@ -56,6 +56,9 @@#include <linux/types.h> #include <linux/socket.h> +#ifndef __KERNEL__ +#include <stdint.h> +#endif typedef __s32 sctp_assoc_t ;
include/uapi/linux/sdla.h +2 -0
@@ -24,6 +24,8 @@#ifndef _UAPISDLA_H#define _UAPISDLA_H +#include <linux/compiler.h> +/* adapter type */ #define SDLA_TYPES #define SDLA_S502A 5020
include/uapi/linux/socket.h +4 -0
@@ -11,6 +11,10 @@typedef unsigned short __kernel_sa_family_t ; +#ifndef __KERNEL__ +#include <sys/socket.h> /* for struct sockaddr. */ +#endif +struct __kernel_sockaddr_storage {__kernel_sa_family_t ss_family;/* address family */ /* Following field(s) are implementation specific */
include/uapi/linux/stddef.h +5 -0
@@ -1,6 +1,11 @@/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __UAPI_STDDEF_H__ +#define __UAPI_STDDEF_H__ +#include <linux/compiler_types.h> #ifndef __always_inline#define __always_inline inline#endif + +#endif // __UAPI_STDDEF_H__
include/uapi/linux/sysctl.h +1 -0
@@ -26,6 +26,7 @@#include <linux/kernel.h> #include <linux/types.h> #include <linux/compiler.h> +#include <stddef.h> #define CTL_MAXNAME 10/* how many path components do we allow in a call to sysctl? In other words, what is
include/uapi/linux/types.h +1 -0
@@ -11,6 +11,7 @@#endif /* __EXPORTED_HEADERS__ */ #endif +#include <linux/compiler_types.h> #include <linux/posix_types.h>
include/uapi/linux/vbox_vmmdev_types.h +1 -0
@@ -11,6 +11,7 @@#include <asm/bitsperlong.h> #include <linux/types.h> +#include <linux/compiler.h> /* * We cannot use linux' compiletime_assert here because it expects to be used
include/uapi/linux/vboxguest.h +1 -0
@@ -9,6 +9,7 @@#define __UAPI_VBOXGUEST_H__#include <asm/bitsperlong.h> +#include <linux/compiler.h> #include <linux/ioctl.h> #include <linux/vbox_err.h> #include <linux/vbox_vmmdev_types.h>
include/uapi/rdma/hfi/hfi1_user.h +1 -0
@@ -58,6 +58,7 @@#define _LINUX__HFI1_USER_H#include <linux/types.h> +#include <linux/compiler.h> #include <rdma/rdma_user_ioctl.h> /*
include/uapi/scsi/scsi_bsg_fc.h +2 -0
@@ -23,6 +23,8 @@#ifndef SCSI_BSG_FC_H #define SCSI_BSG_FC_H +#include <stdint.h> +/* * This file intended to be included by both kernel and user space */
include/uapi/scsi/scsi_netlink.h +1 -0
@@ -25,6 +25,7 @@#include <linux/netlink.h> #include <linux/types.h> +#include <stdint.h> /* * This file intended to be included by both kernel and user space
include/uapi/sound/asound.h +1 -1
@@ -31,7 +31,7 @@#endif #ifndef __KERNEL__ -#include <stdlib.h> +#include <linux/time.h> #endif /*
Signature · 1 line
2.17.1.1185.g55be947832-goog