aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Flynn <jim.flynn@arm.com>2020-07-14 14:26:27 +0100
committerJim Flynn <jim.flynn@arm.com>2020-07-14 16:12:12 +0000
commit6da6a45d09ac8d7ea956c09ba241c9e0840ecb25 (patch)
tree0b3a85aef2b5d03e036c60e344188ae1c5057849
parentbac9b35df7c59f6b5b61e1d233a49bdb88a973ba (diff)
downloadarmnn-6da6a45d09ac8d7ea956c09ba241c9e0840ecb25.tar.gz
Make it build on MACOSX
Still need to explicitly defined -DCMAKE_CXX_FLAGS=--std=c++14 which that flags should goes into CMakefile.txt JF: Fixed merge failure by removing Filesystem.cpp and updated the copyright headers to new standard Change-Id: I6d0886bd86bc1ddb593028194852551d43c77745 Signed-off-by: Keith Mok <ek9852@gmail.com> Signed-off-by: Jim Flynn <jim.flynn@arm.com>
-rw-r--r--profiling/common/include/NetworkSockets.hpp10
-rw-r--r--profiling/common/src/NetworkSockets.cpp18
-rw-r--r--src/armnnUtils/Filesystem.cpp2
-rw-r--r--src/armnnUtils/Filesystem.hpp2
-rw-r--r--src/armnnUtils/Processes.cpp6
-rw-r--r--src/armnnUtils/Processes.hpp2
-rw-r--r--src/backends/backendsCommon/DynamicBackendUtils.cpp8
-rw-r--r--src/backends/backendsCommon/DynamicBackendUtils.hpp6
-rw-r--r--src/profiling/SocketProfilingConnection.cpp2
-rw-r--r--src/profiling/SocketProfilingConnection.hpp7
10 files changed, 38 insertions, 25 deletions
diff --git a/profiling/common/include/NetworkSockets.hpp b/profiling/common/include/NetworkSockets.hpp
index b970424e10..05a45ae90b 100644
--- a/profiling/common/include/NetworkSockets.hpp
+++ b/profiling/common/include/NetworkSockets.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -10,7 +10,7 @@
#pragma once
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
#include <poll.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
@@ -31,6 +31,12 @@ namespace Sockets
using Socket = int;
using PollFd = pollfd;
+#elif defined(__APPLE__)
+
+using Socket = int;
+using PollFd = pollfd;
+#define SOCK_CLOEXEC 0
+
#elif defined(_MSC_VER)
using Socket = SOCKET;
diff --git a/profiling/common/src/NetworkSockets.cpp b/profiling/common/src/NetworkSockets.cpp
index 3ae0644a0b..7f47c79b31 100644
--- a/profiling/common/src/NetworkSockets.cpp
+++ b/profiling/common/src/NetworkSockets.cpp
@@ -5,7 +5,7 @@
#include "common/include/NetworkSockets.hpp"
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
#include <unistd.h>
#include <fcntl.h>
#include <armnn/Conversion.hpp>
@@ -19,7 +19,7 @@ namespace Sockets
bool Initialize()
{
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
return true;
#elif defined(_MSC_VER)
WSADATA wsaData;
@@ -29,7 +29,7 @@ bool Initialize()
int Close(Socket s)
{
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
return close(s);
#elif defined(_MSC_VER)
return closesocket(s);
@@ -39,7 +39,7 @@ int Close(Socket s)
bool SetNonBlocking(Socket s)
{
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
const int currentFlags = fcntl(s, F_GETFL);
return fcntl(s, F_SETFL, currentFlags | O_NONBLOCK) == 0;
#elif defined(_MSC_VER)
@@ -51,7 +51,7 @@ bool SetNonBlocking(Socket s)
long Write(Socket s, const void* buf, size_t len)
{
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
return write(s, buf, len);
#elif defined(_MSC_VER)
return send(s, static_cast<const char*>(buf), static_cast<int>(len), 0);
@@ -61,7 +61,7 @@ long Write(Socket s, const void* buf, size_t len)
long Read(Socket s, void* buf, size_t len)
{
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
return read(s, buf, len);
#elif defined(_MSC_VER)
return recv(s, static_cast<char*>(buf), static_cast<int>(len), 0);
@@ -70,7 +70,7 @@ long Read(Socket s, void* buf, size_t len)
int Ioctl(Socket s, unsigned long int cmd, void* arg)
{
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
ARMNN_NO_CONVERSION_WARN_BEGIN
return ioctl(s, static_cast<int>(cmd), arg);
ARMNN_NO_CONVERSION_WARN_END
@@ -82,7 +82,7 @@ int Ioctl(Socket s, unsigned long int cmd, void* arg)
int Poll(PollFd* fds, nfds_t numFds, int timeout)
{
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
return poll(fds, numFds, timeout);
#elif defined(_MSC_VER)
return WSAPoll(fds, numFds, timeout);
@@ -94,6 +94,8 @@ armnnUtils::Sockets::Socket Accept(Socket s, sockaddr* addr, socklen_t* addrlen,
{
#if defined(__unix__)
return accept4(s, addr, addrlen, flags);
+#elif defined(__APPLE__)
+ return accept(s, addr, addrlen);
#elif defined(_MSC_VER)
return accept(s, addr, reinterpret_cast<int*>(addrlen));
#endif
diff --git a/src/armnnUtils/Filesystem.cpp b/src/armnnUtils/Filesystem.cpp
index ac9a414ae4..59d05239ae 100644
--- a/src/armnnUtils/Filesystem.cpp
+++ b/src/armnnUtils/Filesystem.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
diff --git a/src/armnnUtils/Filesystem.hpp b/src/armnnUtils/Filesystem.hpp
index 869b0c1b5e..3d93ce610d 100644
--- a/src/armnnUtils/Filesystem.hpp
+++ b/src/armnnUtils/Filesystem.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
diff --git a/src/armnnUtils/Processes.cpp b/src/armnnUtils/Processes.cpp
index 86593aaf5f..41b035b887 100644
--- a/src/armnnUtils/Processes.cpp
+++ b/src/armnnUtils/Processes.cpp
@@ -1,11 +1,11 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "Processes.hpp"
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
#include <unistd.h>
#elif defined(_MSC_VER)
#include "WindowsWrapper.hpp"
@@ -18,7 +18,7 @@ namespace Processes
int GetCurrentId()
{
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
return getpid();
#elif defined(_MSC_VER)
return ::GetCurrentProcessId();
diff --git a/src/armnnUtils/Processes.hpp b/src/armnnUtils/Processes.hpp
index 4e5e94b822..89704237db 100644
--- a/src/armnnUtils/Processes.hpp
+++ b/src/armnnUtils/Processes.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
diff --git a/src/backends/backendsCommon/DynamicBackendUtils.cpp b/src/backends/backendsCommon/DynamicBackendUtils.cpp
index 1abea114bd..46b5a52719 100644
--- a/src/backends/backendsCommon/DynamicBackendUtils.cpp
+++ b/src/backends/backendsCommon/DynamicBackendUtils.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -15,7 +15,7 @@ namespace armnn
void* DynamicBackendUtils::OpenHandle(const std::string& sharedObjectPath)
{
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
if (sharedObjectPath.empty())
{
throw RuntimeException("OpenHandle error: shared object path must not be empty");
@@ -35,7 +35,7 @@ void* DynamicBackendUtils::OpenHandle(const std::string& sharedObjectPath)
void DynamicBackendUtils::CloseHandle(const void* sharedObjectHandle)
{
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
if (!sharedObjectHandle)
{
return;
@@ -63,7 +63,7 @@ bool DynamicBackendUtils::IsBackendCompatibleImpl(const BackendVersion &backendA
std::string DynamicBackendUtils::GetDlError()
{
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
const char* errorMessage = dlerror();
if (!errorMessage)
{
diff --git a/src/backends/backendsCommon/DynamicBackendUtils.hpp b/src/backends/backendsCommon/DynamicBackendUtils.hpp
index f4cdd4db0c..63ee611cae 100644
--- a/src/backends/backendsCommon/DynamicBackendUtils.hpp
+++ b/src/backends/backendsCommon/DynamicBackendUtils.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2017 Arm Ltd. All rights reserved.
+// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -14,7 +14,7 @@
#include <string>
#include <vector>
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
#include <dlfcn.h>
#endif
@@ -61,7 +61,7 @@ private:
template<typename EntryPointType>
EntryPointType DynamicBackendUtils::GetEntryPoint(const void* sharedObjectHandle, const char* symbolName)
{
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
if (sharedObjectHandle == nullptr)
{
throw RuntimeException("GetEntryPoint error: invalid handle");
diff --git a/src/profiling/SocketProfilingConnection.cpp b/src/profiling/SocketProfilingConnection.cpp
index 31f930be84..c231045b10 100644
--- a/src/profiling/SocketProfilingConnection.cpp
+++ b/src/profiling/SocketProfilingConnection.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
diff --git a/src/profiling/SocketProfilingConnection.hpp b/src/profiling/SocketProfilingConnection.hpp
index 259ee131f1..a646c03d9c 100644
--- a/src/profiling/SocketProfilingConnection.hpp
+++ b/src/profiling/SocketProfilingConnection.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -29,8 +29,13 @@ private:
// Read a full packet from the socket.
Packet ReceivePacket();
+#ifndef __APPLE__
// To indicate we want to use an abstract UDS ensure the first character of the address is 0.
const char* m_GatorNamespace = "\0gatord_namespace";
+#else
+ // MACOSX does not support abstract UDS
+ const char* m_GatorNamespace = "/tmp/gatord_namespace";
+#endif
armnnUtils::Sockets::PollFd m_Socket[1]{};
};