From c2852f6b5f4643b9ace25373ce759d247e96ad55 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 4 Feb 2010 16:27:56 +0100 Subject: [PATCH] Use spice/types.h and its types There is a standard for integer types (i.e. uint32_t) which we're using at some places, but not others. Lets use it everywhere. --- spice/draw.h | 157 ++++++++++++++++++++-------------------------- spice/ipc_ring.h | 13 ++-- spice/qxl_dev.h | 148 ++++++++++++++++++++++--------------------- spice/red.h | 6 +- spice/reds_stat.h | 2 +- spice/vd_agent.h | 2 +- spice/vdi_dev.h | 20 +++--- 7 files changed, 165 insertions(+), 183 deletions(-) diff --git a/spice/draw.h b/spice/draw.h index e277b2d..50c89d8 100644 --- a/spice/draw.h +++ b/spice/draw.h @@ -31,43 +31,22 @@ #ifndef _H_DRAW #define _H_DRAW -#ifndef _WIN32 -#include -#endif +#include #ifdef __GNUC__ #define ATTR_PACKED __attribute__ ((__packed__)) -typedef uint64_t UINT64; -typedef uint32_t UINT32; -typedef uint16_t UINT16; -typedef uint8_t UINT8; - -typedef int16_t INT16; -typedef int32_t INT32; #else -#include #pragma pack(push) #pragma pack(1) #define ATTR_PACKED #pragma warning(disable:4200) #endif -#ifdef _WIN32_WCE -#include -typedef uint64_t UINT64; -typedef uint32_t UINT32; -typedef uint16_t UINT16; -typedef uint8_t UINT8; - -typedef int16_t INT16; -typedef int32_t INT32; -#endif - #define GET_ADDRESS(addr) ((void *)(unsigned long)(addr)) #define SET_ADDRESS(addr, val) ((addr) = (unsigned long)(val)) -typedef INT32 FIXED28_4; -typedef UINT64 ADDRESS; +typedef int32_t FIXED28_4; +typedef uint64_t ADDRESS; enum { PATH_BEGIN = (1 << 0), @@ -87,26 +66,26 @@ typedef struct ATTR_PACKED PointFix { } PointFix; typedef struct ATTR_PACKED Point { - INT32 x; - INT32 y; + int32_t x; + int32_t y; } Point; typedef struct ATTR_PACKED Point16 { - INT16 x; - INT16 y; + int16_t x; + int16_t y; } Point16; typedef struct ATTR_PACKED Rect { - INT32 top; - INT32 left; - INT32 bottom; - INT32 right; + int32_t top; + int32_t left; + int32_t bottom; + int32_t right; } Rect; typedef struct ATTR_PACKED PathSeg { - UINT32 flags; - UINT32 count; - UINT8 data[0]; + uint32_t flags; + uint32_t count; + uint8_t data[0]; } PathSeg; enum ClipType { @@ -116,7 +95,7 @@ enum ClipType { }; typedef struct ATTR_PACKED Clip { - UINT32 type; + uint32_t type; ADDRESS data; } Clip; @@ -146,9 +125,9 @@ enum { }; typedef struct ATTR_PACKED Brush { - UINT32 type; + uint32_t type; union { - UINT32 color; + uint32_t color; Pattern pattern; } u; } Brush; @@ -158,21 +137,21 @@ enum { }; typedef struct ATTR_PACKED QMask { - UINT8 flags; + uint8_t flags; Point pos; ADDRESS bitmap; } QMask; typedef struct ATTR_PACKED Fill { Brush brush; - UINT16 rop_decriptor; + uint16_t rop_decriptor; QMask mask; } Fill; typedef struct ATTR_PACKED Palette { - UINT64 unique; - UINT16 num_ents; - UINT32 ents[0]; + uint64_t unique; + uint16_t num_ents; + uint32_t ents[0]; } Palette; enum { @@ -190,11 +169,11 @@ enum { }; typedef struct ATTR_PACKED ImageDescriptor { - UINT64 id; - UINT8 type; - UINT8 flags; - UINT32 width; - UINT32 height; + uint64_t id; + uint8_t type; + uint8_t flags; + uint32_t width; + uint32_t height; } ImageDescriptor; enum { @@ -217,11 +196,11 @@ enum { }; typedef struct ATTR_PACKED Bitmap { - UINT8 format; - UINT8 flags; - UINT32 x; - UINT32 y; - UINT32 stride; + uint8_t format; + uint8_t flags; + uint32_t x; + uint32_t y; + uint32_t stride; ADDRESS palette; ADDRESS data; //data[0] ? } Bitmap; @@ -232,8 +211,8 @@ typedef struct ATTR_PACKED BitmapImage { } BitmapImage; typedef struct ATTR_PACKED QUICData { - UINT32 data_size; - UINT8 data[0]; + uint32_t data_size; + uint8_t data[0]; } QUICData, LZ_RGBData; typedef struct ATTR_PACKED QUICImage { @@ -247,10 +226,10 @@ typedef struct ATTR_PACKED LZ_RGBImage { } LZ_RGBImage; typedef struct ATTR_PACKED LZ_PLTData { - UINT8 flags; - UINT32 data_size; + uint8_t flags; + uint32_t data_size; ADDRESS palette; - UINT8 data[0]; + uint8_t data[0]; } LZ_PLTData; typedef struct ATTR_PACKED LZ_PLTImage { @@ -267,28 +246,28 @@ typedef struct ATTR_PACKED Opaque { ADDRESS src_bitmap; Rect src_area; Brush brush; - UINT16 rop_decriptor; - UINT8 scale_mode; + uint16_t rop_decriptor; + uint8_t scale_mode; QMask mask; } Opaque; typedef struct ATTR_PACKED Copy { ADDRESS src_bitmap; Rect src_area; - UINT16 rop_decriptor; - UINT8 scale_mode; + uint16_t rop_decriptor; + uint8_t scale_mode; QMask mask; } Copy, Blend; typedef struct ATTR_PACKED Transparent { ADDRESS src_bitmap; Rect src_area; - UINT32 src_color; - UINT32 true_color; + uint32_t src_color; + uint32_t true_color; } Transparent; typedef struct ATTR_PACKED AlphaBlnd { - UINT8 alpha; + uint8_t alpha; ADDRESS src_bitmap; Rect src_area; } AlphaBlnd; @@ -297,8 +276,8 @@ typedef struct ATTR_PACKED Rop3 { ADDRESS src_bitmap; Rect src_area; Brush brush; - UINT8 rop3; - UINT8 scale_mode; + uint8_t rop3; + uint8_t scale_mode; QMask mask; } Rop3; @@ -324,10 +303,10 @@ enum { }; typedef struct ATTR_PACKED LineAttr { - UINT8 flags; - UINT8 join_style; - UINT8 end_style; - UINT8 style_nseg; + uint8_t flags; + uint8_t join_style; + uint8_t end_style; + uint8_t style_nseg; FIXED28_4 width; FIXED28_4 miter_limit; ADDRESS style; //data[0] ? @@ -337,22 +316,22 @@ typedef struct ATTR_PACKED Stroke { ADDRESS path; LineAttr attr; Brush brush; - UINT16 fore_mode; - UINT16 back_mode; + uint16_t fore_mode; + uint16_t back_mode; } Stroke; typedef struct ATTR_PACKED RasterGlyph { Point render_pos; Point glyph_origin; - UINT16 width; - UINT16 height; - UINT8 data[0]; + uint16_t width; + uint16_t height; + uint8_t data[0]; } RasterGlyph; typedef struct ATTR_PACKED VectotGlyph { Point render_pos; - UINT32 data_size; - UINT8 data[0]; //PathSeg[] + uint32_t data_size; + uint8_t data[0]; //PathSeg[] } VectotGlyph; enum { @@ -363,9 +342,9 @@ enum { }; typedef struct ATTR_PACKED String { - UINT16 length; - UINT16 flags; - UINT8 data[0]; + uint16_t length; + uint16_t flags; + uint8_t data[0]; } String; typedef struct ATTR_PACKED Text { @@ -373,8 +352,8 @@ typedef struct ATTR_PACKED Text { Rect back_area; Brush fore_brush; Brush back_brush; - UINT16 fore_mode; - UINT16 back_mode; + uint16_t fore_mode; + uint16_t back_mode; } Text; enum { @@ -388,12 +367,12 @@ enum { }; typedef struct ATTR_PACKED CursorHeader { - UINT64 unique; - UINT16 type; - UINT16 width; - UINT16 height; - UINT16 hot_spot_x; - UINT16 hot_spot_y; + uint64_t unique; + uint16_t type; + uint16_t width; + uint16_t height; + uint16_t hot_spot_x; + uint16_t hot_spot_y; } CursorHeader; diff --git a/spice/ipc_ring.h b/spice/ipc_ring.h index 1d9b3e1..940586e 100644 --- a/spice/ipc_ring.h +++ b/spice/ipc_ring.h @@ -32,6 +32,7 @@ #ifndef _H_RING_ #define _H_RING_ +#include #define MSB_MASK4(x) \ (((x) & 0x8) ? 0x8 : \ @@ -71,16 +72,16 @@ typedef struct ATTR_PACKED name##_ring_el { \ union { \ el_type el; \ - UINT8 data[POWER2_ALIGN(sizeof(el_type))]; \ + uint8_t data[POWER2_ALIGN(sizeof(el_type))]; \ } ; \ } name##_ring_el; \ \ typedef struct ATTR_PACKED name { \ - UINT32 num_items; \ - UINT32 prod; \ - UINT32 notify_on_prod; \ - UINT32 cons; \ - UINT32 notify_on_cons; \ + uint32_t num_items; \ + uint32_t prod; \ + uint32_t notify_on_prod; \ + uint32_t cons; \ + uint32_t notify_on_cons; \ name##_ring_el items[POWER2_ALIGN(size)]; \ } name; diff --git a/spice/qxl_dev.h b/spice/qxl_dev.h index 048315d..b5f99a5 100644 --- a/spice/qxl_dev.h +++ b/spice/qxl_dev.h @@ -32,6 +32,8 @@ #ifndef _H_QXL_DEV #define _H_QXL_DEV +#include + #include "ipc_ring.h" #include "draw.h" @@ -54,8 +56,8 @@ #define QXL_DEVICE_ID 0x0100 /* 0x100-0x11f reserved for spice */ #define QXL_REVISION 0x03 -#define QXL_ROM_MAGIC (*(UINT32*)"QXRO") -#define QXL_RAM_MAGIC (*(UINT32*)"QXRA") +#define QXL_ROM_MAGIC (*(uint32_t*)"QXRO") +#define QXL_RAM_MAGIC (*(uint32_t*)"QXRA") enum { QXL_RAM_RANGE_INDEX, @@ -86,42 +88,42 @@ enum { }; typedef struct ATTR_PACKED QXLRom { - UINT32 magic; - UINT32 id; - UINT32 update_id; - UINT32 compression_level; - UINT32 log_level; - UINT32 modes_offset; - UINT32 num_pages; - UINT32 surface0_area_size; - UINT32 ram_header_offset; - UINT32 mm_clock; - UINT64 flags; - UINT8 slots_start; - UINT8 slots_end; - UINT8 slot_gen_bits; - UINT8 slot_id_bits; - UINT8 slot_generation; + uint32_t magic; + uint32_t id; + uint32_t update_id; + uint32_t compression_level; + uint32_t log_level; + uint32_t modes_offset; + uint32_t num_pages; + uint32_t surface0_area_size; + uint32_t ram_header_offset; + uint32_t mm_clock; + uint64_t flags; + uint8_t slots_start; + uint8_t slots_end; + uint8_t slot_gen_bits; + uint8_t slot_id_bits; + uint8_t slot_generation; } QXLRom; typedef struct ATTR_PACKED QXLMode { - UINT32 id; - UINT32 x_res; - UINT32 y_res; - UINT32 bits; - UINT32 stride; - UINT32 x_mili; - UINT32 y_mili; - UINT32 orientation; + uint32_t id; + uint32_t x_res; + uint32_t y_res; + uint32_t bits; + uint32_t stride; + uint32_t x_mili; + uint32_t y_mili; + uint32_t orientation; } QXLMode; typedef struct ATTR_PACKED QXLModes { - UINT32 n_modes; + uint32_t n_modes; QXLMode modes[0]; } QXLModes; -typedef UINT64 PHYSICAL; -typedef UINT32 QXLFIXED; //fixed 28.4 +typedef uint64_t PHYSICAL; +typedef uint32_t QXLFIXED; //fixed 28.4 enum QXLCmdType { QXL_CMD_NOP, @@ -133,38 +135,38 @@ enum QXLCmdType { typedef struct ATTR_PACKED QXLCommand { PHYSICAL data; - UINT32 type; - UINT32 ped; + uint32_t type; + uint32_t ped; } QXLCommand; typedef struct ATTR_PACKED QXLCommandExt { QXLCommand cmd; - UINT32 group_id; + uint32_t group_id; } QXLCommandExt; typedef struct ATTR_PACKED QXLMemSlot { - UINT64 mem_start; - UINT64 mem_end; + uint64_t mem_start; + uint64_t mem_end; } QXLMemSlot; #define QXL_SURF_TYPE_PRIMARY 0 typedef struct ATTR_PACKED QXLSurfaceCreate { - UINT32 width; - UINT32 height; - INT32 stride; - UINT32 depth; - UINT32 position; - UINT32 mouse_mode; - UINT32 flags; - UINT32 type; + uint32_t width; + uint32_t height; + int32_t stride; + uint32_t depth; + uint32_t position; + uint32_t mouse_mode; + uint32_t flags; + uint32_t type; PHYSICAL mem; } QXLSurfaceCreate; RING_DECLARE(QXLCommandRing, QXLCommand, 32); RING_DECLARE(QXLCursorRing, QXLCommand, 32); -RING_DECLARE(QXLReleaseRing, UINT64, 8); +RING_DECLARE(QXLReleaseRing, uint64_t, 8); #define QXL_LOG_BUF_SIZE 4096 @@ -172,50 +174,50 @@ RING_DECLARE(QXLReleaseRing, UINT64, 8); #define QXL_INTERRUPT_CURSOR (1 << 1) typedef struct ATTR_PACKED QXLRam { - UINT32 magic; - UINT32 int_pending; - UINT32 int_mask; - UINT8 log_buf[QXL_LOG_BUF_SIZE]; + uint32_t magic; + uint32_t int_pending; + uint32_t int_mask; + uint8_t log_buf[QXL_LOG_BUF_SIZE]; QXLCommandRing cmd_ring; QXLCursorRing cursor_ring; QXLReleaseRing release_ring; Rect update_area; QXLMemSlot mem_slot; QXLSurfaceCreate create_surface; - UINT64 flags; + uint64_t flags; } QXLRam; typedef union QXLReleaseInfo { - UINT64 id; // in - UINT64 next; // out + uint64_t id; // in + uint64_t next; // out } QXLReleaseInfo; typedef struct QXLReleaseInfoExt { QXLReleaseInfo *info; - UINT32 group_id; + uint32_t group_id; } QXLReleaseInfoExt; typedef struct ATTR_PACKED QXLDataChunk { - UINT32 data_size; + uint32_t data_size; PHYSICAL prev_chunk; PHYSICAL next_chunk; - UINT8 data[0]; + uint8_t data[0]; } QXLDataChunk; typedef struct ATTR_PACKED QXLMessage { QXLReleaseInfo release_info; - UINT8 data[0]; + uint8_t data[0]; } QXLMessage; typedef struct ATTR_PACKED QXLUpdateCmd { QXLReleaseInfo release_info; Rect area; - UINT32 update_id; + uint32_t update_id; } QXLUpdateCmd; typedef struct ATTR_PACKED QXLCursor { CursorHeader header; - UINT32 data_size; + uint32_t data_size; QXLDataChunk chunk; } QXLCursor; @@ -230,20 +232,20 @@ enum { typedef struct ATTR_PACKED QXLCursorCmd { QXLReleaseInfo release_info; - UINT8 type; + uint8_t type; union { struct ATTR_PACKED { Point16 position; - UINT8 visible; + uint8_t visible; PHYSICAL shape; } set; struct ATTR_PACKED { - UINT16 length; - UINT16 frequency; + uint16_t length; + uint16_t frequency; } trail; Point16 position; } u; - UINT8 device_data[QXL_CURSUR_DEVICE_DATA_SIZE]; //todo: dynamic size from rom + uint8_t device_data[QXL_CURSUR_DEVICE_DATA_SIZE]; //todo: dynamic size from rom } QXLCursorCmd; enum { @@ -264,9 +266,9 @@ enum { }; typedef struct ATTR_PACKED QXLString { - UINT32 data_size; - UINT16 length; - UINT16 flags; + uint32_t data_size; + uint16_t length; + uint16_t flags; QXLDataChunk chunk; } QXLString; @@ -285,13 +287,13 @@ typedef struct ATTR_PACKED QXLCopyBits { typedef struct ATTR_PACKED QXLDrawable { QXLReleaseInfo release_info; - UINT8 effect; - UINT8 type; - UINT8 self_bitmap; + uint8_t effect; + uint8_t type; + uint8_t self_bitmap; Rect self_bitmap_area; Rect bbox; Clip clip; - UINT32 mm_time; + uint32_t mm_time; union { Fill fill; Opaque opaque; @@ -310,7 +312,7 @@ typedef struct ATTR_PACKED QXLDrawable { } QXLDrawable; typedef struct ATTR_PACKED QXLClipRects { - UINT32 num_rects; + uint32_t num_rects; QXLDataChunk chunk; } QXLClipRects; @@ -322,7 +324,7 @@ enum { }; typedef struct ATTR_PACKED QXLPath { - UINT32 data_size; + uint32_t data_size; QXLDataChunk chunk; } QXLPath; @@ -334,8 +336,8 @@ enum { }; typedef struct ATTR_PACKED QXLImageID { - UINT32 group; - UINT32 unique; + uint32_t group; + uint32_t unique; } QXLImageID; enum { @@ -349,7 +351,7 @@ enum { }; #define QXL_SET_IMAGE_ID(image, _group, _unique) { \ - UINT64* id_ptr = &(image)->descriptor.id; \ + uint64_t* id_ptr = &(image)->descriptor.id; \ QXLImageID *image_id = (QXLImageID *)id_ptr; \ image_id->group = _group; \ image_id->unique = _unique; \ diff --git a/spice/red.h b/spice/red.h index 22c0ec6..4f3e1f8 100644 --- a/spice/red.h +++ b/spice/red.h @@ -31,10 +31,8 @@ #ifndef _H_RED #define _H_RED -#include -#ifdef _WIN32 -#include -#endif +#include + #include "draw.h" #ifdef __GNUC__ #define ATTR_PACKED __attribute__ ((__packed__)) diff --git a/spice/reds_stat.h b/spice/reds_stat.h index 0baa13f..bbe4554 100644 --- a/spice/reds_stat.h +++ b/spice/reds_stat.h @@ -31,7 +31,7 @@ #ifndef _H_REDS_STAT #define _H_REDS_STAT -#include +#include #define REDS_STAT_SHM_NAME "spice.%u" #define REDS_STAT_NODE_NAME_MAX_LENGTH 20 diff --git a/spice/vd_agent.h b/spice/vd_agent.h index 7451210..3bf1412 100644 --- a/spice/vd_agent.h +++ b/spice/vd_agent.h @@ -31,7 +31,7 @@ #ifndef _H_VD_AGENT #define _H_VD_AGENT -#include +#include #ifdef __GNUC__ #define ATTR_PACKED __attribute__ ((__packed__)) #else diff --git a/spice/vdi_dev.h b/spice/vdi_dev.h index d8b5add..2ee3afd 100644 --- a/spice/vdi_dev.h +++ b/spice/vdi_dev.h @@ -31,6 +31,8 @@ #ifndef _H_VDI_DEV #define _H_VDI_DEV +#include + #include "ipc_ring.h" #ifdef __GNUC__ @@ -55,12 +57,12 @@ #define VDI_PORT_INTERRUPT (1 << 0) -#define VDI_PORT_MAGIC (*(UINT32*)"VDIP") +#define VDI_PORT_MAGIC (*(uint32_t*)"VDIP") typedef struct ATTR_PACKED VDIPortPacket { - UINT32 gen; - UINT32 size; - UINT8 data[512 - 2 * sizeof(UINT32)]; + uint32_t gen; + uint32_t size; + uint8_t data[512 - 2 * sizeof(uint32_t)]; } VDIPortPacket; RING_DECLARE(VDIPortRing, VDIPortPacket, 32); @@ -79,13 +81,13 @@ enum { }; typedef struct ATTR_PACKED VDIPortRam { - UINT32 magic; - UINT32 generation; - UINT32 int_pending; - UINT32 int_mask; + uint32_t magic; + uint32_t generation; + uint32_t int_pending; + uint32_t int_mask; VDIPortRing input; VDIPortRing output; - UINT32 reserv[32]; + uint32_t reserv[32]; } VDIPortRam; #ifndef __GNUC__