diff mbox

patches/gcc: Only define CPU_COUNT if not already defined

Message ID 1411703001-13942-1-git-send-email-bryanhundven@gmail.com
State New
Headers show

Commit Message

Bryan Hundven Sept. 26, 2014, 3:43 a.m. UTC
Modern LIBCs #define CPU_COUNT and CPU_COUNT_S in sched.h.
Rather then checking the version or brand of LIBC, just check if
CPU_COUNT is defined before redefining it.

Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
---
 .../010-libgo-do-not-redefine-CPU_COUNT.patch      | 32 ++++++++++++++++++++++
 .../010-libgo-do-not-redefine-CPU_COUNT.patch      | 32 ++++++++++++++++++++++
 .../010-libgo-do-not-redefine-CPU_COUNT.patch      | 32 ++++++++++++++++++++++
 .../010-libgo-do-not-redefine-CPU_COUNT.patch      | 32 ++++++++++++++++++++++
 .../010-libgo-do-not-redefine-CPU_COUNT.patch      | 32 ++++++++++++++++++++++
 .../010-libgo-do-not-redefine-CPU_COUNT.patch      | 32 ++++++++++++++++++++++
 6 files changed, 192 insertions(+)
 create mode 100644 patches/gcc/4.8.0/010-libgo-do-not-redefine-CPU_COUNT.patch
 create mode 100644 patches/gcc/4.8.1/010-libgo-do-not-redefine-CPU_COUNT.patch
 create mode 100644 patches/gcc/4.8.2/010-libgo-do-not-redefine-CPU_COUNT.patch
 create mode 100644 patches/gcc/4.8.3/010-libgo-do-not-redefine-CPU_COUNT.patch
 create mode 100644 patches/gcc/4.9.0/010-libgo-do-not-redefine-CPU_COUNT.patch
 create mode 100644 patches/gcc/4.9.1/010-libgo-do-not-redefine-CPU_COUNT.patch

Comments

Bryan Hundven Oct. 3, 2014, 7:35 a.m. UTC | #1
Yann, List,

