Module Name: src
Committed By: matt
Date: Fri May 29 19:38:59 UTC 2015
Modified Files:
src/sys/lib/libkern: libkern.h
Log Message:
If the platform support popcount as a __builtin, use that in preference
to the libc versions.
To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/lib/libkern/libkern.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/lib/libkern/libkern.h
diff -u src/sys/lib/libkern/libkern.h:1.119 src/sys/lib/libkern/libkern.h:1.120
--- src/sys/lib/libkern/libkern.h:1.119 Sat May 9 18:49:36 2015
+++ src/sys/lib/libkern/libkern.h Fri May 29 19:38:59 2015
@@ -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 snprintb_m(char *, size_t, const ch
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);