1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * Copyright 2021 oxide Computer Company 14 */ 15 16 /* 17 * Test various awkward bitfield cases. In particular, where we have things that 18 * don't cross byte alignment. 19 */ 20 21 #include <stdint.h> 22 23 typedef struct broken { 24 uint32_t brk_a:3; 25 uint32_t brk_b:2; 26 uint32_t brk_c:1; 27 uint32_t brk_d:1; 28 uint32_t brk_e:1; 29 uint32_t brk_f:1; 30 uint32_t brk_g:3; 31 uint32_t brk_h:3; 32 uint32_t brk_i:5; 33 uint32_t brk_j:4; 34 uint32_t brk_k:6; 35 uint32_t brk_l:1; 36 uint32_t brk_m:1; 37 } broken_t; 38 39 broken_t first = { 40 .brk_a = 3, 41 .brk_b = 3, 42 .brk_c = 0, 43 .brk_d = 1, 44 .brk_e = 1, 45 .brk_f = 1, 46 .brk_g = 3, 47 .brk_h = 5, 48 .brk_i = 3, 49 .brk_j = 9, 50 .brk_k = 19, 51 .brk_l = 0, 52 .brk_m = 1 53 }; 54 55 typedef struct broken6491 { 56 unsigned short a:1; 57 unsigned short b:8; 58 unsigned short c:3; 59 unsigned short d:2; 60 unsigned short e:1; 61 unsigned short f:1; 62 } broken6491_t; 63 64 broken6491_t second = { 65 .a = 1, 66 .b = 2, 67 .e = 1 68 }; 69 70 int 71 main(void) 72 { 73 return (0); 74 } 75