summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2020-07-07 16:32:22 +0200
committerDamjan Marion <dmarion@me.com>2020-07-16 13:21:27 +0000
commit5e60c17f49082b7731778e81b58177177a31b58f (patch)
treeeb38ab606efad2bb06adf92fc9c9b161c6b111ab
parente5f0050c7a5d411f96af6401797529d58825e2af (diff)
vppinfra: enable STATIC_ASSERT with clang
For some reason clang does not support &((struct foo*)0)->field in static assertion contrary to gcc. Use offsetof() macro implementation provided by both compilers instead. Type: fix Change-Id: I3311cdd29c5861e45dc0ef92f2bbd66242ca73b8 Signed-off-by: Benoît Ganne <bganne@cisco.com>
-rw-r--r--src/vppinfra/clib.h5
-rw-r--r--src/vppinfra/error_bootstrap.h4
2 files changed, 3 insertions, 6 deletions
diff --git a/src/vppinfra/clib.h b/src/vppinfra/clib.h
index be21cad604b..6c82f869653 100644
--- a/src/vppinfra/clib.h
+++ b/src/vppinfra/clib.h
@@ -38,6 +38,7 @@
#ifndef included_clib_h
#define included_clib_h
+#include <stddef.h>
#include <vppinfra/config.h>
#ifdef __x86_64__
@@ -66,8 +67,8 @@
#define ARRAY_LEN(x) (sizeof (x)/sizeof (x[0]))
#define _STRUCT_FIELD(t,f) (((t *) 0)->f)
-#define STRUCT_OFFSET_OF(t,f) ((uword) & _STRUCT_FIELD (t, f))
-#define STRUCT_BIT_OFFSET_OF(t,f) (BITS(u8) * (uword) & _STRUCT_FIELD (t, f))
+#define STRUCT_OFFSET_OF(t,f) offsetof(t, f)
+#define STRUCT_BIT_OFFSET_OF(t,f) (BITS(u8) * STRUCT_OFFSET_OF (t, f))
#define STRUCT_SIZE_OF(t,f) (sizeof (_STRUCT_FIELD (t, f)))
#define STRUCT_BITS_OF(t,f) (BITS (_STRUCT_FIELD (t, f)))
#define STRUCT_ARRAY_LEN(t,f) ARRAY_LEN (_STRUCT_FIELD (t, f))
diff --git a/src/vppinfra/error_bootstrap.h b/src/vppinfra/error_bootstrap.h
index 8dbbc7f359d..185f4c6c4af 100644
--- a/src/vppinfra/error_bootstrap.h
+++ b/src/vppinfra/error_bootstrap.h
@@ -108,11 +108,7 @@ do { \
} while (0)
#endif /* __COVERITY */
-#if defined(__clang__)
-#define STATIC_ASSERT(truth,...)
-#else
#define STATIC_ASSERT(truth,...) _Static_assert(truth, __VA_ARGS__)
-#endif
#define STATIC_ASSERT_SIZEOF(d, s) \
STATIC_ASSERT (sizeof (d) == s, "Size of " #d " must be " # s " bytes")
a id='n13' href='#n13'>13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
#cloud-config
autoinstall:
  version: 1
  apt:
    geoip: true
    preserve_sources_list: false
    primary:
    - arches: [amd64, i386]
      uri: http://ca.archive.ubuntu.com/ubuntu
    - arches: [default]
      uri: http://ports.ubuntu.com/ubuntu-ports
  identity:
    hostname: s94-t39-sut2
    password: $6$Y62lhMGJD8YNzmJn$H4DSqjrwFp5WN3tOvIrF.g/G2duOV76zXHAmaA/RU8jfT8H8sDumLQe/Q.EmI5pjPv7dzgI8j9BQPWes7efBK0
    realname: testuser
    username: testuser
  keyboard:
    layout: us
    toggle: null
    variant: ''
  locale: en_US.UTF-8
  network:
    ethernets:
      eno1:
        addresses: [ 10.30.51.94/24 ]
        dhcp4: false
        gateway4: 10.30.51.1
        nameservers:
          addresses: [ 1.1.1.1, 8.8.8.8 ]
    version: 2
  packages:
    - python3
  refresh-installer:
    update: no
  ssh:
    allow-pw: true
    authorized-keys: []
    install-server: true
  storage:
    config:
    - grub_device: false
      id: disk-sda
      path: /dev/sda
      ptable: gpt
      preserve: false
      type: disk
      wipe: superblock-recursive
    - device: disk-sda
      grub_device: true
      id: partition-0
      flag: boot
      number: 1
      preserve: false
      size: 536870912
      type: partition
      wipe: superblock
    - id: format-0
      fstype: fat32
      preserve: false
      type: format
      volume: partition-0
    - device: disk-sda
      flag: ''
      grub_device: false
      id: partition-1
      number: 2
      preserve: false
      size: -1
      type: partition
      wipe: superblock
    - fstype: ext4
      id: format-1
      preserve: false
      type: format
      volume: partition-1
    - device: format-1
      id: mount-1
      path: /
      type: mount
    - device: format-0
      id: mount-0
      path: /boot/efi
      type: mount