Tue Jul 21 13:18:44 2009 UTC ()
Add popcount(3) and the long and long long version. Name is inspired by
gnulib, the implementation goes back to the AMD Software Optimizer
guide. A number of platforms will want to replace the C version with
assembler code using native instructions.


(joerg)
diff -r1.1284 -r1.1285 src/distrib/sets/lists/comp/mi
diff -r1.44 -r1.45 src/distrib/sets/lists/tests/mi
diff -r1.406 -r1.407 src/etc/mtree/NetBSD.dist
diff -r1.13 -r1.14 src/include/strings.h
diff -r1.72 -r1.73 src/lib/libc/string/Makefile.inc
diff -r0 -r1.1 src/lib/libc/string/popcount.3
diff -r0 -r1.1 src/lib/libc/string/popcount.c
diff -r0 -r1.1 src/lib/libc/string/popcountl.c
diff -r0 -r1.1 src/lib/libc/string/popcountll.c
diff -r1.1 -r1.2 src/tests/lib/libc/Atffile
diff -r1.1 -r1.2 src/tests/lib/libc/Makefile
diff -r0 -r1.1 src/tests/lib/libc/string/Atffile
diff -r0 -r1.1 src/tests/lib/libc/string/Makefile
diff -r0 -r1.1 src/tests/lib/libc/string/t_popcount.c

cvs diff -r1.1284 -r1.1285 src/distrib/sets/lists/comp/mi (expand / switch to unified diff)

--- src/distrib/sets/lists/comp/mi 2009/07/20 17:03:36 1.1284
+++ src/distrib/sets/lists/comp/mi 2009/07/21 13:18:43 1.1285
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: mi,v 1.1284 2009/07/20 17:03:36 joerg Exp $ 1# $NetBSD: mi,v 1.1285 2009/07/21 13:18:43 joerg Exp $
2# 2#
3# Note: don't delete entries from here - mark them as "obsolete" instead. 3# Note: don't delete entries from here - mark them as "obsolete" instead.
4# 4#
5./etc/mtree/set.comp comp-sys-root 5./etc/mtree/set.comp comp-sys-root
6./usr/bin/addr2line comp-debug-bin bfd 6./usr/bin/addr2line comp-debug-bin bfd
7./usr/bin/ar comp-util-bin bfd 7./usr/bin/ar comp-util-bin bfd
8./usr/bin/as comp-util-bin bfd 8./usr/bin/as comp-util-bin bfd
9./usr/bin/asa comp-fortran-bin 9./usr/bin/asa comp-fortran-bin
10./usr/bin/atf-compile comp-atf-bin 10./usr/bin/atf-compile comp-atf-bin
11./usr/bin/c++ comp-cxx-bin gcccmds 11./usr/bin/c++ comp-cxx-bin gcccmds
12./usr/bin/c++filt comp-cxx-bin bfd 12./usr/bin/c++filt comp-cxx-bin bfd
13./usr/bin/c89 comp-c-bin 13./usr/bin/c89 comp-c-bin
14./usr/bin/c99 comp-c-bin 14./usr/bin/c99 comp-c-bin
@@ -6932,26 +6932,29 @@ @@ -6932,26 +6932,29 @@
6932./usr/share/man/cat3/pcidev_conf_write.0 comp-c-catman .cat 6932./usr/share/man/cat3/pcidev_conf_write.0 comp-c-catman .cat
6933./usr/share/man/cat3/pclose.0 comp-c-catman .cat 6933./usr/share/man/cat3/pclose.0 comp-c-catman .cat
6934./usr/share/man/cat3/pechochar.0 comp-c-catman .cat 6934./usr/share/man/cat3/pechochar.0 comp-c-catman .cat
6935./usr/share/man/cat3/perror.0 comp-c-catman .cat 6935./usr/share/man/cat3/perror.0 comp-c-catman .cat
6936./usr/share/man/cat3/pidfile.0 comp-c-catman .cat 6936./usr/share/man/cat3/pidfile.0 comp-c-catman .cat
6937./usr/share/man/cat3/pidlock.0 comp-c-catman .cat 6937./usr/share/man/cat3/pidlock.0 comp-c-catman .cat
6938./usr/share/man/cat3/pmap_getmaps.0 comp-c-catman .cat 6938./usr/share/man/cat3/pmap_getmaps.0 comp-c-catman .cat
6939./usr/share/man/cat3/pmap_getport.0 comp-c-catman .cat 6939./usr/share/man/cat3/pmap_getport.0 comp-c-catman .cat
6940./usr/share/man/cat3/pmap_rmtcall.0 comp-c-catman .cat 6940./usr/share/man/cat3/pmap_rmtcall.0 comp-c-catman .cat
6941./usr/share/man/cat3/pmap_set.0 comp-c-catman .cat 6941./usr/share/man/cat3/pmap_set.0 comp-c-catman .cat
6942./usr/share/man/cat3/pmap_unset.0 comp-c-catman .cat 6942./usr/share/man/cat3/pmap_unset.0 comp-c-catman .cat
6943./usr/share/man/cat3/pmc.0 comp-c-catman .cat 6943./usr/share/man/cat3/pmc.0 comp-c-catman .cat
6944./usr/share/man/cat3/pnoutrefresh.0 comp-c-catman .cat 6944./usr/share/man/cat3/pnoutrefresh.0 comp-c-catman .cat
 6945./usr/share/man/cat3/popcount.0 comp-c-catman .cat
 6946./usr/share/man/cat3/popcountl.0 comp-c-catman .cat
 6947./usr/share/man/cat3/popcountll.0 comp-c-catman .cat
