Skip to content

Commit c50a626

Browse files
author
Neil T. Dantam
committed
Fix ipcbench build
1 parent 8b01819 commit c50a626

File tree

12 files changed

+228
-58
lines changed

12 files changed

+228
-58
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,4 @@ modules.order
134134
/mask
135135
/ach-poll-example
136136
/debian/libach4
137+
/ipcbench

Makefile.am

Lines changed: 96 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
ACLOCAL_AMFLAGS = -I m4
22

3+
BUILT_SOURCES =
4+
35
EXTRA_DIST = \
46
spin
57

@@ -87,9 +89,99 @@ achd_SOURCES = src/achd/achd.c \
8789
achd_LDADD = libach.la libachutil.la
8890

8991

90-
bin_PROGRAMS += achbench
91-
achbench_SOURCES = src/ach-bench.c
92-
achbench_LDADD = libach.la libachutil.la
92+
# bin_PROGRAMS += achbench
93+
# achbench_SOURCES = src/ach-bench.c
94+
# achbench_LDADD = libach.la libachutil.la
95+
96+
bin_PROGRAMS += ipcbench
97+
ipcbench_SOURCES = benchmark/src/ipcbench.c
98+
ipcbench_SOURCES += benchmark/src/pipe.c \
99+
benchmark/src/mq.c \
100+
benchmark/src/tcp.c \
101+
benchmark/src/unix.c \
102+
benchmark/src/udp.c \
103+
benchmark/src/localdgram.c \
104+
benchmark/src/udp_multicast.c
105+
ipcbench_SOURCES += benchmark/src/ach.c
106+
AM_CPPFLAGS += -I$(top_srcdir)/benchmark/include
107+
108+
## LCM ##
109+
if HAVE_LCM
110+
111+
bin_PROGRAMS += lcm_buffer
112+
113+
lcm_buffer_SOURCES = src/lcm_buffer.c ipcbench_lcm_timestamp_t.c
114+
lcm_buffer_LDADD = -llcm
115+
116+
ipcbench_SOURCES += ipcbench_lcm_timestamp_t.c src/lcm.c
117+
LDADD_LCM = -llcm
118+
BUILT_LCM = ipcbench_lcm_timestamp_t.c ipcbench_lcm_timestamp_t.h
119+
120+
ipcbench_lcm_timestamp_t.h: ipcbench_lcm_timestamp_t.c
121+
122+
ipcbench_lcm_timestamp_t.c: src/lcm_msg.lcm
123+
lcm-gen -c $<
124+
125+
endif
126+
127+
## TAO ##
128+
if HAVE_TAO
129+
130+
bin_PROGRAMS += ace_server
131+
BUILT_TAO = .idlgen.stamp
132+
133+
134+
.idlgen.stamp: src/corba/ipcbench.idl
135+
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(ACE_ROOT)/lib \
136+
$(ACE_ROOT)/TAO/TAO_IDL/tao_idl $<
137+
touch $@
138+
139+
ipcbenchS.cpp: .idlgen.stamp
140+
ipcbenchC.cpp: .idlgen.stamp
141+
ipcbenchS.h: .idlgen.stamp
142+
ipcbenchC.h: .idlgen.stamp
143+
144+
ace_server_SOURCES = src/corba/server.cpp ipcbenchS.cpp ipcbenchC.cpp
145+
ace_server_LDADD = \
146+
-lACE -lTAO \
147+
-lTAO_AnyTypeCode \
148+
-lTAO_TypeCodeFactory \
149+
-lTAO_IDL_BE \
150+
-lTAO_IDL_FE \
151+
-lTAO_PortableServer \
152+
-lTAO_IFR_Client
153+
154+
155+
ipcbench_SOURCES += src/corba/corba.cpp ipcbenchC.cpp ipcbenchS.cpp src/corba/cos.cpp
156+
LDADD_TAO = \
157+
-lACE -lTAO \
158+
-lTAO_AnyTypeCode \
159+
-lTAO_Svc_Utils \
160+
-lTAO_Messaging \
161+
-lTAO_Valuetype \
162+
-lTAO_PI \
163+
-lTAO_CodecFactory \
164+
-lTAO_DynamicInterface \
165+
-lTAO_CosEvent_Skel \
166+
-lTAO_CosEvent \
167+
-lTAO_CosNaming \
168+
-lTAO_CosNotification \
169+
-lTAO_CosTime \
170+
-lTAO_CosTrading \
171+
-lTAO_CosEvent_Serv \
172+
-lTAO_TypeCodeFactory \
173+
-lTAO_IDL_BE \
174+
-lTAO_IDL_FE \
175+
-lTAO_PortableServer \
176+
-lTAO_IFR_Client
177+
endif
178+
179+
# Link Libraries
180+
ipcbench_LDADD = $(LDADD_LCM) $(LDADD_TAO) libach.la
181+
182+
BUILT_SOURCES += $(BUILT_LCM) $(BUILT_TAO)
183+
184+
93185

