[CRIU] [PATCH 07/18] sk-unix: Use native types in unix_sk_info

Cyrill Gorcunov gorcunov at gmail.com
Mon Apr 10 01:51:59 PDT 2017


On Mon, Apr 10, 2017 at 11:43:40AM +0300, Kirill Tkhai wrote:
> I'm not insist on u8:1, but in general there may be a profit:
> 
> $ cat a.c
> #include <stdio.h>
> #include <stdint.h>
> 
> struct A {
>         uint32_t a;
>         uint8_t b:1;
>         uint8_t c:1;
>         uint8_t d:1;
>         uint8_t e:1;
>         uint8_t f:1;
> };
> 
> struct B {
>         uint32_t a;
>         uint8_t b;
>         uint8_t c;
>         uint8_t d;
>         uint8_t e;
>         uint8_t f;
> };
> 
> 
> main(void)
> {
>         printf("%u %u\n", sizeof(struct A), sizeof(struct B));
> 
> }
> 
> $ ./a.out
> 
> 8 12

Packing may have a profit, no argues here, but at moment I would
rather stick with some native types for readability sake. Note
I'll have to update the code anyway so finally I think I'll
shrink the structures and put marks into one bitfield instead.


More information about the CRIU mailing list