Replace vera++ with clang-format (#4518)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
This commit is contained in:
@@ -25,8 +25,7 @@
|
||||
* @param width width of the bit-field to be extracted
|
||||
* @return bit-field's value
|
||||
*/
|
||||
#define JRT_EXTRACT_BIT_FIELD(type, container, lsb, width) \
|
||||
(((container) >> lsb) & ((((type) 1) << (width)) - 1))
|
||||
#define JRT_EXTRACT_BIT_FIELD(type, container, lsb, width) (((container) >> lsb) & ((((type) 1) << (width)) - 1))
|
||||
|
||||
/**
|
||||
* Set a bit-field.
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* Implementation of exit with specified status code.
|
||||
*/
|
||||
|
||||
#include "jrt.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jrt.h"
|
||||
|
||||
/*
|
||||
* Exit with specified status code.
|
||||
@@ -78,11 +78,7 @@ jerry_assert_fail (const char *assertion, /**< assertion condition string */
|
||||
const char *function, /**< function name */
|
||||
const uint32_t line) /**< line */
|
||||
{
|
||||
JERRY_ERROR_MSG ("ICE: Assertion '%s' failed at %s(%s):%lu.\n",
|
||||
assertion,
|
||||
file,
|
||||
function,
|
||||
(unsigned long) line);
|
||||
JERRY_ERROR_MSG ("ICE: Assertion '%s' failed at %s(%s):%lu.\n", assertion, file, function, (unsigned long) line);
|
||||
|
||||
jerry_fatal (ERR_FAILED_INTERNAL_ASSERTION);
|
||||
} /* jerry_assert_fail */
|
||||
@@ -95,10 +91,7 @@ jerry_unreachable (const char *file, /**< file name */
|
||||
const char *function, /**< function name */
|
||||
const uint32_t line) /**< line */
|
||||
{
|
||||
JERRY_ERROR_MSG ("ICE: Unreachable control path at %s(%s):%lu was executed.\n",
|
||||
file,
|
||||
function,
|
||||
(unsigned long) line);
|
||||
JERRY_ERROR_MSG ("ICE: Unreachable control path at %s(%s):%lu was executed.\n", file, function, (unsigned long) line);
|
||||
|
||||
jerry_fatal (ERR_FAILED_INTERNAL_ASSERTION);
|
||||
} /* jerry_unreachable */
|
||||
|
||||
+85
-53
@@ -19,8 +19,9 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "jerryscript-port.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "jrt-types.h"
|
||||
|
||||
/*
|
||||
@@ -33,21 +34,21 @@
|
||||
*/
|
||||
#define JERRY_UNUSED(x) ((void) (x))
|
||||
|
||||
#define JERRY_UNUSED_1(_1) JERRY_UNUSED (_1)
|
||||
#define JERRY_UNUSED_2(_1, _2) JERRY_UNUSED (_1), JERRY_UNUSED_1 (_2)
|
||||
#define JERRY_UNUSED_3(_1, _2, _3) JERRY_UNUSED (_1), JERRY_UNUSED_2 (_2, _3)
|
||||
#define JERRY_UNUSED_4(_1, _2, _3, _4) JERRY_UNUSED (_1), JERRY_UNUSED_3 (_2, _3, _4)
|
||||
#define JERRY_UNUSED_5(_1, _2, _3, _4, _5) JERRY_UNUSED (_1), JERRY_UNUSED_4 (_2, _3, _4, _5)
|
||||
#define JERRY_UNUSED_6(_1, _2, _3, _4, _5, _6) JERRY_UNUSED (_1), JERRY_UNUSED_5 (_2, _3, _4, _5, _6)
|
||||
#define JERRY_UNUSED_7(_1, _2, _3, _4, _5, _6, _7) JERRY_UNUSED (_1), JERRY_UNUSED_6 (_2, _3, _4, _5, _6, _7)
|
||||
#define JERRY_UNUSED_8(_1, _2, _3, _4, _5, _6, _7, _8) JERRY_UNUSED (_1), JERRY_UNUSED_7 (_2, _3, _4, _5, _6, _7, _8)
|
||||
#define JERRY_UNUSED_1(_1) JERRY_UNUSED (_1)
|
||||
#define JERRY_UNUSED_2(_1, _2) JERRY_UNUSED (_1), JERRY_UNUSED_1 (_2)
|
||||
#define JERRY_UNUSED_3(_1, _2, _3) JERRY_UNUSED (_1), JERRY_UNUSED_2 (_2, _3)
|
||||
#define JERRY_UNUSED_4(_1, _2, _3, _4) JERRY_UNUSED (_1), JERRY_UNUSED_3 (_2, _3, _4)
|
||||
#define JERRY_UNUSED_5(_1, _2, _3, _4, _5) JERRY_UNUSED (_1), JERRY_UNUSED_4 (_2, _3, _4, _5)
|
||||
#define JERRY_UNUSED_6(_1, _2, _3, _4, _5, _6) JERRY_UNUSED (_1), JERRY_UNUSED_5 (_2, _3, _4, _5, _6)
|
||||
#define JERRY_UNUSED_7(_1, _2, _3, _4, _5, _6, _7) JERRY_UNUSED (_1), JERRY_UNUSED_6 (_2, _3, _4, _5, _6, _7)
|
||||
#define JERRY_UNUSED_8(_1, _2, _3, _4, _5, _6, _7, _8) JERRY_UNUSED (_1), JERRY_UNUSED_7 (_2, _3, _4, _5, _6, _7, _8)
|
||||
|
||||
#define JERRY_VA_ARGS_NUM_IMPL(_1, _2, _3, _4, _5, _6, _7, _8, N, ...) N
|
||||
#define JERRY_VA_ARGS_NUM(...) JERRY_VA_ARGS_NUM_IMPL (__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1, 0)
|
||||
#define JERRY_VA_ARGS_NUM(...) JERRY_VA_ARGS_NUM_IMPL (__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1, 0)
|
||||
|
||||
#define JERRY_UNUSED_ALL_IMPL_(nargs) JERRY_UNUSED_ ## nargs
|
||||
#define JERRY_UNUSED_ALL_IMPL(nargs) JERRY_UNUSED_ALL_IMPL_ (nargs)
|
||||
#define JERRY_UNUSED_ALL(...) JERRY_UNUSED_ALL_IMPL (JERRY_VA_ARGS_NUM (__VA_ARGS__)) (__VA_ARGS__)
|
||||
#define JERRY_UNUSED_ALL_IMPL_(nargs) JERRY_UNUSED_##nargs
|
||||
#define JERRY_UNUSED_ALL_IMPL(nargs) JERRY_UNUSED_ALL_IMPL_ (nargs)
|
||||
#define JERRY_UNUSED_ALL(...) JERRY_UNUSED_ALL_IMPL (JERRY_VA_ARGS_NUM (__VA_ARGS__)) (__VA_ARGS__)
|
||||
|
||||
/*
|
||||
* Asserts
|
||||
@@ -57,39 +58,43 @@
|
||||
* __LINE__ may be the same for asserts in a header
|
||||
* and in an implementation file.
|
||||
*/
|
||||
#define JERRY_STATIC_ASSERT_GLUE_(a, b, c) a ## b ## _ ## c
|
||||
#define JERRY_STATIC_ASSERT_GLUE(a, b, c) JERRY_STATIC_ASSERT_GLUE_ (a, b, c)
|
||||
#define JERRY_STATIC_ASSERT(x, msg) \
|
||||
enum { JERRY_STATIC_ASSERT_GLUE (static_assertion_failed_, __LINE__, msg) = 1 / (!!(x)) }
|
||||
#define JERRY_STATIC_ASSERT_GLUE_(a, b, c) a##b##_##c
|
||||
#define JERRY_STATIC_ASSERT_GLUE(a, b, c) JERRY_STATIC_ASSERT_GLUE_ (a, b, c)
|
||||
#define JERRY_STATIC_ASSERT(x, msg) \
|
||||
enum \
|
||||
{ \
|
||||
JERRY_STATIC_ASSERT_GLUE (static_assertion_failed_, __LINE__, msg) = 1 / (!!(x)) \
|
||||
}
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
void JERRY_ATTR_NORETURN
|
||||
jerry_assert_fail (const char *assertion, const char *file, const char *function, const uint32_t line);
|
||||
void JERRY_ATTR_NORETURN
|
||||
jerry_unreachable (const char *file, const char *function, const uint32_t line);
|
||||
void JERRY_ATTR_NORETURN jerry_assert_fail (const char *assertion,
|
||||
const char *file,
|
||||
const char *function,
|
||||
const uint32_t line);
|
||||
void JERRY_ATTR_NORETURN jerry_unreachable (const char *file, const char *function, const uint32_t line);
|
||||
|
||||
#define JERRY_ASSERT(x) \
|
||||
do \
|
||||
{ \
|
||||
if (JERRY_UNLIKELY (!(x))) \
|
||||
{ \
|
||||
#define JERRY_ASSERT(x) \
|
||||
do \
|
||||
{ \
|
||||
if (JERRY_UNLIKELY (!(x))) \
|
||||
{ \
|
||||
jerry_assert_fail (#x, __FILE__, __func__, __LINE__); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define JERRY_UNREACHABLE() \
|
||||
do \
|
||||
{ \
|
||||
#define JERRY_UNREACHABLE() \
|
||||
do \
|
||||
{ \
|
||||
jerry_unreachable (__FILE__, __func__, __LINE__); \
|
||||
} while (0)
|
||||
#else /* JERRY_NDEBUG */
|
||||
#define JERRY_ASSERT(x) \
|
||||
do \
|
||||
{ \
|
||||
if (false) \
|
||||
{ \
|
||||
do \
|
||||
{ \
|
||||
if (false) \
|
||||
{ \
|
||||
JERRY_UNUSED (x); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef __GNUC__
|
||||
@@ -97,7 +102,7 @@ jerry_unreachable (const char *file, const char *function, const uint32_t line);
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define JERRY_UNREACHABLE() _assume (0)
|
||||
#define JERRY_UNREACHABLE() _assume (0)
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#ifndef JERRY_UNREACHABLE
|
||||
@@ -115,15 +120,43 @@ void JERRY_ATTR_NORETURN jerry_fatal (jerry_fatal_code_t code);
|
||||
* Logging
|
||||
*/
|
||||
#if JERRY_LOGGING
|
||||
#define JERRY_ERROR_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_ERROR, __VA_ARGS__)
|
||||
#define JERRY_ERROR_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_ERROR, __VA_ARGS__)
|
||||
#define JERRY_WARNING_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_WARNING, __VA_ARGS__)
|
||||
#define JERRY_DEBUG_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_DEBUG, __VA_ARGS__)
|
||||
#define JERRY_TRACE_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_TRACE, __VA_ARGS__)
|
||||
#define JERRY_DEBUG_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_DEBUG, __VA_ARGS__)
|
||||
#define JERRY_TRACE_MSG(...) jerry_port_log (JERRY_LOG_LEVEL_TRACE, __VA_ARGS__)
|
||||
#else /* !JERRY_LOGGING */
|
||||
#define JERRY_ERROR_MSG(...) do { if (false) { JERRY_UNUSED_ALL (__VA_ARGS__); } } while (0)
|
||||
#define JERRY_WARNING_MSG(...) do { if (false) { JERRY_UNUSED_ALL (__VA_ARGS__); } } while (0)
|
||||
#define JERRY_DEBUG_MSG(...) do { if (false) { JERRY_UNUSED_ALL (__VA_ARGS__); } } while (0)
|
||||
#define JERRY_TRACE_MSG(...) do { if (false) { JERRY_UNUSED_ALL (__VA_ARGS__); } } while (0)
|
||||
#define JERRY_ERROR_MSG(...) \
|
||||
do \
|
||||
{ \
|
||||
if (false) \
|
||||
{ \
|
||||
JERRY_UNUSED_ALL (__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#define JERRY_WARNING_MSG(...) \
|
||||
do \
|
||||
{ \
|
||||
if (false) \
|
||||
{ \
|
||||
JERRY_UNUSED_ALL (__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#define JERRY_DEBUG_MSG(...) \
|
||||
do \
|
||||
{ \
|
||||
if (false) \
|
||||
{ \
|
||||
JERRY_UNUSED_ALL (__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#define JERRY_TRACE_MSG(...) \
|
||||
do \
|
||||
{ \
|
||||
if (false) \
|
||||
{ \
|
||||
JERRY_UNUSED_ALL (__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
#endif /* JERRY_LOGGING */
|
||||
|
||||
/**
|
||||
@@ -136,7 +169,7 @@ void JERRY_ATTR_NORETURN jerry_fatal (jerry_fatal_code_t code);
|
||||
*
|
||||
* Returns minimum positive value, that divides @a alignment and is more than or equal to @a value
|
||||
*/
|
||||
#define JERRY_ALIGNUP(value, alignment) (((value) + ((alignment) - 1)) & ~((alignment) - 1))
|
||||
#define JERRY_ALIGNUP(value, alignment) (((value) + ((alignment) -1)) & ~((alignment) -1))
|
||||
|
||||
/*
|
||||
* min, max
|
||||
@@ -151,7 +184,7 @@ void JERRY_ATTR_NORETURN jerry_fatal (jerry_fatal_code_t code);
|
||||
#define JERRY__LOG2_2(n) (((n) >= 1 << 2) ? (2 + JERRY__LOG2_1 ((n) >> 2)) : JERRY__LOG2_1 (n))
|
||||
#define JERRY__LOG2_4(n) (((n) >= 1 << 4) ? (4 + JERRY__LOG2_2 ((n) >> 4)) : JERRY__LOG2_2 (n))
|
||||
#define JERRY__LOG2_8(n) (((n) >= 1 << 8) ? (8 + JERRY__LOG2_4 ((n) >> 8)) : JERRY__LOG2_4 (n))
|
||||
#define JERRY_LOG2(n) (((n) >= 1 << 16) ? (16 + JERRY__LOG2_8 ((n) >> 16)) : JERRY__LOG2_8 (n))
|
||||
#define JERRY_LOG2(n) (((n) >= 1 << 16) ? (16 + JERRY__LOG2_8 ((n) >> 16)) : JERRY__LOG2_8 (n))
|
||||
|
||||
/**
|
||||
* JERRY_BLOCK_TAIL_CALL_OPTIMIZATION
|
||||
@@ -173,17 +206,16 @@ void JERRY_ATTR_NORETURN jerry_fatal (jerry_fatal_code_t code);
|
||||
* This macro is intentionally here as jerryscript-compiler.h is a public header and
|
||||
* it does not make sense to expose this macro to the public.
|
||||
*/
|
||||
#if defined (__clang__) || defined (__GNUC__)
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
/* Clang/GCC will not tail call given inline volatile assembly. */
|
||||
#define JERRY_BLOCK_TAIL_CALL_OPTIMIZATION() __asm__ __volatile__ ("")
|
||||
#define JERRY_BLOCK_TAIL_CALL_OPTIMIZATION() __asm__ __volatile__("")
|
||||
#else /* !defined(__clang__) && !defined(__GNUC__) */
|
||||
/* On GCC 10.x this version also works. */
|
||||
#define JERRY_BLOCK_TAIL_CALL_OPTIMIZATION() \
|
||||
do \
|
||||
{ \
|
||||
JERRY_CONTEXT (status_flags) |= ECMA_STATUS_API_AVAILABLE; \
|
||||
} \
|
||||
while (0)
|
||||
#define JERRY_BLOCK_TAIL_CALL_OPTIMIZATION() \
|
||||
do \
|
||||
{ \
|
||||
JERRY_CONTEXT (status_flags) |= ECMA_STATUS_API_AVAILABLE; \
|
||||
} while (0)
|
||||
#endif /* defined(__clang__) || defined (__GNUC__) */
|
||||
|
||||
#endif /* !JRT_H */
|
||||
|
||||
Reference in New Issue
Block a user