This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.25-659-g8dc6133


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  8dc6133eff1c09382bc8f6f98c49fb807900eecd (commit)
      from  47ea614b9afcdaef80e09d58afcdad4f96ba3f15 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=8dc6133eff1c09382bc8f6f98c49fb807900eecd

commit 8dc6133eff1c09382bc8f6f98c49fb807900eecd
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Jul 1 07:29:19 2017 -0700

    Use __builtin_popcount in __sched_cpucount [BZ #21696]
    
    posix/sched_cpucount.c assumes that size of __cpu_mask == size of long,
    which is incorrect for x32.  This patch uses __builtin_popcount, which
    is availabe in GCC 4.9, in posix/sched_cpucount.c.
    
    Tested on i686, x86-64 and x32 with multi-arch disabled.
    
    	[BZ #21696]
    	* posix/sched_cpucount.c: Don't include <limits.h>.
    	(__sched_cpucount): Use __builtin_popcount.

diff --git a/ChangeLog b/ChangeLog
index 58ce877..4cd5d31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-07-01  Florian Weimer  <fweimer@redhat.com>
+	    H.J. Lu  <hongjiu.lu@intel.com>
+
+	[BZ #21696]
+	* posix/sched_cpucount.c: Don't include <limits.h>.
+	(__sched_cpucount): Use __builtin_popcount.
+
 2017-07-01  Ramana Radhakrishnan  <ramana.gcc@googlemail.com>
 
 	* sysdeps/unix/sysv/aarch64/cpu-features.c (init_cpu_features):
diff --git a/posix/sched_cpucount.c b/posix/sched_cpucount.c
index eaddf61..ab1ff49 100644
--- a/posix/sched_cpucount.c
+++ b/posix/sched_cpucount.c
@@ -15,7 +15,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <limits.h>
 #include <sched.h>
 
 
@@ -36,22 +35,16 @@ __sched_cpucount (size_t setsize, const cpu_set_t *setp)
       if (l == 0)
 	continue;
 
-# if LONG_BIT > 32
-      l = (l & 0x5555555555555555ul) + ((l >> 1) & 0x5555555555555555ul);
-      l = (l & 0x3333333333333333ul) + ((l >> 2) & 0x3333333333333333ul);
-      l = (l & 0x0f0f0f0f0f0f0f0ful) + ((l >> 4) & 0x0f0f0f0f0f0f0f0ful);
-      l = (l & 0x00ff00ff00ff00fful) + ((l >> 8) & 0x00ff00ff00ff00fful);
-      l = (l & 0x0000ffff0000fffful) + ((l >> 16) & 0x0000ffff0000fffful);
-      l = (l & 0x00000000fffffffful) + ((l >> 32) & 0x00000000fffffffful);
-# else
-      l = (l & 0x55555555ul) + ((l >> 1) & 0x55555555ul);
-      l = (l & 0x33333333ul) + ((l >> 2) & 0x33333333ul);
-      l = (l & 0x0f0f0f0ful) + ((l >> 4) & 0x0f0f0f0ful);
-      l = (l & 0x00ff00fful) + ((l >> 8) & 0x00ff00fful);
-      l = (l & 0x0000fffful) + ((l >> 16) & 0x0000fffful);
-# endif
-
-      s += l;
+      _Static_assert (sizeof (l) == sizeof (unsigned int)
+		      || sizeof (l) == sizeof (unsigned long)
+		      || sizeof (l) == sizeof (unsigned long long),
+		      "sizeof (__cpu_mask");
+      if (sizeof (__cpu_mask) == sizeof (unsigned int))
+	s += __builtin_popcount (l);
+      else if (sizeof (__cpu_mask) == sizeof (unsigned long))
+	s += __builtin_popcountl (l);
+      else
+	s += __builtin_popcountll (l);
 #endif
     }
 

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog              |    7 +++++++
 posix/sched_cpucount.c |   27 ++++++++++-----------------
 2 files changed, 17 insertions(+), 17 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]