You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/11/21 11:36:55 UTC

[GitHub] mkiiskila closed pull request #1527: LwIP mbox api additions

mkiiskila closed pull request #1527: LwIP mbox api additions 
URL: https://github.com/apache/mynewt-core/pull/1527
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/net/ip/include/arch/sys_arch.h b/net/ip/include/arch/sys_arch.h
index d598b939c6..691598241d 100644
--- a/net/ip/include/arch/sys_arch.h
+++ b/net/ip/include/arch/sys_arch.h
@@ -29,9 +29,6 @@ extern "C" {
 #include "os/mynewt.h"
 #include <ip/os_queue.h>
 
-#define SYS_MBOX_NULL NULL
-#define SYS_SEM_NULL  NULL
-
 struct os_queue;
 
 typedef struct os_sem sys_sem_t;
@@ -131,6 +128,24 @@ sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
     return ERR_OK;
 }
 
+static inline void
+sys_mbox_free(sys_mbox_t *mbox)
+{
+    os_queue_free(mbox);
+}
+
+static inline int
+sys_mbox_valid(sys_mbox_t *mbox)
+{
+    return mbox->oq_q != NULL;
+}
+
+static inline void
+sys_mbox_set_invalid(sys_mbox_t *mbox)
+{
+    sys_mbox_free(mbox);
+}
+
 static inline sys_thread_t
 sys_thread_new(const char *name, void (*thread)(void *arg), void *arg,
   int stacksize, int prio)
diff --git a/net/ip/include/ip/os_queue.h b/net/ip/include/ip/os_queue.h
index e689d78924..9a0fbee3ea 100644
--- a/net/ip/include/ip/os_queue.h
+++ b/net/ip/include/ip/os_queue.h
@@ -36,6 +36,7 @@ struct os_queue {
 int os_queue_init(struct os_queue *, uint8_t elem_size, uint8_t elem_cnt);
 int os_queue_put(struct os_queue *, void *elem, uint32_t timeout);
 int os_queue_get(struct os_queue *, void *elem, uint32_t timeout);
+void os_queue_free(struct os_queue *);
 
 #ifdef __cplusplus
 }
diff --git a/net/ip/lwip_base/include/lwip/stats.h b/net/ip/lwip_base/include/lwip/stats.h
index 5cde4a094c..2e699e9367 100644
--- a/net/ip/lwip_base/include/lwip/stats.h
+++ b/net/ip/lwip_base/include/lwip/stats.h
@@ -304,7 +304,7 @@ struct stats_ {
 extern struct stats_ lwip_stats;
 
 /** Init statistics */
-void stats_init(void);
+void lwip_stats_init(void);
 
 #define STATS_INC(x) ++lwip_stats.x
 #define STATS_DEC(x) --lwip_stats.x
@@ -315,7 +315,7 @@ void stats_init(void);
                              } while(0)
 #define STATS_GET(x) lwip_stats.x
 #else /* LWIP_STATS */
-#define stats_init()
+#define lwip_stats_init()
 #define STATS_INC(x)
 #define STATS_DEC(x)
 #define STATS_INC_USED(x)
diff --git a/net/ip/lwip_base/src/core/init.c b/net/ip/lwip_base/src/core/init.c
index ea3b5ebebf..5c1201f83f 100644
--- a/net/ip/lwip_base/src/core/init.c
+++ b/net/ip/lwip_base/src/core/init.c
@@ -346,7 +346,7 @@ lwip_init(void)
 #endif
 
   /* Modules initialization */
-  stats_init();
+  lwip_stats_init();
 #if !NO_SYS
   sys_init();
 #endif /* !NO_SYS */
diff --git a/net/ip/lwip_base/src/core/stats.c b/net/ip/lwip_base/src/core/stats.c
index 893d199c04..f66fefac87 100644
--- a/net/ip/lwip_base/src/core/stats.c
+++ b/net/ip/lwip_base/src/core/stats.c
@@ -50,7 +50,7 @@
 struct stats_ lwip_stats;
 
 void
-stats_init(void)
+lwip_stats_init(void)
 {
 #ifdef LWIP_DEBUG
 #if MEM_STATS
diff --git a/net/ip/src/os_queue.c b/net/ip/src/os_queue.c
index f7d0b467a4..34bec07ad8 100644
--- a/net/ip/src/os_queue.c
+++ b/net/ip/src/os_queue.c
@@ -32,7 +32,9 @@ int
 os_queue_init(struct os_queue *q, uint8_t elem_size, uint8_t elem_cnt)
 {
     assert(elem_cnt < SHRT_MAX);
-
+    if (elem_cnt == 0) {
+        elem_cnt = 1;
+    }
     q->oq_q = malloc(elem_size * elem_cnt);
     if (!q->oq_q) {
         return -1;
@@ -45,6 +47,14 @@ os_queue_init(struct os_queue *q, uint8_t elem_size, uint8_t elem_cnt)
     return 0;
 }
 
+void
+os_queue_free(struct os_queue *q)
+{
+    free(q->oq_q);
+    q->oq_q = NULL;
+    q->oq_size = 0;
+}
+
 int
 os_queue_put(struct os_queue *q, void *elem, uint32_t timeout)
 {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services