[Spice-devel] [PATCH] change marshalling macros to consider alignment of types
Frediano Ziglio
fziglio at redhat.com
Fri Dec 11 06:22:18 PST 2015
>
> More details in the log as to when this is needed would be useful.
>
> On Fri, Dec 11, 2015 at 01:36:41PM +0000, Frediano Ziglio wrote:
> > ---
> > python_modules/demarshal.py | 30 ++++++++++++++++++++++--------
> > 1 file changed, 22 insertions(+), 8 deletions(-)
> >
> > diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
> > index 209eafc..743b0d8 100644
> > --- a/python_modules/demarshal.py
> > +++ b/python_modules/demarshal.py
> > @@ -40,20 +40,34 @@ def write_parser_helpers(writer):
> >
> > writer = writer.function_helper()
> >
> > + for sign in ["", "u"]:
> > + type = "%sint8" % sign
> > + writer.macro("read_%s" % type, "ptr", "(*((%s_t *)(ptr)))" % type)
> > + writer.macro("write_%s" % type, "ptr, val", "(*((%s_t *)(ptr))) =
> > val" % type)
> > writer.writeln("#ifdef WORDS_BIGENDIAN")
> > - for size in [8, 16, 32, 64]:
> > + for size in [16, 32, 64]:
>
> I don't think this hunk is strictly related to the alignment change, it
> could go in a "Don't wrap 8 bit accesses in unneeded #ifdef
> WORDS_BIGENDIAN"
>
Yes, just helps reducing code generated.
> > for sign in ["", "u"]:
> > utype = "uint%d" % (size)
> > type = "%sint%d" % (sign, size)
> > swap = "SPICE_BYTESWAP%d" % size
> > - if size == 8:
> > - writer.macro("read_%s" % type, "ptr", "(*((%s_t *)(ptr)))"
> > % type)
> > - writer.macro("write_%s" % type, "ptr, val", "*(%s_t
> > *)(ptr) = val" % (type))
> > - else:
> > - writer.macro("read_%s" % type, "ptr", "((%s_t)%s(*((%s_t
> > *)(ptr))))" % (type, swap, utype))
> > - writer.macro("write_%s" % type, "ptr, val", "*(%s_t
> > *)(ptr) = %s((%s_t)val)" % (utype, swap, utype))
> > + writer.macro("read_%s" % type, "ptr", "((%s_t)%s(*((%s_t
> > *)(ptr))))" % (type, swap, utype))
> > + writer.macro("write_%s" % type, "ptr, val", "*(%s_t *)(ptr) =
> > %s((%s_t)val)" % (utype, swap, utype))
> > + writer.writeln("#elif __GNUC__ > 3")
> > + struct = "pkg_struct"
>
> Why is it called 'pkg_struct' ?
>
Was a struct before... and few fantasy at the moment :)
> I'll let Anton tell us if this helps with his situation or not before
> looking closer at that patch
>
> Christophe
>
I should have put an "RFC", this patch was intended to be tested by Anton
(it's in reply to Anton's thread).
Note that this patch does not consider architectures with big endian and
unaligned access problems.
Frediano
More information about the Spice-devel
mailing list