0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-27 08:41:02 +08:00

Merge #41 into develop

This commit is contained in:
Sergey Yagovtsev 2017-06-05 12:58:13 +03:00
commit 39f0219ade
6 changed files with 47 additions and 10 deletions

View File

@ -204,7 +204,7 @@ int EasySocket::send(const void *buf, size_t nbyte)
{
if(!checkSocket(m_replySocket)) return -1;
int res = 0;
#ifdef _WIN32
#if defined(_WIN32) || defined(__APPLE__)
res = ::send(m_replySocket, (const char*)buf, (int)nbyte, 0);
#else
res = ::send(m_replySocket,buf,nbyte,MSG_NOSIGNAL);
@ -268,6 +268,12 @@ int EasySocket::accept()
//int flag = 1;
//int result = setsockopt(m_replySocket,IPPROTO_TCP,TCP_NODELAY,(char *)&flag,sizeof(int));
// Apple doesn't have MSG_NOSIGNAL, work around it
#ifdef __APPLE__
int value = 1;
setsockopt(m_replySocket, SOL_SOCKET, SO_NOSIGPIPE, &value, sizeof(value));
#endif
//setBlocking(m_replySocket,true);
}
return (int)m_replySocket;
@ -309,6 +315,15 @@ int EasySocket::connect()
{
res = ::connect(m_socket,(struct sockaddr *) &serv_addr,sizeof(serv_addr));
// on Apple, treat EISCONN error as success
#ifdef __APPLE__
if (res == -1 && errno == EISCONN)
{
res = 0;
break;
}
#endif
checkResult(res);
if (res == 0)
@ -339,6 +354,12 @@ int EasySocket::connect()
setsockopt(m_socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,sizeof(struct timeval));
#ifdef __APPLE__
// Apple doesn't have MSG_NOSIGNAL, work around it
int value = 1;
setsockopt(m_socket, SOL_SOCKET, SO_NOSIGPIPE, &value, sizeof(value));
#endif
m_replySocket = m_socket;
}
return res;

View File

@ -445,7 +445,7 @@ namespace profiler {
const uint16_t DEFAULT_PORT = EASY_DEFAULT_PORT;
typedef uint64_t timestamp_t;
typedef uint32_t thread_id_t;
typedef uint64_t thread_id_t;
typedef uint32_t block_id_t;
enum BlockType : uint8_t

View File

@ -61,6 +61,9 @@ The Apache License, Version 2.0 (the "License");
#ifdef _WIN32
#include <Windows.h>
#elif defined(__APPLE__)
#include <pthread.h>
#include <Availability.h>
#else
#include <sys/types.h>
#include <unistd.h>
@ -73,13 +76,22 @@ The Apache License, Version 2.0 (the "License");
#undef max
#endif
inline uint32_t getCurrentThreadId()
inline profiler::thread_id_t getCurrentThreadId()
{
#ifdef _WIN32
return (uint32_t)::GetCurrentThreadId();
return (profiler::thread_id_t)::GetCurrentThreadId();
#elif defined(__APPLE__)
# if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_6) || \
(defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0)
EASY_THREAD_LOCAL static uint64_t _id = 0;
if (!_id)
pthread_threadid_np(NULL, &_id);
return (profiler::thread_id_t)_id;
# else
return (profiler::thread_id_t)pthread_self();
# endif
#else
EASY_THREAD_LOCAL static const pid_t x = syscall(__NR_gettid);
EASY_THREAD_LOCAL static const uint32_t _id = (uint32_t)x;//std::hash<std::thread::id>()(std::this_thread::get_id());
EASY_THREAD_LOCAL static const profiler::thread_id_t _id = (profiler::thread_id_t)syscall(__NR_gettid);
return _id;
#endif
}

View File

@ -87,6 +87,7 @@ extern const uint32_t EASY_CURRENT_VERSION;
# define EASY_VERSION_INT(v_major, v_minor, v_patch) ((static_cast<uint32_t>(v_major) << 24) | (static_cast<uint32_t>(v_minor) << 16) | static_cast<uint32_t>(v_patch))
const uint32_t MIN_COMPATIBLE_VERSION = EASY_VERSION_INT(0, 1, 0); ///< minimal compatible version (.prof file format was not changed seriously since this version)
const uint32_t EASY_V_100 = EASY_VERSION_INT(1, 0, 0); ///< in v1.0.0 some additional data were added into .prof file
const uint32_t EASY_V_130 = EASY_VERSION_INT(1, 3, 0); ///< in v1.3.0 changed sizeof(thread_id_t) uint32_t -> uint64_t
# undef EASY_VERSION_INT
const uint64_t TIME_FACTOR = 1000000000ULL;
@ -557,7 +558,10 @@ extern "C" {
EASY_BLOCK("Read thread data", ::profiler::colors::DarkGreen);
::profiler::thread_id_t thread_id = 0;
inFile.read((char*)&thread_id, sizeof(decltype(thread_id)));
long thread_id_t_size = sizeof(decltype(thread_id));
if (version < EASY_V_130)
thread_id_t_size = sizeof(uint32_t);
inFile.read((char*)&thread_id, thread_id_t_size);
auto& root = threaded_trees[thread_id];

View File

@ -1 +1 @@
1.2.0
1.3.0

View File

@ -1130,8 +1130,8 @@ void EasyGraphicsView::mouseMoveEvent(QMouseEvent* _event)
if (m_mouseButtons != 0)
{
m_mouseMovePath.setX(m_mouseMovePath.x() + abs(delta.x()));
m_mouseMovePath.setY(m_mouseMovePath.y() + abs(delta.y()));
m_mouseMovePath.setX(m_mouseMovePath.x() + ::std::abs((double)delta.x()));
m_mouseMovePath.setY(m_mouseMovePath.y() + ::std::abs((double)delta.y()));
}
auto mouseScenePos = mapToScene(m_mousePressPos);