Add jerryscript-compiler.h public header to cover compiler incompatibilities (#2313)
In general, public headers should not have compiler-specific constructs but both the core and the port headers have attributes, which are non-standard. It's better to factor out such constructs to a common place (a new header) and hide them behind macros, which can then be defined on a per-compiler basis. This patch moves the existing definitions of function attributes and likely/unlikely builtins to the new header. At the same time, it unifies the names of these attribute defines and where they are used. Moreover, it touches on jerry-main and removes the uses of `__attribute__((unused))` entirely and replaces them with the elsewhere used `(void) ...` pattern. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
@@ -164,8 +164,8 @@ void jmem_stats_free_property_bytes (size_t property_size);
|
||||
void jmem_heap_get_stats (jmem_heap_stats_t *);
|
||||
#endif /* JMEM_STATS */
|
||||
|
||||
jmem_cpointer_t jmem_compress_pointer (const void *pointer_p) __attr_pure___;
|
||||
void *jmem_decompress_pointer (uintptr_t compressed_pointer) __attr_pure___;
|
||||
jmem_cpointer_t JERRY_ATTR_PURE jmem_compress_pointer (const void *pointer_p);
|
||||
void * JERRY_ATTR_PURE jmem_decompress_pointer (uintptr_t compressed_pointer);
|
||||
|
||||
/**
|
||||
* A free memory callback routine type.
|
||||
@@ -217,7 +217,7 @@ void jmem_run_free_unused_memory_callbacks (jmem_free_unused_memory_severity_t s
|
||||
* Get value of pointer from specified compressed pointer value
|
||||
*/
|
||||
#define JMEM_CP_GET_POINTER(type, cp_value) \
|
||||
(((unlikely ((cp_value) == JMEM_CP_NULL)) ? NULL : JMEM_CP_GET_NON_NULL_POINTER (type, cp_value)))
|
||||
(((JERRY_UNLIKELY ((cp_value) == JMEM_CP_NULL)) ? NULL : JMEM_CP_GET_NON_NULL_POINTER (type, cp_value)))
|
||||
|
||||
/**
|
||||
* Set value of non-null compressed pointer so that it will correspond
|
||||
@@ -235,7 +235,7 @@ void jmem_run_free_unused_memory_callbacks (jmem_free_unused_memory_severity_t s
|
||||
{ \
|
||||
void *ptr_value = (void *) non_compressed_pointer; \
|
||||
\
|
||||
if (unlikely ((ptr_value) == NULL)) \
|
||||
if (JERRY_UNLIKELY ((ptr_value) == NULL)) \
|
||||
{ \
|
||||
(cp_value) = JMEM_CP_NULL; \
|
||||
} \
|
||||
|
||||
Reference in New Issue
Block a user