diff options
| author | Jean-Baptiste Queru <jbq@google.com> | 2011-05-12 10:44:52 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2011-05-12 10:44:52 -0700 |
| commit | 34df17d03289cee83cee176807c9390b084d77b9 (patch) | |
| tree | 6afdea025be229977b12ab19e2e3182c0d50c50e | |
| parent | c951695ede6636955965d358454a23752c554da6 (diff) | |
| parent | 7078f776fd658f86ecb249eeffc6e7cb0c4ae66a (diff) | |
| download | core-34df17d03289cee83cee176807c9390b084d77b9.tar.gz core-34df17d03289cee83cee176807c9390b084d77b9.tar.bz2 core-34df17d03289cee83cee176807c9390b084d77b9.zip | |
am 7078f776: Merge "cutils: add popcount/popcountl/popcountll static inline definitions"
* commit '7078f776fd658f86ecb249eeffc6e7cb0c4ae66a':
cutils: add popcount/popcountl/popcountll static inline definitions
| -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 000000000..1b3b762e6 --- /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 */ |
