commit:     c2d3a0e09d136d9576202af24f6bca21c51393fe
Author:     Travis Tilley <ttilley <AT> gmail <DOT> com>
AuthorDate: Wed Mar 25 15:38:18 2015 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Wed Mar 25 17:18:53 2015 +0000
URL:        https://gitweb.gentoo.org/proj/hardened-dev.git/commit/?id=c2d3a0e0

sys-kernel/linux-headers: compatibility fixes for use with musl

 ...ecific-inclusion-of-sysinfo.h-in-kernel.h.patch | 12 +++++
 ...mpat.h-fix-some-issues-arising-from-in6.h.patch | 61 ++++++++++++++++++++++
 ...t.h-prevent-redefinition-of-struct-ethhdr.patch | 39 ++++++++++++++
 sys-kernel/linux-headers/linux-headers-3.18.ebuild | 57 ++++++++++++++++++++
 sys-kernel/linux-headers/linux-headers-3.19.ebuild | 57 ++++++++++++++++++++
 5 files changed, 226 insertions(+)

diff --git 
a/sys-kernel/linux-headers/files/glibc-specific-inclusion-of-sysinfo.h-in-kernel.h.patch
 
b/sys-kernel/linux-headers/files/glibc-specific-inclusion-of-sysinfo.h-in-kernel.h.patch
new file mode 100644
index 0000000..0b4cfb1
--- /dev/null
+++ 
b/sys-kernel/linux-headers/files/glibc-specific-inclusion-of-sysinfo.h-in-kernel.h.patch
@@ -0,0 +1,12 @@
+--- ./include/uapi/linux/kernel.h.orig
++++ ./include/uapi/linux/kernel.h
+@@ -1,7 +1,9 @@
+ #ifndef _UAPI_LINUX_KERNEL_H
+ #define _UAPI_LINUX_KERNEL_H
+ 
++#ifdef __GLIBC__
+ #include <linux/sysinfo.h>
++#endif
+ 
+ /*
+  * 'kernel.h' contains some often-used function prototypes etc

diff --git 
a/sys-kernel/linux-headers/files/libc-compat.h-fix-some-issues-arising-from-in6.h.patch
 
b/sys-kernel/linux-headers/files/libc-compat.h-fix-some-issues-arising-from-in6.h.patch
new file mode 100644
index 0000000..e4ce3d6
--- /dev/null
+++ 
b/sys-kernel/linux-headers/files/libc-compat.h-fix-some-issues-arising-from-in6.h.patch
@@ -0,0 +1,61 @@
+--- ./include/uapi/linux/libc-compat.h.orig
++++ ./include/uapi/linux/libc-compat.h
+@@ -48,35 +48,26 @@
+ #ifndef _UAPI_LIBC_COMPAT_H
+ #define _UAPI_LIBC_COMPAT_H
+ 
+-/* We have included glibc headers... */
+-#if defined(__GLIBC__)
++#ifndef __KERNEL__ /* we're used from userspace */
+ 
+-/* Coordinate with glibc netinet/in.h header. */
+-#if defined(_NETINET_IN_H)
++/* Coordinate with libc netinet/in.h header. */
++#ifdef _NETINET_IN_H
+ 
+ /* GLIBC headers included first so don't define anything
+  * that would already be defined. */
+ #define __UAPI_DEF_IN6_ADDR           0
+-/* The exception is the in6_addr macros which must be defined
+- * if the glibc code didn't define them. This guard matches
+- * the guard in glibc/inet/netinet/in.h which defines the
+- * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */
+-#if defined(__USE_MISC) || defined (__USE_GNU)
+ #define __UAPI_DEF_IN6_ADDR_ALT               0
+-#else
+-#define __UAPI_DEF_IN6_ADDR_ALT               1
+-#endif
+ #define __UAPI_DEF_SOCKADDR_IN6               0
+ #define __UAPI_DEF_IPV6_MREQ          0
+ #define __UAPI_DEF_IPPROTO_V6         0
+ 
+-#else
++#else /* defined(_NETINET_IN_H) */
+ 
+ /* Linux headers included first, and we must define everything
+- * we need. The expectation is that glibc will check the
++ * we need. The expectation is that the libc will check the
+  * __UAPI_DEF_* defines and adjust appropriately. */
+ #define __UAPI_DEF_IN6_ADDR           1
+-/* We unconditionally define the in6_addr macros and glibc must
++/* We unconditionally define the in6_addr macros and the libc must
+  * coordinate. */
+ #define __UAPI_DEF_IN6_ADDR_ALT               1
+ #define __UAPI_DEF_SOCKADDR_IN6               1
+@@ -89,7 +80,7 @@
+ /* If we did not see any headers from any supported C libraries,
+  * or we are being included in the kernel, then define everything
+  * that we need. */
+-#else /* !defined(__GLIBC__) */
++#else /* __KERNEL__ */
+ 
+ /* Definitions for in6.h */
+ #define __UAPI_DEF_IN6_ADDR           1
+@@ -98,6 +89,6 @@
+ #define __UAPI_DEF_IPV6_MREQ          1
+ #define __UAPI_DEF_IPPROTO_V6         1
+ 
+-#endif /* __GLIBC__ */
++#endif /* __KERNEL__ */
+ 
+ #endif /* _UAPI_LIBC_COMPAT_H */

