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:18 UTC

[19/27] incubator-mynewt-core git commit: oic; remove oc_process.h/oc_events.h

oic; remove oc_process.h/oc_events.h


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/3fa41bf8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/3fa41bf8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/3fa41bf8

Branch: refs/heads/develop
Commit: 3fa41bf85e4ce8e3c17b4c2d56340434b16b5c83
Parents: 7f841e0
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Nov 17 19:50:00 2016 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Nov 21 17:15:49 2016 -0800

----------------------------------------------------------------------
 net/oic/include/oic/oc_buffer.h          |  16 +-
 net/oic/include/oic/oc_network_events.h  |   3 -
 net/oic/src/api/oc_buffer.c              |   2 +-
 net/oic/src/api/oc_events.h              |  42 --
 net/oic/src/api/oc_main.c                |   6 +-
 net/oic/src/api/oc_network_events.c      |   1 +
 net/oic/src/api/oc_ri.c                  |  12 -
 net/oic/src/messaging/coap/engine.c      |   1 -
 net/oic/src/port/mynewt/ble_adaptor.c    |   1 +
 net/oic/src/port/mynewt/serial_adaptor.c |   1 +
 net/oic/src/port/oc_connectivity.h       |   1 -
 net/oic/src/util/oc_process.c            | 346 -----------------
 net/oic/src/util/oc_process.h            | 535 --------------------------
 net/oic/src/util/pt/lc-addrlabels.h      |  94 -----
 net/oic/src/util/pt/lc-switch.h          |  87 -----
 net/oic/src/util/pt/lc.h                 | 138 -------
 net/oic/src/util/pt/pt-sem.h             | 241 ------------
 net/oic/src/util/pt/pt.h                 | 341 ----------------
 18 files changed, 12 insertions(+), 1856 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/net/oic/include/oic/oc_buffer.h
----------------------------------------------------------------------
diff --git a/net/oic/include/oic/oc_buffer.h b/net/oic/include/oic/oc_buffer.h
index 0bbf8a7..852e427 100644
--- a/net/oic/include/oic/oc_buffer.h
+++ b/net/oic/include/oic/oc_buffer.h
@@ -17,21 +17,17 @@
 #ifndef OC_BUFFER_H
 #define OC_BUFFER_H
 
-#include "../../src/port/oc_connectivity.h"
-#include "../../src/util/oc_process.h"
-#include <stdbool.h>
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-OC_PROCESS_NAME(message_buffer_handler);
-oc_message_t *oc_allocate_message(void);
-void oc_message_add_ref(oc_message_t *message);
-void oc_message_unref(oc_message_t *message);
+struct oc_message_s;
+struct oc_message_s *oc_allocate_message(void);
+void oc_message_add_ref(struct oc_message_s *message);
+void oc_message_unref(struct oc_message_s *message);
 
-void oc_recv_message(oc_message_t *message);
-void oc_send_message(oc_message_t *message);
+void oc_recv_message(struct oc_message_s *message);
+void oc_send_message(struct oc_message_s *message);
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/net/oic/include/oic/oc_network_events.h
----------------------------------------------------------------------
diff --git a/net/oic/include/oic/oc_network_events.h b/net/oic/include/oic/oc_network_events.h
index fb557c0..61a274c 100644
--- a/net/oic/include/oic/oc_network_events.h
+++ b/net/oic/include/oic/oc_network_events.h
@@ -17,9 +17,6 @@
 #ifndef OC_NETWORK_EVENTS_H
 #define OC_NETWORK_EVENTS_H
 
