Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
long_description = fh.read()

ljpeg92 = Extension('ljpegCompress', sources=[
"src/pidng/bitunpack.c", "src/pidng/liblj92/lj92.c"], extra_compile_args=['-std=gnu99'], extra_link_args=[])
"src/pidng/bitunpack.c", "src/pidng/liblj92/lj92.c"], extra_compile_args=[], extra_link_args=[])

setup(
name="pidng",
Expand Down
21 changes: 14 additions & 7 deletions src/pidng/liblj92/lj92.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,21 @@ typedef uint32_t u32;
//#define SLOW_HUFF
//#define DEBUG

#if defined(__clang__)
#define _clz __builtin_clz
#elif defined(__GNUC__) || defined(__GNUG__)
#define _clz __builtin_clz
#elif defined(_MSC_VER)
#define _clz __lzcnt
#if defined(_MSC_VER)
#include <intrin.h>
static inline int __msvc_clz(unsigned int x) {
unsigned long leading_zero;
if (_BitScanReverse(&leading_zero, x)) {
return 31 - leading_zero;
} else {
return 32;
}
}
#define _clz __msvc_clz
#elif defined(__GNUC__) || defined(__clang__)
#define _clz __builtin_clz
#else
#error Could not find builtin clz function
#error Could not find builtin clz function
#endif

typedef struct _ljp {
Expand Down