aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/transport/udp_common.hpp
diff options
context:
space:
mode:
authorBrent Stapleton <brent.stapleton@ettus.com>2019-01-18 09:45:34 -0800
committerBrent Stapleton <brent.stapleton@ettus.com>2019-01-18 17:51:35 -0800
commita53130679944ddd179593259eb953b89ab1a7a38 (patch)
tree5d8274750bed0b21aa133bc93d97d75bbce0ecd9 /host/lib/transport/udp_common.hpp
parent2a44d6836ca08b6b67b83b63487b838e138ac379 (diff)
downloaduhd-a53130679944ddd179593259eb953b89ab1a7a38.tar.gz
uhd-a53130679944ddd179593259eb953b89ab1a7a38.tar.bz2
uhd-a53130679944ddd179593259eb953b89ab1a7a38.zip
lib: transport: apply clang-format
This is a continuation of 967be2a4. $ find host/lib/transport -iname *.hpp -o -iname *.cpp |\ xargs clang-format -i -style=file Skipping host/lib/transport/nirio/ because of build errors. $ git checkout host/lib/transport/nirio
Diffstat (limited to 'host/lib/transport/udp_common.hpp')
-rw-r--r--host/lib/transport/udp_common.hpp81
1 files changed, 41 insertions, 40 deletions
diff --git a/host/lib/transport/udp_common.hpp b/host/lib/transport/udp_common.hpp
index 19457903b..f320e3d85 100644
--- a/host/lib/transport/udp_common.hpp
+++ b/host/lib/transport/udp_common.hpp
@@ -11,60 +11,61 @@
#include <uhd/config.hpp>
#include <boost/asio.hpp>
-namespace uhd{ namespace transport{
+namespace uhd { namespace transport {
- // Jumbo frames can be up to 9600 bytes;
- static const size_t MAX_ETHERNET_MTU = 9600;
+// Jumbo frames can be up to 9600 bytes;
+static const size_t MAX_ETHERNET_MTU = 9600;
#if defined(UHD_PLATFORM_MACOS) || defined(UHD_PLATFORM_BSD)
- // MacOS limits socket buffer size to 1 Mib
- static const size_t MAX_BUFF_SIZE_ETH_MACOS = 0x100000; //1Mib
+// MacOS limits socket buffer size to 1 Mib
+static const size_t MAX_BUFF_SIZE_ETH_MACOS = 0x100000; // 1Mib
#endif
- typedef boost::shared_ptr<boost::asio::ip::udp::socket> socket_sptr;
+typedef boost::shared_ptr<boost::asio::ip::udp::socket> socket_sptr;
- /*!
- * Wait for the socket to become ready for a receive operation.
- * \param sock_fd the open socket file descriptor
- * \param timeout the timeout duration in seconds
- * \return true when the socket is ready for receive
- */
- UHD_INLINE bool wait_for_recv_ready(int sock_fd, double timeout){
+/*!
+ * Wait for the socket to become ready for a receive operation.
+ * \param sock_fd the open socket file descriptor
+ * \param timeout the timeout duration in seconds
+ * \return true when the socket is ready for receive
+ */
+UHD_INLINE bool wait_for_recv_ready(int sock_fd, double timeout)
+{
#ifdef UHD_PLATFORM_WIN32 // select is more portable than poll unfortunately
- //setup timeval for timeout
- timeval tv;
- //If the tv_usec > 1 second on some platforms, select will
- //error EINVAL: An invalid timeout interval was specified.
- tv.tv_sec = int(timeout);
- tv.tv_usec = int(timeout*1000000)%1000000;
+ // setup timeval for timeout
+ timeval tv;
+ // If the tv_usec > 1 second on some platforms, select will
+ // error EINVAL: An invalid timeout interval was specified.
+ tv.tv_sec = int(timeout);
+ tv.tv_usec = int(timeout * 1000000) % 1000000;
- //setup rset for timeout
- fd_set rset;
- FD_ZERO(&rset);
- FD_SET(sock_fd, &rset);
+ // setup rset for timeout
+ fd_set rset;
+ FD_ZERO(&rset);
+ FD_SET(sock_fd, &rset);
- //http://www.gnu.org/s/hello/manual/libc/Interrupted-Primitives.html
- //This macro is provided with gcc to properly deal with EINTR.
- //If not provided, define an empty macro, assume that is OK
- #ifndef TEMP_FAILURE_RETRY
- #define TEMP_FAILURE_RETRY(x) (x)
- #endif
+// http://www.gnu.org/s/hello/manual/libc/Interrupted-Primitives.html
+// This macro is provided with gcc to properly deal with EINTR.
+// If not provided, define an empty macro, assume that is OK
+# ifndef TEMP_FAILURE_RETRY
+# define TEMP_FAILURE_RETRY(x) (x)
+# endif
- //call select with timeout on receive socket
- return TEMP_FAILURE_RETRY(::select(sock_fd+1, &rset, NULL, NULL, &tv)) > 0;
+ // call select with timeout on receive socket
+ return TEMP_FAILURE_RETRY(::select(sock_fd + 1, &rset, NULL, NULL, &tv)) > 0;
#else
- //calculate the total timeout in milliseconds (from seconds)
- int total_timeout = int(timeout*1000);
+ // calculate the total timeout in milliseconds (from seconds)
+ int total_timeout = int(timeout * 1000);
- pollfd pfd_read;
- pfd_read.fd = sock_fd;
- pfd_read.events = POLLIN;
+ pollfd pfd_read;
+ pfd_read.fd = sock_fd;
+ pfd_read.events = POLLIN;
- //call poll with timeout on receive socket
- return ::poll(&pfd_read, 1, total_timeout) > 0;
+ // call poll with timeout on receive socket
+ return ::poll(&pfd_read, 1, total_timeout) > 0;
#endif
- }
+}
-}} //namespace uhd::transport
+}} // namespace uhd::transport
#endif /* INCLUDED_LIBUHD_TRANSPORT_VRT_PACKET_HANDLER_HPP */