diff options
author | Finn Williams <Finn.Williams@arm.com> | 2020-04-29 12:00:24 +0100 |
---|---|---|
committer | finn.williams <finn.williams@arm.com> | 2020-04-30 10:09:59 +0000 |
commit | 9937f9359ac4eeefc3535b66eddddd1b4f067c54 (patch) | |
tree | e10ef064afea0ab59198cec63af34f439dcd13a0 /profiling/common/include | |
parent | be7e35c5994c379e165fb1b7053301afb5d52e04 (diff) | |
download | armnn-9937f9359ac4eeefc3535b66eddddd1b4f067c54.tar.gz |
IVGCVSW-4732 Move NetworkSockets class needs to profiling/common
Signed-off-by: Finn Williams <Finn.Williams@arm.com>
Change-Id: Ie1bd73e6c1818277943e70eaf73b4d9a26da4758
Diffstat (limited to 'profiling/common/include')
-rw-r--r-- | profiling/common/include/NetworkSockets.hpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/profiling/common/include/NetworkSockets.hpp b/profiling/common/include/NetworkSockets.hpp new file mode 100644 index 0000000000..b9e58aac1d --- /dev/null +++ b/profiling/common/include/NetworkSockets.hpp @@ -0,0 +1,59 @@ +// +// Copyright © 2020 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +// This file (along with its corresponding .cpp) defines a very thin platform abstraction layer for the use of +// networking sockets. Thankfully the underlying APIs on Windows and Linux are very similar so not much conversion +// is needed (typically just forwarding the parameters to a differently named function). +// Some of the APIs are in fact completely identical and so no forwarding function is needed. + +#pragma once + +#if defined(__unix__) +#include <poll.h> +#include <sys/ioctl.h> +#include <sys/socket.h> +#include <sys/un.h> +#elif defined(_MSC_VER) +#include <winsock2.h> +#include <afunix.h> +#endif + +namespace armnnUtils +{ +namespace Sockets +{ + +#if defined(__unix__) + +using Socket = int; +using PollFd = pollfd; + +#elif defined(_MSC_VER) + +using Socket = SOCKET; +using PollFd = WSAPOLLFD; +#define SOCK_CLOEXEC 0 + +#endif + +/// Performs any required one-time setup. +bool Initialize(); + +int Close(Socket s); + +bool SetNonBlocking(Socket s); + +long Write(Socket s, const void* buf, size_t len); + +long Read(Socket s, void* buf, size_t len); + +int Ioctl(Socket s, unsigned long int cmd, void* arg); + +int Poll(PollFd* fds, nfds_t numFds, int timeout); + +Socket Accept(Socket s, sockaddr* addr, socklen_t* addrlen, int flags); + +} +} |