misc: add clz wrapper for builtin

* spot/bricks/brick-bitlevel, spot/misc/Makefile.am,
spot/misc/bitset.hh, spot/misc/clz.cc,
spot/misc/clz.hh, spot/misc/fixpool.hh: here.
This commit is contained in:
Etienne Renault 2018-07-13 09:15:38 +00:00
parent 01cceef29a
commit 69457e957b
6 changed files with 158 additions and 8 deletions

View file

@ -20,8 +20,7 @@
#pragma once
#include <spot/misc/common.hh>
#include <climits>
#include <cstddef>
#include <spot/misc/clz.hh>
#if SPOT_DEBUG && defined(HAVE_VALGRIND_MEMCHECK_H)
#include <valgrind/memcheck.h>
@ -59,8 +58,7 @@ namespace spot
return size;
// small numbers are best aligned to the next power of 2
else if (size < alignof(std::max_align_t))
return size_t{1} << (CHAR_BIT*sizeof(size_t) -
__builtin_clz(size));
return size_t{1} << (CHAR_BIT*sizeof(size_t) - clz(size));
else
{
size_t mask = alignof(std::max_align_t)-1;