ref: eef0fe67ee4bb8c254f0f9e61c24ef5d34d05a4f
dir: /tests/testpkdstruct.c/
#include <u.h> #include <libc.h> typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int u32; typedef unsigned long long u64; typedef struct Spanid Spanid; #pragma pack on struct Spanid /* Spanid identifier */ { u64 blkno; /* starting block number */ u16 len; /* number of blocks */ }; #pragma pack off Spanid t[10] = {0}; void save(void) { t[0].blkno = 888888; t[0].len = 9; } Spanid get(int i) { print("get t[i] blkno %llud len %d\n", t[i].blkno, t[i].len); return t[i]; } void put(Spanid s) { print("put s blkno %llud len %d\n", s.blkno, s.len); t[1].blkno = s.blkno; t[1].len = s.len; } void main(int, void**) { Spanid s; save(); s = get(0); print(" blkno %llud len %d\n", s.blkno, s.len); s.blkno = 77777; s.len = 8; put(s); s.len = 10; s = get(1); print(" blkno %llud len %d\n", s.blkno, s.len); exits(0); }