You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/11/22 01:17:11 UTC
[12/27] incubator-mynewt-core git commit: oic; using os_callout() now;
remove oc_etimer.
oic; using os_callout() now; remove oc_etimer.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/7c67f1c2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7c67f1c2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7c67f1c2
Branch: refs/heads/develop
Commit: 7c67f1c2e0a51f2f270f35988f2a72957dcbb8b0
Parents: cf8db8f
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Nov 16 16:18:06 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Nov 21 17:15:48 2016 -0800
----------------------------------------------------------------------
net/oic/include/oic/oc_api.h | 4 -
net/oic/include/oic/oc_ri.h | 13 --
net/oic/src/api/oc_main.c | 9 +-
net/oic/src/api/oc_ri.c | 18 +--
net/oic/src/messaging/coap/observe.h | 1 -
net/oic/src/util/oc_etimer.c | 224 ------------------------------
net/oic/src/util/oc_etimer.h | 186 -------------------------
net/oic/src/util/oc_timer.c | 131 -----------------
net/oic/src/util/oc_timer.h | 96 -------------
9 files changed, 7 insertions(+), 675 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7c67f1c2/net/oic/include/oic/oc_api.h
----------------------------------------------------------------------
diff --git a/net/oic/include/oic/oc_api.h b/net/oic/include/oic/oc_api.h
index 83e91f7..f0c6346 100644
--- a/net/oic/include/oic/oc_api.h
+++ b/net/oic/include/oic/oc_api.h
@@ -138,10 +138,6 @@ bool oc_stop_observe(const char *uri, oc_server_handle_t *server);
/** Common operations */
-void oc_set_delayed_callback(void *cb_data, oc_trigger_t callback,
- uint16_t seconds);
-void oc_remove_delayed_callback(void *cb_data, oc_trigger_t callback);
-
/** API for setting handlers for interrupts */
#define oc_signal_interrupt_handler(name) \
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7c67f1c2/net/oic/include/oic/oc_ri.h
----------------------------------------------------------------------
diff --git a/net/oic/include/oic/oc_ri.h b/net/oic/include/oic/oc_ri.h
index 30a706c..79e57e6 100644
--- a/net/oic/include/oic/oc_ri.h
+++ b/net/oic/include/oic/oc_ri.h
@@ -21,7 +21,6 @@
#include "oc_rep.h"
#include "oc_uuid.h"
#include "../../src/port/oc_connectivity.h"
-#include "../../src/util/oc_etimer.h"
#ifdef __cplusplus
extern "C" {
@@ -129,18 +128,6 @@ typedef struct oc_resource_s
uint8_t num_observers;
} oc_resource_t;
-typedef enum { DONE = 0, CONTINUE } oc_event_callback_retval_t;
-
-typedef oc_event_callback_retval_t (*oc_trigger_t)(void *);
-
-typedef struct oc_event_callback_s
-{
- struct oc_event_callback_s *next;
- struct oc_etimer timer;
- oc_trigger_t callback;
- void *data;
-} oc_event_callback_t;
-
void oc_ri_init(void);
void oc_ri_shutdown(void);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7c67f1c2/net/oic/src/api/oc_main.c
----------------------------------------------------------------------
diff --git a/net/oic/src/api/oc_main.c b/net/oic/src/api/oc_main.c
index 9086b4e..8a19243 100644
--- a/net/oic/src/api/oc_main.c
+++ b/net/oic/src/api/oc_main.c
@@ -21,7 +21,6 @@
#include "port/oc_clock.h"
#include "port/oc_connectivity.h"
-#include "util/oc_etimer.h"
#include "util/oc_process.h"
#include "oc_api.h"
@@ -93,11 +92,9 @@ err:
oc_clock_time_t
oc_main_poll(void)
{
- oc_clock_time_t ticks_until_next_event = oc_etimer_request_poll();
- while (oc_process_run()) {
- ticks_until_next_event = oc_etimer_request_poll();
- }
- return ticks_until_next_event;
+ while (oc_process_run());
+
+ return 0;
}
void
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7c67f1c2/net/oic/src/api/oc_ri.c
----------------------------------------------------------------------
diff --git a/net/oic/src/api/oc_ri.c b/net/oic/src/api/oc_ri.c
index 7d08b82..32d9a62 100644
--- a/net/oic/src/api/oc_ri.c
+++ b/net/oic/src/api/oc_ri.c
@@ -20,7 +20,6 @@
#include <os/os_callout.h>
-#include "util/oc_etimer.h"
#include "util/oc_list.h"
#include "util/oc_memb.h"
#include "util/oc_process.h"
@@ -30,6 +29,7 @@
#include "messaging/coap/oc_coap.h"
#include "port/oc_random.h"
+#include "port/oc_clock.h"
#include "port/mynewt/adaptor.h"
#include "oc_buffer.h"
@@ -192,7 +192,6 @@ static void
start_processes(void)
{
allocate_events();
- oc_etimer_init();
oc_process_start(&coap_engine, NULL);
oc_process_start(&message_buffer_handler, NULL);
@@ -206,7 +205,6 @@ start_processes(void)
static void
stop_processes(void)
{
- oc_etimer_deinit();
oc_process_exit(&coap_engine);
#ifdef OC_SECURITY
@@ -235,7 +233,6 @@ void
oc_ri_init(void)
{
oc_random_init(0); // Fix: allow user to seed RNG.
- oc_clock_init();
set_mpro_status_codes();
#ifdef OC_SERVER
@@ -608,7 +605,7 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response, uint8_t *buffer,
bool set_observe_option = true;
if (cur_resource->properties & OC_PERIODIC) {
os_callout_reset(&cur_resource->callout,
- resource->observe_period_seconds * OC_CLOCK_SECOND);
+ resource->observe_period_seconds * OS_TICKS_PER_SEC);
}
if (set_observe_option) {
@@ -705,13 +702,6 @@ oc_ri_remove_client_cb_by_mid(uint16_t mid)
free_client_cb(cb);
}
-oc_event_callback_retval_t
-oc_ri_remove_client_cb(void *data)
-{
- free_client_cb(data);
- return DONE;
-}
-
bool
oc_ri_send_rst(oc_endpoint_t *endpoint, uint8_t *token, uint8_t token_len,
uint16_t mid)
@@ -789,7 +779,7 @@ oc_ri_invoke_client_cb(void *response, oc_endpoint_t *endpoint)
if (cb->discovery) {
if (oc_ri_process_discovery_payload(payload, payload_len, cb->handler,
endpoint) == OC_STOP_DISCOVERY) {
- oc_ri_remove_client_cb(cb);
+ free_client_cb(cb);
}
} else {
uint16_t err =
@@ -855,7 +845,7 @@ oc_ri_remove_cb(struct os_event *ev)
cb = ev->ev_arg;
- oc_ri_remove_client_cb(cb);
+ free_client_cb(cb);
}
oc_client_cb_t *
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7c67f1c2/net/oic/src/messaging/coap/observe.h
----------------------------------------------------------------------
diff --git a/net/oic/src/messaging/coap/observe.h b/net/oic/src/messaging/coap/observe.h
index 20c207e..b1eadc2 100644
--- a/net/oic/src/messaging/coap/observe.h
+++ b/net/oic/src/messaging/coap/observe.h
@@ -61,7 +61,6 @@ typedef struct coap_observer
int32_t obs_counter;
- struct oc_etimer retrans_timer;
uint8_t retrans_counter;
} coap_observer_t;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7c67f1c2/net/oic/src/util/oc_etimer.c
----------------------------------------------------------------------
diff --git a/net/oic/src/util/oc_etimer.c b/net/oic/src/util/oc_etimer.c
deleted file mode 100644
index 138d251..0000000
--- a/net/oic/src/util/oc_etimer.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright (c) 2016 Intel Corporation
- *
- * Copyright (c) 2004, Swedish Institute of Computer Science.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the Institute nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This file is part of the Contiki operating system.
- *
- * Author: Adam Dunkels <ad...@sics.se>
- *
- */
-
-#include <os/os_eventq.h>
-
-#include "oc_etimer.h"
-#include "oc_process.h"
-#include "port/mynewt/adaptor.h"
-
-static void oc_etimer_process(struct os_event *);
-
-static struct os_event etimer_ev = {
- .ev_cb = oc_etimer_process
-};
-
-static struct oc_etimer *timerlist;
-static oc_clock_time_t next_expiration;
-
-/*---------------------------------------------------------------------------*/
-static void
-update_time(void)
-{
- oc_clock_time_t tdist;
- oc_clock_time_t now;
- struct oc_etimer *t;
-
- if (timerlist == NULL) {
- next_expiration = 0;
- } else {
- now = oc_clock_time();
- t = timerlist;
- /* Must calculate distance to next time into account due to wraps */
- tdist = t->timer.start + t->timer.interval - now;
- for (t = t->next; t != NULL; t = t->next) {
- if (t->timer.start + t->timer.interval - now < tdist) {
- tdist = t->timer.start + t->timer.interval - now;
- }
- }
- next_expiration = now + tdist;
- }
-}
-/*---------------------------------------------------------------------------*/
-oc_clock_time_t
-oc_etimer_request_poll(void)
-{
- oc_etimer_sched();
- return oc_etimer_next_expiration_time();
-}
-/*---------------------------------------------------------------------------*/
-static void
-add_timer(struct oc_etimer *timer)
-{
- struct oc_etimer *t;
-
- oc_etimer_request_poll();
-
- if (timer->p != OC_PROCESS_NONE) {
- for (t = timerlist; t != NULL; t = t->next) {
- if (t == timer) {
- /* Timer already on list, bail out. */
- timer->p = OC_PROCESS_CURRENT();
- update_time();
- return;
- }
- }
- }
-
- /* Timer not on list. */
- timer->p = OC_PROCESS_CURRENT();
- timer->next = timerlist;
- timerlist = timer;
-
- update_time();
-}
-/*---------------------------------------------------------------------------*/
-void
-oc_etimer_set(struct oc_etimer *et, oc_clock_time_t interval)
-{
- oc_timer_set(&et->timer, interval);
- add_timer(et);
-}
-/*---------------------------------------------------------------------------*/
-void
-oc_etimer_restart(struct oc_etimer *et)
-{
- oc_timer_restart(&et->timer);
- add_timer(et);
-}
-/*---------------------------------------------------------------------------*/
-int
-oc_etimer_expired(struct oc_etimer *et)
-{
- return et->p == OC_PROCESS_NONE;
-}
-/*---------------------------------------------------------------------------*/
-int
-oc_etimer_pending(void)
-{
- return timerlist != NULL;
-}
-/*---------------------------------------------------------------------------*/
-oc_clock_time_t
-oc_etimer_next_expiration_time(void)
-{
- return oc_etimer_pending() ? next_expiration : 0;
-}
-/*---------------------------------------------------------------------------*/
-void
-oc_etimer_stop(struct oc_etimer *et)
-{
- struct oc_etimer *t;
-
- /* First check if et is the first event timer on the list. */
- if (et == timerlist) {
- timerlist = timerlist->next;
- update_time();
- } else {
- /* Else walk through the list and try to find the item before the
- et timer. */
- for (t = timerlist; t != NULL && t->next != et; t = t->next)
- ;
-
- if (t != NULL) {
- /* We've found the item before the event timer that we are about
- to remove. We point the items next pointer to the event after
- the removed item. */
- t->next = et->next;
-
- update_time();
- }
- }
-
- /* Remove the next pointer from the item to be removed. */
- et->next = NULL;
- /* Set the timer as expired */
- et->p = OC_PROCESS_NONE;
-}
-
-void
-oc_etimer_init(void)
-{
- timerlist = NULL;
-}
-
-void
-oc_etimer_deinit(void)
-{
- timerlist = NULL;
-}
-
-void
-oc_etimer_sched(void)
-{
- os_eventq_put(oc_evq_get(), &etimer_ev);
-}
-
-static void
-oc_etimer_process(struct os_event *ev)
-{
- struct oc_etimer *t, *u;
-
-again:
- u = NULL;
-
- for (t = timerlist; t != NULL; t = t->next) {
- if (oc_timer_expired(&t->timer)) {
- if (oc_process_post(t->p, OC_PROCESS_EVENT_TIMER, t) ==
- OC_PROCESS_ERR_OK) {
-
- /* Reset the process ID of the event timer, to signal that the
- etimer has expired. This is later checked in the
- oc_etimer_expired() function. */
- t->p = OC_PROCESS_NONE;
- if (u != NULL) {
- u->next = t->next;
- } else {
- timerlist = t->next;
- }
- t->next = NULL;
- update_time();
- goto again;
- } else {
- oc_etimer_request_poll();
- }
- }
- u = t;
- }
-}
-
-/*---------------------------------------------------------------------------*/
-/** @} */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7c67f1c2/net/oic/src/util/oc_etimer.h
----------------------------------------------------------------------
diff --git a/net/oic/src/util/oc_etimer.h b/net/oic/src/util/oc_etimer.h
deleted file mode 100644
index 4ef58e5..0000000
--- a/net/oic/src/util/oc_etimer.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (c) 2016 Intel Corporation
- *
- * Copyright (c) 2004, Swedish Institute of Computer Science.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the Institute nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This file is part of the Contiki operating system.
- *
- * Author: Adam Dunkels <ad...@sics.se>
- *
- */
-
-/**
- * \defgroup etimer Event timers
- *
- * Event timers provides a way to generate timed events. An event
- * timer will post an event to the process that set the timer when the
- * event timer expires.
- *
- * An event timer is declared as a \c struct \c etimer and all access
- * to the event timer is made by a pointer to the declared event
- * timer.
- *
- * \sa \ref timer "Simple timer library"
- * \sa \ref clock "Clock library" (used by the timer library)
- *
- * @{
- */
-
-#ifndef OC_ETIMER_H
-#define OC_ETIMER_H
-
-#include "oc_process.h"
-#include "oc_timer.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * A timer.
- *
- * This structure is used for declaring a timer. The timer must be set
- * with oc_etimer_set() before it can be used.
- *
- * \hideinitializer
- */
-struct oc_etimer
-{
- struct oc_timer timer;
- struct oc_etimer *next;
- struct oc_process *p;
-};
-
-/**
- * \name Functions called from application programs
- * @{
- */
-
-/**
- * \brief Set an event timer.
- * \param et A pointer to the event timer
- * \param interval The interval before the timer expires.
- *
- * This function is used to set an event timer for a time
- * sometime in the future. When the event timer expires,
- * the event PROCESS_EVENT_TIMER will be posted to the
- * process that called the oc_etimer_set() function.
- *
- */
-void oc_etimer_set(struct oc_etimer *et, oc_clock_time_t interval);
-
-/**
- * \brief Restart an event timer from the current point in time
- * \param et A pointer to the event timer.
- *
- * This function restarts the event timer with the same
- * interval that was given to the oc_etimer_set()
- * function. The event timer will start at the current
- * time.
- *
- * \note A periodic timer will drift if this function is
- * used to reset it. For periodic timers, use the
- * oc_etimer_reset() function instead.
- *
- * \sa oc_etimer_reset()
- */
-void oc_etimer_restart(struct oc_etimer *et);
-
-/**
- * \brief Check if an event timer has expired.
- * \param et A pointer to the event timer
- * \return Non-zero if the timer has expired, zero otherwise.
- *
- * This function tests if an event timer has expired and
- * returns true or false depending on its status.
- */
-int oc_etimer_expired(struct oc_etimer *et);
-
-/**
- * \brief Stop a pending event timer.
- * \param et A pointer to the pending event timer.
- *
- * This function stops an event timer that has previously
- * been set with oc_etimer_set() or oc_etimer_reset(). After
- * this function has been called, the event timer will not
- * emit any event when it expires.
- *
- */
-void oc_etimer_stop(struct oc_etimer *et);
-
-/** @} */
-
-/**
- * \name Functions called from timer interrupts, by the system
- * @{
- */
-
-/**
- * \brief Make the event timer aware that the clock has changed
- *
- * This function is used to inform the event timer module
- * that the system clock has been updated. Typically, this
- * function would be called from the timer interrupt
- * handler when the clock has ticked.
- */
-oc_clock_time_t oc_etimer_request_poll(void);
-
-/**
- * \brief Check if there are any non-expired event timers.
- * \return True if there are active event timers, false if there are
- * no active timers.
- *
- * This function checks if there are any active event
- * timers that have not expired.
- */
-int oc_etimer_pending(void);
-
-/**
- * \brief Get next event timer expiration time.
- * \return Next expiration time of all pending event timers.
- * If there are no pending event timers this function
- * returns 0.
- *
- * This functions returns next expiration time of all
- * pending event timers.
- */
-oc_clock_time_t oc_etimer_next_expiration_time(void);
-
-/** @} */
-
-void oc_etimer_init(void);
-void oc_etimer_deinit(void);
-void oc_etimer_sched(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* OC_ETIMER_H */
-/** @} */
-/** @} */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7c67f1c2/net/oic/src/util/oc_timer.c
----------------------------------------------------------------------
diff --git a/net/oic/src/util/oc_timer.c b/net/oic/src/util/oc_timer.c
deleted file mode 100644
index 5372f0b..0000000
--- a/net/oic/src/util/oc_timer.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) 2004, Swedish Institute of Computer Science.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the Institute nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This file is part of the Contiki operating system.
- *
- * Author: Adam Dunkels <ad...@sics.se>
- *
- */
-
-#include "oc_timer.h"
-
-/*---------------------------------------------------------------------------*/
-/**
- * Set a timer.
- *
- * This function is used to set a timer for a time sometime in the
- * future. The function oc_timer_expired() will evaluate to true after
- * the timer has expired.
- *
- * \param t A pointer to the timer
- * \param interval The interval before the timer expires.
- *
- */
-void
-oc_timer_set(struct oc_timer *t, oc_clock_time_t interval)
-{
- t->interval = interval;
- t->start = oc_clock_time();
-}
-/*---------------------------------------------------------------------------*/
-/**
- * Reset the timer with the same interval.
- *
- * This function resets the timer with the same interval that was
- * given to the oc_timer_set() function. The start point of the interval
- * is the exact time that the timer last expired. Therefore, this
- * function will cause the timer to be stable over time, unlike the
- * oc_timer_restart() function.
- *
- * \note Must not be executed before timer expired
- *
- * \param t A pointer to the timer.
- * \sa oc_timer_restart()
- */
-void
-oc_timer_reset(struct oc_timer *t)
-{
- t->start += t->interval;
-}
-/*---------------------------------------------------------------------------*/
-/**
- * Restart the timer from the current point in time
- *
- * This function restarts a timer with the same interval that was
- * given to the oc_timer_set() function. The timer will start at the
- * current time.
- *
- * \note A periodic timer will drift if this function is used to reset
- * it. For preioric timers, use the oc_timer_reset() function instead.
- *
- * \param t A pointer to the timer.
- *
- * \sa oc_timer_reset()
- */
-void
-oc_timer_restart(struct oc_timer *t)
-{
- t->start = oc_clock_time();
-}
-/*---------------------------------------------------------------------------*/
-/**
- * Check if a timer has expired.
- *
- * This function tests if a timer has expired and returns true or
- * false depending on its status.
- *
- * \param t A pointer to the timer
- *
- * \return Non-zero if the timer has expired, zero otherwise.
- *
- */
-int
-oc_timer_expired(struct oc_timer *t)
-{
- /* Note: Can not return diff >= t->interval so we add 1 to diff and return
- t->interval < diff - required to avoid an internal error in mspgcc. */
- oc_clock_time_t diff = (oc_clock_time() - t->start) + 1;
- return t->interval < diff;
-}
-/*---------------------------------------------------------------------------*/
-/**
- * The time until the timer expires
- *
- * This function returns the time until the timer expires.
- *
- * \param t A pointer to the timer
- *
- * \return The time until the timer expires
- *
- */
-oc_clock_time_t
-oc_timer_remaining(struct oc_timer *t)
-{
- return t->start + t->interval - oc_clock_time();
-}
-/*---------------------------------------------------------------------------*/
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7c67f1c2/net/oic/src/util/oc_timer.h
----------------------------------------------------------------------
diff --git a/net/oic/src/util/oc_timer.h b/net/oic/src/util/oc_timer.h
deleted file mode 100644
index fd6c826..0000000
--- a/net/oic/src/util/oc_timer.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2004, Swedish Institute of Computer Science.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the Institute nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This file is part of the Contiki operating system.
- *
- * Author: Adam Dunkels <ad...@sics.se>
- *
- */
-
-/**
- * \defgroup timer Timer library
- *
- * The Contiki kernel does not provide support for timed
- * events. Rather, an application that wants to use timers needs to
- * explicitly use the timer library.
- *
- * The timer library provides functions for setting, resetting and
- * restarting timers, and for checking if a timer has expired. An
- * application must "manually" check if its timers have expired; this
- * is not done automatically.
- *
- * A timer is declared as a \c struct \c timer and all access to the
- * timer is made by a pointer to the declared timer.
- *
- * \note The timer library is not able to post events when a timer
- * expires. The \ref etimer "Event timers" should be used for this
- * purpose.
- *
- * \note The timer library uses the \ref clock "Clock library" to
- * measure time. Intervals should be specified in the format used by
- * the clock library.
- *
- * \sa \ref etimer "Event timers"
- *
- * @{
- */
-
-#ifndef OC_TIMER_H
-#define OC_TIMER_H
-
-#include "../port/oc_clock.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * A timer.
- *
- * This structure is used for declaring a timer. The timer must be set
- * with timer_set() before it can be used.
- *
- * \hideinitializer
- */
-struct oc_timer
-{
- oc_clock_time_t start;
- oc_clock_time_t interval;
-};
-
-void oc_timer_set(struct oc_timer *t, oc_clock_time_t interval);
-void oc_timer_reset(struct oc_timer *t);
-void oc_timer_restart(struct oc_timer *t);
-int oc_timer_expired(struct oc_timer *t);
-oc_clock_time_t oc_timer_remaining(struct oc_timer *t);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* OC_TIMER_H */