-#include "../../src/port/oc_network_events_mutex.h"
-#include "../../src/util/oc_process.h"
-
 #ifdef __cplusplus
 extern "C" {
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/net/oic/src/api/oc_buffer.c
----------------------------------------------------------------------
diff --git a/net/oic/src/api/oc_buffer.c b/net/oic/src/api/oc_buffer.c
index e800e08..88c7731 100644
--- a/net/oic/src/api/oc_buffer.c
+++ b/net/oic/src/api/oc_buffer.c
@@ -27,7 +27,6 @@
 
 #include "config.h"
 #include "oc_buffer.h"
-#include "oc_events.h"
 
 #include "port/mynewt/adaptor.h"
 
@@ -118,6 +117,7 @@ oc_buffer_tx(struct oc_message_s *message)
     } else {
 #endif
 #ifdef OC_SECURITY
+        /* XXX convert this */
         if (message->endpoint.flags & SECURED) {
             LOG("Outbound network event: forwarding to DTLS\n");
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/net/oic/src/api/oc_events.h
----------------------------------------------------------------------
diff --git a/net/oic/src/api/oc_events.h b/net/oic/src/api/oc_events.h
deleted file mode 100644
index 19de52c..0000000
--- a/net/oic/src/api/oc_events.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- // Copyright (c) 2016 Intel Corporation
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- //      http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- */
-
-#ifndef OC_EVENTS_H
-#define OC_EVENTS_H
-
-#include "util/oc_process.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum {
-  INBOUND_NETWORK_EVENT,
-  UDP_TO_DTLS_EVENT,
-  INIT_DTLS_CONN_EVENT,
-  RI_TO_DTLS_EVENT,
-  INBOUND_RI_EVENT,
-  OUTBOUND_NETWORK_EVENT,
-  __NUM_OC_EVENT_TYPES__
-} oc_events_t;
-
-oc_process_event_t oc_events[__NUM_OC_EVENT_TYPES__];
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* OC_EVENTS_H */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/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 8a19243..acf0219 100644
--- a/net/oic/src/api/oc_main.c
+++ b/net/oic/src/api/oc_main.c
@@ -20,8 +20,8 @@
 #include "port/oc_assert.h"
 #include "port/oc_clock.h"
 #include "port/oc_connectivity.h"
-
-#include "util/oc_process.h"
+#include "port/oc_connectivity.h"
+#include "port/oc_network_events_mutex.h"
 
 #include "oc_api.h"
 
@@ -92,8 +92,6 @@ err:
 oc_clock_time_t
 oc_main_poll(void)
 {
-    while (oc_process_run());
-
     return 0;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/net/oic/src/api/oc_network_events.c
----------------------------------------------------------------------
diff --git a/net/oic/src/api/oc_network_events.c b/net/oic/src/api/oc_network_events.c
index 4ff00d2..fd5ba38 100644
--- a/net/oic/src/api/oc_network_events.c
+++ b/net/oic/src/api/oc_network_events.c
@@ -20,6 +20,7 @@
 #include "oc_buffer.h"
 #include "port/oc_connectivity.h"
 #include "port/oc_signal_main_loop.h"
+#include "port/oc_network_events_mutex.h"
 #include "port/mynewt/adaptor.h"
 #include "util/oc_list.h"
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/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 7903682..bcb605a 100644
--- a/net/oic/src/api/oc_ri.c
+++ b/net/oic/src/api/oc_ri.c
@@ -22,7 +22,6 @@
 
 #include "util/oc_list.h"
 #include "util/oc_memb.h"
-#include "util/oc_process.h"
 
 #include "messaging/coap/constants.h"
 #include "messaging/coap/engine.h"
@@ -35,7 +34,6 @@
 #include "oc_buffer.h"
 #include "oc_core_res.h"
 #include "oc_discovery.h"
-#include "oc_events.h"
 #include "oc_network_events.h"
 #include "oc_ri.h"
 #include "oc_uuid.h"
@@ -180,18 +178,8 @@ oc_ri_get_query_value(const char *query, int query_len, const char *key,
 }
 
 static void
-allocate_events(void)
-{
-  int i = 0;
-  for (i = 0; i < __NUM_OC_EVENT_TYPES__; i++) {
-    oc_events[i] = oc_process_alloc_event();
-  }
-}
-
-static void
 start_processes(void)
 {
-  allocate_events();
   coap_engine_init();
 
 #ifdef OC_SECURITY

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/net/oic/src/messaging/coap/engine.c
----------------------------------------------------------------------
diff --git a/net/oic/src/messaging/coap/engine.c b/net/oic/src/messaging/coap/engine.c
index 3fa4d21..fc7477c 100644
--- a/net/oic/src/messaging/coap/engine.c
+++ b/net/oic/src/messaging/coap/engine.c
@@ -37,7 +37,6 @@
 #include <string.h>
 
 /* OIC Stack headers */
-#include "api/oc_events.h"
 #include "oc_buffer.h"
 #include "oc_ri.h"
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/net/oic/src/port/mynewt/ble_adaptor.c
----------------------------------------------------------------------
diff --git a/net/oic/src/port/mynewt/ble_adaptor.c b/net/oic/src/port/mynewt/ble_adaptor.c
index 6963249..18ff7ad 100644
--- a/net/oic/src/port/mynewt/ble_adaptor.c
+++ b/net/oic/src/port/mynewt/ble_adaptor.c
@@ -23,6 +23,7 @@
 #include <os/os.h>
 #include <string.h>
 #include "oc_buffer.h"
+#include "port/oc_connectivity.h"
 #include "../oc_log.h"
 #include "adaptor.h"
 #include "host/ble_hs.h"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/net/oic/src/port/mynewt/serial_adaptor.c
----------------------------------------------------------------------
diff --git a/net/oic/src/port/mynewt/serial_adaptor.c b/net/oic/src/port/mynewt/serial_adaptor.c
index e1d20c0..ef8f4b0 100644
--- a/net/oic/src/port/mynewt/serial_adaptor.c
+++ b/net/oic/src/port/mynewt/serial_adaptor.c
@@ -24,6 +24,7 @@
 #include <os/os.h>
 #include <shell/shell.h>
 #include "oc_buffer.h"
+#include "port/oc_connectivity.h"
 #include "../oc_log.h"
 #include "adaptor.h"
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/net/oic/src/port/oc_connectivity.h
----------------------------------------------------------------------
diff --git a/net/oic/src/port/oc_connectivity.h b/net/oic/src/port/oc_connectivity.h
index a292f16..1380442 100644
--- a/net/oic/src/port/oc_connectivity.h
+++ b/net/oic/src/port/oc_connectivity.h
@@ -20,7 +20,6 @@
 #include "mynewt/config.h"
 #include "oic/oc_network_events.h"
 #include "oc_log.h"
-#include "../util/oc_process.h"
 #include <stdint.h>
 
 #ifdef __cplusplus

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/net/oic/src/util/oc_process.c
----------------------------------------------------------------------
diff --git a/net/oic/src/util/oc_process.c b/net/oic/src/util/oc_process.c
deleted file mode 100644
index 47c3282..0000000
--- a/net/oic/src/util/oc_process.c
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright (c) 2016 Intel Corporation
- *
- * Copyright (c) 2005, 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.
- *
- */
-
-#include "oc_process.h"
-#include "oc_buffer.h"
-#include <stdio.h>
-
-/*
- * Pointer to the currently running process structure.
- */
-struct oc_process *oc_process_list = NULL;
-struct oc_process *oc_process_current = NULL;
-
-static oc_process_event_t lastevent;
-
-/*
- * Structure used for keeping the queue of active events.
- */
-struct event_data
-{
-  oc_process_event_t ev;
-  oc_process_data_t data;
-  struct oc_process *p;
-};
-
-static oc_process_num_events_t nevents, fevent;
-static struct event_data events[OC_PROCESS_CONF_NUMEVENTS];
-
-#if OC_PROCESS_CONF_STATS
-oc_process_num_events_t process_maxevents;
-#endif
-
-static volatile unsigned char poll_requested;
-
-#define OC_PROCESS_STATE_NONE 0
-#define OC_PROCESS_STATE_RUNNING 1
-#define OC_PROCESS_STATE_CALLED 2
-
-static void call_process(struct oc_process *p, oc_process_event_t ev,
-                         oc_process_data_t data);
-
-/*---------------------------------------------------------------------------*/
-oc_process_event_t
-oc_process_alloc_event(void)
-{
-  return lastevent++;
-}
-/*---------------------------------------------------------------------------*/
-void
-oc_process_start(struct oc_process *p, oc_process_data_t data)
-{
-  struct oc_process *q;
-
-  /* First make sure that we don't try to start a process that is
-     already running. */
-  for (q = oc_process_list; q != p && q != NULL; q = q->next)
-    ;
-
-  /* If we found the process on the process list, we bail out. */
-  if (q == p) {
-    return;
-  }
-  /* Put on the procs list.*/
-  p->next = oc_process_list;
-  oc_process_list = p;
-  p->state = OC_PROCESS_STATE_RUNNING;
-  PT_INIT(&p->pt);
-
-  /* Post a synchronous initialization event to the process. */
-  oc_process_post_synch(p, OC_PROCESS_EVENT_INIT, data);
-}
-/*---------------------------------------------------------------------------*/
-static void
-exit_process(struct oc_process *p, struct oc_process *fromprocess)
-{
-  register struct oc_process *q;
-  struct oc_process *old_current = oc_process_current;
-
-  /* Make sure the process is in the process list before we try to
-     exit it. */
-  for (q = oc_process_list; q != p && q != NULL; q = q->next)
-    ;
-  if (q == NULL) {
-    return;
-  }
-
-  if (oc_process_is_running(p)) {
-    /* Process was running */
-    p->state = OC_PROCESS_STATE_NONE;
-
-    /*
-     * Post a synchronous event to all processes to inform them that
-     * this process is about to exit. This will allow services to
-     * deallocate state associated with this process.
-     */
-    for (q = oc_process_list; q != NULL; q = q->next) {
-      if (p != q) {
-        call_process(q, OC_PROCESS_EVENT_EXITED, (oc_process_data_t)p);
-      }
-    }
-
-    if (p->thread != NULL && p != fromprocess) {
-      /* Post the exit event to the process that is about to exit. */
-      oc_process_current = p;
-      p->thread(&p->pt, OC_PROCESS_EVENT_EXIT, NULL);
-    }
-  }
-
-  if (p == oc_process_list) {
-    oc_process_list = oc_process_list->next;
-  } else {
-    for (q = oc_process_list; q != NULL; q = q->next) {
-      if (q->next == p) {
-        q->next = p->next;
-        break;
-      }
-    }
-  }
-
-  oc_process_current = old_current;
-}
-/*---------------------------------------------------------------------------*/
-static void
-call_process(struct oc_process *p, oc_process_event_t ev,
-             oc_process_data_t data)
-{
-  int ret;
-
-  if ((p->state & OC_PROCESS_STATE_RUNNING) && p->thread != NULL) {
-    oc_process_current = p;
-    p->state = OC_PROCESS_STATE_CALLED;
-    ret = p->thread(&p->pt, ev, data);
-    if (ret == PT_EXITED || ret == PT_ENDED || ev == OC_PROCESS_EVENT_EXIT) {
-      exit_process(p, p);
-    } else {
-      p->state = OC_PROCESS_STATE_RUNNING;
-    }
-  }
-}
-/*---------------------------------------------------------------------------*/
-void
-oc_process_exit(struct oc_process *p)
-{
-  exit_process(p, OC_PROCESS_CURRENT());
-}
-/*---------------------------------------------------------------------------*/
-void
-oc_process_init(void)
-{
-  lastevent = OC_PROCESS_EVENT_MAX;
-
-  nevents = fevent = 0;
-#if OC_PROCESS_CONF_STATS
-  process_maxevents = 0;
-#endif /* OC_PROCESS_CONF_STATS */
-
-  oc_process_current = oc_process_list = NULL;
-}
-/*---------------------------------------------------------------------------*/
-/*
- * Call each process' poll handler.
- */
-/*---------------------------------------------------------------------------*/
-static void
-do_poll(void)
-{
-  struct oc_process *p;
-
-  poll_requested = 0;
-  /* Call the processes that needs to be polled. */
-  for (p = oc_process_list; p != NULL; p = p->next) {
-    if (p->needspoll) {
-      p->state = OC_PROCESS_STATE_RUNNING;
-      p->needspoll = 0;
-      call_process(p, OC_PROCESS_EVENT_POLL, NULL);
-    }
-  }
-}
-/*---------------------------------------------------------------------------*/
-/*
- * Process the next event in the event queue and deliver it to
- * listening processes.
- */
-/*---------------------------------------------------------------------------*/
-static void
-do_event(void)
-{
-  static oc_process_event_t ev;
-  static oc_process_data_t data;
-  static struct oc_process *receiver;
-  static struct oc_process *p;
-
-  /*
-   * If there are any events in the queue, take the first one and walk
-   * through the list of processes to see if the event should be
-   * delivered to any of them. If so, we call the event handler
-   * function for the process. We only process one event at a time and
-   * call the poll handlers inbetween.
-   */
-
-  if (nevents > 0) {
-
-    /* There are events that we should deliver. */
-    ev = events[fevent].ev;
-
-    data = events[fevent].data;
-    receiver = events[fevent].p;
-
-    /* Since we have seen the new event, we move pointer upwards
-       and decrease the number of events. */
-    fevent = (fevent + 1) % OC_PROCESS_CONF_NUMEVENTS;
-    --nevents;
-
-    /* If this is a broadcast event, we deliver it to all events, in
-       order of their priority. */
-    if (receiver == OC_PROCESS_BROADCAST) {
-      for (p = oc_process_list; p != NULL; p = p->next) {
-
-        /* If we have been requested to poll a process, we do this in
-           between processing the broadcast event. */
-        if (poll_requested) {
-          do_poll();
-        }
-        call_process(p, ev, data);
-      }
-    } else {
-      /* This is not a broadcast event, so we deliver it to the
-   specified process. */
-      /* If the event was an INIT event, we should also update the
-   state of the process. */
-      if (ev == OC_PROCESS_EVENT_INIT) {
-        receiver->state = OC_PROCESS_STATE_RUNNING;
-      }
-
-      /* Make sure that the process actually is running. */
-      call_process(receiver, ev, data);
-    }
-  }
-}
-/*---------------------------------------------------------------------------*/
-int
-oc_process_run(void)
-{
-  /* Process poll events. */
-  if (poll_requested) {
-    do_poll();
-  }
-
-  /* Process one event from the queue */
-  do_event();
-
-  return nevents + poll_requested;
-}
-/*---------------------------------------------------------------------------*/
-int
-oc_process_nevents(void)
-{
-  return nevents + poll_requested;
-}
-/*---------------------------------------------------------------------------*/
-int
-oc_process_post(struct oc_process *p, oc_process_event_t ev,
-                oc_process_data_t data)
-{
-  static oc_process_num_events_t snum;
-
-  if (nevents == OC_PROCESS_CONF_NUMEVENTS) {
-    oc_message_unref(data);
-    return OC_PROCESS_ERR_FULL;
-  }
-
-  snum =
-    (oc_process_num_events_t)(fevent + nevents) % OC_PROCESS_CONF_NUMEVENTS;
-  events[snum].ev = ev;
-  events[snum].data = data;
-  events[snum].p = p;
-  ++nevents;
-
-#if OC_PROCESS_CONF_STATS
-  if (nevents > process_maxevents) {
-    process_maxevents = nevents;
-  }
-#endif /* OC_PROCESS_CONF_STATS */
-
-  return OC_PROCESS_ERR_OK;
-}
-/*---------------------------------------------------------------------------*/
-void
-oc_process_post_synch(struct oc_process *p, oc_process_event_t ev,
-                      oc_process_data_t data)
-{
-  struct oc_process *caller = oc_process_current;
-
-  call_process(p, ev, data);
-  oc_process_current = caller;
-}
-/*---------------------------------------------------------------------------*/
-void
-oc_process_poll(struct oc_process *p)
-{
-  if (p != NULL) {
-    if (p->state == OC_PROCESS_STATE_RUNNING ||
-        p->state == OC_PROCESS_STATE_CALLED) {
-      p->needspoll = 1;
-      poll_requested = 1;
-    }
-  }
-}
-/*---------------------------------------------------------------------------*/
-int
-oc_process_is_running(struct oc_process *p)
-{
-  return p->state != OC_PROCESS_STATE_NONE;
-}
-/*---------------------------------------------------------------------------*/

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/net/oic/src/util/oc_process.h
----------------------------------------------------------------------
diff --git a/net/oic/src/util/oc_process.h b/net/oic/src/util/oc_process.h
deleted file mode 100644
index b81e217..0000000
--- a/net/oic/src/util/oc_process.h
+++ /dev/null
@@ -1,535 +0,0 @@
-/*
- * Copyright (c) 2016 Intel Corporation
- *
- * Copyright (c) 2005, 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.
- *
- */
-
-/**
- * \defgroup process Contiki processes
- *
- * A process in Contiki consists of a single \ref pt "protothread".
- *
- * @{
- */
-
-#ifndef OC_PROCESS_H
-#define OC_PROCESS_H
-#include "pt/pt.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif /* NULL */
-
-typedef unsigned char oc_process_event_t;
-typedef void *oc_process_data_t;
-typedef unsigned char oc_process_num_events_t;
-
-/**
- * \name Return values
- * @{
- */
-
-/**
- * \brief      Return value indicating that an operation was successful.
- *
- *             This value is returned to indicate that an operation
- *             was successful.
- */
-#define OC_PROCESS_ERR_OK 0
-/**
- * \brief      Return value indicating that the event queue was full.
- *
- *             This value is returned from process_post() to indicate
- *             that the event queue was full and that an event could
- *             not be posted.
- */
-#define OC_PROCESS_ERR_FULL 1
-/* @} */
-
-#define OC_PROCESS_NONE NULL
-
-#ifndef OC_PROCESS_CONF_NUMEVENTS
-#define OC_PROCESS_CONF_NUMEVENTS 10
-#endif /* OC_PROCESS_CONF_NUMEVENTS */
-
-#define OC_PROCESS_EVENT_NONE 0x80
-#define OC_PROCESS_EVENT_INIT 0x81
-#define OC_PROCESS_EVENT_POLL 0x82
-#define OC_PROCESS_EVENT_EXIT 0x83
-#define OC_PROCESS_EVENT_SERVICE_REMOVED 0x84
-#define OC_PROCESS_EVENT_CONTINUE 0x85
-#define OC_PROCESS_EVENT_MSG 0x86
-#define OC_PROCESS_EVENT_EXITED 0x87
-#define OC_PROCESS_EVENT_TIMER 0x88
-#define OC_PROCESS_EVENT_COM 0x89
-#define OC_PROCESS_EVENT_MAX 0x8a
-
-#define OC_PROCESS_BROADCAST NULL
-#define OC_PROCESS_ZOMBIE ((struct oc_process *)0x1)
-
-/**
- * \name Process protothread functions
- * @{
- */
-
-/**
- * Define the beginning of a process.
- *
- * This macro defines the beginning of a process, and must always
- * appear in a OC_PROCESS_THREAD() definition. The OC_PROCESS_END() macro
- * must come at the end of the process.
- *
- * \hideinitializer
- */
-#define OC_PROCESS_BEGIN() PT_BEGIN(process_pt)
-
-/**
- * Define the end of a process.
- *
- * This macro defines the end of a process. It must appear in a
- * OC_PROCESS_THREAD() definition and must always be included. The
- * process exits when the OC_PROCESS_END() macro is reached.
- *
- * \hideinitializer
- */
-#define OC_PROCESS_END() PT_END(process_pt)
-
-/**
- * Wait for an event to be posted to the process.
- *
- * This macro blocks the currently running process until the process
- * receives an event.
- *
- * \hideinitializer
- */
-#define OC_PROCESS_WAIT_EVENT() OC_PROCESS_YIELD()
-
-/**
- * Wait for an event to be posted to the process, with an extra
- * condition.
- *
- * This macro is similar to OC_PROCESS_WAIT_EVENT() in that it blocks the
- * currently running process until the process receives an event. But
- * OC_PROCESS_WAIT_EVENT_UNTIL() takes an extra condition which must be
- * true for the process to continue.
- *
- * \param c The condition that must be true for the process to continue.
- * \sa PT_WAIT_UNTIL()
- *
- * \hideinitializer
- */
-#define OC_PROCESS_WAIT_EVENT_UNTIL(c) OC_PROCESS_YIELD_UNTIL(c)
-
-/**
- * Yield the currently running process.
- *
- * \hideinitializer
- */
-#define OC_PROCESS_YIELD() PT_YIELD(process_pt)
-
-/**
- * Yield the currently running process until a condition occurs.
- *
- * This macro is different from OC_PROCESS_WAIT_UNTIL() in that
- * OC_PROCESS_YIELD_UNTIL() is guaranteed to always yield at least
- * once. This ensures that the process does not end up in an infinite
- * loop and monopolizing the CPU.
- *
- * \param c The condition to wait for.
- *
- * \hideinitializer
- */
-#define OC_PROCESS_YIELD_UNTIL(c) PT_YIELD_UNTIL(process_pt, c)
-
-/**
- * Wait for a condition to occur.
- *
- * This macro does not guarantee that the process yields, and should
- * therefore be used with care. In most cases, OC_PROCESS_WAIT_EVENT(),
- * OC_PROCESS_WAIT_EVENT_UNTIL(), OC_PROCESS_YIELD() or
- * OC_PROCESS_YIELD_UNTIL() should be used instead.
- *
- * \param c The condition to wait for.
- *
- * \hideinitializer
- */
-#define OC_PROCESS_WAIT_UNTIL(c) PT_WAIT_UNTIL(process_pt, c)
-#define OC_PROCESS_WAIT_WHILE(c) PT_WAIT_WHILE(process_pt, c)
-
-/**
- * Exit the currently running process.
- *
- * \hideinitializer
- */
-#define OC_PROCESS_EXIT() PT_EXIT(process_pt)
-
-/**
- * Spawn a protothread from the process.
- *
- * \param pt The protothread state (struct pt) for the new protothread
- * \param thread The call to the protothread function.
- * \sa PT_SPAWN()
- *
- * \hideinitializer
- */
-#define OC_PROCESS_PT_SPAWN(pt, thread) PT_SPAWN(process_pt, pt, thread)
-
-/**
- * Yield the process for a short while.
- *
- * This macro yields the currently running process for a short while,
- * thus letting other processes run before the process continues.
- *
- * \hideinitializer
- */
-#define OC_PROCESS_PAUSE()                                                     \
-  do {                                                                         \
-    process_post(OC_PROCESS_CURRENT(), OC_PROCESS_EVENT_CONTINUE, NULL);       \
-    OC_PROCESS_WAIT_EVENT_UNTIL(ev == OC_PROCESS_EVENT_CONTINUE);              \
-  } while (0)
-
-/** @} end of protothread functions */
-
-/**
- * \name Poll and exit handlers
- * @{
- */
-/**
- * Specify an action when a process is polled.
- *
- * \note This declaration must come immediately before the
- * OC_PROCESS_BEGIN() macro.
- *
- * \param handler The action to be performed.
- *
- * \hideinitializer
- */
-#define OC_PROCESS_POLLHANDLER(handler)                                        \
-  if (ev == OC_PROCESS_EVENT_POLL) {                                           \
-    handler;                                                                   \
-  }
-
-/**
- * Specify an action when a process exits.
- *
- * \note This declaration must come immediately before the
- * OC_PROCESS_BEGIN() macro.
- *
- * \param handler The action to be performed.
- *
- * \hideinitializer
- */
-#define OC_PROCESS_EXITHANDLER(handler)                                        \
-  if (ev == OC_PROCESS_EVENT_EXIT) {                                           \
-    handler;                                                                   \
-  }
-
-/** @} */
-
-/**
- * \name Process declaration and definition
- * @{
- */
-
-/**
- * Define the body of a process.
- *
- * This macro is used to define the body (protothread) of a
- * process. The process is called whenever an event occurs in the
- * system, A process always start with the OC_PROCESS_BEGIN() macro and
- * end with the OC_PROCESS_END() macro.
- *
- * \hideinitializer
- */
-#define OC_PROCESS_THREAD(name, ev, data)                                      \
-  static PT_THREAD(process_thread_##name(                                      \
-    struct pt *process_pt, oc_process_event_t ev, oc_process_data_t data))
-
-/**
- * Declare the name of a process.
- *
- * This macro is typically used in header files to declare the name of
- * a process that is implemented in the C file.
- *
- * \hideinitializer
- */
-#define OC_PROCESS_NAME(name) extern struct oc_process name
-
-/**
- * Declare a process.
- *
- * This macro declares a process. The process has two names: the
- * variable of the process structure, which is used by the C program,
- * and a human readable string name, which is used when debugging.
- * A configuration option allows removal of the readable name to save RAM.
- *
- * \param name The variable name of the process structure.
- * \param strname The string representation of the process' name.
- *
- * \hideinitializer
- */
-#if OC_PROCESS_CONF_NO_OC_PROCESS_NAMES
-#define OC_PROCESS(name, strname)                                              \
-  OC_PROCESS_THREAD(name, ev, data);                                           \
-  struct oc_process name = { NULL, process_thread_##name }
-#else
-#define OC_PROCESS(name, strname)                                              \
-  OC_PROCESS_THREAD(name, ev, data);                                           \
-  struct oc_process name = { NULL, strname, process_thread_##name }
-#endif
-
-/** @} */
-
-struct oc_process
-{
-  struct oc_process *next;
-#if OC_PROCESS_CONF_NO_OC_PROCESS_NAMES
-#define OC_PROCESS_NAME_STRING(process) ""
-#else
-  const char *name;
-#define OC_PROCESS_NAME_STRING(process) (process)->name
-#endif
-  PT_THREAD((*thread)(struct pt *, oc_process_event_t, oc_process_data_t));
-  struct pt pt;
-  unsigned char state, needspoll;
-};
-
-/**
- * \name Functions called from application programs
- * @{
- */
-
-/**
- * Start a process.
- *
- * \param p A pointer to a process structure.
- *
- * \param data An argument pointer that can be passed to the new
- * process
- *
- */
-void oc_process_start(struct oc_process *p, oc_process_data_t data);
-
-/**
- * Post an asynchronous event.
- *
- * This function posts an asynchronous event to one or more
- * processes. The handing of the event is deferred until the target
- * process is scheduled by the kernel. An event can be broadcast to
- * all processes, in which case all processes in the system will be
- * scheduled to handle the event.
- *
- * \param ev The event to be posted.
- *
- * \param data The auxiliary data to be sent with the event
- *
- * \param p The process to which the event should be posted, or
- * OC_PROCESS_BROADCAST if the event should be posted to all processes.
- *
- * \retval OC_PROCESS_ERR_OK The event could be posted.
- *
- * \retval OC_PROCESS_ERR_FULL The event queue was full and the event could
- * not be posted.
- */
-int oc_process_post(struct oc_process *p, oc_process_event_t ev,
-                    oc_process_data_t data);
-
-/**
- * Post a synchronous event to a process.
- *
- * \param p A pointer to the process' process structure.
- *
- * \param ev The event to be posted.
- *
- * \param data A pointer to additional data that is posted together
- * with the event.
- */
-void oc_process_post_synch(struct oc_process *p, oc_process_event_t ev,
-                           oc_process_data_t data);
-
-/**
- * \brief      Cause a process to exit
- * \param p    The process that is to be exited
- *
- *             This function causes a process to exit. The process can
- *             either be the currently executing process, or another
- *             process that is currently running.
- *
- * \sa OC_PROCESS_CURRENT()
- */
-void oc_process_exit(struct oc_process *p);
-
-/**
- * Get a pointer to the currently running process.
- *
- * This macro get a pointer to the currently running
- * process. Typically, this macro is used to post an event to the
- * current process with process_post().
- *
- * \hideinitializer
- */
-#define OC_PROCESS_CURRENT() oc_process_current
-extern struct oc_process *oc_process_current;
-
-/**
- * Switch context to another process
- *
- * This function switch context to the specified process and executes
- * the code as if run by that process. Typical use of this function is
- * to switch context in services, called by other processes. Each
- * OC_PROCESS_CONTEXT_BEGIN() must be followed by the
- * OC_PROCESS_CONTEXT_END() macro to end the context switch.
- *
- * Example:
- \code
- OC_PROCESS_CONTEXT_BEGIN(&test_process);
- etimer_set(&timer, CLOCK_SECOND);
- OC_PROCESS_CONTEXT_END(&test_process);
- \endcode
- *
- * \param p    The process to use as context
- *
- * \sa OC_PROCESS_CONTEXT_END()
- * \sa OC_PROCESS_CURRENT()
- */
-#define OC_PROCESS_CONTEXT_BEGIN(p)                                            \
-  {                                                                            \
-    struct oc_process *tmp_current = OC_PROCESS_CURRENT();                     \
-  oc_process_current = p
-
-/**
- * End a context switch
- *
- * This function ends a context switch and changes back to the
- * previous process.
- *
- * \param p    The process used in the context switch
- *
- * \sa OC_PROCESS_CONTEXT_START()
- */
-#define OC_PROCESS_CONTEXT_END(p)                                              \
-  oc_process_current = tmp_current;                                            \
-  }
-
-/**
- * \brief      Allocate a global event number.
- * \return     The allocated event number
- *
- *             In Contiki, event numbers above 128 are global and may
- *             be posted from one process to another. This function
- *             allocates one such event number.
- *
- * \note       There currently is no way to deallocate an allocated event
- *             number.
- */
-oc_process_event_t oc_process_alloc_event(void);
-
-/** @} */
-
-/**
- * \name Functions called from device drivers
- * @{
- */
-
-/**
- * Request a process to be polled.
- *
- * This function typically is called from an interrupt handler to
- * cause a process to be polled.
- *
- * \param p A pointer to the process' process structure.
- */
-void oc_process_poll(struct oc_process *p);
-
-/** @} */
-
-/**
- * \name Functions called by the system and boot-up code
- * @{
- */
-
-/**
- * \brief      Initialize the process module.
- *
- *             This function initializes the process module and should
- *             be called by the system boot-up code.
- */
-void oc_process_init(void);
-
-/**
- * Run the system once - call poll handlers and process one event.
- *
- * This function should be called repeatedly from the main() program
- * to actually run the Contiki system. It calls the necessary poll
- * handlers, and processes one event. The function returns the number
- * of events that are waiting in the event queue so that the caller
- * may choose to put the CPU to sleep when there are no pending
- * events.
- *
- * \return The number of events that are currently waiting in the
- * event queue.
- */
-int oc_process_run(void);
-
-/**
- * Check if a process is running.
- *
- * This function checks if a specific process is running.
- *
- * \param p The process.
- * \retval Non-zero if the process is running.
- * \retval Zero if the process is not running.
- */
-int oc_process_is_running(struct oc_process *p);
-
-/**
- *  Number of events waiting to be processed.
- *
- * \return The number of events that are currently waiting to be
- * processed.
- */
-int oc_process_nevents(void);
-
-/** @} */
-
-extern struct oc_process *oc_process_list;
-
-#define OC_PROCESS_LIST() oc_process_list
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* OC_PROCESS_H */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/net/oic/src/util/pt/lc-addrlabels.h
----------------------------------------------------------------------
diff --git a/net/oic/src/util/pt/lc-addrlabels.h b/net/oic/src/util/pt/lc-addrlabels.h
deleted file mode 100644
index 68a043e..0000000
--- a/net/oic/src/util/pt/lc-addrlabels.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2004-2005, 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>
- *
- */
-
-/**
- * \addtogroup lc
- * @{
- */
-
-/**
- * \file
- * Implementation of local continuations based on the "Labels as
- * values" feature of gcc
- * \author
- * Adam Dunkels <ad...@sics.se>
- *
- * This implementation of local continuations is based on a special
- * feature of the GCC C compiler called "labels as values". This
- * feature allows assigning pointers with the address of the code
- * corresponding to a particular C label.
- *
- * For more information, see the GCC documentation:
- * http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
- *
- * Thanks to dividuum for finding the nice local scope label
- * implementation.
- */
-
-#ifndef LC_ADDRLABELS_H_
-#define LC_ADDRLABELS_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** \hideinitializer */
-typedef void *lc_t;
-
-#define LC_INIT(s) s = NULL
-
-#define LC_RESUME(s)                                                           \
-  do {                                                                         \
-    if (s != NULL) {                                                           \
-      goto *s;                                                                 \
-    }                                                                          \
-  } while (0)
-
-#define LC_SET(s)                                                              \
-  do {                                                                         \
-    ({                                                                         \
-      __label__ resume;                                                        \
-    resume:                                                                    \
-      (s) = &&resume;                                                          \
-    });                                                                        \
-  } while (0)
-
-#define LC_END(s)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LC_ADDRLABELS_H_ */
-/** @} */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/net/oic/src/util/pt/lc-switch.h
----------------------------------------------------------------------
diff --git a/net/oic/src/util/pt/lc-switch.h b/net/oic/src/util/pt/lc-switch.h
deleted file mode 100644
index 7521c25..0000000
--- a/net/oic/src/util/pt/lc-switch.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2004-2005, 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>
- *
- */
-
-/**
- * \addtogroup lc
- * @{
- */
-
-/**
- * \file
- * Implementation of local continuations based on switch() statement
- * \author Adam Dunkels <ad...@sics.se>
- *
- * This implementation of local continuations uses the C switch()
- * statement to resume execution of a function somewhere inside the
- * function's body. The implementation is based on the fact that
- * switch() statements are able to jump directly into the bodies of
- * control structures such as if() or while() statements.
- *
- * This implementation borrows heavily from Simon Tatham's coroutines
- * implementation in C:
- * http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
- */
-
-#ifndef LC_SWITCH_H_
-#define LC_SWITCH_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* WARNING! lc implementation using switch() does not work if an
-   LC_SET() is done within another switch() statement! */
-
-/** \hideinitializer */
-typedef unsigned short lc_t;
-
-#define LC_INIT(s) s = 0;
-
-#define LC_RESUME(s)                                                           \
-  switch (s) {                                                                 \
-  case 0:
-
-#define LC_SET(s)                                                              \
-  s = __LINE__;                                                                \
-  case __LINE__:
-
-#define LC_END(s) }
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LC_SWITCH_H_ */
-
-/** @} */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/net/oic/src/util/pt/lc.h
----------------------------------------------------------------------
diff --git a/net/oic/src/util/pt/lc.h b/net/oic/src/util/pt/lc.h
deleted file mode 100644
index 1d2c254..0000000
--- a/net/oic/src/util/pt/lc.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2004-2005, 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>
- *
- */
-
-/**
- * \addtogroup pt
- * @{
- */
-
-/**
- * \defgroup lc Local continuations
- * @{
- *
- * Local continuations form the basis for implementing protothreads. A
- * local continuation can be <i>set</i> in a specific function to
- * capture the state of the function. After a local continuation has
- * been set can be <i>resumed</i> in order to restore the state of the
- * function at the point where the local continuation was set.
- *
- *
- */
-
-/**
- * \file core/sys/lc.h
- * Local continuations
- * \author
- * Adam Dunkels <ad...@sics.se>
- *
- */
-
-#ifdef DOXYGEN
-/**
- * Initialize a local continuation.
- *
- * This operation initializes the local continuation, thereby
- * unsetting any previously set continuation state.
- *
- * \hideinitializer
- */
-#define LC_INIT(lc)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Set a local continuation.
- *
- * The set operation saves the state of the function at the point
- * where the operation is executed. As far as the set operation is
- * concerned, the state of the function does <b>not</b> include the
- * call-stack or local (automatic) variables, but only the program
- * counter and such CPU registers that needs to be saved.
- *
- * \hideinitializer
- */
-#define LC_SET(lc)
-
-/**
- * Resume a local continuation.
- *
- * The resume operation resumes a previously set local continuation, thus
- * restoring the state in which the function was when the local
- * continuation was set. If the local continuation has not been
- * previously set, the resume operation does nothing.
- *
- * \hideinitializer
- */
-#define LC_RESUME(lc)
-
-/**
- * Mark the end of local continuation usage.
- *
- * The end operation signifies that local continuations should not be
- * used any more in the function. This operation is not needed for
- * most implementations of local continuation, but is required by a
- * few implementations.
- *
- * \hideinitializer
- */
-#define LC_END(lc)
-
-/**
- * \var typedef lc_t;
- *
- * The local continuation type.
- *
- * \hideinitializer
- */
-#endif /* DOXYGEN */
-
-#ifndef LC_H_
-#define LC_H_
-
-#ifdef LC_CONF_INCLUDE
-#include LC_CONF_INCLUDE
-#else /* LC_CONF_INCLUDE */
-#include "lc-switch.h"
-#endif /* LC_CONF_INCLUDE */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LC_H_ */
-
-/** @} */
-/** @} */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/net/oic/src/util/pt/pt-sem.h
----------------------------------------------------------------------
diff --git a/net/oic/src/util/pt/pt-sem.h b/net/oic/src/util/pt/pt-sem.h
deleted file mode 100644
index ad87c0d..0000000
--- a/net/oic/src/util/pt/pt-sem.h
+++ /dev/null
@@ -1,241 +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>
- *
- */
-
-/**
- * \addtogroup pt
- * @{
- */
-
-/**
- * \defgroup ptsem Protothread semaphores
- * @{
- *
- * This module implements counting semaphores on top of
- * protothreads. Semaphores are a synchronization primitive that
- * provide two operations: "wait" and "signal". The "wait" operation
- * checks the semaphore counter and blocks the thread if the counter
- * is zero. The "signal" operation increases the semaphore counter but
- * does not block. If another thread has blocked waiting for the
- * semaphore that is signaled, the blocked thread will become
- * runnable again.
- *
- * Semaphores can be used to implement other, more structured,
- * synchronization primitives such as monitors and message
- * queues/bounded buffers (see below).
- *
- * The following example shows how the producer-consumer problem, also
- * known as the bounded buffer problem, can be solved using
- * protothreads and semaphores. Notes on the program follow after the
- * example.
- *
- \code
-#include "pt-sem.h"
-
-#define NUM_ITEMS 32
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define BUFSIZE 8
-
-static struct pt_sem mutex, full, empty;
-
-PT_THREAD(producer(struct pt *pt))
-{
-  static int produced;
-
-  PT_BEGIN(pt);
-
-  for(produced = 0; produced < NUM_ITEMS; ++produced) {
-
-    PT_SEM_WAIT(pt, &full);
-
-    PT_SEM_WAIT(pt, &mutex);
-    add_to_buffer(produce_item());
-    PT_SEM_SIGNAL(pt, &mutex);
-
-    PT_SEM_SIGNAL(pt, &empty);
-  }
-
-  PT_END(pt);
-}
-
-PT_THREAD(consumer(struct pt *pt))
-{
-  static int consumed;
-
-  PT_BEGIN(pt);
-
-  for(consumed = 0; consumed < NUM_ITEMS; ++consumed) {
-
-    PT_SEM_WAIT(pt, &empty);
-
-    PT_SEM_WAIT(pt, &mutex);
-    consume_item(get_from_buffer());
-    PT_SEM_SIGNAL(pt, &mutex);
-
-    PT_SEM_SIGNAL(pt, &full);
-  }
-
-  PT_END(pt);
-}
-
-PT_THREAD(driver_thread(struct pt *pt))
-{
-  static struct pt pt_producer, pt_consumer;
-
-  PT_BEGIN(pt);
-
-  PT_SEM_INIT(&empty, 0);
-  PT_SEM_INIT(&full, BUFSIZE);
-  PT_SEM_INIT(&mutex, 1);
-
-  PT_INIT(&pt_producer);
-  PT_INIT(&pt_consumer);
-
-  PT_WAIT_THREAD(pt, producer(&pt_producer) &
-         consumer(&pt_consumer));
-
-  PT_END(pt);
-}
- \endcode
- *
- * The program uses three protothreads: one protothread that
- * implements the consumer, one thread that implements the producer,
- * and one protothread that drives the two other protothreads. The
- * program uses three semaphores: "full", "empty" and "mutex". The
- * "mutex" semaphore is used to provide mutual exclusion for the
- * buffer, the "empty" semaphore is used to block the consumer is the
- * buffer is empty, and the "full" semaphore is used to block the
- * producer is the buffer is full.
- *
- * The "driver_thread" holds two protothread state variables,
- * "pt_producer" and "pt_consumer". It is important to note that both
- * these variables are declared as <i>static</i>. If the static
- * keyword is not used, both variables are stored on the stack. Since
- * protothreads do not store the stack, these variables may be
- * overwritten during a protothread wait operation. Similarly, both
- * the "consumer" and "producer" protothreads declare their local
- * variables as static, to avoid them being stored on the stack.
- *
- *
- */
-
-/**
- * \file
- * Counting semaphores implemented on protothreads
- * \author
- * Adam Dunkels <ad...@sics.se>
- *
- */
-
-#ifndef PT_SEM_H_
-#define PT_SEM_H_
-
-#include "pt.h"
-
-struct pt_sem
-{
-  unsigned int head, tail;
-};
-
-#define PT_SEM_COUNT(s) ((s)->head - (s)->tail)
-
-/**
- * Initialize a semaphore
- *
- * This macro initializes a semaphore with a value for the
- * counter. Internally, the semaphores use an "unsigned int" to
- * represent the counter, and therefore the "count" argument should be
- * within range of an unsigned int.
- *
- * \param s (struct pt_sem *) A pointer to the pt_sem struct
- * representing the semaphore
- *
- * \param c (unsigned int) The initial count of the semaphore.
- * \hideinitializer
- */
-#define PT_SEM_INIT(s, c)                                                      \
-  do {                                                                         \
-    (s)->tail = 0;                                                             \
-    (s)->head = (c);                                                           \
-  } while (0)
-
-/**
- * Wait for a semaphore
- *
- * This macro carries out the "wait" operation on the semaphore. The
- * wait operation causes the protothread to block while the counter is
- * zero. When the counter reaches a value larger than zero, the
- * protothread will continue.
- *
- * \param pt (struct pt *) A pointer to the protothread (struct pt) in
- * which the operation is executed.
- *
- * \param s (struct pt_sem *) A pointer to the pt_sem struct
- * representing the semaphore
- *
- * \hideinitializer
- */
-#define PT_SEM_WAIT(pt, s)                                                     \
-  do {                                                                         \
-    PT_WAIT_UNTIL(pt, PT_SEM_COUNT(s) > 0);                                    \
-    ++(s)->tail;                                                               \
-  } while (0)
-
-/**
- * Signal a semaphore
- *
- * This macro carries out the "signal" operation on the semaphore. The
- * signal operation increments the counter inside the semaphore, which
- * eventually will cause waiting protothreads to continue executing.
- *
- * \param pt (struct pt *) A pointer to the protothread (struct pt) in
- * which the operation is executed.
- *
- * \param s (struct pt_sem *) A pointer to the pt_sem struct
- * representing the semaphore
- *
- * \hideinitializer
- */
-#define PT_SEM_SIGNAL(pt, s) (++(s)->head)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* PT_SEM_H_ */
-
-/** @} */
-/** @} */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa41bf8/net/oic/src/util/pt/pt.h
----------------------------------------------------------------------
diff --git a/net/oic/src/util/pt/pt.h b/net/oic/src/util/pt/pt.h
deleted file mode 100644
index 43d1ab7..0000000
--- a/net/oic/src/util/pt/pt.h
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright (c) 2004-2005, 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>
- *
- */
-
-/**
- * \addtogroup pt
- * @{
- */
-
-/**
- * \file
- * Protothreads implementation.
- * \author
- * Adam Dunkels <ad...@sics.se>
- *
- */
-
-#ifndef PT_H_
-#define PT_H_
-
-#include "lc.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct pt
-{
-  lc_t lc;
-};
-
-#define PT_WAITING 0
-#define PT_YIELDED 1
-#define PT_EXITED 2
-#define PT_ENDED 3
-
-/**
- * \name Initialization
- * @{
- */
-
-/**
- * Initialize a protothread.
- *
- * Initializes a protothread. Initialization must be done prior to
- * starting to execute the protothread.
- *
- * \param pt A pointer to the protothread control structure.
- *
- * \sa PT_SPAWN()
- *
- * \hideinitializer
- */
-#define PT_INIT(pt) LC_INIT((pt)->lc)
-
-/** @} */
-
-/**
- * \name Declaration and definition
- * @{
- */
-
-/**
- * Declaration of a protothread.
- *
- * This macro is used to declare a protothread. All protothreads must
- * be declared with this macro.
- *
- * \param name_args The name and arguments of the C function
- * implementing the protothread.
- *
- * \hideinitializer
- */
-#define PT_THREAD(name_args) char name_args
-
-/**
- * Declare the start of a protothread inside the C function
- * implementing the protothread.
- *
- * This macro is used to declare the starting point of a
- * protothread. It should be placed at the start of the function in
- * which the protothread runs. All C statements above the PT_BEGIN()
- * invokation will be executed each time the protothread is scheduled.
- *
- * \param pt A pointer to the protothread control structure.
- *
- * \hideinitializer
- */
-#define PT_BEGIN(pt)                                                           \
-  {                                                                            \
-    char PT_YIELD_FLAG = 1;                                                    \
-    if (PT_YIELD_FLAG) {                                                       \
-      ;                                                                        \
-    }                                                                          \
-  LC_RESUME((pt)->lc)
-
-/**
- * Declare the end of a protothread.
- *
- * This macro is used for declaring that a protothread ends. It must
- * always be used together with a matching PT_BEGIN() macro.
- *
- * \param pt A pointer to the protothread control structure.
- *
- * \hideinitializer
- */
-#define PT_END(pt)                                                             \
-  LC_END((pt)->lc);                                                            \
-  PT_YIELD_FLAG = 0;                                                           \
-  PT_INIT(pt);                                                                 \
-  return PT_ENDED;                                                             \
-  }
-
-/** @} */
-
-/**
- * \name Blocked wait
- * @{
- */
-
-/**
- * Block and wait until condition is true.
- *
- * This macro blocks the protothread until the specified condition is
- * true.
- *
- * \param pt A pointer to the protothread control structure.
- * \param condition The condition.
- *
- * \hideinitializer
- */
-#define PT_WAIT_UNTIL(pt, condition)                                           \
-  do {                                                                         \
-    LC_SET((pt)->lc);                                                          \
-    if (!(condition)) {                                                        \
-      return PT_WAITING;                                                       \
-    }                                                                          \
-  } while (0)
-
-/**
- * Block and wait while condition is true.
- *
- * This function blocks and waits while condition is true. See
- * PT_WAIT_UNTIL().
- *
- * \param pt A pointer to the protothread control structure.
- * \param cond The condition.
- *
- * \hideinitializer
- */
-#define PT_WAIT_WHILE(pt, cond) PT_WAIT_UNTIL((pt), !(cond))
-
-/** @} */
-
-/**
- * \name Hierarchical protothreads
- * @{
- */
-
-/**
- * Block and wait until a child protothread completes.
- *
- * This macro schedules a child protothread. The current protothread
- * will block until the child protothread completes.
- *
- * \note The child protothread must be manually initialized with the
- * PT_INIT() function before this function is used.
- *
- * \param pt A pointer to the protothread control structure.
- * \param thread The child protothread with arguments
- *
- * \sa PT_SPAWN()
- *
- * \hideinitializer
- */
-#define PT_WAIT_THREAD(pt, thread) PT_WAIT_WHILE((pt), PT_SCHEDULE(thread))
-
-/**
- * Spawn a child protothread and wait until it exits.
- *
- * This macro spawns a child protothread and waits until it exits. The
- * macro can only be used within a protothread.
- *
- * \param pt A pointer to the protothread control structure.
- * \param child A pointer to the child protothread's control structure.
- * \param thread The child protothread with arguments
- *
- * \hideinitializer
- */
-#define PT_SPAWN(pt, child, thread)                                            \
-  do {                                                                         \
-    PT_INIT((child));                                                          \
-    PT_WAIT_THREAD((pt), (thread));                                            \
-  } while (0)
-
-/** @} */
-
-/**
- * \name Exiting and restarting
- * @{
- */
-
-/**
- * Restart the protothread.
- *
- * This macro will block and cause the running protothread to restart
- * its execution at the place of the PT_BEGIN() call.
- *
- * \param pt A pointer to the protothread control structure.
- *
- * \hideinitializer
- */
-#define PT_RESTART(pt)                                                         \
-  do {                                                                         \
-    PT_INIT(pt);                                                               \
-    return PT_WAITING;                                                         \
-  } while (0)
-
-/**
- * Exit the protothread.
- *
- * This macro causes the protothread to exit. If the protothread was
- * spawned by another protothread, the parent protothread will become
- * unblocked and can continue to run.
- *
- * \param pt A pointer to the protothread control structure.
- *
- * \hideinitializer
- */
-#define PT_EXIT(pt)                                                            \
-  do {                                                                         \
-    PT_INIT(pt);                                                               \
-    return PT_EXITED;                                                          \
-  } while (0)
-
-/** @} */
-
-/**
- * \name Calling a protothread
- * @{
- */
-
-/**
- * Schedule a protothread.
- *
- * This function schedules a protothread. The return value of the
- * function is non-zero if the protothread is running or zero if the
- * protothread has exited.
- *
- * \param f The call to the C function implementing the protothread to
- * be scheduled
- *
- * \hideinitializer
- */
-#define PT_SCHEDULE(f) ((f) < PT_EXITED)
-
-/** @} */
-
-/**
- * \name Yielding from a protothread
- * @{
- */
-
-/**
- * Yield from the current protothread.
- *
- * This function will yield the protothread, thereby allowing other
- * processing to take place in the system.
- *
- * \param pt A pointer to the protothread control structure.
- *
- * \hideinitializer
- */
-#define PT_YIELD(pt)                                                           \
-  do {                                                                         \
-    PT_YIELD_FLAG = 0;                                                         \
-    LC_SET((pt)->lc);                                                          \
-    if (PT_YIELD_FLAG == 0) {                                                  \
-      return PT_YIELDED;                                                       \
-    }                                                                          \
-  } while (0)
-
-/**
- * \brief      Yield from the protothread until a condition occurs.
- * \param pt   A pointer to the protothread control structure.
- * \param cond The condition.
- *
- *             This function will yield the protothread, until the
- *             specified condition evaluates to true.
- *
- *
- * \hideinitializer
- */
-#define PT_YIELD_UNTIL(pt, cond)                                               \
-  do {                                                                         \
-    PT_YIELD_FLAG = 0;                                                         \
-    LC_SET((pt)->lc);                                                          \
-    if ((PT_YIELD_FLAG == 0) || !(cond)) {                                     \
-      return PT_YIELDED;                                                       \
-    }                                                                          \
-  } while (0)
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* PT_H_ */
-
-/** @} */