File uapi-add-a-compatibility-layer-between-linux-uio-h-and-glibc of Package linux-glibc-devel
From: Dmitry V. Levin <ldv@altlinux.org>
Date: Feb. 22, 2017, 2:29 a.m.
Subject: uapi: add a compatibility layer between linux/uio.h and glibc
References: bsc#1053501
Patch-mainline: Not yet, submitted 2/22/2017 to lkml <jeffm: and largely ignored, lduncan will follow up, Oct 4, 2017>
Do not define struct iovec in linux/uio.h when <sys/uio.h> or <fcntl.h>
is already included and provides these definitions.
This fixes the following compilation error when <sys/uio.h> or <fcntl.h>
is included before <linux/uio.h>:
/usr/include/linux/uio.h:16:8: error: redefinition of 'struct iovec'
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Acked-by: Lee Duncan <lduncan@suse.com>
---
include/uapi/linux/libc-compat.h | 10 ++++++++++
include/uapi/linux/uio.h | 3 +++
2 files changed, 13 insertions(+)
--- a/include/linux/libc-compat.h
+++ b/include/linux/libc-compat.h
@@ -158,6 +158,13 @@
#endif /* defined(__NETIPX_IPX_H) */
+/* Coordinate with glibc bits/uio.h header. */
+#if defined(_SYS_UIO_H) || defined(_FCNTL_H)
+#define __UAPI_DEF_IOVEC 0
+#else
+#define __UAPI_DEF_IOVEC 1
+#endif
+
/* Definitions for xattr.h */
#if defined(_SYS_XATTR_H)
#define __UAPI_DEF_XATTR 0
@@ -205,6 +212,9 @@
#define __UAPI_DEF_IPX_ROUTE_DEF 1
#endif
+/* Definitions for uio.h */
+#define __UAPI_DEF_IOVEC 1
+
/* Definitions for xattr.h */
#ifndef __UAPI_DEF_XATTR
#define __UAPI_DEF_XATTR 1
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -9,15 +9,18 @@
#ifndef __LINUX_UIO_H
#define __LINUX_UIO_H
+#include <linux/libc-compat.h>
#include <linux/types.h>
+#if __UAPI_DEF_IOVEC
struct iovec
{
void *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)