diff options
| author | hansr <hk-git@circlestorm.org> | 2014-10-09 15:10:33 +0200 |
|---|---|---|
| committer | hansr <hk-git@circlestorm.org> | 2014-10-09 15:10:33 +0200 |
| commit | 1eecc12f19f75fd59f59fad5d36daa5e520f43fc (patch) | |
| tree | 461b1749c5894080e4ba40a197c20cc6bba12636 | |
| parent | 279e637d951d3101d5509e60f4ca8c39178e3518 (diff) | |
| download | Project-Tick-1eecc12f19f75fd59f59fad5d36daa5e520f43fc.tar.gz Project-Tick-1eecc12f19f75fd59f59fad5d36daa5e520f43fc.zip | |
Clean up likely/unlikely definitions
| -rw-r--r-- | deflate.h | 4 | ||||
| -rw-r--r-- | deflate_medium.c | 6 | ||||
| -rw-r--r-- | match.c | 2 | ||||
| -rw-r--r-- | zutil.h | 25 |
4 files changed, 21 insertions, 16 deletions
@@ -459,8 +459,4 @@ local void send_bits(s, value, length) } #endif - -#define likely(x) __builtin_expect((x),1) -#define unlikely(x) __builtin_expect((x),0) - #endif /* DEFLATE_H */ diff --git a/deflate_medium.c b/deflate_medium.c index 4beada8d85..0d4d98a7da 100644 --- a/deflate_medium.c +++ b/deflate_medium.c @@ -54,7 +54,7 @@ static int emit_match(deflate_state *s, struct match match, IPos hash_head) static void insert_match(deflate_state *s, struct match match) { - if (zunlikely(s->lookahead <= match.match_length + MIN_MATCH)) + if (unlikely(s->lookahead <= match.match_length + MIN_MATCH)) return; /* matches that are not long enough we need to emit as litterals */ @@ -80,7 +80,7 @@ static void insert_match(deflate_state *s, struct match match) match.match_length--; /* string at strstart already in table */ do { match.strstart++; - if (zlikely(match.strstart >= match.orgstart)) { + if (likely(match.strstart >= match.orgstart)) { insert_string(s, match.strstart); } /* strstart never exceeds WSIZE-MAX_MATCH, so there are @@ -118,7 +118,7 @@ static void fizzle_matches(deflate_state *s, struct match *current, struct match orig = s->window - current->match_length + 1 + next->strstart ; /* quick exit check.. if this fails then don't bother with anything else */ - if (zlikely(*match != *orig)) + if (likely(*match != *orig)) return; /* @@ -201,7 +201,7 @@ local unsigned std2_longest_match(deflate_state *z_const s, IPos cur_match) * is limited to the lookahead, so the output of deflate is not * affected by the uninitialized values. */ - if (zlikely((*(unsigned short *)(match + best_len - 1) != scan_end))) + if (likely((*(unsigned short *)(match + best_len - 1) != scan_end))) continue; if (*(unsigned short *)match != scan_start) continue; @@ -121,14 +121,6 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ #pragma warn -8066 #endif -#if defined(__GNUC__) -# define zlikely(x) __builtin_expect(!!(x), 1) -# define zunlikely(x) __builtin_expect(!!(x), 0) -#else -# define zlikely(x) x -# define zunlikely(x) x -#endif - /* provide prototypes for these when building zlib without LFS */ #if !defined(_WIN32) && \ (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) @@ -235,4 +227,21 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) #endif /* ZSWAP32 */ +/* Only enable likely/unlikely if the compiler is known to support it */ +#if defined(__GNUC__) && (__GNUC__ >= 3) +# ifndef likely +# define likely(x) __builtin_expect(!!(x),1) +# endif +# ifndef unlikely +# define unlikely(x) __builtin_expect(!!(x),0) +# endif +#else +# ifndef likely +# define likely(x) x +# endif +# ifndef unlikely +# define unlikely(x) x +# endif +#endif /* (un)likely */ + #endif /* ZUTIL_H */ |
