mirror of git://gcc.gnu.org/git/gcc.git
stl_algo.h (__lg<>(_Size)): Slightly tweak.
2007-10-25 Paolo Carlini <pcarlini@suse.de> * include/bits/stl_algo.h (__lg<>(_Size)): Slightly tweak. (__lg(int), __lg(long), __lg(long long)): Add, overloads exploiting __builtin_clz*. From-SVN: r129624
This commit is contained in:
parent
0bf2cf8907
commit
1fcd0a2c50
|
@ -1,3 +1,9 @@
|
|||
2007-10-25 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/bits/stl_algo.h (__lg<>(_Size)): Slightly tweak.
|
||||
(__lg(int), __lg(long), __lg(long long)): Add, overloads
|
||||
exploiting __builtin_clz*.
|
||||
|
||||
2007-10-24 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/tr1_impl/array (_M_instance): Align naturally.
|
||||
|
|
|
@ -2085,7 +2085,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
|
||||
/**
|
||||
* @if maint
|
||||
* This is a helper function for the sort routines.
|
||||
* This is a helper function for the sort routines. Precondition: __n > 0.
|
||||
* @endif
|
||||
*/
|
||||
template<typename _Size>
|
||||
|
@ -2093,11 +2093,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
|||
__lg(_Size __n)
|
||||
{
|
||||
_Size __k;
|
||||
for (__k = 0; __n != 1; __n >>= 1)
|
||||
for (__k = 0; __n != 0; __n >>= 1)
|
||||
++__k;
|
||||
return __k;
|
||||
return __k - 1;
|
||||
}
|
||||
|
||||
inline int
|
||||
__lg(int __n)
|
||||
{ return sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); }
|
||||
|
||||
inline long
|
||||
__lg(long __n)
|
||||
{ return sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); }
|
||||
|
||||
inline long long
|
||||
__lg(long long __n)
|
||||
{ return sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); }
|
||||
|
||||
// sort
|
||||
|
||||
template<typename _RandomAccessIterator, typename _Size>
|
||||
|
|
Loading…
Reference in New Issue