1 The following patches are taken directly from:
3 https://github.com/esnet/iperf/pull/664
5 as an upstream submission.
7 commit b63d41b25f49a76d0be66edfb61bd4cb68921d55
8 Author: Philip Prindeville <philipp@redfish-solutions.com>
9 Date: Tue Oct 31 13:41:08 2017 -0600
11 Fix warnings about _GNU_SOURCE being redefined.
13 Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
15 diff --git a/src/iperf.h b/src/iperf.h
16 index bb951dc..b656784 100755
21 #include <sys/select.h>
22 #include <sys/socket.h>
27 #include <netinet/tcp.h>
29 #if defined(HAVE_CPUSET_SETAFFINITY)
30 diff --git a/src/iperf_api.c b/src/iperf_api.c
31 index ab30b93..9e41238 100755
35 * This code is distributed under a BSD style license, see the LICENSE file
36 * for complete information.
44 #include "iperf_config.h"
46 commit 315254cfc5f5682627f4a46ade3100bc3c64cfcc
47 Author: Philip Prindeville <philipp@redfish-solutions.com>
48 Date: Tue Oct 31 13:42:58 2017 -0600
50 Fix warnings of format-specified mismatching type
52 Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
54 diff --git a/src/iperf_tcp.c b/src/iperf_tcp.c
55 index 91cf032..6f86d5d 100644
59 * This code is distributed under a BSD style license, see the LICENSE
60 * file for complete information.
62 -#include "iperf_config.h"
71 +#if defined(HAVE_INTTYPES_H)
72 +# include <inttypes.h>
74 +# define PRIu64 "llu"
77 #if defined(HAVE_FLOWLABEL)
78 #include "flowlabel.h"
79 #endif /* HAVE_FLOWLABEL */
80 @@ -90,7 +94,7 @@ iperf_tcp_send(struct iperf_stream *sp)
81 sp->result->bytes_sent_this_interval += r;
84 - printf("sent %d bytes of %d, total %llu\n", r, sp->settings->blksize, sp->result->bytes_sent);
85 + printf("sent %d bytes of %d, total %" PRIu64 "\n", r, sp->settings->blksize, sp->result->bytes_sent);
89 diff --git a/src/iperf_udp.c b/src/iperf_udp.c
90 index a2ea6d0..d04ae44 100644
95 #include "portable_endian.h"
97 +#if defined(HAVE_INTTYPES_H)
98 +# include <inttypes.h>
100 +# define PRIu64 "llu"
105 * receives the data for UDP
106 @@ -98,7 +104,7 @@ iperf_udp_recv(struct iperf_stream *sp)
110 - fprintf(stderr, "pcount %llu packet_count %d\n", pcount, sp->packet_count);
111 + fprintf(stderr, "pcount %" PRIu64 " packet_count %d\n", pcount, sp->packet_count);
114 * Try to handle out of order packets. The way we do this
115 @@ -141,7 +147,7 @@ iperf_udp_recv(struct iperf_stream *sp)
117 /* Log the out-of-order packet */
119 - fprintf(stderr, "OUT OF ORDER - incoming packet sequence %llu but expected sequence %d on stream %d", pcount, sp->packet_count, sp->socket);
120 + fprintf(stderr, "OUT OF ORDER - incoming packet sequence %" PRIu64 " but expected sequence %d on stream %d", pcount, sp->packet_count, sp->socket);
124 @@ -220,7 +226,7 @@ iperf_udp_send(struct iperf_stream *sp)
125 sp->result->bytes_sent_this_interval += r;
128 - printf("sent %d bytes of %d, total %llu\n", r, sp->settings->blksize, sp->result->bytes_sent);
129 + printf("sent %d bytes of %d, total %" PRIu64 "\n", r, sp->settings->blksize, sp->result->bytes_sent);
134 commit 9a66b3b0349e0a158bb4940b668a5cbc7c245762
135 Author: Philip Prindeville <philipp@redfish-solutions.com>
136 Date: Tue Oct 31 13:44:34 2017 -0600
138 Simplify endianness checks
140 Linux can be built with too many types of C run-time library and it's
141 not reasonable to have to enumerate all of them, especially since at
142 least one of them (MUSL) goes out of its way to not be easily
145 Instead, leverage autoconf better for Linux/BSD to detect either
146 <endian.h> or <sys/endian.h> directly.
148 Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
150 diff --git a/configure.ac b/configure.ac
151 index f57e83f..cfb42ac 100644
154 @@ -101,6 +101,14 @@ AC_CHECK_HEADERS([netinet/sctp.h],
158 +AC_CHECK_HEADER([endian.h],
159 + AC_DEFINE([HAVE_ENDIAN_H], [1], [Define to 1 if you have the <endian.h> header file.]),
160 + AC_CHECK_HEADER([sys/endian.h],
161 + AC_DEFINE([HAVE_SYS_ENDIAN_H], [1], [Define to 1 if you have the <sys/endian.h> header file.]),
162 + AC_MSG_WARN([Couldn't find endian.h or sys/endian.h files: doing compile-time tests.])
166 if test "x$with_openssl" = "xno"; then
167 AC_MSG_WARN( [Building without OpenSSL; disabling iperf_auth functionality.] )
169 diff --git a/src/iperf_config.h.in b/src/iperf_config.h.in
170 index bd03935..a9e51ec 100644
171 --- a/src/iperf_config.h.in
172 +++ b/src/iperf_config.h.in
174 /* Define to 1 if you have the <dlfcn.h> header file. */
177 +/* Define to 1 if you have the <endian.h> header file. */
178 +#undef HAVE_ENDIAN_H
180 /* Have IPv6 flowlabel support. */
181 #undef HAVE_FLOWLABEL
184 /* Define to 1 if the system has the type `struct sctp_assoc_value'. */
185 #undef HAVE_STRUCT_SCTP_ASSOC_VALUE
187 +/* Define to 1 if you have the <sys/endian.h> header file. */
188 +#undef HAVE_SYS_ENDIAN_H
190 /* Define to 1 if you have the <sys/socket.h> header file. */
191 #undef HAVE_SYS_SOCKET_H
193 diff --git a/src/portable_endian.h b/src/portable_endian.h
194 index b86d37a..5dbc6e5 100644
195 --- a/src/portable_endian.h
196 +++ b/src/portable_endian.h
201 -// GLIBC / Linux with endian(3) support, which was added in glibc 2.9.
202 -// Intended to support CentOS 6 and newer.
203 -#if defined(__linux__) && \
204 - ((__GLIBC__ > 3) || \
205 - (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 9))
207 +#if defined(HAVE_ENDIAN_H)
210 +#elif defined(HAVE_SYS_ENDIAN_H)
211 +# include <sys/endian.h>
213 +# if defined(__OpenBSD__)
215 +# define be16toh(x) betoh16(x)
216 +# define le16toh(x) letoh16(x)
218 +# define be32toh(x) betoh32(x)
219 +# define le32toh(x) letoh32(x)
221 +# define be64toh(x) betoh64(x)
222 +# define le64toh(x) letoh64(x)
224 +# elif defined(__sgi)
226 +# include <netinet/in.h>
227 +# include <inttypes.h>
229 +# define be64toh(x) (x)
230 +# define htobe64(x) (x)
234 #elif defined(__CYGWIN__)
238 # define __LITTLE_ENDIAN LITTLE_ENDIAN
239 # define __PDP_ENDIAN PDP_ENDIAN
241 -#elif defined(__OpenBSD__)
243 -# include <sys/endian.h>
245 -# define be16toh(x) betoh16(x)
246 -# define le16toh(x) letoh16(x)
248 -# define be32toh(x) betoh32(x)
249 -# define le32toh(x) letoh32(x)
251 -# define be64toh(x) betoh64(x)
252 -# define le64toh(x) letoh64(x)
254 -#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
256 -# include <sys/endian.h>
258 -#elif defined(__sgi)
260 -# include <sys/endian.h>
261 -# include <netinet/in.h>
262 -# include <inttypes.h>
264 -# define be64toh(x) (x)
265 -# define htobe64(x) (x)
267 #elif defined(__sun) && defined(__SVR4)
269 # include <sys/types.h>
271 commit 7e7285d0daf92ef7beda8f78a6f63cc647a77f38
272 Author: Philip Prindeville <philipp@redfish-solutions.com>
273 Date: Tue Oct 31 13:48:06 2017 -0600
275 Sys headers should not be included directly
277 There's usually a top-level header which then includes the sys/
280 Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
282 diff --git a/src/net.c b/src/net.c
283 index af456cb..afd0022 100644
288 #include <sys/socket.h>
289 #include <sys/types.h>
290 -#include <sys/errno.h>
291 #include <netinet/in.h>
292 #include <netinet/tcp.h>
296 -#include <sys/fcntl.h>