Discussion:
[PATCH v05 01/72] headers_install.sh: enhance error handling
(too old to reply)
Mikko Rapeli
2016-08-22 18:40:02 UTC
Permalink
Exit with error if using undefined variables or if any sub command fails
with error return value. unidef needs special handling since but this can
be done without the trap. Enables examining intermediate files if some
commands failed.

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
scripts/headers_install.sh | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
index fdebd66..fe22807 100755
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -1,4 +1,6 @@
#!/bin/sh
+set -e
+set -u

if [ $# -lt 2 ]
then
@@ -26,7 +28,6 @@ shift
# Iterate through files listed on command line

FILE=
-trap 'rm -f "$OUTDIR/$FILE" "$OUTDIR/$FILE.sed"' EXIT
for i in "$@"
do
FILE="$(basename "$i")"
@@ -37,10 +38,13 @@ do
-e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
-e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g' \
-e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \
- "$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1
+ "$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || \
+ ( rm -f "$OUTDIR/$FILE.sed" ; exit 1 )
scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \
- > "$OUTDIR/$FILE"
- [ $? -gt 1 ] && exit 1
+ > "$OUTDIR/$FILE" || \
+ ( if [ $? -gt 1 ]; then \
+ rm -f "$OUTDIR/$FILE" "$OUTDIR/$FILE.sed" ; \
+ exit 1 ; \
+ fi )
rm -f "$OUTDIR/$FILE.sed"
done
-trap - EXIT
--
2.8.1
Mikko Rapeli
2016-08-22 18:40:02 UTC
Permalink
Fixes userspace compilation errors like:

scsi/scsi_netlink.h:43:2: error: unknown type name ‘uint8_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/scsi/scsi_netlink.h | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/uapi/scsi/scsi_netlink.h b/include/uapi/scsi/scsi_netlink.h
index 62b4eda..36b53a76 100644
--- a/include/uapi/scsi/scsi_netlink.h
+++ b/include/uapi/scsi/scsi_netlink.h
@@ -22,8 +22,8 @@
#ifndef SCSI_NETLINK_H
#define SCSI_NETLINK_H

-#include <linux/netlink.h>
#include <linux/types.h>
+#include <linux/netlink.h>

/*
* This file intended to be included by both kernel and user space
@@ -40,12 +40,12 @@

/* SCSI_TRANSPORT_MSG event message header */
struct scsi_nl_hdr {
- uint8_t version;
- uint8_t transport;
- uint16_t magic;
- uint16_t msgtype;
- uint16_t msglen;
-} __attribute__((aligned(sizeof(uint64_t))));
+ __u8 version;
+ __u8 transport;
+ __u16 magic;
+ __u16 msgtype;
+ __u16 msglen;
+} __attribute__((aligned(sizeof(__u64))));

/* scsi_nl_hdr->version value */
#define SCSI_NL_VERSION 1
@@ -89,10 +89,10 @@ struct scsi_nl_hdr {
*/
struct scsi_nl_host_vendor_msg {
struct scsi_nl_hdr snlh; /* must be 1st element ! */
- uint64_t vendor_id;
- uint16_t host_no;
- uint16_t vmsg_datalen;
-} __attribute__((aligned(sizeof(uint64_t))));
+ __u64 vendor_id;
+ __u16 host_no;
+ __u16 vmsg_datalen;
+} __attribute__((aligned(sizeof(__u64))));


/*
--
2.8.1
Mikko Rapeli
2016-08-22 18:40:02 UTC
Permalink
Fixes userspace compilation errors like:

linux/sctp.h:652:2: error: unknown type name ‘uint32_t’

Acked-by: Neil Horman <***@tuxdriver.com>
Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/sctp.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
index a406adc..ab697b3 100644
--- a/include/uapi/linux/sctp.h
+++ b/include/uapi/linux/sctp.h
@@ -743,13 +743,13 @@ struct sctp_authkeyid {
*/
struct sctp_sack_info {
sctp_assoc_t sack_assoc_id;
- uint32_t sack_delay;
- uint32_t sack_freq;
+ __u32 sack_delay;
+ __u32 sack_freq;
};

struct sctp_assoc_value {
- sctp_assoc_t assoc_id;
- uint32_t assoc_value;
+ sctp_assoc_t assoc_id;
+ __u32 assoc_value;
};

/*
@@ -819,7 +819,7 @@ struct sctp_status {
struct sctp_authchunks {
sctp_assoc_t gauth_assoc_id;
__u32 gauth_number_of_chunks;
- uint8_t gauth_chunks[];
+ __u8 gauth_chunks[];
};

/* The broken spelling has been released already in lksctp-tools header,
--
2.8.1
Mikko Rapeli
2016-08-22 18:40:02 UTC
Permalink
Fixes userspace compilation errors like:

linux/dm-log-userspace.h:416:2: error: unknown type name ‘uint64_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/dm-log-userspace.h | 43 ++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/include/uapi/linux/dm-log-userspace.h b/include/uapi/linux/dm-log-userspace.h
index 0fa0d9e..c5ff216 100644
--- a/include/uapi/linux/dm-log-userspace.h
+++ b/include/uapi/linux/dm-log-userspace.h
@@ -7,6 +7,7 @@
#ifndef __DM_LOG_USERSPACE_H__
#define __DM_LOG_USERSPACE_H__

+#include <linux/types.h>
#include <linux/dm-ioctl.h> /* For DM_UUID_LEN */

/*
@@ -147,12 +148,12 @@

/*
* DM_ULOG_GET_REGION_SIZE corresponds to (found in dm-dirty-log.h):
- * uint32_t (*get_region_size)(struct dm_dirty_log *log);
+ * __u32 (*get_region_size)(struct dm_dirty_log *log);
*
* Payload-to-userspace:
* None.
* Payload-to-kernel:
- * uint64_t - contains the region size
+ * __u64 - contains the region size
*
* The region size is something that was determined at constructor time.
* It is returned in the payload area and 'data_size' is set to
@@ -168,11 +169,11 @@
* int (*is_clean)(struct dm_dirty_log *log, region_t region);
*
* Payload-to-userspace:
- * uint64_t - the region to get clean status on
+ * __u64 - the region to get clean status on
* Payload-to-kernel:
* int64_t - 1 if clean, 0 otherwise
*
- * Payload is sizeof(uint64_t) and contains the region for which the clean
+ * Payload is sizeof(__u64) and contains the region for which the clean
* status is being made.
*
* When the request has been processed, user-space must return the
@@ -187,7 +188,7 @@
* int can_block);
*
* Payload-to-userspace:
- * uint64_t - the region to get sync status on
+ * __u64 - the region to get sync status on
* Payload-to-kernel:
* int64_t - 1 if in-sync, 0 otherwise
*
@@ -203,7 +204,7 @@
* Payload-to-userspace:
* If the 'integrated_flush' directive is present in the constructor
* table, the payload is as same as DM_ULOG_MARK_REGION:
- * uint64_t [] - region(s) to mark
+ * __u64 [] - region(s) to mark
* else
* None
* Payload-to-kernel:
@@ -225,13 +226,13 @@
* void (*mark_region)(struct dm_dirty_log *log, region_t region);
*
* Payload-to-userspace:
- * uint64_t [] - region(s) to mark
+ * __u64 [] - region(s) to mark
* Payload-to-kernel:
* None.
*
* Incoming payload contains the one or more regions to mark dirty.
* The number of regions contained in the payload can be determined from
- * 'data_size/sizeof(uint64_t)'.
+ * 'data_size/sizeof(__u64)'.
*
* When the request has been processed, user-space must return the
* dm_ulog_request to the kernel - setting the 'error' field and clearing
@@ -244,13 +245,13 @@
* void (*clear_region)(struct dm_dirty_log *log, region_t region);
*
* Payload-to-userspace:
- * uint64_t [] - region(s) to clear
+ * __u64 [] - region(s) to clear
* Payload-to-kernel:
* None.
*
* Incoming payload contains the one or more regions to mark clean.
* The number of regions contained in the payload can be determined from
- * 'data_size/sizeof(uint64_t)'.
+ * 'data_size/sizeof(__u64)'.
*
* When the request has been processed, user-space must return the
* dm_ulog_request to the kernel - setting the 'error' field and clearing
@@ -267,7 +268,7 @@
* Payload-to-kernel:
* {
* int64_t i; -- 1 if recovery necessary, 0 otherwise
- * uint64_t r; -- The region to recover if i=1
+ * __u64 r; -- The region to recover if i=1
* }
* 'data_size' should be set appropriately.
*
@@ -283,7 +284,7 @@
*
* Payload-to-userspace:
* {
- * uint64_t - region to set sync state on
+ * __u64 - region to set sync state on
* int64_t - 0 if not-in-sync, 1 if in-sync
* }
* Payload-to-kernel:
@@ -302,7 +303,7 @@
* Payload-to-userspace:
* None.
* Payload-to-kernel:
- * uint64_t - the number of in-sync regions
+ * __u64 - the number of in-sync regions
*
* No incoming payload. Kernel-bound payload contains the number of
* regions that are in-sync (in a size_t).
@@ -350,11 +351,11 @@
* int (*is_remote_recovering)(struct dm_dirty_log *log, region_t region);
*
* Payload-to-userspace:
- * uint64_t - region to determine recovery status on
+ * __u64 - region to determine recovery status on
* Payload-to-kernel:
* {
* int64_t is_recovering; -- 0 if no, 1 if yes
- * uint64_t in_sync_hint; -- lowest region still needing resync
+ * __u64 in_sync_hint; -- lowest region still needing resync
* }
*
* When the request has been processed, user-space must return the
@@ -413,16 +414,16 @@ struct dm_ulog_request {
* differentiate between logs that are being swapped and have the
* same 'uuid'. (Think "live" and "inactive" device-mapper tables.)
*/
- uint64_t luid;
+ __u64 luid;
char uuid[DM_UUID_LEN];
char padding[3]; /* Padding because DM_UUID_LEN = 129 */

- uint32_t version; /* See DM_ULOG_REQUEST_VERSION */
- int32_t error; /* Used to report back processing errors */
+ __u32 version; /* See DM_ULOG_REQUEST_VERSION */
+ __s32 error; /* Used to report back processing errors */

- uint32_t seq; /* Sequence number for request */
- uint32_t request_type; /* DM_ULOG_* defined above */
- uint32_t data_size; /* How much data (not including this struct) */
+ __u32 seq; /* Sequence number for request */
+ __u32 request_type; /* DM_ULOG_* defined above */
+ __u32 data_size; /* How much data (not including this struct) */

char data[0];
};
--
2.8.1
Mikko Rapeli
2016-08-22 18:40:02 UTC
Permalink
Fixes userspace compilation error:

error: ‘SIOCDEVPRIVATE’ undeclared here (not in a function)
SIOCSCCRESERVED = SIOCDEVPRIVATE

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/scc.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/scc.h b/include/uapi/linux/scc.h
index 72b6b81..2992b88 100644
--- a/include/uapi/linux/scc.h
+++ b/include/uapi/linux/scc.h
@@ -3,6 +3,7 @@
#ifndef _UAPI_SCC_H
#define _UAPI_SCC_H

+#include <linux/sockios.h>

/* selection of hardware types */
--
2.8.1
Mikko Rapeli
2016-08-22 18:40:02 UTC
Permalink
Fixes userspace compilation errors about unknown pid_t, u_short etc types.

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/coda.h | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/coda.h b/include/uapi/linux/coda.h
index 695fade..fab3bd0 100644
--- a/include/uapi/linux/coda.h
+++ b/include/uapi/linux/coda.h
@@ -100,7 +100,14 @@ typedef unsigned long long u_quad_t;
#if defined(__linux__)
#include <linux/time.h>
#define cdev_t u_quad_t
+typedef unsigned long u_long;
+typedef unsigned int u_int;
+typedef unsigned short u_short;
+typedef u_long ino_t;
+
#ifndef __KERNEL__
+typedef u_long dev_t;
+typedef void *caddr_t;
#if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
#define _UQUAD_T_ 1
typedef unsigned long long u_quad_t;
@@ -295,8 +302,8 @@ struct coda_statfs {
struct coda_in_hdr {
u_int32_t opcode;
u_int32_t unique; /* Keep multiple outstanding msgs distinct */
- pid_t pid;
- pid_t pgid;
+ __kernel_pid_t pid;
+ __kernel_pid_t pgid;
vuid_t uid;
};
--
2.8.1
kbuild test robot
2016-08-23 03:10:01 UTC
Permalink
Hi Mikko,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.8-rc3]
[cannot apply to next-20160822]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url: https://github.com/0day-ci/linux/commits/Mikko-Rapeli/Userspace-compile-test-and-fixes-for-exported-uapi-header-files/20160823-034928
config: x86_64-randconfig-v0-08230740 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

All errors (new ones prefixed by >>):

In file included from include/linux/coda.h:64,
include/uapi/linux/coda.h:103: error: redefinition of typedef 'u_long'
include/linux/types.h:86: note: previous declaration of 'u_long' was here
include/uapi/linux/coda.h:104: error: redefinition of typedef 'u_int'
include/linux/types.h:85: note: previous declaration of 'u_int' was here
include/uapi/linux/coda.h:105: error: redefinition of typedef 'u_short'
include/linux/types.h:84: note: previous declaration of 'u_short' was here
include/uapi/linux/coda.h:106: error: redefinition of typedef 'ino_t'
include/linux/types.h:16: note: previous declaration of 'ino_t' was here

vim +/u_long +103 include/uapi/linux/coda.h

97 #endif /* !DJGPP */
98
99
100 #if defined(__linux__)
101 #include <linux/time.h>
102 #define cdev_t u_quad_t
103 typedef unsigned long u_long;
104 typedef unsigned int u_int;
105 typedef unsigned short u_short;
106 typedef u_long ino_t;
107
108 #ifndef __KERNEL__
109 typedef u_long dev_t;

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Mikko Rapeli
2016-08-22 18:40:02 UTC
Permalink
Fixes userspace compilation error:

error: unknown type name ‘size_t’
size_t bufsz;

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/kexec.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/kexec.h b/include/uapi/linux/kexec.h
index aae5ebf..f964d83 100644
--- a/include/uapi/linux/kexec.h
+++ b/include/uapi/linux/kexec.h
@@ -51,9 +51,9 @@
*/
struct kexec_segment {
const void *buf;
- size_t bufsz;
+ __kernel_size_t bufsz;
const void *mem;
- size_t memsz;
+ __kernel_size_t memsz;
};

#endif /* __KERNEL__ */
--
2.8.1
Mikko Rapeli
2016-08-22 18:40:02 UTC
Permalink
Fixes userspace compile errors like:

error: field ‘sem_perm’ has incomplete type
struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
error: unknown type name ‘__kernel_time_t’
__kernel_time_t sem_otime; /* last semop time */

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
arch/x86/include/uapi/asm/sembuf.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/x86/include/uapi/asm/sembuf.h b/arch/x86/include/uapi/asm/sembuf.h
index cc2d6a3..f11ed52 100644
--- a/arch/x86/include/uapi/asm/sembuf.h
+++ b/arch/x86/include/uapi/asm/sembuf.h
@@ -1,6 +1,9 @@
#ifndef _ASM_X86_SEMBUF_H
#define _ASM_X86_SEMBUF_H

+#include <linux/types.h>
+#include <linux/ipc.h>
+
/*
* The semid64_ds structure for x86 architecture.
* Note extra padding because this structure is passed back and forth
--
2.8.1
Mikko Rapeli
2016-08-22 18:40:02 UTC
Permalink
Fixes userspace compilation error:

error: unknown type name ‘__kernel_key_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/asm-generic/ipcbuf.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/uapi/asm-generic/ipcbuf.h b/include/uapi/asm-generic/ipcbuf.h
index 3dbcc1e..909f825 100644
--- a/include/uapi/asm-generic/ipcbuf.h
+++ b/include/uapi/asm-generic/ipcbuf.h
@@ -1,6 +1,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
--
2.8.1
Mikko Rapeli
2016-08-22 18:40:02 UTC
Permalink
Would be nice to be able to compile all userspace header files also alone.

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/patchkey.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/patchkey.h b/include/uapi/linux/patchkey.h
index 1bda0e5..cee195d 100644
--- a/include/uapi/linux/patchkey.h
+++ b/include/uapi/linux/patchkey.h
@@ -11,7 +11,7 @@
*/

#ifndef _LINUX_PATCHKEY_H_INDIRECT
-#error "patchkey.h included directly"
+#warning "patchkey.h included directly"
#endif

#ifndef _UAPI_LINUX_PATCHKEY_H
--
2.8.1
Mikko Rapeli
2016-08-22 18:40:02 UTC
Permalink
Fixes userspace compilation errors like:

scsi/scsi_netlink_fc.h:60:2: error: expected specifier-qualifier-list before ‘uint64_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/scsi/scsi_netlink_fc.h | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/uapi/scsi/scsi_netlink_fc.h b/include/uapi/scsi/scsi_netlink_fc.h
index cbf76e4..2493a0f 100644
--- a/include/uapi/scsi/scsi_netlink_fc.h
+++ b/include/uapi/scsi/scsi_netlink_fc.h
@@ -57,14 +57,14 @@
*/
struct fc_nl_event {
struct scsi_nl_hdr snlh; /* must be 1st element ! */
- uint64_t seconds;
- uint64_t vendor_id;
- uint16_t host_no;
- uint16_t event_datalen;
- uint32_t event_num;
- uint32_t event_code;
- uint32_t event_data;
-} __attribute__((aligned(sizeof(uint64_t))));
+ __u64 seconds;
+ __u64 vendor_id;
+ __u16 host_no;
+ __u16 event_datalen;
+ __u32 event_num;
+ __u32 event_code;
+ __u32 event_data;
+} __attribute__((aligned(sizeof(__u64))));


#endif /* SCSI_NETLINK_FC_H */
--
2.8.1
Mikko Rapeli
2016-08-22 18:40:02 UTC
Permalink
Fixes userspace compilation errors like:

linux/nfsd/cld.h:40:2: error: unknown type name ‘uint16_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/nfsd/cld.h | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/uapi/linux/nfsd/cld.h b/include/uapi/linux/nfsd/cld.h
index f14a9ab..d9f2306 100644
--- a/include/uapi/linux/nfsd/cld.h
+++ b/include/uapi/linux/nfsd/cld.h
@@ -22,6 +22,8 @@
#ifndef _NFSD_CLD_H
#define _NFSD_CLD_H

+#include <linux/types.h>
+
/* latest upcall version available */
#define CLD_UPCALL_VERSION 1

@@ -37,18 +39,18 @@ enum cld_command {

/* representation of long-form NFSv4 client ID */
struct cld_name {
- uint16_t cn_len; /* length of cm_id */
+ __u16 cn_len; /* length of cm_id */
unsigned char cn_id[NFS4_OPAQUE_LIMIT]; /* client-provided */
} __attribute__((packed));

/* message struct for communication with userspace */
struct cld_msg {
- uint8_t cm_vers; /* upcall version */
- uint8_t cm_cmd; /* upcall command */
- int16_t cm_status; /* return code */
- uint32_t cm_xid; /* transaction id */
+ __u8 cm_vers; /* upcall version */
+ __u8 cm_cmd; /* upcall command */
+ __s16 cm_status; /* return code */
+ __u32 cm_xid; /* transaction id */
union {
- int64_t cm_gracetime; /* grace period start time */
+ __s64 cm_gracetime; /* grace period start time */
struct cld_name cm_name;
} __attribute__((packed)) cm_u;
} __attribute__((packed));
--
2.8.1
Mikko Rapeli
2016-08-22 18:40:02 UTC
Permalink
Include linux/types.h and asm/msgbuf.h and use __kernel_size_t instead
of size_t.

Fixes userspace compilation errors like:

error: field ‘shm_perm’ has incomplete type
struct ipc64_perm shm_perm; /* operation perms */
error: unknown type name ‘size_t’
error: unknown type name ‘__kernel_time_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/asm-generic/shmbuf.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/uapi/asm-generic/shmbuf.h b/include/uapi/asm-generic/shmbuf.h
index 7e9fb2f..ae867ad 100644
--- a/include/uapi/asm-generic/shmbuf.h
+++ b/include/uapi/asm-generic/shmbuf.h
@@ -1,7 +1,9 @@
#ifndef __ASM_GENERIC_SHMBUF_H
#define __ASM_GENERIC_SHMBUF_H

+#include <linux/types.h>
#include <asm/bitsperlong.h>
+#include <asm/msgbuf.h>

/*
* The shmid64_ds structure for x86 architecture.
@@ -24,7 +26,7 @@

struct shmid64_ds {
struct ipc64_perm shm_perm; /* operation perms */
- size_t shm_segsz; /* size of segment (bytes) */
+ __kernel_size_t shm_segsz; /* size of segment (bytes) */
__kernel_time_t shm_atime; /* last attach time */
#if __BITS_PER_LONG != 64
unsigned long __unused1;
--
2.8.1
Mikko Rapeli
2016-08-22 18:40:02 UTC
Permalink
Fixes userspace compilation error:

error: unknown type name ‘size_t’
size_t length;

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/reiserfs_xattr.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/reiserfs_xattr.h b/include/uapi/linux/reiserfs_xattr.h
index 38fdd64..af52b38 100644
--- a/include/uapi/linux/reiserfs_xattr.h
+++ b/include/uapi/linux/reiserfs_xattr.h
@@ -18,7 +18,7 @@ struct reiserfs_xattr_header {
struct reiserfs_security_handle {
const char *name;
void *value;
- size_t length;
+ __kernel_size_t length;
};

#endif /* _LINUX_REISERFS_XATTR_H */
--
2.8.1
Mikko Rapeli
2016-08-22 18:40:03 UTC
Permalink
Fixes userspace compilation errors like:

scsi/scsi_bsg_fc.h:83:2: error: unknown type name ‘uint8_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/scsi/scsi_bsg_fc.h | 54 +++++++++++++++++++++--------------------
1 file changed, 28 insertions(+), 26 deletions(-)

diff --git a/include/uapi/scsi/scsi_bsg_fc.h b/include/uapi/scsi/scsi_bsg_fc.h
index 3031b90..1a20447 100644
--- a/include/uapi/scsi/scsi_bsg_fc.h
+++ b/include/uapi/scsi/scsi_bsg_fc.h
@@ -22,6 +22,8 @@
#ifndef SCSI_BSG_FC_H
#define SCSI_BSG_FC_H

+#include <linux/types.h>
+
/*
* This file intended to be included by both kernel and user space
*/
@@ -80,10 +82,10 @@
* with the transport upon completion of the login.
*/
struct fc_bsg_host_add_rport {
- uint8_t reserved;
+ __u8 reserved;

/* FC Address Identier of the remote port to login to */
- uint8_t port_id[3];
+ __u8 port_id[3];
};

/* Response:
@@ -101,10 +103,10 @@ struct fc_bsg_host_add_rport {
* remain logged in with the remote port.
*/
struct fc_bsg_host_del_rport {
- uint8_t reserved;
+ __u8 reserved;

/* FC Address Identier of the remote port to logout of */
- uint8_t port_id[3];
+ __u8 port_id[3];
};

/* Response:
@@ -125,10 +127,10 @@ struct fc_bsg_host_els {
* ELS Command Code being sent (must be the same as byte 0
* of the payload)
*/
- uint8_t command_code;
+ __u8 command_code;

/* FC Address Identier of the remote port to send the ELS to */
- uint8_t port_id[3];
+ __u8 port_id[3];
};

/* Response:
@@ -165,14 +167,14 @@ struct fc_bsg_ctels_reply {
* Note: x_RJT/BSY status will indicae that the rjt_data field
* is valid and contains the reason/explanation values.
*/
- uint32_t status; /* See FC_CTELS_STATUS_xxx */
+ __u32 status; /* See FC_CTELS_STATUS_xxx */

/* valid if status is not FC_CTELS_STATUS_OK */
struct {
- uint8_t action; /* fragment_id for CT REJECT */
- uint8_t reason_code;
- uint8_t reason_explanation;
- uint8_t vendor_unique;
+ __u8 action; /* fragment_id for CT REJECT */
+ __u8 reason_code;
+ __u8 reason_explanation;
+ __u8 vendor_unique;
} rjt_data;
};

@@ -188,17 +190,17 @@ struct fc_bsg_ctels_reply {
* and whether to tear it down after the request.
*/
struct fc_bsg_host_ct {
- uint8_t reserved;
+ __u8 reserved;

/* FC Address Identier of the remote port to send the ELS to */
- uint8_t port_id[3];
+ __u8 port_id[3];

/*
* We need words 0-2 of the generic preamble for the LLD's
*/
- uint32_t preamble_word0; /* revision & IN_ID */
- uint32_t preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
- uint32_t preamble_word2; /* Cmd Code, Max Size */
+ __u32 preamble_word0; /* revision & IN_ID */
+ __u32 preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
+ __u32 preamble_word2; /* Cmd Code, Max Size */

};
/* Response:
@@ -218,17 +220,17 @@ struct fc_bsg_host_vendor {
* Identifies the vendor that the message is formatted for. This
* should be the recipient of the message.
*/
- uint64_t vendor_id;
+ __u64 vendor_id;

/* start of vendor command area */
- uint32_t vendor_cmd[0];
+ __u32 vendor_cmd[0];
};

/* Response:
*/
struct fc_bsg_host_vendor_reply {
/* start of vendor response area */
- uint32_t vendor_rsp[0];
+ __u32 vendor_rsp[0];
};


@@ -247,7 +249,7 @@ struct fc_bsg_rport_els {
* ELS Command Code being sent (must be the same as
* byte 0 of the payload)
*/
- uint8_t els_code;
+ __u8 els_code;
};

