[Spice-devel] [PATCH] change marshalling macros to consider alignment of types

Christophe Fergeau cfergeau at redhat.com
Fri Dec 11 05:59:24 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"

>          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' ?

I'll let Anton tell us if this helps with his situation or not before
looking closer at that patch

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20151211/8d4e4fcd/attachment.sig>


More information about the Spice-devel mailing list