File tree Expand file tree Collapse file tree 2 files changed +47
-6
lines changed
thirdparty/bungee_library/upstream/src Expand file tree Collapse file tree 2 files changed +47
-6
lines changed Original file line number Diff line number Diff line change 4444 distribution : ${{env.JAVA_DISTRIBUTION}}
4545 java-version : ${{env.JAVA_VERSION}}
4646 - name : Setup Android SDK
47- uses : android-actions/setup-android@v2.0.10
47+ uses : android-actions/setup-android@v3
4848 - name : Setup Android NDK
4949 uses : nttld/setup-ndk@v1
5050 with :
7171 distribution : ${{env.JAVA_DISTRIBUTION}}
7272 java-version : ${{env.JAVA_VERSION}}
7373 - name : Setup Android SDK
74- uses : android-actions/setup-android@v2.0.10
74+ uses : android-actions/setup-android@v3
7575 - name : Setup Android NDK
7676 uses : nttld/setup-ndk@v1
7777 with :
@@ -102,7 +102,7 @@ jobs:
102102 distribution : ${{env.JAVA_DISTRIBUTION}}
103103 java-version : ${{env.JAVA_VERSION}}
104104 - name : Setup Android SDK
105- uses : android-actions/setup-android@v2.0.10
105+ uses : android-actions/setup-android@v3
106106 - name : Setup Android NDK
107107 uses : nttld/setup-ndk@v1
108108 with :
Original file line number Diff line number Diff line change 55
66#include " Assert.h"
77
8- #include < bit >
8+ #include < limits >
99#include < type_traits>
1010
1111namespace Bungee {
1212
13+ template <class T >
14+ constexpr int bit_width (T x) noexcept
15+ {
16+ static_assert (std::is_integral_v<T>, " T must be an integral type" );
17+ using U = std::make_unsigned_t <T>;
18+
19+ U u = static_cast <U>(x);
20+
21+ if (u == 0 )
22+ return 0 ;
23+
24+ int width = 0 ;
25+ while (u != 0 )
26+ {
27+ u >>= 1 ;
28+ ++width;
29+ }
30+
31+ return width;
32+ }
33+
34+ template <class T >
35+ constexpr int countr_zero (T x) noexcept
36+ {
37+ static_assert (std::is_integral_v<T>, " T must be an integral type" );
38+ using U = std::make_unsigned_t <T>;
39+ U u = static_cast <U>(x);
40+
41+ if (u == 0 )
42+ return std::numeric_limits<U>::digits; // number of bits in type
43+
44+ int count = 0 ;
45+ while ((u & 1 ) == 0 )
46+ {
47+ u >>= 1 ;
48+ ++count;
49+ }
50+
51+ return count;
52+ }
53+
1354template <bool floor = false >
1455static inline int log2 (unsigned x)
1556{
@@ -18,9 +59,9 @@ static inline int log2(unsigned x)
1859
1960 int y;
2061 if constexpr (floor)
21- y = std:: bit_width (x) - 1 ;
62+ y = bit_width (x) - 1 ;
2263 else
23- y = std:: countr_zero (x);
64+ y = countr_zero (x);
2465
2566 BUNGEE_ASSERT1 (floor ? (1 << y <= x && x < 2 << y) : (x == 1 << y));
2667 return y;
You can’t perform that action at this time.
0 commit comments