> On Sep 25, 2014, at 8:43 PM, Bryan Hundven <bryanhundven@gmail.com> wrote:
> 
> Modern LIBCs #define CPU_COUNT and CPU_COUNT_S in sched.h.
> Rather then checking the version or brand of LIBC, just check if
> CPU_COUNT is defined before redefining it.
> 
> Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
> ---
> .../010-libgo-do-not-redefine-CPU_COUNT.patch      | 32 ++++++++++++++++++++++
> .../010-libgo-do-not-redefine-CPU_COUNT.patch      | 32 ++++++++++++++++++++++
> .../010-libgo-do-not-redefine-CPU_COUNT.patch      | 32 ++++++++++++++++++++++
> .../010-libgo-do-not-redefine-CPU_COUNT.patch      | 32 ++++++++++++++++++++++
> .../010-libgo-do-not-redefine-CPU_COUNT.patch      | 32 ++++++++++++++++++++++
> .../010-libgo-do-not-redefine-CPU_COUNT.patch      | 32 ++++++++++++++++++++++
> 6 files changed, 192 insertions(+)
> create mode 100644 patches/gcc/4.8.0/010-libgo-do-not-redefine-CPU_COUNT.patch
> create mode 100644 patches/gcc/4.8.1/010-libgo-do-not-redefine-CPU_COUNT.patch
> create mode 100644 patches/gcc/4.8.2/010-libgo-do-not-redefine-CPU_COUNT.patch
> create mode 100644 patches/gcc/4.8.3/010-libgo-do-not-redefine-CPU_COUNT.patch
> create mode 100644 patches/gcc/4.9.0/010-libgo-do-not-redefine-CPU_COUNT.patch
> create mode 100644 patches/gcc/4.9.1/010-libgo-do-not-redefine-CPU_COUNT.patch
> 
> diff --git a/patches/gcc/4.8.0/010-libgo-do-not-redefine-CPU_COUNT.patch b/patches/gcc/4.8.0/010-libgo-do-not-redefine-CPU_COUNT.patch
> new file mode 100644
> index 0000000..dc9817e
> --- /dev/null
> +++ b/patches/gcc/4.8.0/010-libgo-do-not-redefine-CPU_COUNT.patch
> @@ -0,0 +1,32 @@
> +From fe9d1f9b730f653039868515000a02cbb73e8941 Mon Sep 17 00:00:00 2001
> +From: Bryan Hundven <bryanhundven@gmail.com>
> +Date: Thu, 25 Sep 2014 18:54:06 -0700
> +Subject: [PATCH] libgo/runtime: Only define CPU_COUNT if not already defined
> +
> +Modern LIBCs #define CPU_COUNT and CPU_COUNT_S in sched.h.
> +Rather then checking the version or brand of LIBC, just check if
> +CPU_COUNT is defined before redefining it.
> +
> +Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
> +---
> + libgo/runtime/getncpu-linux.c | 4 ++--
> + 1 file changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/libgo/runtime/getncpu-linux.c b/libgo/runtime/getncpu-linux.c
> +index 0122b77..4aab58f 100644
> +--- a/libgo/runtime/getncpu-linux.c
> ++++ b/libgo/runtime/getncpu-linux.c
> +@@ -5,8 +5,8 @@
> + #include <features.h>
> + #include <sched.h>
> + 
> +-// CPU_COUNT is only provided by glibc 2.6 or higher
> +-#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 6)
> ++// Define CPU_COUNT if it isn't already.
> ++#if !defined(CPU_COUNT)
> + #define CPU_COUNT(set) _CPU_COUNT((unsigned int *)(set), sizeof(*(set))/sizeof(unsigned int))
> + static int _CPU_COUNT(unsigned int *set, size_t len) {
> + 	int cnt;
> +-- 
> +2.1.1
> +
> diff --git a/patches/gcc/4.8.1/010-libgo-do-not-redefine-CPU_COUNT.patch b/patches/gcc/4.8.1/010-libgo-do-not-redefine-CPU_COUNT.patch
> new file mode 100644
> index 0000000..dc9817e
> --- /dev/null
> +++ b/patches/gcc/4.8.1/010-libgo-do-not-redefine-CPU_COUNT.patch
> @@ -0,0 +1,32 @@
> +From fe9d1f9b730f653039868515000a02cbb73e8941 Mon Sep 17 00:00:00 2001
> +From: Bryan Hundven <bryanhundven@gmail.com>
> +Date: Thu, 25 Sep 2014 18:54:06 -0700
> +Subject: [PATCH] libgo/runtime: Only define CPU_COUNT if not already defined
> +
> +Modern LIBCs #define CPU_COUNT and CPU_COUNT_S in sched.h.
> +Rather then checking the version or brand of LIBC, just check if
> +CPU_COUNT is defined before redefining it.
> +
> +Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
> +---
> + libgo/runtime/getncpu-linux.c | 4 ++--
> + 1 file changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/libgo/runtime/getncpu-linux.c b/libgo/runtime/getncpu-linux.c
> +index 0122b77..4aab58f 100644
> +--- a/libgo/runtime/getncpu-linux.c
> ++++ b/libgo/runtime/getncpu-linux.c
> +@@ -5,8 +5,8 @@
> + #include <features.h>
> + #include <sched.h>
> + 
> +-// CPU_COUNT is only provided by glibc 2.6 or higher
> +-#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 6)
> ++// Define CPU_COUNT if it isn't already.
> ++#if !defined(CPU_COUNT)
> + #define CPU_COUNT(set) _CPU_COUNT((unsigned int *)(set), sizeof(*(set))/sizeof(unsigned int))
> + static int _CPU_COUNT(unsigned int *set, size_t len) {
> + 	int cnt;
> +-- 
> +2.1.1
> +
> diff --git a/patches/gcc/4.8.2/010-libgo-do-not-redefine-CPU_COUNT.patch b/patches/gcc/4.8.2/010-libgo-do-not-redefine-CPU_COUNT.patch
> new file mode 100644
> index 0000000..dc9817e
> --- /dev/null
> +++ b/patches/gcc/4.8.2/010-libgo-do-not-redefine-CPU_COUNT.patch
> @@ -0,0 +1,32 @@
> +From fe9d1f9b730f653039868515000a02cbb73e8941 Mon Sep 17 00:00:00 2001
> +From: Bryan Hundven <bryanhundven@gmail.com>
> +Date: Thu, 25 Sep 2014 18:54:06 -0700
> +Subject: [PATCH] libgo/runtime: Only define CPU_COUNT if not already defined
> +
> +Modern LIBCs #define CPU_COUNT and CPU_COUNT_S in sched.h.
> +Rather then checking the version or brand of LIBC, just check if
> +CPU_COUNT is defined before redefining it.
> +
> +Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
> +---
> + libgo/runtime/getncpu-linux.c | 4 ++--
> + 1 file changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/libgo/runtime/getncpu-linux.c b/libgo/runtime/getncpu-linux.c
> +index 0122b77..4aab58f 100644
> +--- a/libgo/runtime/getncpu-linux.c
> ++++ b/libgo/runtime/getncpu-linux.c
> +@@ -5,8 +5,8 @@
> + #include <features.h>
> + #include <sched.h>
> + 
> +-// CPU_COUNT is only provided by glibc 2.6 or higher
> +-#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 6)
> ++// Define CPU_COUNT if it isn't already.
> ++#if !defined(CPU_COUNT)
> + #define CPU_COUNT(set) _CPU_COUNT((unsigned int *)(set), sizeof(*(set))/sizeof(unsigned int))
> + static int _CPU_COUNT(unsigned int *set, size_t len) {
> + 	int cnt;
> +-- 
> +2.1.1
> +
> diff --git a/patches/gcc/4.8.3/010-libgo-do-not-redefine-CPU_COUNT.patch b/patches/gcc/4.8.3/010-libgo-do-not-redefine-CPU_COUNT.patch
> new file mode 100644
> index 0000000..dc9817e
> --- /dev/null
> +++ b/patches/gcc/4.8.3/010-libgo-do-not-redefine-CPU_COUNT.patch
> @@ -0,0 +1,32 @@
> +From fe9d1f9b730f653039868515000a02cbb73e8941 Mon Sep 17 00:00:00 2001
> +From: Bryan Hundven <bryanhundven@gmail.com>
> +Date: Thu, 25 Sep 2014 18:54:06 -0700
> +Subject: [PATCH] libgo/runtime: Only define CPU_COUNT if not already defined
> +
> +Modern LIBCs #define CPU_COUNT and CPU_COUNT_S in sched.h.
> +Rather then checking the version or brand of LIBC, just check if
> +CPU_COUNT is defined before redefining it.
> +
> +Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
> +---
> + libgo/runtime/getncpu-linux.c | 4 ++--
> + 1 file changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/libgo/runtime/getncpu-linux.c b/libgo/runtime/getncpu-linux.c
> +index 0122b77..4aab58f 100644
> +--- a/libgo/runtime/getncpu-linux.c
> ++++ b/libgo/runtime/getncpu-linux.c
> +@@ -5,8 +5,8 @@
> + #include <features.h>
> + #include <sched.h>
> + 
> +-// CPU_COUNT is only provided by glibc 2.6 or higher
> +-#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 6)
> ++// Define CPU_COUNT if it isn't already.
> ++#if !defined(CPU_COUNT)
> + #define CPU_COUNT(set) _CPU_COUNT((unsigned int *)(set), sizeof(*(set))/sizeof(unsigned int))
> + static int _CPU_COUNT(unsigned int *set, size_t len) {
> + 	int cnt;
> +-- 
> +2.1.1
> +
> diff --git a/patches/gcc/4.9.0/010-libgo-do-not-redefine-CPU_COUNT.patch b/patches/gcc/4.9.0/010-libgo-do-not-redefine-CPU_COUNT.patch
> new file mode 100644
> index 0000000..dc9817e
> --- /dev/null
> +++ b/patches/gcc/4.9.0/010-libgo-do-not-redefine-CPU_COUNT.patch
> @@ -0,0 +1,32 @@
> +From fe9d1f9b730f653039868515000a02cbb73e8941 Mon Sep 17 00:00:00 2001
> +From: Bryan Hundven <bryanhundven@gmail.com>
> +Date: Thu, 25 Sep 2014 18:54:06 -0700
> +Subject: [PATCH] libgo/runtime: Only define CPU_COUNT if not already defined
> +
> +Modern LIBCs #define CPU_COUNT and CPU_COUNT_S in sched.h.
> +Rather then checking the version or brand of LIBC, just check if
> +CPU_COUNT is defined before redefining it.
> +
> +Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
> +---
> + libgo/runtime/getncpu-linux.c | 4 ++--
> + 1 file changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/libgo/runtime/getncpu-linux.c b/libgo/runtime/getncpu-linux.c
> +index 0122b77..4aab58f 100644
> +--- a/libgo/runtime/getncpu-linux.c
> ++++ b/libgo/runtime/getncpu-linux.c
> +@@ -5,8 +5,8 @@
> + #include <features.h>
> + #include <sched.h>
> + 
> +-// CPU_COUNT is only provided by glibc 2.6 or higher
> +-#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 6)
> ++// Define CPU_COUNT if it isn't already.
> ++#if !defined(CPU_COUNT)
> + #define CPU_COUNT(set) _CPU_COUNT((unsigned int *)(set), sizeof(*(set))/sizeof(unsigned int))
> + static int _CPU_COUNT(unsigned int *set, size_t len) {
> + 	int cnt;
> +-- 
> +2.1.1
> +
> diff --git a/patches/gcc/4.9.1/010-libgo-do-not-redefine-CPU_COUNT.patch b/patches/gcc/4.9.1/010-libgo-do-not-redefine-CPU_COUNT.patch
> new file mode 100644
> index 0000000..dc9817e
> --- /dev/null
> +++ b/patches/gcc/4.9.1/010-libgo-do-not-redefine-CPU_COUNT.patch
> @@ -0,0 +1,32 @@
> +From fe9d1f9b730f653039868515000a02cbb73e8941 Mon Sep 17 00:00:00 2001
> +From: Bryan Hundven <bryanhundven@gmail.com>
> +Date: Thu, 25 Sep 2014 18:54:06 -0700
> +Subject: [PATCH] libgo/runtime: Only define CPU_COUNT if not already defined
> +
> +Modern LIBCs #define CPU_COUNT and CPU_COUNT_S in sched.h.
> +Rather then checking the version or brand of LIBC, just check if
> +CPU_COUNT is defined before redefining it.
> +
> +Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
> +---
> + libgo/runtime/getncpu-linux.c | 4 ++--
> + 1 file changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/libgo/runtime/getncpu-linux.c b/libgo/runtime/getncpu-linux.c
> +index 0122b77..4aab58f 100644
> +--- a/libgo/runtime/getncpu-linux.c
> ++++ b/libgo/runtime/getncpu-linux.c
> +@@ -5,8 +5,8 @@
> + #include <features.h>
> + #include <sched.h>
> + 
> +-// CPU_COUNT is only provided by glibc 2.6 or higher
> +-#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 6)
> ++// Define CPU_COUNT if it isn't already.
> ++#if !defined(CPU_COUNT)
> + #define CPU_COUNT(set) _CPU_COUNT((unsigned int *)(set), sizeof(*(set))/sizeof(unsigned int))
> + static int _CPU_COUNT(unsigned int *set, size_t len) {
> + 	int cnt;
> +-- 
> +2.1.1
> +
> -- 
> 2.1.1
> 

This patch is now upstream, and will be in gcc-5.0:

https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=215832

https://code.google.com/p/gofrontend/issues/detail?id=38

So there is no reason to port it beyond 4.9.1 (hoping it gets back-ported to 4.9.2).

Cheers,

-Bryan


--
For unsubscribe information see http://sourceware.org/lists.html#faq
diff mbox

Patch

diff --git a/patches/gcc/4.8.0/010-libgo-do-not-redefine-CPU_COUNT.patch b/patches/gcc/4.8.0/010-libgo-do-not-redefine-CPU_COUNT.patch
new file mode 100644
index 0000000..dc9817e
--- /dev/null
+++ b/patches/gcc/4.8.0/010-libgo-do-not-redefine-CPU_COUNT.patch
@@ -0,0 +1,32 @@ 
+From fe9d1f9b730f653039868515000a02cbb73e8941 Mon Sep 17 00:00:00 2001
+From: Bryan Hundven <bryanhundven@gmail.com>
+Date: Thu, 25 Sep 2014 18:54:06 -0700
+Subject: [PATCH] libgo/runtime: Only define CPU_COUNT if not already defined
+
+Modern LIBCs #define CPU_COUNT and CPU_COUNT_S in sched.h.
+Rather then checking the version or brand of LIBC, just check if
+CPU_COUNT is defined before redefining it.
+
+Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
+---
+ libgo/runtime/getncpu-linux.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libgo/runtime/getncpu-linux.c b/libgo/runtime/getncpu-linux.c
+index 0122b77..4aab58f 100644
+--- a/libgo/runtime/getncpu-linux.c
++++ b/libgo/runtime/getncpu-linux.c
+@@ -5,8 +5,8 @@
+ #include <features.h>
+ #include <sched.h>
+ 
+-// CPU_COUNT is only provided by glibc 2.6 or higher
+-#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 6)
++// Define CPU_COUNT if it isn't already.
++#if !defined(CPU_COUNT)
+ #define CPU_COUNT(set) _CPU_COUNT((unsigned int *)(set), sizeof(*(set))/sizeof(unsigned int))
+ static int _CPU_COUNT(unsigned int *set, size_t len) {
+ 	int cnt;
+-- 
+2.1.1
+
diff --git a/patches/gcc/4.8.1/010-libgo-do-not-redefine-CPU_COUNT.patch b/patches/gcc/4.8.1/010-libgo-do-not-redefine-CPU_COUNT.patch
new file mode 100644
index 0000000..dc9817e
--- /dev/null
+++ b/patches/gcc/4.8.1/010-libgo-do-not-redefine-CPU_COUNT.patch
@@ -0,0 +1,32 @@ 
+From fe9d1f9b730f653039868515000a02cbb73e8941 Mon Sep 17 00:00:00 2001
+From: Bryan Hundven <bryanhundven@gmail.com>
+Date: Thu, 25 Sep 2014 18:54:06 -0700
+Subject: [PATCH] libgo/runtime: Only define CPU_COUNT if not already defined
+
+Modern LIBCs #define CPU_COUNT and CPU_COUNT_S in sched.h.
+Rather then checking the version or brand of LIBC, just check if
+CPU_COUNT is defined before redefining it.
+
+Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
+---
+ libgo/runtime/getncpu-linux.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libgo/runtime/getncpu-linux.c b/libgo/runtime/getncpu-linux.c
+index 0122b77..4aab58f 100644
+--- a/libgo/runtime/getncpu-linux.c
++++ b/libgo/runtime/getncpu-linux.c
+@@ -5,8 +5,8 @@
+ #include <features.h>
+ #include <sched.h>
+ 
+-// CPU_COUNT is only provided by glibc 2.6 or higher
+-#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 6)
++// Define CPU_COUNT if it isn't already.
++#if !defined(CPU_COUNT)
+ #define CPU_COUNT(set) _CPU_COUNT((unsigned int *)(set), sizeof(*(set))/sizeof(unsigned int))
+ static int _CPU_COUNT(unsigned int *set, size_t len) {
+ 	int cnt;
+-- 
+2.1.1
+
diff --git a/patches/gcc/4.8.2/010-libgo-do-not-redefine-CPU_COUNT.patch b/patches/gcc/4.8.2/010-libgo-do-not-redefine-CPU_COUNT.patch
new file mode 100644
index 0000000..dc9817e
--- /dev/null
+++ b/patches/gcc/4.8.2/010-libgo-do-not-redefine-CPU_COUNT.patch
@@ -0,0 +1,32 @@ 
+From fe9d1f9b730f653039868515000a02cbb73e8941 Mon Sep 17 00:00:00 2001
+From: Bryan Hundven <bryanhundven@gmail.com>
+Date: Thu, 25 Sep 2014 18:54:06 -0700
+Subject: [PATCH] libgo/runtime: Only define CPU_COUNT if not already defined
+
+Modern LIBCs #define CPU_COUNT and CPU_COUNT_S in sched.h.
+Rather then checking the version or brand of LIBC, just check if
+CPU_COUNT is defined before redefining it.
+
+Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
+---
+ libgo/runtime/getncpu-linux.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libgo/runtime/getncpu-linux.c b/libgo/runtime/getncpu-linux.c
+index 0122b77..4aab58f 100644
+--- a/libgo/runtime/getncpu-linux.c
++++ b/libgo/runtime/getncpu-linux.c
+@@ -5,8 +5,8 @@
+ #include <features.h>
+ #include <sched.h>
+ 
+-// CPU_COUNT is only provided by glibc 2.6 or higher
+-#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 6)
++// Define CPU_COUNT if it isn't already.
++#if !defined(CPU_COUNT)
+ #define CPU_COUNT(set) _CPU_COUNT((unsigned int *)(set), sizeof(*(set))/sizeof(unsigned int))
+ static int _CPU_COUNT(unsigned int *set, size_t len) {
+ 	int cnt;
+-- 
+2.1.1
+
diff --git a/patches/gcc/4.8.3/010-libgo-do-not-redefine-CPU_COUNT.patch b/patches/gcc/4.8.3/010-libgo-do-not-redefine-CPU_COUNT.patch
new file mode 100644
index 0000000..dc9817e
--- /dev/null
+++ b/patches/gcc/4.8.3/010-libgo-do-not-redefine-CPU_COUNT.patch
@@ -0,0 +1,32 @@ 
+From fe9d1f9b730f653039868515000a02cbb73e8941 Mon Sep 17 00:00:00 2001
+From: Bryan Hundven <bryanhundven@gmail.com>
+Date: Thu, 25 Sep 2014 18:54:06 -0700
+Subject: [PATCH] libgo/runtime: Only define CPU_COUNT if not already defined
+
+Modern LIBCs #define CPU_COUNT and CPU_COUNT_S in sched.h.
+Rather then checking the version or brand of LIBC, just check if
+CPU_COUNT is defined before redefining it.
+
+Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
+---
+ libgo/runtime/getncpu-linux.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libgo/runtime/getncpu-linux.c b/libgo/runtime/getncpu-linux.c
+index 0122b77..4aab58f 100644
+--- a/libgo/runtime/getncpu-linux.c
++++ b/libgo/runtime/getncpu-linux.c
+@@ -5,8 +5,8 @@
+ #include <features.h>
+ #include <sched.h>
+ 
+-// CPU_COUNT is only provided by glibc 2.6 or higher
+-#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 6)
++// Define CPU_COUNT if it isn't already.
++#if !defined(CPU_COUNT)
+ #define CPU_COUNT(set) _CPU_COUNT((unsigned int *)(set), sizeof(*(set))/sizeof(unsigned int))
+ static int _CPU_COUNT(unsigned int *set, size_t len) {
+ 	int cnt;
+-- 
+2.1.1
+
diff --git a/patches/gcc/4.9.0/010-libgo-do-not-redefine-CPU_COUNT.patch b/patches/gcc/4.9.0/010-libgo-do-not-redefine-CPU_COUNT.patch
new file mode 100644
index 0000000..dc9817e
--- /dev/null
+++ b/patches/gcc/4.9.0/010-libgo-do-not-redefine-CPU_COUNT.patch
@@ -0,0 +1,32 @@ 
+From fe9d1f9b730f653039868515000a02cbb73e8941 Mon Sep 17 00:00:00 2001
+From: Bryan Hundven <bryanhundven@gmail.com>
+Date: Thu, 25 Sep 2014 18:54:06 -0700
+Subject: [PATCH] libgo/runtime: Only define CPU_COUNT if not already defined
+
+Modern LIBCs #define CPU_COUNT and CPU_COUNT_S in sched.h.
+Rather then checking the version or brand of LIBC, just check if
+CPU_COUNT is defined before redefining it.
+
+Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
+---
+ libgo/runtime/getncpu-linux.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libgo/runtime/getncpu-linux.c b/libgo/runtime/getncpu-linux.c
+index 0122b77..4aab58f 100644
+--- a/libgo/runtime/getncpu-linux.c
++++ b/libgo/runtime/getncpu-linux.c
+@@ -5,8 +5,8 @@
+ #include <features.h>
+ #include <sched.h>
+ 
+-// CPU_COUNT is only provided by glibc 2.6 or higher
+-#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 6)
++// Define CPU_COUNT if it isn't already.
++#if !defined(CPU_COUNT)
+ #define CPU_COUNT(set) _CPU_COUNT((unsigned int *)(set), sizeof(*(set))/sizeof(unsigned int))
+ static int _CPU_COUNT(unsigned int *set, size_t len) {
+ 	int cnt;
+-- 
+2.1.1
+
diff --git a/patches/gcc/4.9.1/010-libgo-do-not-redefine-CPU_COUNT.patch b/patches/gcc/4.9.1/010-libgo-do-not-redefine-CPU_COUNT.patch
new file mode 100644
index 0000000..dc9817e
--- /dev/null
+++ b/patches/gcc/4.9.1/010-libgo-do-not-redefine-CPU_COUNT.patch
@@ -0,0 +1,32 @@ 
+From fe9d1f9b730f653039868515000a02cbb73e8941 Mon Sep 17 00:00:00 2001
+From: Bryan Hundven <bryanhundven@gmail.com>
+Date: Thu, 25 Sep 2014 18:54:06 -0700
+Subject: [PATCH] libgo/runtime: Only define CPU_COUNT if not already defined
+
+Modern LIBCs #define CPU_COUNT and CPU_COUNT_S in sched.h.
+Rather then checking the version or brand of LIBC, just check if
+CPU_COUNT is defined before redefining it.
+
+Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
+---
+ libgo/runtime/getncpu-linux.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libgo/runtime/getncpu-linux.c b/libgo/runtime/getncpu-linux.c
+index 0122b77..4aab58f 100644
+--- a/libgo/runtime/getncpu-linux.c
++++ b/libgo/runtime/getncpu-linux.c
+@@ -5,8 +5,8 @@
+ #include <features.h>
+ #include <sched.h>
+ 
+-// CPU_COUNT is only provided by glibc 2.6 or higher
+-#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 6)
++// Define CPU_COUNT if it isn't already.
++#if !defined(CPU_COUNT)
+ #define CPU_COUNT(set) _CPU_COUNT((unsigned int *)(set), sizeof(*(set))/sizeof(unsigned int))
+ static int _CPU_COUNT(unsigned int *set, size_t len) {
+ 	int cnt;
+-- 
+2.1.1
+