6945./usr/share/man/cat3/popen.0 comp-c-catman .cat 6948./usr/share/man/cat3/popen.0 comp-c-catman .cat
6946./usr/share/man/cat3/pos_form_cursor.0 comp-c-catman .cat 6949./usr/share/man/cat3/pos_form_cursor.0 comp-c-catman .cat
6947./usr/share/man/cat3/posix_memalign.0 comp-c-catman .cat 6950./usr/share/man/cat3/posix_memalign.0 comp-c-catman .cat
6948./usr/share/man/cat3/posix_openpt.0 comp-c-catman .cat 6951./usr/share/man/cat3/posix_openpt.0 comp-c-catman .cat
6949./usr/share/man/cat3/post_form.0 comp-c-catman .cat 6952./usr/share/man/cat3/post_form.0 comp-c-catman .cat
6950./usr/share/man/cat3/pow.0 comp-c-catman .cat 6953./usr/share/man/cat3/pow.0 comp-c-catman .cat
6951./usr/share/man/cat3/powf.0 comp-c-catman .cat 6954./usr/share/man/cat3/powf.0 comp-c-catman .cat
6952./usr/share/man/cat3/prefresh.0 comp-c-catman .cat 6955./usr/share/man/cat3/prefresh.0 comp-c-catman .cat
6953./usr/share/man/cat3/printf.0 comp-c-catman .cat 6956./usr/share/man/cat3/printf.0 comp-c-catman .cat
6954./usr/share/man/cat3/printw.0 comp-c-catman .cat 6957./usr/share/man/cat3/printw.0 comp-c-catman .cat
6955./usr/share/man/cat3/prop_array.0 comp-c-catman .cat 6958./usr/share/man/cat3/prop_array.0 comp-c-catman .cat
6956./usr/share/man/cat3/prop_array_add.0 comp-c-catman .cat 6959./usr/share/man/cat3/prop_array_add.0 comp-c-catman .cat
6957./usr/share/man/cat3/prop_array_capacity.0 comp-c-catman .cat 6960./usr/share/man/cat3/prop_array_capacity.0 comp-c-catman .cat
@@ -12389,26 +12392,29 @@ @@ -12389,26 +12392,29 @@
12389./usr/share/man/html3/pcidev_conf_write.html comp-c-htmlman html 12392./usr/share/man/html3/pcidev_conf_write.html comp-c-htmlman html
12390./usr/share/man/html3/pclose.html comp-c-htmlman html 12393./usr/share/man/html3/pclose.html comp-c-htmlman html
12391./usr/share/man/html3/pechochar.html comp-c-htmlman html 12394./usr/share/man/html3/pechochar.html comp-c-htmlman html
12392./usr/share/man/html3/perror.html comp-c-htmlman html 12395./usr/share/man/html3/perror.html comp-c-htmlman html
12393./usr/share/man/html3/pidfile.html comp-c-htmlman html 12396./usr/share/man/html3/pidfile.html comp-c-htmlman html
12394./usr/share/man/html3/pidlock.html comp-c-htmlman html 12397./usr/share/man/html3/pidlock.html comp-c-htmlman html
12395./usr/share/man/html3/pmap_getmaps.html comp-c-htmlman html 12398./usr/share/man/html3/pmap_getmaps.html comp-c-htmlman html
12396./usr/share/man/html3/pmap_getport.html comp-c-htmlman html 12399./usr/share/man/html3/pmap_getport.html comp-c-htmlman html
12397./usr/share/man/html3/pmap_rmtcall.html comp-c-htmlman html 12400./usr/share/man/html3/pmap_rmtcall.html comp-c-htmlman html
12398./usr/share/man/html3/pmap_set.html comp-c-htmlman html 12401./usr/share/man/html3/pmap_set.html comp-c-htmlman html
12399./usr/share/man/html3/pmap_unset.html comp-c-htmlman html 12402./usr/share/man/html3/pmap_unset.html comp-c-htmlman html
12400./usr/share/man/html3/pmc.html comp-c-htmlman html 12403./usr/share/man/html3/pmc.html comp-c-htmlman html
12401./usr/share/man/html3/pnoutrefresh.html comp-c-htmlman html 12404./usr/share/man/html3/pnoutrefresh.html comp-c-htmlman html
 12405./usr/share/man/html3/popcount.html comp-c-htmlman html
 12406./usr/share/man/html3/popcountl.html comp-c-htmlman html
 12407./usr/share/man/html3/popcountll.html comp-c-htmlman html
12402./usr/share/man/html3/popen.html comp-c-htmlman html 12408./usr/share/man/html3/popen.html comp-c-htmlman html
12403./usr/share/man/html3/pos_form_cursor.html comp-c-htmlman html 12409./usr/share/man/html3/pos_form_cursor.html comp-c-htmlman html
12404./usr/share/man/html3/posix_memalign.html comp-c-htmlman html 12410./usr/share/man/html3/posix_memalign.html comp-c-htmlman html
12405./usr/share/man/html3/posix_openpt.html comp-c-htmlman html 12411./usr/share/man/html3/posix_openpt.html comp-c-htmlman html
12406./usr/share/man/html3/post_form.html comp-c-htmlman html 12412./usr/share/man/html3/post_form.html comp-c-htmlman html
12407./usr/share/man/html3/pow.html comp-c-htmlman html 12413./usr/share/man/html3/pow.html comp-c-htmlman html
12408./usr/share/man/html3/powf.html comp-c-htmlman html 12414./usr/share/man/html3/powf.html comp-c-htmlman html
12409./usr/share/man/html3/prefresh.html comp-c-htmlman html 12415./usr/share/man/html3/prefresh.html comp-c-htmlman html
12410./usr/share/man/html3/printf.html comp-c-htmlman html 12416./usr/share/man/html3/printf.html comp-c-htmlman html
12411./usr/share/man/html3/printw.html comp-c-htmlman html 12417./usr/share/man/html3/printw.html comp-c-htmlman html
12412./usr/share/man/html3/prop_array.html comp-c-htmlman html 12418./usr/share/man/html3/prop_array.html comp-c-htmlman html
12413./usr/share/man/html3/prop_array_add.html comp-c-htmlman html 12419./usr/share/man/html3/prop_array_add.html comp-c-htmlman html
12414./usr/share/man/html3/prop_array_capacity.html comp-c-htmlman html 12420./usr/share/man/html3/prop_array_capacity.html comp-c-htmlman html
@@ -17840,26 +17846,29 @@ @@ -17840,26 +17846,29 @@
17840./usr/share/man/man3/pcidev_conf_write.3 comp-c-man .man 17846./usr/share/man/man3/pcidev_conf_write.3 comp-c-man .man
17841./usr/share/man/man3/pclose.3 comp-c-man .man 17847./usr/share/man/man3/pclose.3 comp-c-man .man
17842./usr/share/man/man3/pechochar.3 comp-c-man .man 17848./usr/share/man/man3/pechochar.3 comp-c-man .man
17843./usr/share/man/man3/perror.3 comp-c-man .man 17849./usr/share/man/man3/perror.3 comp-c-man .man
17844./usr/share/man/man3/pidfile.3 comp-c-man .man 17850./usr/share/man/man3/pidfile.3 comp-c-man .man
17845./usr/share/man/man3/pidlock.3 comp-c-man .man 17851./usr/share/man/man3/pidlock.3 comp-c-man .man
17846./usr/share/man/man3/pmap_getmaps.3 comp-c-man .man 17852./usr/share/man/man3/pmap_getmaps.3 comp-c-man .man
17847./usr/share/man/man3/pmap_getport.3 comp-c-man .man 17853./usr/share/man/man3/pmap_getport.3 comp-c-man .man
17848./usr/share/man/man3/pmap_rmtcall.3 comp-c-man .man 17854./usr/share/man/man3/pmap_rmtcall.3 comp-c-man .man
17849./usr/share/man/man3/pmap_set.3 comp-c-man .man 17855./usr/share/man/man3/pmap_set.3 comp-c-man .man
17850./usr/share/man/man3/pmap_unset.3 comp-c-man .man 17856./usr/share/man/man3/pmap_unset.3 comp-c-man .man
17851./usr/share/man/man3/pmc.3 comp-c-man .man 17857./usr/share/man/man3/pmc.3 comp-c-man .man
17852./usr/share/man/man3/pnoutrefresh.3 comp-c-man .man 17858./usr/share/man/man3/pnoutrefresh.3 comp-c-man .man
 17859./usr/share/man/man3/popcount.3 comp-c-man .man
 17860./usr/share/man/man3/popcountl.3 comp-c-man .man
 17861./usr/share/man/man3/popcountll.3 comp-c-man .man