/* Response:
@@ -265,9 +267,9 @@ struct fc_bsg_rport_ct {
/*
* We need words 0-2 of the generic preamble for the LLD's
*/
- uint32_t preamble_word0; /* revision & IN_ID */
- uint32_t preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
- uint32_t preamble_word2; /* Cmd Code, Max Size */
+ __u32 preamble_word0; /* revision & IN_ID */
+ __u32 preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
+ __u32 preamble_word2; /* Cmd Code, Max Size */
};
/* Response:
*
@@ -279,7 +281,7 @@ struct fc_bsg_rport_ct {

/* request (CDB) structure of the sg_io_v4 */
struct fc_bsg_request {
- uint32_t msgcode;
+ __u32 msgcode;
union {
struct fc_bsg_host_add_rport h_addrport;
struct fc_bsg_host_del_rport h_delrport;
@@ -303,10 +305,10 @@ struct fc_bsg_reply {
* msg and status fields. The per-msgcode reply structure
* will contain valid data.
*/
- uint32_t result;
+ __u32 result;

/* If there was reply_payload, how much was recevied ? */
- uint32_t reply_payload_rcv_len;
+ __u32 reply_payload_rcv_len;

union {
struct fc_bsg_host_vendor_reply vendor_reply;
--
2.8.1
Mikko Rapeli
2016-08-22 18:40:03 UTC
Permalink
Fixes userspace compilation errors:

error: unknown type name ‘pid_t’
pid_t sender_pid
error: unknown type name ‘uid_t’
uid_t sender_euid;

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/android/binder.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/android/binder.h b/include/uapi/linux/android/binder.h
index 41420e3..4e4a385 100644
--- a/include/uapi/linux/android/binder.h
+++ b/include/uapi/linux/android/binder.h
@@ -142,8 +142,8 @@ struct binder_transaction_data {

/* General information about the transaction. */
__u32 flags;
- pid_t sender_pid;
- uid_t sender_euid;
+ __kernel_pid_t sender_pid;
+ __kernel_uid_t sender_euid;
binder_size_t data_size; /* number of bytes of data */
binder_size_t offsets_size; /* number of bytes of offsets */
--
2.8.1
Mikko Rapeli
2016-08-22 18:40:03 UTC
Permalink
Fixes userspace compilation errors like:

error: field ‘msg_perm’ has incomplete type
struct ipc64_perm msg_perm

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/asm-generic/msgbuf.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/uapi/asm-generic/msgbuf.h b/include/uapi/asm-generic/msgbuf.h
index f55ecc4..f5fbd8e 100644
--- a/include/uapi/asm-generic/msgbuf.h
+++ b/include/uapi/asm-generic/msgbuf.h
@@ -2,6 +2,8 @@
#define __ASM_GENERIC_MSGBUF_H

#include <asm/bitsperlong.h>
+#include <asm/ipcbuf.h>
+
/*
* generic msqid64_ds structure.
*
--
2.8.1
Mikko Rapeli
2016-08-22 18:40:03 UTC
Permalink
Fixes userspace compilation errors like:

linux/rds.h:96:2: error: unknown type name ‘uint8_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/rds.h | 102 +++++++++++++++++++++++------------------------
1 file changed, 51 insertions(+), 51 deletions(-)

diff --git a/include/uapi/linux/rds.h b/include/uapi/linux/rds.h
index 0f9265c..5bf0368 100644
--- a/include/uapi/linux/rds.h
+++ b/include/uapi/linux/rds.h
@@ -103,8 +103,8 @@
#define RDS_INFO_LAST 10010

struct rds_info_counter {
- uint8_t name[32];
- uint64_t value;
+ __u8 name[32];
+ __u64 value;
} __attribute__((packed));

#define RDS_INFO_CONNECTION_FLAG_SENDING 0x01
@@ -114,35 +114,35 @@ struct rds_info_counter {
#define TRANSNAMSIZ 16

struct rds_info_connection {
- uint64_t next_tx_seq;
- uint64_t next_rx_seq;
+ __u64 next_tx_seq;
+ __u64 next_rx_seq;
__be32 laddr;
__be32 faddr;
- uint8_t transport[TRANSNAMSIZ]; /* null term ascii */
- uint8_t flags;
+ __u8 transport[TRANSNAMSIZ]; /* null term ascii */
+ __u8 flags;
} __attribute__((packed));

#define RDS_INFO_MESSAGE_FLAG_ACK 0x01
#define RDS_INFO_MESSAGE_FLAG_FAST_ACK 0x02

struct rds_info_message {
- uint64_t seq;
- uint32_t len;
+ __u64 seq;
+ __u32 len;
__be32 laddr;
__be32 faddr;
__be16 lport;
__be16 fport;
- uint8_t flags;
+ __u8 flags;
} __attribute__((packed));

struct rds_info_socket {
- uint32_t sndbuf;
+ __u32 sndbuf;
__be32 bound_addr;
__be32 connected_addr;
__be16 bound_port;
__be16 connected_port;
- uint32_t rcvbuf;
- uint64_t inum;
+ __u32 rcvbuf;
+ __u64 inum;
} __attribute__((packed));

struct rds_info_tcp_socket {
@@ -150,25 +150,25 @@ struct rds_info_tcp_socket {
__be16 local_port;
__be32 peer_addr;
__be16 peer_port;
- uint64_t hdr_rem;
- uint64_t data_rem;
- uint32_t last_sent_nxt;
- uint32_t last_expected_una;
- uint32_t last_seen_una;
+ __u64 hdr_rem;
+ __u64 data_rem;
+ __u32 last_sent_nxt;
+ __u32 last_expected_una;
+ __u32 last_seen_una;
} __attribute__((packed));

#define RDS_IB_GID_LEN 16
struct rds_info_rdma_connection {
__be32 src_addr;
__be32 dst_addr;
- uint8_t src_gid[RDS_IB_GID_LEN];
- uint8_t dst_gid[RDS_IB_GID_LEN];
+ __u8 src_gid[RDS_IB_GID_LEN];
+ __u8 dst_gid[RDS_IB_GID_LEN];

- uint32_t max_send_wr;
- uint32_t max_recv_wr;
- uint32_t max_send_sge;
- uint32_t rdma_mr_max;
- uint32_t rdma_mr_size;
+ __u32 max_send_wr;
+ __u32 max_recv_wr;
+ __u32 max_send_sge;
+ __u32 rdma_mr_max;
+ __u32 rdma_mr_size;
};

/*
@@ -209,70 +209,70 @@ struct rds_info_rdma_connection {
* (so that the application does not have to worry about
* alignment).
*/
-typedef uint64_t rds_rdma_cookie_t;
+typedef __u64 rds_rdma_cookie_t;

struct rds_iovec {
- uint64_t addr;
- uint64_t bytes;
+ __u64 addr;
+ __u64 bytes;
};

struct rds_get_mr_args {
struct rds_iovec vec;
- uint64_t cookie_addr;
- uint64_t flags;
+ __u64 cookie_addr;
+ __u64 flags;
};

struct rds_get_mr_for_dest_args {
struct sockaddr_storage dest_addr;
struct rds_iovec vec;
- uint64_t cookie_addr;
- uint64_t flags;
+ __u64 cookie_addr;
+ __u64 flags;
};

struct rds_free_mr_args {
rds_rdma_cookie_t cookie;
- uint64_t flags;
+ __u64 flags;
};

struct rds_rdma_args {
rds_rdma_cookie_t cookie;
struct rds_iovec remote_vec;
- uint64_t local_vec_addr;
- uint64_t nr_local;
- uint64_t flags;
- uint64_t user_token;
+ __u64 local_vec_addr;
+ __u64 nr_local;
+ __u64 flags;
+ __u64 user_token;
};

struct rds_atomic_args {
rds_rdma_cookie_t cookie;
- uint64_t local_addr;
- uint64_t remote_addr;
+ __u64 local_addr;
+ __u64 remote_addr;
union {
struct {
- uint64_t compare;
- uint64_t swap;
+ __u64 compare;
+ __u64 swap;
} cswp;
struct {
- uint64_t add;
+ __u64 add;
} fadd;
struct {
- uint64_t compare;
- uint64_t swap;
- uint64_t compare_mask;
- uint64_t swap_mask;
+ __u64 compare;
+ __u64 swap;
+ __u64 compare_mask;
+ __u64 swap_mask;
} m_cswp;
struct {
- uint64_t add;
- uint64_t nocarry_mask;
+ __u64 add;
+ __u64 nocarry_mask;
} m_fadd;
};
- uint64_t flags;
- uint64_t user_token;
+ __u64 flags;
+ __u64 user_token;
};

struct rds_rdma_notify {
- uint64_t user_token;
- int32_t status;
+ __u64 user_token;
+ __s32 status;
};

#define RDS_RDMA_SUCCESS 0
--
2.8.1
Sowmini Varadhan
2016-08-22 19:00:02 UTC
Permalink
Post by Mikko Rapeli
linux/rds.h:96:2: error: unknown type name ‘uint8_t’
Acked-by: Sowmini Varadhan <***@oracle.com>

I think we discussed this some time before, and I certainly
dont have any religious opinions about it, but I would like
to point out that this means that the exported rds.h will
expose __<type> to user space applications.

--Sowmini
Mikko Rapeli
2016-08-22 18:40:03 UTC
Permalink
The test is to compile all kernel uapi headers against the
non-conflicting set of all GNU libc headers. The test covers
variants where kernel header is included before libc header
and libc header before kernel header.

Tested in Debian unstable with libc6 version 2.22-4.

Example execution:

$ make headers_install && \
cd usr/include && \
../../scripts/headers_compile_test.sh -lk
Testing that /home/mcfrisk/src/linux-2.6/usr/headers_compile_test_include.rwDf0l
/libc_headers.h compiles
cc -Wall -c -nostdinc -I /usr/lib/gcc/i686-linux-gnu/6/include -I /usr/lib/gcc/i
686-linux-gnu/6/include-fixed -I . -I /home/mcfrisk/src/linux-2.6/usr/headers_co
mpile_test_include.rwDf0l -I /home/mcfrisk/src/linux-2.6/usr/headers_compile_tes
t_include.rwDf0l/i686-linux-gnu -o /dev/null ./drm/i810_drm.h
PASSED: ./drm/i810_drm.h
cc -Wall -c -nostdinc -I /usr/lib/gcc/i686-linux-gnu/6/include -I /usr/lib/gcc/i
686-linux-gnu/6/include-fixed -I . -I /home/mcfrisk/src/linux-2.6/usr/headers_co
mpile_test_include.rwDf0l -I /home/mcfrisk/src/linux-2.6/usr/headers_compile_tes
t_include.rwDf0l/i686-linux-gnu -o /dev/null ./drm/i810_drm.h_libc_before_kernel
.h
PASSED libc before kernel test: ./drm/i810_drm.h
...
cc -Wall -c -nostdinc -I /usr/lib/gcc/i686-linux-gnu/6/include -I /usr/lib/gcc/i
686-linux-gnu/6/include-fixed -I . -I /home/mcfrisk/src/linux-2.6/usr/headers_co
mpile_test_include.rwDf0l -I /home/mcfrisk/src/linux-2.6/usr/headers_compile_tes
t_include.rwDf0l/i686-linux-gnu -o /dev/null ./linux/coda.h
PASSED: ./linux/coda.h
cc -Wall -c -nostdinc -I /usr/lib/gcc/i686-linux-gnu/6/include -I /usr/lib/gcc/i
686-linux-gnu/6/include-fixed -I . -I /home/mcfrisk/src/linux-2.6/usr/headers_co
mpile_test_include.rwDf0l -I /home/mcfrisk/src/linux-2.6/usr/headers_compile_tes
t_include.rwDf0l/i686-linux-gnu -o /dev/null ./linux/coda.h_libc_before_kernel.h
In file included from ./linux/coda.h_libc_before_kernel.h:2:0:
./linux/coda.h:108:16: error: conflicting types for ‘dev_t’
typedef u_long dev_t;
^~~~~
In file included from /home/mcfrisk/src/linux-2.6/usr/headers_compile_test_inclu
de.rwDf0l/aio.h:26:0,
from /home/mcfrisk/src/linux-2.6/usr/headers_compile_test_inclu
de.rwDf0l/libc_headers.h:1,
from ./linux/coda.h_libc_before_kernel.h:1:
/home/mcfrisk/src/linux-2.6/usr/headers_compile_test_include.rwDf0l/sys/types.h:
60:17: note: previous declaration of ‘dev_t’ was here
typedef __dev_t dev_t;
^~~~~
In file included from ./linux/coda.h_libc_before_kernel.h:2:0:
./linux/coda.h:109:16: error: conflicting types for ‘caddr_t’
typedef void * caddr_t;
^~~~~~~
In file included from /home/mcfrisk/src/linux-2.6/usr/headers_compile_test_include.rwDf0l/aio.h:26:0,
from /home/mcfrisk/src/linux-2.6/usr/headers_compile_test_include.rwDf0l/libc_headers.h:1,
from ./linux/coda.h_libc_before_kernel.h:1:
/home/mcfrisk/src/linux-2.6/usr/headers_compile_test_include.rwDf0l/sys/types.h:116:19: note: previous declaration of ‘caddr_t’ was here
typedef __caddr_t caddr_t;
^~~~~~~
FAILED libc before kernel test: ./linux/coda.h
...
Kernel header compile test statistics:

0 files failed the kernel header compile test.
784 files passed the kernel header compile test.

libc and kernel header compatibility test statistics:
39 files failed libc before kernel include test.
745 files passed libc before kernel include test.

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
scripts/headers_compile_test.sh | 329 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 319 insertions(+), 10 deletions(-)

diff --git a/scripts/headers_compile_test.sh b/scripts/headers_compile_test.sh
index e13f533..94021b6 100755
--- a/scripts/headers_compile_test.sh
+++ b/scripts/headers_compile_test.sh
@@ -15,14 +15,19 @@ Execute in root directory of exported kernel headers in Linux kernel source
tree. Sets up gcc and libc headers without existing kernel headers to
a temporary environment and tries to compile all exported header files
from current directory against them. Return value is zero if all tests pass,
-non-zero if something goes wrong during execution, or the amount of files
-which failed the compile test.
+non-zero if something goes wrong during execution or if any file failed
+the compile tests.

Supported arguments:

- -h|--help print help
- -k|--keep don't cleanup temporary header files and directories
- -v|--verbose print more verbose output
+ -h|--help print help
+ -k|--keep don't cleanup temporary header files and directories
+ -lk|--libc-kernel test for conflicts between kernel and libc headers
+ when libc headers are included before kernel headers
+ -kl|--kernel-libc test for conflicts between kernel and libc headers
+ when kernel headers are included before libc headers
+ -l|--libc test both -lk and -kl
+ -v|--verbose print more verbose output

Example in Linux kernel source tree:

@@ -38,6 +43,9 @@ set -euo pipefail

KEEP=0
HELP=0
+LIBC_TEST=0
+LIBC_KERNEL_TEST=0
+KERNEL_LIBC_TEST=0

# command line arguments
for p in "$@"; do
@@ -45,6 +53,19 @@ for p in "$@"; do
-k|--keep)
KEEP=1
;;
+ -l|--libc)
+ LIBC_TEST=1
+ LIBC_KERNEL_TEST=1
+ KERNEL_LIBC_TEST=1
+ ;;
+ -lk|--libc-kernel)
+ LIBC_TEST=1
+ LIBC_KERNEL_TEST=1
+ ;;
+ -kl|--kernel-libc)
+ LIBC_TEST=1
+ KERNEL_LIBC_TEST=1
+ ;;
-h|--help)
HELP=1
;;
@@ -138,6 +159,164 @@ for d in $LIBC; do
fi
done

+# A single header with all non-conflicting libc headers to test kernel
+# headers against libc headers for conflicts.
+if [ "$LIBC_TEST" != 0 ]; then
+ # List taken from Debian unstable libc6 version 2.21-9.
+ # Some glibc headers conflict with each other so they
+ # are filtered out. Not perfect but better than nothing.
+ #
+ # $ for f in $( egrep "\.h$" /var/lib/dpkg/info/libc6-dev\:i386.list | sed -e 's|/usr/include/||'| sort | grep -v arpa | grep -v linux-gnu | grep -v rpcsvc | grep -v regexp.h | grep -v rpc | grep -v scsi | grep -v talkd ); do echo "#include <$f>"; done > libc_headers.h
+
+ cat > "$COMPILE_TEST_INC/libc_headers.h" << EOF_LIBC_HEADERS
+#include <aio.h>
+#include <aliases.h>
+#include <alloca.h>
+#include <argp.h>
+#include <argz.h>
+#include <ar.h>
+#include <assert.h>
+#include <byteswap.h>
+#include <complex.h>
+#include <cpio.h>
+#include <crypt.h>
+#include <ctype.h>
+#include <dirent.h>
+#include <dlfcn.h>
+#include <elf.h>
+#include <endian.h>
+#include <envz.h>
+#include <err.h>
+#include <errno.h>
+#include <error.h>
+#include <execinfo.h>
+#include <fcntl.h>
+#include <features.h>
+#include <fenv.h>
+#include <fmtmsg.h>
+#include <fnmatch.h>
+#include <fstab.h>
+#include <fts.h>
+#include <ftw.h>
+#include <_G_config.h>
+#include <gconv.h>
+#include <getopt.h>
+#include <glob.h>
+#include <gnu-versions.h>
+#include <grp.h>
+#include <gshadow.h>
+#include <iconv.h>
+#include <ifaddrs.h>
+#include <inttypes.h>
+#include <langinfo.h>
+#include <lastlog.h>
+#include <libgen.h>
+#include <libintl.h>
+#include <libio.h>
+#include <limits.h>
+#include <link.h>
+#include <locale.h>
+#include <malloc.h>
+#include <math.h>
+#include <mcheck.h>
+#include <memory.h>
+#include <mntent.h>
+#include <monetary.h>
+#include <mqueue.h>
+#include <netash/ash.h>
+#include <netatalk/at.h>
+#include <netax25/ax25.h>
+#include <netdb.h>
+#include <neteconet/ec.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/if.h>
+#include <net/if_packet.h>
+#include <net/if_ppp.h>
+#include <net/if_shaper.h>
+#include <net/if_slip.h>
+#include <netinet/ether.h>
+#include <netinet/icmp6.h>
+#include <netinet/if_ether.h>
+#include <netinet/if_fddi.h>
+#include <netinet/if_tr.h>
+#include <netinet/igmp.h>
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/ip6.h>
+#include <netinet/ip.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/tcp.h>
+#include <netinet/udp.h>
+#include <netipx/ipx.h>
+#include <netiucv/iucv.h>
+#include <netpacket/packet.h>
+#include <net/ppp-comp.h>
+#include <net/ppp_defs.h>
+#include <netrom/netrom.h>
+#include <netrose/rose.h>
+#include <net/route.h>
+#include <nfs/nfs.h>
+#include <nl_types.h>
+#include <nss.h>
+#include <obstack.h>
+#include <paths.h>
+#include <poll.h>
+#include <printf.h>
+#include <protocols/routed.h>
+#include <protocols/rwhod.h>
+#include <protocols/timed.h>
+#include <pthread.h>
+#include <pty.h>
+#include <pwd.h>
+#include <re_comp.h>
+#include <regex.h>
+#include <resolv.h>
+#include <sched.h>
+#include <search.h>
+#include <semaphore.h>
+#include <setjmp.h>
+#include <sgtty.h>
+#include <shadow.h>
+#include <signal.h>
+#include <spawn.h>
+#include <stab.h>
+#include <stdc-predef.h>
+#include <stdint.h>
+#include <stdio_ext.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <stropts.h>
+#include <syscall.h>
+#include <sysexits.h>
+#include <syslog.h>
+#include <tar.h>
+#include <termio.h>
+#include <termios.h>
+#include <tgmath.h>
+#include <thread_db.h>
+#include <time.h>
+#include <ttyent.h>
+#include <uchar.h>
+#include <ucontext.h>
+#include <ulimit.h>
+#include <unistd.h>
+#include <ustat.h>
+#include <utime.h>
+#include <utmp.h>
+#include <utmpx.h>
+#include <values.h>
+#include <wait.h>
+#include <wchar.h>
+#include <wctype.h>
+#include <wordexp.h>
+#include <xlocale.h>
+EOF_LIBC_HEADERS
+
+fi # LIBC_TEST
+
# Simulate libc headers without kernel headers by removing
# all known kernel header dirs from the copied libc ones.
# This seems to magically work.
@@ -170,11 +349,32 @@ if [ "$GCC_INC"foobar == "foobar" ]; then
fi
set -u

-# For each header file, try to compile it using the headers we prepared.
+# sanity check: test that plain libc headers compile
+if [ "$LIBC_TEST" != 0 ]; then
+ echo "Testing that $COMPILE_TEST_INC/libc_headers.h compiles"
+ $CC -Wall -c -nostdinc $GCC_INC -I . \
+ -I "$COMPILE_TEST_INC" \
+ -I "$COMPILE_TEST_INC/$ARCH_TRIPLET" \
+ -o /dev/null \
+ "$COMPILE_TEST_INC/libc_headers.h"
+fi
+
+# Summary counters:
_FAILED=0
_PASSED=0
+_LIBC_FAILED=0
+_LIBC_PASSED=0
+_LIBC_BEFORE_KERNEL_FAILED=0
+_LIBC_BEFORE_KERNEL_PASSED=0
+_KERNEL_BEFORE_LIBC_FAILED=0
+_KERNEL_BEFORE_LIBC_PASSED=0
+
+# For each header file, try to compile it using the headers we prepared.
for f in $( find . -name "*\.h" | xargs ); do
_FAIL=0
+ _FAIL_LIBC=0
+ _FAIL_LIBC_BEFORE_KERNEL=0
+ _FAIL_KERNEL_BEFORE_LIBC=0

# compile test, CC not quoted to support ccache
echo $CC -Wall -c -nostdinc $GCC_INC -I . -I "$COMPILE_TEST_INC" -I "$COMPILE_TEST_INC/$ARCH_TRIPLET" -o /dev/null "$f"
@@ -189,10 +389,119 @@ for f in $( find . -name "*\.h" | xargs ); do
echo "PASSED: $f"
_PASSED="$(( _PASSED + 1))"
fi
+
+ # libc header conflict tests
+ if [ "$LIBC_TEST" != 0 ]; then
+ _LIBC_BEFORE_KERNEL="$f"_libc_before_kernel.h
+ _KERNEL_BEFORE_LIBC="$f"_kernel_before_libc.h
+
+ # libc header included before kernel header
+ if [ "$LIBC_KERNEL_TEST" != 0 ]; then
+ cat > "$_LIBC_BEFORE_KERNEL" << EOF_LIBC_BEFORE_KERNEL
+#include <libc_headers.h>
+#include <$( echo "$f" | cut -c3- )>
+EOF_LIBC_BEFORE_KERNEL
+ echo \
+ $CC -Wall -c -nostdinc $GCC_INC \
+ -I . -I "$COMPILE_TEST_INC" \
+ -I "$COMPILE_TEST_INC/$ARCH_TRIPLET" \
+ -o /dev/null "$_LIBC_BEFORE_KERNEL"
+ $CC -Wall -c -nostdinc $GCC_INC \
+ -I . -I "$COMPILE_TEST_INC" \
+ -I "$COMPILE_TEST_INC/$ARCH_TRIPLET" \
+ -o /dev/null "$_LIBC_BEFORE_KERNEL" \
+ || _FAIL_LIBC_BEFORE_KERNEL=1
+
+ # report errors
+ if [ "$_FAIL_LIBC_BEFORE_KERNEL" -gt 0 ]; then
+ echo "FAILED libc before kernel test: $f"
+ _LIBC_BEFORE_KERNEL_FAILED="$(( _LIBC_BEFORE_KERNEL_FAILED + 1 ))"
+ else
+ echo "PASSED libc before kernel test: $f"
+ _LIBC_BEFORE_KERNEL_PASSED="$(( _LIBC_BEFORE_KERNEL_PASSED + 1))"
+ fi
+ fi
+
+ # kernel header included before libc
+ if [ "$KERNEL_LIBC_TEST" != 0 ]; then
+ cat > "$_KERNEL_BEFORE_LIBC" << EOF_KERNEL_BEFORE_LIBC
+#include <$( echo "$f" | cut -c3- )>
+#include <libc_headers.h>
+EOF_KERNEL_BEFORE_LIBC
+ echo \
+ $CC -Wall -c -nostdinc $GCC_INC \
+ -I . -I "$COMPILE_TEST_INC" \
+ -I "$COMPILE_TEST_INC/$ARCH_TRIPLET" \
+ -o /dev/null "$_KERNEL_BEFORE_LIBC"
+ $CC -Wall -c -nostdinc $GCC_INC \
+ -I . -I "$COMPILE_TEST_INC" \
+ -I "$COMPILE_TEST_INC/$ARCH_TRIPLET" \
+ -o /dev/null "$_KERNEL_BEFORE_LIBC" \
+ || _FAIL_KERNEL_BEFORE_LIBC=1
+
+ # report errors
+ if [ "$_FAIL_KERNEL_BEFORE_LIBC" -gt 0 ]; then
+ echo "FAILED kernel before libc test: $f"
+ _KERNEL_BEFORE_LIBC_FAILED="$(( _KERNEL_BEFORE_LIBC_FAILED + 1 ))"
+ else
+ echo "PASSED kernel before libc test: $f"
+ _KERNEL_BEFORE_LIBC_PASSED="$(( _KERNEL_BEFORE_LIBC_PASSED + 1))"
+ fi
+ fi
+
+ # libc summary
+ if [ "$_FAIL_LIBC_BEFORE_KERNEL" -gt 0 -o "$_FAIL_KERNEL_BEFORE_LIBC" -gt 0 ]; then
+ _LIBC_FAILED="$(( _LIBC_FAILED + 1))"
+ else
+ _LIBC_PASSED="$(( _LIBC_PASSED + 1))"
+ fi
+
+ if [ "$KEEP" = "0" ]; then
+ rm -f "$_LIBC_BEFORE_KERNEL" "$_KERNEL_BEFORE_LIBC"
+ fi
+ fi # LIBC_TEST
done

