Print this page
12259 CTF shouldn't assume enum size
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/test/util-tests/tests/ctf/test-enum.c
+++ new/usr/src/test/util-tests/tests/ctf/test-enum.c
1 1 /*
2 2 * This file and its contents are supplied under the terms of the
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
3 3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 4 * You may only use this file in accordance with the terms of version
5 5 * 1.0 of the CDDL.
6 6 *
7 7 * A full copy of the text of the CDDL should have accompanied this
8 8 * source. A copy of the CDDL is also available via the Internet at
9 9 * http://www.illumos.org/license/CDDL.
10 10 */
11 11
12 12 /*
13 - * Copyright (c) 2019, Joyent, Inc.
13 + * Copyright 2020 Joyent, Inc.
14 14 */
15 15
16 16 #include <stdint.h>
17 17
18 18 /*
19 19 * Basic sanity checking of enumerations, using specific numbers and arbitrary
20 20 * numbers.
21 21 */
22 22
23 23 enum ff6 {
24 24 TERRA,
25 25 LOCKE,
26 26 EDGAR,
27 27 SABIN,
28 28 CELES,
29 29 CYAN,
30 30 SHADOW,
31 31 GAU,
32 32 SETZER,
33 33 STRAGO,
34 34 RELM,
35 35 MOG,
36 36 GOGO,
37 37 UMARO,
38 38 LEO,
39 39 KEFKA
40 40 };
41 41
42 42 typedef enum ff10 {
43 43 TIDUS = -10,
44 44 YUNA = 23,
45 45 AURON = -34,
46 46 WAKA = 52,
47 47 LULU = INT32_MAX,
48 48 RIKKU = INT32_MIN,
49 49 KHIMARI = 0
50 50 } ff10_t;
51 51
52 52 /*
53 53 * The following enum is copy of the ddi_hp_cn_state_t enumeration which was
54 54 * previously incorrectly converted by the tools. Notably, we always assumed
55 55 * that the DWARF enum values were signed; however, in this case we needed to
56 56 * check for an unsigned version before a signed version, otherwise some of the
57 57 * entries below will have the wrong values.
58 58 */
59 59 typedef enum chrono {
60 60 CRONO = 0x1000,
61 61 LUCCA = 0x2000,
62 62 MARLE = 0x3000,
63 63 FROG = 0x4000,
64 64 ROBO = 0x5000,
↓ open down ↓ |
41 lines elided |
↑ open up ↑ |
65 65 AYLA = 0x6000,
66 66 MAGUS = 0x7000,
67 67 SCHALA = 0x8000,
68 68 LAVOS = 0x9000,
69 69 BALTHAZAR = 0xa000
70 70 } chrono_t;
71 71
72 72 enum ff6 ff6;
73 73 ff10_t ff10;
74 74 chrono_t trigger;
75 +
76 +/*
77 + * Normally enums are integer-sized, but a packed enum is a counter-example, as
78 + * is something like trace_alloc_type_t which can't fit in an int.
79 + */
80 +
81 +enum char_enum {
82 + CE1,
83 + CE2
84 +} __attribute__((packed)) ce;
85 +
86 +enum short_enum {
87 + SE1,
88 + SE2,
89 + SE3 = 255,
90 + SE4 = 256,
91 + SE5 = 257
92 +} __attribute__((packed)) se;
93 +
94 +enum int_enum {
95 + IE1,
96 + IE2,
97 + IE3 = 256,
98 + IE4 = 257
99 +} ie;
100 +
101 +enum ll_enum {
102 + LLE1 = -1ULL,
103 + LLE2 = -2ULL,
104 +} lle;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX