diff options
author | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2013-11-09 04:47:08 +0000 |
---|---|---|
committer | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2013-11-09 04:47:08 +0000 |
commit | 9297c9e7809e9116faf7b73dbb97a39ed75995bf (patch) | |
tree | 7f9b599c3cd5d1470276b43864d25e9a3e581eeb /wsutil | |
parent | 3aaf560877c6977aae0084f7f99944cc314791c3 (diff) |
Rename swar_count_bits() to ws_count_ones()
Try to make ws_count_ones() inline function.
svn path=/trunk/; revision=53178
Diffstat (limited to 'wsutil')
-rw-r--r-- | wsutil/CMakeLists.txt | 1 | ||||
-rw-r--r-- | wsutil/Makefile.common | 3 | ||||
-rw-r--r-- | wsutil/bits_count_ones.h (renamed from wsutil/swar.c) | 14 | ||||
-rw-r--r-- | wsutil/swar.h | 32 |
4 files changed, 10 insertions, 40 deletions
diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt index 02d15a0f04..f1ce424472 100644 --- a/wsutil/CMakeLists.txt +++ b/wsutil/CMakeLists.txt @@ -61,7 +61,6 @@ set(WSUTIL_FILES str_util.c rc4.c report_err.c - swar.c tempfile.c type_util.c u3.c diff --git a/wsutil/Makefile.common b/wsutil/Makefile.common index 4d2ab79376..a01ecee98a 100644 --- a/wsutil/Makefile.common +++ b/wsutil/Makefile.common @@ -52,7 +52,6 @@ LIBWSUTIL_SRC = \ sha1.c \ strnatcmp.c \ str_util.c \ - swar.c \ rc4.c \ report_err.c \ tempfile.c \ @@ -63,6 +62,7 @@ LIBWSUTIL_SRC = \ LIBWSUTIL_INCLUDES = \ aes.h \ bits_ctz.h \ + bits_count_ones.h \ crash_info.h \ crc6.h \ crc7.h \ @@ -87,7 +87,6 @@ LIBWSUTIL_INCLUDES = \ pint.h \ rc4.h \ report_err.h \ - swar.h \ tempfile.h \ type_util.h \ u3.h diff --git a/wsutil/swar.c b/wsutil/bits_count_ones.h index c784ea42f9..82f88bc43c 100644 --- a/wsutil/swar.c +++ b/wsutil/bits_count_ones.h @@ -1,5 +1,5 @@ /* - * swar.c + * bits_count_ones.h * * $Id$ * @@ -23,12 +23,13 @@ * */ +#ifndef __WSUTIL_BITS_COUNT_ONES_H__ +#define __WSUTIL_BITS_COUNT_ONES_H__ + #include "config.h" #include <glib.h> -#include "swar.h" - /* * The variable-precision SWAR algorithm is an interesting way to count * the number of bits set in an integer. While its performance is very @@ -37,9 +38,10 @@ * http://playingwithpointers.com/swar.html */ -int swar_count_bits(const guint32 bitmask) +static inline int +ws_count_ones(const guint32 x) { - int bits = bitmask; + int bits = x; bits = bits - ((bits >> 1) & 0x55555555); bits = (bits & 0x33333333) + ((bits >> 2) & 0x33333333); @@ -47,3 +49,5 @@ int swar_count_bits(const guint32 bitmask) return (bits * 0x01010101) >> 24; } + +#endif /* __WSUTIL_BITS_COUNT_ONES_H__ */ diff --git a/wsutil/swar.h b/wsutil/swar.h deleted file mode 100644 index 6541308fed..0000000000 --- a/wsutil/swar.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * swar.h - * - * $Id$ - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef __SWAR_H__ -#define __SWAR_H__ - -#include "ws_symbol_export.h" - -WS_DLL_PUBLIC int swar_count_bits(const guint32 bitmask); - -#endif /* __SWAR_H__ */ |