Commit Graph

18 Commits

Author SHA1 Message Date
Frediano Ziglio
f6f998004b Wrap spice.h in order to do some adjustment
Instead of including spice.h directly include an header that wraps
it. This allows to remove the SPICE_SERVER_INTERNAL define.
Currently is used to rename SpiceCharDeviceInstance to RedCharDevice
and reduce its visibility to hidden. This remove some warnings
and some weird code in the source.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
6db395dc74 Make sure empty structure are ABI compatible
Empty structure are not really portable however adding
an zero size array seems to be the way to have a zero
size structure portably.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
e0b395fb68 Declare exported functions as C
Allows to be used by both C and C++ code.
So to leave part of the code in C and part move to C++.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Christophe Fergeau
bc5326b1ce Unify header guards
This changes the header guards in all .h files to follow this format:

/*
 * Licensing block
 */

/* ... */

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-30 18:17:20 +01:00
Frediano Ziglio
ce06958fb8 Improve statistic code interface
Use new structures and functions to implement the statistics code.
Use inline functions instead of macros for increased type-safety.
If statistics are disabled, the structures and functions become
empty. This confines the configuration-specific #defines to the
statistics implementation itself and avoids the need for #defines in
the calling functions. This greatly reduces the chance of accidentally
breaking the build for one configuration or the other. The reds option
was removed from stat_inc_counter() as it was not used.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-02-15 10:13:48 +00:00
Frediano Ziglio
f9ccabfaea Separate code to manage statistic file
Code is quite independent so move in separate file.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-16 16:38:13 +00:00
Frediano Ziglio
ae01c6d4bc Removed only written roundtrip_stat field
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-27 14:22:04 +01:00
Frediano Ziglio
f36c3887ba Make sure all headers are independent
Make sure is possible to include any headers alone.

I used this script to check independence (run under server directory):
----
#!/bin/bash

set -e

# check not already modified
if grep -q libheaders.la Makefile.am; then
    echo "Header library already prepared" >&2
    exit 1
fi

add_lib() {
    local hdr="$1"

    hdr=${hdr%.h}
    c="mao_${hdr}.c"
    echo "#include \"${hdr}.h\"" > $c
    echo -e "\t$c \\" >&3
}

# add library to compile all headers alones
exec 3>> Makefile.am
echo "
noinst_LTLIBRARIES += libheaders.la
libheaders_la_SOURCES =				\\" >&3
for hdr in *.h; do
    case $hdr in
    spice-bitmap-utils.h)
        add_lib $hdr
        ;;
    spice*.h)
        ;;
    *)
        add_lib $hdr
        ;;
    esac
done
echo -e "\t\$(NULL)" >&3
exec 3>&-
----

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-18 00:24:37 +01:00
Jonathon Jongsma
41d97b037a Add RedsState arg to all stat functions
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:04:02 +00:00
Christophe Fergeau
02c8a0f386 stat: Make stat_compress_init/stat_init the same
When COMPRESS_STAT is not set, and RED_WORKER_STAT is set,
stat_time() will be a no-op, but stat_start_time_init() will try to use
stat_info_t::clock. This causes a compile warning on 32 bit arches (not
sure why not on 64 bit builds), as well as an error from valgrind.

Since stat_time() and stat_compress_time() are both doing the same work,
this commit makes them the same function, which ensures
stat_info_t::clock will be set and stat_start_time_init() can be used
regardless of the _init() method which is called.
2016-01-12 11:46:32 +01:00
Frediano Ziglio
253d2cef40 stat: use a better design for statistic functions
make sure code compile with statistics enabled or disabled.
Dummy (empty) structures and functions are used instead of preprocessor.
Also fix a problem as stat_compress_init did not initialize clock
field.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-09 17:02:48 +00:00
Frediano Ziglio
4173663ea1 stat: fix portability problem in stat_time_t declaration
Assure stat_time_t is 64 bit on all architectures.
long is not 64 bit on 32 bit systems so use uint64_t intead.
Also avoid 32 bit overflows for such architectures.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-09 17:02:41 +00:00
Frediano Ziglio
89707f3b4d stat: fix stat_info_t initialization
For compression statistics clock field was not initialized but used
computing statistics.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-03 10:56:03 +00:00
Frediano Ziglio
1ab8df03ce worker: fix compiling with COMPRESS_STAT enabled
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-11-12 13:25:09 +00:00
Marc-André Lureau
7b1d03508d worker: move RED_WORKER_STAT, make it compile again
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-11-11 15:42:10 +00:00
Daniel P. Berrange
02d56750bd Remove trailing blank lines
Remove any blank lines at the end of all source files
2012-01-13 18:11:59 +02:00
Alexander Larsson
c97116aeb9 Relicense everything from GPL to LGPL 2.1+ 2010-04-13 22:22:15 +02:00
Yaniv Kamay
c1b79eb035 fresh start 2009-10-14 15:06:41 +02:00