Commit Graph

655 Commits

Author SHA1 Message Date
Frediano Ziglio
c208ca85cd ring: Remove __ring_remove function
Is just used by ring_remove, no reason to have it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <dinechin@redhat.com>
2017-11-07 13:11:19 +00:00
Frediano Ziglio
c2f2096d90 test-marshallers: Test demarshalling
Generate demarshallers code and check it too.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-25 16:13:27 +01:00
Frediano Ziglio
c25c75b552 test-marshallers: Use unaligned structure
Allows to test for bad performance on some systems.
For instance on ARMv6/ARMv7 which does not support by default
64 bit unaligned read/write this can be checked on Linux
using /proc/cpu/alignment file.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-25 16:13:18 +01:00
Frediano Ziglio
74e50b57ae Make the compiler work out better way to write unaligned memory
Instead of assuming that the system can safely do unaligned access
to memory use packed structures to allow the compiler generate
best code possible.
A packed structure tells the compiler to not leave padding inside it
and that the structure can be unaligned so any field can be unaligned
having to generate proper access code based on architecture.
For instance ARM7 can use unaligned access but not for 64 bit
numbers (currently these accesses are emulated by Linux kernel
with obvious performance consequences).

This changes the current methods from:

#ifdef WORDS_BIGENDIAN
#define read_uint32(ptr) ((uint32_t)SPICE_BYTESWAP32(*((uint32_t *)(ptr))))
#define write_uint32(ptr, val) *(uint32_t *)(ptr) = SPICE_BYTESWAP32((uint32_t)val)
#else
#define read_uint32(ptr) (*((uint32_t *)(ptr)))
#define write_uint32(ptr, val) (*((uint32_t *)(ptr))) = val
#endif

to:

#include <spice/start-packed.h>
typedef struct SPICE_ATTR_PACKED {
    uint32_t v;
} uint32_unaligned_t;
#include <spice/end-packed.h>

#ifdef WORDS_BIGENDIAN
#define read_uint32(ptr) ((uint32_t)SPICE_BYTESWAP32(((uint32_unaligned_t *)(ptr))->v))
#define write_uint32(ptr, val) ((uint32_unaligned_t *)(ptr))->v = SPICE_BYTESWAP32((uint32_t)val)
#else
#define read_uint32(ptr) (((uint32_unaligned_t *)(ptr))->v)
#define write_uint32(ptr, val) (((uint32_unaligned_t *)(ptr))->v) = val
#endif

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-25 16:12:45 +01:00
Frediano Ziglio
70d4739ce2 quic: avoid crash on specific images
encodes_ones is called to encode a long sequence of 1 bits.
In some conditions (I manage to reproduce with a 85000x4 pixel
image fill with a single color) encodes_ones is called with a
"n" value >= 32.
This cause encode to be called with a "len" value of 32 which
trigger this assert:

   spice_assert(len > 0 && len < 32);

causing a crash. Instead of calling encode with a constant
"len" as 32 call encode_32 which is supposed to encode
exactly 32 bit.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-23 22:47:08 +01:00
Frediano Ziglio
429ad96537 quic: turn back some commented out checks as compile time
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-09 07:07:36 +01:00
Frediano Ziglio
a6d6e8435a quic: use 32 bit for bppmask
In most occurrences bppmask is converted to 32 bit anyway.
In the left one a possible more bigger precision is not needed.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-09 07:07:34 +01:00
Frediano Ziglio
6a882282f1 quic: remove Channel::encoder
This field is easily accessible from Encoder structure.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-09 07:07:32 +01:00
Frediano Ziglio
3306492247 quic: remove only assigned CommonState::encoder
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-09 07:07:29 +01:00
Frediano Ziglio
65ba949fb0 quic: remove only assigned num_channels field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-09 07:07:13 +01:00
Frediano Ziglio
9f6a671294 quic: fix typo golomb_deoding -> golomb_decoding
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-03 13:33:00 +01:00
Frediano Ziglio
b64ee40a60 quic: fix typo corelate -> correlate
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-03 13:32:45 +01:00
Christophe Fergeau
c39f2da17e quic: Use i == 0 rather than !i
This helps to make quic_rgb_tmpl.c and quic_tmpl.c more consistent.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-01 15:53:59 +02:00
Christophe Fergeau
8dd7374a1d quic: Fix "corelate" typo
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-01 15:53:47 +02:00
Christophe Fergeau
9574246403 quic: Use SPICE_VERIFY for static check
DEFevol is known at compile-time, so we can use SPICE_VERIFY to check
its value.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-01 15:53:44 +02:00
Christophe Fergeau
5684ed10be quic: Use DEFwmimax constant rather than wmimax variable
We never change its value, so we basically have 2 constants for the
same thing, DEFwmimax and wmimax. This commit removes the latter.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-01 15:53:42 +02:00
Christophe Fergeau
f122d3dadc quic: Use DEFwminext constant rather than wminext variable
We never change its value, so we basically have 2 constants for the
same thing, DEFwminext and wminext. This commit removes the latter

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-01 15:53:38 +02:00
Christophe Fergeau
db5bff3728 quic: Use DEFevol constant rather than evol variable
We never change 'evol' value, and this is currently causing issues with
gcc 7.1.1: quic.c is checking at compile-time that 'evol' is 1, 3 or 5.
This is a constant, so a static check should be good, but the compiler (gcc
7.1.1) is unable to know 'evol' value at compile-time. Since the removal
of spice_static_assert in favour of SPICE_VERIFY, this causes a
compile-time failure.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-08-01 15:53:34 +02:00
Christophe Fergeau
a25ebbac56 canvas: Don't try to unref NULL pixman_image_t
pixman_image_unref() does not ignore NULL pointers, it tries to
dereference it which causes a crash. When trying to decode invalid QUIC
data, we could end up in a situation where 'surface' would still be
NULL when reaching the setjmp block.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-07-20 17:13:35 +02:00
Christophe Fergeau
fffe755d9c log: Define G_LOG_DOMAIN as early as possible
"log: Forbid the usage of obsolete SPICE_LOG_DOMAIN" introduced a small
regression, if G_LOG_DOMAIN is not set when glib.h is included, the
header will set it to a default value. Redefining it later in log.c is
going to cause a compile-time warning.
This commit adds the definition to SPICE_COMMON_CFLAGS so that it's
defined before any inclusion of glib.h is possible. This is similar to
what is done in spice/configure.ac.