94186
noinst_PROGRAMS = ach-example
95187
ach_example_SOURCES = src/ach-example.c
@@ -201,7 +293,7 @@ EXTRA_DIST += $(JSOURCES)
201293

202294
if BUILD_JAVA
203295

204-
BUILT_SOURCES = org_golems_ach_Lib.h
296+
BUILT_SOURCES += org_golems_ach_Lib.h
205297

206298

207299
JCLASSES = \

benchmark/include/util.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ static struct timespec get_ticks() {
1515

1616
static void calibrate(void) {
1717
/* warm up */
18-
for( size_t i = 0; i < 10; i++) get_ticks();
18+
size_t i;
19+
for( i = 0; i < 10; i++) get_ticks();
1920

2021
/* Average tick time */
2122
double a = 0;
2223
struct timespec r0,r1;
2324
overhead = 0;
24-
for( size_t i = 0; i<1000; i++ ) {
25+
for( i = 0; i<1000; i++ ) {
2526
r0 = get_ticks();
2627
r1 = get_ticks();
2728
a += ticks_delta(r0,r1);

benchmark/src/ach.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ static void s_init(enum ach_map map)
5555
{
5656
channel = (struct ach_channel*)calloc(ipcbench_cnt, sizeof(struct ach_channel));
5757

58-
for( size_t i = 0; i < ipcbench_cnt; i ++ ) {
58+
size_t i;
59+
enum ach_status r;
60+
for( i = 0; i < ipcbench_cnt; i ++ ) {
5961
char buf[64];
60-
snprintf( buf, sizeof(buf), CHAN_NAME "-%d", i );
61-
62-
ach_status_t r = ach_unlink(buf); /* delete first */
62+
snprintf( buf, sizeof(buf), CHAN_NAME "-%lu", i );
6363

64+
r = ach_unlink(buf); /* delete first */
6465
if( !( ACH_OK == r || ACH_ENOENT == r) ) {
6566
fprintf(stderr, "ach_unlink: %s\n", ach_result_to_string(r) );
6667
abort();
@@ -87,13 +88,13 @@ static void s_init(enum ach_map map)
8788
} else if( ach_status_match(r, ACH_MASK_ENOENT | ACH_MASK_EACCES) ) {
8889
usleep(1000); /* Race against udev */
8990
} else {
90-
fprintf(stderr, "ach_open", ach_result_to_string(r) );
91+
fprintf(stderr, "ach_open: %s", ach_result_to_string(r) );
9192
abort();
9293
}
9394
}
9495

9596
if( ipcbench_cnt > 1 ) {
96-
enum ach_status r = ach_channel_fd(&channel[i], &ipcbench_pfd[i].fd);
97+
r = ach_channel_fd(&channel[i], &ipcbench_pfd[i].fd);
9798
if( ACH_OK != r ) {
9899
fprintf(stderr, "ach_channel_fd: %s\n", ach_result_to_string(r));
99100
abort();
@@ -115,9 +116,10 @@ static void s_init_kernel()
115116
}
116117

117118
static void s_destroy(void) {
118-
for( size_t i = 0; i < ipcbench_cnt; i ++ ) {
119+
size_t i;
120+
for( i = 0; i < ipcbench_cnt; i ++ ) {
119121
char buf[64];
120-
snprintf( buf, sizeof(buf), CHAN_NAME "-%d", i );
122+
snprintf( buf, sizeof(buf), CHAN_NAME "-%lu", i );
121123

122124
enum ach_status r = ach_unlink(buf);
123125
if( ACH_OK != r ) {

benchmark/src/ipcbench.c

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#endif //HAVE_CONFIG
4646

4747
#include <signal.h>
48+
#include <math.h>
4849
#include <sys/wait.h>
4950
#include "ipcbench.h"
5051
#include "util.h"
@@ -125,7 +126,8 @@ static void recv(struct ipcbench_vtab *vtab, int emit) {
125126
}
126127

127128
/* warm up */
128-
for( size_t i = 0; i < opt_discard; i ++ ) {
129+
size_t i;
130+
for( i = 0; i < opt_discard; i ++ ) {
129131
struct timespec ts;
130132
vtab->recv(&ts );
131133
}
@@ -197,7 +199,7 @@ int main( int argc, char **argv ) {
197199

198200

199201
/* Parse args */
200-
const char *type = "ach";
202+
const char *type = sym_vtabs[0].name;
201203
char *endptr = 0;
202204
int c;
203205
while( (c = getopt( argc, argv, "lt:f:s:S:c:d:v?V")) != -1 ) {
@@ -217,10 +219,13 @@ int main( int argc, char **argv ) {
217219
}
218220
break;
219221
case 'l':
220-
for( size_t i = 0; NULL != sym_vtabs[i].name; i++ ) {
222+
{
223+
size_t i;
224+
for( i = 0; NULL != sym_vtabs[i].name; i++ ) {
221225
puts( sym_vtabs[i].name );
222226
}
223227
exit(EXIT_SUCCESS);
228+
}
224229
case 's':
225230
opt_subscribers = (size_t)atoi(optarg);
226231
break;
@@ -292,8 +297,8 @@ int main( int argc, char **argv ) {
292297
/* Compute period */
293298
{
294299
double period = 1.0 / opt_freq;
295-
ipcbench_period.tv_sec = period;
296-
ipcbench_period.tv_nsec = (period - (time_t)period) * 1e9;
300+
ipcbench_period.tv_sec = (time_t)period;
301+
ipcbench_period.tv_nsec = (long) ((period - floor(period)) * 1e9);
297302
}
298303

299304
/* Setup message queue */
@@ -314,27 +319,33 @@ int main( int argc, char **argv ) {
314319

315320
/* Execute */
316321
ipcbench_pfd = (struct pollfd*)calloc(ipcbench_cnt, sizeof(struct pollfd));
317-
for( size_t i = 0; i < ipcbench_cnt; i ++ ) {
318-
ipcbench_pfd[i].events = POLLIN;
322+
{
323+
size_t i;
324+
for( i = 0; i < ipcbench_cnt; i ++ ) {
325+
ipcbench_pfd[i].events = POLLIN;
326+
}
319327
}
320328
if( vtab->init ) vtab->init();
321329

322330
/* Fork subscribers */
323331
pid_t pid_listen[opt_subscribers + opt_nonrt_subscribers];
324-
for( size_t i = 0; i < opt_subscribers + opt_nonrt_subscribers; i ++ ) {
325-
pid_listen[i] = fork();
326-
if( 0 == pid_listen[i] ) {
327-
int emit = 1;
328-
if( i >= opt_subscribers ) {
329-
make_realtime(0);
330-
emit=0;
332+
{
333+
size_t i;
334+
for( i = 0; i < opt_subscribers + opt_nonrt_subscribers; i ++ ) {
335+
pid_listen[i] = fork();
336+
if( 0 == pid_listen[i] ) {
337+
int emit = 1;
338+
if( i >= opt_subscribers ) {
339+
make_realtime(0);
340+
emit=0;
341+
}
342+
if( vtab->recv_loop ) vtab->recv_loop(emit);
343+
else recv(vtab, emit);
344+
return 0;
345+
} else if ( pid_listen[i] < 0 ) {
346+
perror("Couldn't fork\n");
347+
abort();
331348
}
332-
if( vtab->recv_loop ) vtab->recv_loop(emit);
333-
else recv(vtab, emit);
334-
return 0;
335-
} else if ( pid_listen[i] < 0 ) {
336-
perror("Couldn't fork\n");
337-
abort();
338349
}
339350
}
340351

@@ -350,9 +361,12 @@ int main( int argc, char **argv ) {
350361
}
351362

352363
/* Wait */
353-
sleep(opt_sec);
354-
for( size_t i = 0; i < opt_subscribers; i ++ ) {
355-
kill_wait(pid_listen[i]);
364+
sleep((unsigned)opt_sec);
365+
{
366+
size_t i;
367+
for( i = 0; i < opt_subscribers; i ++ ) {
368+
kill_wait(pid_listen[i]);
369+
}
356370
}
357371
kill_wait(pid_send);
358372

@@ -361,6 +375,8 @@ int main( int argc, char **argv ) {
361375

362376
if( vtab->destroy ) vtab->destroy();
363377

378+
/* remove mq */
379+
//mq_unlink(MQ);
364380
return 0;
365381

366382
}

benchmark/src/localdgram.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@
5858
static int *sock;
5959
static struct sockaddr_un *addr;
6060

61-
#define NAME "/tmp/ipcbench-%d.dsock"
61+
#define NAME "/tmp/ipcbench-%lu.dsock"
6262

6363

6464
static void s_init(void) {
65-
for( size_t i = 0; i < ipcbench_cnt; i ++ ) {
65+
size_t i;
66+
for( i = 0; i < ipcbench_cnt; i ++ ) {
6667
char buf[64];
6768
snprintf(buf, sizeof(buf), NAME, i);
6869
unlink( buf );
@@ -72,7 +73,8 @@ static void s_init(void) {
7273
}
7374

7475
static void s_init_send(void) {
75-
for( size_t i = 0; i < ipcbench_cnt; i ++ ) {
76+
size_t i;
77+
for( i = 0; i < ipcbench_cnt; i ++ ) {
7678
sock[i] = socket( PF_UNIX, SOCK_DGRAM, 0 );
7779
if( sock[i] < 0 ) {
7880
perror( "Could not create socket");
@@ -89,7 +91,8 @@ static void s_init_send(void) {
8991
static void s_init_recv(void) {
9092
s_init_send();
9193

92-
for( size_t i = 0; i < ipcbench_cnt; i ++ ) {
94+
size_t i;
95+
for( i = 0; i < ipcbench_cnt; i ++ ) {
9396
if (bind(sock[i], (struct sockaddr *) &addr[i], sizeof(struct sockaddr_un)) < 0) {
9497
perror("Failed to bind the socket");
9598
abort();

benchmark/src/mq.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ static mqd_t *fd;
5555
static void s_open(int flag) {
5656
char buf[64];
5757
fd = (mqd_t*)calloc(ipcbench_cnt,sizeof(mqd_t));
58-
for( size_t i = 0; i < ipcbench_cnt; i ++ ) {
59-
snprintf(buf, sizeof(buf), NAME "-%d");
58+
size_t i;
59+
for( i = 0; i < ipcbench_cnt; i ++ ) {
60+
snprintf(buf, sizeof(buf), NAME "-%lu", i);
6061
struct mq_attr attr = {.mq_maxmsg = 10,
6162
.mq_msgsize = sizeof(struct timespec),
6263
.mq_flags = 0};

benchmark/src/pipe.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ static int *fd;
5353
static void s_init() {
5454
printf("pipe\n");
5555
fd = (int*) malloc( 2 * sizeof(int) * ipcbench_cnt );
56-
for( size_t i = 0; i < ipcbench_cnt; i ++ ) {
56+
size_t i;
57+
for( i = 0; i < ipcbench_cnt; i ++ ) {
5758
if( pipe(fd + 2*i) ) {
5859
perror( "could not create pipe" );
5960
abort();

0 commit comments

Comments
 (0)