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/05/24 16:02:41 UTC
[GitHub] andrzej-kaczmarek closed pull request #113: porting: Fix multiple
build errors on non-Mynewt builds
andrzej-kaczmarek closed pull request #113: porting: Fix multiple build errors on non-Mynewt builds
URL: https://github.com/apache/mynewt-nimble/pull/113
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/nimble/controller/src/ble_ll.c b/nimble/controller/src/ble_ll.c
index d1d2a2c7..b0d80fff 100644
--- a/nimble/controller/src/ble_ll.c
+++ b/nimble/controller/src/ble_ll.c
@@ -43,7 +43,7 @@
#include "ble_ll_conn_priv.h"
#if MYNEWT_VAL(BLE_LL_DIRECT_TEST_MODE) == 1
-#include <ble_ll_dtm_priv.h>
+#include "ble_ll_dtm_priv.h"
#endif
/* XXX:
diff --git a/nimble/controller/src/ble_ll_adv.c b/nimble/controller/src/ble_ll_adv.c
index 3fa0c770..4654cb26 100644
--- a/nimble/controller/src/ble_ll_adv.c
+++ b/nimble/controller/src/ble_ll_adv.c
@@ -17,6 +17,7 @@
* under the License.
*/
#include <stdint.h>
+#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "syscfg/syscfg.h"
diff --git a/nimble/controller/src/ble_ll_hci.c b/nimble/controller/src/ble_ll_hci.c
index 91ceb228..aa0eb32e 100644
--- a/nimble/controller/src/ble_ll_hci.c
+++ b/nimble/controller/src/ble_ll_hci.c
@@ -35,7 +35,7 @@
#include "ble_ll_conn_priv.h"
#if MYNEWT_VAL(BLE_LL_DIRECT_TEST_MODE) == 1
-#include <ble_ll_dtm_priv.h>
+#include "ble_ll_dtm_priv.h"
#endif
static void ble_ll_hci_cmd_proc(struct ble_npl_event *ev);
diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index 7ab32639..cb75e878 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -3528,7 +3528,7 @@ ble_gap_ext_connect(uint8_t own_addr_type, const ble_addr_t *peer_addr,
return BLE_HS_ENOTSUP;
#endif
- uint32_t duration_ticks;
+ ble_npl_time_t duration_ticks;
int rc;
STATS_INC(ble_gap_stats, initiate);
@@ -3584,7 +3584,7 @@ ble_gap_ext_connect(uint8_t own_addr_type, const ble_addr_t *peer_addr,
}
if (duration_ms != BLE_HS_FOREVER) {
- rc = os_time_ms_to_ticks(duration_ms, &duration_ticks);
+ rc = ble_npl_time_ms_to_ticks(duration_ms, &duration_ticks);
if (rc != 0) {
/* Duration too great. */
rc = BLE_HS_EINVAL;
diff --git a/nimble/host/src/ble_hs.c b/nimble/host/src/ble_hs.c
index 62b7e485..c4ffd949 100644
--- a/nimble/host/src/ble_hs.c
+++ b/nimble/host/src/ble_hs.c
@@ -117,14 +117,18 @@ ble_hs_evq_set(struct ble_npl_eventq *evq)
int
ble_hs_locked_by_cur_task(void)
{
+#if MYNEWT
struct os_task *owner;
- if (!os_started()) {
+ if (!ble_npl_os_started()) {
return ble_hs_dbg_mutex_locked;
}
owner = ble_hs_mutex.mu.mu_owner;
return owner != NULL && owner == os_sched_get_current_task();
+#else
+ return 1;
+#endif
}
#endif
@@ -147,7 +151,7 @@ ble_hs_lock_nested(void)
int rc;
#if MYNEWT_VAL(BLE_HS_DEBUG)
- if (!os_started()) {
+ if (!ble_npl_os_started()) {
ble_hs_dbg_mutex_locked = 1;
return;
}
@@ -166,7 +170,7 @@ ble_hs_unlock_nested(void)
int rc;
#if MYNEWT_VAL(BLE_HS_DEBUG)
- if (!os_started()) {
+ if (!ble_npl_os_started()) {
ble_hs_dbg_mutex_locked = 0;
return;
}
@@ -184,7 +188,7 @@ ble_hs_lock(void)
{
BLE_HS_DBG_ASSERT(!ble_hs_locked_by_cur_task());
#if MYNEWT_VAL(BLE_HS_DEBUG)
- if (!os_started()) {
+ if (!ble_npl_os_started()) {
BLE_HS_DBG_ASSERT(!ble_hs_dbg_mutex_locked);
}
#endif
@@ -199,7 +203,7 @@ void
ble_hs_unlock(void)
{
#if MYNEWT_VAL(BLE_HS_DEBUG)
- if (!os_started()) {
+ if (!ble_npl_os_started()) {
BLE_HS_DBG_ASSERT(ble_hs_dbg_mutex_locked);
}
#endif
@@ -517,7 +521,7 @@ void
ble_hs_notifications_sched(void)
{
#if !MYNEWT_VAL(BLE_HS_REQUIRE_OS)
- if (!os_started()) {
+ if (!ble_npl_os_started()) {
ble_gatts_tx_notifications();
return;
}
diff --git a/nimble/host/src/ble_hs_flow.c b/nimble/host/src/ble_hs_flow.c
index ca93389e..c0f9f509 100644
--- a/nimble/host/src/ble_hs_flow.c
+++ b/nimble/host/src/ble_hs_flow.c
@@ -24,7 +24,7 @@
#if MYNEWT_VAL(BLE_HS_FLOW_CTRL)
#define BLE_HS_FLOW_ITVL_TICKS \
- (MYNEWT_VAL(BLE_HS_FLOW_CTRL_ITVL) * OS_TICKS_PER_SEC / 1000)
+ ble_npl_time_ms_to_ticks32(MYNEWT_VAL(BLE_HS_FLOW_CTRL_ITVL))
/**
* The number of freed buffers since the most-recent
@@ -34,13 +34,11 @@
static uint16_t ble_hs_flow_num_completed_pkts;
/** Periodically sends number-of-completed-packets events. */
-static struct os_callout ble_hs_flow_timer;
+static struct ble_npl_callout ble_hs_flow_timer;
-static os_event_fn ble_hs_flow_event_cb;
+static ble_npl_event_fn ble_hs_flow_event_cb;
-static struct os_event ble_hs_flow_ev = {
- .ev_cb = ble_hs_flow_event_cb,
-};
+static struct ble_npl_event ble_hs_flow_ev;
static int
ble_hs_flow_tx_num_comp_pkts(void)
@@ -84,7 +82,7 @@ ble_hs_flow_tx_num_comp_pkts(void)
rc = ble_hs_hci_cmd_send_buf(
BLE_HCI_OP(BLE_HCI_OGF_CTLR_BASEBAND,
BLE_HCI_OCF_CB_HOST_NUM_COMP_PKTS),
- buf, off);
+ buf, sizeof(buf));
if (rc != 0) {
return rc;
}
@@ -95,7 +93,7 @@ ble_hs_flow_tx_num_comp_pkts(void)
}
static void
-ble_hs_flow_event_cb(struct os_event *ev)
+ble_hs_flow_event_cb(struct ble_npl_event *ev)
{
int rc;
@@ -135,10 +133,10 @@ ble_hs_flow_inc_completed_pkts(struct ble_hs_conn *conn)
*/
num_free = MYNEWT_VAL(BLE_ACL_BUF_COUNT) - ble_hs_flow_num_completed_pkts;
if (num_free <= MYNEWT_VAL(BLE_HS_FLOW_CTRL_THRESH)) {
- os_eventq_put(ble_hs_evq_get(), &ble_hs_flow_ev);
- os_callout_stop(&ble_hs_flow_timer);
+ ble_npl_eventq_put(ble_hs_evq_get(), &ble_hs_flow_ev);
+ ble_npl_callout_stop(&ble_hs_flow_timer);
} else if (ble_hs_flow_num_completed_pkts == 1) {
- rc = os_callout_reset(&ble_hs_flow_timer, BLE_HS_FLOW_ITVL_TICKS);
+ rc = ble_npl_callout_reset(&ble_hs_flow_timer, BLE_HS_FLOW_ITVL_TICKS);
BLE_HS_DBG_ASSERT_EVAL(rc == 0);
}
}
@@ -229,9 +227,11 @@ ble_hs_flow_startup(void)
struct hci_host_buf_size buf_size_cmd;
int rc;
+ ble_npl_event_init(&ble_hs_flow_ev, ble_hs_flow_event_cb, NULL);
+
/* Assume failure. */
ble_hci_trans_set_acl_free_cb(NULL, NULL);
- os_callout_stop(&ble_hs_flow_timer);
+ ble_npl_callout_stop(&ble_hs_flow_timer);
rc = ble_hs_hci_cmd_tx_set_ctlr_to_host_fc(BLE_HCI_CTLR_TO_HOST_FC_ACL);
if (rc != 0) {
@@ -251,8 +251,8 @@ ble_hs_flow_startup(void)
/* Flow control successfully enabled. */
ble_hs_flow_num_completed_pkts = 0;
ble_hci_trans_set_acl_free_cb(ble_hs_flow_acl_free, NULL);
- os_callout_init(&ble_hs_flow_timer, ble_hs_evq_get(),
- ble_hs_flow_event_cb, NULL);
+ ble_npl_callout_init(&ble_hs_flow_timer, ble_hs_evq_get(),
+ ble_hs_flow_event_cb, NULL);
#endif
return 0;
diff --git a/porting/nimble/include/log/log.h b/porting/nimble/include/log/log.h
index 3e3fc8b4..04e59102 100644
--- a/porting/nimble/include/log/log.h
+++ b/porting/nimble/include/log/log.h
@@ -27,6 +27,7 @@ extern "C" {
static inline void
log_dummy(void *log, ...)
{
+ (void)log;
}
#define LOG_DEBUG(_log, _mod, ...) log_dummy(_log, ## __VA_ARGS__)
diff --git a/porting/nimble/include/os/os_mempool.h b/porting/nimble/include/os/os_mempool.h
index db80d4e4..c69fb3da 100644
--- a/porting/nimble/include/os/os_mempool.h
+++ b/porting/nimble/include/os/os_mempool.h
@@ -30,6 +30,7 @@
#include <stdbool.h>
#include "os/os.h"
+#include "os/queue.h"
#ifdef __cplusplus
extern "C" {
@@ -188,6 +189,15 @@ os_error_t os_mempool_init(struct os_mempool *mp, uint16_t blocks,
os_error_t os_mempool_ext_init(struct os_mempool_ext *mpe, uint16_t blocks,
uint32_t block_size, void *membuf, char *name);
+/**
+ * Clears a memory pool.
+ *
+ * @param mp The mempool to clear.
+ *
+ * @return os_error_t
+ */
+os_error_t os_mempool_clear(struct os_mempool *mp);
+
/**
* Performs an integrity check of the specified mempool. This function
* attempts to detect memory corruption in the specified memory pool.
diff --git a/porting/nimble/src/os_mempool.c b/porting/nimble/src/os_mempool.c
index fa223a7a..bce78ef8 100644
--- a/porting/nimble/src/os_mempool.c
+++ b/porting/nimble/src/os_mempool.c
@@ -136,6 +136,45 @@ os_mempool_ext_init(struct os_mempool_ext *mpe, uint16_t blocks,
return 0;
}
+os_error_t
+os_mempool_clear(struct os_mempool *mp)
+{
+ struct os_memblock *block_ptr;
+ int true_block_size;
+ uint8_t *block_addr;
+ uint16_t blocks;
+
+ if (!mp) {
+ return OS_INVALID_PARM;
+ }
+
+ true_block_size = OS_MEM_TRUE_BLOCK_SIZE(mp->mp_block_size);
+
+ /* cleanup the memory pool structure */
+ mp->mp_num_free = mp->mp_num_blocks;
+ mp->mp_min_free = mp->mp_num_blocks;
+ os_mempool_poison((void *)mp->mp_membuf_addr, true_block_size);
+ SLIST_FIRST(mp) = (void *)mp->mp_membuf_addr;
+
+ /* Chain the memory blocks to the free list */
+ block_addr = (uint8_t *)mp->mp_membuf_addr;
+ block_ptr = (struct os_memblock *)block_addr;
+ blocks = mp->mp_num_blocks;
+
+ while (blocks > 1) {
+ block_addr += true_block_size;
+ os_mempool_poison(block_addr, true_block_size);
+ SLIST_NEXT(block_ptr, mb_next) = (struct os_memblock *)block_addr;
+ block_ptr = (struct os_memblock *)block_addr;
+ --blocks;
+ }
+
+ /* Last one in the list should be NULL */
+ SLIST_NEXT(block_ptr, mb_next) = NULL;
+
+ return OS_OK;
+}
+
bool
os_mempool_is_sane(const struct os_mempool *mp)
{
@@ -194,8 +233,6 @@ os_memblock_get(struct os_mempool *mp)
/* Get a free block */
block = SLIST_FIRST(mp);
- os_mempool_poison_check(block, OS_MEMPOOL_TRUE_BLOCK_SIZE(mp));
-
/* Set new free list head */
SLIST_FIRST(mp) = SLIST_NEXT(block, mb_next);
@@ -206,6 +243,10 @@ os_memblock_get(struct os_mempool *mp)
}
}
OS_EXIT_CRITICAL(sr);
+
+ if (block) {
+ os_mempool_poison_check(block, OS_MEMPOOL_TRUE_BLOCK_SIZE(mp));
+ }
}
return (void *)block;
----------------------------------------------------------------
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