From patchwork Thu Nov 12 17:05:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 56446 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp537502lbb; Thu, 12 Nov 2015 09:11:29 -0800 (PST) X-Received: by 10.140.93.52 with SMTP id c49mr16751058qge.101.1447348288901; Thu, 12 Nov 2015 09:11:28 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id b4si5101811qhd.81.2015.11.12.09.11.28; Thu, 12 Nov 2015 09:11:28 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: by lists.linaro.org (Postfix, from userid 109) id 865D56202C; Thu, 12 Nov 2015 17:11:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 0CB8B62045; Thu, 12 Nov 2015 17:06:38 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 4D6276202A; Thu, 12 Nov 2015 17:06:11 +0000 (UTC) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com [209.85.217.173]) by lists.linaro.org (Postfix) with ESMTPS id 1A0FC61A21 for ; Thu, 12 Nov 2015 17:06:00 +0000 (UTC) Received: by lbbsy6 with SMTP id sy6so10358329lbb.2 for ; Thu, 12 Nov 2015 09:05:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AYUOwyQim6Svgek96PxRC8dcuTLBbtrSxmERb4ZY5C8=; b=eVV3+p5m4hHY19nzy6sYjOYBXW9M6NUtHVrt25YV/Jrn+x1MgxMpUNpxB0WNNu5a8X 3YjQsjZCdxDA/X8oQdQVE392Ir5NKQV5CkNL6qV23be2j2mqKFyVnEWA1jMaNNaOVh7h VSe54y+K7dWrpWI18LhsymdOePqeA9zySVp9vewf/BrRdYtcs0+QYruG/cJfYW7gBON9 vxN2o35TltKpfDtzKuRdvtf1zVw7vhqbKFqHhwJVn3FzK1EA2nQubQ2+F/hJtN/5iSUf L8i5XkCt6zDYGwSuRBvi7KfN1TfMgpnFQz+ziU1KMNHNKsAkioetlj9pgf8DAHANVtFH tqgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AYUOwyQim6Svgek96PxRC8dcuTLBbtrSxmERb4ZY5C8=; b=mqVZSyjhQy2sLCvmeocSxFo9tkzb2qE+Ar9wMmho9TVTMQHe0asyMdzUGv1U8N9uuj LdezRJriqZhHS+Y3IHuRiSDrXCSgrdPs8Mlmpb+kQdhIU7oIKxlyqyrfC+bk3ZwCkWYo YvN1reHCimuK88vDGq3SJv83JnA3+kftpaBjnf7PwGGQmcSijP/Zf0K9oIk/r4hm/9eX tO2YdGg9DcGQa4qu5SJBdgdDnmq1X6jYcqZsMwrRfsgN9rY2RhrJSA69hfib4P4cffqI /hBnu81VuBS5LJ68vcs7g2IamOFuNqC2UwZFzYKB4n04h0kEC8BMorSKKKNOtW3mycXY l3Og== X-Gm-Message-State: ALoCoQksnRbtLIzg13m7poehxW53qP8A3hMOonqkcy4bsscqloKoycSW78XKt9lWpZ5BVVqec6tY X-Received: by 10.112.77.98 with SMTP id r2mr1103482lbw.124.1447347958980; Thu, 12 Nov 2015 09:05:58 -0800 (PST) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id nb1sm2412412lbb.9.2015.11.12.09.05.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Nov 2015 09:05:58 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 12 Nov 2015 19:05:43 +0200 Message-Id: <1447347943-16807-8-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447347943-16807-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1447347943-16807-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [lng] [PATCH 7/7] api: time: make local time to be wall time X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" It's more convenient the local time to be a wall time. It's allows to measure time beginning from start of the thread. This allows to use local time in similar manner as it's supposed to be used with global time and the 64-bit timer is enough to guarantee it. Signed-off-by: Ivan Khoronzhuk --- example/generator/odp_generator.c | 2 +- include/odp/api/time.h | 30 +++++- .../linux-generic/include/odp/plat/time_types.h | 4 +- platform/linux-generic/include/odp_internal.h | 2 + platform/linux-generic/odp_schedule.c | 2 +- platform/linux-generic/odp_time.c | 110 +++++++++++++++------ test/performance/odp_pktio_perf.c | 24 ++--- test/validation/pktio/pktio.c | 4 +- test/validation/scheduler/scheduler.c | 2 +- test/validation/time/time.c | 67 +++++++++---- 10 files changed, 174 insertions(+), 73 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 2de530d..ddae7c0 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -594,7 +594,7 @@ static void print_global_stats(int num_workers) while (odp_thrmask_worker(&thrd_mask) < num_workers) continue; - wait = odp_time_local_from_ns(verbose_interval * ODP_TIME_SEC_IN_NS); + wait = odp_time_local_val(verbose_interval * ODP_TIME_SEC_IN_NS); next = odp_time_sum(odp_time_local(), wait); while (odp_thrmask_worker(&thrd_mask) == num_workers) { diff --git a/include/odp/api/time.h b/include/odp/api/time.h index 3228879..9a5916b 100644 --- a/include/odp/api/time.h +++ b/include/odp/api/time.h @@ -37,15 +37,16 @@ extern "C" { */ /** - * @def ODP_TIME_NULL - * Zero time stamp + * @def ODP_TIME_NULL_VAL + * Zero time interval */ /** * Current local time * * Returns current local time stamp value. The local time source provides high - * resolution time and is monotonic. + * resolution time and is monotonic. The local time is wall time that means it's + * local for each thread. * * @return Local time stamp. */ @@ -57,7 +58,9 @@ odp_time_t odp_time_local(void); * @param t2 Second time stamp * @param t1 First time stamp * - * @return Difference of time stamps + * @return Difference of time stamps ot intervals. Diff of timestamp and + * interval results in timestamp. + * */ odp_time_t odp_time_diff(odp_time_t t2, odp_time_t t1); @@ -68,6 +71,9 @@ odp_time_t odp_time_diff(odp_time_t t2, odp_time_t t1); * @param t2 Time stamp * * @return Sum of time stamps + * + * @note Sum of two timestamp shouldn't be used, only timestamp and interval or + * two intervals. Sum of timestamp and interval results in timestamp. */ odp_time_t odp_time_sum(odp_time_t t1, odp_time_t t2); @@ -90,12 +96,28 @@ uint64_t odp_time_to_ns(odp_time_t time); odp_time_t odp_time_local_from_ns(uint64_t ns); /** + * Convert nanoseconds to interval of local time + * + * @param ns Time in nanoseconds + */ +odp_time_t odp_time_local_val(uint64_t ns); + +/** + * Convert time interval to nanoseconds + * + * @param val Time interval + */ +uint64_t odp_time_val_to_ns(odp_time_t val); + +/** * Compare two times * * @param t2 Second time * @param t1 First time * * @retval <0 if t2 < t1, >0 if t1 = t2, 1 if t2 > t1 + * + * @note Compare two timestamps or two intervals */ int odp_time_cmp(odp_time_t t2, odp_time_t t1); diff --git a/platform/linux-generic/include/odp/plat/time_types.h b/platform/linux-generic/include/odp/plat/time_types.h index e5765ec..ccf6580 100644 --- a/platform/linux-generic/include/odp/plat/time_types.h +++ b/platform/linux-generic/include/odp/plat/time_types.h @@ -23,9 +23,9 @@ extern "C" { typedef struct timespec odp_time_t; -odp_time_t odp_time_null(void); +odp_time_t odp_time_null_val(void); -#define ODP_TIME_NULL odp_time_null() +#define ODP_TIME_NULL_VAL odp_time_null_val() /** * @} diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index 14ba159..baff135 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -79,6 +79,8 @@ int odp_schedule_term_local(void); int odp_timer_init_global(void); int odp_timer_disarm_all(void); +int odp_time_local_init(void); + void _odp_flush_caches(void); #ifdef __cplusplus diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 3017876..6a3440c 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -603,7 +603,7 @@ static int schedule_loop(odp_queue_t *out_queue, uint64_t wait, break; if (first) { - wtime = odp_time_local_from_ns(wait); + wtime = odp_time_local_val(wait); next = odp_time_sum(odp_time_local(), wtime); first = 0; continue; diff --git a/platform/linux-generic/odp_time.c b/platform/linux-generic/odp_time.c index 73b2dcb..52471a0 100644 --- a/platform/linux-generic/odp_time.c +++ b/platform/linux-generic/odp_time.c @@ -11,53 +11,103 @@ #include #include -odp_time_t odp_time_local(void) +struct timespec start_local_time; +uint64_t start_local_ns; + +static inline +odp_time_t _odp_time_diff(odp_time_t t2, odp_time_t t1) { - int ret; struct timespec time; - ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time); - if (odp_unlikely(ret != 0)) - ODP_ABORT("clock_gettime failed\n"); + time.tv_sec = t2.tv_sec - t1.tv_sec; + time.tv_nsec = t2.tv_nsec - t1.tv_nsec; + + if (time.tv_nsec < 0) { + time.tv_nsec += ODP_TIME_SEC_IN_NS; + --time.tv_sec; + } return time; } -odp_time_t odp_time_diff(odp_time_t t2, odp_time_t t1) +static inline +odp_time_t _odp_time_sum(odp_time_t t1, odp_time_t t2) { struct timespec time; - time.tv_sec = t2.tv_sec - t1.tv_sec; - time.tv_nsec = t2.tv_nsec - t1.tv_nsec; + time.tv_sec = t2.tv_sec + t1.tv_sec; + time.tv_nsec = t2.tv_nsec + t1.tv_nsec; - if (time.tv_nsec < 0) { - time.tv_nsec += ODP_TIME_SEC_IN_NS; - --time.tv_sec; + if (time.tv_nsec >= ODP_TIME_SEC_IN_NS) { + time.tv_nsec -= ODP_TIME_SEC_IN_NS; + ++time.tv_sec; } return time; } -uint64_t odp_time_to_ns(odp_time_t time) +static inline +odp_time_t _odp_time_local_val(uint64_t ns) +{ + struct timespec val; + + val.tv_sec = ns / ODP_TIME_SEC_IN_NS; + val.tv_nsec = ns % ODP_TIME_SEC_IN_NS; + + return val; +} + +static inline +uint64_t _odp_time_val_to_ns(odp_time_t val) { uint64_t ns; - ns = time.tv_sec * ODP_TIME_SEC_IN_NS; - ns += time.tv_nsec; + ns = val.tv_sec * ODP_TIME_SEC_IN_NS; + ns += val.tv_nsec; return ns; } -odp_time_t odp_time_local_from_ns(uint64_t ns) +odp_time_t odp_time_local(void) { + int ret; struct timespec time; - time.tv_sec = ns / ODP_TIME_SEC_IN_NS; - time.tv_nsec = ns % ODP_TIME_SEC_IN_NS; + ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time); + if (odp_unlikely(ret != 0)) + ODP_ABORT("clock_gettime failed\n"); return time; } +odp_time_t odp_time_diff(odp_time_t t2, odp_time_t t1) +{ + return _odp_time_diff(t2, t1); +} + +uint64_t odp_time_val_to_ns(odp_time_t val) +{ + return _odp_time_val_to_ns(val); +} + +uint64_t odp_time_to_ns(odp_time_t time) +{ + struct timespec val; + + val = _odp_time_diff(time, start_local_time); + return _odp_time_val_to_ns(val); +} + +odp_time_t odp_time_local_from_ns(uint64_t ns) +{ + return _odp_time_sum(_odp_time_local_val(ns), start_local_time); +} + +odp_time_t odp_time_local_val(uint64_t ns) +{ + return _odp_time_local_val(ns); +} + int odp_time_cmp(odp_time_t t2, odp_time_t t1) { if (t2.tv_sec < t1.tv_sec) @@ -71,17 +121,7 @@ int odp_time_cmp(odp_time_t t2, odp_time_t t1) odp_time_t odp_time_sum(odp_time_t t1, odp_time_t t2) { - struct timespec time; - - time.tv_sec = t2.tv_sec + t1.tv_sec; - time.tv_nsec = t2.tv_nsec + t1.tv_nsec; - - if (time.tv_nsec >= ODP_TIME_SEC_IN_NS) { - time.tv_nsec -= ODP_TIME_SEC_IN_NS; - ++time.tv_sec; - } - - return time; + return _odp_time_sum(t1, t2); } uint64_t odp_time_to_u64(odp_time_t time) @@ -96,11 +136,21 @@ uint64_t odp_time_to_u64(odp_time_t time) resolution = (uint64_t)tres.tv_nsec; - return odp_time_to_ns(time) / resolution; + return _odp_time_val_to_ns(time) / resolution; } -odp_time_t odp_time_null(void) +odp_time_t odp_time_null_val(void) { return (struct timespec) {0, 0}; } +int odp_time_local_init(void) +{ + int ret; + + ret = clock_gettime(CLOCK_MONOTONIC_RAW, &start_local_time); + if (ret) + start_local_time = odp_time_null_val(); + + return ret; +} diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c index 3d37ae1..e1f65e4 100644 --- a/test/performance/odp_pktio_perf.c +++ b/test/performance/odp_pktio_perf.c @@ -310,7 +310,7 @@ static void *run_thread_tx(void *arg) uint32_t batch_len; int unsent_pkts = 0; odp_event_t tx_event[BATCH_LEN_MAX]; - odp_time_t idle_start = ODP_TIME_NULL; + odp_time_t idle_start = ODP_TIME_NULL_VAL; thread_args_t *targs = arg; @@ -328,10 +328,10 @@ static void *run_thread_tx(void *arg) if (outq == ODP_QUEUE_INVALID) LOG_ABORT("Failed to get output queue for thread %d\n", thr_id); - burst_gap = odp_time_local_from_ns( + burst_gap = odp_time_local_val( ODP_TIME_SEC_IN_NS / (targs->pps / targs->batch_len)); send_duration = - odp_time_local_from_ns(targs->duration * ODP_TIME_SEC_IN_NS); + odp_time_local_val(targs->duration * ODP_TIME_SEC_IN_NS); odp_barrier_wait(&globals->tx_barrier); @@ -343,18 +343,18 @@ static void *run_thread_tx(void *arg) if (odp_time_cmp(burst_gap_end, cur_time) > 0) { cur_time = odp_time_local(); - if (!odp_time_cmp(idle_start, ODP_TIME_NULL)) + if (!odp_time_cmp(idle_start, ODP_TIME_NULL_VAL)) idle_start = cur_time; continue; } - if (odp_time_cmp(idle_start, ODP_TIME_NULL) > 0) { + if (odp_time_cmp(idle_start, ODP_TIME_NULL_VAL) > 0) { odp_time_t diff = odp_time_diff(cur_time, idle_start); stats->s.idle_ticks = odp_time_sum(diff, stats->s.idle_ticks); - idle_start = ODP_TIME_NULL; + idle_start = ODP_TIME_NULL_VAL; } burst_gap_end = odp_time_sum(burst_gap_end, burst_gap); @@ -375,7 +375,7 @@ static void *run_thread_tx(void *arg) " AllocFail %-6"PRIu64" Idle %"PRIu64"ms\n", thr_id, stats->s.tx_cnt, stats->s.enq_failures, stats->s.alloc_failures, - odp_time_to_ns(stats->s.idle_ticks) / + odp_time_val_to_ns(stats->s.idle_ticks) / (uint64_t)ODP_TIME_MSEC_IN_NS); return NULL; @@ -595,13 +595,13 @@ static int setup_txrx_masks(odp_cpumask_t *thd_mask_tx, */ static void busy_loop_ns(uint64_t wait_ns) { - odp_time_t diff; - odp_time_t start_time = odp_time_local(); - odp_time_t wait = odp_time_local_from_ns(wait_ns); + odp_time_t wait = odp_time_local_val(wait_ns); + odp_time_t cur = odp_time_local(); + odp_time_t end_time = odp_time_sum(cur, wait); do { - diff = odp_time_diff(odp_time_local(), start_time); - } while (odp_time_cmp(wait, diff) > 0); + cur = odp_time_local(); + } while (odp_time_cmp(end_time, cur) > 0); } /* diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index aee3a7d..6d7e954 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -339,7 +339,7 @@ static odp_event_t queue_deq_wait_time(odp_queue_t queue, uint64_t ns) odp_time_t wait, end; odp_event_t ev; - wait = odp_time_local_from_ns(ns); + wait = odp_time_local_val(ns); end = odp_time_sum(odp_time_local(), wait); do { ev = odp_queue_deq(queue); @@ -359,7 +359,7 @@ static odp_packet_t wait_for_packet(pktio_info_t *pktio_rx, uint64_t wait; wait = odp_schedule_wait_time(ns); - wait_time = odp_time_local_from_ns(ns); + wait_time = odp_time_local_val(ns); end = odp_time_sum(odp_time_local(), wait_time); do { pkt = ODP_PACKET_INVALID; diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c index a562a8a..58f93e0 100644 --- a/test/validation/scheduler/scheduler.c +++ b/test/validation/scheduler/scheduler.c @@ -718,7 +718,7 @@ static void *schedule_common_(void *arg) CU_ASSERT(from != ODP_QUEUE_INVALID); if (locked) { int cnt; - odp_time_t time = ODP_TIME_NULL; + odp_time_t time = ODP_TIME_NULL_VAL; /* Do some work here to keep the thread busy */ for (cnt = 0; cnt < 1000; cnt++) time = odp_time_sum(time, diff --git a/test/validation/time/time.c b/test/validation/time/time.c index 8f5dfe6..4386c34 100644 --- a/test/validation/time/time.c +++ b/test/validation/time/time.c @@ -18,6 +18,7 @@ void time_test_odp_conversion(void) odp_time_t time; uint64_t upper_limit, lower_limit; + /* test timestamp conversions */ ns1 = 100; time = odp_time_local_from_ns(ns1); @@ -34,8 +35,18 @@ void time_test_odp_conversion(void) ns2 = odp_time_to_ns(time); - /* need to check within arithmetic tolerance that the same - * value in ns is returned after conversions */ + /* + * need to check within arithmetic tolerance that the same + * value in ns is returned after conversions + */ + upper_limit = ns1 + TOLERANCE; + lower_limit = ns1 - TOLERANCE; + CU_ASSERT((ns2 <= upper_limit) && (ns2 >= lower_limit)); + + /* test time vals conversions */ + time = odp_time_local_val(ns1); + ns2 = odp_time_val_to_ns(time); + upper_limit = ns1 + TOLERANCE; lower_limit = ns1 - TOLERANCE; CU_ASSERT((ns2 <= upper_limit) && (ns2 >= lower_limit)); @@ -75,6 +86,7 @@ void time_test_odp_cmp(void) volatile int count = 0; odp_time_t t1, t2, t3; + /* test compare of timestamps */ t1 = odp_time_local(); while (count < BUSY_LOOP_CNT) { @@ -105,8 +117,23 @@ void time_test_odp_cmp(void) CU_ASSERT(odp_time_cmp(t2, t1) > 0); CU_ASSERT(odp_time_cmp(t1, t2) < 0); - t1 = odp_time_local_from_ns(0); - CU_ASSERT(odp_time_cmp(t1, ODP_TIME_NULL) == 0); + t1 = odp_time_local_val(0); + CU_ASSERT(odp_time_cmp(t1, ODP_TIME_NULL_VAL) == 0); + + /* test compare of time intervals */ + t1 = odp_time_local_val(15); + t2 = odp_time_local_val(23); + t3 = odp_time_local_val(51); + + CU_ASSERT(odp_time_cmp(t2, t1) > 0); + CU_ASSERT(odp_time_cmp(t3, t2) > 0); + CU_ASSERT(odp_time_cmp(t3, t1) > 0); + CU_ASSERT(odp_time_cmp(t1, t2) < 0); + CU_ASSERT(odp_time_cmp(t2, t3) < 0); + CU_ASSERT(odp_time_cmp(t1, t3) < 0); + CU_ASSERT(odp_time_cmp(t1, t1) == 0); + CU_ASSERT(odp_time_cmp(t2, t2) == 0); + CU_ASSERT(odp_time_cmp(t3, t3) == 0); } /* check that a time difference gives a reasonable result */ @@ -129,12 +156,12 @@ void time_test_odp_diff(void) CU_ASSERT(odp_time_cmp(t2, t1) > 0); diff = odp_time_diff(t2, t1); - CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL) > 0); + CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL_VAL) > 0); ns1 = odp_time_to_ns(t1); ns2 = odp_time_to_ns(t2); ns = ns2 - ns1; - nsdiff = odp_time_to_ns(diff); + nsdiff = odp_time_val_to_ns(diff); upper_limit = ns + TOLERANCE; lower_limit = ns - TOLERANCE; @@ -142,11 +169,11 @@ void time_test_odp_diff(void) /* test timestamp and interval diff */ ns1 = 54; - t1 = odp_time_local_from_ns(ns1); + t1 = odp_time_local_val(ns1); ns = ns2 - ns1; diff = odp_time_diff(t2, t1); - CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL) > 0); + CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL_VAL) > 0); nsdiff = odp_time_to_ns(diff); upper_limit = ns + TOLERANCE; @@ -157,10 +184,10 @@ void time_test_odp_diff(void) ns2 = 60 * 10 * ODP_TIME_SEC_IN_NS; ns = ns2 - ns1; - t2 = odp_time_local_from_ns(ns2); + t2 = odp_time_local_val(ns2); diff = odp_time_diff(t2, t1); - CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL) > 0); - nsdiff = odp_time_to_ns(diff); + CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL_VAL) > 0); + nsdiff = odp_time_val_to_ns(diff); upper_limit = ns + TOLERANCE; lower_limit = ns - TOLERANCE; @@ -168,9 +195,9 @@ void time_test_odp_diff(void) /* same time has to diff to 0 */ diff = odp_time_diff(t2, t2); - CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL) == 0); + CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL_VAL) == 0); - diff = odp_time_diff(t2, ODP_TIME_NULL); + diff = odp_time_diff(t2, ODP_TIME_NULL_VAL); CU_ASSERT(odp_time_cmp(t2, diff) == 0); } @@ -184,12 +211,12 @@ void time_test_odp_sum(void) /* sum timestamp and interval */ t1 = odp_time_local(); ns2 = 103; - t2 = odp_time_local_from_ns(ns2); + t2 = odp_time_local_val(ns2); ns1 = odp_time_to_ns(t1); ns = ns1 + ns2; sum = odp_time_sum(t2, t1); - CU_ASSERT(odp_time_cmp(sum, ODP_TIME_NULL) > 0); + CU_ASSERT(odp_time_cmp(sum, ODP_TIME_NULL_VAL) > 0); nssum = odp_time_to_ns(sum); upper_limit = ns + TOLERANCE; @@ -198,19 +225,19 @@ void time_test_odp_sum(void) /* sum intervals */ ns1 = 60 * 13 * ODP_TIME_SEC_IN_NS; - t1 = odp_time_local_from_ns(ns1); + t1 = odp_time_local_val(ns1); ns = ns1 + ns2; sum = odp_time_sum(t2, t1); - CU_ASSERT(odp_time_cmp(sum, ODP_TIME_NULL) > 0); - nssum = odp_time_to_ns(sum); + CU_ASSERT(odp_time_cmp(sum, ODP_TIME_NULL_VAL) > 0); + nssum = odp_time_val_to_ns(sum); upper_limit = ns + TOLERANCE; lower_limit = ns - TOLERANCE; CU_ASSERT((nssum <= upper_limit) && (nssum >= lower_limit)); /* test on 0 */ - sum = odp_time_sum(t2, ODP_TIME_NULL); + sum = odp_time_sum(t2, ODP_TIME_NULL_VAL); CU_ASSERT(odp_time_cmp(t2, sum) == 0); } @@ -235,7 +262,7 @@ void time_test_odp_to_u64(void) CU_ASSERT(val2 > val1); - val1 = odp_time_to_u64(ODP_TIME_NULL); + val1 = odp_time_to_u64(ODP_TIME_NULL_VAL); CU_ASSERT(val1 == 0); }