Signed-off-by: Mike Holmes <[email protected]>
---
Also cleaned up checkpatch wanrings
platform/linux-generic/include/api/odp_debug.h | 16 +++++++-
platform/linux-generic/odp_buffer_pool.c | 51 ++++++++++++--------------
platform/linux-generic/odp_time.c | 3 +-
3 files changed, 38 insertions(+), 32 deletions(-)
diff --git a/platform/linux-generic/include/api/odp_debug.h
b/platform/linux-generic/include/api/odp_debug.h
index e8f6003..344b0a9 100644
--- a/platform/linux-generic/include/api/odp_debug.h
+++ b/platform/linux-generic/include/api/odp_debug.h
@@ -13,6 +13,7 @@
#define ODP_DEBUG_H_
#include <stdio.h>
+#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
@@ -76,8 +77,19 @@ extern "C" {
* Print output to stderr (file, line and function).
*/
#define ODP_ERR(fmt, ...) \
- fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
- __LINE__, __func__, ##__VA_ARGS__)
+do { fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
+ __LINE__, __func__, ##__VA_ARGS__); \
+} while (0)
+
+/**
+ * Print output to stderr (file, line and function),
+ * then abort.
+ */
+#define ODP_ABORT(fmt, ...) \
+do { fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
+ __LINE__, __func__, ##__VA_ARGS__); \
+ abort(); \
+} while (0)
#ifdef __cplusplus
}
diff --git a/platform/linux-generic/odp_buffer_pool.c
b/platform/linux-generic/odp_buffer_pool.c
index f54a0c4..68d7630 100644
--- a/platform/linux-generic/odp_buffer_pool.c
+++ b/platform/linux-generic/odp_buffer_pool.c
@@ -47,7 +47,7 @@ union buffer_type_any_u {
};
ODP_STATIC_ASSERT((sizeof(union buffer_type_any_u) % 8) == 0,
- "BUFFER_TYPE_ANY_U__SIZE_ERR");
+ "BUFFER_TYPE_ANY_U__SIZE_ERR");
/* Any buffer type header */
typedef struct {
@@ -88,7 +88,7 @@ static inline odp_buffer_pool_t pool_index_to_handle(uint32_t
pool_id)
static inline uint32_t pool_handle_to_index(odp_buffer_pool_t pool_hdl)
{
- return pool_hdl -1;
+ return pool_hdl - 1;
}
@@ -98,10 +98,8 @@ static inline void set_handle(odp_buffer_hdr_t *hdr,
odp_buffer_pool_t pool_hdl = pool->s.pool_hdl;
uint32_t pool_id = pool_handle_to_index(pool_hdl);
- if (pool_id >= ODP_CONFIG_BUFFER_POOLS) {
- ODP_ERR("set_handle: Bad pool handle %u\n", pool_hdl);
- exit(0);
- }
+ if (pool_id >= ODP_CONFIG_BUFFER_POOLS)
+ ODP_ABORT("set_handle: Bad pool handle %u\n", pool_hdl);
if (index > ODP_BUFFER_MAX_INDEX)
ODP_ERR("set_handle: Bad buffer index\n");
@@ -146,7 +144,8 @@ static odp_buffer_hdr_t *index_to_hdr(pool_entry_t *pool,
uint32_t index)
{
odp_buffer_hdr_t *hdr;
- hdr = (odp_buffer_hdr_t *)(pool->s.buf_base + index * pool->s.buf_size);
+ hdr = (odp_buffer_hdr_t *)(pool->s.buf_base + index
+ * pool->s.buf_size);
return hdr;
}
@@ -172,7 +171,7 @@ static uint32_t rem_buf_index(odp_buffer_chunk_hdr_t
*chunk_hdr)
static odp_buffer_chunk_hdr_t *next_chunk(pool_entry_t *pool,
- odp_buffer_chunk_hdr_t *chunk_hdr)
+ odp_buffer_chunk_hdr_t *chunk_hdr)
{
uint32_t index;
@@ -218,15 +217,13 @@ static void add_chunk(pool_entry_t *pool,
odp_buffer_chunk_hdr_t *chunk_hdr)
static void check_align(pool_entry_t *pool, odp_buffer_hdr_t *hdr)
{
if (!ODP_ALIGNED_CHECK_POWER_2(hdr->addr, pool->s.user_align)) {
- ODP_ERR("check_align: user data align error %p, align %zu\n",
- hdr->addr, pool->s.user_align);
- exit(0);
+ ODP_ABORT("check_align: user data align error %p, align %zu\n",
+ hdr->addr, pool->s.user_align);
}
if (!ODP_ALIGNED_CHECK_POWER_2(hdr, ODP_CACHE_LINE_SIZE)) {
- ODP_ERR("check_align: hdr align error %p, align %i\n",
- hdr, ODP_CACHE_LINE_SIZE);
- exit(0);
+ ODP_ABORT("check_align: hdr align error %p, align %i\n",
+ hdr, ODP_CACHE_LINE_SIZE);
}
}
@@ -264,8 +261,7 @@ static void fill_hdr(void *ptr, pool_entry_t *pool,
uint32_t index,
buf_data = any_hdr->buf_data;
break;
default:
- ODP_ERR("Bad buffer type\n");
- exit(0);
+ ODP_ABORT("Bad buffer type\n");
}
memset(hdr, 0, size);
@@ -303,18 +299,17 @@ static void link_bufs(pool_entry_t *pool)
pool_size = pool->s.pool_size;
pool_base = (uintptr_t) pool->s.pool_base_addr;
- if (buf_type == ODP_BUFFER_TYPE_RAW) {
+ if (buf_type == ODP_BUFFER_TYPE_RAW)
hdr_size = sizeof(odp_raw_buffer_hdr_t);
- } else if (buf_type == ODP_BUFFER_TYPE_PACKET) {
+ else if (buf_type == ODP_BUFFER_TYPE_PACKET)
hdr_size = sizeof(odp_packet_hdr_t);
- } else if (buf_type == ODP_BUFFER_TYPE_TIMEOUT) {
+ else if (buf_type == ODP_BUFFER_TYPE_TIMEOUT)
hdr_size = sizeof(odp_timeout_hdr_t);
- } else if (buf_type == ODP_BUFFER_TYPE_ANY) {
+ else if (buf_type == ODP_BUFFER_TYPE_ANY)
hdr_size = sizeof(odp_any_buffer_hdr_t);
- } else {
- ODP_ERR("odp_buffer_pool_create: Bad type %i\n", buf_type);
- exit(0);
- }
+ else
+ ODP_ABORT("odp_buffer_pool_create: Bad type %i\n", buf_type);
+
/* Chunk must fit into buffer data area.*/
min_size = sizeof(odp_buffer_chunk_hdr_t) - hdr_size;
@@ -366,7 +361,7 @@ static void link_bufs(pool_entry_t *pool)
add_chunk(pool, chunk_hdr);
chunk_hdr = (odp_buffer_chunk_hdr_t *)index_to_hdr(pool,
- index);
+ index);
pool->s.num_bufs += ODP_BUFS_PER_CHUNK;
pool_size -= ODP_BUFS_PER_CHUNK * tot_size;
}
@@ -374,9 +369,9 @@ static void link_bufs(pool_entry_t *pool)
odp_buffer_pool_t odp_buffer_pool_create(const char *name,
- void *base_addr, uint64_t size,
- size_t buf_size, size_t buf_align,
- int buf_type)
+ void *base_addr, uint64_t size,
+ size_t buf_size, size_t buf_align,
+ int buf_type)
{
odp_buffer_pool_t pool_hdl = ODP_BUFFER_POOL_INVALID;
pool_entry_t *pool;
diff --git a/platform/linux-generic/odp_time.c
b/platform/linux-generic/odp_time.c
index 181294a..faece0e 100644
--- a/platform/linux-generic/odp_time.c
+++ b/platform/linux-generic/odp_time.c
@@ -59,8 +59,7 @@ uint64_t odp_time_get_cycles(void)
ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time);
if (ret != 0) {
- ODP_ERR("clock_gettime failed\n");
- exit(EXIT_FAILURE);
+ ODP_ABORT("clock_gettime failed\n");
}
hz = odp_sys_cpu_hz();
--
1.9.1
_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp