Skip to content

Commit c354f55

Browse files
authored
Merge pull request swiftlang#2621 from 3405691582/Prefix_ExposeIntrinsics
[CF] Expose flsl and narrow scope of popcountll.
2 parents 8657d9e + f631bd6 commit c354f55

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

CoreFoundation/Base.subproj/CoreFoundation_Prefix.h

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@ CF_INLINE uint64_t mach_absolute_time() {
227227
#define strtol_l(a,b,c,locale) strtol(a,b,c)
228228

229229
#define fprintf_l(a,locale,b,...) fprintf(a, b, __VA_ARGS__)
230+
231+
CF_INLINE int flsl( long mask ) {
232+
int idx = 0;
233+
while (mask != 0) {
234+
mask = (unsigned long)mask >> 1;
235+
idx++;
236+
}
237+
return idx;
238+
}
230239
#endif // TARGET_OS_LINUX || TARGET_OS_WIN32 || defined(__OpenBSD__)
231240

232241
#if TARGET_OS_LINUX
@@ -369,6 +378,15 @@ CF_INLINE long long llabs(long long v) {
369378
#include <fcntl.h>
370379
#include <errno.h>
371380

381+
CF_INLINE int popcountll(long long x) {
382+
int count = 0;
383+
while (x) {
384+
count++;
385+
x &= x - 1; // reset LS1B
386+
}
387+
return count;
388+
}
389+
372390
#endif
373391

374392
#if !defined(CF_PRIVATE)
@@ -384,21 +402,6 @@ CF_INLINE long long llabs(long long v) {
384402

385403
#include <stdarg.h>
386404

387-
CF_INLINE int flsl( long mask ) {
388-
int idx = 0;
389-
while (mask != 0) mask = (unsigned long)mask >> 1, idx++;
390-
return idx;
391-
}
392-
393-
CF_INLINE int popcountll(long long x) {
394-
int count = 0;
395-
while (x) {
396-
count++;
397-
x &= x - 1; // reset LS1B
398-
}
399-
return count;
400-
}
401-
402405
CF_PRIVATE int asprintf(char **ret, const char *format, ...);
403406

404407
#endif

0 commit comments

Comments
 (0)