17853./usr/share/man/man3/popen.3 comp-c-man .man 17862./usr/share/man/man3/popen.3 comp-c-man .man
17854./usr/share/man/man3/pos_form_cursor.3 comp-c-man .man 17863./usr/share/man/man3/pos_form_cursor.3 comp-c-man .man
17855./usr/share/man/man3/posix_memalign.3 comp-c-man .man 17864./usr/share/man/man3/posix_memalign.3 comp-c-man .man
17856./usr/share/man/man3/posix_openpt.3 comp-c-man .man 17865./usr/share/man/man3/posix_openpt.3 comp-c-man .man
17857./usr/share/man/man3/post_form.3 comp-c-man .man 17866./usr/share/man/man3/post_form.3 comp-c-man .man
17858./usr/share/man/man3/pow.3 comp-c-man .man 17867./usr/share/man/man3/pow.3 comp-c-man .man
17859./usr/share/man/man3/powf.3 comp-c-man .man 17868./usr/share/man/man3/powf.3 comp-c-man .man
17860./usr/share/man/man3/prefresh.3 comp-c-man .man 17869./usr/share/man/man3/prefresh.3 comp-c-man .man
17861./usr/share/man/man3/printf.3 comp-c-man .man 17870./usr/share/man/man3/printf.3 comp-c-man .man
17862./usr/share/man/man3/printw.3 comp-c-man .man 17871./usr/share/man/man3/printw.3 comp-c-man .man
17863./usr/share/man/man3/prop_array.3 comp-c-man .man 17872./usr/share/man/man3/prop_array.3 comp-c-man .man
17864./usr/share/man/man3/prop_array_add.3 comp-c-man .man 17873./usr/share/man/man3/prop_array_add.3 comp-c-man .man
17865./usr/share/man/man3/prop_array_capacity.3 comp-c-man .man 17874./usr/share/man/man3/prop_array_capacity.3 comp-c-man .man

cvs diff -r1.44 -r1.45 src/distrib/sets/lists/tests/mi (expand / switch to unified diff)

--- src/distrib/sets/lists/tests/mi 2009/07/20 17:03:36 1.44
+++ src/distrib/sets/lists/tests/mi 2009/07/21 13:18:43 1.45
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: mi,v 1.44 2009/07/20 17:03:36 joerg Exp $ 1# $NetBSD: mi,v 1.45 2009/07/21 13:18:43 joerg Exp $
2# 2#
3# Note: don't delete entries from here - mark them as "obsolete" instead. 3# Note: don't delete entries from here - mark them as "obsolete" instead.
4# 4#
5./etc/mtree/set.tests tests-sys-root 5./etc/mtree/set.tests tests-sys-root
6./usr/libdata/debug/usr/tests tests-base-debug 6./usr/libdata/debug/usr/tests tests-base-debug
7./usr/libdata/debug/usr/tests/atf tests-atf-debug 7./usr/libdata/debug/usr/tests/atf tests-atf-debug
8./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug 8./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug
9./usr/libdata/debug/usr/tests/atf/atf-c/h_check.debug tests-atf-debug debug 9./usr/libdata/debug/usr/tests/atf/atf-c/h_check.debug tests-atf-debug debug
10./usr/libdata/debug/usr/tests/atf/atf-c/t_check.debug tests-atf-debug debug 10./usr/libdata/debug/usr/tests/atf/atf-c/t_check.debug tests-atf-debug debug
11./usr/libdata/debug/usr/tests/atf/atf-c/t_config.debug tests-atf-debug debug 11./usr/libdata/debug/usr/tests/atf/atf-c/t_config.debug tests-atf-debug debug
12./usr/libdata/debug/usr/tests/atf/atf-c/t_dynstr.debug tests-atf-debug debug 12./usr/libdata/debug/usr/tests/atf/atf-c/t_dynstr.debug tests-atf-debug debug
13./usr/libdata/debug/usr/tests/atf/atf-c/t_env.debug tests-atf-debug debug 13./usr/libdata/debug/usr/tests/atf/atf-c/t_env.debug tests-atf-debug debug
14./usr/libdata/debug/usr/tests/atf/atf-c/t_error.debug tests-atf-debug debug 14./usr/libdata/debug/usr/tests/atf/atf-c/t_error.debug tests-atf-debug debug
@@ -126,26 +126,28 @@ @@ -126,26 +126,28 @@
126./usr/libdata/debug/usr/tests/kernel/t_lock.debug tests-kernel-tests debug 126./usr/libdata/debug/usr/tests/kernel/t_lock.debug tests-kernel-tests debug
127./usr/libdata/debug/usr/tests/kernel/t_lwpctl.debug tests-kernel-tests debug 127./usr/libdata/debug/usr/tests/kernel/t_lwpctl.debug tests-kernel-tests debug
128./usr/libdata/debug/usr/tests/kernel/t_mkdir.debug tests-kernel-tests debug 128./usr/libdata/debug/usr/tests/kernel/t_mkdir.debug tests-kernel-tests debug
129./usr/libdata/debug/usr/tests/kernel/t_pipe.debug tests-kernel-tests debug 129./usr/libdata/debug/usr/tests/kernel/t_pipe.debug tests-kernel-tests debug
130./usr/libdata/debug/usr/tests/kernel/t_poll3w.debug tests-kernel-tests debug 130./usr/libdata/debug/usr/tests/kernel/t_poll3w.debug tests-kernel-tests debug
131./usr/libdata/debug/usr/tests/kernel/t_posix_fadvise.debug tests-kernel-tests debug 131./usr/libdata/debug/usr/tests/kernel/t_posix_fadvise.debug tests-kernel-tests debug
132./usr/libdata/debug/usr/tests/kernel/t_time.debug tests-kernel-tests debug 132./usr/libdata/debug/usr/tests/kernel/t_time.debug tests-kernel-tests debug
133./usr/libdata/debug/usr/tests/kernel/t_ucontext.debug tests-kernel-tests debug 133./usr/libdata/debug/usr/tests/kernel/t_ucontext.debug tests-kernel-tests debug
134./usr/libdata/debug/usr/tests/kernel/t_writev.debug tests-kernel-tests debug 134./usr/libdata/debug/usr/tests/kernel/t_writev.debug tests-kernel-tests debug
135./usr/libdata/debug/usr/tests/lib tests-lib-debug 135./usr/libdata/debug/usr/tests/lib tests-lib-debug
136./usr/libdata/debug/usr/tests/lib/libc tests-lib-debug 136./usr/libdata/debug/usr/tests/lib/libc tests-lib-debug
137./usr/libdata/debug/usr/tests/lib/libc/stdlib tests-lib-debug 137./usr/libdata/debug/usr/tests/lib/libc/stdlib tests-lib-debug
138./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_mi_vector_hash.debug tests-lib-debug debug 138./usr/libdata/debug/usr/tests/lib/libc/stdlib/t_mi_vector_hash.debug tests-lib-debug debug
 139./usr/libdata/debug/usr/tests/lib/libc/string tests-lib-debug debug
 140./usr/libdata/debug/usr/tests/lib/libc/string/t_popcount.debug tests-lib-debug debug
