diff options
| author | Dima Zavin <dima@android.com> | 2011-03-14 14:14:49 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-03-14 14:14:49 -0700 |
| commit | 29d1f53a56fc2eb5a52a80ceb6cfbde778e4bc12 (patch) | |
| tree | ce15117aee51bebb0f872b4db7d29a0dff6f9442 /include/cutils | |
| parent | a0768663c5798986c3ccfb3fdab380c5a4cf7d67 (diff) | |
| parent | 5a809b90e91d2ccf4c84181d10d175eb2c1c6bc7 (diff) | |
| download | system_core-29d1f53a56fc2eb5a52a80ceb6cfbde778e4bc12.tar.gz system_core-29d1f53a56fc2eb5a52a80ceb6cfbde778e4bc12.tar.bz2 system_core-29d1f53a56fc2eb5a52a80ceb6cfbde778e4bc12.zip | |
Merge "cutils: add popcount/popcountl/popcountll static inline definitions"
Diffstat (limited to 'include/cutils')
| -rw-r--r-- | include/cutils/bitops.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/include/cutils/bitops.h b/include/cutils/bitops.h new file mode 100644 index 00000000..1b3b762e --- /dev/null +++ b/include/cutils/bitops.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CUTILS_BITOPS_H +#define __CUTILS_BITOPS_H + +#include <sys/cdefs.h> + +__BEGIN_DECLS + +static inline int popcount(unsigned int x) +{ + return __builtin_popcount(x); +} + +static inline int popcountl(unsigned long x) +{ + return __builtin_popcountl(x); +} + +static inline int popcountll(unsigned long long x) +{ + return __builtin_popcountll(x); +} + +__END_DECLS + +#endif /* __CUTILS_BITOPS_H */ |
