File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -25,3 +25,12 @@ static inline int ilog2(int x)
2525 */
2626#define RANGE_CHECK (x , minx , size ) \
2727 ((int32_t) ((x - minx) | (minx + size - 1 - x)) >= 0)
28+
29+ /* Packed macro */
30+ #if defined(__GNUC__ ) || defined(__clang__ )
31+ #define PACKED (name ) name __attribute__((packed))
32+ #elif defined(_MSC_VER )
33+ #define PACKED (name ) __pragma(pack(push, 1)) name __pragma(pack(pop))
34+ #else /* unsupported compilers */
35+ #define PACKED (name )
36+ #endif
Original file line number Diff line number Diff line change 2626
2727#define PRIV (x ) ((struct virtio_blk_config *) x->priv)
2828
29- struct virtio_blk_config {
29+ PACKED ( struct virtio_blk_config {
3030 uint64_t capacity ;
3131 uint32_t size_max ;
3232 uint32_t seg_max ;
@@ -55,14 +55,14 @@ struct virtio_blk_config {
5555 uint32_t max_write_zeroes_seg ;
5656 uint8_t write_zeroes_may_unmap ;
5757 uint8_t unused1 [3 ];
58- } __attribute__(( packed ) );
58+ });
5959
60- struct vblk_req_header {
60+ PACKED ( struct vblk_req_header {
6161 uint32_t type ;
6262 uint32_t reserved ;
6363 uint64_t sector ;
6464 uint8_t status ;
65- } __attribute__(( packed ) );
65+ });
6666
6767static struct virtio_blk_config vblk_configs [VBLK_DEV_CNT_MAX ];
6868static int vblk_dev_cnt = 0 ;
Original file line number Diff line number Diff line change 3030
3131enum { VNET_QUEUE_RX = 0 , VNET_QUEUE_TX = 1 };
3232
33- struct virtio_net_config {
33+ PACKED ( struct virtio_net_config {
3434 uint8_t mac [6 ];
3535 uint16_t status ;
3636 uint16_t max_virtqueue_pairs ;
3737 uint16_t mtu ;
38- } __attribute__(( packed ) );
38+ });
3939
4040static struct virtio_net_config vnet_configs [VNET_DEV_CNT_MAX ];
4141static int vnet_dev_cnt = 0 ;
You can’t perform that action at this time.
0 commit comments