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
↓ 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 {
↓ 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