Commit b0b0226b authored by rna's avatar rna
Browse files

Merge branch 'develop' into feature/congestionControl

parents 70070657 038a34c1
Loading
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -44,18 +44,6 @@ static inline prrtPacketLength_t deliver_packet(const PrrtSocket *s, void *buffe
    return len;
}

struct timespec abstime_from_now(prrtTimedelta_t wait_time) {
    struct timespec now;
    clock_gettime(CLOCK_REALTIME, &now);

    struct timespec deadline;
    prrtTimedelta_t diff_s = wait_time / 1000000;
    prrtTimedelta_t diff_ns = (wait_time % 1000000) * 1000;
    deadline.tv_sec = diff_s + now.tv_sec;
    deadline.tv_nsec = diff_ns + now.tv_nsec;
    return deadline;
}

PrrtSocket *PrrtSocket_create(prrtByteCount_t mtu, prrtTimedelta_t target_delay_us) {
    assert(sizeof(float) == 4);
    PrrtSocket *s = (PrrtSocket *) calloc(1, sizeof(PrrtSocket));
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ add_library(UTIL ../defines.h
        bptree.c bptree.h
        bitmap.c bitmap.h
        mpsc_queue.c mpsc_queue.h
        time.c time.h
        windowedFilter.c windowedFilter.h)
set_property(TARGET UTIL PROPERTY C_STANDARD 99)
target_link_libraries(UTIL ${M_LIB})

prrt/util/time.c

0 → 100644
+23 −0
Original line number Diff line number Diff line
#include <time.h>
#include <stdint.h>
#include "time.h"

long long timedelta(struct timespec *t1, struct timespec *t2) {
    long long delta = t1->tv_sec - t2->tv_sec;
    delta *= 1000000000;
    delta += t1->tv_nsec - t2->tv_nsec;
    return delta;
}

struct timespec abstime_from_now(uint32_t wait_time) {
    struct timespec now;
    clock_gettime(CLOCK_REALTIME, &now);

    struct timespec deadline;
    uint32_t diff_s = wait_time / 1000000;
    uint32_t diff_ns = (wait_time % 1000000) * 1000;
    deadline.tv_sec = diff_s + now.tv_sec;
    deadline.tv_nsec = diff_ns + now.tv_nsec;
    return deadline;
}

prrt/util/time.h

0 → 100644
+7 −0
Original line number Diff line number Diff line
#ifndef PRRT_TIME_H
#define PRRT_TIME_H

long long timedelta(struct timespec *t1, struct timespec *t2);
struct timespec abstime_from_now(uint32_t wait_time);

#endif //PRRT_TIME_H