summaryrefslogtreecommitdiffstats
path: root/src/tools/vppapigen/vppapigen_c.py
diff options
context:
space:
mode:
authorAndrew Yourtchenko <ayourtch@gmail.com>2019-03-19 14:52:29 +0100
committerPaul Vinciguerra <pvinci@vinciconsulting.com>2019-03-22 12:53:01 +0000
commit5c4b9f1efd1c5d9853a3c508e2a103d0f5679173 (patch)
treec99cd1497c254979c78c025f078dde505a7ca95f /src/tools/vppapigen/vppapigen_c.py
parentf7f13347bc8bc941a2d9aa847ddd88a758d65f71 (diff)
vppapigen: allow for enum size other than u32
Change-Id: If20d2fbab9b854b7db276c81918fdff6abcb8385 Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Diffstat (limited to 'src/tools/vppapigen/vppapigen_c.py')
-rw-r--r--src/tools/vppapigen/vppapigen_c.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/tools/vppapigen/vppapigen_c.py b/src/tools/vppapigen/vppapigen_c.py
index e189b024454..6c4ca356f3a 100644
--- a/src/tools/vppapigen/vppapigen_c.py
+++ b/src/tools/vppapigen/vppapigen_c.py
@@ -127,10 +127,19 @@ def typedefs(objs, aliases, filename):
tname = o.__class__.__name__
output += duplicate_wrapper_head(o.name)
if tname == 'Enum':
- output += "typedef enum {\n"
+ if o.enumtype == 'u32':
+ output += "typedef enum {\n"
+ else:
+ output += "typedef enum __attribute__((__packed__)) {\n"
+
for b in o.block:
output += " %s = %s,\n" % (b[0], b[1])
output += '} vl_api_%s_t;\n' % o.name
+ if o.enumtype != 'u32':
+ size1 = 'sizeof(vl_api_%s_t)' % o.name
+ size2 = 'sizeof(%s)' % o.enumtype
+ err_str = 'size of API enum %s is wrong' % o.name
+ output += 'STATIC_ASSERT(%s == %s, "%s");\n' % (size1, size2, err_str)
else:
if tname == 'Union':
output += "typedef VL_API_PACKED(union _vl_api_%s {\n" % o.name