Commit 3dc067fa authored by Philip Trettner's avatar Philip Trettner
Browse files
parents 38b4fe1d 8e0104c1
...@@ -6,9 +6,13 @@ file(GLOB_RECURSE HEADER_FILES "src/*.hh") ...@@ -6,9 +6,13 @@ file(GLOB_RECURSE HEADER_FILES "src/*.hh")
add_library(aion STATIC ${SOURCE_FILES} ${HEADER_FILES}) add_library(aion STATIC ${SOURCE_FILES} ${HEADER_FILES})
target_include_directories(aion PUBLIC src/) target_include_directories(aion PUBLIC src/)
target_compile_options(aion PRIVATE -Wall -Werror) if (MSVC)
target_compile_options(aion PUBLIC target_compile_options(aion PUBLIC /MP)
else()
target_compile_options(aion PRIVATE -Wall -Werror)
target_compile_options(aion PUBLIC
$<$<COMPILE_LANGUAGE:CXX>:-std=c++11>) $<$<COMPILE_LANGUAGE:CXX>:-std=c++11>)
endif()
find_package(Qt5Core REQUIRED) find_package(Qt5Core REQUIRED)
target_link_libraries(aion PRIVATE ${Qt5Core_LIBRARIES}) target_link_libraries(aion PRIVATE ${Qt5Core_LIBRARIES})
#include "Action.hh" #include "Action.hh"
#include <sys/time.h>
using namespace aion; using namespace aion;
// empty for now // empty for now
...@@ -59,7 +59,7 @@ public: // properties ...@@ -59,7 +59,7 @@ public: // properties
double max() const { return mMax * 1.e-9; } double max() const { return mMax * 1.e-9; }
/// returns the p-th percentile (p in [0, 100]) /// returns the p-th percentile (p in [0, 100])
int64_t percentileNS(int p); int64_t percentileNS(int p);
double percentile(int p) { return percentile(p) * 1.e-9; } double percentile(int p) { return percentileNS(p) * 1.e-9; }
int64_t medianNS() { return percentileNS(50); } int64_t medianNS() { return percentileNS(50); }
double median() { return medianNS() * 1.e-9; } double median() { return medianNS() * 1.e-9; }
public: public:
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
using namespace aion; using namespace aion;
#ifdef _MSC_VER #ifdef _MSC_VER
#include <Windows.h>
#define AION_THREADLOCAL __declspec(thread) #define AION_THREADLOCAL __declspec(thread)
#else #else
#define AION_THREADLOCAL __thread // GCC 4.7 has no thread_local yet #define AION_THREADLOCAL __thread // GCC 4.7 has no thread_local yet
...@@ -25,10 +26,17 @@ std::mutex sLabelLock; ...@@ -25,10 +26,17 @@ std::mutex sLabelLock;
std::vector<ActionLabel *> sLabels; std::vector<ActionLabel *> sLabels;
std::vector<std::vector<ActionEntry> *> sEntriesPerThread; std::vector<std::vector<ActionEntry> *> sEntriesPerThread;
#if _MSC_VER
LARGE_INTEGER sFrequency; // null init
#endif
void writeTime(ActionEntry &e) void writeTime(ActionEntry &e)
{ {
#if _MSC_VER #if _MSC_VER
#error not implemented LARGE_INTEGER time;
QueryPerformanceCounter(&time);
e.secs = int32_t(time.QuadPart / sFrequency.QuadPart);
e.nsecs = int32_t((time.QuadPart % sFrequency.QuadPart) * 1000000000LL / sFrequency.QuadPart);
#else #else
struct timespec t; struct timespec t;
clock_gettime(CLOCK_MONOTONIC, &t); clock_gettime(CLOCK_MONOTONIC, &t);
...@@ -76,6 +84,12 @@ ActionLabel::ActionLabel(const char *file, int line, const char *function, const ...@@ -76,6 +84,12 @@ ActionLabel::ActionLabel(const char *file, int line, const char *function, const
: mName(name), mFile(file), mLine(line), mFunction(function) : mName(name), mFile(file), mLine(line), mFunction(function)
{ {
sLabelLock.lock(); sLabelLock.lock();
#if _MSC_VER
if (sFrequency.QuadPart == 0)
QueryPerformanceFrequency(&sFrequency);
#endif
mIndex = sLabels.size(); mIndex = sLabels.size();
sLabels.push_back(this); sLabels.push_back(this);
if (!sEntries) if (!sEntries)
......
...@@ -38,7 +38,9 @@ ...@@ -38,7 +38,9 @@
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#ifndef _MSC_VER
#include <sys/uio.h> #include <sys/uio.h>
#endif
#define SNAPPY_MAJOR 1 #define SNAPPY_MAJOR 1
#define SNAPPY_MINOR 1 #define SNAPPY_MINOR 1
...@@ -59,13 +61,18 @@ typedef uint32_t uint32; ...@@ -59,13 +61,18 @@ typedef uint32_t uint32;
typedef int64_t int64; typedef int64_t int64;
typedef uint64_t uint64; typedef uint64_t uint64;
#ifdef _MSC_VER
typedef int64_t ssize_t;
#endif
typedef std::string string; typedef std::string string;
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ #define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \ TypeName(const TypeName&); \
void operator=(const TypeName&) void operator=(const TypeName&)
#if !1 // TODO #ifdef _MSC_VER
// Windows does not have an iovec type, yet the concept is universally useful. // Windows does not have an iovec type, yet the concept is universally useful.
// It is simple to define it ourselves, so we put it inside our own namespace. // It is simple to define it ourselves, so we put it inside our own namespace.
struct iovec { struct iovec {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment