Skip to content

Commit

Permalink
Bringup of Thunder on MACOS (#1680)
Browse files Browse the repository at this point in the history
Co-authored-by: MFransen69 <[email protected]>
  • Loading branch information
HaseenaSainul and MFransen69 authored Jul 2, 2024
1 parent caf8bfd commit 850b57b
Show file tree
Hide file tree
Showing 67 changed files with 686 additions and 199 deletions.
13 changes: 10 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,16 @@ workspace/
/artifacts/Release
*.pyc
Source/Thunder/Thunder
Source/Thunder/Thunder-1.0.0
Source/Thunder/Thunder-*
Source/Thunder/config/
Source/ThunderPlugin/ThunderPlugin
Source/ThunderPlugin/ThunderPlugin-1.0.0
Source/Thunder/scripts/wpeframework
Source/ThunderPlugin/ThunderPlugin-*
Source/extensions/localtracer/example/local_trace_test
Source/extensions/privilegedrequest/example/fdpassing
Source/messaging/tracing.h
Source/plugins/json/
Thunder.cmake
*/*/generated/
*/*/*/generated/
install_manifest.txt
site/
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
# the RPATH to be used when installing, but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()

Expand Down
10 changes: 8 additions & 2 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ endif()

if(ENABLE_STRICT_COMPILER_SETTINGS)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(FATAL_ERROR "Compiling with Clang")
set(CMAKE_STRICT_COMPILER_SETTINGS "-Weverything -Wextra -Wpedantic -Werror")
message(STATUS "Compiling with Clang")
set(CMAKE_STRICT_COMPILER_SETTINGS "-Wall -Wextra -Wpedantic")
set(CMAKE_STRICT_CXX_COMPILER_SETTINGS "${CMAKE_STRICT_COMPILER_SETTINGS} -Wnon-virtual-dtor")
elseif(${CMAKE_COMPILER_IS_GNUCXX})
message(STATUS "Compiling with GCC")
Expand All @@ -68,6 +68,12 @@ if(ENABLE_STRICT_COMPILER_SETTINGS)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_STRICT_CXX_COMPILER_SETTINGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_STRICT_COMPILER_SETTINGS}")
else()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_COMPILER_SETTINGS "-Wno-deprecated-declarations")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_COMPILER_SETTINGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_COMPILER_SETTINGS}")
endif()
endif()

if(CORE)
Expand Down
4 changes: 4 additions & 0 deletions Source/Thunder/PluginHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,11 @@ POP_WARNING()
printf("Pending: %d\n", static_cast<uint32_t>(metaData.Pending.size()));
printf("Poolruns:\n");
for (uint8_t index = 0; index < metaData.Slots; index++) {
#ifdef __APPLE__
printf(" Thread%02d|0x%16" PRIxPTR ": %10d", (index), reinterpret_cast<uintptr_t>(metaData.Slot[index].WorkerId), metaData.Slot[index].Runs);
#else
printf(" Thread%02d|0x%16lX: %10d", (index), metaData.Slot[index].WorkerId, metaData.Slot[index].Runs);
#endif
if (metaData.Slot[index].Job.IsSet() == false) {
printf("\n");
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Thunder/PluginServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ namespace PluginHost {
result = Core::ERROR_INPROGRESS;
} else if ((currentState == IShell::state::DEACTIVATION) || (currentState == IShell::state::DESTROYED) || (currentState == IShell::state::HIBERNATED)) {
result = Core::ERROR_ILLEGAL_STATE;
} else if ( (currentState == IShell::state::DEACTIVATED) ) {
} else if (currentState == IShell::state::DEACTIVATED) {
result = Activate(why);
currentState = State();
}
Expand Down
13 changes: 9 additions & 4 deletions Source/Thunder/PluginServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ namespace PluginHost {
~WorkerPoolImplementation() override = default;

public:
void Idle() {
void Idle() override
{
// Could be that we can now drop the dynamic library...
Core::ServiceAdministrator::Instance().FlushLibraries();
}
Expand Down Expand Up @@ -867,7 +868,7 @@ namespace PluginHost {

Unlock();
}
virtual Core::ProxyType<Core::JSON::IElement> Inbound(const string& identifier)
Core::ProxyType<Core::JSON::IElement> Inbound(const string& identifier) override
{
Core::ProxyType<Core::JSON::IElement> result;
Lock();
Expand Down Expand Up @@ -4160,7 +4161,7 @@ namespace PluginHost {
}

// Whenever there is a state change on the link, it is reported here.
void StateChange()
void StateChange() override
{
TRACE(Activity, (_T("State change on [%d] to [%s]"), Id(), (IsSuspended() ? _T("SUSPENDED") : (IsUpgrading() ? _T("UPGRADING") : (IsWebSocket() ? _T("WEBSOCKET") : _T("WEBSERVER"))))));

Expand Down Expand Up @@ -4417,7 +4418,11 @@ namespace PluginHost {

std::list<Core::callstack_info> stackList;

::DumpCallStack((ThreadId)index.Current().Id.Value(), stackList);
#ifdef __APPLE__
::DumpCallStack(reinterpret_cast<ThreadId>(index.Current().Id.Value()), stackList);
#else
::DumpCallStack(static_cast<ThreadId>(index.Current().Id.Value()), stackList);
#endif

PostMortemData::Callstack dump;
dump.Id = index.Current().Id.Value();
Expand Down
6 changes: 3 additions & 3 deletions Source/Thunder/SystemInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ namespace PluginHost {
END_INTERFACE_MAP

public:
uint64_t TimeSync() const;
uint64_t TimeSync() const override;

bool Set(const PluginHost::ISubSystem::ITime* info);
inline bool Set(const uint64_t ticks)
Expand Down Expand Up @@ -762,8 +762,8 @@ namespace PluginHost {
return (_flags);
}

string BuildTreeHash() const;
string Version() const;
string BuildTreeHash() const override;
string Version() const override;

BEGIN_INTERFACE_MAP(SystemInfo)
INTERFACE_ENTRY(PluginHost::ISubSystem)
Expand Down
3 changes: 2 additions & 1 deletion Source/ThunderPlugin/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ POP_WARNING()
{
Core::WorkerPool::Stop();
}
void Idle() {
void Idle() override
{
// If we handled all pending requests, it is safe to "unload"
Core::ServiceAdministrator::Instance().FlushLibraries();
}
Expand Down
4 changes: 2 additions & 2 deletions Source/com/Administrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ namespace RPC {
_adminLock.Unlock();

if (result == true) {
TRACE_L3("Validated instance 0x%08" PRIxPTR " by administration", impl);
TRACE_L3("Validated instance 0x%08" PRId64 " by administration", impl);
} else {
TRACE_L1("Failed to validate instance 0x%08" PRIxPTR " of interface 0x%08x", impl, id);
TRACE_L1("Failed to validate instance 0x%08" PRId64 " of interface 0x%08x", impl, id);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Source/com/Administrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ namespace RPC {

Stubs::iterator stub(_stubs.find(ACTUALINTERFACE::ID));
if (stub != _stubs.end()) {
PUSH_WARNING(DISABLE_WARNING_DELETE_INCOMPLETE)
delete stub->second;
POP_WARNING()
_stubs.erase(ACTUALINTERFACE::ID);
} else {
TRACE_L1("Failed to find a Stub for %d.", ACTUALINTERFACE::ID);
Expand Down
3 changes: 1 addition & 2 deletions Source/com/Communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,6 @@ namespace RPC {

private:
friend class ProcessShutdown;
class RemoteConnectionMap;

class MonitorableProcess : public RemoteConnection, public IMonitorableProcess {
public:
Expand Down Expand Up @@ -1841,7 +1840,7 @@ POP_WARNING()
// Lock event until Dispatch() sets it.
return (_announceEvent.Lock(waitTime) == Core::ERROR_NONE);
}
virtual void Dispatch(Core::IIPC& element);
void Dispatch(Core::IIPC& element) override;

protected:
void StateChange() override;
Expand Down
11 changes: 6 additions & 5 deletions Source/com/IUnknown.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ namespace ProxyStub {
inline uint16_t Length() const {
return (3);
}
virtual Core::IUnknown* Convert(void* incomingData) const {
virtual Core::IUnknown* Convert(void* incomingData) const {
return (reinterpret_cast<Core::IUnknown*>(incomingData));
}
virtual uint32_t InterfaceId() const {
virtual uint32_t InterfaceId() const {
return (Core::IUnknown::ID);
}
virtual void Handle(const uint16_t index, Core::ProxyType<Core::IPCChannel>& channel, Core::ProxyType<RPC::InvokeMessage>& message);
Expand Down Expand Up @@ -87,14 +87,15 @@ namespace ProxyStub {
{
return (_myHandlerCount + UnknownStub::Length());
}
virtual Core::IUnknown* Convert(void* incomingData) const
Core::IUnknown* Convert(void* incomingData) const override
{
return (reinterpret_cast<INTERFACE*>(incomingData));
}
virtual uint32_t InterfaceId() const {
uint32_t InterfaceId() const override
{
return (INTERFACE::ID);
}
virtual void Handle(const uint16_t index, Core::ProxyType<Core::IPCChannel>& channel, Core::ProxyType<RPC::InvokeMessage>& message)
void Handle(const uint16_t index, Core::ProxyType<Core::IPCChannel>& channel, Core::ProxyType<RPC::InvokeMessage>& message) override
{
uint16_t baseNumber(UnknownStub::Length());

Expand Down
2 changes: 2 additions & 0 deletions Source/com/IteratorType.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ namespace RPC {
}

public:
PUSH_WARNING(DISABLE_WARNING_INCONSISTENT_MISSING_OVERRIDE)
virtual uint32_t AddRef() const = 0;
virtual uint32_t Release() const = 0;
POP_WARNING()

virtual bool IsValid() const override
{
Expand Down
2 changes: 1 addition & 1 deletion Source/com/Messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ namespace RPC {
if (parentInfo.empty() == false) {
const size_t delimiter = std::min(parentInfo.find(','), parentInfo.length());

if (exchangeId == ~0UL) {
if (exchangeId == static_cast<uint32_t>(~0UL)) {
exchangeId = Core::NumberType<uint32_t>(parentInfo.c_str(), static_cast<uint32_t>(delimiter)).Value();
}

Expand Down
4 changes: 4 additions & 0 deletions Source/core/ASN1.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ namespace Core {
{
if (_buffer != nullptr) {
_buffer[0] = 1;
PUSH_WARNING(DISABLE_WARNING_CONSTANT_LOGICAL_OPERAND)
_buffer[1] = (length & 0xFF);
_buffer[2] = ((length >> 8) && 0xFF);
_buffer[3] = (length & 0xFF);
_buffer[4] = ((length >> 8) && 0xFF);
POP_WARNING()
}
}
Buffer(const Buffer& copy)
Expand Down Expand Up @@ -100,7 +102,9 @@ namespace Core {

if (_buffer != nullptr) {
_buffer[1] = (length & 0xFF);
PUSH_WARNING(DISABLE_WARNING_CONSTANT_LOGICAL_OPERAND)
_buffer[2] = ((length >> 8) && 0xFF);
POP_WARNING()
}
}
inline uint16_t Size() const
Expand Down
4 changes: 4 additions & 0 deletions Source/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ if (NOT BUILD_SHARED_LIBS)
)
endif()

if (APPLE)
target_compile_definitions( ${TARGET} PRIVATE __APPLE_USE_RFC_3542)
endif()

target_include_directories( ${TARGET}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated/core>
Expand Down
2 changes: 2 additions & 0 deletions Source/core/DataElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ namespace Core {
m_MaxSize = (adjust < m_MaxSize ? (m_MaxSize - adjust) : 0);

if (adjust != 0) {
PUSH_WARNING(DISABLE_WARNING_PEDANTIC)
TRACE_L1("Aligning the memory buffer by %d bytes to %p !!!", adjust, m_Buffer);
POP_WARNING()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/core/DataElementFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace Core {

protected:
void Close();
virtual void Reallocation(const uint64_t size);
void Reallocation(const uint64_t size) override;

void ReopenMemoryMappedFile();

Expand Down
15 changes: 14 additions & 1 deletion Source/core/DoorBell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ namespace Core {
DoorBell::Connector::Connector(DoorBell& parent, const Core::NodeId& node)
: _parent(parent)
, _doorbell(node)
#ifdef __APPLE__
, _sendSocket(::socket(_doorbell.Type(), SOCK_DGRAM, 0))
#else
, _sendSocket(::socket(_doorbell.Type(), SOCK_DGRAM|SOCK_CLOEXEC, 0))
#endif
, _receiveSocket(INVALID_SOCKET)
, _registered(0)
{
Expand All @@ -46,6 +50,9 @@ namespace Core {
}
#else
int flags = fcntl(_sendSocket, F_GETFL, 0) | O_NONBLOCK;
#ifdef __APPLE__
flags |= O_CLOEXEC;
#endif
if (fcntl(_sendSocket, F_SETFL, flags) != 0) {
TRACE_L1("SendSocket:Error on port socket F_SETFL call. Error %d", errno);
}
Expand All @@ -72,7 +79,11 @@ namespace Core {
bool DoorBell::Connector::Bind() const
{
if (_receiveSocket == INVALID_SOCKET) {
#ifdef __APPLE__
_receiveSocket = ::socket(_doorbell.Type(), SOCK_DGRAM, 0);
#else
_receiveSocket = ::socket(_doorbell.Type(), SOCK_DGRAM|SOCK_CLOEXEC, 0);
#endif

#ifndef __WINDOWS__
// Check if domain path already exists, if so remove.
Expand Down Expand Up @@ -109,7 +120,9 @@ namespace Core {
}
else {
int flags = fcntl(_receiveSocket, F_GETFL, 0) | O_NONBLOCK;

#ifdef __APPLE__
flags |= O_CLOEXEC;
#endif
if (fcntl(_receiveSocket, F_SETFL, flags) != 0) {
TRACE_L1("Error on port socket F_SETFL call. Error %d", errno);
::close(_receiveSocket);
Expand Down
Loading

0 comments on commit 850b57b

Please sign in to comment.