Skip to content

Commit aa2650e

Browse files
committed
Do the floating-point tests closer to what we need.
It's All Very Complicated, so mirror what print-lmp.c does - just do a calculation based on a particular input value and print the result using the same format print-lmp.c does, and have tests/TESTrun see what that result is. Just do that inside tcpdump.c, so we don't need the fptype stuff.
1 parent 565131d commit aa2650e

File tree

6 files changed

+18
-99
lines changed

6 files changed

+18
-99
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ if(NOT C_ADDITIONAL_FLAGS STREQUAL "")
11101110
set_target_properties(netdissect PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS})
11111111
endif()
11121112

1113-
set(TCPDUMP_SOURCE_LIST_C fptype.c tcpdump.c)
1113+
set(TCPDUMP_SOURCE_LIST_C tcpdump.c)
11141114

11151115
if(NOT HAVE_BPF_DUMP)
11161116
set(TCPDUMP_SOURCE_LIST_C ${TCPDUMP_SOURCE_LIST_C} bpf_dump.c)

Makefile.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@
7070
@rm -f $@
7171
$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
7272

73-
CSRC = fptype.c tcpdump.c
73+
CSRC = tcpdump.c
7474

7575
LIBNETDISSECT_SRC=\
7676
addrtoname.c \

fptype.c

-49
This file was deleted.

fptype.h

-34
This file was deleted.

tcpdump.c

+7-11
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ The Regents of the University of California. All rights reserved.\n";
150150

151151
#include "print.h"
152152

153-
#include "fptype.h"
154-
155153
#ifndef PATH_MAX
156154
#define PATH_MAX 1024
157155
#endif
@@ -1903,15 +1901,13 @@ main(int argc, char **argv)
19031901
* may differ (e.g., it might be 32-bit, 64-bit,
19041902
* or 80-bit).
19051903
*/
1906-
switch (float_type_check(0x4e93312d)) {
1907-
1908-
case 0x461a5794:
1909-
printf("FPTYPE1\n");
1910-
break;
1911-
1912-
default:
1913-
printf("FPTYPE2\n");
1914-
break;
1904+
{
1905+
union { /* int to float conversion buffer */
1906+
float f;
1907+
uint32_t i;
1908+
} f;
1909+
f.i = 0x4e93312d;
1910+
printf("%.3f\n", f.f*8/1000000);
19151911
}
19161912
return 0;
19171913

tests/TESTrun

+9-3
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,17 @@ sub loadconfighash {
6969
#print Dumper($main::confighhash);
7070

7171
# also run tcpdump --fp-type to get the type of floating-point
72-
# arithmetic we're doing, setting a HAVE_{fptype} key
72+
# arithmetic we're doing, setting a HAVE_{fptype} key based
73+
# on the value it prints
7374
open(FPTYPE_PIPE, "./tcpdump --fp-type |") or die("piping tcpdump --fp-type failed\n");
74-
my $have_fptype = "HAVE_" . <FPTYPE_PIPE>;
75+
my $fptype_val = <FPTYPE_PIPE>;
7576
close(FPTYPE_PIPE);
76-
$have_fptype =~ s/^\s+|\s+$//g;
77+
my $have_fptype;
78+
if($fptype_val == "9877.895") {
79+
$have_fptype = "HAVE_FPTYPE1";
80+
} else {
81+
$have_fptype = "HAVE_FPTYPE2";
82+
}
7783
$main::confighhash->{$have_fptype} = 1;
7884

7985
return $main::confighhash;

0 commit comments

Comments
 (0)