Initialize a new read frame. * 'n' is the number of cells for the read frame. * 'from' is a pointer to the beginning of the new slice for the array of UWORDS to hold the frame's cells. * * Precondition: UWORD from[ROUND_UWORD(n)]; */
| 29 | * Precondition: UWORD from[ROUND_UWORD(n)]; |
| 30 | */ |
| 31 | static inline frameItem initReadFrame(size_t n, UWORD* from) { |
| 32 | const size_t len = ROUND_UWORD(n); |
| 33 | /* '(1U * len) * UWORD_BIT - n' equals the number of padding bits in a frame of size 'n'. |
| 34 | * Note that even if (len * UWORD_BIT) overflows, |
| 35 | * (1) We have ensured an unsigned computation by multiplying by 1U so the behaviour is well-defined. |
| 36 | * (2) after subtracting 'n' we are left with a value in the range 0 .. UWORD-BIT - 1. |
| 37 | */ |
| 38 | return (frameItem){ .edge = from + len, .offset = (1U * len) * UWORD_BIT - n }; |
| 39 | } |
| 40 | |
| 41 | /* Initialize a new write frame. |
| 42 | * 'n' is the number of cells for the write frame. |
no outgoing calls