[llvm-commits] [test-suite] r46447 - in /test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url: packet.c packet.h url.c
Chris Lattner
sabre at nondot.org
Sun Jan 27 23:23:41 PST 2008
Author: lattner
Date: Mon Jan 28 01:23:41 2008
New Revision: 46447
URL: http://llvm.org/viewvc/llvm-project?rev=46447&view=rev
Log:
make this program not read random memory
Modified:
test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/packet.c
test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/packet.h
test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/url.c
Modified: test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/packet.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/packet.c?rev=46447&r1=46446&r2=46447&view=diff
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/packet.c (original)
+++ test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/packet.c Mon Jan 28 01:23:41 2008
@@ -22,25 +22,20 @@
/* Traces automatically drop the TCP checksum and urgent pointer, so header is 36 bytes */
#define HEADER_SIZE 36
-int packets_processed = 0;
#ifdef CONSTANT_PACKET
unsigned int packet_index = 0;
#endif
char *
-get_next_packet ()
+get_next_packet (int packet_number)
{
+ packet_number %= MAX_PACKETS;
char *packet;
unsigned int packet_length;
- if (packets_processed == MAX_PACKETS)
- {
- fprintf (stderr, "All packets (%d) processed, recompile with larger MAX_PACKETS \n", MAX_PACKETS);
- exit (1);
- }
- packet_length = (packet_lengths[packets_processed]);
+ packet_length = (packet_lengths[packet_number]);
if (packet_length < 40)
{
/* Should never happen */
@@ -61,10 +56,9 @@
}
/* Copy the header information */
- memcpy ((void *)packet, (void *)headers[packets_processed], HEADER_SIZE);
+ memcpy ((void *)packet, (void *)headers[packet_number], HEADER_SIZE);
#endif
- packets_processed ++;
return packet;
}
@@ -72,7 +66,6 @@
unsigned int
packet_size (unsigned int packet_number)
{
- if (packet_number == MAX_PACKETS)
- return (packet_lengths[packets_processed]);
- else return (packet_lengths[packet_number]);
+ packet_number %= MAX_PACKETS;
+ return (packet_lengths[packet_number]);
}
Modified: test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/packet.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/packet.h?rev=46447&r1=46446&r2=46447&view=diff
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/packet.h (original)
+++ test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/packet.h Mon Jan 28 01:23:41 2008
@@ -13,9 +13,9 @@
* and improve what you give them.
*
*/
-#define MAX_PACKETS 1500
+#define MAX_PACKETS 100
-char *get_next_packet ();
+char *get_next_packet (int);
/* For testing...*/
unsigned int packet_size (unsigned int);
Modified: test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/url.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/url.c?rev=46447&r1=46446&r2=46447&view=diff
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/url.c (original)
+++ test-suite/trunk/MultiSource/Benchmarks/Trimaran/netbench-url/url.c Mon Jan 28 01:23:41 2008
@@ -113,7 +113,7 @@
{
long original_checksum, checksum;
- packet = get_next_packet();
+ packet = get_next_packet(i);
/* We only have to check the checksum to make sure nothing is changed.. */
#ifdef LITTLE_ENDIAN
More information about the llvm-commits
mailing list