Blame jemalloc/include/jemalloc/internal/util.h

Packit 345191
#ifndef JEMALLOC_INTERNAL_UTIL_H
Packit 345191
#define JEMALLOC_INTERNAL_UTIL_H
Packit 345191
Packit 345191
#define UTIL_INLINE static inline
Packit 345191
Packit 345191
/* Junk fill patterns. */
Packit 345191
#ifndef JEMALLOC_ALLOC_JUNK
Packit 345191
#  define JEMALLOC_ALLOC_JUNK	((uint8_t)0xa5)
Packit 345191
#endif
Packit 345191
#ifndef JEMALLOC_FREE_JUNK
Packit 345191
#  define JEMALLOC_FREE_JUNK	((uint8_t)0x5a)
Packit 345191
#endif
Packit 345191
Packit 345191
/*
Packit 345191
 * Wrap a cpp argument that contains commas such that it isn't broken up into
Packit 345191
 * multiple arguments.
Packit 345191
 */
Packit 345191
#define JEMALLOC_ARG_CONCAT(...) __VA_ARGS__
Packit 345191
Packit 345191
/* cpp macro definition stringification. */
Packit 345191
#define STRINGIFY_HELPER(x) #x
Packit 345191
#define STRINGIFY(x) STRINGIFY_HELPER(x)
Packit 345191
Packit 345191
/*
Packit 345191
 * Silence compiler warnings due to uninitialized values.  This is used
Packit 345191
 * wherever the compiler fails to recognize that the variable is never used
Packit 345191
 * uninitialized.
Packit 345191
 */
Packit 345191
#define JEMALLOC_CC_SILENCE_INIT(v) = v
Packit 345191
Packit 345191
#ifdef __GNUC__
Packit 345191
#  define likely(x)   __builtin_expect(!!(x), 1)
Packit 345191
#  define unlikely(x) __builtin_expect(!!(x), 0)
Packit 345191
#else
Packit 345191
#  define likely(x)   !!(x)
Packit 345191
#  define unlikely(x) !!(x)
Packit 345191
#endif
Packit 345191
Packit 345191
#if !defined(JEMALLOC_INTERNAL_UNREACHABLE)
Packit 345191
#  error JEMALLOC_INTERNAL_UNREACHABLE should have been defined by configure
Packit 345191
#endif
Packit 345191
Packit 345191
#define unreachable() JEMALLOC_INTERNAL_UNREACHABLE()
Packit 345191
Packit 345191
/* Set error code. */
Packit 345191
UTIL_INLINE void
Packit 345191
set_errno(int errnum) {
Packit 345191
#ifdef _WIN32
Packit 345191
	SetLastError(errnum);
Packit 345191
#else
Packit 345191
	errno = errnum;
Packit 345191
#endif
Packit 345191
}
Packit 345191
Packit 345191
/* Get last error code. */
Packit 345191
UTIL_INLINE int
Packit 345191
get_errno(void) {
Packit 345191
#ifdef _WIN32
Packit 345191
	return GetLastError();
Packit 345191
#else
Packit 345191
	return errno;
Packit 345191
#endif
Packit 345191
}
Packit 345191
Packit 345191
#undef UTIL_INLINE
Packit 345191
Packit 345191
#endif /* JEMALLOC_INTERNAL_UTIL_H */