mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice-protocol
synced 2026-01-03 15:39:36 +00:00
Define and use new SPICE_MAGIC_CONST macro
This macro allow to define magic constants without using weird memory tweacks. This remove some possible warning from some compiler and make code more optimized as compiler is able to compute the constant. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
parent
3ab16f2dad
commit
295d05e733
@ -18,10 +18,11 @@
|
||||
#ifndef _H_CONTROLLER_PROT
|
||||
#define _H_CONTROLLER_PROT
|
||||
|
||||
#include <spice/macros.h>
|
||||
#include <spice/types.h>
|
||||
#include <spice/start-packed.h>
|
||||
|
||||
#define CONTROLLER_MAGIC (*(uint32_t*)"CTRL")
|
||||
#define CONTROLLER_MAGIC SPICE_MAGIC_CONST("CTRL")
|
||||
#define CONTROLLER_VERSION 1
|
||||
|
||||
|
||||
|
||||
@ -18,10 +18,11 @@
|
||||
#ifndef _H_FOREIGN_MENU_PROT
|
||||
#define _H_FOREIGN_MENU_PROT
|
||||
|
||||
#include <spice/macros.h>
|
||||
#include <spice/types.h>
|
||||
#include <spice/start-packed.h>
|
||||
|
||||
#define FOREIGN_MENU_MAGIC (*(uint32_t*)"FRGM")
|
||||
#define FOREIGN_MENU_MAGIC SPICE_MAGIC_CONST("FRGM")
|
||||
#define FOREIGN_MENU_VERSION 1
|
||||
|
||||
typedef struct SPICE_ATTR_PACKED FrgMenuInitHeader {
|
||||
|
||||
@ -414,4 +414,12 @@
|
||||
#endif
|
||||
|
||||
|
||||
#if SPICE_ENDIAN == SPICE_ENDIAN_LITTLE
|
||||
#define SPICE_MAGIC_CONST(s) \
|
||||
((uint32_t)((s[0]&0xffu)|((s[1]&0xffu)<<8)|((s[2]&0xff)<<16)|((s[3]&0xffu)<<24)))
|
||||
#else
|
||||
#define SPICE_MAGIC_CONST(s) \
|
||||
((uint32_t)((s[3]&0xffu)|((s[2]&0xffu)<<8)|((s[1]&0xff)<<16)|((s[0]&0xffu)<<24)))
|
||||
#endif
|
||||
|
||||
#endif /* _H_SPICE_MACROS */
|
||||
|
||||
@ -33,9 +33,10 @@
|
||||
|
||||
#include <spice/types.h>
|
||||
#include <spice/enums.h>
|
||||
#include <spice/macros.h>
|
||||
#include <spice/start-packed.h>
|
||||
|
||||
#define SPICE_MAGIC (*(uint32_t*)"REDQ")
|
||||
#define SPICE_MAGIC SPICE_MAGIC_CONST("REDQ")
|
||||
#define SPICE_VERSION_MAJOR 2
|
||||
#define SPICE_VERSION_MINOR 2
|
||||
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
#include <spice/barrier.h>
|
||||
#include <spice/ipc_ring.h>
|
||||
#include <spice/enums.h>
|
||||
#include <spice/macros.h>
|
||||
|
||||
#include <spice/start-packed.h>
|
||||
|
||||
@ -54,8 +55,8 @@ enum {
|
||||
#define QXL_DEVICE_ID_DEVEL 0x01ff
|
||||
#define QXL_REVISION_DEVEL 0x01
|
||||
|
||||
#define QXL_ROM_MAGIC (*(const uint32_t*)"QXRO")
|
||||
#define QXL_RAM_MAGIC (*(const uint32_t*)"QXRA")
|
||||
#define QXL_ROM_MAGIC SPICE_MAGIC_CONST("QXRO")
|
||||
#define QXL_RAM_MAGIC SPICE_MAGIC_CONST("QXRA")
|
||||
|
||||
enum {
|
||||
QXL_RAM_RANGE_INDEX,
|
||||
|
||||
@ -31,11 +31,12 @@
|
||||
#ifndef _H_SPICE_STATS
|
||||
#define _H_SPICE_STATS
|
||||
|
||||
#include <spice/macros.h>
|
||||
#include <spice/types.h>
|
||||
|
||||
#define SPICE_STAT_SHM_NAME "/spice.%u"
|
||||
#define SPICE_STAT_NODE_NAME_MAX 20
|
||||
#define SPICE_STAT_MAGIC (*(uint32_t*)"STAT")
|
||||
#define SPICE_STAT_MAGIC SPICE_MAGIC_CONST("STAT")
|
||||
#define SPICE_STAT_VERSION 1
|
||||
|
||||
enum {
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
#include <spice/types.h>
|
||||
#include <spice/barrier.h>
|
||||
#include <spice/ipc_ring.h>
|
||||
#include <spice/macros.h>
|
||||
|
||||
#include <spice/start-packed.h>
|
||||
|
||||
@ -48,7 +49,7 @@
|
||||
|
||||
#define VDI_PORT_INTERRUPT (1 << 0)
|
||||
|
||||
#define VDI_PORT_MAGIC (*(uint32_t*)"VDIP")
|
||||
#define VDI_PORT_MAGIC SPICE_MAGIC_CONST("VDIP")
|
||||
|
||||
typedef struct SPICE_ATTR_PACKED VDIPortPacket {
|
||||
uint32_t gen;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user