[Spice-devel] [PATCH spice-common] Create common header for demarshallers declarations
Frediano Ziglio
fziglio at redhat.com
Fri Oct 12 12:04:52 UTC 2018
Code generated for demarshallers define and declare some types and
functions.
However these types and functions are also declared separately in
other headers resulting in potential ABI mismatch if the different
declarations do not match.
Using a common header shared between generated code and code using
these functions prevent potentially multiple different declarations.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
common/Makefile.am | 1 +
common/client_demarshallers.h | 8 +-------
common/demarshallers.h | 31 +++++++++++++++++++++++++++++++
common/meson.build | 1 +
python_modules/demarshal.py | 1 +
5 files changed, 35 insertions(+), 7 deletions(-)
create mode 100644 common/demarshallers.h
Patch apply on top of cleanup series.
Maybe would be good to remove client_demarshallers.h and put
function declarations (spice_get_server_channel_parser and
spice_get_client_channel_parser) inside demarshallers.h ?
diff --git a/common/Makefile.am b/common/Makefile.am
index d8e30d1..9f9ec92 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -21,6 +21,7 @@ libspice_common_la_SOURCES = \
backtrace.h \
canvas_utils.c \
canvas_utils.h \
+ demarshallers.h \
draw.h \
lines.c \
lines.h \
diff --git a/common/client_demarshallers.h b/common/client_demarshallers.h
index 43c7e7d..2f4b852 100644
--- a/common/client_demarshallers.h
+++ b/common/client_demarshallers.h
@@ -17,18 +17,12 @@
#ifndef _H_DEMARSHAL
#define _H_DEMARSHAL
-#include <stddef.h>
-#include <spice/macros.h>
+#include <common/demarshallers.h>
SPICE_BEGIN_DECLS
-typedef void (*message_destructor_t)(uint8_t *message);
-typedef uint8_t * (*spice_parse_channel_func_t)(uint8_t *message_start, uint8_t *message_end, uint16_t message_type, int minor,
- size_t *size_out, message_destructor_t *free_message);
-
spice_parse_channel_func_t spice_get_server_channel_parser(uint32_t channel, unsigned int *max_message_type);
SPICE_END_DECLS
#endif
-
diff --git a/common/demarshallers.h b/common/demarshallers.h
new file mode 100644
index 0000000..85a7fd3
--- /dev/null
+++ b/common/demarshallers.h
@@ -0,0 +1,31 @@
+/*
+ Copyright (C) 2010 Red Hat, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef COMMON_DEMARSHALLERS_H_
+#define COMMON_DEMARSHALLERS_H_
+
+#include <stddef.h>
+#include <spice/macros.h>
+
+SPICE_BEGIN_DECLS
+
+typedef void (*message_destructor_t)(uint8_t *message);
+typedef uint8_t * (*spice_parse_channel_func_t)(uint8_t *message_start, uint8_t *message_end, uint16_t message_type, int minor,
+ size_t *size_out, message_destructor_t *free_message);
+
+SPICE_END_DECLS
+
+#endif
diff --git a/common/meson.build b/common/meson.build
index 36ba43b..0234be5 100644
--- a/common/meson.build
+++ b/common/meson.build
@@ -6,6 +6,7 @@ spice_common_sources = [
'backtrace.h',
'canvas_utils.c',
'canvas_utils.h',
+ 'demarshallers.h',
'draw.h',
'lines.c',
'lines.h',
diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index 6fe3c66..36213b1 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -1229,6 +1229,7 @@ def write_includes(writer):
writer.writeln("#include <spice/protocol.h>")
writer.writeln("#include <spice/macros.h>")
writer.writeln('#include <common/mem.h>')
+ writer.writeln('#include <common/demarshallers.h>')
writer.newline()
writer.writeln("#ifdef _MSC_VER")
writer.writeln("#pragma warning(disable:4101)")
--
2.17.1
More information about the Spice-devel
mailing list