Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/lib/libkern If the platform support popcount as a __buil...



details:   https://anonhg.NetBSD.org/src/rev/f3941742ef14
branches:  trunk
changeset: 338548:f3941742ef14
user:      matt <matt%NetBSD.org@localhost>
date:      Fri May 29 19:38:59 2015 +0000

description:
If the platform support popcount as a __builtin, use that in preference
to the libc versions.

diffstat:

 sys/lib/libkern/libkern.h |  11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diffs (30 lines):

diff -r bef0c66c328a -r f3941742ef14 sys/lib/libkern/libkern.h
--- a/sys/lib/libkern/libkern.h Fri May 29 19:37:27 2015 +0000
+++ b/sys/lib/libkern/libkern.h Fri May 29 19:38:59 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: libkern.h,v 1.119 2015/05/09 18:49:36 christos Exp $   */
+/*     $NetBSD: libkern.h,v 1.120 2015/05/29 19:38:59 matt Exp $       */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -443,11 +443,20 @@
 int     kheapsort(void *, size_t, size_t, int (*)(const void *, const void *),
                   void *);
 uint32_t crc32(uint32_t, const uint8_t *, size_t);
+#if __GNUC_PREREQ__(4, 5) \
+    && (defined(__alpha_cix__) || defined(__mips_popcount))
+#define        popcount        __builtin_popcount
+#define        popcountl       __builtin_popcountl
+#define        popcountll      __builtin_popcountll
+#define        popcount32      __builtin_popcount
+#define        popcount64      __builtin_popcountll
+#else
 unsigned int   popcount(unsigned int) __constfunc;
 unsigned int   popcountl(unsigned long) __constfunc;
 unsigned int   popcountll(unsigned long long) __constfunc;
 unsigned int   popcount32(uint32_t) __constfunc;
 unsigned int   popcount64(uint64_t) __constfunc;
+#endif
 
 void   *explicit_memset(void *, int, size_t);
 int    consttime_memequal(const void *, const void *, size_t);



Home | Main Index | Thread Index | Old Index