mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
WIP, Haiku port
This commit is contained in:
parent
4226f7888e
commit
aee8d6e59e
@ -16,6 +16,14 @@ else ifeq (0,$(shell ld -ltbb -o /dev/null 2>/dev/null; echo $$?))
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(shell uname -o),Haiku)
|
||||
LIBS += -lroot -lnetwork -luuid
|
||||
else
|
||||
LIBS += -ldl
|
||||
endif
|
||||
|
||||
|
||||
OBJDIRBASE := obj/$(BUILD)
|
||||
OBJDIR := $(OBJDIRBASE)/o/o/o
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ CFLAGS +=
|
||||
CXXFLAGS := $(CFLAGS) -std=c++11 -fpic
|
||||
DEFINES += -DTRACY_ENABLE
|
||||
INCLUDES :=
|
||||
LIBS := -lpthread -ldl
|
||||
LIBS := -lpthread
|
||||
PROJECT := libtracy
|
||||
IMAGE := $(PROJECT)-$(BUILD).so
|
||||
SHARED_LIBRARY := yes
|
||||
|
||||
@ -16,7 +16,20 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h> // for access()
|
||||
|
||||
#if !defined(__has_include) || !defined(__linux__)
|
||||
#if defined __HAIKU__
|
||||
#include <uuid/uuid.h>
|
||||
static inline size_t szmin(size_t a, size_t b) {
|
||||
return a < b? a : b;
|
||||
}
|
||||
static inline ssize_t getrandom(unsigned char * buf, size_t buflen, unsigned int flags) {
|
||||
for (size_t i = 0; i < buflen; i += sizeof(uuid_t)) {
|
||||
uuid_t uuid;
|
||||
uuid_generate_random(uuid);
|
||||
memcpy(buf+i, uuid, szmin(buflen-i, sizeof(uuid)));
|
||||
}
|
||||
return buflen;
|
||||
}
|
||||
#elif !defined(__has_include) || !defined(__linux__)
|
||||
#include <sys/random.h> // for getrandom() - the random token string
|
||||
#elif __has_include(<sys/random.h>)
|
||||
#include <sys/random.h>
|
||||
|
||||
@ -2,7 +2,7 @@ CFLAGS +=
|
||||
CXXFLAGS := $(CFLAGS) -std=c++17
|
||||
DEFINES += -DIMGUI_ENABLE_FREETYPE
|
||||
INCLUDES := -I../../../imgui $(shell pkg-config --cflags freetype2 capstone wayland-egl egl wayland-cursor xkbcommon)
|
||||
LIBS := $(shell pkg-config --libs freetype2 capstone wayland-egl egl wayland-cursor xkbcommon) -lpthread -ldl
|
||||
LIBS := $(shell pkg-config --libs freetype2 capstone wayland-egl egl wayland-cursor xkbcommon) -lpthread
|
||||
|
||||
PROJECT := Tracy
|
||||
IMAGE := $(PROJECT)-$(BUILD)
|
||||
|
||||
@ -1,4 +1,10 @@
|
||||
ifeq ($(shell uname -o),Haiku)
|
||||
CFLAGS := -gdwarf-3 -Wall
|
||||
LDFLAGS := -gdwarf-3
|
||||
else
|
||||
CFLAGS := -g3 -Wall
|
||||
LDFLAGS := -g3
|
||||
endif
|
||||
DEFINES := -DDEBUG
|
||||
BUILD := debug
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ CFLAGS +=
|
||||
CXXFLAGS := $(CFLAGS) -std=c++17
|
||||
DEFINES += -DIMGUI_ENABLE_FREETYPE
|
||||
INCLUDES := -I../../../imgui $(shell pkg-config --cflags glfw3 freetype2 capstone)
|
||||
LIBS := $(shell pkg-config --libs glfw3 freetype2 capstone) -lpthread -ldl
|
||||
LIBS := $(shell pkg-config --libs glfw3 freetype2 capstone) -lpthread
|
||||
|
||||
PROJECT := Tracy
|
||||
IMAGE := $(PROJECT)-$(BUILD)
|
||||
|
||||
@ -117,7 +117,11 @@
|
||||
#endif
|
||||
#define GLFW_HAS_FOCUS_WINDOW (GLFW_VERSION_COMBINED >= 3200) // 3.2+ glfwFocusWindow
|
||||
#define GLFW_HAS_FOCUS_ON_SHOW (GLFW_VERSION_COMBINED >= 3300) // 3.3+ GLFW_FOCUS_ON_SHOW
|
||||
#if defined __HAIKU__
|
||||
#define GLFW_HAS_MONITOR_WORK_AREA 0 // Crashes
|
||||
#else
|
||||
#define GLFW_HAS_MONITOR_WORK_AREA (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetMonitorWorkarea
|
||||
#endif
|
||||
#define GLFW_HAS_OSX_WINDOW_POS_FIX (GLFW_VERSION_COMBINED >= 3301) // 3.3.1+ Fixed: Resizing window repositions it on MacOS #1553
|
||||
#ifdef GLFW_RESIZE_NESW_CURSOR // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released?
|
||||
#define GLFW_HAS_NEW_CURSORS (GLFW_VERSION_COMBINED >= 3400) // 3.4+ GLFW_RESIZE_ALL_CURSOR, GLFW_RESIZE_NESW_CURSOR, GLFW_RESIZE_NWSE_CURSOR, GLFW_NOT_ALLOWED_CURSOR
|
||||
|
||||
@ -685,7 +685,13 @@ static int open_libgl(void)
|
||||
libgl = dlopen("libGL.so.3", RTLD_LAZY | RTLD_LOCAL);
|
||||
if (!libgl)
|
||||
return GL3W_ERROR_LIBRARY_OPEN;
|
||||
*(void **)(&glx_get_proc_address) = dlsym(libgl, "glXGetProcAddressARB");
|
||||
*(void **)(&glx_get_proc_address) = dlsym(libgl,
|
||||
#if defined __HAIKU__
|
||||
"_glapi_get_proc_address"
|
||||
#else
|
||||
"glXGetProcAddressARB"
|
||||
#endif
|
||||
);
|
||||
return GL3W_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -28,6 +28,8 @@
|
||||
# define TRACY_HAS_CALLSTACK 4
|
||||
# elif defined BSD
|
||||
# define TRACY_HAS_CALLSTACK 6
|
||||
# elif defined __HAIKU__
|
||||
# define TRACY_HAS_CALLSTACK 5
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifdef TRACY_ENABLE
|
||||
# ifdef __linux__
|
||||
# if defined __linux__ || defined __HAIKU__
|
||||
# include "TracyDebug.hpp"
|
||||
# ifdef TRACY_VERBOSE
|
||||
# include <dlfcn.h>
|
||||
|
||||
@ -90,7 +90,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined __APPLE__ || defined __HAIKU__
|
||||
# ifndef TRACY_DELAYED_INIT
|
||||
# define TRACY_DELAYED_INIT
|
||||
# endif
|
||||
@ -422,6 +422,21 @@ static const char* GetProcessName()
|
||||
return processName;
|
||||
}
|
||||
|
||||
|
||||
#if defined __HAIKU__
|
||||
#include <image.h>
|
||||
static char executable_path[MAXPATHLEN];
|
||||
|
||||
extern "C" void
|
||||
initialize_before(image_id our_image)
|
||||
{
|
||||
image_info ii;
|
||||
get_image_info(our_image, &ii);
|
||||
snprintf(executable_path, sizeof(executable_path), "%s", ii.name);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static const char* GetProcessExecutablePath()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@ -459,6 +474,8 @@ static const char* GetProcessExecutablePath()
|
||||
static char buf[_PC_PATH_MAX + 1];
|
||||
_cmdname(buf);
|
||||
return buf;
|
||||
#elif defined __HAIKU__
|
||||
return executable_path;
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
@ -539,6 +556,8 @@ static const char* GetHostInfo()
|
||||
ptr += sprintf( ptr, "OS: BSD (OpenBSD)\n" );
|
||||
#elif defined __QNX__
|
||||
ptr += sprintf( ptr, "OS: QNX\n" );
|
||||
#elif defined __HAIKU__
|
||||
ptr += sprintf( ptr, "OS: Haiku (Haiku)\n" );
|
||||
#else
|
||||
ptr += sprintf( ptr, "OS: unknown\n" );
|
||||
#endif
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
#include <atomic>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#if !defined __HAIKU__
|
||||
#include <linux/perf_event.h>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
@ -78,6 +78,25 @@ void SysTime::ReadTimes()
|
||||
idle = data[4];
|
||||
}
|
||||
|
||||
# elif defined __HAIKU__
|
||||
|
||||
void SysTime::ReadTimes()
|
||||
{
|
||||
bigtime_t now = system_time();
|
||||
system_info si;
|
||||
get_system_info(&si);
|
||||
cpu_info ci[256];
|
||||
get_cpu_info(0, si.cpu_count, ci);
|
||||
bigtime_t tot = 0;
|
||||
for (uint32 i = 0; i < si.cpu_count; i++)
|
||||
tot += ci[i].active_time;
|
||||
used = tot / si.cpu_count;
|
||||
static bigtime_t prev;
|
||||
bigtime_t interval = now - prev;
|
||||
idle = interval - used;
|
||||
prev = now;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
SysTime::SysTime()
|
||||
@ -97,7 +116,7 @@ float SysTime::Get()
|
||||
|
||||
#if defined _WIN32
|
||||
return diffUsed == 0 ? -1 : ( diffUsed - diffIdle ) * 100.f / diffUsed;
|
||||
#elif defined __linux__ || defined __APPLE__ || defined BSD
|
||||
#elif defined __linux__ || defined __APPLE__ || defined BSD || defined __HAIKU__
|
||||
const auto total = diffUsed + diffIdle;
|
||||
return total == 0 ? -1 : diffUsed * 100.f / total;
|
||||
#endif
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#ifndef __TRACYSYSTIME_HPP__
|
||||
#define __TRACYSYSTIME_HPP__
|
||||
|
||||
#if defined _WIN32 || defined __linux__ || defined __APPLE__
|
||||
#if defined _WIN32 || defined __linux__ || defined __APPLE__ || defined __HAIKU__
|
||||
# define TRACY_HAS_SYSTIME
|
||||
#else
|
||||
# include <sys/param.h>
|
||||
|
||||
@ -37,6 +37,10 @@
|
||||
# define MSG_NOSIGNAL 0
|
||||
#endif
|
||||
|
||||
#if defined __HAIKU__
|
||||
#define TRACY_ONLY_IPV4
|
||||
#endif
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
@ -492,7 +496,7 @@ bool ListenSocket::Listen( uint16_t port, int backlog )
|
||||
#if defined _WIN32
|
||||
unsigned long val = 0;
|
||||
setsockopt( m_sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&val, sizeof( val ) );
|
||||
#elif defined BSD
|
||||
#elif defined BSD || defined __HAIKU__
|
||||
int val = 0;
|
||||
setsockopt( m_sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&val, sizeof( val ) );
|
||||
val = 1;
|
||||
|
||||
@ -31,6 +31,8 @@
|
||||
#elif defined __QNX__
|
||||
# include <process.h>
|
||||
# include <sys/neutrino.h>
|
||||
#elif defined __HAIKU__
|
||||
# include <kernel/OS.h>
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
@ -86,6 +88,8 @@ TRACY_API uint32_t GetThreadHandleImpl()
|
||||
#elif defined __EMSCRIPTEN__
|
||||
// Not supported, but let it compile.
|
||||
return 0;
|
||||
#elif defined __HAIKU__
|
||||
return find_thread(0);
|
||||
#else
|
||||
// To add support for a platform, retrieve and return the kernel thread identifier here.
|
||||
//
|
||||
|
||||
@ -71,6 +71,11 @@ POSSIBILITY OF SUCH DAMAGE. */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined __HAIKU__
|
||||
#undef HAVE_DL_ITERATE_PHDR
|
||||
#define ElfW(x) Elf_##x
|
||||
#endif
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#ifdef _MSC_VER
|
||||
# define stat64 _stat64
|
||||
#endif
|
||||
#if defined __APPLE__ || defined __FreeBSD__
|
||||
#if defined __APPLE__ || defined __FreeBSD__ || defined __HAIKU__
|
||||
# define stat64 stat
|
||||
#endif
|
||||
|
||||
|
||||
@ -31,6 +31,8 @@
|
||||
#elif defined __APPLE__ || defined BSD
|
||||
# include <sys/types.h>
|
||||
# include <sys/sysctl.h>
|
||||
#elif defined __HAIKU__
|
||||
# include <kernel/OS.h>
|
||||
#endif
|
||||
|
||||
#include "IconsFontAwesome6.h"
|
||||
@ -141,6 +143,10 @@ void View::InitMemory()
|
||||
size_t sz = sizeof( memSize );
|
||||
sysctlbyname( "hw.physmem", &memSize, &sz, nullptr, 0 );
|
||||
m_totalMemory = memSize;
|
||||
#elif defined __HAIKU__
|
||||
system_info sysInfo;
|
||||
get_system_info(&sysInfo);
|
||||
m_totalMemory = sysInfo.max_pages * PAGESIZE;
|
||||
#else
|
||||
m_totalMemory = 0;
|
||||
#endif
|
||||
|
||||
@ -17,7 +17,7 @@ void OpenWebpage( const char* url )
|
||||
{
|
||||
#ifdef _WIN32
|
||||
ShellExecuteA( nullptr, nullptr, url, nullptr, nullptr, 0 );
|
||||
#elif defined __APPLE__
|
||||
#elif defined __APPLE__ || defined __HAIKU__
|
||||
char buf[1024];
|
||||
sprintf( buf, "open %s", url );
|
||||
system( buf );
|
||||
|
||||
@ -3,7 +3,12 @@ CFLAGS := $(OPTFLAGS) -Wall -DTRACY_ENABLE
|
||||
CXXFLAGS := $(CFLAGS) -std=gnu++11
|
||||
DEFINES +=
|
||||
INCLUDES := -I../public/tracy
|
||||
LIBS := -lpthread -ldl
|
||||
LIBS := -lpthread
|
||||
ifeq ($(shell uname -o),Haiku)
|
||||
LIBS += -lroot -lnetwork
|
||||
else
|
||||
LIBS += -ldl
|
||||
endif
|
||||
LDFLAGS := -rdynamic
|
||||
IMAGE := tracy_test
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user