From 180ce075dd8db2f6ec4597af8c06ba569e5787df Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Thu, 6 Dec 2012 23:34:31 -0800 Subject: [PATCH] Refresh of udpong --- examples/common.c | 2 ++ examples/common.h | 24 ++++++++++++++++++++++++ examples/rstream.c | 19 +------------------ examples/udpong.c | 17 +---------------- 4 files changed, 28 insertions(+), 34 deletions(-) diff --git a/examples/common.c b/examples/common.c index 43bfb6b0..939f50c7 100644 --- a/examples/common.c +++ b/examples/common.c @@ -45,6 +45,8 @@ #include #include "common.h" +int use_rs = 1; + int get_rdma_addr(char *src, char *dst, char *port, struct rdma_addrinfo *hints, struct rdma_addrinfo **rai) { diff --git a/examples/common.h b/examples/common.h index ef0ea7b5..37dc79eb 100644 --- a/examples/common.h +++ b/examples/common.h @@ -35,8 +35,10 @@ #include #include #include +#include #include +#include #if __BYTE_ORDER == __BIG_ENDIAN static inline uint64_t cpu_to_be64(uint64_t x) { return x; } @@ -46,6 +48,28 @@ static inline uint64_t cpu_to_be64(uint64_t x) { return bswap_64(x); } static inline uint32_t cpu_to_be32(uint32_t x) { return bswap_32(x); } #endif +extern int use_rs; + +#define rs_socket(f,t,p) use_rs ? rsocket(f,t,p) : socket(f,t,p) +#define rs_bind(s,a,l) use_rs ? rbind(s,a,l) : bind(s,a,l) +#define rs_listen(s,b) use_rs ? rlisten(s,b) : listen(s,b) +#define rs_connect(s,a,l) use_rs ? rconnect(s,a,l) : connect(s,a,l) +#define rs_accept(s,a,l) use_rs ? raccept(s,a,l) : accept(s,a,l) +#define rs_shutdown(s,h) use_rs ? rshutdown(s,h) : shutdown(s,h) +#define rs_close(s) use_rs ? rclose(s) : close(s) +#define rs_recv(s,b,l,f) use_rs ? rrecv(s,b,l,f) : recv(s,b,l,f) +#define rs_send(s,b,l,f) use_rs ? rsend(s,b,l,f) : send(s,b,l,f) +#define rs_recvfrom(s,b,l,f,a,al) \ + use_rs ? rrecvfrom(s,b,l,f,a,al) : recvfrom(s,b,l,f,a,al) +#define rs_sendto(s,b,l,f,a,al) \ + use_rs ? rsendto(s,b,l,f,a,al) : sendto(s,b,l,fa,al) +#define rs_poll(f,n,t) use_rs ? rpoll(f,n,t) : poll(f,n,t) +#define rs_fcntl(s,c,p) use_rs ? rfcntl(s,c,p) : fcntl(s,c,p) +#define rs_setsockopt(s,l,n,v,ol) \ + use_rs ? rsetsockopt(s,l,n,v,ol) : setsockopt(s,l,n,v,ol) +#define rs_getsockopt(s,l,n,v,ol) \ + use_rs ? rgetsockopt(s,l,n,v,ol) : getsockopt(s,l,n,v,ol) + union socket_addr { struct sockaddr sa; struct sockaddr_in sin; diff --git a/examples/rstream.c b/examples/rstream.c index fa7491c2..617710e9 100644 --- a/examples/rstream.c +++ b/examples/rstream.c @@ -45,7 +45,7 @@ #include #include -include "common.h" +#include "common.h" struct test_size_param { int size; @@ -80,7 +80,6 @@ enum rs_optimization { }; static int rs, lrs; -static int use_rs = 1; static int use_async; static int verify; static int flags = MSG_DONTWAIT; @@ -101,22 +100,6 @@ static char *src_addr; static struct timeval start, end; static void *buf; -#define rs_socket(f,t,p) use_rs ? rsocket(f,t,p) : socket(f,t,p) -#define rs_bind(s,a,l) use_rs ? rbind(s,a,l) : bind(s,a,l) -#define rs_listen(s,b) use_rs ? rlisten(s,b) : listen(s,b) -#define rs_connect(s,a,l) use_rs ? rconnect(s,a,l) : connect(s,a,l) -#define rs_accept(s,a,l) use_rs ? raccept(s,a,l) : accept(s,a,l) -#define rs_shutdown(s,h) use_rs ? rshutdown(s,h) : shutdown(s,h) -#define rs_close(s) use_rs ? rclose(s) : close(s) -#define rs_recv(s,b,l,f) use_rs ? rrecv(s,b,l,f) : recv(s,b,l,f) -#define rs_send(s,b,l,f) use_rs ? rsend(s,b,l,f) : send(s,b,l,f) -#define rs_poll(f,n,t) use_rs ? rpoll(f,n,t) : poll(f,n,t) -#define rs_fcntl(s,c,p) use_rs ? rfcntl(s,c,p) : fcntl(s,c,p) -#define rs_setsockopt(s,l,n,v,ol) \ - use_rs ? rsetsockopt(s,l,n,v,ol) : setsockopt(s,l,n,v,ol) -#define rs_getsockopt(s,l,n,v,ol) \ - use_rs ? rgetsockopt(s,l,n,v,ol) : getsockopt(s,l,n,v,ol) - static void show_perf(void) { char str[32]; diff --git a/examples/udpong.c b/examples/udpong.c index d29e5848..4adec2f1 100644 --- a/examples/udpong.c +++ b/examples/udpong.c @@ -45,6 +45,7 @@ #include #include +#include "common.h" static int test_size[] = { { 1 << 6 }, @@ -80,7 +81,6 @@ static struct client clients[256]; static int id; static int rs; -static int use_rs = 1; static int use_async; static int flags = MSG_DONTWAIT; static int poll_timeout; @@ -98,21 +98,6 @@ static socklen_t addrlen; static struct timeval start, end; static struct message msg; -#define rs_socket(f,t,p) use_rs ? rsocket(f,t,p) : socket(f,t,p) -#define rs_bind(s,a,l) use_rs ? rbind(s,a,l) : bind(s,a,l) -#define rs_connect(s,a,l) use_rs ? rconnect(s,a,l) : connect(s,a,l) -#define rs_close(s) use_rs ? rclose(s) : close(s) -#define rs_recvfrom(s,b,l,f,a,al) \ - use_rs ? rrecvfrom(s,b,l,f,a,al) : recvfrom(s,b,l,f,a,al) -#define rs_sendto(s,b,l,f,a,al) \ - use_rs ? rsendto(s,b,l,f,a,al) : sendto(s,b,l,fa,al) -#define rs_poll(f,n,t) use_rs ? rpoll(f,n,t) : poll(f,n,t) -#define rs_fcntl(s,c,p) use_rs ? rfcntl(s,c,p) : fcntl(s,c,p) -#define rs_setsockopt(s,l,n,v,ol) \ - use_rs ? rsetsockopt(s,l,n,v,ol) : setsockopt(s,l,n,v,ol) -#define rs_getsockopt(s,l,n,v,ol) \ - use_rs ? rgetsockopt(s,l,n,v,ol) : getsockopt(s,l,n,v,ol) - static void show_perf(void) { char str[32]; -- 2.41.0