diff options
author | Miles Bader <miles@lsi.nec.co.jp> | 2002-08-30 05:13:57 +0000 |
---|---|---|
committer | Miles Bader <miles@lsi.nec.co.jp> | 2002-08-30 05:13:57 +0000 |
commit | 8879afda8b95340b8e2263e4862d02bfe6aa54f1 (patch) | |
tree | cfaacad2c7792f5dd0ba254df357f6092ff960a4 /libc/stdlib/malloc | |
parent | 27364377c65a4c6bc3a7ab429f0921adead19349 (diff) |
(likely, unlikely): New macros.
(__malloc_likely, __malloc_unlikely): Macros removed.
Diffstat (limited to 'libc/stdlib/malloc')
-rw-r--r-- | libc/stdlib/malloc/malloc.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libc/stdlib/malloc/malloc.h b/libc/stdlib/malloc/malloc.h index 4914a9edc..30a28b776 100644 --- a/libc/stdlib/malloc/malloc.h +++ b/libc/stdlib/malloc/malloc.h @@ -110,14 +110,16 @@ extern malloc_mutex_t __malloc_sbrk_lock; #endif /* __UCLIBC_HAS_THREADS__ */ -/* Use branch-prediction macros from libc if defined. */ -#ifdef likely -#define __malloc_likely(c) likely(c) -#define __malloc_unlikely(c) unlikely(c) +/* branch-prediction macros; they may already be defined by libc. */ +#ifndef likely +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +#define likely(cond) __builtin_expect(!!(int)(cond), 1) +#define unlikely(cond) __builtin_expect((int)(cond), 0) #else -#define __malloc_likely(c) (c) -#define __malloc_unlikely(c) (c) +#define likely(cond) (cond) +#define unlikely(cond) (cond) #endif +#endif /* !likely */ /* Define MALLOC_DEBUGGING to cause malloc to emit debugging info to stderr. */ |