Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement __builtin_clz in MSVC #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/zopfli/symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ Utilities for using the lz77 symbols of the deflate spec.
/* __builtin_clz available beginning with GCC 3.4 */
#elif __GNUC__ * 100 + __GNUC_MINOR__ >= 304
# define ZOPFLI_HAS_BUILTIN_CLZ
/* _BitScanReverse available beginning with Visual Studio 2005 */
#elif _MSC_VER >= 1400
# include <intrin.h>
# define ZOPFLI_HAS_BUILTIN_CLZ
static int __inline __builtin_clz(unsigned int x) {
unsigned long r;
_BitScanReverse(&r, x);
return 31 ^ r;
}
#endif

/* Gets the amount of extra bits for the given dist, cfr. the DEFLATE spec. */
Expand Down