jitterbug/util.h

28 lines
622 B
C
Raw Normal View History

2022-12-29 20:10:36 +02:00
#ifndef _JITTERBUG__UTIL_H
#define _JITTERBUG__UTIL_H
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
2023-01-16 16:04:09 +02:00
#include "config.h"
#ifdef JB_ENABLE_BRANCH_HINTS
# ifdef __has_builtin
# if __has_builtin(__builtin_expect)
# define __JB_UTIL_CAN_USE_BRANCH_HINTS
# endif
# endif
#endif
#ifdef __JB_UTIL_CAN_USE_BRANCH_HINTS
# define unlikely(M_expr) __builtin_expect(!!(M_expr), 0)
# define likely(M_expr) __builtin_expect(!!(M_expr), 1)
#else
# define unlikely(M_expr) (M_expr)
# define likely(M_expr) (M_expr)
#endif
2022-12-29 20:10:36 +02:00
char *string_dup(const char *s);
#endif // _JITTERBUG__UTIL_H