Debian Codegraph @

src/frozendict/c_src/3_6/cpython_src/other.c

raw
1 static const unsigned int BitLengthTable[32] = {
2 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
3 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
4 };
5
6 unsigned int _Py_bit_length(unsigned long d) {
7 unsigned int d_bits = 0;
8 while (d >= 32) {
9 d_bits += 6;
10 d >>= 6;
11 }
12 d_bits += BitLengthTable[d];
13 return d_bits;
14 }
15
16 #define Py_IS_TYPE(op, type) (Py_TYPE(op) == type)
17
18 #define PySet_CheckExact(op) Py_IS_TYPE(op, &PySet_Type)
19
20 #if defined(RANDALL_WAS_HERE)
21 # define Py_UNREACHABLE() \
22 Py_FatalError( \
23 "If you're seeing this, the code is in what I thought was\n" \
24 "an unreachable state.\n\n" \
25 "I could give you advice for what to do, but honestly, why\n" \
26 "should you trust me? I clearly screwed this up. I'm writing\n" \
27 "a message that should never appear, yet I know it will\n" \
28 "probably appear someday.\n\n" \
29 "On a deep level, I know I'm not up to this task.\n" \
30 "I'm so sorry.\n" \
31 "https://xkcd.com/2200")
32 #elif defined(Py_DEBUG)
33 # define Py_UNREACHABLE() \
34 Py_FatalError( \
35 "We've reached an unreachable state. Anything is possible.\n" \
36 "The limits were in our heads all along. Follow your dreams.\n" \
37 "https://xkcd.com/2200")
38 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
39 # define Py_UNREACHABLE() __builtin_unreachable()
40 #elif defined(__clang__) || defined(__INTEL_COMPILER)
41 # define Py_UNREACHABLE() __builtin_unreachable()
42 #elif defined(_MSC_VER)
43 # define Py_UNREACHABLE() __assume(0)
44 #else
45 # define Py_UNREACHABLE() \
46 Py_FatalError("Unreachable C code path reached")
47 #endif
48
49 #if defined(__GNUC__) \
50 && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))
51 #define _Py_HOT_FUNCTION __attribute__((hot))
52 #else
53 #define _Py_HOT_FUNCTION
54 #endif
55