Sunday, 22 March 2020

libnspsl -- remove bitfields

This patch will probably be something we need to carry forward
in our own port, but I'm going to submit it for discussion anyways.

Currently, the plan 9 C compilers do *not* support static initialization
of bitfields, so we need to do somethign about that. We can replace them
with an enum and flags, or we can drop them entirely. This patch does
the latter.

If you'd be willing to take some other method of removing bitfields, I'd
be happy to implement it and reduce the diff.

--- /mnt/git/object/e41d7b3c868309e0704e01e841cc80da72dd8157/tree/src/psl.inc Mon Jun 24 03:47:46 2019
+++ src/psl.inc Sun Mar 22 14:53:33 2020
@@ -9,9 +9,9 @@
*/
union pnode {
struct {
- unsigned int idx:24; /**< index of domain element in string table */
- unsigned int len:6; /**< length of domain element in string table */
- unsigned int children:1; /**< has children */
+ unsigned int idx; /**< index of domain element in string table */
+ unsigned char len; /**< length of domain element in string table */
+ unsigned char children; /**< has children */
} label;
struct {
uint16_t index; /**< index of first child node */
@@ -28,8 +28,8 @@ enum stab_entities {
* Huffman coding node
*/
struct hnode {
- uint8_t term:1; /**< non zero if the node terminates a code */
- uint8_t value:7; /**< value in node */
+ uint8_t term; /**< non zero if the node terminates a code */
+ uint8_t value; /**< value in node */
};

/**

No comments:

Post a Comment