From 5497f08e5e4dc400f4425519a87bbe388d68336b Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 23 May 2013 21:17:29 +0200 Subject: [PATCH] hpkg attribute tags: use 7 bits for attribute ID ATM the 6 bits suffice, but there isn't that much headroom. --- headers/private/package/hpkg/HPKGDefsPrivate.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/headers/private/package/hpkg/HPKGDefsPrivate.h b/headers/private/package/hpkg/HPKGDefsPrivate.h index cfc614366a..3966cd6a1b 100644 --- a/headers/private/package/hpkg/HPKGDefsPrivate.h +++ b/headers/private/package/hpkg/HPKGDefsPrivate.h @@ -71,11 +71,11 @@ struct hpkg_repo_header { // attribute tag arithmetics -// (using 6 bits for id, 3 for type, 1 for hasChildren and 2 for encoding) +// (using 7 bits for id, 3 for type, 1 for hasChildren and 2 for encoding) static inline uint16 compose_attribute_tag(uint16 id, uint16 type, uint16 encoding, bool hasChildren) { - return ((encoding << 10) | (uint16(hasChildren ? 1 : 0) << 9) | (type << 6) + return ((encoding << 11) | (uint16(hasChildren ? 1 : 0) << 10) | (type << 7) | id) + 1; } @@ -84,28 +84,28 @@ compose_attribute_tag(uint16 id, uint16 type, uint16 encoding, bool hasChildren) static inline uint16 attribute_tag_encoding(uint16 tag) { - return ((tag - 1) >> 10) & 0x3; + return ((tag - 1) >> 11) & 0x3; } static inline bool attribute_tag_has_children(uint16 tag) { - return (((tag - 1) >> 9) & 0x1) != 0; + return (((tag - 1) >> 10) & 0x1) != 0; } static inline uint16 attribute_tag_type(uint16 tag) { - return ((tag - 1) >> 6) & 0x7; + return ((tag - 1) >> 7) & 0x7; } static inline uint16 attribute_tag_id(uint16 tag) { - return (tag - 1) & 0x3f; + return (tag - 1) & 0x7f; }