139./usr/libdata/debug/usr/tests/modules tests-sys-debug 141./usr/libdata/debug/usr/tests/modules tests-sys-debug
140./usr/libdata/debug/usr/tests/modules/t_modctl.debug tests-sys-debug debug 142./usr/libdata/debug/usr/tests/modules/t_modctl.debug tests-sys-debug debug
141./usr/libdata/debug/usr/tests/net tests-net-debug 143./usr/libdata/debug/usr/tests/net tests-net-debug
142./usr/libdata/debug/usr/tests/net/sys tests-net-debug 144./usr/libdata/debug/usr/tests/net/sys tests-net-debug
143./usr/libdata/debug/usr/tests/net/sys/t_connect.debug tests-net-debug debug 145./usr/libdata/debug/usr/tests/net/sys/t_connect.debug tests-net-debug debug
144./usr/libdata/debug/usr/tests/net/sys/t_listen.debug tests-net-debug debug 146./usr/libdata/debug/usr/tests/net/sys/t_listen.debug tests-net-debug debug
145./usr/libdata/debug/usr/tests/rump tests-syscall-debug 147./usr/libdata/debug/usr/tests/rump tests-syscall-debug
146./usr/libdata/debug/usr/tests/rump/rumpkern tests-syscall-debug 148./usr/libdata/debug/usr/tests/rump/rumpkern tests-syscall-debug
147./usr/libdata/debug/usr/tests/rump/rumpkern/t_modcmd.debug tests-syscall-debug debug 149./usr/libdata/debug/usr/tests/rump/rumpkern/t_modcmd.debug tests-syscall-debug debug
148./usr/libdata/debug/usr/tests/syscall tests-syscall-debug 150./usr/libdata/debug/usr/tests/syscall tests-syscall-debug
149./usr/libdata/debug/usr/tests/syscall/t_cmsg.debug tests-syscall-debug debug 151./usr/libdata/debug/usr/tests/syscall/t_cmsg.debug tests-syscall-debug debug
150./usr/libdata/debug/usr/tests/util tests-util-debug 152./usr/libdata/debug/usr/tests/util tests-util-debug
151./usr/libdata/debug/usr/tests/util/df tests-util-debug 153./usr/libdata/debug/usr/tests/util/df tests-util-debug
@@ -837,26 +839,29 @@ @@ -837,26 +839,29 @@
837./usr/tests/kernel/t_poll3w tests-kernel-tests 839./usr/tests/kernel/t_poll3w tests-kernel-tests
838./usr/tests/kernel/t_posix_fadvise tests-kernel-tests 840./usr/tests/kernel/t_posix_fadvise tests-kernel-tests
839./usr/tests/kernel/t_time tests-kernel-tests 841./usr/tests/kernel/t_time tests-kernel-tests
840./usr/tests/kernel/t_ucontext tests-kernel-tests 842./usr/tests/kernel/t_ucontext tests-kernel-tests
841./usr/tests/kernel/t_umount tests-kernel-tests 843./usr/tests/kernel/t_umount tests-kernel-tests
842./usr/tests/kernel/t_writev tests-kernel-tests 844./usr/tests/kernel/t_writev tests-kernel-tests
843./usr/tests/lib tests-lib-tests 845./usr/tests/lib tests-lib-tests
844./usr/tests/lib/Atffile tests-lib-tests 846./usr/tests/lib/Atffile tests-lib-tests
845./usr/tests/lib/libc tests-lib-tests 847./usr/tests/lib/libc tests-lib-tests
846./usr/tests/lib/libc/Atffile tests-lib-tests 848./usr/tests/lib/libc/Atffile tests-lib-tests
847./usr/tests/lib/libc/stdlib tests-lib-tests 849./usr/tests/lib/libc/stdlib tests-lib-tests
848./usr/tests/lib/libc/stdlib/Atffile tests-lib-tests 850./usr/tests/lib/libc/stdlib/Atffile tests-lib-tests
849./usr/tests/lib/libc/stdlib/t_mi_vector_hash tests-lib-tests 851./usr/tests/lib/libc/stdlib/t_mi_vector_hash tests-lib-tests
 852./usr/tests/lib/libc/string tests-lib-tests
 853./usr/tests/lib/libc/string/Atffile tests-lib-tests
 854./usr/tests/lib/libc/string/t_popcount tests-lib-tests
850./usr/tests/modules tests-sys-tests 855./usr/tests/modules tests-sys-tests
851./usr/tests/modules/Atffile tests-sys-tests 856./usr/tests/modules/Atffile tests-sys-tests
852./usr/tests/net tests-net-tests 857./usr/tests/net tests-net-tests
853./usr/tests/net/Atffile tests-net-tests 858./usr/tests/net/Atffile tests-net-tests
854./usr/tests/net/sys tests-net-tests 859./usr/tests/net/sys tests-net-tests
855./usr/tests/net/sys/Atffile tests-net-tests 860./usr/tests/net/sys/Atffile tests-net-tests
856./usr/tests/net/sys/t_connect tests-net-tests 861./usr/tests/net/sys/t_connect tests-net-tests
857./usr/tests/net/sys/t_listen tests-net-tests 862./usr/tests/net/sys/t_listen tests-net-tests
858./usr/tests/rump tests-rump-tests 863./usr/tests/rump tests-rump-tests
859./usr/tests/rump/Atffile tests-rump-tests 864./usr/tests/rump/Atffile tests-rump-tests
860./usr/tests/rump/rumpkern tests-rump-tests 865./usr/tests/rump/rumpkern tests-rump-tests
861./usr/tests/rump/rumpkern/Atffile tests-rump-tests 866./usr/tests/rump/rumpkern/Atffile tests-rump-tests
862./usr/tests/rump/rumpkern/t_modcmd tests-rump-tests 867./usr/tests/rump/rumpkern/t_modcmd tests-rump-tests

cvs diff -r1.406 -r1.407 src/etc/mtree/Attic/NetBSD.dist (expand / switch to unified diff)

--- src/etc/mtree/Attic/NetBSD.dist 2009/07/20 17:03:37 1.406
+++ src/etc/mtree/Attic/NetBSD.dist 2009/07/21 13:18:43 1.407
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: NetBSD.dist,v 1.406 2009/07/20 17:03:37 joerg Exp $ 1# $NetBSD: NetBSD.dist,v 1.407 2009/07/21 13:18:43 joerg Exp $
2# @(#)4.4BSD.dist 8.1 (Berkeley) 6/13/93 2# @(#)4.4BSD.dist 8.1 (Berkeley) 6/13/93
3 3
4# Do not customize this file as it may be overwritten on upgrades. 4# Do not customize this file as it may be overwritten on upgrades.
5# Put your custom specifications in /etc/mtree/special.local. 5# Put your custom specifications in /etc/mtree/special.local.
6# See security.conf(5) for details. 6# See security.conf(5) for details.
7 7
8/set type=dir uname=root gname=wheel mode=0755 8/set type=dir uname=root gname=wheel mode=0755
9 9
10. 10.
11./altroot 11./altroot
12./bin 12./bin
13./dev 13./dev
14./dev/altq 14./dev/altq
@@ -1427,26 +1427,27 @@ @@ -1427,26 +1427,27 @@
1427./usr/tests/fs/tmpfs 1427./usr/tests/fs/tmpfs
1428./usr/tests/games 1428./usr/tests/games
1429./usr/tests/ipf 1429./usr/tests/ipf
1430./usr/tests/ipf/expected 1430./usr/tests/ipf/expected
1431./usr/tests/ipf/input 1431./usr/tests/ipf/input
1432./usr/tests/ipf/regress 1432./usr/tests/ipf/regress
1433./usr/tests/kernel 1433./usr/tests/kernel
1434./usr/tests/kernel/kqueue 1434./usr/tests/kernel/kqueue
1435./usr/tests/kernel/kqueue/read 1435./usr/tests/kernel/kqueue/read
1436./usr/tests/kernel/kqueue/write 1436./usr/tests/kernel/kqueue/write
1437./usr/tests/lib 1437./usr/tests/lib
1438./usr/tests/lib/libc 1438./usr/tests/lib/libc
1439./usr/tests/lib/libc/stdlib 1439./usr/tests/lib/libc/stdlib
 1440./usr/tests/lib/libc/string