This avoids this warning:
CC       log.lo
log.c:44:0: warning: "G_LOG_DOMAIN" redefined
 #define G_LOG_DOMAIN "Spice"

In file included from /usr/include/glib-2.0/glib.h:62:0,
                 from log.c:22:
/usr/include/glib-2.0/glib/gmessages.h:280:0: note: this is the location of the previous definition
 #define G_LOG_DOMAIN    ((gchar*) 0)

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-07-07 17:04:36 +02:00
Frediano Ziglio
eeab433539 log: Force format in log macro to be a string
Make sure format is a string and not a pointer.
This prevents usages like:

  spice_debug(NULL);

This forbids computed format strings, but on the other hand, forcing
the use of string constants allows the compiler to always check
argument types against the format string. Moreover, there is no
occurrences of computed format strings in the current codebase.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-05 09:53:10 +01:00
Frediano Ziglio
518c57db20 log: Forbid the usage of obsolete SPICE_LOG_DOMAIN
As we decided to not use multiple GLib domains, the SPICE_LOG_DOMAIN
macro is not really useful. This commit removes it.
Will be replaced by some different categorization.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-05 09:53:02 +01:00
Frediano Ziglio
14c595b609 quic: Fix typo in function names
reste -> reset

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-04 10:06:09 +01:00
Frediano Ziglio
dde1fe3533 log: remove spice_static_assert macro
The macro was misused and not doing static check.
Spice have other working static check macros to use.
The macro is used only by spice-common so removing it
does not cause issues to other depending projects.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-06-22 11:34:19 +01:00
Frediano Ziglio
2ff5c77fff quic: constantify some variable
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-06-22 11:34:19 +01:00
Frediano Ziglio
f80b229e07 canvas-base: Do not attempt useless cast on stride adjustment
memmove already deal with any alignment so there's no
reason to have row byte pointer cast to uint32_t.
This also remove the confusing "dest" terminology used. The image
is aligned in place so the image bits are used for both destination
and source.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-06-21 12:57:52 +01:00
Christophe de Dinechin
858a0bfae9 Avoid clang warnings on casts with stricter alignment requirements
For example, something like this:
    uint8_t  *p8;
    uint32_t *p32 = (uint32_t *) p8;

generates a warning like this:
  spice-channel.c:1350:10: error: cast from 'uint8_t *' (aka 'unsigned char *') to
      'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to
      4 [-Werror,-Wcast-align]

The warning indicates that we end up with a pointer to data that
should be 4-byte aligned, but its value may be misaligned. On x86,
this does not make much of a difference, except a relatively minor
performance penalty. However, on platforms such as older ARM, misaligned
accesses are emulated by the kernel, and support for them is optional.
So we may end up with a fault.

The intent of the fix here is to make it easy to identify and rework
places where actual mis-alignment occurs. Wherever casts raise the warning,
they are replaced with a macro:

- SPICE_ALIGNED_CAST(type, value) casts value to type, and indicates that
  we believe the resulting pointer is aligned. If it is not, a runtime
  warning will be issued. This check is disabled unless
  --enable-alignment-checks is passed at configure time

- SPICE_UNALIGNED_CAST(type, value) casts value to type, and indicates that
  we believe the resulting pointer is not always aligned.

Any code using SPICE_UNALIGNED_CAST may need to be revisited in order
to improve performance, e.g. by using memcpy.

There are normally no warnings for SPICE_UNALIGNED_CAST, but it is possible
to emit debug messages for mis-alignment in SPICE_UNALIGNED_CAST
by configuring with CFLAGS=-DSPICE_DEBUG_ALIGNMENT.

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
2017-06-20 11:33:45 +02:00
Frediano Ziglio
765652da1d Use SPICE_ATTR_PACKED instead of custom ATTR_PACKED
Reuse {start,end}-packed headers to specify packed structure.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-06-15 12:47:36 +01:00
Christophe de Dinechin
30a33922d8 Use space and not colon to separate log domains
According to https://developer.gnome.org/glib/stable/glib-running.html,
G_MESSAGES_DEBUG is a space-separated list of log domains for which
informational and debug messages should be printed

