diff mbox

Update ODP_ERR to call abort

Message ID 1411400116-33778-1-git-send-email-mike.holmes@linaro.org
State Rejected
Headers show

Commit Message

Mike Holmes Sept. 22, 2014, 3:35 p.m. UTC
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 platform/linux-generic/include/api/odp_debug.h | 7 +++++--
 platform/linux-generic/odp_buffer_pool.c       | 5 -----
 platform/linux-generic/odp_time.c              | 1 -
 3 files changed, 5 insertions(+), 8 deletions(-)

Comments

Balasubramanian Manoharan Sept. 22, 2014, 3:54 p.m. UTC | #1
Hi Mike,

I would not prefer LOG functions to call abort() on behalf of the
application, this design prevents the applications from calling its
specific clean-up code. coz applications can be written in a way in which
clean-up can be done in a single place at the end of the main function
combining all the lock-release and clean-up for different calls.

Is there any specific requirement for this design?

Regards,
Bala
Steve McIntyre Sept. 22, 2014, 4:11 p.m. UTC | #2
On Mon, Sep 22, 2014 at 08:54:30AM -0700, Bala Manoharan wrote:
>Hi Mike,
>
>I would not prefer LOG functions to call abort() on behalf of the application,
>this design prevents the applications from calling its specific clean-up code.
>coz applications can be written in a way in which clean-up can be done in a
>single place at the end of the main function combining all the lock-release and
>clean-up for different calls.

I'd agree with that myself, yes, but Mike's just cleaning up existing
code which calls LOG_ERR() then exit() in a number of cases as far as
I can see. I'm a very stong believer in libraries *not* causing a
process to exit.

Cheers,
Mike Holmes Sept. 22, 2014, 4:14 p.m. UTC | #3
On 22 September 2014 11:54, Bala Manoharan <bala.manoharan@linaro.org>
wrote:

> Hi Mike,
>
> I would not prefer LOG functions to call abort() on behalf of the
> application,
>
Np, If we want a new name that is fine, I wondered how many ODP_ERRs would
be seriously considered ERR or a FATAL
The purpose is to ensure there is no need of calls to exit in the
implementations, so any ideas on a good name? From the above possibly
ODP_FATAL?
We also then need to update
http://docs.opendataplane.org/arch/html/exception_handling.html  to make it
clearer.

this design prevents the applications from calling its specific clean-up
> code. coz applications can be written in a way in which clean-up can be
> done in a single place at the end of the main function combining all the
> lock-release and clean-up for different calls.
>
> Is there any specific requirement for this design?
>
> Regards,
> Bala
>
Balasubramanian Manoharan Sept. 22, 2014, 4:42 p.m. UTC | #4
Yes. I would prefer ODP_ABORT("message") this call can be used by the
application so that there is no need to provide two separate calls for
ODP_ERR and abort().


Regards,
Bala

On 22 September 2014 09:14, Mike Holmes <mike.holmes@linaro.org> wrote:

>
>
> On 22 September 2014 11:54, Bala Manoharan <bala.manoharan@linaro.org>
> wrote:
>
>> Hi Mike,
>>
>> I would not prefer LOG functions to call abort() on behalf of the
>> application,
>>
> Np, If we want a new name that is fine, I wondered how many ODP_ERRs would
> be seriously considered ERR or a FATAL
> The purpose is to ensure there is no need of calls to exit in the
> implementations, so any ideas on a good name? From the above possibly
> ODP_FATAL?
> We also then need to update
> http://docs.opendataplane.org/arch/html/exception_handling.html  to make
> it clearer.
>
> this design prevents the applications from calling its specific clean-up
>> code. coz applications can be written in a way in which clean-up can be
>> done in a single place at the end of the main function combining all the
>> lock-release and clean-up for different calls.
>>
>> Is there any specific requirement for this design?
>>
>> Regards,
>> Bala
>>
>
>
>
> --
> *Mike Holmes*
> Linaro Technical Manager / Lead
> LNG - ODP
>
diff mbox

Patch

diff --git a/platform/linux-generic/include/api/odp_debug.h b/platform/linux-generic/include/api/odp_debug.h
index e8f6003..692a6b2 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,10 @@  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__); \
+	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..b88cf88 100644
--- a/platform/linux-generic/odp_buffer_pool.c
+++ b/platform/linux-generic/odp_buffer_pool.c
@@ -100,7 +100,6 @@  static inline void set_handle(odp_buffer_hdr_t *hdr,
 
 	if (pool_id >= ODP_CONFIG_BUFFER_POOLS) {
 		ODP_ERR("set_handle: Bad pool handle %u\n", pool_hdl);
-		exit(0);
 	}
 
 	if (index > ODP_BUFFER_MAX_INDEX)
@@ -220,13 +219,11 @@  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);
 	}
 
 	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);
 	}
 }
 
@@ -265,7 +262,6 @@  static void fill_hdr(void *ptr, pool_entry_t *pool, uint32_t index,
 		break;
 	default:
 		ODP_ERR("Bad buffer type\n");
-		exit(0);
 	}
 
 	memset(hdr, 0, size);
@@ -313,7 +309,6 @@  static void link_bufs(pool_entry_t *pool)
 		hdr_size = sizeof(odp_any_buffer_hdr_t);
 	} else {
 		ODP_ERR("odp_buffer_pool_create: Bad type %i\n", buf_type);
-		exit(0);
 	}
 
 	/* Chunk must fit into buffer data area.*/
diff --git a/platform/linux-generic/odp_time.c b/platform/linux-generic/odp_time.c
index 181294a..b4b8650 100644
--- a/platform/linux-generic/odp_time.c
+++ b/platform/linux-generic/odp_time.c
@@ -60,7 +60,6 @@  uint64_t odp_time_get_cycles(void)
 
 	if (ret != 0) {
 		ODP_ERR("clock_gettime failed\n");
-		exit(EXIT_FAILURE);
 	}
 
 	hz  = odp_sys_cpu_hz();