Also, any reason why those could not be static inline (and turned into something like get_u16, put_u16, ...)? Are they something coming from imported code, which we do not want to change name?
On Sat, Nov 28, 2015 at 7:19 AM, Davide Libenzi <[email protected]> wrote: > On Fri, Nov 27, 2015 at 9:16 AM, barret rhoden <[email protected]> > wrote: > >> > Question. Should I force the payloads to be strings, or should I use >> > binary? Example: >> > >> > struct req1 { >> > uint32_t size; >> > uint32_t req; >> > uint32_t cnt; >> > uint64_t something[NMAX]; >> > }; >> >> You could also use a binary, arch-independent format. That struct has >> endianness assumptions. But you can still use a binary format of your >> choosing. >> >> For another example, in Plan 9 (and Akaros), when we read() a >> directory, we get a byte stream of format 'M'. In Akaros, we convert >> those to structs for our own processing (e.g. convM2kdirent(), which >> you can see in a few places in kern/src/ns/sysfile.c). There are >> similar ones, e.g. convM2D(). >> >> There's a bunch of helpers to convert from bytes to fields, e.g. >> GBIT8() and write fields as bytes (PBIT8()). >> >> What I'd do is come up with what you want the structs to look like, >> then write little conv() helpers. For example: >> >> conv_req1_to_X(struct req1 *req1, uint8_t *buf, size_t len) >> { >> PBIT32(buf, req1->size); >> buf += BIT32SZ; >> PBIT32(buf, req1->req); >> buf += BIT32SZ; >> PBIT32(buf, req1->cnt); >> buf += BIT32SZ; >> for (int i = 0; i < NMAX; i++) { >> PBIT64(buf, req1->something); >> buf += BIT64SZ; >> } >> } >> >> (written hastily, checkout convD2M for a better example). >> > > These interfaces though, are not exposed to userspace, so I will have to > move them into a dedicated ros/ file, I guess? > > -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