diff --git 
a/sys-kernel/linux-headers/files/libc-compat.h-prevent-redefinition-of-struct-ethhdr.patch
 
b/sys-kernel/linux-headers/files/libc-compat.h-prevent-redefinition-of-struct-ethhdr.patch
new file mode 100644
index 0000000..b8ac94f
--- /dev/null
+++ 
b/sys-kernel/linux-headers/files/libc-compat.h-prevent-redefinition-of-struct-ethhdr.patch
@@ -0,0 +1,39 @@
+--- ./include/uapi/linux/if_ether.h.orig
++++ ./include/uapi/linux/if_ether.h
+@@ -22,6 +22,7 @@
+ #define _UAPI_LINUX_IF_ETHER_H
+ 
+ #include <linux/types.h>
++#include <linux/libc-compat.h>
+ 
+ /*
+  *    IEEE 802.3 Ethernet magic constants.  The frame sizes omit the preamble
+@@ -130,11 +131,12 @@
+  *    This is an Ethernet frame header.
+  */
+ 
++#if __UAPI_DEF_ETHHDR
+ struct ethhdr {
+       unsigned char   h_dest[ETH_ALEN];       /* destination eth addr */
+       unsigned char   h_source[ETH_ALEN];     /* source ether addr    */
+       __be16          h_proto;                /* packet type ID field */
+ } __attribute__((packed));
+-
++#endif
+ 
+ #endif /* _UAPI_LINUX_IF_ETHER_H */
+--- ./include/uapi/linux/libc-compat.h.orig
++++ ./include/uapi/linux/libc-compat.h
+@@ -50,6 +50,12 @@
+ 
+ #ifndef __KERNEL__ /* we're used from userspace */
+ 
++#ifdef _NETINET_IF_ETHER_H /* musl */
++#define __UAPI_DEF_ETHHDR 0
++#else /* glibc uses __NETINET_IF_ETHER_H, and includes the kernel header. */
++#define __UAPI_DEF_ETHHDR 1
++#endif
++
+ /* Coordinate with libc netinet/in.h header. */
+ #ifdef _NETINET_IN_H
+ 