1440./usr/tests/modules 1441./usr/tests/modules
1441./usr/tests/net 1442./usr/tests/net
1442./usr/tests/net/sys 1443./usr/tests/net/sys
1443./usr/tests/rump 1444./usr/tests/rump
1444./usr/tests/rump/rumpkern 1445./usr/tests/rump/rumpkern
1445./usr/tests/syscall 1446./usr/tests/syscall
1446./usr/tests/util 1447./usr/tests/util
1447./usr/tests/util/awk 1448./usr/tests/util/awk
1448./usr/tests/util/bzip2 1449./usr/tests/util/bzip2
1449./usr/tests/util/config 1450./usr/tests/util/config
1450./usr/tests/util/config/support 1451./usr/tests/util/config/support
1451./usr/tests/util/config/support/arch 1452./usr/tests/util/config/support/arch
1452./usr/tests/util/config/support/arch/regress 1453./usr/tests/util/config/support/arch/regress

cvs diff -r1.13 -r1.14 src/include/strings.h (expand / switch to unified diff)

--- src/include/strings.h 2008/04/28 20:22:54 1.13
+++ src/include/strings.h 2009/07/21 13:18:43 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: strings.h,v 1.13 2008/04/28 20:22:54 martin Exp $ */ 1/* $NetBSD: strings.h,v 1.14 2009/07/21 13:18:43 joerg Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Klaus Klein. 8 * by Klaus Klein.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -42,26 +42,29 @@ typedef _BSD_SIZE_T_ size_t; @@ -42,26 +42,29 @@ typedef _BSD_SIZE_T_ size_t;
42 42
43#if defined(_NETBSD_SOURCE) 43#if defined(_NETBSD_SOURCE)
44#include <sys/null.h> 44#include <sys/null.h>
45#endif 45#endif
46 46
47#include <sys/cdefs.h> 47#include <sys/cdefs.h>
48 48
49__BEGIN_DECLS 49__BEGIN_DECLS
50int bcmp(const void *, const void *, size_t); 50int bcmp(const void *, const void *, size_t);
51void bcopy(const void *, void *, size_t); 51void bcopy(const void *, void *, size_t);
52void bzero(void *, size_t); 52void bzero(void *, size_t);
53int ffs(int); 53int ffs(int);
54char *index(const char *, int); 54char *index(const char *, int);
 55unsigned int popcount(unsigned int) __constfunc;
 56unsigned int popcountl(unsigned long) __constfunc;
 57unsigned int popcountll(unsigned long long) __constfunc;
55char *rindex(const char *, int); 58char *rindex(const char *, int);
56int strcasecmp(const char *, const char *); 59int strcasecmp(const char *, const char *);
57int strncasecmp(const char *, const char *, size_t); 60int strncasecmp(const char *, const char *, size_t);
58__END_DECLS 61__END_DECLS
59 62
60#if defined(_NETBSD_SOURCE) 63#if defined(_NETBSD_SOURCE)
61#include <string.h> 64#include <string.h>
62#endif 65#endif
63 66
64#if _FORTIFY_SOURCE > 0 67#if _FORTIFY_SOURCE > 0
65#include <ssp/strings.h> 68#include <ssp/strings.h>
66#endif 69#endif
67#endif /* !defined(_STRINGS_H_) */ 70#endif /* !defined(_STRINGS_H_) */

cvs diff -r1.72 -r1.73 src/lib/libc/string/Makefile.inc (expand / switch to unified diff)

--- src/lib/libc/string/Makefile.inc 2009/07/18 09:41:23 1.72
+++ src/lib/libc/string/Makefile.inc 2009/07/21 13:18:43 1.73
@@ -1,20 +1,20 @@ @@ -1,20 +1,20 @@
1# from: @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 1# from: @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
2# $NetBSD: Makefile.inc,v 1.72 2009/07/18 09:41:23 dsl Exp $ 2# $NetBSD: Makefile.inc,v 1.73 2009/07/21 13:18:43 joerg Exp $
3 3
4# string sources 4# string sources
5.PATH: ${ARCHDIR}/string ${.CURDIR}/string 5.PATH: ${ARCHDIR}/string ${.CURDIR}/string
6 6
7SRCS+= bm.c stpcpy.c stpncpy.c \ 7SRCS+= bm.c popcountl.c stpcpy.c stpncpy.c \
8 strcasecmp.c strncasecmp.c strcasestr.c strcoll.c strdup.c \ 8 strcasecmp.c strncasecmp.c strcasestr.c strcoll.c strdup.c \
9 strerror.c strlcat.c strlcpy.c strnlen.c \ 9 strerror.c strlcat.c strlcpy.c strnlen.c \
10 strmode.c strsignal.c strtok.c \ 10 strmode.c strsignal.c strtok.c \
11 strtok_r.c strxfrm.c __strsignal.c strerror_r.c strndup.c \ 11 strtok_r.c strxfrm.c __strsignal.c strerror_r.c strndup.c \
12 stresep.c memrchr.c 12 stresep.c memrchr.c
13 13
14# wide char 14# wide char
15SRCS+= wcscat.c wcschr.c wcscmp.c wcscpy.c wcscspn.c wcslcat.c wcslcpy.c \ 15SRCS+= wcscat.c wcschr.c wcscmp.c wcscpy.c wcscspn.c wcslcat.c wcslcpy.c \
16 wcslen.c wcsncat.c wcscasecmp.c wcsdup.c wcsncasecmp.c \ 16 wcslen.c wcsncat.c wcscasecmp.c wcsdup.c wcsncasecmp.c \
17 wcsncmp.c wcsncpy.c wcspbrk.c wcsrchr.c wcsspn.c wcsstr.c wcstok.c \ 17 wcsncmp.c wcsncpy.c wcspbrk.c wcsrchr.c wcsspn.c wcsstr.c wcstok.c \
18 wcswcs.c wmemchr.c wmemcmp.c wmemcpy.c wmemmove.c wmemset.c 18 wcswcs.c wmemchr.c wmemcmp.c wmemcpy.c wmemmove.c wmemset.c
19CPPFLAGS.wcscmp.c+= -I${LIBCDIR}/locale 19CPPFLAGS.wcscmp.c+= -I${LIBCDIR}/locale
20CPPFLAGS.wcsncmp.c+= -I${LIBCDIR}/locale 20CPPFLAGS.wcsncmp.c+= -I${LIBCDIR}/locale
@@ -45,36 +45,45 @@ SRCS+= memcpy.c @@ -45,36 +45,45 @@ SRCS+= memcpy.c
45.endif 45.endif
46.if empty(SRCS:Mmemmem.S) 46.if empty(SRCS:Mmemmem.S)
47SRCS+= memmem.c 47SRCS+= memmem.c
48.endif 48.endif
49.if empty(SRCS:Mmemmove.S) 49.if empty(SRCS:Mmemmove.S)
50SRCS+= memmove.c 50SRCS+= memmove.c
51.endif 51.endif
52.if empty(SRCS:Mstrchr.S) 52.if empty(SRCS:Mstrchr.S)
53SRCS+= strchr.c 53SRCS+= strchr.c
54.endif 54.endif
55.if empty(SRCS:Mstrrchr.S) 55.if empty(SRCS:Mstrrchr.S)
56SRCS+= strrchr.c 56SRCS+= strrchr.c
57.endif 57.endif
 58.if empty(SRCS:Mpopcount.S)
 59SRCS+= popcount.c
 60.endif
 61.if empty(SRCS:Mpopcountll.S)
 62SRCS+= popcountll.c
 63.endif
