forked from osmocom/wireshark
Remove popcount in favor of ws_count_ones.
Remove our popcount implementation in favor of ws_count_ones, which is our other popcount implementation. This required updating and running process-x11-xcb.pl. Change-Id: I8634c55242113b338c5b0173837c35f98b148b4f Reviewed-on: https://code.wireshark.org/review/26454 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
a2cbec743e
commit
0874b8bac6
|
@ -98,7 +98,6 @@ endif()
|
|||
check_function_exists("getifaddrs" HAVE_GETIFADDRS)
|
||||
check_function_exists("issetugid" HAVE_ISSETUGID)
|
||||
check_function_exists("mkstemps" HAVE_MKSTEMPS)
|
||||
check_function_exists("popcount" HAVE_POPCOUNT)
|
||||
check_function_exists("setresgid" HAVE_SETRESGID)
|
||||
check_function_exists("setresuid" HAVE_SETRESUID)
|
||||
check_function_exists("strptime" HAVE_STRPTIME)
|
||||
|
|
|
@ -243,9 +243,6 @@
|
|||
/* Define to 1 if you have the `pcap_set_tstamp_type' function. */
|
||||
#cmakedefine HAVE_PCAP_SET_TSTAMP_TYPE 1
|
||||
|
||||
/* Define to 1 if you have the popcount function. */
|
||||
#cmakedefine HAVE_POPCOUNT 1
|
||||
|
||||
/* Define to 1 if you have the <pwd.h> header file. */
|
||||
#cmakedefine HAVE_PWD_H 1
|
||||
|
||||
|
|
|
@ -2313,7 +2313,6 @@ if test "x$ac_cv_func_getopt_long" = xyes; then
|
|||
fi
|
||||
|
||||
AC_REPLACE_FUNCS(strptime)
|
||||
AC_REPLACE_FUNCS(popcount)
|
||||
|
||||
AC_CHECK_FUNCS(mkstemps)
|
||||
AC_CHECK_FUNCS(issetugid)
|
||||
|
|
|
@ -121,7 +121,6 @@ libwsutil.so.0 libwsutil0 #MINVER#
|
|||
plugins_dump_all@Base 1.12.0~rc1
|
||||
plugins_get_count@Base 2.5.0
|
||||
plugins_get_descriptions@Base 1.12.0~rc1
|
||||
popcount@Base 1.99.2
|
||||
printable_char_or_period@Base 1.99.0
|
||||
profile_exists@Base 1.12.0~rc1
|
||||
profile_store_persconffiles@Base 1.12.0~rc1
|
||||
|
|
|
@ -47,9 +47,7 @@
|
|||
#include "packet-x11-keysymdef.h"
|
||||
#include "packet-x11.h"
|
||||
|
||||
#ifndef HAVE_POPCOUNT
|
||||
# include "wsutil/popcount.h"
|
||||
#endif
|
||||
#include <wsutil/bits_count_ones.h>
|
||||
|
||||
void proto_register_x11(void);
|
||||
void proto_reg_handoff_x11(void);
|
||||
|
|
|
@ -21703,8 +21703,8 @@ static int struct_size_xkb_DeviceLedInfo(tvbuff_t *tvb _U_, int *offsetp _U_, gu
|
|||
int f_namesPresent;
|
||||
f_namesPresent = tvb_get_guint32(tvb, *offsetp + size + 4, byte_order);
|
||||
f_mapsPresent = tvb_get_guint32(tvb, *offsetp + size + 8, byte_order);
|
||||
size += popcount(f_namesPresent) * 4;
|
||||
size += popcount(f_mapsPresent) * 12;
|
||||
size += ws_count_ones(f_namesPresent) * 4;
|
||||
size += ws_count_ones(f_mapsPresent) * 12;
|
||||
return size + 20;
|
||||
}
|
||||
|
||||
|
@ -21731,8 +21731,8 @@ static void struct_xkb_DeviceLedInfo(tvbuff_t *tvb, int *offsetp, proto_tree *ro
|
|||
*offsetp += 4;
|
||||
proto_tree_add_item(t, hf_x11_struct_xkb_DeviceLedInfo_state, tvb, *offsetp, 4, byte_order);
|
||||
*offsetp += 4;
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_struct_xkb_DeviceLedInfo_names, hf_x11_struct_xkb_DeviceLedInfo_names_item, popcount(f_namesPresent), byte_order);
|
||||
struct_xkb_IndicatorMap(tvb, offsetp, t, byte_order, popcount(f_mapsPresent));
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_struct_xkb_DeviceLedInfo_names, hf_x11_struct_xkb_DeviceLedInfo_names_item, ws_count_ones(f_namesPresent), byte_order);
|
||||
struct_xkb_IndicatorMap(tvb, offsetp, t, byte_order, ws_count_ones(f_mapsPresent));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23989,7 +23989,7 @@ static void xkbGetMap_Reply(tvbuff_t *tvb, packet_info *pinfo, int *offsetp, pro
|
|||
struct_xkb_SetBehavior(tvb, offsetp, t, byte_order, f_totalKeyBehaviors);
|
||||
}
|
||||
if (f_present & (1U << 6)) {
|
||||
listOfByte(tvb, offsetp, t, hf_x11_xkb_GetMap_reply_VirtualMods_vmods_rtrn, popcount(f_virtualMods), byte_order);
|
||||
listOfByte(tvb, offsetp, t, hf_x11_xkb_GetMap_reply_VirtualMods_vmods_rtrn, ws_count_ones(f_virtualMods), byte_order);
|
||||
if (*offsetp % 4) {
|
||||
proto_tree_add_item(t, hf_x11_unused, tvb, *offsetp, (4 - *offsetp % 4), ENC_NA);
|
||||
*offsetp += (4 - *offsetp % 4);
|
||||
|
@ -24153,8 +24153,8 @@ static void xkbSetMap(tvbuff_t *tvb, packet_info *pinfo _U_, int *offsetp, proto
|
|||
length -= f_totalKeyBehaviors * 4;
|
||||
}
|
||||
if (f_present & (1U << 6)) {
|
||||
listOfByte(tvb, offsetp, t, hf_x11_xkb_SetMap_VirtualMods_vmods, popcount(f_virtualMods), byte_order);
|
||||
length -= popcount(f_virtualMods) * 1;
|
||||
listOfByte(tvb, offsetp, t, hf_x11_xkb_SetMap_VirtualMods_vmods, ws_count_ones(f_virtualMods), byte_order);
|
||||
length -= ws_count_ones(f_virtualMods) * 1;
|
||||
if (*offsetp % 4) {
|
||||
proto_tree_add_item(t, hf_x11_unused, tvb, *offsetp, (4 - *offsetp % 4), ENC_NA);
|
||||
*offsetp += (4 - *offsetp % 4);
|
||||
|
@ -24238,7 +24238,7 @@ static void xkbGetCompatMap_Reply(tvbuff_t *tvb, packet_info *pinfo, int *offset
|
|||
proto_tree_add_item(t, hf_x11_unused, tvb, *offsetp, 16, ENC_NA);
|
||||
*offsetp += 16;
|
||||
struct_xkb_SymInterpret(tvb, offsetp, t, byte_order, f_nSIRtrn);
|
||||
struct_xkb_ModDef(tvb, offsetp, t, byte_order, popcount(f_groupsRtrn));
|
||||
struct_xkb_ModDef(tvb, offsetp, t, byte_order, ws_count_ones(f_groupsRtrn));
|
||||
}
|
||||
|
||||
static void xkbSetCompatMap(tvbuff_t *tvb, packet_info *pinfo _U_, int *offsetp, proto_tree *t, guint byte_order, int length _U_)
|
||||
|
@ -24274,8 +24274,8 @@ static void xkbSetCompatMap(tvbuff_t *tvb, packet_info *pinfo _U_, int *offsetp,
|
|||
*offsetp += 2;
|
||||
struct_xkb_SymInterpret(tvb, offsetp, t, byte_order, f_nSI);
|
||||
length -= f_nSI * 16;
|
||||
struct_xkb_ModDef(tvb, offsetp, t, byte_order, popcount(f_groups));
|
||||
length -= popcount(f_groups) * 4;
|
||||
struct_xkb_ModDef(tvb, offsetp, t, byte_order, ws_count_ones(f_groups));
|
||||
length -= ws_count_ones(f_groups) * 4;
|
||||
}
|
||||
|
||||
static void xkbGetIndicatorState(tvbuff_t *tvb, packet_info *pinfo _U_, int *offsetp, proto_tree *t, guint byte_order, int length _U_)
|
||||
|
@ -24340,7 +24340,7 @@ static void xkbGetIndicatorMap_Reply(tvbuff_t *tvb, packet_info *pinfo, int *off
|
|||
*offsetp += 1;
|
||||
proto_tree_add_item(t, hf_x11_unused, tvb, *offsetp, 15, ENC_NA);
|
||||
*offsetp += 15;
|
||||
struct_xkb_IndicatorMap(tvb, offsetp, t, byte_order, popcount(f_which));
|
||||
struct_xkb_IndicatorMap(tvb, offsetp, t, byte_order, ws_count_ones(f_which));
|
||||
}
|
||||
|
||||
static void xkbSetIndicatorMap(tvbuff_t *tvb, packet_info *pinfo _U_, int *offsetp, proto_tree *t, guint byte_order, int length _U_)
|
||||
|
@ -24353,8 +24353,8 @@ static void xkbSetIndicatorMap(tvbuff_t *tvb, packet_info *pinfo _U_, int *offse
|
|||
f_which = tvb_get_guint32(tvb, *offsetp, byte_order);
|
||||
proto_tree_add_item(t, hf_x11_xkb_SetIndicatorMap_which, tvb, *offsetp, 4, byte_order);
|
||||
*offsetp += 4;
|
||||
struct_xkb_IndicatorMap(tvb, offsetp, t, byte_order, popcount(f_which));
|
||||
length -= popcount(f_which) * 12;
|
||||
struct_xkb_IndicatorMap(tvb, offsetp, t, byte_order, ws_count_ones(f_which));
|
||||
length -= ws_count_ones(f_which) * 12;
|
||||
}
|
||||
|
||||
static void xkbGetNamedIndicator(tvbuff_t *tvb, packet_info *pinfo _U_, int *offsetp, proto_tree *t, guint byte_order, int length _U_)
|
||||
|
@ -24816,13 +24816,13 @@ static void xkbGetNames_Reply(tvbuff_t *tvb, packet_info *pinfo, int *offsetp, p
|
|||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_GetNames_reply_KTLevelNames_ktLevelNames, hf_x11_xkb_GetNames_reply_KTLevelNames_ktLevelNames_item, sumof_nLevelsPerType, byte_order);
|
||||
}
|
||||
if (f_which & (1U << 8)) {
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_GetNames_reply_IndicatorNames_indicatorNames, hf_x11_xkb_GetNames_reply_IndicatorNames_indicatorNames_item, popcount(f_indicators), byte_order);
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_GetNames_reply_IndicatorNames_indicatorNames, hf_x11_xkb_GetNames_reply_IndicatorNames_indicatorNames_item, ws_count_ones(f_indicators), byte_order);
|
||||
}
|
||||
if (f_which & (1U << 11)) {
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_GetNames_reply_VirtualModNames_virtualModNames, hf_x11_xkb_GetNames_reply_VirtualModNames_virtualModNames_item, popcount(f_virtualMods), byte_order);
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_GetNames_reply_VirtualModNames_virtualModNames, hf_x11_xkb_GetNames_reply_VirtualModNames_virtualModNames_item, ws_count_ones(f_virtualMods), byte_order);
|
||||
}
|
||||
if (f_which & (1U << 12)) {
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_GetNames_reply_GroupNames_groups, hf_x11_xkb_GetNames_reply_GroupNames_groups_item, popcount(f_groupNames), byte_order);
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_GetNames_reply_GroupNames_groups, hf_x11_xkb_GetNames_reply_GroupNames_groups_item, ws_count_ones(f_groupNames), byte_order);
|
||||
}
|
||||
if (f_which & (1U << 9)) {
|
||||
struct_xkb_KeyName(tvb, offsetp, t, byte_order, f_nKeys);
|
||||
|
@ -24979,16 +24979,16 @@ static void xkbSetNames(tvbuff_t *tvb, packet_info *pinfo _U_, int *offsetp, pro
|
|||
length -= sumof_nLevelsPerType * 4;
|
||||
}
|
||||
if (f_which & (1U << 8)) {
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_SetNames_IndicatorNames_indicatorNames, hf_x11_xkb_SetNames_IndicatorNames_indicatorNames_item, popcount(f_indicators), byte_order);
|
||||
length -= popcount(f_indicators) * 4;
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_SetNames_IndicatorNames_indicatorNames, hf_x11_xkb_SetNames_IndicatorNames_indicatorNames_item, ws_count_ones(f_indicators), byte_order);
|
||||
length -= ws_count_ones(f_indicators) * 4;
|
||||
}
|
||||
if (f_which & (1U << 11)) {
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_SetNames_VirtualModNames_virtualModNames, hf_x11_xkb_SetNames_VirtualModNames_virtualModNames_item, popcount(f_virtualMods), byte_order);
|
||||
length -= popcount(f_virtualMods) * 4;
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_SetNames_VirtualModNames_virtualModNames, hf_x11_xkb_SetNames_VirtualModNames_virtualModNames_item, ws_count_ones(f_virtualMods), byte_order);
|
||||
length -= ws_count_ones(f_virtualMods) * 4;
|
||||
}
|
||||
if (f_which & (1U << 12)) {
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_SetNames_GroupNames_groups, hf_x11_xkb_SetNames_GroupNames_groups_item, popcount(f_groupNames), byte_order);
|
||||
length -= popcount(f_groupNames) * 4;
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_SetNames_GroupNames_groups, hf_x11_xkb_SetNames_GroupNames_groups_item, ws_count_ones(f_groupNames), byte_order);
|
||||
length -= ws_count_ones(f_groupNames) * 4;
|
||||
}
|
||||
if (f_which & (1U << 9)) {
|
||||
struct_xkb_KeyName(tvb, offsetp, t, byte_order, f_nKeys);
|
||||
|
@ -25467,7 +25467,7 @@ static void xkbGetKbdByName_Reply(tvbuff_t *tvb, packet_info *pinfo, int *offset
|
|||
struct_xkb_SetBehavior(tvb, offsetp, t, byte_order, f_totalKeyBehaviors);
|
||||
}
|
||||
if (f_present & (1U << 6)) {
|
||||
listOfByte(tvb, offsetp, t, hf_x11_xkb_GetKbdByName_reply_Types_VirtualMods_vmods_rtrn, popcount(f_virtualMods), byte_order);
|
||||
listOfByte(tvb, offsetp, t, hf_x11_xkb_GetKbdByName_reply_Types_VirtualMods_vmods_rtrn, ws_count_ones(f_virtualMods), byte_order);
|
||||
if (*offsetp % 4) {
|
||||
proto_tree_add_item(t, hf_x11_unused, tvb, *offsetp, (4 - *offsetp % 4), ENC_NA);
|
||||
*offsetp += (4 - *offsetp % 4);
|
||||
|
@ -25526,7 +25526,7 @@ static void xkbGetKbdByName_Reply(tvbuff_t *tvb, packet_info *pinfo, int *offset
|
|||
proto_tree_add_item(t, hf_x11_unused, tvb, *offsetp, 16, ENC_NA);
|
||||
*offsetp += 16;
|
||||
struct_xkb_SymInterpret(tvb, offsetp, t, byte_order, f_nSIRtrn);
|
||||
struct_xkb_ModDef(tvb, offsetp, t, byte_order, popcount(f_groupsRtrn));
|
||||
struct_xkb_ModDef(tvb, offsetp, t, byte_order, ws_count_ones(f_groupsRtrn));
|
||||
}
|
||||
if (f_reported & (1U << 4)) {
|
||||
int f_nIndicators;
|
||||
|
@ -25692,13 +25692,13 @@ static void xkbGetKbdByName_Reply(tvbuff_t *tvb, packet_info *pinfo, int *offset
|
|||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_GetKbdByName_reply_KeyNames_KTLevelNames_ktLevelNames, hf_x11_xkb_GetKbdByName_reply_KeyNames_KTLevelNames_ktLevelNames_item, sumof_nLevelsPerType, byte_order);
|
||||
}
|
||||
if (f_which & (1U << 8)) {
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_GetKbdByName_reply_KeyNames_IndicatorNames_indicatorNames, hf_x11_xkb_GetKbdByName_reply_KeyNames_IndicatorNames_indicatorNames_item, popcount(f_indicators), byte_order);
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_GetKbdByName_reply_KeyNames_IndicatorNames_indicatorNames, hf_x11_xkb_GetKbdByName_reply_KeyNames_IndicatorNames_indicatorNames_item, ws_count_ones(f_indicators), byte_order);
|
||||
}
|
||||
if (f_which & (1U << 11)) {
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_GetKbdByName_reply_KeyNames_VirtualModNames_virtualModNames, hf_x11_xkb_GetKbdByName_reply_KeyNames_VirtualModNames_virtualModNames_item, popcount(f_virtualMods), byte_order);
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_GetKbdByName_reply_KeyNames_VirtualModNames_virtualModNames, hf_x11_xkb_GetKbdByName_reply_KeyNames_VirtualModNames_virtualModNames_item, ws_count_ones(f_virtualMods), byte_order);
|
||||
}
|
||||
if (f_which & (1U << 12)) {
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_GetKbdByName_reply_KeyNames_GroupNames_groups, hf_x11_xkb_GetKbdByName_reply_KeyNames_GroupNames_groups_item, popcount(f_groupNames), byte_order);
|
||||
listOfCard32(tvb, offsetp, t, hf_x11_xkb_GetKbdByName_reply_KeyNames_GroupNames_groups, hf_x11_xkb_GetKbdByName_reply_KeyNames_GroupNames_groups_item, ws_count_ones(f_groupNames), byte_order);
|
||||
}
|
||||
if (f_which & (1U << 9)) {
|
||||
struct_xkb_KeyName(tvb, offsetp, t, byte_order, f_nKeys);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Do not modify this file. */
|
||||
/* It was automatically generated by ../../tools/process-x11-xcb.pl
|
||||
using mesa version 17.1-branchpoint-393-geeff7e1154 */
|
||||
using mesa version 17.3-branchpoint-3917-g370e356eba */
|
||||
/*
|
||||
* Copyright 2008, 2009, 2013, 2014 Open Text Corporation <pharris[AT]opentext.com>
|
||||
*
|
||||
|
@ -1277,6 +1277,7 @@ static const value_string mesa_enum[] = {
|
|||
{ 0x8a48, "TEXTURE_SRGB_DECODE_EXT" },
|
||||
{ 0x8a49, "DECODE_EXT" },
|
||||
{ 0x8a4a, "SKIP_DECODE_EXT" },
|
||||
{ 0x8a52, "FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT" },
|
||||
{ 0x8b30, "FRAGMENT_SHADER" },
|
||||
{ 0x8b31, "VERTEX_SHADER" },
|
||||
{ 0x8b40, "PROGRAM_OBJECT_ARB" },
|
||||
|
|
|
@ -43,19 +43,7 @@ eot
|
|||
* By Gerald Combs <gerald[AT]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.
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
eot
|
||||
|
|
|
@ -538,7 +538,7 @@ sub get_unop($;$) {
|
|||
return '(' . $op->att('op') . "$left)";
|
||||
}
|
||||
when ('popcount') {
|
||||
return "popcount($left)";
|
||||
return "ws_count_ones($left)";
|
||||
}
|
||||
default { die "Invalid unop element $op->name()\n"; }
|
||||
}
|
||||
|
@ -1774,19 +1774,7 @@ eot
|
|||
* By Gerald Combs <gerald[AT]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.
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
eot
|
||||
|
|
|
@ -207,10 +207,6 @@ if(NOT HAVE_GETOPT_LONG)
|
|||
list(APPEND WSUTIL_FILES getopt_long.c)
|
||||
endif()
|
||||
|
||||
if(NOT HAVE_POPCOUNT)
|
||||
list(APPEND WSUTIL_FILES popcount.c)
|
||||
endif()
|
||||
|
||||
if(NOT HAVE_STRPTIME)
|
||||
list(APPEND WSUTIL_FILES strptime.c)
|
||||
endif()
|
||||
|
|
|
@ -198,8 +198,6 @@ EXTRA_DIST = \
|
|||
file_util.h \
|
||||
getopt_long.c \
|
||||
getopt_long.h \
|
||||
popcount.c \
|
||||
popcount.h \
|
||||
strptime.c \
|
||||
strptime.h \
|
||||
win32-utils.c \
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/* popcount.c
|
||||
*
|
||||
* popcount() replacement function for systems that don't provide their own.
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "wsutil/popcount.h"
|
||||
|
||||
int
|
||||
popcount(unsigned int mask)
|
||||
{
|
||||
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
|
||||
/* GCC 3.4 or newer */
|
||||
return __builtin_popcount(mask);
|
||||
#else
|
||||
/* HACKMEM 169 */
|
||||
unsigned long y;
|
||||
|
||||
y = (mask >> 1) &033333333333;
|
||||
y = mask - y - ((y >>1) & 033333333333);
|
||||
return (((y + (y >> 3)) & 030707070707) % 077);
|
||||
#endif
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
/* popcount.h
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef __POPCOUNT_H__
|
||||
#define __POPCOUNT_H__
|
||||
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
WS_DLL_PUBLIC int popcount(unsigned int mask);
|
||||
|
||||
#endif /* __POPCOUNT_H__ */
|
||||
|
Loading…
Reference in New Issue