Skip to content

Commit 678e9c3

Browse files
committed
Merge branch 'asm-generic-headers-cleanup' into asm-generic
A series from Masahiro Yamada to clean up the uapi headers, making sure they can actually be included from user space without additional dependencies on either kernel headers or specific libc versions. * asm-generic-headers-cleanup: sparc: add asm/stat.h to UAPI compile-test coverage powerpc: add asm/stat.h to UAPI compile-test coverage mips: add asm/stat.h to UAPI compile-test coverage riscv: add linux/bpf_perf_event.h to UAPI compile-test coverage kbuild: prevent exported headers from including <stdlib.h>, <stdbool.h> agpgart.h: do not include <stdlib.h> from exported header
2 parents 03a679a + 31a088b commit 678e9c3

File tree

7 files changed

+40
-37
lines changed

7 files changed

+40
-37
lines changed

arch/mips/include/uapi/asm/stat.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
struct stat {
2020
unsigned st_dev;
2121
long st_pad1[3]; /* Reserved for network id */
22-
ino_t st_ino;
23-
mode_t st_mode;
22+
__kernel_ino_t st_ino;
23+
__kernel_mode_t st_mode;
2424
__u32 st_nlink;
25-
uid_t st_uid;
26-
gid_t st_gid;
25+
__kernel_uid_t st_uid;
26+
__kernel_gid_t st_gid;
2727
unsigned st_rdev;
2828
long st_pad2[2];
2929
long st_size;
@@ -55,11 +55,11 @@ struct stat64 {
5555

5656
unsigned long long st_ino;
5757

58-
mode_t st_mode;
58+
__kernel_mode_t st_mode;
5959
__u32 st_nlink;
6060

61-
uid_t st_uid;
62-
gid_t st_gid;
61+
__kernel_uid_t st_uid;
62+
__kernel_gid_t st_gid;
6363

6464
unsigned long st_rdev;
6565
unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */
@@ -96,11 +96,11 @@ struct stat {
9696

9797
unsigned long st_ino;
9898

99-
mode_t st_mode;
99+
__kernel_mode_t st_mode;
100100
__u32 st_nlink;
101101

102-
uid_t st_uid;
103-
gid_t st_gid;
102+
__kernel_uid_t st_uid;
103+
__kernel_gid_t st_gid;
104104

105105
unsigned int st_rdev;
106106
unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */

arch/powerpc/include/uapi/asm/stat.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ struct __old_kernel_stat {
2929

3030
struct stat {
3131
unsigned long st_dev;
32-
ino_t st_ino;
32+
__kernel_ino_t st_ino;
3333
#ifdef __powerpc64__
3434
unsigned long st_nlink;
35-
mode_t st_mode;
35+
__kernel_mode_t st_mode;
3636
#else
37-
mode_t st_mode;
37+
__kernel_mode_t st_mode;
3838
unsigned short st_nlink;
3939
#endif
40-
uid_t st_uid;
41-
gid_t st_gid;
40+
__kernel_uid_t st_uid;
41+
__kernel_gid_t st_gid;
4242
unsigned long st_rdev;
4343
long st_size;
4444
unsigned long st_blksize;

arch/sparc/include/uapi/asm/stat.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
/* 64 bit sparc */
99
struct stat {
1010
unsigned int st_dev;
11-
ino_t st_ino;
12-
mode_t st_mode;
11+
__kernel_ino_t st_ino;
12+
__kernel_mode_t st_mode;
1313
short st_nlink;
14-
uid_t st_uid;
15-
gid_t st_gid;
14+
__kernel_uid_t st_uid;
15+
__kernel_gid_t st_gid;
1616
unsigned int st_rdev;
1717
long st_size;
1818
long st_atime;
@@ -51,8 +51,8 @@ struct stat64 {
5151
/* 32 bit sparc */
5252
struct stat {
5353
unsigned short st_dev;
54-
ino_t st_ino;
55-
mode_t st_mode;
54+
__kernel_ino_t st_ino;
55+
__kernel_mode_t st_mode;
5656
short st_nlink;
5757
unsigned short st_uid;
5858
unsigned short st_gid;

include/uapi/linux/agpgart.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252

5353
#ifndef __KERNEL__
5454
#include <linux/types.h>
55-
#include <stdlib.h>
5655

5756
struct agp_version {
5857
__u16 major;
@@ -64,10 +63,10 @@ typedef struct _agp_info {
6463
__u32 bridge_id; /* bridge vendor/device */
6564
__u32 agp_mode; /* mode info of bridge */
6665
unsigned long aper_base;/* base of aperture */
67-
size_t aper_size; /* size of aperture */
68-
size_t pg_total; /* max pages (swap + system) */
69-
size_t pg_system; /* max pages (system) */
70-
size_t pg_used; /* current pages used */
66+
__kernel_size_t aper_size; /* size of aperture */
67+
__kernel_size_t pg_total; /* max pages (swap + system) */
68+
__kernel_size_t pg_system; /* max pages (system) */
69+
__kernel_size_t pg_used; /* current pages used */
7170
} agp_info;
7271

7372
typedef struct _agp_setup {

usr/dummy-include/stdbool.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
#ifndef _STDBOOL_H
3+
#define _STDBOOL_H
4+
5+
#error "Please do not include <stdbool.h> from exported headers"
6+
7+
#endif /* _STDBOOL_H */

usr/dummy-include/stdlib.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
#ifndef _STDLIB_H
3+
#define _STDLIB_H
4+
5+
#error "Please do not include <stdlib.h> from exported headers"
6+
7+
#endif /* _STDLIB_H */

usr/include/Makefile

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ UAPI_CFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
1515
# USERCFLAGS might contain sysroot location for CC.
1616
UAPI_CFLAGS += $(USERCFLAGS)
1717

18-
override c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I$(objtree)/usr/include
18+
override c_flags = $(UAPI_CFLAGS) -Wp,-MMD,$(depfile) -I $(obj) -I $(srctree)/usr/dummy-include
1919

2020
# The following are excluded for now because they fail to build.
2121
#
@@ -65,21 +65,11 @@ no-header-test += asm/sigcontext.h
6565
no-header-test += linux/if_bonding.h
6666
endif
6767

68-
ifeq ($(SRCARCH),mips)
69-
no-header-test += asm/stat.h
70-
endif
71-
7268
ifeq ($(SRCARCH),powerpc)
73-
no-header-test += asm/stat.h
74-
no-header-test += linux/bpf_perf_event.h
75-
endif
76-
77-
ifeq ($(SRCARCH),riscv)
7869
no-header-test += linux/bpf_perf_event.h
7970
endif
8071

8172
ifeq ($(SRCARCH),sparc)
82-
no-header-test += asm/stat.h
8373
no-header-test += asm/uctx.h
8474
no-header-test += asm/fbio.h
8575
endif

0 commit comments

Comments
 (0)