Are the padding rules supposed to be consistent between the compiler and
dtrace on x64?


# cat /tmp/s.d 
typedef struct _my_data {
        uint32_t a;
        uint32_t b;
        uint64_t c;
} my_data;

typedef struct _more_data {
    uint32_t x;
    my_data y;
} more_data;

BEGIN {
        printf("my_data: %d\n", sizeof(my_data));
        printf("more_data: %d\n", sizeof(more_data));
        printf("offset: %d\n", offsetof(more_data, y));
        exit(0);
}

# cat /tmp/s.d 
typedef struct _my_data {
        uint32_t a;
        uint32_t b;
        uint64_t c;
} my_data;

typedef struct _more_data {
    uint32_t x;
    my_data y;
} more_data;

BEGIN {
        printf("my_data: %d\n", sizeof(my_data));
        printf("more_data: %d\n", sizeof(more_data));
        printf("offset: %d\n", offsetof(more_data, y));
        exit(0);
}

$ cc -m64 /tmp/x.c -o /tmp/x
$ /tmp/x
my_data: 16
more_data: 24
offset: 8

# dtrace -qs /tmp/s.d
my_data: 16
more_data: 20
offset: 4


Bug?

_______________________________________________
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org

Reply via email to