Remove epan win32 x86 assembly

Not used. Remove also weird pre-hash hash optimization in proto.c.

Change-Id: Ibebc12dbe90ac1d05fb1ba601d32fe98797fbd56
Reviewed-on: https://code.wireshark.org/review/24254
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: João Valverde <j@v6e.pt>
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
João Valverde 2017-11-05 13:05:20 +00:00 committed by Anders Broman
parent 93bda0b18d
commit ba6dd97081
8 changed files with 23 additions and 360 deletions

View File

@ -41,21 +41,6 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
)
set(LIBWIRESHARK_ASM_FILES
asm_utils.c
# todo
# !IFDEF NASM
# asm_utils_win32_x86.obj: asm_utils_win32_x86.asm
# $(NASM) -f $(WIRESHARK_TARGET_PLATFORM) -o $@ $?
# !ENDIF
# ...
# !IF defined(NASM) && "$(WIRESHARK_TARGET_PLATFORM)" == "win32"
# asm_utils_win32_x86.obj
# !ELSE
# asm_utils.obj
# !ENDIF
)
add_custom_command(
OUTPUT ps.c
COMMAND ${PYTHON_EXECUTABLE}
@ -314,7 +299,6 @@ set(epan_LIBS
set(CLEAN_FILES
${LIBWIRESHARK_CLEAN_FILES}
${LIBWIRESHARK_ASM_FILES}
)
set_source_files_properties(
@ -333,7 +317,6 @@ endif()
add_library(epan ${LINK_MODE_LIB}
${LIBWIRESHARK_FILES}
${GENERATED_FILES}
${LIBWIRESHARK_ASM_FILES}
$<TARGET_OBJECTS:crypt>
$<TARGET_OBJECTS:dfilter>
$<TARGET_OBJECTS:dissectors>

View File

@ -44,7 +44,6 @@ LIBWIRESHARK_SRC = \
afn.c \
aftypes.c \
app_mem_usage.c \
asm_utils.c \
asn1.c \
capture_dissectors.c \
charsets.c \
@ -285,7 +284,6 @@ LIBWIRESHARK_INCLUDES_PUBLIC = \
xdlc.h
LIBWIRESHARK_INCLUDES_PRIVATE = \
asm_utils.h \
epan-int.h \
to_str-int.h
@ -362,7 +360,6 @@ libwireshark_generated_la_CFLAGS = $(GENERATED_CFLAGS)
EXTRA_DIST = \
.editorconfig \
asm_utils_win32_x86.asm \
diam_dict.l \
dtd_grammar.lemon \
dtd_parse.l \

View File

@ -1,85 +0,0 @@
/* asm_utils.c
* Functions optionally implemented in assembler
*
* 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.
*/
#include "config.h"
#include <string.h>
#include <glib.h>
#include "asm_utils.h"
#include "ws_attributes.h"
/* String comparison func for dfilter_token GTree */
gint
wrs_strcmp(gconstpointer a, gconstpointer b)
{
return strcmp((const char*)a, (const char*)b);
}
gint
wrs_strcmp_with_data(gconstpointer a, gconstpointer b, gpointer user_data _U_)
{
return strcmp((const char*)a, (const char*)b);
}
gboolean
wrs_str_equal(gconstpointer a, gconstpointer b)
{
return !strcmp((const char*)a, (const char*)b);
}
guchar
wrs_check_charset(const guint8 table[256], const char *str)
{
const char *p = str;
guchar c;
do {
c = *(p++);
} while (table[c]);
return c;
}
guint
wrs_str_hash(gconstpointer v)
{
/* 31 bit hash function */
const signed char *p = (const signed char *)v;
guint32 h = *p;
if (h)
for (p += 1; *p != '\0'; p++)
h = (h << 5) - h + *p;
return h;
}
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/

View File

@ -1,36 +0,0 @@
/* asm_utils.h
* Functions optionally implemented in assembler
*
* 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 __ASM_UTILS_H__
#define __ASM_UTILS_H__
gint wrs_strcmp(gconstpointer a, gconstpointer b);
gint wrs_strcmp_with_data(gconstpointer a, gconstpointer b, gpointer user_data);
gboolean wrs_str_equal(gconstpointer a, gconstpointer b);
guchar wrs_check_charset(const guchar table[256], const char *str);
guint wrs_str_hash(gconstpointer v);
/* int wrs_count_bitshift(guint32 bitmask); */
#endif /* __ASM_UTILS_H__ */

View File

@ -1,184 +0,0 @@
; asm_utils_win32_x86.asm
; Functions optionally implemented in assembler
;
; 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.
;
SECTION .text
GLOBAL _wrs_strcmp
GLOBAL _wrs_strcmp_with_data
GLOBAL _wrs_str_equal
GLOBAL _wrs_check_charset
GLOBAL _wrs_str_hash
align 16
_wrs_strcmp:
_wrs_strcmp_with_data:
mov ecx, dword [esp + 4] ; a
mov edx, dword [esp + 8] ; b
push ebx
CMP_LOOP:
mov eax, dword [ecx]
mov ebx, dword [edx]
cmp al, bl
jne CMP_NEQ_END
or al, al
jz CMP_EQ_END
cmp ah, bh
jne CMP_NEQ_END
or ah, ah
jz CMP_EQ_END
shr eax, 16
shr ebx, 16
add ecx, byte 4
add edx, byte 4
cmp al, bl
jne CMP_NEQ_END
or al, al
jz CMP_EQ_END
cmp ah, bh
jne CMP_NEQ_END
or ah, ah
jnz CMP_LOOP
CMP_EQ_END:
pop ebx
xor eax, eax
retn
CMP_NEQ_END:
; returns 1 or -1 based on CF flag from the last comparision
sbb eax, eax
pop ebx
shl eax, 1
inc eax
retn
align 16
_wrs_str_equal:
mov ecx, dword [esp + 4] ; a
mov edx, dword [esp + 8] ; b
push ebx
EQL_LOOP:
mov eax, dword [ecx]
mov ebx, dword [edx]
cmp al, bl
jne EQL_NEQ_END
or al, al
jz EQL_EQ_END
cmp ah, bh
jne EQL_NEQ_END
or ah, ah
jz EQL_EQ_END
shr eax, 16
shr ebx, 16
add ecx, byte 4
add edx, byte 4
cmp al, bl
jne EQL_NEQ_END
or al, al
jz EQL_EQ_END
cmp ah, bh
jne EQL_NEQ_END
or ah, ah
jnz EQL_LOOP
EQL_EQ_END:
xor eax, eax
pop ebx
not eax
retn
EQL_NEQ_END:
pop ebx
xor eax, eax
retn
align 16
_wrs_check_charset:
mov edx, dword [esp + 4] ; table
mov ecx, dword [esp + 8] ; str
push edi
push ebx
mov edi, edx
mov bl, byte 0xFF
CHK_LOOP:
mov eax, dword [ecx]
movzx edx, al
test bl, byte [edi+edx]
jz CHK_AL_END
movzx edx, ah
test bl, byte [edi+edx]
jz CHK_AH_END
shr eax, 16
add ecx, byte 4
movzx edx, al
test bl, byte [edi+edx]
jz CHK_AL_END
movzx edx, ah
test bl, byte [edi+edx]
jnz CHK_LOOP
CHK_AH_END:
movzx eax, ah
pop ebx
pop edi
retn
CHK_AL_END:
movzx eax, al
pop ebx
pop edi
retn
align 16
_wrs_str_hash:
mov edx, dword [esp + 4] ; v
push ebx
xor eax, eax
mov ecx, dword [edx]
or cl, cl
movzx ebx, cl
jz HASH_END
HASH_LOOP:
sub ebx, eax
shl eax, 5
add eax, ebx
or ch, ch
movzx ebx, ch
jz HASH_END
sub ebx, eax
shl eax, 5
add eax, ebx
shr ecx, 16
add edx, byte 4
or cl, cl
movzx ebx, cl
jz HASH_END
sub ebx, eax
shl eax, 5
add eax, ebx
or ch, ch
movzx ebx, ch
jz HASH_END
sub ebx, eax
shl eax, 5
add eax, ebx
mov ecx, dword [edx]
or cl, cl
movzx ebx, cl
jnz HASH_LOOP
HASH_END:
pop ebx
retn

View File

@ -49,7 +49,6 @@
#include <epan/expert.h>
#include <epan/prefs.h>
#include <epan/range.h>
#include <epan/asm_utils.h>
#include <wsutil/str_util.h>
#include <wsutil/ws_printf.h> /* ws_debug_printf */
@ -215,7 +214,7 @@ packet_init(void)
heur_dissector_lists = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, destroy_heuristic_dissector_list);
heuristic_short_names = g_hash_table_new(wrs_str_hash, g_str_equal);
heuristic_short_names = g_hash_table_new(g_str_hash, g_str_equal);
}
void

View File

@ -46,7 +46,6 @@
#include "tvbuff.h"
#include "wmem/wmem.h"
#include "charsets.h"
#include "asm_utils.h"
#include "column-utils.h"
#include "to_str-int.h"
#include "to_str.h"
@ -421,6 +420,18 @@ proto_compare_name(gconstpointer p1_arg, gconstpointer p2_arg)
return g_ascii_strcasecmp(p1->short_name, p2->short_name);
}
static inline guchar
check_charset(const guint8 table[256], const char *str)
{
const char *p = str;
guchar c;
do {
c = *(p++);
} while (table[c]);
return c;
}
#ifdef HAVE_PLUGINS
/*
* List of dissector plugins.
@ -525,9 +536,9 @@ proto_init(void (register_all_protocols_func)(register_cb cb, gpointer client_da
{
proto_cleanup_base();
proto_names = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL);
proto_short_names = g_hash_table_new(wrs_str_hash, g_str_equal);
proto_filter_names = g_hash_table_new(wrs_str_hash, g_str_equal);
proto_names = g_hash_table_new(g_str_hash, g_str_equal);
proto_short_names = g_hash_table_new(g_str_hash, g_str_equal);
proto_filter_names = g_hash_table_new(g_str_hash, g_str_equal);
gpa_hfinfo.len = 0;
gpa_hfinfo.allocated_len = 0;
@ -6504,8 +6515,6 @@ proto_register_protocol(const char *name, const char *short_name,
const protocol_t *existing_protocol = NULL;
header_field_info *hfinfo;
int proto_id;
const char *existing_name;
gint *key;
guint i;
gchar c;
gboolean found_invalid;
@ -6516,26 +6525,14 @@ proto_register_protocol(const char *name, const char *short_name,
* or an inappropriate plugin.
* This situation has to be fixed to not register more than one
* protocol with the same name.
*
* This is done by reducing the number of strcmp (and alike) calls
* as much as possible, as this significally slows down startup time.
*
* Drawback: As a hash value is used to reduce insert time,
* this might lead to a hash collision.
* However, although we have somewhat over 1000 protocols, we're using
* a 32 bit int so this is very, very unlikely.
*/
key = (gint *)g_malloc (sizeof(gint));
*key = wrs_str_hash(name);
existing_name = (const char *)g_hash_table_lookup(proto_names, key);
if (existing_name != NULL) {
existing_protocol = (const protocol_t *)g_hash_table_lookup(proto_names, name);
if (existing_protocol != NULL) {
/* g_error will terminate the program */
g_error("Duplicate protocol name \"%s\"!"
" This might be caused by an inappropriate plugin or a development error.", name);
}
g_hash_table_insert(proto_names, key, (gpointer)name);
existing_protocol = (const protocol_t *)g_hash_table_lookup(proto_short_names, short_name);
if (existing_protocol != NULL) {
@ -6577,6 +6574,7 @@ proto_register_protocol(const char *name, const char *short_name,
protocol->heur_list = NULL;
/* list will be sorted later by name, when all protocols completed registering */
protocols = g_list_prepend(protocols, protocol);
g_hash_table_insert(proto_names, (gpointer)name, protocol);
g_hash_table_insert(proto_filter_names, (gpointer)filter_name, protocol);
g_hash_table_insert(proto_short_names, (gpointer)short_name, protocol);
@ -6674,7 +6672,6 @@ proto_deregister_protocol(const char *short_name)
protocol_t *protocol;
header_field_info *hfinfo;
int proto_id;
gint key;
guint i;
proto_id = proto_get_id_by_short_name(short_name);
@ -6682,9 +6679,7 @@ proto_deregister_protocol(const char *short_name)
if (protocol == NULL)
return FALSE;
key = wrs_str_hash(protocol->name);
g_hash_table_remove(proto_names, &key);
g_hash_table_remove(proto_names, protocol->name);
g_hash_table_remove(proto_short_names, (gpointer)short_name);
g_hash_table_remove(proto_filter_names, (gpointer)protocol->filter_name);
@ -6811,12 +6806,9 @@ proto_get_id(const protocol_t *protocol)
gboolean
proto_name_already_registered(const gchar *name)
{
gint key;
DISSECTOR_ASSERT_HINT(name, "No name present");
key = wrs_str_hash(name);
if (g_hash_table_lookup(proto_names, &key) != NULL)
if (g_hash_table_lookup(proto_names, name) != NULL)
return TRUE;
return FALSE;
}
@ -7931,7 +7923,7 @@ proto_register_field_init(header_field_info *hfinfo, const int parent)
/* Check that the filter name (abbreviation) is legal;
* it must contain only alphanumerics, '-', "_", and ".". */
c = wrs_check_charset(fld_abbrev_chars, hfinfo->abbrev);
c = check_charset(fld_abbrev_chars, hfinfo->abbrev);
if (c) {
if (g_ascii_isprint(c))
fprintf(stderr, "Invalid character '%c' in filter name '%s'\n", c, hfinfo->abbrev);
@ -11892,7 +11884,7 @@ proto_tree_add_checksum(proto_tree *tree, tvbuff_t *tvb, const guint offset,
guchar
proto_check_field_name(const gchar *field_name)
{
return wrs_check_charset(fld_abbrev_chars, field_name);
return check_charset(fld_abbrev_chars, field_name);
}
gboolean

View File

@ -117,7 +117,6 @@ $Win64Archives = @{
"libxml2-2.9.4-win64ws.zip" = "";
"lua-5.2.4_Win64_dllw4_lib.zip" = "lua5.2.4";
"lz4-1.7.5-win64ws.zip" = "";
"nasm-2.09.08-win32.zip" = "";
"nghttp2-1.14.0-1-win64ws.zip" = "";
"portaudio_v19_2.zip" = "";
"sbc-1.3-1-win64ws.zip" = "";
@ -142,7 +141,6 @@ $Win32Archives = @{
"libxml2-2.9.4-win32ws.zip" = "";
"lua-5.2.4_Win32_dllw4_lib.zip" = "lua5.2.4";
"lz4-1.7.5-win32ws.zip" = "";
"nasm-2.09.08-win32.zip" = "";
"nghttp2-1.14.0-1-win32ws.zip" = "";
"portaudio_v19_2.zip" = "";
"sbc-1.3-1-win32ws.zip" = "";
@ -195,7 +193,6 @@ $CleanupItems = @(
"lua5.1.4"
"lua5.2.?"
"lz4-*-win??ws"
"nasm-2.09.08"
"nghttp2-*-win??ws"
"portaudio_v19"
"portaudio_v19_2"