}
#endif
-
-#define likely(x) __builtin_expect((x),1)
-#define unlikely(x) __builtin_expect((x),0)
-
#endif /* DEFLATE_H */
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 */
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
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;
/*
* 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;
#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)
(((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 */