-echo Statistics:
-echo "$_FAILED files failed the compile test."
-echo "$_PASSED files passed the compile test."
+cat << EOF_STATS
+
+Kernel header compile test statistics:
+
+$_FAILED files failed the kernel header compile test.
+$_PASSED files passed the kernel header compile test.
+
+EOF_STATS
+
+if [ "$LIBC_TEST" != 0 ]; then
+ cat << EOF_LIBC_STATS
+libc and kernel header compatibility test statistics:
+EOF_LIBC_STATS
+
+if [ "$LIBC_KERNEL_TEST" != 0 ] && [ "$KERNEL_LIBC_TEST" != 0 ]; then
+ cat << EOF_LIBC_COMBINED
+$_LIBC_FAILED files failed the libc compatibility test.
+$_LIBC_PASSED files passed the libc compatibility test.
+EOF_LIBC_COMBINED
+fi
+
+if [ "$LIBC_KERNEL_TEST" != 0 ]; then
+ cat << EOF_LIBC_KERNEL
+$_LIBC_BEFORE_KERNEL_FAILED files failed libc before kernel include test.
+$_LIBC_BEFORE_KERNEL_PASSED files passed libc before kernel include test.
+EOF_LIBC_KERNEL
+fi
+
+if [ "$KERNEL_LIBC_TEST" != 0 ]; then
+ cat << EOF_KERNEL_LIBC
+$_KERNEL_BEFORE_LIBC_FAILED files failed kernel before libc include test.
+$_KERNEL_BEFORE_LIBC_PASSED files passed kernel before libc include test.
+EOF_KERNEL_LIBC
+fi

-exit "$_FAILED"
+fi # LIBC_TEST
+
+# return value, summary of all failures.
+if [ "$(( $_FAILED + $_LIBC_BEFORE_KERNEL_FAILED + $_KERNEL_BEFORE_LIBC_FAILED ))" != 0 ]; then
+ exit 1
+else
+ exit 0
+fi
--
2.8.1
Mikko Rapeli
2016-08-22 18:50:01 UTC
Permalink
Fixes userspace compile error:

error: ‘IFHWADDRLEN’ undeclared here (not in a function)
unsigned char sllc_mac[IFHWADDRLEN];

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/llc.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/llc.h b/include/uapi/linux/llc.h
index 9c987a4..f503599 100644
--- a/include/uapi/linux/llc.h
+++ b/include/uapi/linux/llc.h
@@ -14,6 +14,7 @@
#define _UAPI__LINUX_LLC_H

#include <linux/socket.h>
+#include <linux/if.h>