diff --git a/sys-kernel/linux-headers/linux-headers-3.18.ebuild 
b/sys-kernel/linux-headers/linux-headers-3.18.ebuild
new file mode 100644
index 0000000..7d5f922
--- /dev/null
+++ b/sys-kernel/linux-headers/linux-headers-3.18.ebuild
@@ -0,0 +1,57 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: 
/var/cvsroot/gentoo-x86/sys-kernel/linux-headers/linux-headers-3.18.ebuild,v 
1.3 2015/03/24 20:13:13 maekke Exp $
+
+EAPI="4"
+
+ETYPE="headers"
+H_SUPPORTEDARCH="alpha amd64 arc arm arm64 avr32 bfin cris frv hexagon hppa 
ia64 m32r m68k metag microblaze mips mn10300 openrisc ppc ppc64 s390 score sh 
sparc tile x86 xtensa"
+inherit kernel-2
+detect_version
+
+PATCH_VER="1"
+SRC_URI="mirror://gentoo/gentoo-headers-base-${PV}.tar.xz
+       ${PATCH_VER:+mirror://gentoo/gentoo-headers-${PV}-${PATCH_VER}.tar.xz}"
+
+KEYWORDS="~alpha amd64 arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 
~sh ~sparc ~x86 ~amd64-linux ~arm-linux ~x86-linux"
+
+DEPEND="app-arch/xz-utils
+       dev-lang/perl"
+RDEPEND="!!media-sound/alsa-headers"
+
+S=${WORKDIR}/gentoo-headers-base-${PV}
+
+src_unpack() {
+       unpack ${A}
+}
+
+src_prepare() {
+       [[ -n ${PATCH_VER} ]] && EPATCH_SUFFIX="patch" epatch "${WORKDIR}"/${PV}
+       epatch 
"${FILESDIR}"/glibc-specific-inclusion-of-sysinfo.h-in-kernel.h.patch
+       epatch 
"${FILESDIR}"/libc-compat.h-fix-some-issues-arising-from-in6.h.patch
+       epatch 
"${FILESDIR}"/libc-compat.h-prevent-redefinition-of-struct-ethhdr.patch
+}
+
+src_install() {
+       kernel-2_src_install
+
+       # hrm, build system sucks
+       find "${ED}" '(' -name '.install' -o -name '*.cmd' ')' -delete
+       find "${ED}" -depth -type d -delete 2>/dev/null
+
+       # provided by libdrm (for now?)
+       rm -rf "${ED}"/$(kernel_header_destdir)/drm
+}
+
+src_test() {
+       einfo "Possible unescaped attribute/type usage"
+       egrep -r \
+               -e '(^|[[:space:](])(asm|volatile|inline)[[:space:](]' \
+               -e '\<([us](8|16|32|64))\>' \
+               .
+
+       einfo "Missing linux/types.h include"
+       egrep -l -r -e '__[us](8|16|32|64)' "${ED}" | xargs grep -L 
linux/types.h
+
+       emake ARCH=$(tc-arch-kernel) headers_check
+}

diff --git a/sys-kernel/linux-headers/linux-headers-3.19.ebuild 
b/sys-kernel/linux-headers/linux-headers-3.19.ebuild
new file mode 100644
index 0000000..13e8eb2
--- /dev/null
+++ b/sys-kernel/linux-headers/linux-headers-3.19.ebuild
@@ -0,0 +1,57 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: 
/var/cvsroot/gentoo-x86/sys-kernel/linux-headers/linux-headers-3.19.ebuild,v 
1.1 2015/02/09 19:25:54 vapier Exp $
+
+EAPI="4"
+
+ETYPE="headers"
+H_SUPPORTEDARCH="alpha amd64 arc arm arm64 avr32 bfin cris frv hexagon hppa 
ia64 m32r m68k metag microblaze mips mn10300 nios2 openrisc ppc ppc64 s390 
score sh sparc tile x86 xtensa"
+inherit kernel-2
+detect_version
+
+PATCH_VER="1"
+SRC_URI="mirror://gentoo/gentoo-headers-base-${PV}.tar.xz
+       ${PATCH_VER:+mirror://gentoo/gentoo-headers-${PV}-${PATCH_VER}.tar.xz}"
+
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 
~sh ~sparc ~x86 ~amd64-linux ~arm-linux ~x86-linux"
+
+DEPEND="app-arch/xz-utils
+       dev-lang/perl"
+RDEPEND="!!media-sound/alsa-headers"
+
+S=${WORKDIR}/gentoo-headers-base-${PV}
+
+src_unpack() {
+       unpack ${A}
+}
+
+src_prepare() {
+       [[ -n ${PATCH_VER} ]] && EPATCH_SUFFIX="patch" epatch "${WORKDIR}"/${PV}
+       epatch 
"${FILESDIR}"/glibc-specific-inclusion-of-sysinfo.h-in-kernel.h.patch
+       epatch 
"${FILESDIR}"/libc-compat.h-fix-some-issues-arising-from-in6.h.patch
+       epatch 
"${FILESDIR}"/libc-compat.h-prevent-redefinition-of-struct-ethhdr.patch
+}
+
+src_install() {
+       kernel-2_src_install
+
+       # hrm, build system sucks
+       find "${ED}" '(' -name '.install' -o -name '*.cmd' ')' -delete
+       find "${ED}" -depth -type d -delete 2>/dev/null
+
+       # provided by libdrm (for now?)
+       rm -rf "${ED}"/$(kernel_header_destdir)/drm
+}
+
+src_test() {
+       einfo "Possible unescaped attribute/type usage"
+       egrep -r \
+               -e '(^|[[:space:](])(asm|volatile|inline)[[:space:](]' \
+               -e '\<([us](8|16|32|64))\>' \
+               .
+
+       einfo "Missing linux/types.h include"
+       egrep -l -r -e '__[us](8|16|32|64)' "${ED}" | xargs grep -L 
linux/types.h
+
+       emake ARCH=$(tc-arch-kernel) headers_check
+}

Reply via email to