Note that the equivalent code in spice-util.c gets it right.

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-06-09 09:56:29 +01:00
Frediano Ziglio
1d7acdcf57 log: Use GLib logging levels directly
As we moved toward GLib logging instead of having to convert
every time the log level from the old system to GLib use
directly GLib constants.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-06-09 09:46:35 +01:00
Frediano Ziglio
31ebe7c6d5 fix indentation on previous patch
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-06-01 10:12:34 +01:00
Frediano Ziglio
564635e3c1 log: Check log level from spice_logv
This was suggested by Christophe de Dinechin as an optimisation.
Most of the messages won't be processed for formatting.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-05-31 10:20:58 +01:00
Frediano Ziglio
a607077883 log: Optimise glib_debug_level check
Use INT_MAX for invalid value to remove a test in code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-05-31 10:20:56 +01:00
Frediano Ziglio
f4a4d52702 log: Do not check impossible function return
spice_log_level_to_glib never returns 0 so don't check
for this value.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-05-31 10:20:50 +01:00
Frediano Ziglio
36fd7325e5 codegen: Fix license name
License reported for MIT was indeed a BSD 3-Clause license,
not a MIT one (https://opensource.org/licenses/BSD-3-Clause).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2017-05-18 16:40:36 +01:00
Christophe de Dinechin
5faba1e860 Style adjustment - Making code match surrounding style
Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-05-18 16:37:21 +01:00
Frediano Ziglio
1d527e21d5 codegen: Allows to specify license of generated files
Some headers for spice are distributed using MIT licenses.
Allows to generate such headers if needed.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-05-08 09:54:10 +01:00
Christophe Fergeau
af682b1b06 log: Follow spice style guidelines for #include in log.h
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-31 12:14:02 +02:00
Christophe Fergeau
0996c33d6d log: Add missing stdio.h include
This is needed because spice_printerr uses fprintf/stderr

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-31 10:37:28 +01:00
Marc-André Lureau
1fd73d0a98 build-sys: don't dist spice-protocol.html
The HTML file is not built by default.
This fixes make distcheck in spice-gtk.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-03-28 14:57:50 +02:00
Frediano Ziglio
4423ea5d2a region: Avoid possible memory corruption
pixman_region32_copy assume that destination (first argument)
is initialized and can use a pointer inside based on different
conditions.
As intersection is not initialized this can cause different
memory problems.
This resulted in memory leak detection from address sanitizer.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-02-28 15:26:54 +00:00
Sebastian Andrzej Siewior
ab7cae45bc ssl: Use ASN1_STRING_get0_data instead of ASN1_STRING_data
The latter is deprecated, so might be removed at  some point in the
future. This also adds a compatibility wrapper for OpenSSL < 1.1.0.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
2017-02-16 16:40:52 +01:00
Jonathon Jongsma
c9ecd0e29e Document REGION_TEST_* bitmasks
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-03 11:07:32 -06:00
Frediano Ziglio
30e8237934 protocol: Add support for VP9 video codec
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2017-01-31 08:51:33 +00:00
Victor Toso
6439bec0de protocol: add preferred video codec message
Client might want to choose a preferred video codec for streaming for
different reasons which having hardware decoder support being the most
interest one.

This message allows the client to send an array of video codecs in
order of preference.

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-01-06 12:20:47 +00:00
Frediano Ziglio
86dcd22d33 marshaller: Remove deprecated replacement functions
spice-common has no stable ABI/API.
Also these function caused linking problems as these functions
were defined multiple times.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-12-08 13:49:13 +00:00
Jonathon Jongsma
adb36c6185 Marshaller: rename _add_ref() to _add_by_ref()
The spice_marshaller_add_ref() family of functions is confusing since it
sounds like you're incrementing a reference on the marshaller. What it
is actually doing is adding a data buffer to the marshaller by reference
rather than by value. Changing the function names to _add_by_ref() makes
this clearer.

The old functions are deprecated and are simply inline functions that
call the new functions.

Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-12-06 11:21:55 -06:00
Victor Toso
a5871c80a9 sw-canvas: remove unused defines
Including CANVAS_SINGLE_INSTANCE that was bounded to CanvasBase user
data which was removed in previous commit

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-30 15:36:29 +01:00
Victor Toso
580ca81536 canvas-base: remove user data from CanvasBase
Neither Spice nor spice-gtk are using this since the
following commit in Spice "server: remove OpenGL"
c5c176a5c7718177f23b07981556b5d460627498

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-11-30 15:36:29 +01:00
Pavel Grunt
5f241e655b spice-deps: Set python version based on modules availability
Building spice or spice-gtk from git requires python modules pyparsing
and six. Search for them in the both Python versions and set
the Python version accordingly.
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-29 11:43:25 +01:00