Move likely/unlikely to compiler.h

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2018-12-15 19:11:46 +00:00
parent b73dce1d6d
commit 68873efaa2
3 changed files with 7 additions and 8 deletions

View File

@ -10,6 +10,8 @@
#include <stdio.h>
#include <unistd.h>
#include "compiler.h"
#define ARR_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
#ifdef __FAST_MATH__
@ -104,7 +106,7 @@ normalize_d(double d) {
*/
static inline void *
allocchk_(const char *func_name, void *ptr) {
if (!ptr) {
if (unlikely(!ptr)) {
// Since memory allocation failed, we try to print
// this error message without any memory allocation.
const char msg[] = "(): Failed to allocate memory\n";