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)
25
25
*/
26
26
#define RANGE_CHECK (x , minx , size ) \
27
27
((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 26
26
27
27
#define PRIV (x ) ((struct virtio_blk_config *) x->priv)
28
28
29
- struct virtio_blk_config {
29
+ PACKED ( struct virtio_blk_config {
30
30
uint64_t capacity ;
31
31
uint32_t size_max ;
32
32
uint32_t seg_max ;
@@ -55,14 +55,14 @@ struct virtio_blk_config {
55
55
uint32_t max_write_zeroes_seg ;
56
56
uint8_t write_zeroes_may_unmap ;
57
57
uint8_t unused1 [3 ];
58
- } __attribute__(( packed ) );
58
+ });
59
59
60
- struct vblk_req_header {
60
+ PACKED ( struct vblk_req_header {
61
61
uint32_t type ;
62
62
uint32_t reserved ;
63
63
uint64_t sector ;
64
64
uint8_t status ;
65
- } __attribute__(( packed ) );
65
+ });
66
66
67
67
static struct virtio_blk_config vblk_configs [VBLK_DEV_CNT_MAX ];
68
68
static int vblk_dev_cnt = 0 ;
Original file line number Diff line number Diff line change 30
30
31
31
enum { VNET_QUEUE_RX = 0 , VNET_QUEUE_TX = 1 };
32
32
33
- struct virtio_net_config {
33
+ PACKED ( struct virtio_net_config {
34
34
uint8_t mac [6 ];
35
35
uint16_t status ;
36
36
uint16_t max_virtqueue_pairs ;
37
37
uint16_t mtu ;
38
- } __attribute__(( packed ) );
38
+ });
39
39
40
40
static struct virtio_net_config vnet_configs [VNET_DEV_CNT_MAX ];
41
41
static int vnet_dev_cnt = 0 ;
You can’t perform that action at this time.
0 commit comments