BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlb_bitutil.h
Go to the documentation of this file.
1/// @file bdlb_bitutil.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlb_bitutil.h -*-C++-*-
8#ifndef INCLUDED_BDLB_BITUTIL
9#define INCLUDED_BDLB_BITUTIL
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlb_bitutil bdlb_bitutil
15/// @brief Provide efficient bit-manipulation of `uint32_t`/`uint64_t` values.
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlb
19/// @{
20/// @addtogroup bdlb_bitutil
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlb_bitutil-purpose"> Purpose</a>
25/// * <a href="#bdlb_bitutil-classes"> Classes </a>
26/// * <a href="#bdlb_bitutil-description"> Description </a>
27/// * <a href="#bdlb_bitutil-usage"> Usage </a>
28///
29/// # Purpose {#bdlb_bitutil-purpose}
30/// Provide efficient bit-manipulation of `uint32_t`/`uint64_t` values.
31///
32/// # Classes {#bdlb_bitutil-classes}
33///
34/// - bdlb::BitUtil: namespace for `uint32_t` and `uint64_t` bit-level operations
35///
36/// # Description {#bdlb_bitutil-description}
37/// This component provides a utility `struct`, `bdlb::BitUtil`,
38/// that serves as a namespace for a collection of efficient, bit-level
39/// procedures on 32- and 64-bit unsigned integer types. In particular,
40/// `BitUtil` supplies single bit manipulation, bit counting, and mathematical
41/// functions that can be optimized with bitwise operations.
42///
43/// This component is meant to interoperate cleanly both with fundamental types,
44/// as well as common sized integer type aliases like `bsl::uin64_t` and
45/// `bslsl::Types::UInt64`. An overload set consisting of the fundamental
46/// integer types `unsigned int`, `unsigned long`, and `unsigned long long` is
47/// used to minimize warnings and avoid ambiguity that may arise when dealing
48/// with explicitly sized types that may alias to different fundamental types on
49/// different platforms.
50///
51/// Some of the methods provided in `BitUtil` have other common names. Below is
52/// a list of mappings from the name used in `BitUtil` to these related function
53/// names:
54///
55/// * numLeadingUnsetBits: cntlz, clz, ffs, ffo, nlz, ctlz
56/// * numTrailingUnsetBits: cnttz, ctz, ntz, cttz
57/// * numBitsSet: popcnt, popcount
58///
59/// ## Usage {#bdlb_bitutil-usage}
60///
61///
62/// The following usage examples illustrate how some of the methods provided by
63/// this component are used. Note that, in all of these examples, the low-order
64/// bit is considered bit 0 and resides on the right edge of the bit string.
65///
66/// First, we use `withBitSet` to demonstrate the ordering of bits:
67/// @code
68/// assert(static_cast<uint32_t>(0x00000001)
69/// == bdlb::BitUtil::withBitSet(static_cast<uint32_t>(0), 0));
70/// assert(static_cast<uint32_t>(0x00000008)
71/// == bdlb::BitUtil::withBitSet(static_cast<uint32_t>(0), 3));
72/// assert(static_cast<uint32_t>(0x00800000)
73/// == bdlb::BitUtil::withBitSet(static_cast<uint32_t>(0), 23));
74/// assert(static_cast<uint32_t>(0x66676666)
75/// == bdlb::BitUtil::withBitSet(static_cast<uint32_t>(0x66666666), 16));
76///
77/// /*------------------------------------------------------------------------+
78/// | 'bdlb::BitUtil::withBitSet(0x66666666, 16)' in binary: |
79/// | |
80/// | input in binary: 01100110011001100110011001100110 |
81/// | set bit 16: 1 |
82/// | result: 01100110011001110110011001100110 |
83/// +------------------------------------------------------------------------*/
84/// @endcode
85/// Then, we count the number of set bits in a value with `numBitsSet`:
86/// @code
87/// assert(0 == bdlb::BitUtil::numBitsSet(static_cast<uint32_t>(0x00000000)));
88/// assert(2 == bdlb::BitUtil::numBitsSet(static_cast<uint32_t>(0x00101000)));
89/// assert(8 == bdlb::BitUtil::numBitsSet(static_cast<uint32_t>(0x30071101)));
90///
91/// /*------------------------------------------------------------------------+
92/// | 'bdlb::BitUtil::numBitsSet(0x30071101)' in binary: |
93/// | |
94/// | input in binary: 00110000000001110001000100000001 |
95/// | that has 8 bits set. result: 8 |
96/// +------------------------------------------------------------------------*/
97/// @endcode
98/// Finally, we use `numLeadingUnsetBits` to determine the number of unset bits
99/// with a higher index than the first set bit:
100/// @code
101/// assert(32 ==
102/// bdlb::BitUtil::numLeadingUnsetBits(static_cast<uint32_t>(0x00000000)));
103/// assert(31 ==
104/// bdlb::BitUtil::numLeadingUnsetBits(static_cast<uint32_t>(0x00000001)));
105/// assert(7 ==
106/// bdlb::BitUtil::numLeadingUnsetBits(static_cast<uint32_t>(0x01000000)));
107/// assert(7 ==
108/// bdlb::BitUtil::numLeadingUnsetBits(static_cast<uint32_t>(0x01620030)));
109///
110/// /*------------------------------------------------------------------------+
111/// | 'bdlb::BitUtil::numLeadingUnsetBits(0x01620030)' in binary: |
112/// | |
113/// | input in binary: 00000001011000100000000000110000 |
114/// | highest set bit: 1 |
115/// | number of unset bits leading this set bit == 7 |
116/// +------------------------------------------------------------------------*/
117/// @endcode
118/// @}
119/** @} */
120/** @} */
121
122/** @addtogroup bdl
123 * @{
124 */
125/** @addtogroup bdlb
126 * @{
127 */
128/** @addtogroup bdlb_bitutil
129 * @{
130 */
131
132#include <bdlscm_version.h>
133
134#include <bslmf_conditional.h>
135
136#include <bsls_assert.h>
137#include <bsls_performancehint.h>
138#include <bsls_platform.h>
139#include <bsls_review.h>
140
141#include <bsl_climits.h>
142#include <bsl_cstdint.h>
143
144#ifdef BSLS_PLATFORM_CMP_IBM // Use IBM intrinsics
145#include <builtins.h>
146# define BDLB_BITUTIL_USE_IBM_INTRINSICS 1
147 // Use the intrinsics that map directly to CPU instructions on IBM
148#endif
149
150
151#if defined(BSLS_PLATFORM_CMP_GNU) || defined(BSLS_PLATFORM_CMP_CLANG)
152/// Use optimal intrinsics that know about CPU instruction sets on compilers
153/// the recognize the Gnu intrinsic spellings.
154# define BDLB_BITUTIL_USE_GNU_INTRINSICS 1
155#endif
156
157#ifdef BSLS_PLATFORM_CMP_MSVC
158#include <intrin.h>
159# define BDLB_BITUTIL_USE_MSVC_INTRINSICS 1
160 // Use the intrinsics that map directly to CPU instructions on MSVC
161
162# if defined(BSLS_PLATFORM_CPU_ARM)
163# define BDLB_BITUTIL_USE_MSVC_COUNT_ONE_BITS 1
164 // Use _CountOneBits instead of __popcnt intrinsics on MSVC
165# endif
166
167#endif
168
169
170namespace bdlb {
171
172 // ==============
173 // struct BitUtil
174 // ==============
175
176/// This utility `struct` provides a namespace for a set of bit-level,
177/// stateless functions that operate on the built-in 32- and 64-bit unsigned
178/// integer types.
179struct BitUtil {
180
181 private:
182 // PRIVATE CONSTANTS
183 enum {
184 k_BITS_PER_INT32 = 32, // bits used to represent an 'int32_t'
185 k_BITS_PER_INT64 = 64 // bits used to represent an 'int64_t'
186 };
187
188 public:
189 // PUBLIC TYPE ALIASES (to support old toolchains)
190 typedef bsl::uint32_t uint32_t;
191 typedef bsl::uint64_t uint64_t;
192
193 private:
194 // PRIVATE TYPES
195 typedef bsl::conditional<sizeof(unsigned long) == sizeof(unsigned int),
196 unsigned int,
197 unsigned long long>::type ULongLikeType;
198
199 // PRIVATE CLASS METHODS
200
201 /// Convert the specified `value` from `unsigned long` to another
202 /// unsigned type of the same size - `unsigned int` or
203 /// `unsigned long long`.
204 static ULongLikeType normalize(unsigned long value);
205
206 static int privateNumBitsSet(unsigned int value);
207 static int privateNumBitsSet(unsigned long value);
208 /// Return the number of 1 bits in the specified `value`.
209 static int privateNumBitsSet(unsigned long long value);
210
211 static int privateNumLeadingUnsetBits(unsigned int value);
212 static int privateNumLeadingUnsetBits(unsigned long value);
213 /// Return the number of consecutive 0 bits starting from the
214 /// most-significant bit in the specified `value`.
215 static int privateNumLeadingUnsetBits(unsigned long long value);
216
217 static int privateNumTrailingUnsetBits(unsigned int value);
218 static int privateNumTrailingUnsetBits(unsigned long value);
219 /// Return the number of consecutive 0 bits starting from the
220 /// least-significant bit in the specified `value`.
221 static int privateNumTrailingUnsetBits(unsigned long long value);
222
223 public:
224 // CLASS METHODS
225
226 static bool isBitSet(unsigned int value, int index);
227 static bool isBitSet(unsigned long value, int index);
228 /// Return `true` if the bit in the specified `value` at the specified
229 /// `index` is set to 1, and `false` otherwise. The behavior is
230 /// undefined unless `0 <= index < sizeInBits(value)`.
231 static bool isBitSet(unsigned long long value, int index);
232
233 static int log2(unsigned int value);
234 static int log2(unsigned long value);
235 /// Return the base-2 logarithm of the specified `value` rounded up to
236 /// the nearest integer. The behavior is undefined unless `0 < value`.
237 static int log2(unsigned long long value);
238
239 static int numBitsSet(unsigned int value);
240 static int numBitsSet(unsigned long value);
241 /// Return the number of 1 bits in the specified `value`.
242 static int numBitsSet(unsigned long long value);
243
244 static int numLeadingUnsetBits(unsigned int value);
245 static int numLeadingUnsetBits(unsigned long value);
246 /// Return the number of consecutive 0 bits starting from the
247 /// most-significant bit in the specified `value`.
248 static int numLeadingUnsetBits(unsigned long long value);
249
250 static int numTrailingUnsetBits(unsigned int value);
251 static int numTrailingUnsetBits(unsigned long value);
252 /// Return the number of consecutive 0 bits starting from the
253 /// least-significant bit in the specified `value`.
254 static int numTrailingUnsetBits(unsigned long long value);
255
256 static unsigned int roundUp(unsigned int value, unsigned int boundary);
257 static unsigned long roundUp(unsigned long value, unsigned long boundary);
258 /// Return the least multiple of the specified `boundary` that is
259 /// greater than or equal to the specified `value`, and 0 if
260 /// `0 == value` or the conversion was not successful. The behavior is
261 /// undefined unless `1 == numBitsSet(boundary)`. Note that the
262 /// conversion will succeed if and only if `0 == value % boundary` or
263 /// `(1 << sizeInBits(value)) > (value / boundary + 1) * boundary`.
264 static unsigned long long roundUp(unsigned long long value,
265 unsigned long long boundary);
266
267 static unsigned int roundUpToBinaryPower(unsigned int value);
268 static unsigned long roundUpToBinaryPower(unsigned long value);
269 /// Return the least power of 2 that is greater than or equal to the
270 /// specified `value`, and 0 if the conversion was not successful. Note
271 /// that the conversion will succeed if and only if
272 /// `0 < value <= (1 << (sizeInBits(value) - 1))`
273 static unsigned long long roundUpToBinaryPower(unsigned long long value);
274
275 /// Return the number of bits in the specified `value` of the (template
276 /// parameter) type `INTEGER`.
277 template <class INTEGER>
278 static int sizeInBits(INTEGER value = 0);
279
280 static unsigned int withBitCleared(unsigned int value, int index);
281 static unsigned long withBitCleared(unsigned long value, int index);
282 /// Return the result of replacing the bit at the specified `index` in
283 /// the specified `value` with 0, transferring all other bits from
284 /// `value` unchanged. The behavior is undefined unless
285 /// `0 <= index < sizeInBits(value)`.
286 static unsigned long long withBitCleared(unsigned long long value,
287 int index);
288
289 static unsigned int withBitSet(unsigned int value, int index);
290 static unsigned long withBitSet(unsigned long value, int index);
291 /// Return the result of replacing the bit at the specified `index` in
292 /// the specified `value` with 1, transferring all other bits from
293 /// `value` unchanged. The behavior is undefined unless
294 /// `0 <= index < sizeInBits(value)`.
295 static unsigned long long withBitSet(unsigned long long value, int index);
296};
297
298// ============================================================================
299// INLINE FUNCTION DEFINITIONS
300// ============================================================================
301
302 // --------------
303 // struct BitUtil
304 // --------------
305
306// CLASS METHODS
307inline
308BitUtil::ULongLikeType BitUtil::normalize(unsigned long value)
309{
310 return static_cast<ULongLikeType>(value);
311}
312
313inline
314bool BitUtil::isBitSet(unsigned int value, int index)
315{
316 BSLS_ASSERT_SAFE( 0 <= index);
317 BSLS_ASSERT_SAFE(index < k_BITS_PER_INT32);
318
319 return ((1 << index) & value) != 0;
320}
321
322inline
323bool BitUtil::isBitSet(unsigned long long value, int index)
324{
325 BSLS_ASSERT_SAFE( 0 <= index);
326 BSLS_ASSERT_SAFE(index < k_BITS_PER_INT64);
327
328 return ((1ULL << index) & value) != 0;
329}
330
331inline
332bool BitUtil::isBitSet(unsigned long value, int index)
333{
334 return isBitSet(normalize(value), index);
335}
336
337inline
338int BitUtil::log2(unsigned int value)
339{
340 BSLS_ASSERT(0 < value);
341
342 return k_BITS_PER_INT32 - numLeadingUnsetBits(value - 1);
343}
344
345inline
346int BitUtil::log2(unsigned long long value)
347{
348 BSLS_ASSERT(0ULL < value);
349
350 return k_BITS_PER_INT64 - numLeadingUnsetBits(value - 1);
351}
352
353inline
354int BitUtil::log2(unsigned long value)
355{
356 return log2(normalize(value));
357}
358
359inline
360int BitUtil::numBitsSet(unsigned int value)
361{
362#if defined(BDLB_BITUTIL_USE_IBM_INTRINSICS)
363 return __popcnt4(value);
364#elif defined(BDLB_BITUTIL_USE_GNU_INTRINSICS)
365 return __builtin_popcount(value);
366#elif defined(BDLB_BITUTIL_USE_MSVC_INTRINSICS)
367# if !defined(BDLB_BITUTIL_USE_MSVC_COUNT_ONE_BITS)
368 return __popcnt(value);
369# else
370 return _CountOneBits(value);
371# endif
372#else
373 return privateNumBitsSet(value);
374#endif
375}
376
377inline
378int BitUtil::numBitsSet(unsigned long long value)
379{
380#if defined(BDLB_BITUTIL_USE_IBM_INTRINSICS)
381 return __popcnt8(value);
382#elif defined(BDLB_BITUTIL_USE_GNU_INTRINSICS)
383 return __builtin_popcountll(value);
384#elif defined(BDLB_BITUTIL_USE_MSVC_INTRINSICS)
385 #if !defined(BDLB_BITUTIL_USE_MSVC_COUNT_ONE_BITS)
386 #if defined(BSLS_PLATFORM_CPU_64_BIT)
387 return static_cast<int>(__popcnt64(value));
388 #else
389 // '__popcnt64' available only in 64bit target
390 return __popcnt(static_cast<unsigned int>(value)) +
391 __popcnt(static_cast<unsigned int>(value >>
392 k_BITS_PER_INT32));
393 #endif
394 #else
395 return _CountOneBits64(value);
396 #endif
397#else
398 return privateNumBitsSet(value);
399#endif
400}
401
402inline
403int BitUtil::numBitsSet(unsigned long value)
404{
405 return numBitsSet(normalize(value));
406}
407
408inline
409int BitUtil::numLeadingUnsetBits(unsigned int value)
410{
411#if defined(BDLB_BITUTIL_USE_IBM_INTRINSICS)
412 return __cntlz4(value);
413#elif defined(BDLB_BITUTIL_USE_GNU_INTRINSICS)
414 // '__builtin_clz(0)' is undefined
415 return __builtin_clz(value | 1) + static_cast<int>(!value);
416#elif defined(BDLB_BITUTIL_USE_MSVC_INTRINSICS)
417 // '_BitScanReverse(&index, 0)' sets 'index' to an unspecified value
418 unsigned long index;
419 return _BitScanReverse(&index, value)
420 ? k_BITS_PER_INT32 - 1 - index
421 : k_BITS_PER_INT32;
422#else
423 return privateNumLeadingUnsetBits(value);
424#endif
425}
426
427inline
428int BitUtil::numLeadingUnsetBits(unsigned long long value)
429{
430#if defined(BDLB_BITUTIL_USE_IBM_INTRINSICS)
431 return __cntlz8(value);
432#elif defined(BDLB_BITUTIL_USE_GNU_INTRINSICS)
433 // '__builtin_clzll(0)' is undefined
434 return __builtin_clzll(value | 1) + static_cast<int>(!value);
435#elif defined(BDLB_BITUTIL_USE_MSVC_INTRINSICS)
436 #if defined(BSLS_PLATFORM_CPU_64_BIT)
437 // '_BitScanReverse64(&index, 0)' sets 'index' to an unspecified value
438 unsigned long index;
439 return _BitScanReverse64(&index, value)
440 ? k_BITS_PER_INT64 - 1 - index
441 : k_BITS_PER_INT64;
442 #else
443 // '_BitScanReverse64' available only in 64bit target
444 return value > 0xffffffff
445 ? numLeadingUnsetBits(static_cast<unsigned int>(
446 value >> k_BITS_PER_INT32))
447 : numLeadingUnsetBits(static_cast<unsigned int>(value))
448 + k_BITS_PER_INT32;
449 #endif
450#else
451 return privateNumLeadingUnsetBits(value);
452#endif
453}
454
455inline
456int BitUtil::numLeadingUnsetBits(unsigned long value)
457{
458 return numLeadingUnsetBits(normalize(value));
459}
460
461inline
462int BitUtil::numTrailingUnsetBits(unsigned int value)
463{
464#if defined(BDLB_BITUTIL_USE_IBM_INTRINSICS)
465 return __cnttz4(value);
466#elif defined(BDLB_BITUTIL_USE_GNU_INTRINSICS)
467 enum {
468 k_INT32_MASK = k_BITS_PER_INT32 - 1
469 };
470 const unsigned int a = __builtin_ffs(value) - 1;
471 return (a & k_INT32_MASK) + (a >> k_INT32_MASK);
472
473 // Other possibility:
474 //..
475 // return (__builtin_ffs(value) - 1) ^ ((-!value) & ~k_BITS_PER_INT32);
476 //..
477#elif defined(BDLB_BITUTIL_USE_MSVC_INTRINSICS)
478 // '_BitScanForward(&index, 0)' sets 'index' to an unspecified value
479 unsigned long index;
480 return _BitScanForward(&index, value) ? index : k_BITS_PER_INT32;
481#else
482 return privateNumTrailingUnsetBits(value);
483#endif
484}
485
486inline
487int BitUtil::numTrailingUnsetBits(unsigned long long value)
488{
489#if defined(BDLB_BITUTIL_USE_IBM_INTRINSICS)
490 return __cnttz8(value);
491#elif defined(BDLB_BITUTIL_USE_GNU_INTRINSICS)
492 enum {
493 k_INT64_MASK = k_BITS_PER_INT64 - 1,
494 k_INT32_MASK = k_BITS_PER_INT32 - 1
495 };
496 const unsigned int a = __builtin_ffsll(value) - 1;
497 return (a & k_INT64_MASK) + (a >> k_INT32_MASK);
498
499 // Other possibility:
500 //..
501 // return (__builtin_ffsll(value) - 1) ^ ((-!value) & ~k_BITS_PER_INT64);
502 //..
503#elif defined(BDLB_BITUTIL_USE_MSVC_INTRINSICS)
504 #if defined(BSLS_PLATFORM_CPU_64_BIT)
505 // '_BitScanForward64(&index, 0)' sets 'index' to an unspecified value
506 unsigned long index;
507 return _BitScanForward64(&index, value) ? index : k_BITS_PER_INT64;
508 #else
509 // '_BitScanForward64' available only in 64bit target
510 return 0 != (value & 0xffffffff)
511 ? numTrailingUnsetBits(static_cast<unsigned int>(value))
512 : numTrailingUnsetBits(static_cast<unsigned int>(
513 value >> k_BITS_PER_INT32)) + k_BITS_PER_INT32;
514 #endif
515#else
516 return privateNumTrailingUnsetBits(value);
517#endif
518}
519
520inline
521int BitUtil::numTrailingUnsetBits(unsigned long value)
522{
523 return numTrailingUnsetBits(normalize(value));
524}
525
526inline
527unsigned int BitUtil::roundUp(unsigned int value, unsigned int boundary)
528{
529 BSLS_ASSERT(1 == numBitsSet(boundary));
530
531 return ((value - 1) | (boundary - 1)) + 1;
532}
533
534inline
535unsigned long long BitUtil::roundUp(unsigned long long value,
536 unsigned long long boundary)
537{
538 BSLS_ASSERT(1 == numBitsSet(boundary));
539
540 return ((value - 1) | (boundary - 1)) + 1;
541}
542
543inline
544unsigned long BitUtil::roundUp(unsigned long value, unsigned long boundary)
545{
546 return roundUp(normalize(value), normalize(boundary));
547}
548
549inline
550unsigned int BitUtil::roundUpToBinaryPower(unsigned int value)
551{
552 const int index = numLeadingUnsetBits(value - 1);
554 ? 1U << (k_BITS_PER_INT32 - index)
555 : 0;
556}
557
558inline
559unsigned long long BitUtil::roundUpToBinaryPower(unsigned long long value)
560{
561 const int index = numLeadingUnsetBits(value - 1);
563 ? 1ULL << (k_BITS_PER_INT64 - index)
564 : 0;
565}
566
567inline
568unsigned long BitUtil::roundUpToBinaryPower(unsigned long value)
569{
570 return roundUpToBinaryPower(normalize(value));
571}
572
573template <class TYPE>
574inline
576{
577 return static_cast<int>(CHAR_BIT * sizeof(TYPE));
578}
579
580inline
581unsigned int BitUtil::withBitCleared(unsigned int value, int index)
582{
583 BSLS_ASSERT( 0 <= index);
584 BSLS_ASSERT(index < k_BITS_PER_INT32);
585
586 return value & ~(1 << index);
587}
588
589inline
590unsigned long long BitUtil::withBitCleared(unsigned long long value, int index)
591{
592 BSLS_ASSERT( 0 <= index);
593 BSLS_ASSERT(index < k_BITS_PER_INT64);
594
595 return value & ~(1ULL << index);
596}
597
598inline
599unsigned long BitUtil::withBitCleared(unsigned long value, int index)
600{
601 return withBitCleared(normalize(value), index);
602}
603
604inline
605unsigned int BitUtil::withBitSet(unsigned int value, int index)
606{
607 BSLS_ASSERT( 0 <= index);
608 BSLS_ASSERT(index < k_BITS_PER_INT32);
609
610 return value | (1 << index);
611}
612
613inline
614unsigned long long BitUtil::withBitSet(unsigned long long value, int index)
615{
616 BSLS_ASSERT( 0 <= index);
617 BSLS_ASSERT(index < k_BITS_PER_INT64);
618
619 return value | (1ULL << index);
620}
621
622inline
623unsigned long BitUtil::withBitSet(unsigned long value, int index)
624{
625 return withBitSet(normalize(value), index);
626}
627
628} // close package namespace
629
630
631#endif
632
633// ----------------------------------------------------------------------------
634// Copyright 2014 Bloomberg Finance L.P.
635//
636// Licensed under the Apache License, Version 2.0 (the "License");
637// you may not use this file except in compliance with the License.
638// You may obtain a copy of the License at
639//
640// http://www.apache.org/licenses/LICENSE-2.0
641//
642// Unless required by applicable law or agreed to in writing, software
643// distributed under the License is distributed on an "AS IS" BASIS,
644// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
645// See the License for the specific language governing permissions and
646// limitations under the License.
647// ----------------------------- END-OF-FILE ----------------------------------
648
649/** @} */
650/** @} */
651/** @} */
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_PERFORMANCEHINT_PREDICT_LIKELY(expr)
Definition bsls_performancehint.h:451
Definition bdlb_algorithmworkaroundutil.h:74
Definition bdlb_bitutil.h:179
static int numTrailingUnsetBits(unsigned int value)
Definition bdlb_bitutil.h:462
static unsigned int withBitSet(unsigned int value, int index)
Definition bdlb_bitutil.h:605
static int numLeadingUnsetBits(unsigned int value)
Definition bdlb_bitutil.h:409
static unsigned int withBitCleared(unsigned int value, int index)
Definition bdlb_bitutil.h:581
static int log2(unsigned int value)
Definition bdlb_bitutil.h:338
static int numBitsSet(unsigned int value)
Definition bdlb_bitutil.h:360
static unsigned int roundUp(unsigned int value, unsigned int boundary)
Definition bdlb_bitutil.h:527
bsl::uint64_t uint64_t
Definition bdlb_bitutil.h:191
static unsigned int roundUpToBinaryPower(unsigned int value)
Definition bdlb_bitutil.h:550
bsl::uint32_t uint32_t
Definition bdlb_bitutil.h:190
static bool isBitSet(unsigned int value, int index)
Definition bdlb_bitutil.h:314
static int sizeInBits(INTEGER value=0)
Definition bslmf_conditional.h:120
Definition bslmf_integralconstant.h:244