team-charls / charls

CharLS, a C++ JPEG-LS library implementation
BSD 3-Clause "New" or "Revised" License
180 stars 74 forks source link

Fix countl_zero: replace __builtin_clzl with __builtin_clzll #272

Closed vbaderks closed 1 year ago

vbaderks commented 1 year ago

GCC\Clang provide 3 overloads for builtin_clz: int __builtin_clz (unsigned int x) int builtin_clzl (unsigned long) int __builtin_clzll (unsigned long long)

GCC and Clang can be used to build CharLS for Linux\macOS (LP64 data model) and Windows (LLP64 data model).

Using __builtin_clzl (unsigned long) for 64 bits works for LP64 (long is 64 bits) but fails for the LLP64 data model (long is 32 bits) __builtin_clzll (unsigned long long) works for both the LP64 and the LLP64 data model (unsigned long long int is always at least 64 bits)

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication