def nla_get_u64(nla): """Return value of 64 bit integer attribute as an int(). https://github.com/thom311/libnl/blob/libnl3_2_25/lib/attr.c#L649 Positional arguments: nla -- 64 bit integer attribute (nlattr class instance). Returns: Payload as an int(). """ tmp = c_uint64(0) if nla and nla_len(nla) >= sizeof(tmp): tmp = c_uint64.from_buffer(nla_data(nla)[:SIZEOF_U64]) return int(tmp.value)
def test_sizes(): """Test sizeof().""" assert 1 == sizeof(c_byte) assert 4 == sizeof(c_int) assert 1 == sizeof(c_int8) assert 8 if sys.maxsize > 2**32 else 4 == sizeof( c_long) # Platform dependant. assert 8 == sizeof(c_longlong) assert 2 == sizeof(c_uint16) assert 4 == sizeof(c_uint32) assert 8 == sizeof(c_uint64) assert 1 == sizeof(c_uint8) assert 1 == sizeof(c_ubyte) assert 4 == sizeof(c_uint) assert 8 if sys.maxsize > 2**32 else 4 == sizeof( c_ulong) # Platform dependant. assert 8 == sizeof(c_ulonglong) assert 2 == sizeof(c_ushort)
def test_sizes(): """Test sizeof().""" assert 1 == sizeof(c_byte) assert 4 == sizeof(c_int) assert 1 == sizeof(c_int8) assert 8 if sys.maxsize > 2 ** 32 else 4 == sizeof(c_long) # Platform dependant. assert 8 == sizeof(c_longlong) assert 2 == sizeof(c_uint16) assert 4 == sizeof(c_uint32) assert 8 == sizeof(c_uint64) assert 1 == sizeof(c_uint8) assert 1 == sizeof(c_ubyte) assert 4 == sizeof(c_uint) assert 8 if sys.maxsize > 2 ** 32 else 4 == sizeof(c_ulong) # Platform dependant. assert 8 == sizeof(c_ulonglong) assert 2 == sizeof(c_ushort)