<commit_before>#include <davix_internal_config.hpp>
#include "timepoint.hpp"

#if __cplusplus <= 201103L
#include <chrono>
#elif HAVE_CLOCK_GETTIME
#include <sys/syscall.h>
#endif

static void gettimeofday_timespec(struct timespec *time_value) {
    struct timeval now;
    (void) gettimeofday(&now, NULL);
    time_value->tv_sec  = now.tv_sec;
    time_value->tv_nsec = now.tv_usec * 1000;
}

// also for use inside libneon
extern "C" {

// we should get rid of ifdefs as soon as we have C++11 on all platforms we care about
void davix_get_monotonic_time(struct timespec *time_value){
#if __cplusplus >= 201103L
    using namespace std;
    auto now = chrono::steady_clock::now().time_since_epoch();
    chrono::seconds sec = chrono::duration_cast<chrono::seconds>(now);

    time_value->tv_sec  = sec.count();
    time_value->tv_nsec = chrono::duration_cast<chrono::nanoseconds>(now - sec).count();
#elif defined(HAVE_CLOCK_GETTIME)
#warning "Using clock_gettime"
    // todo: use the glibc wrapper for clock_gettime once it's available<commit_msg>DMC-826 2nd typo >.<<commit_after>#include <davix_internal_config.hpp>
#include "timepoint.hpp"

#if __cplusplus >= 201103L
#include <chrono>
#elif HAVE_CLOCK_GETTIME
#include <sys/syscall.h>
#endif

static void gettimeofday_timespec(struct timespec *time_value) {
    struct timeval now;
    (void) gettimeofday(&now, NULL);
    time_value->tv_sec  = now.tv_sec;
    time_value->tv_nsec = now.tv_usec * 1000;
}

// also for use inside libneon
extern "C" {

// we should get rid of ifdefs as soon as we have C++11 on all platforms we care about
void davix_get_monotonic_time(struct timespec *time_value){
#if __cplusplus >= 201103L
    using namespace std;
    auto now = chrono::steady_clock::now().time_since_epoch();
    chrono::seconds sec = chrono::duration_cast<chrono::seconds>(now);

    time_value->tv_sec  = sec.count();
    time_value->tv_nsec = chrono::duration_cast<chrono::nanoseconds>(now - sec).count();
#elif defined(HAVE_CLOCK_GETTIME)
#warning "Using clock_gettime"
    // todo: use the glibc wrapper for clock_gettime once it's available
{'fraction_non_alphanumeric': 0.11675367821547224, 'fraction_numerical': 0.018984337921214997, 'mean_word_length': 4.988636363636363, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6871170', 'n_tokens_mistral': 785, 'n_tokens_neox': 734, 'n_words': 184}