#define __LLC_SOCK_SIZE__ 16 /* sizeof(sockaddr_llc), word align. */
struct sockaddr_llc {
--
2.8.1
Mikko Rapeli
2016-08-22 18:50:01 UTC
Permalink
Fixes userspace compilation error:

error: unknown type name ‘size_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/omapfb.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/omapfb.h b/include/uapi/linux/omapfb.h
index 7c97bc0..b637a92 100644
--- a/include/uapi/linux/omapfb.h
+++ b/include/uapi/linux/omapfb.h
@@ -181,7 +181,7 @@ struct omapfb_memory_read {
__u16 y;
__u16 w;
__u16 h;
- size_t buffer_size;
+ __kernel_size_t buffer_size;
void __user *buffer;
};
--
2.8.1
Mikko Rapeli
2016-08-22 18:50:01 UTC
Permalink
Fixes userspace compilation errors like:

error: field ‘addr’ has incomplete type
struct sockaddr_in addr; /* IP address and port to send to */
^
error: field ‘addr’ has incomplete type
struct sockaddr_in6 addr; /* IP address and port to send to */

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/if_pppol2tp.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/if_pppol2tp.h b/include/uapi/linux/if_pppol2tp.h
index 163e8ad..4bd1f55 100644
--- a/include/uapi/linux/if_pppol2tp.h
+++ b/include/uapi/linux/if_pppol2tp.h
@@ -16,7 +16,8 @@
#define _UAPI__LINUX_IF_PPPOL2TP_H

#include <linux/types.h>
-
+#include <linux/in.h>
+#include <linux/in6.h>

/* Structure used to connect() the socket to a particular tunnel UDP
* socket over IPv4.
--
2.8.1
David Miller
2016-08-22 23:40:03 UTC
Permalink
From: Mikko Rapeli <***@iki.fi>
Date: Mon, 22 Aug 2016 20:32:42 +0200
Post by Mikko Rapeli
error: field ‘addr’ has incomplete type
struct sockaddr_in addr; /* IP address and port to send to */
^
error: field ‘addr’ has incomplete type
struct sockaddr_in6 addr; /* IP address and port to send to */
Signed-off-by: Mik
Mikko Rapeli
2016-08-22 18:50:01 UTC
Permalink
Fixes userspace compilation error:

error: array type has incomplete element type
struct timespec ts[3];

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/errqueue.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/errqueue.h b/include/uapi/linux/errqueue.h
index 07bdce1..6b1cdc6 100644
--- a/include/uapi/linux/errqueue.h
+++ b/include/uapi/linux/errqueue.h
@@ -2,6 +2,7 @@
#define _UAPI_LINUX_ERRQUEUE_H

#include <linux/types.h>
+#include <linux/time.h>

struct sock_extended_err {
__u32 ee_errno;
--
2.8.1
kbuild test robot
2016-08-22 21:40:02 UTC
Permalink
Hi Mikko,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.8-rc3 next-20160822]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url: https://github.com/0day-ci/linux/commits/Mikko-Rapeli/Userspace-compile-test-and-fixes-for-exported-uapi-header-files/20160823-034928
config: i386-tinyconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

Note: the linux-review/Mikko-Rapeli/Userspace-compile-test-and-fixes-for-exported-uapi-header-files/20160823-034928 HEAD ab90ab906304d4f306e440f4dbfa334720093b4f builds fine.
It only hurts bisectibility.

All error/warnings (new ones prefixed by >>):

In file included from ./usr/include/linux/errqueue.h:5:0,
./usr/include/linux/time.h:9:8: error: redefinition of 'struct timespec'
struct timespec {
^~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/sys/select.h:43:0,
from /usr/include/x86_64-linux-gnu/sys/types.h:219,
from /usr/include/stdlib.h:314,
from Documentation/networking/timestamping/timestamping.c:33:
/usr/include/time.h:120:8: note: originally defined here
struct timespec
^~~~~~~~
In file included from ./usr/include/linux/errqueue.h:5:0,
./usr/include/linux/time.h:15:8: error: redefinition of 'struct timeval'
struct timeval {
^~~~~~~
In file included from /usr/include/x86_64-linux-gnu/sys/select.h:45:0,
from /usr/include/x86_64-linux-gnu/sys/types.h:219,
from /usr/include/stdlib.h:314,
from Documentation/networking/timestamping/timestamping.c:33:
/usr/include/x86_64-linux-gnu/bits/time.h:30:8: note: originally defined here
struct timeval
^~~~~~~
In file included from ./usr/include/linux/errqueue.h:5:0,
./usr/include/linux/time.h:20:8: error: redefinition of 'struct timezone'
struct timezone {
^~~~~~~~
In file included from Documentation/networking/timestamping/timestamping.c:37:0:
/usr/include/x86_64-linux-gnu/sys/time.h:55:8: note: originally defined here
struct timezone
^~~~~~~~
In file included from ./usr/include/linux/errqueue.h:5:0,
./usr/include/linux/time.h:30:0: warning: "ITIMER_REAL" redefined
#define ITIMER_REAL 0

In file included from Documentation/networking/timestamping/timestamping.c:37:0:
/usr/include/x86_64-linux-gnu/sys/time.h:95:0: note: this is the location of the previous definition
#define ITIMER_REAL ITIMER_REAL

In file included from ./usr/include/linux/errqueue.h:5:0,
./usr/include/linux/time.h:31:0: warning: "ITIMER_VIRTUAL" redefined
#define ITIMER_VIRTUAL 1

In file included from Documentation/networking/timestamping/timestamping.c:37:0:
/usr/include/x86_64-linux-gnu/sys/time.h:98:0: note: this is the location of the previous definition
#define ITIMER_VIRTUAL ITIMER_VIRTUAL

In file included from ./usr/include/linux/errqueue.h:5:0,
./usr/include/linux/time.h:32:0: warning: "ITIMER_PROF" redefined
#define ITIMER_PROF 2

In file included from Documentation/networking/timestamping/timestamping.c:37:0:
/usr/include/x86_64-linux-gnu/sys/time.h:102:0: note: this is the location of the previous definition
#define ITIMER_PROF ITIMER_PROF

In file included from ./usr/include/linux/errqueue.h:5:0,
./usr/include/linux/time.h:39:8: error: redefinition of 'struct itimerval'
struct itimerval {
^~~~~~~~~
In file included from Documentation/networking/timestamping/timestamping.c:37:0:
/usr/include/x86_64-linux-gnu/sys/time.h:107:8: note: originally defined here
struct itimerval
^~~~~~~~~
Documentation/networking/timestamping/timestamping.c:144:15: warning: passing argument 1 of 'gettimeofday' from incompatible pointer type [-Wincompatible-pointer-types]
gettimeofday(&now, 0);
^
In file included from Documentation/networking/timestamping/timestamping.c:37:0:
/usr/include/x86_64-linux-gnu/sys/time.h:71:12: note: expected 'struct timeval * __restrict__' but argument is of type 'struct timeval *'
extern int gettimeofday (struct timeval *__restrict __tv,
^~~~~~~~~~~~
Documentation/networking/timestamping/timestamping.c: In function 'printpacket':
Documentation/networking/timestamping/timestamping.c:164:15: warning: passing argument 1 of 'gettimeofday' from incompatible pointer type [-Wincompatible-pointer-types]
gettimeofday(&now, 0);
^
In file included from Documentation/networking/timestamping/timestamping.c:37:0:
/usr/include/x86_64-linux-gnu/sys/time.h:71:12: note: expected 'struct timeval * __restrict__' but argument is of type 'struct timeval *'
extern int gettimeofday (struct timeval *__restrict __tv,
^~~~~~~~~~~~
Documentation/networking/timestamping/timestamping.c: In function 'main':
Documentation/networking/timestamping/timestamping.c:474:15: warning: passing argument 1 of 'gettimeofday' from incompatible pointer type [-Wincompatible-pointer-types]
gettimeofday(&next, 0);
^
In file included from Documentation/networking/timestamping/timestamping.c:37:0:
/usr/include/x86_64-linux-gnu/sys/time.h:71:12: note: expected 'struct timeval * __restrict__' but argument is of type 'struct timeval *'
extern int gettimeofday (struct timeval *__restrict __tv,
^~~~~~~~~~~~
Documentation/networking/timestamping/timestamping.c:484:16: warning: passing argument 1 of 'gettimeofday' from incompatible pointer type [-Wincompatible-pointer-types]
gettimeofday(&now, 0);
^
In file included from Documentation/networking/timestamping/timestamping.c:37:0:
/usr/include/x86_64-linux-gnu/sys/time.h:71:12: note: expected 'struct timeval * __restrict__' but argument is of type 'struct timeval *'
extern int gettimeofday (struct timeval *__restrict __tv,
^~~~~~~~~~~~
Documentation/networking/timestamping/timestamping.c:499:49: warning: passing argument 5 of 'select' from incompatible pointer type [-Wincompatible-pointer-types]
res = select(sock + 1, &readfs, 0, &errorfs, &delta);
^
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:219:0,
from /usr/include/stdlib.h:314,
from Documentation/networking/timestamping/timestamping.c:33:
/usr/include/x86_64-linux-gnu/sys/select.h:106:12: note: expected 'struct timeval * __restrict__' but argument is of type 'struct timeval *'
extern int select (int __nfds, fd_set *__restrict __readfds,
^~~~~~
Documentation/networking/timestamping/timestamping.c:500:17: warning: passing argument 1 of 'gettimeofday' from incompatible pointer type [-Wincompatible-pointer-types]
gettimeofday(&now, 0);
^
In file included from Documentation/networking/timestamping/timestamping.c:37:0:
/usr/include/x86_64-linux-gnu/sys/time.h:71:12: note: expected 'struct timeval * __restrict__' but argument is of type 'struct timeval *'
extern int gettimeofday (struct timeval *__restrict __tv,
^~~~~~~~~~~~

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
2016-08-22 22:10:02 UTC
Permalink
Hi Mikko,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.8-rc3 next-20160822]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url: https://github.com/0day-ci/linux/commits/Mikko-Rapeli/Userspace-compile-test-and-fixes-for-exported-uapi-header-files/20160823-034928
config: i386-tinyconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

Note: the linux-review/Mikko-Rapeli/Userspace-compile-test-and-fixes-for-exported-uapi-header-files/20160823-034928 HEAD ab90ab906304d4f306e440f4dbfa334720093b4f builds fine.
It only hurts bisectibility.

All errors (new ones prefixed by >>):

In file included from ./usr/include/linux/errqueue.h:5:0,
from Documentation/networking/timestamping/txtimestamp.c:40:
./usr/include/linux/time.h:9:8: error: redefinition of 'struct timespec'
struct timespec {
^~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/sys/select.h:43:0,
from /usr/include/x86_64-linux-gnu/sys/types.h:219,
from /usr/include/x86_64-linux-gnu/sys/uio.h:23,
from /usr/include/x86_64-linux-gnu/sys/socket.h:26,
from /usr/include/netinet/in.h:23,
from /usr/include/arpa/inet.h:22,
from Documentation/networking/timestamping/txtimestamp.c:35:
/usr/include/time.h:120:8: note: originally defined here
struct timespec
^~~~~~~~
In file included from ./usr/include/linux/errqueue.h:5:0,
from Documentation/networking/timestamping/txtimestamp.c:40:
./usr/include/linux/time.h:15:8: error: redefinition of 'struct timeval'
struct timeval {
^~~~~~~
In file included from /usr/include/x86_64-linux-gnu/sys/select.h:45:0,
from /usr/include/x86_64-linux-gnu/sys/types.h:219,
from /usr/include/x86_64-linux-gnu/sys/uio.h:23,
from /usr/include/x86_64-linux-gnu/sys/socket.h:26,
from /usr/include/netinet/in.h:23,
from /usr/include/arpa/inet.h:22,
from Documentation/networking/timestamping/txtimestamp.c:35:
/usr/include/x86_64-linux-gnu/bits/time.h:30:8: note: originally defined here
struct timeval
^~~~~~~
/usr/include/x86_64-linux-gnu/sys/time.h:55:8: error: redefinition of 'struct timezone'
struct timezone
^~~~~~~~
In file included from ./usr/include/linux/errqueue.h:5:0,
from Documentation/networking/timestamping/txtimestamp.c:40:
./usr/include/linux/time.h:20:8: note: originally defined here
struct timezone {
^~~~~~~~
./usr/include/linux/time.h:30:22: error: expected identifier before numeric constant
#define ITIMER_REAL 0
^
/usr/include/x86_64-linux-gnu/sys/time.h:107:8: error: redefinition of 'struct itimerval'
struct itimerval
^~~~~~~~~
In file included from ./usr/include/linux/errqueue.h:5:0,
from Documentation/networking/timestamping/txtimestamp.c:40:
./usr/include/linux/time.h:39:8: note: originally defined here
struct itimerval {
^~~~~~~~~
/usr/include/time.h:161:8: error: redefinition of 'struct itimerspec'
struct itimerspec
^~~~~~~~~~
In file included from ./usr/include/linux/errqueue.h:5:0,
from Documentation/networking/timestamping/txtimestamp.c:40:
./usr/include/linux/time.h:34:8: note: originally defined here
struct itimerspec {
^~~~~~~~~~

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
2016-08-22 23:30:01 UTC
Permalink
Hi Mikko,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.8-rc3 next-20160822]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url: https://github.com/0day-ci/linux/commits/Mikko-Rapeli/Userspace-compile-test-and-fixes-for-exported-uapi-header-files/20160823-034928
config: x86_64-randconfig-s2-08230509 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

Note: the linux-review/Mikko-Rapeli/Userspace-compile-test-and-fixes-for-exported-uapi-header-files/20160823-034928 HEAD ab90ab906304d4f306e440f4dbfa334720093b4f builds fine.
It only hurts bisectibility.

All error/warnings (new ones prefixed by >>):

In file included from ./usr/include/linux/errqueue.h:5,
from Documentation/networking/timestamping/timestamping.c:46:
./usr/include/linux/time.h:9: error: redefinition of 'struct timespec'
./usr/include/linux/time.h:15: error: redefinition of 'struct timeval'
./usr/include/linux/time.h:20: error: redefinition of 'struct timezone'
In file included from ./usr/include/linux/errqueue.h:5,
from Documentation/networking/timestamping/timestamping.c:46:
./usr/include/linux/time.h:30:1: warning: "ITIMER_REAL" redefined
/usr/include/x86_64-linux-gnu/sys/time.h:95:1: warning: this is the location of the previous definition
In file included from ./usr/include/linux/errqueue.h:5,
from Documentation/networking/timestamping/timestamping.c:46:
./usr/include/linux/time.h:31:1: warning: "ITIMER_VIRTUAL" redefined
In file included from Documentation/networking/timestamping/timestamping.c:37:
/usr/include/x86_64-linux-gnu/sys/time.h:98:1: warning: this is the location of the previous definition
In file included from ./usr/include/linux/errqueue.h:5,
from Documentation/networking/timestamping/timestamping.c:46:
./usr/include/linux/time.h:32:1: warning: "ITIMER_PROF" redefined
In file included from Documentation/networking/timestamping/timestamping.c:37:
/usr/include/x86_64-linux-gnu/sys/time.h:102:1: warning: this is the location of the previous definition
./usr/include/linux/time.h:39: error: redefinition of 'struct itimerval'
Documentation/networking/timestamping/timestamping.c: In function 'sendpacket':
Documentation/networking/timestamping/timestamping.c:144: warning: passing argument 1 of 'gettimeofday' from incompatible pointer type
/usr/include/x86_64-linux-gnu/sys/time.h:71: note: expected 'struct timeval * __restrict__' but argument is of type 'struct timeval *'
Documentation/networking/timestamping/timestamping.c: In function 'printpacket':
Documentation/networking/timestamping/timestamping.c:164: warning: passing argument 1 of 'gettimeofday' from incompatible pointer type
/usr/include/x86_64-linux-gnu/sys/time.h:71: note: expected 'struct timeval * __restrict__' but argument is of type 'struct timeval *'
Documentation/networking/timestamping/timestamping.c: In function 'main':
Documentation/networking/timestamping/timestamping.c:474: warning: passing argument 1 of 'gettimeofday' from incompatible pointer type
/usr/include/x86_64-linux-gnu/sys/time.h:71: note: expected 'struct timeval * __restrict__' but argument is of type 'struct timeval *'
Documentation/networking/timestamping/timestamping.c:484: warning: passing argument 1 of 'gettimeofday' from incompatible pointer type
/usr/include/x86_64-linux-gnu/sys/time.h:71: note: expected 'struct timeval * __restrict__' but argument is of type 'struct timeval *'
Documentation/networking/timestamping/timestamping.c:499: warning: passing argument 5 of 'select' from incompatible pointer type
/usr/include/x86_64-linux-gnu/sys/select.h:106: note: expected 'struct timeval * __restrict__' but argument is of type 'struct timeval *'
Documentation/networking/timestamping/timestamping.c:500: warning: passing argument 1 of 'gettimeofday' from incompatible pointer type
/usr/include/x86_64-linux-gnu/sys/time.h:71: note: expected 'struct timeval * __restrict__' but argument is of type 'struct timeval *'
--
In file included from ./usr/include/linux/errqueue.h:5,
from Documentation/networking/timestamping/txtimestamp.c:40:
./usr/include/linux/time.h:9: error: redefinition of 'struct timespec'
./usr/include/linux/time.h:15: error: redefinition of 'struct timeval'
In file included from Documentation/networking/timestamping/txtimestamp.c:59:
/usr/include/x86_64-linux-gnu/sys/time.h:56: error: redefinition of 'struct timezone'
/usr/include/x86_64-linux-gnu/sys/time.h:94: error: expected identifier before numeric constant
/usr/include/x86_64-linux-gnu/sys/time.h:108: error: redefinition of 'struct itimerval'
In file included from Documentation/networking/timestamping/txtimestamp.c:61:
/usr/include/time.h:162: error: redefinition of 'struct itimerspec'

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Mikko Rapeli
2016-08-22 18:50:01 UTC
Permalink
Fixes userspace compilation errors:

error: field ‘addr’ has incomplete type
struct sockaddr_in addr; /* IP address and port to send to */

error: field ‘addr’ has incomplete type
struct sockaddr_in6 addr; /* IP address and port to send to */

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/if_pppox.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/if_pppox.h b/include/uapi/linux/if_pppox.h
index 473c3c4..d37bbb1 100644
--- a/include/uapi/linux/if_pppox.h
+++ b/include/uapi/linux/if_pppox.h
@@ -24,6 +24,8 @@
#include <linux/if.h>
#include <linux/if_ether.h>
#include <linux/if_pppol2tp.h>
+#include <linux/in.h>
+#include <linux/in6.h>

/* For user-space programs to pick up these definitions
* which they wouldn't get otherwise without defining __KERNEL__
--
2.8.1
David Miller
2016-08-22 23:40:03 UTC
Permalink
From: Mikko Rapeli <***@iki.fi>
Date: Mon, 22 Aug 2016 20:32:43 +0200
Post by Mikko Rapeli
error: field ‘addr’ has incomplete type
struct sockaddr_in addr; /* IP address and port to send to */
error: field ‘addr’ has incomplete type
struct sockaddr_in6 addr; /* IP address and port to send to */
Mikko Rapeli
2016-08-22 18:50:01 UTC
Permalink
Fixes userspace compile errors like:

error: field ‘vifc_lcl_addr’ has incomplete type
struct in_addr vifc_lcl_addr; /* Local interface address */

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/mroute.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/mroute.h b/include/uapi/linux/mroute.h
index cf94301..4540653 100644
--- a/include/uapi/linux/mroute.h
+++ b/include/uapi/linux/mroute.h
@@ -3,6 +3,7 @@

#include <linux/sockios.h>
#include <linux/types.h>
+#include <linux/in.h>

/* Based on the MROUTING 3.5 defines primarily to keep
* source compatibility with BSD.
--
2.8.1
David Miller
2016-08-22 23:40:03 UTC
Permalink
From: Mikko Rapeli <***@iki.fi>
Date: Mon, 22 Aug 2016 20:32:48 +0200
Post by Mikko Rapeli
error: field ‘vifc_lcl_addr’ has incomplete type
struct in_addr vifc_lcl_addr; /* Local interface address */
Signed-off-by: Mikko Rapeli <mik
Mikko Rapeli
2016-08-22 18:50:01 UTC
Permalink
Fixes userspace compiler error:

error: ‘IFNAMSIZ’ undeclared here (not in a function)

Suggested by Frans Klaver <***@gmail.com> on lkml message
<***@bugger.home>.

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/hdlc/ioctl.h | 5 +++++
include/uapi/linux/if.h | 5 +----
2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/uapi/linux/hdlc/ioctl.h b/include/uapi/linux/hdlc/ioctl.h
index 04bc027..4b7a7ed 100644
--- a/include/uapi/linux/hdlc/ioctl.h
+++ b/include/uapi/linux/hdlc/ioctl.h
@@ -1,6 +1,11 @@
#ifndef __HDLC_IOCTL_H__
#define __HDLC_IOCTL_H__

+#include <linux/libc-compat.h> /* for compatibility with glibc */
+
+#if __UAPI_DEF_IF_IFNAMSIZ
+#define IFNAMSIZ 16
+#endif /* __UAPI_DEF_IF_IFNAMSIZ */

#define GENERIC_HDLC_VERSION 4 /* For synchronization with sethdlc utility */

diff --git a/include/uapi/linux/if.h b/include/uapi/linux/if.h
index e601c8c..68bd205 100644
--- a/include/uapi/linux/if.h
+++ b/include/uapi/linux/if.h
@@ -23,12 +23,9 @@
#include <linux/types.h> /* for "__kernel_caddr_t" et al */
#include <linux/socket.h> /* for "struct sockaddr" et al */
#include <linux/compiler.h> /* for "__user" et al */
+#include <linux/hdlc/ioctl.h> /* for IFNAMSIZ */

-#if __UAPI_DEF_IF_IFNAMSIZ
-#define IFNAMSIZ 16
-#endif /* __UAPI_DEF_IF_IFNAMSIZ */
#define IFALIASZ 256
-#include <linux/hdlc/ioctl.h>

/* For glibc compatibility. An empty enum does not compile. */
#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 && \
--
2.8.1
David Miller
2016-08-22 23:40:03 UTC
Permalink
From: Mikko Rapeli <***@iki.fi>
Date: Mon, 22 Aug 2016 20:32:44 +0200
Post by Mikko Rapeli
error: ‘IFNAMSIZ’ undeclared here (not in a function)
IFNAMSIZ has to be in linux/if.h, you aren't explaining why you have
to move it to the hdlc header instead of having the hdlc header
include linux/if.h

And if your reason is legitimate, you have to add that explan
Mikko Rapeli
2016-08-22 18:50:02 UTC
Permalink
Fixes userspace compilation errors like:

error: field ‘msg_perm’ has incomplete type
struct ipc64_perm msg_perm;
error: unknown type name ‘__kernel_ulong_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/asm-generic/sembuf.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/uapi/asm-generic/sembuf.h b/include/uapi/asm-generic/sembuf.h
index 4cb2c13..17d523f 100644
--- a/include/uapi/asm-generic/sembuf.h
+++ b/include/uapi/asm-generic/sembuf.h
@@ -2,6 +2,8 @@
#define __ASM_GENERIC_SEMBUF_H

#include <asm/bitsperlong.h>
+#include <asm/posix_types.h>
+#include <asm/ipcbuf.h>

/*
* The semid64_ds structure for x86 architecture.
--
2.8.1
Mikko Rapeli
2016-08-22 18:50:02 UTC
Permalink
Fixes userspace compile error:

error: field ‘real’ has incomplete type
struct timeval real; /* real (wall-clock) time */

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/atm_zatm.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/atm_zatm.h b/include/uapi/linux/atm_zatm.h
index 9c9c6ad..5cd4d4d 100644
--- a/include/uapi/linux/atm_zatm.h
+++ b/include/uapi/linux/atm_zatm.h
@@ -14,6 +14,7 @@

#include <linux/atmapi.h>
#include <linux/atmioc.h>
+#include <linux/time.h>

#define ZATM_GETPOOL _IOW('a',ATMIOC_SARPRV+1,struct atmif_sioc)
/* get pool statistics */
--
2.8.1
David Miller
2016-08-22 23:40:03 UTC
Permalink
From: Mikko Rapeli <***@iki.fi>
Date: Mon, 22 Aug 2016 20:32:58 +0200
Post by Mikko Rapeli
error: field ‘real’ has incomplete type
struct timeval real; /* real (wall-clock) time */
Applied
Mikko Rapeli
2016-08-22 18:50:02 UTC
Permalink
Fixes userspace compiler error:

error: unknown type name ‘size_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/asm-generic/signal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/asm-generic/signal.h b/include/uapi/asm-generic/signal.h
index 3094618..6bbcdfa 100644
--- a/include/uapi/asm-generic/signal.h
+++ b/include/uapi/asm-generic/signal.h
@@ -113,7 +113,7 @@ struct sigaction {
typedef struct sigaltstack {
void __user *ss_sp;
int ss_flags;
- size_t ss_size;
+ __kernel_size_t ss_size;
} stack_t;

#endif /* __ASSEMBLY__ */
--
2.8.1
Mikko Rapeli
2016-08-22 18:50:02 UTC
Permalink
Fixes userspace compile error:

error: unknown type name ‘__kernel_long_t’
__kernel_long_t mq_flags; /* message queue flags */

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/mqueue.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/mqueue.h b/include/uapi/linux/mqueue.h
index d0a2b8e..bbd5116 100644
--- a/include/uapi/linux/mqueue.h
+++ b/include/uapi/linux/mqueue.h
@@ -18,6 +18,8 @@
#ifndef _LINUX_MQUEUE_H
#define _LINUX_MQUEUE_H

+#include <linux/types.h>
+
#define MQ_PRIO_MAX 32768
/* per-uid limit of kernel memory used by mqueue, in bytes */
#define MQ_BYTES_MAX 819200
--
2.8.1
Mikko Rapeli
2016-08-22 18:50:02 UTC
Permalink
Fixes userspace compilation error:

error: unknown type name ‘size_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/sysctl.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
index d2b1215..52e9795 100644
--- a/include/uapi/linux/sysctl.h
+++ b/include/uapi/linux/sysctl.h
@@ -35,9 +35,9 @@ struct __sysctl_args {
int __user *name;
int nlen;
void __user *oldval;
- size_t __user *oldlenp;
+ __kernel_size_t __user *oldlenp;
void __user *newval;
- size_t newlen;
+ __kernel_size_t newlen;
unsigned long __unused[4];
};
--
2.8.1
Mikko Rapeli
2016-08-22 18:50:02 UTC
Permalink
Fixes userspace compiler errors like:

linux/hsi/hsi_char.h:51:2: error: unknown type name ‘uint32_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/hsi/hsi_char.h | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/uapi/linux/hsi/hsi_char.h b/include/uapi/linux/hsi/hsi_char.h
index 76160b4..c00a463 100644
--- a/include/uapi/linux/hsi/hsi_char.h
+++ b/include/uapi/linux/hsi/hsi_char.h
@@ -20,10 +20,11 @@
* 02110-1301 USA
*/

-
#ifndef __HSI_CHAR_H
#define __HSI_CHAR_H

+#include <linux/types.h>
+
#define HSI_CHAR_MAGIC 'k'
#define HSC_IOW(num, dtype) _IOW(HSI_CHAR_MAGIC, num, dtype)
#define HSC_IOR(num, dtype) _IOR(HSI_CHAR_MAGIC, num, dtype)
@@ -48,16 +49,16 @@
#define HSC_ARB_PRIO 1

struct hsc_rx_config {
- uint32_t mode;
- uint32_t flow;
- uint32_t channels;
+ __u32 mode;
+ __u32 flow;
+ __u32 channels;
};

struct hsc_tx_config {
- uint32_t mode;
- uint32_t channels;
- uint32_t speed;
- uint32_t arb_mode;
+ __u32 mode;
+ __u32 channels;
+ __u32 speed;
+ __u32 arb_mode;
};

#endif /* __HSI_CHAR_H */
--
2.8.1
Sebastian Reichel
2016-08-22 21:00:02 UTC
Permalink
Hi,
linux/hsi/hsi_char.h:51:2: error: unknown type name ‘uint32_t’
---
include/uapi/linux/hsi/hsi_char.h | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/include/uapi/linux/hsi/hsi_char.h b/include/uapi/linux/hsi/hsi_char.h
index 76160b4..c00a463 100644
--- a/include/uapi/linux/hsi/hsi_char.h
+++ b/include/uapi/linux/hsi/hsi_char.h
@@ -20,10 +20,11 @@
* 02110-1301 USA
*/
-
#ifndef __HSI_CHAR_H
#define __HSI_CHAR_H
+#include <linux/types.h>
+
#define HSI_CHAR_MAGIC 'k'
#define HSC_IOW(num, dtype) _IOW(HSI_CHAR_MAGIC, num, dtype)
#define HSC_IOR(num, dtype) _IOR(HSI_CHAR_MAGIC, num, dtype)
@@ -48,16 +49,16 @@
#define HSC_ARB_PRIO 1
struct hsc_rx_config {
- uint32_t mode;
- uint32_t flow;
- uint32_t channels;
+ __u32 mode;
+ __u32 flow;
+ __u32 channels;
};
struct hsc_tx_config {
- uint32_t mode;
- uint32_t channels;
- uint32_t speed;
- uint32_t arb_mode;
+ __u32 mode;
+ __u32 channels;
+ __u32 speed;
+ __u32 arb_mode;
};
#endif /* __HSI_CHAR_H */
Thanks, queued.

-- Sebastian
Mikko Rapeli
2016-08-22 18:50:02 UTC
Permalink
Fixes userspace compilation error:

error: ‘DLM_RESNAME_MAXLEN’ undeclared here (not in a function)
char resource_name[DLM_RESNAME_MAXLEN];

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/dlm_netlink.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/dlm_netlink.h b/include/uapi/linux/dlm_netlink.h
index 647c8ef..ef1e2e0 100644
--- a/include/uapi/linux/dlm_netlink.h
+++ b/include/uapi/linux/dlm_netlink.h
@@ -10,6 +10,7 @@
#define _DLM_NETLINK_H

#include <linux/types.h>
+#include <linux/dlmconstants.h>

enum {
DLM_STATUS_WAITING = 1,
--
2.8.1
Mikko Rapeli
2016-08-22 18:50:02 UTC
Permalink
Fixes userspace compilation error:

error: ‘NAME_MAX’ undeclared here (not in a function)

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/auto_fs.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/auto_fs.h b/include/uapi/linux/auto_fs.h
index 9175a1b..1bfc3ed 100644
--- a/include/uapi/linux/auto_fs.h
+++ b/include/uapi/linux/auto_fs.h
@@ -12,6 +12,7 @@
#define _UAPI_LINUX_AUTO_FS_H

#include <linux/types.h>
+#include <linux/limits.h>
#ifndef __KERNEL__
#include <sys/ioctl.h>
#endif /* __KERNEL__ */
--
2.8.1
Ian Kent
2016-08-23 00:50:02 UTC
Permalink
Post by Mikko Rapeli
error: ‘NAME_MAX’ undeclared here (not in a function)
Thanks for your effort but a patch for this, from from Tomohiro Kusumi, is
currently included in the mm tree.
Post by Mikko Rapeli
---
include/uapi/linux/auto_fs.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/uapi/linux/auto_fs.h b/include/uapi/linux/auto_fs.h
index 9175a1b..1bfc3ed 100644
--- a/include/uapi/linux/auto_fs.h
+++ b/include/uapi/linux/auto_fs.h
@@ -12,6 +12,7 @@
#define _UAPI_LINUX_AUTO_FS_H
#include <linux/types.h>
+#include <linux/limits.h>
#ifndef __KERNEL__
#include <sys/ioctl.h>
#endif /* __KERNEL__ */
Mikko Rapeli
2016-08-22 18:50:02 UTC
Permalink
Fixes userspace compilation errors like:

error: unknown type name ‘uint16_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/target_core_user.h | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/uapi/linux/target_core_user.h b/include/uapi/linux/target_core_user.h
index c506cdd..af17b41 100644
--- a/include/uapi/linux/target_core_user.h
+++ b/include/uapi/linux/target_core_user.h
@@ -105,26 +105,26 @@ struct tcmu_cmd_entry {

union {
struct {
- uint32_t iov_cnt;
- uint32_t iov_bidi_cnt;
- uint32_t iov_dif_cnt;
- uint64_t cdb_off;
- uint64_t __pad1;
- uint64_t __pad2;
+ __u32 iov_cnt;
+ __u32 iov_bidi_cnt;
+ __u32 iov_dif_cnt;
+ __u64 cdb_off;
+ __u64 __pad1;
+ __u64 __pad2;
struct iovec iov[0];
} req;
struct {
- uint8_t scsi_status;
- uint8_t __pad1;
- uint16_t __pad2;
- uint32_t __pad3;
+ __u8 scsi_status;
+ __u8 __pad1;
+ __u16 __pad2;
+ __u32 __pad3;
char sense_buffer[TCMU_SENSE_BUFFERSIZE];
} rsp;
};

} __packed;

-#define TCMU_OP_ALIGN_SIZE sizeof(uint64_t)
+#define TCMU_OP_ALIGN_SIZE sizeof(__u64)

enum tcmu_genl_cmd {
TCMU_CMD_UNSPEC,
--
2.8.1
Mikko Rapeli
2016-08-22 18:50:02 UTC
Permalink
Users of kernel header files would be happier if they did not contain
kernel specific parts and would contain #include statements for all
other header files that they depend on, and in general would compile.

For each header file exported to userspace, this script tries to compile it
together with minimal header files from GCC and libc, and reports results.

Kernel headers depend on GCC headers so their path is included in the
test compiler command line.

Default libc and GCC header file locations are parsed from compiler
configuration.

Some gcc and kernel headers depend on libc headers which are made available
by copying from the compiler default location to a temporary location and
removing possibly existing kernel headers from this directory. This is a bit
of a hack but seems to work in multiple environments.

Tested natively on:

Debian unstable, i586-linux-gnu and gcc 4.9.2
Raspbian Wheezy, arm-linux-gnueabihf and gcc 4.6.3
Ubuntu 12.04 LTS, x86_64-linux-gnu and gcc 4.6.3

Tested cross compilation using standard CROSS_COMPILE=/path/to/gcc with:

arm-linux-gnueabihf-gcc (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC 4.9-2014.09) 4.9.2 20140904 (prerelease)

Execute the script in the directory where kernel header files are installed.
For example:

$ make headers_install
$ cd usr/include
$ ../../scripts/headers_compile_test.sh

Example statistics from v4.4-rc3-10-gc846b17 kernel on 32bit x86:

122 files failed the compile test.
645 files passed the compile test.

Example error types from v4.4-rc3-10-gc846b17 kernel:

$ ../../scripts/headers_compile_test.sh 2>&1 | \
grep error: | sed -e 's/.*error://g' | sort | uniq -c | sort -rn

381 unknown type name ‘uint32_t’
125 unknown type name ‘uint64_t’
99 unknown type name ‘size_t’
43 unknown type name ‘__kernel_ulong_t’
29 unknown type name ‘uint8_t’
23 unknown type name ‘int32_t’
16 unknown type name ‘__kernel_time_t’
14 unknown type name ‘__be16’
14 ‘IFNAMSIZ’ undeclared here (not in a function)
14 field ‘addr’ has incomplete type
9 field ‘ifru_netmask’ has incomplete type
9 field ‘ifru_hwaddr’ has incomplete type
9 field ‘ifru_dstaddr’ has incomplete type
9 field ‘ifru_broadaddr’ has incomplete type
9 field ‘ifru_addr’ has incomplete type
8 unknown type name ‘uint16_t’
8 unknown type name ‘pid_t’
8 unknown type name ‘__kernel_pid_t’
7 unknown type name ‘u_short’
5 unknown type name ‘__kernel_long_t’
4 unknown type name ‘__kernel_uid32_t’
4 unknown type name ‘__kernel_gid32_t’
4 ‘ETH_ALEN’ undeclared here (not in a function)
3 unknown type name ‘caddr_t’
3 ‘IPSET_ERR_TYPE_SPECIFIC’ undeclared here (not in a function)
3 field ‘src_addr’ has incomplete type
3 field ‘laddr’ has incomplete type
3 field ‘bssid’ has incomplete type
3 expected specifier-qualifier-list before ‘uint64_t’
2 unknown type name ‘u_long’
2 unknown type name ‘stack_t’
2 unknown type name ‘sigset_t’
2 unknown type name ‘sa_family_t’
2 unknown type name ‘__kernel_mode_t’
2 unknown type name ‘__kernel_key_t’
2 unknown type name ‘elf_gregset_t’
2 unknown type name ‘bool’
2 ‘uint64_t’ undeclared here (not in a function)
2 ‘true’ undeclared (first use in this function)
2 ‘NAME_MAX’ undeclared here (not in a function)
2 ‘__kernel_mode_t’ undeclared here (not in a function)
2 invalid application of ‘sizeof’ to incomplete type ‘struct sockaddr’
2 field ‘uc_mcontext’ has incomplete type
2 field ‘src’ has incomplete type
2 field ‘shm_perm’ has incomplete type
2 field ‘sem_perm’ has incomplete type
2 field ‘raddr’ has incomplete type
2 field ‘msg_perm’ has incomplete type
2 field ‘grp’ has incomplete type
2 field ‘dst_addr’ has incomplete type
2 field ‘arp_pa’ has incomplete type
2 field ‘arp_netmask’ has incomplete type
2 field ‘arp_ha’ has incomplete type
2 ‘false’ undeclared (first use in this function)
1 xen/interface/xen.h: No such file or directory
1 via_drmclient.h: No such file or directory
1 unknown type name ‘wait_queue_head_t’
1 unknown type name ‘uid_t’
1 unknown type name ‘int64_t’
1 unknown type name ‘int16_t’
1 unknown type name ‘ino_t’
1 unknown type name ‘elf_greg_t’
1 unknown type name ‘elf_fpxregset_t’
1 unknown type name ‘elf_fpregset_t’
1 unknown type name ‘__be32’
1 ‘SIOCDEVPRIVATE’ undeclared here (not in a function)
1 ‘sa_family_t’ undeclared here (not in a function)
1 ‘NULL’ undeclared (first use in this function)
1 ‘MSG_FIN’ undeclared here (not in a function)
1 ‘MAX_IPOPTLEN’ undeclared here (not in a function)
1 ‘MAX_ADDR_LEN’ undeclared here (not in a function)
1 ‘IFHWADDRLEN’ undeclared here (not in a function)
1 field ‘vmask’ has incomplete type
1 field ‘vifc_rmt_addr’ has incomplete type
1 field ‘vifc_lcl_addr’ has incomplete type
1 field ‘vaddr’ has incomplete type
1 field ‘uc_chain’ has incomplete type
1 field ‘tcp’ has incomplete type
1 field ‘sspp_addr’ has incomplete type
1 field ‘ssp_addr’ has incomplete type
1 field ‘src_mask’ has incomplete type
1 field ‘spt_address’ has incomplete type
1 field ‘spp_address’ has incomplete type
1 field ‘spinfo_address’ has incomplete type
1 field ‘spc_aaddr’ has incomplete type
1 field ‘smsk’ has incomplete type
1 field ‘sin_addr’ has incomplete type
1 field ‘sas_obs_rto_ipaddr’ has incomplete type
1 field ‘saddr’ has incomplete type
1 field ‘rtmsg_src’ has incomplete type
1 field ‘rtmsg_gateway’ has incomplete type
1 field ‘rtmsg_dst’ has incomplete type
1 field ‘rt_genmask’ has incomplete type
1 field ‘rt_gateway’ has incomplete type
1 field ‘rt_dst’ has incomplete type
1 field ‘prefix’ has incomplete type
1 field ‘mfcc_origin’ has incomplete type
1 field ‘mfcc_mcastgrp’ has incomplete type
1 field ‘mf6cc_origin’ has incomplete type
1 field ‘mf6cc_mcastgrp’ has incomplete type
1 field ‘mask’ has incomplete type
1 field ‘iph’ has incomplete type
1 field ‘ip’ has incomplete type
1 field ‘im_src’ has incomplete type
1 field ‘im_dst’ has incomplete type
1 field ‘im6_src’ has incomplete type
1 field ‘im6_dst’ has incomplete type
1 field ‘gw’ has incomplete type
1 field ‘dst_mask’ has incomplete type
1 field ‘dmsk’ has incomplete type
1 field ‘dest_addr’ has incomplete type
1 field ‘daddr’ has incomplete type
1 field ‘ap_addr’ has incomplete type
1 field ‘a6’ has incomplete type
1 field ‘a4’ has incomplete type
1 #error "patchkey.h included directly"
1 ‘DLM_RESNAME_MAXLEN’ undeclared here (not in a function)
1 array type has incomplete element type ‘struct timespec’
1 array type has incomplete element type ‘struct in6_addr’

Once all these errors have been fixed, this test should be added to
'make headers_check'.

Since I've been stubborn enough to work with this script and fixes to the
test failures for over a year, I added my self to MAINTAINERS.
I will continue to maintain this script as a hobby.

Signed-off-by: Mikko Rapeli <***@iki.fi>
Cc: Alexander Stein <***@systec-electronic.com>
Cc: Gabriel Laskar <***@lse.epita.fr>
---
MAINTAINERS | 5 +
scripts/headers_compile_test.sh | 198 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 203 insertions(+)
create mode 100755 scripts/headers_compile_test.sh

diff --git a/MAINTAINERS b/MAINTAINERS
index a306795..a6fb57d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3245,6 +3245,11 @@ S: Maintained
F: mm/memcontrol.c
F: mm/swap_cgroup.c

+COMPILE TEST FOR HEADER FILES EXPORTED TO USERSPACE
+M: Mikko Rapeli <***@iki.fi>
+S: Maintained
+F: scripts/headers_compile_test.sh
+
CORETEMP HARDWARE MONITORING DRIVER
M: Fenghua Yu <***@intel.com>
L: linux-***@vger.kernel.org
diff --git a/scripts/headers_compile_test.sh b/scripts/headers_compile_test.sh
new file mode 100755
index 0000000..e13f533
--- /dev/null
+++ b/scripts/headers_compile_test.sh
@@ -0,0 +1,198 @@
+#!/bin/bash
+
+help() {
+ cat << EOF_HELP
+Userspace compile test for exported kernel headers.
+
+ Copyright (C) 2015 Mikko Rapeli <***@iki.fi>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; version 2
+ of the License.
+
+Execute in root directory of exported kernel headers in Linux kernel source
+tree. Sets up gcc and libc headers without existing kernel headers to
+a temporary environment and tries to compile all exported header files
+from current directory against them. Return value is zero if all tests pass,
+non-zero if something goes wrong during execution, or the amount of files
+which failed the compile test.
+
+Supported arguments:
+
+ -h|--help print help
+ -k|--keep don't cleanup temporary header files and directories
+ -v|--verbose print more verbose output
+
+Example in Linux kernel source tree:
+
+ \$ make headers_install
+ \$ cd usr/include
+ \$ $( readlink -f "$0" )
+
+EOF_HELP
+}
+
+# bash due to arithmetics and pipefail
+set -euo pipefail
+
+KEEP=0
+HELP=0
+
+# command line arguments
+for p in "$@"; do
+ case "$p" in
+ -k|--keep)
+ KEEP=1
+ ;;
+ -h|--help)
+ HELP=1
+ ;;
+ -v|--verbose)
+ set -x
+ ;;
+ *)
+ help
+ echo "Unknown argument: $p"
+ exit 1
+ ;;
+ esac
+done
+
+if [ "$HELP" != "0" ]; then help; exit 0; fi
+
+# sanity test
+if [ ! -d ./linux ]; then
+ echo Sanity check error: ./linux directory not found
+ echo Should be called in usr/include after \'make headers_install\'.
+ echo Returns number of failed files, 0 if none.
+ exit 1
+fi
+
+# Support CC variable for compiler and ccache, and cross compiling.
+# CC is used without quotes to support CC="ccache gcc".
+set +u
+if [ "$CC"foobar == "foobar" ]; then
+ CC=cc
+fi
+
+if [ "$CROSS_COMPILE"foobar != "foobar" ]; then
+ # Using gcc name since some cross compiler tool chains don't provide
+ # the cc symlink
+ CC="$CROSS_COMPILE"gcc
+fi
+set -u
+
+# Kernel headers refer to some gcc and libc headers so make them available.
+set +u
+if [ "$ARCH_TRIPLET"foobar == "foobar" ]; then
+ # Taking triplet from gcc/cpp
+ ARCH_TRIPLET="$( $CC -v -x c -E - < /dev/null 2>&1 | \
+ grep Target | sed -e 's/Target: //' )"
+fi
+
+if [ "$LIBC"foobar == "foobar" ]; then
+ # trying to grep libc includes from gcc/cpp defaults
+ _TEMP="$( $CC -v -x c -E - < /dev/null 2>&1 | \
+ sed -n -e '/^#include <...> search starts here:$/,/^End of search list.$/{//!p}' | \
+ sed -e 's/^\ \//\//g' | \
+ grep '/usr/include' )"
+
+ # sanity check and prepare LIBC dirs
+ for d in $_TEMP; do
+ if [ ! -d "$d" ]; then
+ echo "$d not a directory"
+ exit 1
+ fi
+ LIBC="$LIBC $d"
+ done
+fi
+set -u
+
+# Copy libc include files to temp directory for the tests.
+COMPILE_TEST_INC="$( readlink -f \
+ "$( mktemp -d ../headers_compile_test_include.XXXXXX )" )"
+
+# cleanup if keep not set
+if [ "$KEEP" = "0" ]; then
+ trap 'rm -rf "$COMPILE_TEST_INC"' EXIT
+else
+ trap 'printf \
+"Temporary directory not cleaned up! Remove manually:\n${COMPILE_TEST_INC}\n"' \
+ EXIT
+fi
+
+for d in $LIBC; do
+ # check if last part of dir is the arch triplet, cross compile paths
+ # can have it also elsewhere so just the last one counts.
+ if ! ( echo "$d" | egrep "$ARCH_TRIPLET$" > /dev/null ); then
+ # hopefully just main libc dir, e.g. /usr/include,
+ # follow symlinks from e.g. /usr/include/bits
+ cp -aL "$d"/* "$COMPILE_TEST_INC"/
+ elif ( echo "$d" | egrep "$ARCH_TRIPLET$" > /dev/null ); then
+ # hopefully the arch specific dir, e.g. /usr/include/x86_64-linux-gnu
+ cp -ar "$d"/* "$COMPILE_TEST_INC/"
+ else
+ echo "$d unexpected, bailing out"
+ exit 1
+ fi
+done
+
+# Simulate libc headers without kernel headers by removing
+# all known kernel header dirs from the copied libc ones.
+# This seems to magically work.
+_KERNEL_DIRS="$( find . -type d | grep -v '^\.$' )"
+( cd "$COMPILE_TEST_INC" && rm -rf $_KERNEL_DIRS )
+
+# GCC headers
+set +u
+if [ "$GCC_INC"foobar == "foobar" ]; then
+ # Take from $CC default system include paths, filter out
+ # /usr/local/include and /usr/include stuff first, then try to match
+ # for gcc.
+ _TEMP="$( $CC -v -x c -E - < /dev/null 2>&1 | \
+ sed -n -e '/^#include <...> search starts here:$/,/^End of search list.$/{//!p}' | \
+ sed -e 's/^\ \//\//g' | \
+ egrep -v '/usr/local/include' | \
+ egrep -v '/usr/include' | \
+ grep gcc | \
+ xargs )"
+
+ # merge and prepare for use with $CC
+ for d in $_TEMP; do
+ # sanity test
+ if [ ! -d "$d" ]; then
+ echo "$d: is not a directory"
+ exit 1
+ fi
+ GCC_INC="$GCC_INC -I $d"
+ done
+fi
+set -u
+
+# For each header file, try to compile it using the headers we prepared.
+_FAILED=0
+_PASSED=0
+for f in $( find . -name "*\.h" | xargs ); do
+ _FAIL=0
+
+ # compile test, CC not quoted to support ccache
+ echo $CC -Wall -c -nostdinc $GCC_INC -I . -I "$COMPILE_TEST_INC" -I "$COMPILE_TEST_INC/$ARCH_TRIPLET" -o /dev/null "$f"
+ $CC -Wall -c -nostdinc $GCC_INC -I . -I "$COMPILE_TEST_INC" -I "$COMPILE_TEST_INC/$ARCH_TRIPLET" -o /dev/null "$f" \
+ || _FAIL=1
+
+ # report errors
+ if [ "$_FAIL" -gt 0 ]; then
+ echo "FAILED: $f"
+ _FAILED="$(( _FAILED + 1 ))"
+ else
+ echo "PASSED: $f"
+ _PASSED="$(( _PASSED + 1))"
+ fi
+done
+
+echo Statistics:
+echo "$_FAILED files failed the compile test."
+echo "$_PASSED files passed the compile test."
+
+exit "$_FAILED"
--
2.8.1
Mikko Rapeli
2016-08-22 18:50:02 UTC
Permalink
Fixes userspace compile errors like:

error: ‘IFNAMSIZ’ undeclared here (not in a function)
error: field ‘laddr’ has incomplete type
struct in6_addr laddr; /* local tunnel end-point address */

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/ip6_tunnel.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/uapi/linux/ip6_tunnel.h b/include/uapi/linux/ip6_tunnel.h
index 48af63c..21cfd62 100644
--- a/include/uapi/linux/ip6_tunnel.h
+++ b/include/uapi/linux/ip6_tunnel.h
@@ -2,6 +2,8 @@
#define _IP6_TUNNEL_H

#include <linux/types.h>
+#include <linux/if.h>
+#include <linux/in6.h>

#define IPV6_TLV_TNL_ENCAP_LIMIT 4
#define IPV6_DEFAULT_TNL_ENCAP_LIMIT 4
--
2.8.1
Mikko Rapeli
2016-08-22 18:50:02 UTC
Permalink
Fixes userspace compilation error:

error: ‘MAX_ADDR_LEN’ undeclared here (not in a function)

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/packet_diag.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/packet_diag.h b/include/uapi/linux/packet_diag.h
index d08c63f..2a75e97 100644
--- a/include/uapi/linux/packet_diag.h
+++ b/include/uapi/linux/packet_diag.h
@@ -2,6 +2,7 @@
#define __PACKET_DIAG_H__

#include <linux/types.h>
+#include <linux/netdevice.h>

struct packet_diag_req {
__u8 sdiag_family;
--
2.8.1
Mikko Rapeli
2016-08-22 18:50:02 UTC
Permalink
Copied the NULL definition from include/linux/stddef.h which does not have
it in userspace.

Fixes userspace compilation error:

error: ‘NULL’ undeclared (first use in this function)
return NULL;

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/btrfs.h | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h
index ac5eacd..8865985 100644
--- a/include/uapi/linux/btrfs.h
+++ b/include/uapi/linux/btrfs.h
@@ -20,6 +20,12 @@
#define _UAPI_LINUX_BTRFS_H
#include <linux/types.h>
#include <linux/ioctl.h>
+#include <linux/stddef.h>
+
+/* for userspace where linux/stddef.h doesn't define this */
+#ifndef NULL
+#define NULL ((void *)0)
+#endif

#define BTRFS_IOCTL_MAGIC 0x94
#define BTRFS_VOL_NAME_MAX 255
--
2.8.1
Mikko Rapeli
2016-08-22 18:50:03 UTC
Permalink
Fixes userspace compilation error:

error: unknown type name ‘size_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
arch/x86/include/uapi/asm/signal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/uapi/asm/signal.h b/arch/x86/include/uapi/asm/signal.h
index 8264f47..74346db 100644
--- a/arch/x86/include/uapi/asm/signal.h
+++ b/arch/x86/include/uapi/asm/signal.h
@@ -127,7 +127,7 @@ struct sigaction {
typedef struct sigaltstack {
void __user *ss_sp;
int ss_flags;
- size_t ss_size;
+ __kernel_size_t ss_size;
} stack_t;

#endif /* __ASSEMBLY__ */
--
2.8.1
Mikko Rapeli
2016-08-22 18:50:03 UTC
Permalink
Fixes userspace compilation errors due to missing timespec definition.

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/hsi/cs-protocol.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/hsi/cs-protocol.h b/include/uapi/linux/hsi/cs-protocol.h
index f153d6e..c8d9f08 100644
--- a/include/uapi/linux/hsi/cs-protocol.h
+++ b/include/uapi/linux/hsi/cs-protocol.h
@@ -26,6 +26,7 @@

#include <linux/types.h>
#include <linux/ioctl.h>
+#include <linux/time.h>

/* chardev parameters */
#define CS_DEV_FILE_NAME "/dev/cmt_speech"
--
2.8.1
Sebastian Reichel
2016-08-22 21:00:02 UTC
Permalink
Hi,
Post by Mikko Rapeli
Fixes userspace compilation errors due to missing timespec definition.
---
include/uapi/linux/hsi/cs-protocol.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/uapi/linux/hsi/cs-protocol.h b/include/uapi/linux/hsi/cs-protocol.h
index f153d6e..c8d9f08 100644
--- a/include/uapi/linux/hsi/cs-protocol.h
+++ b/include/uapi/linux/hsi/cs-protocol.h
@@ -26,6 +26,7 @@
#include <linux/types.h>
#include <linux/ioctl.h>
+#include <linux/time.h>
/* chardev parameters */
#define CS_DEV_FILE_NAME "/dev/cmt_speech"
As far as I can see there header file does not use timespec since
I removed it roughly a year ago.

-- Sebastian
Mikko Rapeli
2016-08-23 07:00:01 UTC
Permalink
Post by Sebastian Reichel
Hi,
Post by Mikko Rapeli
Fixes userspace compilation errors due to missing timespec definition.
---
include/uapi/linux/hsi/cs-protocol.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/uapi/linux/hsi/cs-protocol.h b/include/uapi/linux/hsi/cs-protocol.h
index f153d6e..c8d9f08 100644
--- a/include/uapi/linux/hsi/cs-protocol.h
+++ b/include/uapi/linux/hsi/cs-protocol.h
@@ -26,6 +26,7 @@
#include <linux/types.h>
#include <linux/ioctl.h>
+#include <linux/time.h>
/* chardev parameters */
#define CS_DEV_FILE_NAME "/dev/cmt_speech"
As far as I can see there header file does not use timespec since
I removed it roughly a year ago.
Ok, sorry I missed that. I will the need for this again.

-Mikko

Mikko Rapeli
2016-08-22 18:50:03 UTC
Permalink
Fixes userspace compiler error:

error: unknown type name ‘uint32_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/openvswitch.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index d95a301..645499a 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -632,8 +632,8 @@ enum ovs_hash_alg {
* @hash_basis: basis used for computing hash.
*/
struct ovs_action_hash {
- uint32_t hash_alg; /* One of ovs_hash_alg. */
- uint32_t hash_basis;
+ __u32 hash_alg; /* One of ovs_hash_alg. */
+ __u32 hash_basis;
};

/**
--
2.8.1
Stephen Hemminger
2016-08-22 19:40:02 UTC
Permalink
On Mon, 22 Aug 2016 20:32:55 +0200
Post by Mikko Rapeli
error: unknown type name ‘uint32_t’
---
include/uapi/linux/openvswitch.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index d95a301..645499a 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -632,8 +632,8 @@ enum ovs_hash_alg {
*/
struct ovs_action_hash {
- uint32_t hash_alg; /* One of ovs_hash_alg. */
- uint32_t hash_basis;
+ __u32 hash_alg; /* One of ovs_hash_alg. */
+ __u32 hash_basis;
};
/**
This is a a real issue, but being buried in a huge patch series of include
file stuff I don't think anyone would see it.
David Miller
2016-08-22 23:30:01 UTC
Permalink
From: Stephen Hemminger <***@networkplumber.org>
Date: Mon, 22 Aug 2016 12:39:38 -0700
Post by Stephen Hemminger
This is a a real issue, but being buried in a huge patch series of include
file stuff I don't think anyone would see it.
It hit netdev and thus patchwork, therefore anyone watching networking
patches saw it.

I would not call it buried at all.
David Miller
2016-08-22 23:40:02 UTC
Permalink
From: Mikko Rapeli <***@iki.fi>
Date: Mon, 22 Aug 2016 20:32:55 +0200
Post by Mikko Rapeli
error: unknown type name ‘uint32_t’
Applied.
Mikko Rapeli
2016-08-22 19:00:01 UTC
Permalink
Kernel uapi header are supposed to use them. Fixes userspace compile error:

linux/openvswitch.h:583:2: error: unknown type name ‘uint32_t’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/openvswitch.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index 645499a..54c3b4f 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -583,7 +583,7 @@ enum ovs_userspace_attr {
#define OVS_USERSPACE_ATTR_MAX (__OVS_USERSPACE_ATTR_MAX - 1)

struct ovs_action_trunc {
- uint32_t max_len; /* Max packet size in bytes. */
+ __u32 max_len; /* Max packet size in bytes. */
};

/**
--
2.8.1
David Miller
2016-08-22 23:40:02 UTC
Permalink
From: Mikko Rapeli <***@iki.fi>
Date: Mon, 22 Aug 2016 20:33:19 +0200
Post by Mikko Rapeli
linux/openvswitch.h:583:2: error: unknown type name ‘uint32_t’
Mikko Rapeli
2016-08-22 19:00:01 UTC
Permalink
Fixes this userspace compile error when net/route.h is included before
linux/route.h:

linux/route.h:30:8: error: redefinition of ‘struct rtentry’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/libc-compat.h | 10 ++++++++++
include/uapi/linux/route.h | 4 +++-
2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index 07a3462..16ba7dc 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -230,6 +230,13 @@

#endif /* defined(_NETROSE_ROSE_H) */

+/* Coordinate with glibc net/route.h */
+#if defined(_NET_ROUTE_H)
+#define __UAPI_DEF_RTENTRY 0
+#else /* defined(_NET_ROUTE_H) */
+#define __UAPI_DEF_RTENTRY 1
+#endif /* defined(_NET_ROUTE_H) */
+
/* Coordinate with glibc pty.h */
#if defined(_PTY_H)
#define __UAPI_DEF_TERMIOS 0
@@ -369,6 +376,9 @@
#define __UAPI_DEF_ROSE_CAUSE_STRUCT 1
#define __UAPI_DEF_ROSE_FACILITIES_STRUCT 1

+/* Definitions for route.h */
+#define __UAPI_DEF_RTENTRY 1
+
/* Definitions for time.h */
#define __UAPI_DEF_TIMESPEC 1
#define __UAPI_DEF_TIMEVAL 1
diff --git a/include/uapi/linux/route.h b/include/uapi/linux/route.h
index 6600708..7b77ef2 100644
--- a/include/uapi/linux/route.h
+++ b/include/uapi/linux/route.h
@@ -23,10 +23,12 @@
#ifndef _LINUX_ROUTE_H
#define _LINUX_ROUTE_H

+#include <linux/libc-compat.h>
#include <linux/if.h>
#include <linux/compiler.h>

/* This structure gets passed by the SIOCADDRT and SIOCDELRT calls. */
+#if __UAPI_DEF_RTENTRY
struct rtentry {
unsigned long rt_pad1;
struct sockaddr rt_dst; /* target address */
@@ -45,7 +47,7 @@ struct rtentry {
unsigned long rt_window; /* Window clamping */
unsigned short rt_irtt; /* Initial RTT */
};
-
+#endif /* __UAPI_DEF_RTENTRY */

#define RTF_UP 0x0001 /* route usable */
#define RTF_GATEWAY 0x0002 /* destination is a gateway */
--
2.8.1
David Miller
2016-08-22 23:40:02 UTC
Permalink
You have to post this properly to the netdev list.

If netdev is not CC:'d it doesn't get properly logged in patchwork,
and won't be applied.
Mikko Rapeli
2016-08-22 19:00:02 UTC
Permalink
Both are needed to compile <xen/gntdev.h> wihtout compiler warnings
in userspace. Fixes these userspace compile errors:

xen/gntdev.h:151:4: error: unknown type name ‘grant_ref_t’
grant_ref_t ref;
^
xen/gntdev.h:153:4: error: unknown type name ‘domid_t’
domid_t domid;
^

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/xen/gntdev.h | 6 ++++++
include/xen/interface/grant_table.h | 6 +-----
2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/include/uapi/xen/gntdev.h b/include/uapi/xen/gntdev.h
index d066197..f208706 100644
--- a/include/uapi/xen/gntdev.h
+++ b/include/uapi/xen/gntdev.h
@@ -34,6 +34,12 @@
#define __LINUX_PUBLIC_GNTDEV_H__

#include <linux/types.h>
+#include <xen/privcmd.h>
+
+/*
+ * Reference to a grant entry in a specified domain's grant table.
+ */
+typedef __u32 grant_ref_t;

struct ioctl_gntdev_grant_ref {
/* The domain ID of the grant to be mapped. */
diff --git a/include/xen/interface/grant_table.h b/include/xen/interface/grant_table.h
index 56806bc..7e064d6 100644
--- a/include/xen/interface/grant_table.h
+++ b/include/xen/interface/grant_table.h
@@ -29,6 +29,7 @@
#define __XEN_PUBLIC_GRANT_TABLE_H__

#include <xen/interface/xen.h>
+#include <uapi/xen/gntdev.h> /* for grant_ref_t */

/***********************************
* GRANT TABLE REPRESENTATION
@@ -85,11 +86,6 @@
*/

/*
- * Reference to a grant entry in a specified domain's grant table.
- */
-typedef uint32_t grant_ref_t;
-
-/*
* A grant table comprises a packed array of grant entries in one or more
* page frames shared between Xen and a guest.
* [XEN]: This field is written by Xen and read by the sharing guest.
--
2.8.1
Mikko Rapeli
2016-08-22 19:00:02 UTC
Permalink
Fixes this userspace compile error when glibc netinet/ip_icmp.h is included
before linux/icmp.h:

linux/icmp.h:68:8: error: redefinition of ‘struct icmphdr’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/icmp.h | 4 +++-
include/uapi/linux/libc-compat.h | 10 ++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/icmp.h b/include/uapi/linux/icmp.h
index fddd9d7..cd38005 100644
--- a/include/uapi/linux/icmp.h
+++ b/include/uapi/linux/icmp.h
@@ -17,6 +17,7 @@
#ifndef _UAPI_LINUX_ICMP_H
#define _UAPI_LINUX_ICMP_H

+#include <linux/libc-compat.h>
#include <linux/types.h>

#define ICMP_ECHOREPLY 0 /* Echo Reply */
@@ -64,7 +65,7 @@
#define ICMP_EXC_TTL 0 /* TTL count exceeded */
#define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */

-
+#if __UAPI_DEF_ICMPHDR
struct icmphdr {
__u8 type;
__u8 code;
@@ -82,6 +83,7 @@ struct icmphdr {
__u8 reserved[4];
} un;
};
+#endif /* __UAPI_DEF_ICMPHDR */


/*
diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index 40190a4..8a5a7cc 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -154,6 +154,13 @@

#endif /* _NETINET_IN_H */

+/* Coordinate with glibc netinet/ip_icmp.h header. */
+#if defined(__NETINET_IP_ICMP_H)
+#define __UAPI_DEF_ICMPHDR 0
+#else /* defined(__NETINET_IP_ICMP_H) */
+#define __UAPI_DEF_ICMPHDR 1
+#endif /* defined(__NETINET_IP_ICMP_H) */
+
/* Coordinate with glibc netipx/ipx.h header. */
#if defined(__NETIPX_IPX_H)

@@ -218,6 +225,9 @@
#define __UAPI_DEF_IN6_PKTINFO 1
#define __UAPI_DEF_IP6_MTUINFO 1

+/* Definitions for icmp.h */
+#define __UAPI_DEF_ICMPHDR 1
+
/* Definitions for ipx.h */
#define __UAPI_DEF_SOCKADDR_IPX 1
#define __UAPI_DEF_IPX_ROUTE_DEFINITION 1
--
2.8.1
David Miller
2016-08-22 23:40:02 UTC
Permalink
Must be CC:'d to netdev.
Mikko Rapeli
2016-08-22 19:10:01 UTC
Permalink
Only users of upc_req in kernel side fs/coda/psdev.c and fs/coda/upcall.c
already include linux/coda_psdev.h.

Suggested by Jan Harkes <***@cs.cmu.edu> on lkml message
<***@cs.cmu.edu>.

Fixes these include/uapi/linux/coda_psdev.h compilation errors in userspace:

./linux/coda_psdev.h:12:19: error: field ‘uc_chain’ has incomplete type
struct list_head uc_chain;
^
./linux/coda_psdev.h:13:2: error: unknown type name ‘caddr_t’
caddr_t uc_data;
^
./linux/coda_psdev.h:14:2: error: unknown type name ‘u_short’
u_short uc_flags;
^
./linux/coda_psdev.h:15:2: error: unknown type name ‘u_short’
u_short uc_inSize; /* Size is at most 5000 bytes */
^
./linux/coda_psdev.h:16:2: error: unknown type name ‘u_short’
u_short uc_outSize;
^
./linux/coda_psdev.h:17:2: error: unknown type name ‘u_short’
u_short uc_opcode; /* copied from data to save lookup */
^
./linux/coda_psdev.h:19:2: error: unknown type name ‘wait_queue_head_t’
wait_queue_head_t uc_sleep; /* process' wait queue */
^

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/linux/coda_psdev.h | 11 +++++++++++
include/uapi/linux/coda_psdev.h | 13 -------------
2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/include/linux/coda_psdev.h b/include/linux/coda_psdev.h
index 5b8721e..fe1466d 100644
--- a/include/linux/coda_psdev.h
+++ b/include/linux/coda_psdev.h
@@ -19,6 +19,17 @@ struct venus_comm {
struct mutex vc_mutex;
};

+/* messages between coda filesystem in kernel and Venus */
+struct upc_req {
+ struct list_head uc_chain;
+ caddr_t uc_data;
+ u_short uc_flags;
+ u_short uc_inSize; /* Size is at most 5000 bytes */
+ u_short uc_outSize;
+ u_short uc_opcode; /* copied from data to save lookup */
+ int uc_unique;
+ wait_queue_head_t uc_sleep; /* process' wait queue */
+};

static inline struct venus_comm *coda_vcp(struct super_block *sb)
{
diff --git a/include/uapi/linux/coda_psdev.h b/include/uapi/linux/coda_psdev.h
index 79d0598..e2c44d2 100644
--- a/include/uapi/linux/coda_psdev.h
+++ b/include/uapi/linux/coda_psdev.h
@@ -6,19 +6,6 @@
#define CODA_PSDEV_MAJOR 67
#define MAX_CODADEVS 5 /* how many do we allow */

-
-/* messages between coda filesystem in kernel and Venus */
-struct upc_req {
- struct list_head uc_chain;
- caddr_t uc_data;
- u_short uc_flags;
- u_short uc_inSize; /* Size is at most 5000 bytes */
- u_short uc_outSize;
- u_short uc_opcode; /* copied from data to save lookup */
- int uc_unique;
- wait_queue_head_t uc_sleep; /* process' wait queue */
-};
-
#define CODA_REQ_ASYNC 0x1
#define CODA_REQ_READ 0x2
#define CODA_REQ_WRITE 0x4
--
2.8.1
Mikko Rapeli
2016-08-22 19:10:01 UTC
Permalink
Fixes userspace compilation error:

error: ‘IFNAMSIZ’ undeclared here (not in a function)

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/if_pppox.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/if_pppox.h b/include/uapi/linux/if_pppox.h
index e128769..473c3c4 100644
--- a/include/uapi/linux/if_pppox.h
+++ b/include/uapi/linux/if_pppox.h
@@ -21,6 +21,7 @@
#include <asm/byteorder.h>

#include <linux/socket.h>
+#include <linux/if.h>
#include <linux/if_ether.h>
#include <linux/if_pppol2tp.h>
--
2.8.1
Stephen Hemminger
2016-08-22 19:40:02 UTC
Permalink
On Mon, 22 Aug 2016 20:32:38 +0200
Post by Mikko Rapeli
error: ‘IFNAMSIZ’ undeclared here (not in a function)
---
include/uapi/linux/if_pppox.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/uapi/linux/if_pppox.h b/include/uapi/linux/if_pppox.h
index e128769..473c3c4 100644
--- a/include/uapi/linux/if_pppox.h
+++ b/include/uapi/linux/if_pppox.h
@@ -21,6 +21,7 @@
#include <asm/byteorder.h>
#include <linux/socket.h>
+#include <linux/if.h>
#include <linux/if_ether.h>
#include <linux/if_pppol2tp.h>
I went back to the first patch in LKML for this series.
It seems your goal is that every include file should be standalone,
i.e it must include every definition it uses.

I disagree with this premise. It just makes things harder to maintain with
no real gain for any existing program. What is the motivation for all this
useless churn? Is there some silly style rule that should be fixed instead?
David Miller
2016-08-22 23:30:02 UTC
Permalink
From: Stephen Hemminger <***@networkplumber.org>
Date: Mon, 22 Aug 2016 12:37:45 -0700
Post by Stephen Hemminger
It seems your goal is that every include file should be standalone,
i.e it must include every definition it uses.
I think this is absolutely mandatory Stephen. If you include x.h
it should just work if you use the interfaces x.h defines.

No user should have to know about dependencies, that is exactly the
job of the header file itself.
Mikko Rapeli
2016-08-23 06:50:01 UTC
Permalink
Post by Stephen Hemminger
On Mon, 22 Aug 2016 20:32:38 +0200
Post by Mikko Rapeli
error: ‘IFNAMSIZ’ undeclared here (not in a function)
---
include/uapi/linux/if_pppox.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/uapi/linux/if_pppox.h b/include/uapi/linux/if_pppox.h
index e128769..473c3c4 100644
--- a/include/uapi/linux/if_pppox.h
+++ b/include/uapi/linux/if_pppox.h
@@ -21,6 +21,7 @@
#include <asm/byteorder.h>
#include <linux/socket.h>
+#include <linux/if.h>
#include <linux/if_ether.h>
#include <linux/if_pppol2tp.h>
I went back to the first patch in LKML for this series.
It seems your goal is that every include file should be standalone,
i.e it must include every definition it uses.
I disagree with this premise. It just makes things harder to maintain with
no real gain for any existing program. What is the motivation for all this
useless churn? Is there some silly style rule that should be fixed instead?
With over 700 uapi headers exported to userspace by Linux kernel, how
do I find out the 'correct' order of including them if they can not be
included alone? Any hints on automating that?

My first trial was to include all of the uapi headers as a single bunch to
abi checker tool which calls gcc on them, but the compilation result was
so bad and hopeless that I decided to try feeding each header file one by
one to the compiler and here I am over two years later still fixing these
issues.

I came up with the rule because to me it makes sense. Several kernel
devs agree with this approach and have accepted patches.

If your kernel subsystem uapi headers have a single entry point header file,
then all of the others can just depend on that and be done with it.
For example most (if not all) drm driver specific headers include <drm/drm.h>.

-Mikko
David Miller
2016-08-22 23:40:01 UTC
Permalink
From: Mikko Rapeli <***@iki.fi>
Date: Mon, 22 Aug 2016 20:32:38 +0200
Post by Mikko Rapeli
error: ‘IFNAMSIZ’ undeclared here (not in a function)
Signed-off-by: Mikko Rapeli <mikko.rapel
Mikko Rapeli
2016-08-22 19:10:01 UTC
Permalink
Fixes these userspace compile warnings and error when glibc fcntl.h is
included before linux/fcntl.h:

asm-generic/fcntl.h:18:0: warning: "O_ACCMODE" redefined
asm-generic/fcntl.h:19:0: warning: "O_RDONLY" redefined
asm-generic/fcntl.h:20:0: warning: "O_WRONLY" redefined
asm-generic/fcntl.h:21:0: warning: "O_RDWR" redefined
asm-generic/fcntl.h:195:8: error: redefinition of ‘struct flock’
linux/fcntl.h:16:0: warning: "F_DUPFD_CLOEXEC" redefined

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/asm-generic/fcntl.h | 6 ++++++
include/uapi/linux/fcntl.h | 3 +++
include/uapi/linux/libc-compat.h | 20 ++++++++++++++++++++
3 files changed, 29 insertions(+)

diff --git a/include/uapi/asm-generic/fcntl.h b/include/uapi/asm-generic/fcntl.h
index e063eff..3b429ce 100644
--- a/include/uapi/asm-generic/fcntl.h
+++ b/include/uapi/asm-generic/fcntl.h
@@ -1,6 +1,7 @@
#ifndef _ASM_GENERIC_FCNTL_H
#define _ASM_GENERIC_FCNTL_H

+#include <linux/libc-compat.h>
#include <linux/types.h>

/*
@@ -15,10 +16,13 @@
* When introducing new O_* bits, please check its uniqueness in fcntl_init().
*/

+#if __UAPI_DEF_O_ACCMODE_RDONLY_WRONLY_RDWR
#define O_ACCMODE 00000003
#define O_RDONLY 00000000
#define O_WRONLY 00000001
#define O_RDWR 00000002
+#endif /* __UAPI_DEF_O_ACCMODE_RDONLY_WRONLY_RDWR */
+
#ifndef O_CREAT
#define O_CREAT 00000100 /* not fcntl */
#endif
@@ -192,6 +196,7 @@ struct f_owner_ex {
#define __ARCH_FLOCK_PAD
#endif

+#if __UAPI_DEF_FLOCK
struct flock {
short l_type;
short l_whence;
@@ -200,6 +205,7 @@ struct flock {
__kernel_pid_t l_pid;
__ARCH_FLOCK_PAD
};
+#endif /* __UAPI_DEF_FLOCK */
#endif

#ifndef HAVE_ARCH_STRUCT_FLOCK64
diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h
index beed138..279bcfb 100644
--- a/include/uapi/linux/fcntl.h
+++ b/include/uapi/linux/fcntl.h
@@ -1,6 +1,7 @@
#ifndef _UAPI_LINUX_FCNTL_H
#define _UAPI_LINUX_FCNTL_H

+#include <linux/libc-compat.h>
#include <asm/fcntl.h>

#define F_SETLEASE (F_LINUX_SPECIFIC_BASE + 0)
@@ -13,7 +14,9 @@
#define F_CANCELLK (F_LINUX_SPECIFIC_BASE + 5)

/* Create a file descriptor with FD_CLOEXEC set. */
+#if __UAPI_DEF_F_DUPFD_CLOEXEC
#define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6)
+#endif /* __UAPI_DEF_F_DUPFD_CLOEXEC */

/*
* Request nofications on a directory.
diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index 44b8a6b..40190a4 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -51,6 +51,21 @@
/* We have included glibc headers... */
#if defined(__GLIBC__)

+/* Coordinate with glibc fcntl.h header. */
+#if defined(_FCNTL_H)
+
+#define __UAPI_DEF_FLOCK 0
+#define __UAPI_DEF_F_DUPFD_CLOEXEC 0
+#define __UAPI_DEF_O_ACCMODE_RDONLY_WRONLY_RDWR 0
+
+#else /* defined(_FCNTL_H) */
+
+#define __UAPI_DEF_FLOCK 1
+#define __UAPI_DEF_F_DUPFD_CLOEXEC 1
+#define __UAPI_DEF_O_ACCMODE_RDONLY_WRONLY_RDWR 1
+
+#endif /* defined(_FCNTL_H) */
+
/* Coordinate with glibc net/if.h header. */
#if defined(_NET_IF_H) && defined(__USE_MISC)

@@ -170,6 +185,11 @@
* that we need. */
#else /* !defined(__GLIBC__) */

+/* Definitions for asm-generic/fcntl.h */
+#define __UAPI_DEF_FLOCK 1
+#define __UAPI_DEF_F_DUPFD_CLOEXEC 1
+#define __UAPI_DEF_O_ACCMODE_RDONLY_WRONLY_RDWR 1
+
/* Definitions for if.h */
#define __UAPI_DEF_IF_IFCONF 1
#define __UAPI_DEF_IF_IFMAP 1
--
2.8.1
Mikko Rapeli
2016-08-22 19:20:01 UTC
Permalink
Fixes userspace compile errors like:

error: field ‘mf6cc_origin’ has incomplete type
struct sockaddr_in6 mf6cc_origin; /* Origin of mcast */

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/mroute6.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/mroute6.h b/include/uapi/linux/mroute6.h
index 5062fb5..d05424f 100644
--- a/include/uapi/linux/mroute6.h
+++ b/include/uapi/linux/mroute6.h
@@ -4,6 +4,7 @@
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/sockios.h>
+#include <linux/in6.h>

/*
* Based on the MROUTING 3.5 defines primarily to keep
--
2.8.1
David Miller
2016-08-22 23:30:01 UTC
Permalink
From: Mikko Rapeli <***@iki.fi>
Date: Mon, 22 Aug 2016 20:32:40 +0200
Post by Mikko Rapeli
error: field ‘mf6cc_origin’ has incomplete type
struct sockaddr_in6 mf6cc_origin; /* Origin of mcast */
Signed-off-by: Mikko Rapeli <mikko.rape
Mikko Rapeli
2016-08-22 19:20:01 UTC
Permalink
This libc header has sockaddr definition for userspace.

Fixes userspace compilation errors like these from kernel headers including
only linux/socket.h:

error: field ‘ifru_addr’ has incomplete type
struct sockaddr ifru_addr;

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/socket.h | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/include/uapi/linux/socket.h b/include/uapi/linux/socket.h
index 76ab0c6..8a81197 100644
--- a/include/uapi/linux/socket.h
+++ b/include/uapi/linux/socket.h
@@ -1,6 +1,10 @@
#ifndef _UAPI_LINUX_SOCKET_H
#define _UAPI_LINUX_SOCKET_H

+#ifndef __KERNEL__
+#include <sys/socket.h>
+#endif
+
/*
* Desired design of maximum size and alignment (see RFC2553)
*/
--
2.8.1
Mikko Rapeli
2016-08-22 19:20:02 UTC
Permalink
Fixes these userspace compile errors and warnings when glibc
netrose/rose.h is included before linux/rose.h:

linux/rose.h:25:0: warning: "SIOCRSGCAUSE" redefined
linux/rose.h:26:0: warning: "SIOCRSSCAUSE" redefined
linux/rose.h:27:0: warning: "SIOCRSL2CALL" redefined
linux/rose.h:28:0: warning: "SIOCRSSL2CALL" redefined
linux/rose.h:29:0: warning: "SIOCRSACCEPT" redefined
linux/rose.h:30:0: warning: "SIOCRSCLRRT" redefined
linux/rose.h:31:0: warning: "SIOCRSGL2CALL" redefined
linux/rose.h:32:0: warning: "SIOCRSGFACILITIES" redefined
linux/rose.h:47:3: error: conflicting types for ‘rose_address’
linux/rose.h:49:8: error: redefinition of ‘struct sockaddr_rose’
linux/rose.h:57:8: error: redefinition of ‘struct full_sockaddr_rose’
linux/rose.h:65:8: error: redefinition of ‘struct rose_route_struct’
linux/rose.h:74:8: error: redefinition of ‘struct rose_cause_struct’
linux/rose.h:79:8: error: redefinition of ‘struct rose_facilities_struct’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/libc-compat.h | 30 ++++++++++++++++++++++++++++++
include/uapi/linux/rose.h | 15 +++++++++++++++
2 files changed, 45 insertions(+)

diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index 01bb521..acc2e75 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -209,6 +209,27 @@

#endif /* defined(__NETIPX_IPX_H) */

+/* Coordinate with glibc netrose/rose.h */
+#if defined(_NETROSE_ROSE_H)
+#define __UAPI_DEF_SIOCRSGCAUSE_TO_SIOCRSGFACILITIES 0
+#define __UAPI_DEF_ROSE_ADDRESS 0
+#define __UAPI_DEF_SOCKADDR_ROSE 0
+#define __UAPI_DEF_FULL_SOCKADDR_ROSE 0
+#define __UAPI_DEF_ROSE_ROUTE_STRUCT 0
+#define __UAPI_DEF_ROSE_CAUSE_STRUCT 0
+#define __UAPI_DEF_ROSE_FACILITIES_STRUCT 0
+
+#else /* defined(_NETROSE_ROSE_H) */
+#define __UAPI_DEF_SIOCRSGCAUSE_TO_SIOCRSGFACILITIES 1
+#define __UAPI_DEF_ROSE_ADDRESS 1
+#define __UAPI_DEF_SOCKADDR_ROSE 1
+#define __UAPI_DEF_FULL_SOCKADDR_ROSE 1
+#define __UAPI_DEF_ROSE_ROUTE_STRUCT 1
+#define __UAPI_DEF_ROSE_CAUSE_STRUCT 1
+#define __UAPI_DEF_ROSE_FACILITIES_STRUCT 1
+
+#endif /* defined(_NETROSE_ROSE_H) */
+
/* Definitions for sys/uio.h */
#if defined(_SYS_UIO_H)
#define __UAPI_DEF_IOVEC 0
@@ -283,6 +304,15 @@
#define __UAPI_DEF_IPX_CONFIG_DATA 1
#define __UAPI_DEF_IPX_ROUTE_DEF 1

+/* Definitions for rose.h */
+#define __UAPI_DEF_SIOCRSGCAUSE_TO_SIOCRSGFACILITIES 1
+#define __UAPI_DEF_ROSE_ADDRESS 1
+#define __UAPI_DEF_SOCKADDR_ROSE 1
+#define __UAPI_DEF_FULL_SOCKADDR_ROSE 1
+#define __UAPI_DEF_ROSE_ROUTE_STRUCT 1
+#define __UAPI_DEF_ROSE_CAUSE_STRUCT 1
+#define __UAPI_DEF_ROSE_FACILITIES_STRUCT 1
+
/* Definitions for uio.h */
#define __UAPI_DEF_IOVEC 1

diff --git a/include/uapi/linux/rose.h b/include/uapi/linux/rose.h
index 1fcfe95..c39499c 100644
--- a/include/uapi/linux/rose.h
+++ b/include/uapi/linux/rose.h
@@ -7,6 +7,7 @@
#ifndef ROSE_KERNEL_H
#define ROSE_KERNEL_H

+#include <linux/libc-compat.h>
#include <linux/socket.h>
#include <linux/ax25.h>

@@ -22,6 +23,7 @@
#define ROSE_QBITINCL 6
#define ROSE_HOLDBACK 7

+#if __UAPI_DEF_SIOCRSGCAUSE_TO_SIOCRSGFACILITIES
#define SIOCRSGCAUSE (SIOCPROTOPRIVATE+0)
#define SIOCRSSCAUSE (SIOCPROTOPRIVATE+1)
#define SIOCRSL2CALL (SIOCPROTOPRIVATE+2)
@@ -30,6 +32,7 @@
#define SIOCRSCLRRT (SIOCPROTOPRIVATE+4)
#define SIOCRSGL2CALL (SIOCPROTOPRIVATE+5)
#define SIOCRSGFACILITIES (SIOCPROTOPRIVATE+6)
+#endif /* __UAPI_DEF_SIOCRSGCAUSE_TO_SIOCRSGFACILITIES */

#define ROSE_DTE_ORIGINATED 0x00
#define ROSE_NUMBER_BUSY 0x01
@@ -42,10 +45,13 @@
#define ROSE_LOCAL_PROCEDURE 0x13
#define ROSE_SHIP_ABSENT 0x39

+#if __UAPI_DEF_ROSE_ADDRESS
typedef struct {
char rose_addr[5];
} rose_address;
+#endif /* __UAPI_DEF_ROSE_ADDRESS */

+#if __UAPI_DEF_SOCKADDR_ROSE
struct sockaddr_rose {
__kernel_sa_family_t srose_family;
rose_address srose_addr;
@@ -53,7 +59,9 @@ struct sockaddr_rose {
int srose_ndigis;
ax25_address srose_digi;
};
+#endif /* __UAPI_DEF_SOCKADDR_ROSE */

+#if __UAPI_DEF_FULL_SOCKADDR_ROSE
struct full_sockaddr_rose {
__kernel_sa_family_t srose_family;
rose_address srose_addr;
@@ -61,7 +69,9 @@ struct full_sockaddr_rose {
unsigned int srose_ndigis;
ax25_address srose_digis[ROSE_MAX_DIGIS];
};
+#endif /* __UAPI_DEF_FULL_SOCKADDR_ROSE */

+#if __UAPI_DEF_ROSE_ROUTE_STRUCT
struct rose_route_struct {
rose_address address;
unsigned short mask;
@@ -70,12 +80,16 @@ struct rose_route_struct {
unsigned char ndigis;
ax25_address digipeaters[AX25_MAX_DIGIS];
};
+#endif /* __UAPI_DEF_ROSE_ROUTE_STRUCT */

+#if __UAPI_DEF_ROSE_CAUSE_STRUCT
struct rose_cause_struct {
unsigned char cause;
unsigned char diagnostic;
};
+#endif /* __UAPI_DEF_ROSE_CAUSE_STRUCT */

+#if __UAPI_DEF_ROSE_FACILITIES_STRUCT
struct rose_facilities_struct {
rose_address source_addr, dest_addr;
ax25_address source_call, dest_call;
@@ -86,5 +100,6 @@ struct rose_facilities_struct {
rose_address fail_addr;
ax25_address fail_call;
};
+#endif /* __UAPI_DEF_ROSE_FACILITIES_STRUCT */

#endif
--
2.8.1
David Miller
2016-08-22 23:40:02 UTC
Permalink
Must be CC:'d to netdev.
Mikko Rapeli
2016-08-22 19:20:02 UTC
Permalink
Kernel headers should use linux/types.h types.

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/linux/sdb.h | 62 +++++++++++++++++++++++++----------------------------
1 file changed, 29 insertions(+), 33 deletions(-)

diff --git a/include/linux/sdb.h b/include/linux/sdb.h
index fbb76a4..e9ff976 100644
--- a/include/linux/sdb.h
+++ b/include/linux/sdb.h
@@ -3,11 +3,7 @@
*/
#ifndef __SDB_H__
#define __SDB_H__
-#ifdef __KERNEL__
#include <linux/types.h>
-#else
-#include <stdint.h>
-#endif

/*
* All structures are 64 bytes long and are expected
@@ -25,12 +21,12 @@
* and not terminated with a 0 byte.
*/
struct sdb_product {
- uint64_t vendor_id; /* 0x18..0x1f */
- uint32_t device_id; /* 0x20..0x23 */
- uint32_t version; /* 0x24..0x27 */
- uint32_t date; /* 0x28..0x2b */
- uint8_t name[19]; /* 0x2c..0x3e */
- uint8_t record_type; /* 0x3f */
+ __u64 vendor_id; /* 0x18..0x1f */
+ __u32 device_id; /* 0x20..0x23 */
+ __u32 version; /* 0x24..0x27 */
+ __u32 date; /* 0x28..0x2b */
+ __u8 name[19]; /* 0x2c..0x3e */
+ __u8 record_type; /* 0x3f */
};

/*
@@ -40,8 +36,8 @@ struct sdb_product {
* (for example 0x100000 - 0x10ffff)
*/
struct sdb_component {
- uint64_t addr_first; /* 0x08..0x0f */
- uint64_t addr_last; /* 0x10..0x17 */
+ __u64 addr_first; /* 0x08..0x0f */
+ __u64 addr_last; /* 0x10..0x17 */
struct sdb_product product; /* 0x18..0x3f */
};

@@ -63,10 +59,10 @@ enum sdb_record_type {
*/
#define SDB_MAGIC 0x5344422d /* "SDB-" */
struct sdb_interconnect {
- uint32_t sdb_magic; /* 0x00-0x03 */
- uint16_t sdb_records; /* 0x04-0x05 */
- uint8_t sdb_version; /* 0x06 */
- uint8_t sdb_bus_type; /* 0x07 */
+ __u32 sdb_magic; /* 0x00-0x03 */
+ __u16 sdb_records; /* 0x04-0x05 */
+ __u8 sdb_version; /* 0x06 */
+ __u8 sdb_bus_type; /* 0x07 */
struct sdb_component sdb_component; /* 0x08-0x3f */
};

@@ -77,10 +73,10 @@ struct sdb_interconnect {
* bus-specific bits are defined by each bus (see below)
*/
struct sdb_device {
- uint16_t abi_class; /* 0x00-0x01 */
- uint8_t abi_ver_major; /* 0x02 */
- uint8_t abi_ver_minor; /* 0x03 */
- uint32_t bus_specific; /* 0x04-0x07 */
+ __u16 abi_class; /* 0x00-0x01 */
+ __u8 abi_ver_major; /* 0x02 */
+ __u8 abi_ver_minor; /* 0x03 */
+ __u32 bus_specific; /* 0x04-0x07 */
struct sdb_component sdb_component; /* 0x08-0x3f */
};

@@ -89,7 +85,7 @@ struct sdb_device {
* child is the address of the nested SDB table
*/
struct sdb_bridge {
- uint64_t sdb_child; /* 0x00-0x07 */
+ __u64 sdb_child; /* 0x00-0x07 */
struct sdb_component sdb_component; /* 0x08-0x3f */
};

@@ -100,7 +96,7 @@ struct sdb_bridge {
* just provide product information for an aggregate device
*/
struct sdb_integration {
- uint8_t reserved[24]; /* 0x00-0x17 */
+ __u8 reserved[24]; /* 0x00-0x17 */
struct sdb_product product; /* 0x08-0x3f */
};

@@ -109,8 +105,8 @@ struct sdb_integration {
* again, an informative field that software can ignore
*/
struct sdb_repo_url {
- uint8_t repo_url[63]; /* 0x00-0x3e */
- uint8_t record_type; /* 0x3f */
+ __u8 repo_url[63]; /* 0x00-0x3e */
+ __u8 record_type; /* 0x3f */
};

/* Type 0x82: Synthesis tool information
@@ -118,13 +114,13 @@ struct sdb_repo_url {
* this informative record
*/
struct sdb_synthesis {
- uint8_t syn_name[16]; /* 0x00-0x0f */
- uint8_t commit_id[16]; /* 0x10-0x1f */
- uint8_t tool_name[8]; /* 0x20-0x27 */
- uint32_t tool_version; /* 0x28-0x2b */
- uint32_t date; /* 0x2c-0x2f */
- uint8_t user_name[15]; /* 0x30-0x3e */
- uint8_t record_type; /* 0x3f */
+ __u8 syn_name[16]; /* 0x00-0x0f */
+ __u8 commit_id[16]; /* 0x10-0x1f */
+ __u8 tool_name[8]; /* 0x20-0x27 */
+ __u32 tool_version; /* 0x28-0x2b */
+ __u32 date; /* 0x2c-0x2f */
+ __u8 user_name[15]; /* 0x30-0x3e */
+ __u8 record_type; /* 0x3f */
};

/* Type 0xff: empty
@@ -135,8 +131,8 @@ struct sdb_synthesis {
* It can also be used to pad a table to a desired length.
*/
struct sdb_empty {
- uint8_t reserved[63]; /* 0x00-0x3e */
- uint8_t record_type; /* 0x3f */
+ __u8 reserved[63]; /* 0x00-0x3e */
+ __u8 record_type; /* 0x3f */
};

/* The type of bus, for bus-specific flags */
--
2.8.1
Mikko Rapeli
2016-08-22 19:20:02 UTC
Permalink
Fixes uapi header compilation error from userspace on ARCH=arm:

asm/signal.h:112:2: error: unknown type name ‘size_t’
size_t ss_size;

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
arch/arm/include/uapi/asm/signal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/uapi/asm/signal.h b/arch/arm/include/uapi/asm/signal.h
index 33073bd..859f2de 100644
--- a/arch/arm/include/uapi/asm/signal.h
+++ b/arch/arm/include/uapi/asm/signal.h
@@ -113,7 +113,7 @@ struct sigaction {
typedef struct sigaltstack {
void __user *ss_sp;
int ss_flags;
- size_t ss_size;
+ __kernel_size_t ss_size;
} stack_t;
--
2.8.1
Mikko Rapeli
2016-08-22 19:20:02 UTC
Permalink
xen/interface/xen.h is not exported from kernel headers so remove the
dependency and provide needed defines for domid_t and xen_pfn_t if they
are not already defined by some other e.g. Xen specific headers.

Suggested by Andrew Cooper <***@citrix.com> on lkml message
<***@citrix.com>.

The ifdef for ARM is ugly but did not find better solutions for it.

Fixes userspace compilation error:

xen/privcmd.h:38:31: fatal error: xen/interface/xen.h: No such file or directory

Signed-off-by: Mikko Rapeli <***@iki.fi>
Cc: David Vrabel <***@citrix.com>
---
arch/arm/include/asm/xen/interface.h | 2 +-
include/uapi/xen/privcmd.h | 12 +++++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/xen/interface.h b/arch/arm/include/asm/xen/interface.h
index 75d5968..6898ee1 100644
--- a/arch/arm/include/asm/xen/interface.h
+++ b/arch/arm/include/asm/xen/interface.h
@@ -38,7 +38,7 @@
* fine since it simply wouldn't be able to create any sure pfns in
* the first place.
*/
-typedef uint64_t xen_pfn_t;
+typedef __u64 xen_pfn_t;
#define PRI_xen_pfn "llx"
typedef uint64_t xen_ulong_t;
#define PRI_xen_ulong "llx"
diff --git a/include/uapi/xen/privcmd.h b/include/uapi/xen/privcmd.h
index 7ddeeda..16c11f9 100644
--- a/include/uapi/xen/privcmd.h
+++ b/include/uapi/xen/privcmd.h
@@ -35,7 +35,17 @@

#include <linux/types.h>
#include <linux/compiler.h>
-#include <xen/interface/xen.h>
+
+/* Defined by include/xen/interface/xen.h, but it is not part of Linux uapi */
+#ifndef __XEN_PUBLIC_XEN_H__
+typedef __u16 domid_t;
+
+#if (defined __ARMEL__ || defined __ARMEB__)
+typedef __u64 xen_pfn_t;
+#else
+typedef unsigned long xen_pfn_t;
+#endif /* (defined __ARMEL__ || defined __ARMEB__) */
+#endif /* __XEN_PUBLIC_XEN_H__ */

struct privcmd_hypercall {
__u64 op;
--
2.8.1
Mikko Rapeli
2016-08-22 19:30:01 UTC
Permalink
Fixes userspace compile errors like:

error: field ‘rtmsg_dst’ has incomplete type
struct in6_addr rtmsg_dst;

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/ipv6_route.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/ipv6_route.h b/include/uapi/linux/ipv6_route.h
index f6598d1..25ab362 100644
--- a/include/uapi/linux/ipv6_route.h
+++ b/include/uapi/linux/ipv6_route.h
@@ -14,6 +14,7 @@
#define _UAPI_LINUX_IPV6_ROUTE_H

#include <linux/types.h>
+#include <linux/in6.h>

#define RTF_DEFAULT 0x00010000 /* default - learned via ND */
#define RTF_ALLONLINK 0x00020000 /* (deprecated and will be removed)
--
2.8.1
Mikko Rapeli
2016-08-22 19:30:01 UTC
Permalink
It has definition of domid_t. Fixes userspace compiler error when
xen/privcmd.h is compiled alone:

xen/evtchn.h:100:2: error: unknown type name ‘domid_t’
domid_t domid;
^~~~~~~

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/xen/evtchn.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/uapi/xen/evtchn.h b/include/uapi/xen/evtchn.h
index cb4aa4b..81df4b3 100644
--- a/include/uapi/xen/evtchn.h
+++ b/include/uapi/xen/evtchn.h
@@ -33,6 +33,8 @@
#ifndef __LINUX_PUBLIC_EVTCHN_H__
#define __LINUX_PUBLIC_EVTCHN_H__

+#include <xen/privcmd.h>
+
/*
* Bind a fresh port to VIRQ @virq.
* Return allocated port.
--
2.8.1
Mikko Rapeli
2016-08-22 19:30:01 UTC
Permalink
Based on git commit messages and the #error macro messages it should not be
used in userspace. Fixes userspace compile errors:

sound/asoc.h:21:2: error: #error This API is an early revision and not enabled
in the current
#error This API is an early revision and not enabled in the current
^~~~~
sound/asoc.h:22:2: error: #error kernel release, it will be enabled in a futur
e kernel version
#error kernel release, it will be enabled in a future kernel version
^~~~~
sound/asoc.h:23:2: error: #error with incompatible changes to what is here.
#error with incompatible changes to what is here.
^~~~~

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/sound/Kbuild | 1 -
1 file changed, 1 deletion(-)

diff --git a/include/uapi/sound/Kbuild b/include/uapi/sound/Kbuild
index 691984c..6d8b203 100644
--- a/include/uapi/sound/Kbuild
+++ b/include/uapi/sound/Kbuild
@@ -1,6 +1,5 @@
# UAPI Header export list
header-y += asequencer.h
-header-y += asoc.h
header-y += asound.h
header-y += asound_fm.h
header-y += compress_offload.h
--
2.8.1
Mikko Rapeli
2016-08-22 19:30:01 UTC
Permalink
Fixes these userspace compile error when glibc netax25/ax25.h is included
before linux/ax25.h:

linux/ax25.h:28:0: warning: "SIOCAX25GETUID" redefined
linux/ax25.h:38:0: warning: "SIOCAX25GETINFO" redefined
linux/ax25.h:47:3: error: conflicting types for ‘ax25_address’
linux/ax25.h:49:8: error: redefinition of ‘struct sockaddr_ax25’
linux/ax25.h:58:8: error: redefinition of ‘struct full_sockaddr_ax25’
linux/ax25.h:63:8: error: redefinition of ‘struct ax25_routes_struct’
linux/ax25.h:70:8: error: redefinition of ‘struct ax25_route_opt_struct’
linux/ax25.h:77:8: error: redefinition of ‘struct ax25_ctl_struct’
linux/ax25.h:98:8: error: redefinition of ‘struct ax25_info_struct’
linux/ax25.h:111:8: error: redefinition of ‘struct ax25_fwd_struct’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/ax25.h | 22 +++++++++++++++++++++
include/uapi/linux/libc-compat.h | 41 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)

diff --git a/include/uapi/linux/ax25.h b/include/uapi/linux/ax25.h
index 74c89a4..e296c8a 100644
--- a/include/uapi/linux/ax25.h
+++ b/include/uapi/linux/ax25.h
@@ -6,6 +6,7 @@
#ifndef AX25_KERNEL_H
#define AX25_KERNEL_H

+#include <linux/libc-compat.h>
#include <linux/socket.h>

#define AX25_MTU 256
@@ -25,6 +26,7 @@

#define AX25_KILL 99

+#if __UAPI_DEF_SIOCAX25GETUID_TO_SIOCAX25DELFWD
#define SIOCAX25GETUID (SIOCPROTOPRIVATE+0)
#define SIOCAX25ADDUID (SIOCPROTOPRIVATE+1)
#define SIOCAX25DELUID (SIOCPROTOPRIVATE+2)
@@ -34,46 +36,61 @@
#define SIOCAX25GETINFOOLD (SIOCPROTOPRIVATE+9)
#define SIOCAX25ADDFWD (SIOCPROTOPRIVATE+10)
#define SIOCAX25DELFWD (SIOCPROTOPRIVATE+11)
+#endif /* __UAPI_DEF_SIOCAX25GETUID_TO_SIOCAX25DELFWD */
#define SIOCAX25DEVCTL (SIOCPROTOPRIVATE+12)
+/* glibc uses SIOCPROTOPRIVATE+9 for SIOCAX25GETINFO */
+#if __UAPI_DEF_SIOCAX25GETINFO
#define SIOCAX25GETINFO (SIOCPROTOPRIVATE+13)
+#endif /* __UAPI_DEF_SIOCAX25GETINFO */

#define AX25_SET_RT_IPMODE 2

#define AX25_NOUID_DEFAULT 0
#define AX25_NOUID_BLOCK 1

+#if __UAPI_DEF_AX25_ADDRESS
typedef struct {
char ax25_call[7]; /* 6 call + SSID (shifted ascii!) */
} ax25_address;
+#endif /* __UAPI_DEF_AX25_ADDRESS */

+#if __UAPI_DEF_SOCKADDR_AX25
struct sockaddr_ax25 {
__kernel_sa_family_t sax25_family;
ax25_address sax25_call;
int sax25_ndigis;
/* Digipeater ax25_address sets follow */
};
+#endif /* __UAPI_DEF_SOCKADDR_AX25 */

#define sax25_uid sax25_ndigis

+#if __UAPI_DEF_FULL_SOCKADDR_AX25
struct full_sockaddr_ax25 {
struct sockaddr_ax25 fsa_ax25;
ax25_address fsa_digipeater[AX25_MAX_DIGIS];
};
+#endif /* __UAPI_DEF_FULL_SOCKADDR_AX25 */

+#if __UAPI_DEF_AX25_ROUTES_STRUCT
struct ax25_routes_struct {
ax25_address port_addr;
ax25_address dest_addr;
unsigned char digi_count;
ax25_address digi_addr[AX25_MAX_DIGIS];
};
+#endif /* __UAPI_DEF_AX25_ROUTES_STRUCT */

+#if __UAPI_DEF_AX25_ROUTES_OPT_STRUCT
struct ax25_route_opt_struct {
ax25_address port_addr;
ax25_address dest_addr;
int cmd;
int arg;
};
+#endif /* __UAPI_DEF_AX25_ROUTES_OPT_STRUCT */

+#if __UAPI_DEF_AX25_CTL_STRUCT
struct ax25_ctl_struct {
ax25_address port_addr;
ax25_address source_addr;
@@ -83,6 +100,7 @@ struct ax25_ctl_struct {
unsigned char digi_count;
ax25_address digi_addr[AX25_MAX_DIGIS];
};
+#endif /* __UAPI_DEF_AX25_CTL_STRUCT */

/* this will go away. Please do not export to user land */
struct ax25_info_struct_deprecated {
@@ -95,6 +113,7 @@ struct ax25_info_struct_deprecated {
unsigned int rcv_q, snd_q;
};

+#if __UAPI_DEF_AX25_INFO_STRUCT
struct ax25_info_struct {
unsigned int n2, n2count;
unsigned int t1, t1timer;
@@ -107,10 +126,13 @@ struct ax25_info_struct {
unsigned int paclen;
unsigned int window;
};
+#endif /* __UAPI_DEF_AX25_INFO_STRUCT */

+#if __UAPI_DEF_AX25_FWD_STRUCT
struct ax25_fwd_struct {
ax25_address port_from;
ax25_address port_to;
};
+#endif /* __UAPI_DEF_AX25_FWD_STRUCT */

#endif
diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index f793b09..01bb521 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -100,6 +100,35 @@

#endif /* _NET_IF_H */

+/* Coordinate with glibc netax25/ax25.h header. */
+#if defined(_NETAX25_AX25_H)
+
+#define __UAPI_DEF_SIOCAX25GETUID_TO_SIOCAX25DELFWD 0
+#define __UAPI_DEF_SIOCAX25GETINFO 0
+#define __UAPI_DEF_AX25_ADDRESS 0
+#define __UAPI_DEF_SOCKADDR_AX25 0
+#define __UAPI_DEF_FULL_SOCKADDR_AX25 0
+#define __UAPI_DEF_AX25_ROUTES_STRUCT 0
+#define __UAPI_DEF_AX25_ROUTES_OPT_STRUCT 0
+#define __UAPI_DEF_AX25_CTL_STRUCT 0
+#define __UAPI_DEF_AX25_INFO_STRUCT 0
+#define __UAPI_DEF_AX25_FWD_STRUCT 0
+
+#else /* defined(_NETAX25_AX25_H) */
+
+#define __UAPI_DEF_SIOCAX25GETUID_TO_SIOCAX25DELFWD 1
+#define __UAPI_DEF_SIOCAX25GETINFO 1
+#define __UAPI_DEF_AX25_ADDRESS 1
+#define __UAPI_DEF_SOCKADDR_AX25 1
+#define __UAPI_DEF_FULL_SOCKADDR_AX25 1
+#define __UAPI_DEF_AX25_ROUTES_STRUCT 1
+#define __UAPI_DEF_AX25_ROUTES_OPT_STRUCT 1
+#define __UAPI_DEF_AX25_CTL_STRUCT 1
+#define __UAPI_DEF_AX25_INFO_STRUCT 1
+#define __UAPI_DEF_AX25_FWD_STRUCT 1
+
+#endif /* defined(_NETAX25_AX25_H) */
+
/* Coordinate with glibc netinet/in.h header. */
#if defined(_NETINET_IN_H)

@@ -204,6 +233,18 @@
#define __UAPI_DEF_F_DUPFD_CLOEXEC 1
#define __UAPI_DEF_O_ACCMODE_RDONLY_WRONLY_RDWR 1

+/* Definitions for ax25.h */
+#define __UAPI_DEF_SIOCAX25GETUID_TO_SIOCAX25DELFWD 1
+#define __UAPI_DEF_SIOCAX25GETINFO 1
+#define __UAPI_DEF_AX25_ADDRESS 1
+#define __UAPI_DEF_SOCKADDR_AX25 1
+#define __UAPI_DEF_FULL_SOCKADDR_AX25 1
+#define __UAPI_DEF_AX25_ROUTES_STRUCT 1
+#define __UAPI_DEF_AX25_ROUTES_OPT_STRUCT 1
+#define __UAPI_DEF_AX25_CTL_STRUCT 1
+#define __UAPI_DEF_AX25_INFO_STRUCT 1
+#define __UAPI_DEF_AX25_FWD_STRUCT 1
+
/* Definitions for if.h */
#define __UAPI_DEF_IF_IFCONF 1
#define __UAPI_DEF_IF_IFMAP 1
--
2.8.1
David Miller
2016-08-22 23:40:02 UTC
Permalink
Must be CC:'d to netdev.
Mikko Rapeli
2016-08-22 19:30:02 UTC
Permalink
Fixes these compiler warnings via libc-compat.h when glibc netipx/ipx.h is
included before linux/ipx.h:

./linux/ipx.h:9:8: error: redefinition of ‘struct sockaddr_ipx’
./linux/ipx.h:26:8: error: redefinition of ‘struct ipx_route_definition’
./linux/ipx.h:32:8: error: redefinition of ‘struct ipx_interface_definition’
./linux/ipx.h:49:8: error: redefinition of ‘struct ipx_config_data’
./linux/ipx.h:58:8: error: redefinition of ‘struct ipx_route_def’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/ipx.h | 13 ++++++++++++-
include/uapi/linux/libc-compat.h | 26 ++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/ipx.h b/include/uapi/linux/ipx.h
index 3d48014..30f031d 100644
--- a/include/uapi/linux/ipx.h
+++ b/include/uapi/linux/ipx.h
@@ -1,11 +1,13 @@
#ifndef _IPX_H_
#define _IPX_H_
+#include <linux/libc-compat.h> /* for compatibility with glibc netipx/ipx.h */
#include <linux/types.h>
#include <linux/sockios.h>
#include <linux/socket.h>
#define IPX_NODE_LEN 6
#define IPX_MTU 576

+#if __UAPI_DEF_SOCKADDR_IPX
struct sockaddr_ipx {
__kernel_sa_family_t sipx_family;
__be16 sipx_port;
@@ -14,6 +16,7 @@ struct sockaddr_ipx {
__u8 sipx_type;
unsigned char sipx_zero; /* 16 byte fill */
};
+#endif /* __UAPI_DEF_SOCKADDR_IPX */

/*
* So we can fit the extra info for SIOCSIFADDR into the address nicely
@@ -23,12 +26,15 @@ struct sockaddr_ipx {
#define IPX_DLTITF 0
#define IPX_CRTITF 1

+#if __UAPI_DEF_IPX_ROUTE_DEFINITION
struct ipx_route_definition {
__be32 ipx_network;
__be32 ipx_router_network;
unsigned char ipx_router_node[IPX_NODE_LEN];
};
+#endif /* __UAPI_DEF_IPX_ROUTE_DEFINITION */

+#if __UAPI_DEF_IPX_INTERFACE_DEFINITION
struct ipx_interface_definition {
__be32 ipx_network;
unsigned char ipx_device[16];
@@ -45,16 +51,20 @@ struct ipx_interface_definition {
#define IPX_INTERNAL 2
unsigned char ipx_node[IPX_NODE_LEN];
};
-
+#endif /* __UAPI_DEF_IPX_INTERFACE_DEFINITION */
+
+#if __UAPI_DEF_IPX_CONFIG_DATA
struct ipx_config_data {
unsigned char ipxcfg_auto_select_primary;
unsigned char ipxcfg_auto_create_interfaces;
};
+#endif /* __UAPI_DEF_IPX_CONFIG_DATA */

/*
* OLD Route Definition for backward compatibility.
*/

+#if __UAPI_DEF_IPX_ROUTE_DEF
struct ipx_route_def {
__be32 ipx_network;
__be32 ipx_router_network;
@@ -67,6 +77,7 @@ struct ipx_route_def {
#define IPX_RT_BLUEBOOK 2
#define IPX_RT_ROUTED 1
};
+#endif /* __UAPI_DEF_IPX_ROUTE_DEF */

#define SIOCAIPXITFCRT (SIOCPROTOPRIVATE)
#define SIOCAIPXPRISLT (SIOCPROTOPRIVATE + 1)
diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index e4f048e..44b8a6b 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -139,6 +139,25 @@

#endif /* _NETINET_IN_H */

+/* Coordinate with glibc netipx/ipx.h header. */
+#if defined(__NETIPX_IPX_H)
+
+#define __UAPI_DEF_SOCKADDR_IPX 0
+#define __UAPI_DEF_IPX_ROUTE_DEFINITION 0
+#define __UAPI_DEF_IPX_INTERFACE_DEFINITION 0
+#define __UAPI_DEF_IPX_CONFIG_DATA 0
+#define __UAPI_DEF_IPX_ROUTE_DEF 0
+
+#else /* defined(__NETIPX_IPX_H) */
+
+#define __UAPI_DEF_SOCKADDR_IPX 1
+#define __UAPI_DEF_IPX_ROUTE_DEFINITION 1
+#define __UAPI_DEF_IPX_INTERFACE_DEFINITION 1
+#define __UAPI_DEF_IPX_CONFIG_DATA 1
+#define __UAPI_DEF_IPX_ROUTE_DEF 1
+
+#endif /* defined(__NETIPX_IPX_H) */
+
/* Definitions for xattr.h */
#if defined(_SYS_XATTR_H)
#define __UAPI_DEF_XATTR 0
@@ -179,6 +198,13 @@
#define __UAPI_DEF_IN6_PKTINFO 1
#define __UAPI_DEF_IP6_MTUINFO 1

+/* Definitions for ipx.h */
+#define __UAPI_DEF_SOCKADDR_IPX 1
+#define __UAPI_DEF_IPX_ROUTE_DEFINITION 1
+#define __UAPI_DEF_IPX_INTERFACE_DEFINITION 1
+#define __UAPI_DEF_IPX_CONFIG_DATA 1
+#define __UAPI_DEF_IPX_ROUTE_DEF 1
+
/* Definitions for xattr.h */
#define __UAPI_DEF_XATTR 1
--
2.8.1
David Miller
2016-08-22 23:40:03 UTC
Permalink
From: Mikko Rapeli <***@iki.fi>
Date: Mon, 22 Aug 2016 20:33:21 +0200
Post by Mikko Rapeli
Fixes these compiler warnings via libc-compat.h when glibc netipx/ipx.h is
./linux/ipx.h:9:8: error: redefinition of ‘struct sockaddr_ipx’
./linux/ipx.h:26:8: error: redefinition of ‘struct ipx_route_definition’
./linux/ipx.h:32:8: error: redefinition of ‘struct ipx_interface_definition’
./linux/ipx.h:49:8: error: redefinition of ‘struct ipx_config_data’
./linux/ipx.h:58:8: error: redefinition of ‘struct ipx_route_def’
Applied.
Mikko Rapeli
2016-08-22 19:30:02 UTC
Permalink
Kernel headers should not use stdint.h.

Signed-off-by: Mikko Rapeli <***@iki.fi>
Cc: Arnd Bergmann <***@arndb.de>
Cc: Miklos Szeredi <***@szeredi.hu>
---
include/uapi/linux/fuse.h | 452 +++++++++++++++++++++++-----------------------
1 file changed, 224 insertions(+), 228 deletions(-)

diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
index 27e1736..f9eadc7 100644
--- a/include/uapi/linux/fuse.h
+++ b/include/uapi/linux/fuse.h
@@ -113,11 +113,7 @@
#ifndef _LINUX_FUSE_H
#define _LINUX_FUSE_H

-#ifdef __KERNEL__
#include <linux/types.h>
-#else
-#include <stdint.h>
-#endif

/*
* Version negotiation:
@@ -152,42 +148,42 @@
userspace works under 64bit kernels */

struct fuse_attr {
- uint64_t ino;
- uint64_t size;
- uint64_t blocks;
- uint64_t atime;
- uint64_t mtime;
- uint64_t ctime;
- uint32_t atimensec;
- uint32_t mtimensec;
- uint32_t ctimensec;
- uint32_t mode;
- uint32_t nlink;
- uint32_t uid;
- uint32_t gid;
- uint32_t rdev;
- uint32_t blksize;
- uint32_t padding;
+ __u64 ino;
+ __u64 size;
+ __u64 blocks;
+ __u64 atime;
+ __u64 mtime;
+ __u64 ctime;
+ __u32 atimensec;
+ __u32 mtimensec;
+ __u32 ctimensec;
+ __u32 mode;
+ __u32 nlink;
+ __u32 uid;
+ __u32 gid;
+ __u32 rdev;
+ __u32 blksize;
+ __u32 padding;
};

struct fuse_kstatfs {
- uint64_t blocks;
- uint64_t bfree;
- uint64_t bavail;
- uint64_t files;
- uint64_t ffree;
- uint32_t bsize;
- uint32_t namelen;
- uint32_t frsize;
- uint32_t padding;
- uint32_t spare[6];
+ __u64 blocks;
+ __u64 bfree;
+ __u64 bavail;
+ __u64 files;
+ __u64 ffree;
+ __u32 bsize;
+ __u32 namelen;
+ __u32 frsize;
+ __u32 padding;
+ __u32 spare[6];
};

struct fuse_file_lock {
- uint64_t start;
- uint64_t end;
- uint32_t type;
- uint32_t pid; /* tgid */
+ __u64 start;
+ __u64 end;
+ __u32 type;
+ __u32 pid; /* tgid */
};

/**
@@ -388,149 +384,149 @@ enum fuse_notify_code {
#define FUSE_COMPAT_ENTRY_OUT_SIZE 120

struct fuse_entry_out {
- uint64_t nodeid; /* Inode ID */
- uint64_t generation; /* Inode generation: nodeid:gen must
+ __u64 nodeid; /* Inode ID */
+ __u64 generation; /* Inode generation: nodeid:gen must
be unique for the fs's lifetime */
- uint64_t entry_valid; /* Cache timeout for the name */
- uint64_t attr_valid; /* Cache timeout for the attributes */
- uint32_t entry_valid_nsec;
- uint32_t attr_valid_nsec;
+ __u64 entry_valid; /* Cache timeout for the name */
+ __u64 attr_valid; /* Cache timeout for the attributes */
+ __u32 entry_valid_nsec;
+ __u32 attr_valid_nsec;
struct fuse_attr attr;
};

struct fuse_forget_in {
- uint64_t nlookup;
+ __u64 nlookup;
};

struct fuse_forget_one {
- uint64_t nodeid;
- uint64_t nlookup;
+ __u64 nodeid;
+ __u64 nlookup;
};

struct fuse_batch_forget_in {
- uint32_t count;
- uint32_t dummy;
+ __u32 count;
+ __u32 dummy;
};

struct fuse_getattr_in {
- uint32_t getattr_flags;
- uint32_t dummy;
- uint64_t fh;
+ __u32 getattr_flags;
+ __u32 dummy;
+ __u64 fh;
};

#define FUSE_COMPAT_ATTR_OUT_SIZE 96

struct fuse_attr_out {
- uint64_t attr_valid; /* Cache timeout for the attributes */
- uint32_t attr_valid_nsec;
- uint32_t dummy;
+ __u64 attr_valid; /* Cache timeout for the attributes */
+ __u32 attr_valid_nsec;
+ __u32 dummy;
struct fuse_attr attr;
};

#define FUSE_COMPAT_MKNOD_IN_SIZE 8

struct fuse_mknod_in {
- uint32_t mode;
- uint32_t rdev;
- uint32_t umask;
- uint32_t padding;
+ __u32 mode;
+ __u32 rdev;
+ __u32 umask;
+ __u32 padding;
};

struct fuse_mkdir_in {
- uint32_t mode;
- uint32_t umask;
+ __u32 mode;
+ __u32 umask;
};

struct fuse_rename_in {
- uint64_t newdir;
+ __u64 newdir;
};

struct fuse_rename2_in {
- uint64_t newdir;
- uint32_t flags;
- uint32_t padding;
+ __u64 newdir;
+ __u32 flags;
+ __u32 padding;
};

struct fuse_link_in {
- uint64_t oldnodeid;
+ __u64 oldnodeid;
};

struct fuse_setattr_in {
- uint32_t valid;
- uint32_t padding;
- uint64_t fh;
- uint64_t size;
- uint64_t lock_owner;
- uint64_t atime;
- uint64_t mtime;
- uint64_t ctime;
- uint32_t atimensec;
- uint32_t mtimensec;
- uint32_t ctimensec;
- uint32_t mode;
- uint32_t unused4;
- uint32_t uid;
- uint32_t gid;
- uint32_t unused5;
+ __u32 valid;
+ __u32 padding;
+ __u64 fh;
+ __u64 size;
+ __u64 lock_owner;
+ __u64 atime;
+ __u64 mtime;
+ __u64 ctime;
+ __u32 atimensec;
+ __u32 mtimensec;
+ __u32 ctimensec;
+ __u32 mode;
+ __u32 unused4;
+ __u32 uid;
+ __u32 gid;
+ __u32 unused5;
};

struct fuse_open_in {
- uint32_t flags;
- uint32_t unused;
+ __u32 flags;
+ __u32 unused;
};

struct fuse_create_in {
- uint32_t flags;
- uint32_t mode;
- uint32_t umask;
- uint32_t padding;
+ __u32 flags;
+ __u32 mode;
+ __u32 umask;
+ __u32 padding;
};

struct fuse_open_out {
- uint64_t fh;
- uint32_t open_flags;
- uint32_t padding;
+ __u64 fh;
+ __u32 open_flags;
+ __u32 padding;
};

struct fuse_release_in {
- uint64_t fh;
- uint32_t flags;
- uint32_t release_flags;
- uint64_t lock_owner;
+ __u64 fh;
+ __u32 flags;
+ __u32 release_flags;
+ __u64 lock_owner;
};

struct fuse_flush_in {
- uint64_t fh;
- uint32_t unused;
- uint32_t padding;
- uint64_t lock_owner;
+ __u64 fh;
+ __u32 unused;
+ __u32 padding;
+ __u64 lock_owner;
};

struct fuse_read_in {
- uint64_t fh;
- uint64_t offset;
- uint32_t size;
- uint32_t read_flags;
- uint64_t lock_owner;
- uint32_t flags;
- uint32_t padding;
+ __u64 fh;
+ __u64 offset;
+ __u32 size;
+ __u32 read_flags;
+ __u64 lock_owner;
+ __u32 flags;
+ __u32 padding;
};

#define FUSE_COMPAT_WRITE_IN_SIZE 24

struct fuse_write_in {
- uint64_t fh;
- uint64_t offset;
- uint32_t size;
- uint32_t write_flags;
- uint64_t lock_owner;
- uint32_t flags;
- uint32_t padding;
+ __u64 fh;
+ __u64 offset;
+ __u32 size;
+ __u32 write_flags;
+ __u64 lock_owner;
+ __u32 flags;
+ __u32 padding;
};

struct fuse_write_out {
- uint32_t size;
- uint32_t padding;
+ __u32 size;
+ __u32 padding;
};

#define FUSE_COMPAT_STATFS_SIZE 48
@@ -540,32 +536,32 @@ struct fuse_statfs_out {
};

struct fuse_fsync_in {
- uint64_t fh;
- uint32_t fsync_flags;
- uint32_t padding;
+ __u64 fh;
+ __u32 fsync_flags;
+ __u32 padding;
};

struct fuse_setxattr_in {
- uint32_t size;
- uint32_t flags;
+ __u32 size;
+ __u32 flags;
};

struct fuse_getxattr_in {
- uint32_t size;
- uint32_t padding;
+ __u32 size;
+ __u32 padding;
};

struct fuse_getxattr_out {
- uint32_t size;
- uint32_t padding;
+ __u32 size;
+ __u32 padding;
};

struct fuse_lk_in {
- uint64_t fh;
- uint64_t owner;
+ __u64 fh;
+ __u64 owner;
struct fuse_file_lock lk;
- uint32_t lk_flags;
- uint32_t padding;
+ __u32 lk_flags;
+ __u32 padding;
};

struct fuse_lk_out {
@@ -573,140 +569,140 @@ struct fuse_lk_out {
};

struct fuse_access_in {
- uint32_t mask;
- uint32_t padding;
+ __u32 mask;
+ __u32 padding;
};

struct fuse_init_in {
- uint32_t major;
- uint32_t minor;
- uint32_t max_readahead;
- uint32_t flags;
+ __u32 major;
+ __u32 minor;
+ __u32 max_readahead;
+ __u32 flags;
};

#define FUSE_COMPAT_INIT_OUT_SIZE 8
#define FUSE_COMPAT_22_INIT_OUT_SIZE 24

struct fuse_init_out {
- uint32_t major;
- uint32_t minor;
- uint32_t max_readahead;
- uint32_t flags;
- uint16_t max_background;
- uint16_t congestion_threshold;
- uint32_t max_write;
- uint32_t time_gran;
- uint32_t unused[9];
+ __u32 major;
+ __u32 minor;
+ __u32 max_readahead;
+ __u32 flags;
+ __u16 max_background;
+ __u16 congestion_threshold;
+ __u32 max_write;
+ __u32 time_gran;
+ __u32 unused[9];
};

#define CUSE_INIT_INFO_MAX 4096

struct cuse_init_in {
- uint32_t major;
- uint32_t minor;
- uint32_t unused;
- uint32_t flags;
+ __u32 major;
+ __u32 minor;
+ __u32 unused;
+ __u32 flags;
};

struct cuse_init_out {
- uint32_t major;
- uint32_t minor;
- uint32_t unused;
- uint32_t flags;
- uint32_t max_read;
- uint32_t max_write;
- uint32_t dev_major; /* chardev major */
- uint32_t dev_minor; /* chardev minor */
- uint32_t spare[10];
+ __u32 major;
+ __u32 minor;
+ __u32 unused;
+ __u32 flags;
+ __u32 max_read;
+ __u32 max_write;
+ __u32 dev_major; /* chardev major */
+ __u32 dev_minor; /* chardev minor */
+ __u32 spare[10];
};

struct fuse_interrupt_in {
- uint64_t unique;
+ __u64 unique;
};

struct fuse_bmap_in {
- uint64_t block;
- uint32_t blocksize;
- uint32_t padding;
+ __u64 block;
+ __u32 blocksize;
+ __u32 padding;
};

struct fuse_bmap_out {
- uint64_t block;
+ __u64 block;
};

struct fuse_ioctl_in {
- uint64_t fh;
- uint32_t flags;
- uint32_t cmd;
- uint64_t arg;
- uint32_t in_size;
- uint32_t out_size;
+ __u64 fh;
+ __u32 flags;
+ __u32 cmd;
+ __u64 arg;
+ __u32 in_size;
+ __u32 out_size;
};

struct fuse_ioctl_iovec {
- uint64_t base;
- uint64_t len;
+ __u64 base;
+ __u64 len;
};

struct fuse_ioctl_out {
- int32_t result;
- uint32_t flags;
- uint32_t in_iovs;
- uint32_t out_iovs;
+ __s32 result;
+ __u32 flags;
+ __u32 in_iovs;
+ __u32 out_iovs;
};

struct fuse_poll_in {
- uint64_t fh;
- uint64_t kh;
- uint32_t flags;
- uint32_t events;
+ __u64 fh;
+ __u64 kh;
+ __u32 flags;
+ __u32 events;
};

struct fuse_poll_out {
- uint32_t revents;
- uint32_t padding;
+ __u32 revents;
+ __u32 padding;
};

struct fuse_notify_poll_wakeup_out {
- uint64_t kh;
+ __u64 kh;
};

struct fuse_fallocate_in {
- uint64_t fh;
- uint64_t offset;
- uint64_t length;
- uint32_t mode;
- uint32_t padding;
+ __u64 fh;
+ __u64 offset;
+ __u64 length;
+ __u32 mode;
+ __u32 padding;
};

struct fuse_in_header {
- uint32_t len;
- uint32_t opcode;
- uint64_t unique;
- uint64_t nodeid;
- uint32_t uid;
- uint32_t gid;
- uint32_t pid;
- uint32_t padding;
+ __u32 len;
+ __u32 opcode;
+ __u64 unique;
+ __u64 nodeid;
+ __u32 uid;
+ __u32 gid;
+ __u32 pid;
+ __u32 padding;
};

struct fuse_out_header {
- uint32_t len;
- int32_t error;
- uint64_t unique;
+ __u32 len;
+ __s32 error;
+ __u64 unique;
};

struct fuse_dirent {
- uint64_t ino;
- uint64_t off;
- uint32_t namelen;
- uint32_t type;
+ __u64 ino;
+ __u64 off;
+ __u32 namelen;
+ __u32 type;
char name[];
};

#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
#define FUSE_DIRENT_ALIGN(x) \
- (((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1))
+ (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
#define FUSE_DIRENT_SIZE(d) \
FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)

@@ -721,61 +717,61 @@ struct fuse_direntplus {
FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET_DIRENTPLUS + (d)->dirent.namelen)

struct fuse_notify_inval_inode_out {
- uint64_t ino;
- int64_t off;
- int64_t len;
+ __u64 ino;
+ __s64 off;
+ __s64 len;
};

struct fuse_notify_inval_entry_out {
- uint64_t parent;
- uint32_t namelen;
- uint32_t padding;
+ __u64 parent;
+ __u32 namelen;
+ __u32 padding;
};

struct fuse_notify_delete_out {
- uint64_t parent;
- uint64_t child;
- uint32_t namelen;
- uint32_t padding;
+ __u64 parent;
+ __u64 child;
+ __u32 namelen;
+ __u32 padding;
};

struct fuse_notify_store_out {
- uint64_t nodeid;
- uint64_t offset;
- uint32_t size;
- uint32_t padding;
+ __u64 nodeid;
+ __u64 offset;
+ __u32 size;
+ __u32 padding;
};

struct fuse_notify_retrieve_out {
- uint64_t notify_unique;
- uint64_t nodeid;
- uint64_t offset;
- uint32_t size;
- uint32_t padding;
+ __u64 notify_unique;
+ __u64 nodeid;
+ __u64 offset;
+ __u32 size;
+ __u32 padding;
};

/* Matches the size of fuse_write_in */
struct fuse_notify_retrieve_in {
- uint64_t dummy1;
- uint64_t offset;
- uint32_t size;
- uint32_t dummy2;
- uint64_t dummy3;
- uint64_t dummy4;
+ __u64 dummy1;
+ __u64 offset;
+ __u32 size;
+ __u32 dummy2;
+ __u64 dummy3;
+ __u64 dummy4;
};

/* Device ioctls: */
-#define FUSE_DEV_IOC_CLONE _IOR(229, 0, uint32_t)
+#define FUSE_DEV_IOC_CLONE _IOR(229, 0, __u32)

struct fuse_lseek_in {
- uint64_t fh;
- uint64_t offset;
- uint32_t whence;
- uint32_t padding;
+ __u64 fh;
+ __u64 offset;
+ __u32 whence;
+ __u32 padding;
};

struct fuse_lseek_out {
- uint64_t offset;
+ __u64 offset;
};

#endif /* _LINUX_FUSE_H */
--
2.8.1
Mikko Rapeli
2016-08-22 19:30:02 UTC
Permalink
Remove typedef elf_greg_t greg_t and friends from userspace.
Remove struct elf_prstatus completely from userspace.

elfcore.h as such does not compile in userspace. All userspace users
of <linux/elfcore.h> like gcc/gdb and linux-tools contain their own modified
versions of the file. With these changes the file compiles but is generally
not usable for things like core dump parsing but luckily userspace users
already know this and have their own modified version of the needed
definitions and headers. But at least this compiles now.

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/elfcore.h | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/include/uapi/linux/elfcore.h b/include/uapi/linux/elfcore.h
index 569737c..6c23066 100644
--- a/include/uapi/linux/elfcore.h
+++ b/include/uapi/linux/elfcore.h
@@ -15,15 +15,7 @@ struct elf_siginfo
int si_errno; /* errno */
};

-
-#ifndef __KERNEL__
-typedef elf_greg_t greg_t;
-typedef elf_gregset_t gregset_t;
-typedef elf_fpregset_t fpregset_t;
-typedef elf_fpxregset_t fpxregset_t;
-#define NGREG ELF_NGREG
-#endif
-
+#ifdef __KERNEL__
/*
* Definitions to generate Intel SVR4-like core files.
* These mostly have the same names as the SVR4 types with "elf_"
@@ -48,10 +40,10 @@ struct elf_prstatus
struct sigaltstack pr_altstack; /* Alternate stack info */
struct sigaction pr_action; /* Signal action for current sig */
#endif
- pid_t pr_pid;
- pid_t pr_ppid;
- pid_t pr_pgrp;
- pid_t pr_sid;
+ __kernel_pid_t pr_pid;
+ __kernel_pid_t pr_ppid;
+ __kernel_pid_t pr_pgrp;
+ __kernel_pid_t pr_sid;
struct timeval pr_utime; /* User time */
struct timeval pr_stime; /* System time */
struct timeval pr_cutime; /* Cumulative user time */
@@ -72,6 +64,7 @@ struct elf_prstatus
#endif
int pr_fpvalid; /* True if math co-processor being used. */
};
+#endif /* __KERNEL__ */

#define ELF_PRARGSZ (80) /* Number of chars for args */

@@ -84,7 +77,7 @@ struct elf_prpsinfo
unsigned long pr_flag; /* flags */
__kernel_uid_t pr_uid;
__kernel_gid_t pr_gid;
- pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
+ __kernel_pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
/* Lots missing */
char pr_fname[16]; /* filename of executable */
char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
--
2.8.1
Mikko Rapeli
2016-08-22 19:30:02 UTC
Permalink
Fixes these userspace compile errors and warnings when glibc time.h
is included before linux/time.h:

linux/time.h:9:8: error: redefinition of ‘struct timespec’
linux/time.h:15:8: error: redefinition of ‘struct timeval’
linux/time.h:20:8: error: redefinition of ‘struct timezone’
linux/time.h:30:0: warning: "ITIMER_REAL" redefined
linux/time.h:31:0: warning: "ITIMER_VIRTUAL" redefined
linux/time.h:32:0: warning: "ITIMER_PROF" redefined
linux/time.h:34:8: error: redefinition of ‘struct itimerspec’
linux/time.h:39:8: error: redefinition of ‘struct itimerval’
linux/time.h:67:0: warning: "TIMER_ABSTIME" redefined

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/libc-compat.h | 37 +++++++++++++++++++++++++++++++++++++
include/uapi/linux/time.h | 18 ++++++++++++++++--
2 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index acc2e75..cb25f16 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -230,6 +230,21 @@

#endif /* defined(_NETROSE_ROSE_H) */

+/* Coordinate with glibc time.h */
+#if defined(_TIME_H)
+#define __UAPI_DEF_TIMESPEC 0
+#define __UAPI_DEF_TIMEVAL 0
+#define __UAPI_DEF_ITIMERSPEC 0
+#define __UAPI_DEF_TIMER_ABSTIME 0
+
+#else /* defined(_TIME_H) */
+#define __UAPI_DEF_TIMESPEC 1
+#define __UAPI_DEF_TIMEVAL 1
+#define __UAPI_DEF_ITIMERSPEC 1
+#define __UAPI_DEF_TIMER_ABSTIME 1
+
+#endif /* defined(_TIME_H) */
+
/* Definitions for sys/uio.h */
#if defined(_SYS_UIO_H)
#define __UAPI_DEF_IOVEC 0
@@ -237,6 +252,19 @@
#define __UAPI_DEF_IOVEC 1
#endif /* defined(_SYS_UIO_H) */

+/* Definitions for sys/time.h */
+#if defined(_SYS_TIME_H)
+#define __UAPI_DEF_TIMEZONE 0
+#define __UAPI_DEF_ITIMER_REAL_VIRTUAL_PROF 0
+#define __UAPI_DEF_ITIMERVAL 0
+
+#else /* defined(_SYS_TIME_H) */
+#define __UAPI_DEF_TIMEZONE 1
+#define __UAPI_DEF_ITIMER_REAL_VIRTUAL_PROF 1
+#define __UAPI_DEF_ITIMERVAL 1
+
+#endif /* defined(_SYS_TIME_H) */
+
/* Definitions for xattr.h */
#if defined(_SYS_XATTR_H)
#define __UAPI_DEF_XATTR 0
@@ -313,6 +341,15 @@
#define __UAPI_DEF_ROSE_CAUSE_STRUCT 1
#define __UAPI_DEF_ROSE_FACILITIES_STRUCT 1

+/* Definitions for time.h */
+#define __UAPI_DEF_TIMESPEC 1
+#define __UAPI_DEF_TIMEVAL 1
+#define __UAPI_DEF_TIMEZONE 1
+#define __UAPI_DEF_ITIMER_REAL_VIRTUAL_PROF 1
+#define __UAPI_DEF_ITIMERSPEC 1
+#define __UAPI_DEF_ITIMERVAL 1
+#define __UAPI_DEF_TIMER_ABSTIME 1
+
/* Definitions for uio.h */
#define __UAPI_DEF_IOVEC 1

diff --git a/include/uapi/linux/time.h b/include/uapi/linux/time.h
index e75e1b6..66fb19c 100644
--- a/include/uapi/linux/time.h
+++ b/include/uapi/linux/time.h
@@ -1,45 +1,57 @@
#ifndef _UAPI_LINUX_TIME_H
#define _UAPI_LINUX_TIME_H

+#include <linux/libc-compat.h>
#include <linux/types.h>


#ifndef _STRUCT_TIMESPEC
#define _STRUCT_TIMESPEC
+#if __UAPI_DEF_TIMESPEC
struct timespec {
__kernel_time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
-#endif
+#endif /* __UAPI_DEF_TIMESPEC */
+#endif /* _STRUCT_TIMESPEC */

+#if __UAPI_DEF_TIMEVAL
struct timeval {
__kernel_time_t tv_sec; /* seconds */
__kernel_suseconds_t tv_usec; /* microseconds */
};
+#endif /* __UAPI_DEF_TIMEVAL */

+#if __UAPI_DEF_TIMEZONE
struct timezone {
int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; /* type of dst correction */
};
-
+#endif /* __UAPI_DEF_TIMEZONE */

/*
* Names of the interval timers, and structure
* defining a timer setting:
*/
+#if __UAPI_DEF_ITIMER_REAL_VIRTUAL_PROF
#define ITIMER_REAL 0
#define ITIMER_VIRTUAL 1
#define ITIMER_PROF 2
+#endif /* __UAPI_DEF_ITIMER_REAL_VIRTUAL_PROF */

+#if __UAPI_DEF_ITIMERSPEC
struct itimerspec {
struct timespec it_interval; /* timer period */
struct timespec it_value; /* timer expiration */
};
+#endif /* __UAPI_DEF_ITIMERSPEC */

+#if __UAPI_DEF_ITIMERVAL
struct itimerval {
struct timeval it_interval; /* timer interval */
struct timeval it_value; /* current value */
};
+#endif /* __UAPI_DEF_ITIMERVAL */

/*
* The IDs of the various system clocks (for POSIX.1b interval timers):
@@ -64,6 +76,8 @@ struct itimerval {
/*
* The various flags for setting POSIX.1b interval timers:
*/
+#if __UAPI_DEF_TIMER_ABSTIME
#define TIMER_ABSTIME 0x01
+#endif /* __UAPI_DEF_TIMER_ABSTIME */

#endif /* _UAPI_LINUX_TIME_H */
--
2.8.1
Mikko Rapeli
2016-08-22 19:30:02 UTC
Permalink
Fixes userspace compilation errors like:

error: unknown type name ‘__be32’
error: field ‘dest_addr’ has incomplete type
struct sockaddr_storage dest_addr;

Signed-off-by: Mikko Rapeli <***@iki.fi>
Acked-by: Sowmini Varadhan <***@oracle.com>
---
include/uapi/linux/rds.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/rds.h b/include/uapi/linux/rds.h
index 5bf0368..441adf7 100644
--- a/include/uapi/linux/rds.h
+++ b/include/uapi/linux/rds.h
@@ -35,6 +35,7 @@
#define _LINUX_RDS_H

#include <linux/types.h>
+#include <linux/socket.h>

#define RDS_IB_ABI_VERSION 0x301
--
2.8.1
Mikko Rapeli
2016-08-22 19:30:02 UTC
Permalink
Fixes this userspace compile error when glibc sys/uio.h is included
before linux/uio.h:

linux/uio.h:16:8: error: redefinition of ‘struct iovec’

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/libc-compat.h | 10 ++++++++++
include/uapi/linux/uio.h | 4 +++-
2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index 8a5a7cc..f793b09 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -180,6 +180,13 @@

#endif /* defined(__NETIPX_IPX_H) */

+/* Definitions for sys/uio.h */
+#if defined(_SYS_UIO_H)
+#define __UAPI_DEF_IOVEC 0
+#else /* defined(_SYS_UIO_H) */
+#define __UAPI_DEF_IOVEC 1
+#endif /* defined(_SYS_UIO_H) */
+
/* Definitions for xattr.h */
#if defined(_SYS_XATTR_H)
#define __UAPI_DEF_XATTR 0
@@ -235,6 +242,9 @@
#define __UAPI_DEF_IPX_CONFIG_DATA 1
#define __UAPI_DEF_IPX_ROUTE_DEF 1

+/* Definitions for uio.h */
+#define __UAPI_DEF_IOVEC 1
+
/* Definitions for xattr.h */
#define __UAPI_DEF_XATTR 1

diff --git a/include/uapi/linux/uio.h b/include/uapi/linux/uio.h
index 2731d56..cba4819 100644
--- a/include/uapi/linux/uio.h
+++ b/include/uapi/linux/uio.h
@@ -9,15 +9,17 @@
#ifndef _UAPI__LINUX_UIO_H
#define _UAPI__LINUX_UIO_H

+#include <linux/libc-compat.h>
#include <linux/compiler.h>
#include <linux/types.h>

-
+#if __UAPI_DEF_IOVEC
struct iovec
{
void __user *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */
__kernel_size_t iov_len; /* Must be size_t (1003.1g) */
};
+#endif /* __UAPI_DEF_IOVEC */

/*
* UIO_MAXIOV shall be at least 16 1003.1g (5.4.1.1)
--
2.8.1
Mikko Rapeli
2016-08-22 19:40:02 UTC
Permalink
linux/time.h conflicts with userspace header time.h. Try to be compatible
for kernel and userspace.

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/errqueue.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/include/uapi/linux/errqueue.h b/include/uapi/linux/errqueue.h
index 6b1cdc6..b310b2c 100644
--- a/include/uapi/linux/errqueue.h
+++ b/include/uapi/linux/errqueue.h
@@ -2,7 +2,12 @@
#define _UAPI_LINUX_ERRQUEUE_H

#include <linux/types.h>
+
+#ifdef __KERNEL__
#include <linux/time.h>
+#else
+#include <time.h>
+#endif /* __KERNEL__ */

struct sock_extended_err {
__u32 ee_errno;
--
2.8.1
Mikko Rapeli
2016-08-22 19:40:02 UTC
Permalink
Kernel headers should use linux/types.h types.

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/linux/xz.h | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/include/linux/xz.h b/include/linux/xz.h
index 64cffa6..7686511 100644
--- a/include/linux/xz.h
+++ b/include/linux/xz.h
@@ -11,12 +11,11 @@
#ifndef XZ_H
#define XZ_H

+# include <linux/types.h>
#ifdef __KERNEL__
# include <linux/stddef.h>
-# include <linux/types.h>
#else
# include <stddef.h>
-# include <stdint.h>
#endif

/* In Linux, this is used to make extern functions static when needed. */
@@ -134,11 +133,11 @@ enum xz_ret {
* the variables in_pos and out_pos are modified by the XZ code.
*/
struct xz_buf {
- const uint8_t *in;
+ const __u8 *in;
size_t in_pos;
size_t in_size;

- uint8_t *out;
+ __u8 *out;
size_t out_pos;
size_t out_size;
};
@@ -191,7 +190,7 @@ struct xz_dec;
* ready to be used with xz_dec_run(). If memory allocation fails,
* xz_dec_init() returns NULL.
*/
-XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max);
+XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, __u32 dict_max);

/**
* xz_dec_run() - Run the XZ decoder
@@ -259,6 +258,6 @@ XZ_EXTERN void xz_crc32_init(void);
* calculation, the third argument must be zero. To continue the calculation,
* the previously returned value is passed as the third argument.
*/
-XZ_EXTERN uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc);
+XZ_EXTERN __u32 xz_crc32(const __u8 *buf, size_t size, __u32 crc);
#endif
#endif
--
2.8.1
Mikko Rapeli
2016-08-22 19:40:02 UTC
Permalink
Fixes these userspace compilation errors when rdma_user_rxe.h is compiled
alone:

rdma/rdma_user_rxe.h:59:20: error: field ‘_sockaddr’ has incomplete type
struct sockaddr _sockaddr;
^~~~~~~~~
rdma/rdma_user_rxe.h:60:22: error: field ‘_sockaddr_in’ has incomplete type
struct sockaddr_in _sockaddr_in;
^~~~~~~~~~~~
rdma/rdma_user_rxe.h:61:23: error: field ‘_sockaddr_in6’ has incomplete type
struct sockaddr_in6 _sockaddr_in6;
^~~~~~~~~~~~~

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/rdma/rdma_user_rxe.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/uapi/rdma/rdma_user_rxe.h b/include/uapi/rdma/rdma_user_rxe.h
index 1de99cf..ce6c929 100644
--- a/include/uapi/rdma/rdma_user_rxe.h
+++ b/include/uapi/rdma/rdma_user_rxe.h
@@ -34,6 +34,8 @@
#define RDMA_USER_RXE_H

#include <linux/types.h>
+#include <linux/in.h>
+#include <linux/in6.h>

union rxe_gid {
__u8 raw[16];
--
2.8.1
Mikko Rapeli
2016-08-22 19:50:02 UTC
Permalink
Fixes these userspace compile errors and warnings when glibc termios.h
is included before linux/termios.h:

asm-generic/termbits.h:11:8: error: redefinition of ‘struct termios’
asm-generic/termios.h:14:8: error: redefinition of ‘struct winsize’
asm-generic/termios.h:22:8: error: redefinition of ‘struct termio’

Not fixing multiple NCSS definitions since I don't know which one would be
correct so this warning remains:

asm-generic/termbits.h:10:0: warning: "NCCS" redefined
#define NCCS 19
^
bits/termios.h:27:0: note: this is the location of the previous definition
#define NCCS 32
^

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/asm-generic/termbits.h | 3 +++
include/uapi/asm-generic/termios.h | 5 +++++
include/uapi/linux/libc-compat.h | 28 ++++++++++++++++++++++++++++
3 files changed, 36 insertions(+)

diff --git a/include/uapi/asm-generic/termbits.h b/include/uapi/asm-generic/termbits.h
index 232b478..314bfef 100644
--- a/include/uapi/asm-generic/termbits.h
+++ b/include/uapi/asm-generic/termbits.h
@@ -1,6 +1,7 @@
#ifndef __ASM_GENERIC_TERMBITS_H
#define __ASM_GENERIC_TERMBITS_H

+#include <linux/libc-compat.h>
#include <linux/posix_types.h>

typedef unsigned char cc_t;
@@ -8,6 +9,7 @@ typedef unsigned int speed_t;
typedef unsigned int tcflag_t;

#define NCCS 19
+#if __UAPI_DEF_TERMIOS
struct termios {
tcflag_t c_iflag; /* input mode flags */
tcflag_t c_oflag; /* output mode flags */
@@ -16,6 +18,7 @@ struct termios {
cc_t c_line; /* line discipline */
cc_t c_cc[NCCS]; /* control characters */
};
+#endif /* __UAPI_DEF_TERMIOS */

struct termios2 {
tcflag_t c_iflag; /* input mode flags */
diff --git a/include/uapi/asm-generic/termios.h b/include/uapi/asm-generic/termios.h
index 0881760..3428999 100644
--- a/include/uapi/asm-generic/termios.h
+++ b/include/uapi/asm-generic/termios.h
@@ -8,17 +8,21 @@
* New architectures should not provide their own version.
*/

+#include <linux/libc-compat.h>
#include <asm/termbits.h>
#include <asm/ioctls.h>

+#if __UAPI_DEF_WINSIZE
struct winsize {
unsigned short ws_row;
unsigned short ws_col;
unsigned short ws_xpixel;
unsigned short ws_ypixel;
};
+#endif /* __UAPI_DEF_WINSIZE */

#define NCC 8
+#if __UAPI_DEF_TERMIO
struct termio {
unsigned short c_iflag; /* input mode flags */
unsigned short c_oflag; /* output mode flags */
@@ -27,6 +31,7 @@ struct termio {
unsigned char c_line; /* line discipline */
unsigned char c_cc[NCC]; /* control characters */
};
+#endif /* __UAPI_DEF_TERMIO */

/* modem lines */
#define TIOCM_LE 0x001
diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index cb25f16..07a3462 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -230,6 +230,13 @@

#endif /* defined(_NETROSE_ROSE_H) */

+/* Coordinate with glibc pty.h */
+#if defined(_PTY_H)
+#define __UAPI_DEF_TERMIOS 0
+#else /* defined(_PTY_H) */
+#define __UAPI_DEF_TERMIOS 1
+#endif /* defined(_PTY_H) */
+
/* Coordinate with glibc time.h */
#if defined(_TIME_H)
#define __UAPI_DEF_TIMESPEC 0
@@ -245,6 +252,15 @@

#endif /* defined(_TIME_H) */

+/* Definitions for sys/ioctl.h */
+#if defined(_SYS_IOCTL_H)
+#define __UAPI_DEF_TERMIO 0
+#define __UAPI_DEF_WINSIZE 0
+#else /* defined(_SYS_IOCTL_H) */
+#define __UAPI_DEF_TERMIO 1
+#define __UAPI_DEF_WINSIZE 1
+#endif /* defined(_SYS_IOCTL_H) */
+
/* Definitions for sys/uio.h */
#if defined(_SYS_UIO_H)
#define __UAPI_DEF_IOVEC 0
@@ -265,6 +281,13 @@

#endif /* defined(_SYS_TIME_H) */

+/* Coordinate with glibc termios.h */
+#if defined(_TERMIOS_H)
+#define __UAPI_DEF_TERMIOS 0
+#else /* defined(_TERMIOS_H) */
+#define __UAPI_DEF_TERMIOS 1
+#endif /* defined(_TERMIOS_H) */
+
/* Definitions for xattr.h */
#if defined(_SYS_XATTR_H)
#define __UAPI_DEF_XATTR 0
@@ -282,6 +305,11 @@
#define __UAPI_DEF_F_DUPFD_CLOEXEC 1
#define __UAPI_DEF_O_ACCMODE_RDONLY_WRONLY_RDWR 1

+/* Definitions for asm-generic/termbits.h and asm-generic/termios.h */
+#define __UAPI_DEF_TERMIO 1
+#define __UAPI_DEF_TERMIOS 1
+#define __UAPI_DEF_WINSIZE 1
+
/* Definitions for ax25.h */
#define __UAPI_DEF_SIOCAX25GETUID_TO_SIOCAX25DELFWD 1
#define __UAPI_DEF_SIOCAX25GETINFO 1
--
2.8.1
Mikko Rapeli
2016-08-22 19:50:02 UTC
Permalink
Fixes userspace compilation errors like:

error: field ‘iph’ has incomplete type
error: field ‘prefix’ has incomplete type

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/uapi/linux/if_tunnel.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/include/uapi/linux/if_tunnel.h b/include/uapi/linux/if_tunnel.h
index 1046f55..777b6cd 100644
--- a/include/uapi/linux/if_tunnel.h
+++ b/include/uapi/linux/if_tunnel.h
@@ -2,6 +2,9 @@
#define _UAPI_IF_TUNNEL_H_

#include <linux/types.h>
+#include <linux/if.h>
+#include <linux/ip.h>
+#include <linux/in6.h>
#include <asm/byteorder.h>
--
2.8.1
David Miller
2016-08-22 23:30:02 UTC
Permalink
From: Mikko Rapeli <***@iki.fi>
Date: Mon, 22 Aug 2016 20:32:39 +0200
Post by Mikko Rapeli
error: field ‘iph’ has incomplete type
error: field ‘prefix’ has incomplete type
Applied.
Mikko Rapeli
2016-08-22 19:50:03 UTC
Permalink
Kernel headers should use linux/types.h types.

Signed-off-by: Mikko Rapeli <***@iki.fi>
---
include/linux/ipmi-fru.h | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/include/linux/ipmi-fru.h b/include/linux/ipmi-fru.h
index 4d3a763..ceecf1f 100644
--- a/include/linux/ipmi-fru.h
+++ b/include/linux/ipmi-fru.h
@@ -9,11 +9,10 @@
*/
#ifndef __LINUX_IPMI_FRU_H__
#define __LINUX_IPMI_FRU_H__
-#ifdef __KERNEL__
# include <linux/types.h>
+#ifdef __KERNEL__
# include <linux/string.h>
#else
-# include <stdint.h>
# include <string.h>
#endif

@@ -24,14 +23,14 @@

/* chapter 8, page 5 */
struct fru_common_header {
- uint8_t format; /* 0x01 */
- uint8_t internal_use_off; /* multiple of 8 bytes */
- uint8_t chassis_info_off; /* multiple of 8 bytes */
- uint8_t board_area_off; /* multiple of 8 bytes */
- uint8_t product_area_off; /* multiple of 8 bytes */
- uint8_t multirecord_off; /* multiple of 8 bytes */
- uint8_t pad; /* must be 0 */
- uint8_t checksum; /* sum modulo 256 must be 0 */
+ __u8 format; /* 0x01 */
+ __u8 internal_use_off; /* multiple of 8 bytes */
+ __u8 chassis_info_off; /* multiple of 8 bytes */
+ __u8 board_area_off; /* multiple of 8 bytes */
+ __u8 product_area_off; /* multiple of 8 bytes */
+ __u8 multirecord_off; /* multiple of 8 bytes */
+ __u8 pad; /* must be 0 */
+ __u8 checksum; /* sum modulo 256 must be 0 */
};

/* chapter 9, page 5 -- internal_use: not used by us */
@@ -40,16 +39,16 @@ struct fru_common_header {

/* chapter 13, page 9 -- used by board_info_area below */
struct fru_type_length {
- uint8_t type_length;
- uint8_t data[0];
+ __u8 type_length;
+ __u8 data[0];
};

/* chapter 11, page 7 */
struct fru_board_info_area {
- uint8_t format; /* 0x01 */
- uint8_t area_len; /* multiple of 8 bytes */
- uint8_t language; /* I hope it's 0 */
- uint8_t mfg_date[3]; /* LSB, minutes since 1996-01-01 */
+ __u8 format; /* 0x01 */
+ __u8 area_len; /* multiple of 8 bytes */
+ __u8 language; /* I hope it's 0 */
+ __u8 mfg_date[3]; /* LSB, minutes since 1996-01-01 */
struct fru_type_length tl[0]; /* type-length stuff follows */

/*
--
2.8.1
Loading...