58 64
59MAN+= bm.3 bcmp.3 bcopy.3 bstring.3 bzero.3 ffs.3 index.3 \ 65MAN+= bm.3 bcmp.3 bcopy.3 bstring.3 bzero.3 ffs.3 index.3 \
60 memccpy.3 memchr.3 memcmp.3 memcpy.3 memmem.3 memmove.3 memset.3 \ 66 memccpy.3 memchr.3 memcmp.3 memcpy.3 memmem.3 memmove.3 memset.3 \
 67 popcount.3 \
61 rindex.3 strcasecmp.3 strcat.3 strchr.3 strcmp.3 strcoll.3 \ 68 rindex.3 strcasecmp.3 strcat.3 strchr.3 strcmp.3 strcoll.3 \
62 strcpy.3 strcspn.3 strdup.3 strerror.3 string.3 strings.3 strlcpy.3 \ 69 strcpy.3 strcspn.3 strdup.3 strerror.3 string.3 strings.3 strlcpy.3 \
63 strlen.3 strmode.3 strpbrk.3 strrchr.3 strsep.3 \ 70 strlen.3 strmode.3 strpbrk.3 strrchr.3 strsep.3 \
64 strsignal.3 strspn.3 strstr.3 strtok.3 strxfrm.3 \ 71 strsignal.3 strspn.3 strstr.3 strtok.3 strxfrm.3 \
65 swab.3 wcstok.3 wcswidth.3 wmemchr.3 wcsdup.3 wcscasecmp.3 72 swab.3 wcstok.3 wcswidth.3 wmemchr.3 wcsdup.3 wcscasecmp.3
66 73
67MLINKS+=bm.3 bm_comp.3 bm.3 bm_exec.3 bm.3 bm_free.3 74MLINKS+=bm.3 bm_comp.3 bm.3 bm_exec.3 bm.3 bm_free.3
 75MLINKS+=popcount.3 popcountl.3
 76MLINKS+=popcount.3 popcountll.3
68MLINKS+=strcasecmp.3 strncasecmp.3 77MLINKS+=strcasecmp.3 strncasecmp.3
69MLINKS+=strcat.3 strncat.3 78MLINKS+=strcat.3 strncat.3
70MLINKS+=strcmp.3 strncmp.3 79MLINKS+=strcmp.3 strncmp.3
71MLINKS+=strcpy.3 strncpy.3 strcpy.3 stpcpy.3 strcpy.3 stpncpy.3 80MLINKS+=strcpy.3 strncpy.3 strcpy.3 stpcpy.3 strcpy.3 stpncpy.3
72MLINKS+=strlcpy.3 strlcat.3 81MLINKS+=strlcpy.3 strlcat.3
73MLINKS+=strlen.3 strnlen.3 82MLINKS+=strlen.3 strnlen.3
74MLINKS+=strstr.3 strcasestr.3 83MLINKS+=strstr.3 strcasestr.3
75MLINKS+=memchr.3 memrchr.3 84MLINKS+=memchr.3 memrchr.3
76MLINKS+=strtok.3 strtok_r.3 85MLINKS+=strtok.3 strtok_r.3
77MLINKS+=strerror.3 strerror_r.3 strerror.3 perror.3 \ 86MLINKS+=strerror.3 strerror_r.3 strerror.3 perror.3 \
78 strerror.3 sys_errlist.3 strerror.3 sys_nerr.3 87 strerror.3 sys_errlist.3 strerror.3 sys_nerr.3
79MLINKS+=strdup.3 strndup.3 88MLINKS+=strdup.3 strndup.3
80MLINKS+=strsep.3 stresep.3 89MLINKS+=strsep.3 stresep.3

File Added: src/lib/libc/string/popcount.3
.\"	$NetBSD: popcount.3,v 1.1 2009/07/21 13:18:44 joerg Exp $
.\"
.\" Copyright (c) 2009 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Joerg Sonnenberger.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd July 13, 2009
.Dt POPCOUNT 3
.Os
.Sh NAME
.Nm popcount ,
.Nm popcountl ,
.Nm popcountll
.Nd count number of bits set in a bit string
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In strings.h
.Ft unsigned int
.Fn popcount "unsigned int value"
.Ft unsigned int
.Fn popcountl "unsigned long value"
.Ft unsigned int
.Fn popcountl "unsigned long long value"
.Sh DESCRIPTION
The
.Nm
functions returns the number of bits set in
.Fa value .
.Sh SEE ALSO
.Xr ffs 3
.Sh HISTORY
The
.Fn popcount ,
.Fn popcountl
and
.Fn popcountll
functions appeared in
.Nx 6.0 .

File Added: src/lib/libc/string/Attic/popcount.c
/*	$NetBSD: popcount.c,v 1.1 2009/07/21 13:18:44 joerg Exp $	*/
/*-
 * Copyright (c) 2009 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Joerg Sonnenberger.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#include <sys/cdefs.h>
__RCSID("$NetBSD: popcount.c,v 1.1 2009/07/21 13:18:44 joerg Exp $");

#include <limits.h>
#include <strings.h>

#if UINT_MAX > 0xffffffffUL
#error "Unsupported architecture"
#endif

/*
 * This a hybrid algorithm for bit counting between parallel counting and
 * using multiplication.  The idea is to sum up the bits in each Byte, so
 * that the final accumulation can be done with a single multiplication.
 * If the platform has a slow multiplication instruction, it can be replaced
 * by the commented out version below.
 */

