mirror of
https://github.com/espressif/esp-idf.git
synced 2024-09-20 00:36:01 -04:00
Merge branch 'bugfix/newlib_header_additional_defines' into 'master'
newlib: fix possible redefinition of likely/unlikely macros Closes IDFGH-4631 See merge request espressif/esp-idf!12370
This commit is contained in:
commit
8c799e6469
@ -23,12 +23,20 @@
|
|||||||
* code.
|
* code.
|
||||||
*/
|
*/
|
||||||
#if (CONFIG_COMPILER_OPTIMIZATION_PERF)
|
#if (CONFIG_COMPILER_OPTIMIZATION_PERF)
|
||||||
|
#ifndef likely
|
||||||
#define likely(x) __builtin_expect(!!(x), 1)
|
#define likely(x) __builtin_expect(!!(x), 1)
|
||||||
|
#endif
|
||||||
|
#ifndef unlikely
|
||||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
|
#ifndef likely
|
||||||
#define likely(x) (x)
|
#define likely(x) (x)
|
||||||
|
#endif
|
||||||
|
#ifndef unlikely
|
||||||
#define unlikely(x) (x)
|
#define unlikely(x) (x)
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Utility macros used for designated initializers, which work differently
|
* Utility macros used for designated initializers, which work differently
|
||||||
|
@ -19,23 +19,28 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <sdkconfig.h>
|
#include <sdkconfig.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "esp_compiler.h"
|
|
||||||
|
|
||||||
#include_next <assert.h>
|
#include_next <assert.h>
|
||||||
|
|
||||||
#if defined(CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT) && !defined(NDEBUG)
|
/* moved part of libc provided assert to here allows
|
||||||
#undef assert
|
* tweaking the assert macro to use __builtin_expect()
|
||||||
#define assert(__e) (likely(__e)) ? (void)0 : abort()
|
* and reduce jumps in the "asserts OK" code path
|
||||||
#else
|
*
|
||||||
/* moved part of toolchain provided assert to there then
|
* Note: using __builtin_expect() not likely() to avoid defining the likely
|
||||||
* we can tweak the original assert macro to perform likely
|
* macro in namespace of non-IDF code that may include this standard header.
|
||||||
* before deliver it to original toolchain implementation
|
*/
|
||||||
*/
|
#undef assert
|
||||||
#undef assert
|
|
||||||
#ifdef NDEBUG
|
#if defined(NDEBUG)
|
||||||
# define assert(__e) ((void)0)
|
|
||||||
#else
|
# define assert(__e) ((void)0)
|
||||||
# define assert(__e) (likely(__e) ? (void)0 : __assert_func (__FILE__, __LINE__, \
|
|
||||||
__ASSERT_FUNC, #__e))
|
#elif CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT
|
||||||
#endif
|
|
||||||
|
#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
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user