diff options
author | Tilghman Lesher <tilghman@meg.abyt.es> | 2009-12-02 03:26:16 +0000 |
---|---|---|
committer | Tilghman Lesher <tilghman@meg.abyt.es> | 2009-12-02 03:26:16 +0000 |
commit | f46840c107b029d60c01a45938e10b7062081ac6 (patch) | |
tree | 1f3193e3fae80882dc4d90585f9832b1897361d5 /main | |
parent | 08ec550c1673c44e1ef176f2399c7f30d0e30a71 (diff) |
So apparently, some platforms don't have ffsll(3).
The manpage lies; it says that the function is in POSIX, but that's only for
ffs(3), not ffsll(3).
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@232164 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r-- | main/strcompat.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/main/strcompat.c b/main/strcompat.c index 156809003..ff123713e 100644 --- a/main/strcompat.c +++ b/main/strcompat.c @@ -386,3 +386,16 @@ uint64_t htonll(uint64_t host64) } #endif +#ifndef HAVE_FFSLL +int ffsll(long long n) +{ + int i; + for (i = 0; i < 64; i++) { + if ((1LL << i) & n) { + return i + 1; + } + } + return 0; +} +#endif + |