unsigned int
popcount(unsigned int v)
{
	unsigned int c;

	v = v - ((v >> 1) & 0x55555555U);
	v = (v & 0x33333333U) + ((v >> 2) & 0x33333333U);
	v = ((v + (v >> 4)) & 0x0f0f0f0fU;
	c = (v * 0x01010101U) >> 24;
	/*
	 * v = (v >> 16) + v;
	 * v = (v >> 8) + v;
	 * c = v & 255;
	 */

	return c;
}

File Added: src/lib/libc/string/Attic/popcountl.c
/*	$NetBSD: popcountl.c,v 1.1 2009/07/21 13:18:44 joerg Exp $	*/
/*-
 * Copyright (c) 2009 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Joerg Sonnenberger.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#include <sys/cdefs.h>
__RCSID("$NetBSD: popcountl.c,v 1.1 2009/07/21 13:18:44 joerg Exp $");

#include <limits.h>
#include <strings.h>

#if ULONG_MAX == UINT_MAX
__strong_alias(popcountl, popcount);
#elif ULONG_MAX == ULLONG_MAX
__strong_alias(popcountll, popcount);
#else
#error "Unsupporting architecture"
#endif

File Added: src/lib/libc/string/Attic/popcountll.c
/*	$NetBSD: popcountll.c,v 1.1 2009/07/21 13:18:44 joerg Exp $	*/
/*-
 * Copyright (c) 2009 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Joerg Sonnenberger.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#include <sys/cdefs.h>
__RCSID("$NetBSD: popcountll.c,v 1.1 2009/07/21 13:18:44 joerg Exp $");

#include <strings.h>

#if ULONGLONG_MAX > 0xffffffffffffffffULL
#error "Unsupported architecture"
#endif

/*
 * If unsigned long long is larger than size_t, the follow assumes that
 * splitting into 32bit halfes is faster.
 *
 * The native pocountll version is based on the same ideas as popcount(3),
 * see popcount.c for comments.
 */

#if ULONGLONG_MAX > SIZE_MAX
unsigned int
popcountll(unsigned long long v)
{
	return popcount(v >> 32) + popcount(v & 0xffffffffU);
}
#else
unsigned int
popcountll(unsigned long long v)
{
	unsigned int c;

	v = v - ((v >> 1) & 0x5555555555555555ULL);
	v = (v & 0x3333333333333333ULL) + ((v >> 2) & 0x3333333333333333ULL);
	v = ((v + (v >> 4)) & 0x0f0f0f0f0f0f0f0fULL) * 0x0101010101010101ULL;
	c = v >> 56;

	return c;
}
#endif

cvs diff -r1.1 -r1.2 src/tests/lib/libc/Attic/Atffile (expand / switch to unified diff)

--- src/tests/lib/libc/Attic/Atffile 2009/07/20 17:03:38 1.1
+++ src/tests/lib/libc/Attic/Atffile 2009/07/21 13:18:44 1.2
@@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
1Content-Type: application/X-atf-atffile; version="1" 1Content-Type: application/X-atf-atffile; version="1"
2 2
3prop: test-suite = "NetBSD" 3prop: test-suite = "NetBSD"
4 4
5tp: stdlib 5tp: stdlib
 6tp: string

cvs diff -r1.1 -r1.2 src/tests/lib/libc/Makefile (expand / switch to unified diff)

--- src/tests/lib/libc/Makefile 2009/07/20 17:03:38 1.1
+++ src/tests/lib/libc/Makefile 2009/07/21 13:18:44 1.2
@@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
1# $NetBSD: Makefile,v 1.1 2009/07/20 17:03:38 joerg Exp $ 1# $NetBSD: Makefile,v 1.2 2009/07/21 13:18:44 joerg Exp $
2 2
3.include <bsd.own.mk> 3.include <bsd.own.mk>
4 4
5SUBDIR+= stdlib 5SUBDIR+= stdlib string
6 6
7TESTSDIR= ${TESTSBASE}/lib/libc 7TESTSDIR= ${TESTSBASE}/lib/libc
8 8
9.include <bsd.subdir.mk> 9.include <bsd.subdir.mk>
10.include <bsd.test.mk> 10.include <bsd.test.mk>

File Added: src/tests/lib/libc/string/Attic/Atffile
Content-Type: application/X-atf-atffile; version="1"
X-NetBSD-Id: "$NetBSD: Atffile,v 1.1 2009/07/21 13:18:44 joerg Exp $"

prop: test-suite = "NetBSD"

tp: t_popcount

File Added: src/tests/lib/libc/string/Makefile
# $NetBSD: Makefile,v 1.1 2009/07/21 13:18:44 joerg Exp $

.include <bsd.own.mk>

TESTSDIR=	${TESTSBASE}/lib/libc/string

TESTS_C+=	t_popcount

.include <bsd.test.mk>

File Added: src/tests/lib/libc/string/t_popcount.c
/*	$NetBSD: t_popcount.c,v 1.1 2009/07/21 13:18:44 joerg Exp $	*/
/*-
 * Copyright (c) 2009 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Joerg Sonnenberger.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#include <sys/cdefs.h>
__RCSID("$NetBSD: t_popcount.c,v 1.1 2009/07/21 13:18:44 joerg Exp $");

#include <atf-c.h>
#include <strings.h>

static unsigned int byte_count[256];

static void
popcount_init(void)
{
	unsigned int i, j;

	for (i = 0; i < 256; ++i) {
		byte_count[i] = 0;
		for (j = i; j != 0; j >>= 1) {
			if (j & 1)
				++byte_count[i];
		}
	}
}

unsigned int test_parts[256] = {
	0x318e53e6U, 0x11710316U, 0x62608ffaU, 0x67e0f562U, 
	0xe432e82cU, 0x9862e8b2U, 0x7d96a627U, 0x3f74ad31U, 
	0x3cecf906U, 0xcdc0dcb4U, 0x241dab64U, 0x31e6133eU, 
	0x23086ad4U, 0x721d5a91U, 0xc483da53U, 0x6a62af52U, 
	0xf3f5c386U, 0xe0de3f77U, 0x65afe528U, 0xf4816485U, 
	0x40ccbf08U, 0x25df49c1U, 0xae5a6ee0U, 0xab36ccadU, 
	0x87e1ec29U, 0x60ca2407U, 0x49d62e47U, 0xa09f2df5U, 
	0xaf4c1c68U, 0x8ef08d50U, 0x624cfd2fU, 0xa6a36f20U, 
	0x68aaf879U, 0x0fe9deabU, 0x5c9a4060U, 0x215d8f08U, 
	0x55e84712U, 0xea1f1681U, 0x3a10b8a1U, 0x08e06632U, 
	0xcbc875e2U, 0x31e53258U, 0xcd3807a4U, 0xb9d17516U, 
	0x8fbfd9abU, 0x6651b555U, 0x550fb381U, 0x05061b9dU, 
	0x35aef3f2U, 0x9175078cU, 0xae0f14daU, 0x92a2d5f8U, 
	0x70d968feU, 0xe86f41c5U, 0x5cfaf39fU, 0x8499b18dU, 
	0xb33f879aU, 0x0a68ad3dU, 0x9323ecc1U, 0x060037ddU, 
	0xb91a5051U, 0xa0dbebf6U, 0x3e6aa6f1U, 0x7b422b5bU, 
	0x599e811eU, 0x199f7594U, 0xca453365U, 0x1cda6f48U, 
	0xe9c75d2cU, 0x6a873217U, 0x79c45d72U, 0x143b8e37U, 
	0xa11df26eU, 0xaf31f80aU, 0x311bf759U, 0x2378563cU, 
	0x9ab95fa5U, 0xfcf4d47cU, 0x1f7db268U, 0xd64b09e1U, 
	0xad7936daU, 0x7a59005cU, 0x45b173d3U, 0xc1a71b32U, 
	0x7d9f0de2U, 0xa9ac3792U, 0x9e7f9966U, 0x7f0b8080U, 
	0xece6c06fU, 0x78d92a3cU, 0x6d5f8f6cU, 0xc50ca544U, 
	0x5d8ded27U, 0xd27a8462U, 0x4bcd13ccU, 0xd49075f2U, 
	0xa8d52acfU, 0x41915d97U, 0x564f7062U, 0xefb046e2U, 
	0xe296277aU, 0x605b0ea3U, 0x10b2c3a1U, 0x4e8e5c66U, 
	0x4bd8ec04U, 0x29935be9U, 0x381839f3U, 0x555d8824U, 
	0xd6befddbU, 0x5d8d6d6eU, 0xb2fdb7b4U, 0xb471c8fcU, 
	0xc2fd325bU, 0x932d2487U, 0xbdbbadefU, 0x66c8895dU, 
	0x5d77857aU, 0x259f1cc0U, 0x302037faU, 0xda9aa7a8U, 
	0xb112c6aaU, 0x78f74192U, 0xfd4da741U, 0xfa5765c1U, 
	0x6ea1bc5cU, 0xd283f39cU, 0x268ae67dU, 0xdedcd134U, 
	0xbbf92410U, 0x6b45fb55U, 0x2f75ac71U, 0x64bf2ca5U, 
	0x8b99675aU, 0x3f4923b6U, 0x7e610550U, 0x04b1c06dU, 
	0x8f92e7c6U, 0x45cb608bU, 0x2d06d1f2U, 0x79cf387aU, 
	0xfd3ed225U, 0x243eee20U, 0x2cbefc6fU, 0x8286cbaaU, 
	0x70d4c182U, 0x054e3cc6U, 0xb66c5362U, 0x0c73fa5dU, 
	0x539948feU, 0xec638563U, 0x0cf04ab6U, 0xec7b52f4U, 
	0x58eeffceU, 0x6fe8049aU, 0xb3b33332U, 0x2e33bfdbU, 
	0xcc817567U, 0x71ac57c8U, 0x4bab3ac7U, 0x327c558bU, 
	0x82a6d279U, 0x5adf71daU, 0x1074a656U, 0x3c533c1fU, 
	0x82fdbe69U, 0x21b4f6afU, 0xd59580e8U, 0x0de824ebU, 
	0xa510941bU, 0x7cd91144U, 0xa8c10631U, 0x4c839267U, 
	0x5d503c2fU, 0xe1567d55U, 0x23910cc7U, 0xdb1bdc34U, 
	0x2a866704U, 0x33e21f0cU, 0x5c7681b4U, 0x818651caU, 
	0xb1d18162U, 0x225ad014U, 0xadf7d6baU, 0xac548d9bU, 
	0xe94736e5U, 0x2279c5f1U, 0x33215d2cU, 0xdc8ab90eU, 
	0xf5e3d7f2U, 0xedcb15cfU, 0xc9a43c4cU, 0xfc678fc6U, 
	0x43796b95U, 0x3f8b700cU, 0x867bbc72U, 0x81f71fecU, 
	0xd00cad7dU, 0x302c458fU, 0x8ae21accU, 0x05850ce8U, 
	0x7764d8e8U, 0x8a36cd68U, 0x40b44bd7U, 0x1cffaeb7U, 
	0x2b248f34U, 0x1eefdbafU, 0x574d7437U, 0xe86cd935U, 
	0xf53dd1c8U, 0x1b022513U, 0xef2d249bU, 0x94fb2b08U, 
	0x15d3eff8U, 0x14245e1bU, 0x82aa8425U, 0x53959028U, 
	0x9c5f9b80U, 0x325e0c82U, 0x3e236c24U, 0x74e1dd36U, 
	0x9890df3fU, 0xaf9701a2U, 0x023b3413U, 0x7634c67eU, 
	0x55cf5e45U, 0x56d2a95bU, 0xb6db869bU, 0xac19e260U, 
	0xdd310740U, 0x26d68f84U, 0x45bebf17U, 0xe4a7728fU, 
	0xf082e66eU, 0xb2fe3c10U, 0x2db1fa2cU, 0x4b3dfcfaU, 
	0xc7b3a672U, 0xaeadc67bU, 0x6cce6f2bU, 0x8263dbbfU, 
	0xd9724d5bU, 0xbcc767b5U, 0x8d563798U, 0x2db764b4U, 
	0x76e0cee7U, 0xd34f9a67U, 0x035c810aU, 0x3f56bdc1U, 
	0x5b3f2c84U, 0x0baca8c0U, 0xfe979a77U, 0x484ca775U, 
	0xbdc7f104U, 0xc06c3efbU, 0xdbc5f32cU, 0x44b017e7U, 
};

ATF_TC(t_popcount);
ATF_TC(t_popcountll);

ATF_TC_HEAD(t_popcount, tc)
{
	atf_tc_set_md_var(tc, "descr", "Test popcount results");
	atf_tc_set_md_var(tc, "timeout", "0");
}

ATF_TC_HEAD(t_popcountll, tc)
{
	atf_tc_set_md_var(tc, "descr", "Test popcountll results");
	atf_tc_set_md_var(tc, "timeout", "0");
}

ATF_TC_BODY(t_popcount, tc)
{
	unsigned int i, r;

	popcount_init();

	for (i = 0; i < 0xffffffff; ++i) {
		r = byte_count[i & 255] + byte_count[(i >> 8) & 255]
		    + byte_count[(i >> 16) & 255]
		    + byte_count[(i >> 24) & 255];

		ATF_CHECK_EQ(r, popcount(i));
	}
	ATF_CHECK_EQ(popcount(0xffffffff), 32);
}

ATF_TC_BODY(t_popcountll, tc)
{
	unsigned int i, j, r, r2, p;
	unsigned long long v;

	popcount_init();

	for (j = 0; j < 256; ++j) {
		p = test_parts[j];
		r2 = byte_count[p & 255] + byte_count[(p >> 8) & 255]
		    + byte_count[(p >> 16) & 255]
		    + byte_count[(p >> 24) & 255];

		for (i = 0; i < 0xffffffff; ++i) {
			r = byte_count[i & 255] + byte_count[(i >> 8) & 255]
			    + byte_count[(i >> 16) & 255]
			    + byte_count[(i >> 24) & 255] + r2;

			v = (((unsigned long long)i) << 32) + p;
			ATF_CHECK_EQ(r, popcountll(v));
			v = (((unsigned long long)p) << 32) + i;
			ATF_CHECK_EQ(r, popcountll(v));
		}
	}

	ATF_CHECK_EQ(popcountll(0xffffffffffffffff), 64);
}

ATF_TP_ADD_TCS(tp)
{
	ATF_TP_ADD_TC(tp, t_popcount);
	ATF_TP_ADD_TC(tp, t_popcountll);

	return atf_no_error();
}