Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions qrenderdoc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ if(NOT ${CMAKE_VERSION} VERSION_LESS "3.24")
cmake_policy(SET CMP0135 NEW)
endif()

if(FREEBSD)
set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};/usr/local/include")
endif()

CHECK_INCLUDE_FILE(pcre.h PCRE_HEADER)

set(PCRE_PREFIX_PATH "")
Expand Down
6 changes: 5 additions & 1 deletion renderdoc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,11 @@ target_link_libraries(renderdoc ${RDOC_LIBRARIES})
add_dependencies(renderdoc renderdoc_libentry)

if(UNIX AND NOT ANDROID AND NOT APPLE)
set(RDOC_LINK_FLAGS "-Wl,--undefined,force_include_libentry -Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/${RDOC_BASE_NAME}.version")
if(FREEBSD)
set(RDOC_LINK_FLAGS "-Wl,--undefined,force_include_libentry")
else()
set(RDOC_LINK_FLAGS "-Wl,--undefined,force_include_libentry -Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/${RDOC_BASE_NAME}.version")
endif()

if(NOT ENABLE_ASAN AND NOT ENABLE_TSAN)
set(RDOC_LINK_FLAGS "${RDOC_LINK_FLAGS} -Wl,--no-undefined")
Expand Down
4 changes: 2 additions & 2 deletions renderdoc/os/posix/bsd/bsd_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ static void CheckLoadedLibraries()

for(FunctionLoadCallback cb : callbacks)
if(cb)
cb(handle);
cb(handle, libName.c_str());
}
}

Expand Down Expand Up @@ -470,7 +470,7 @@ void *intercept_dlopen(const char *filename, int flag, void *ret)

for(FunctionLoadCallback cb : callbacks)
if(cb)
cb(ret);
cb(ret, libName.c_str());

ret = realdlopen("lib" STRINGIZE(RDOC_BASE_NAME) ".so", flag);
break;
Expand Down
79 changes: 79 additions & 0 deletions renderdoc/os/posix/bsd/bsd_threading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@

#include "os/os_specific.h"

#include "common/common.h"

#include <errno.h>
#include <pthread.h>
#include <semaphore.h>
#include <time.h>
#include <unistd.h>

Expand All @@ -41,4 +46,78 @@ uint64_t Timing::GetTick()

void Threading::SetCurrentThreadName(const rdcstr &name)
{
// only substantial difference from linux_threading.cpp
pthread_setname_np(pthread_self(), name.c_str());
}

uint32_t Threading::NumberOfCores()
{
long ret = sysconf(_SC_NPROCESSORS_ONLN);
if(ret <= 0)
return 1;
return uint32_t(ret);
}

namespace Threading
{

// works for all posix except apple, hence being here
struct PosixSemaphore : public Semaphore
{
~PosixSemaphore() {}

sem_t h;
};

Semaphore *Semaphore::Create()
{
PosixSemaphore *sem = new PosixSemaphore();
int err = sem_init(&sem->h, 0, 0);
// only documented errors are too large initial value (impossible for 0) or for shared semaphores
// going wrong (we're not shared)
RDCASSERT(err == 0, (int)errno);
return sem;
}

void Semaphore::Destroy()
{
PosixSemaphore *sem = (PosixSemaphore *)this;
sem_destroy(&sem->h);
delete sem;
}

void Semaphore::Wake(uint32_t numToWake)
{
PosixSemaphore *sem = (PosixSemaphore *)this;
for(uint32_t i = 0; i < numToWake; i++)
sem_post(&sem->h);
}

void Semaphore::WaitForWake()
{
PosixSemaphore *sem = (PosixSemaphore *)this;

// handle extremely moronic stupid signal interruptions
do
{
int ret = sem_wait(&sem->h);

if(ret == -1)
{
if(errno == EINTR)
continue;

RDCWARN("Semaphore wait failed: %d", errno);
}
} while(false);
}

Semaphore::Semaphore()
{
}

Semaphore::~Semaphore()
{
}

};
Loading