mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
newlib: Avoid introducing ESP-IDF macros from newlib platform headers
Also, rewrite the assert.h header to be clearer Closes https://github.com/espressif/esp-idf/issues/6445
This commit is contained in:
parent
31e565c3d5
commit
7778779489
@ -19,23 +19,28 @@
|
||||
#pragma once
|
||||
#include <sdkconfig.h>
|
||||
#include <stdlib.h>
|
||||
#include "esp_compiler.h"
|
||||
|
||||
#include_next <assert.h>
|
||||
|
||||
#if defined(CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT) && !defined(NDEBUG)
|
||||
#undef assert
|
||||
#define assert(__e) (likely(__e)) ? (void)0 : abort()
|
||||
#else
|
||||
/* moved part of toolchain provided assert to there then
|
||||
* we can tweak the original assert macro to perform likely
|
||||
* before deliver it to original toolchain implementation
|
||||
*/
|
||||
#undef assert
|
||||
#ifdef NDEBUG
|
||||
# define assert(__e) ((void)0)
|
||||
#else
|
||||
# define assert(__e) (likely(__e) ? (void)0 : __assert_func (__FILE__, __LINE__, \
|
||||
__ASSERT_FUNC, #__e))
|
||||
#endif
|
||||
/* moved part of libc provided assert to here allows
|
||||
* tweaking the assert macro to use __builtin_expect()
|
||||
* and reduce jumps in the "asserts OK" code path
|
||||
*
|
||||
* Note: using __builtin_expect() not likely() to avoid defining the likely
|
||||
* macro in namespace of non-IDF code that may include this standard header.
|
||||
*/
|
||||
#undef assert
|
||||
|
||||
#if defined(NDEBUG)
|
||||
|
||||
# define assert(__e) ((void)0)
|
||||
|
||||
#elif CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT
|
||||
|
||||
#define assert(__e) __builtin_expect(!!(__e), 1) ? (void)0 : abort()
|
||||
|
||||
#else // !CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT
|
||||
|
||||
#define assert(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __assert_func (__FILE__, __LINE__, \
|
||||
__ASSERT_FUNC, #__e))
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user