summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-03-09 11:10:00 +0100
committerAlexander Larsson <alexl@redhat.com>2010-03-09 11:10:00 +0100
commit90c5766caf16e35cb871116a4655a106a3c272dc (patch)
treeddc2ea976240a3f8f9c3294b41492256e6eb3f82 /server
parent5cb99e12c6817592f49ca153a3081dd6b5995cf2 (diff)
downloadspice-90c5766caf16e35cb871116a4655a106a3c272dc.tar.gz
spice-90c5766caf16e35cb871116a4655a106a3c272dc.tar.xz
spice-90c5766caf16e35cb871116a4655a106a3c272dc.zip
Use macros from <spice/macros.h> rather than duplicate them
Diffstat (limited to 'server')
-rw-r--r--server/glz_encoder_config.h4
-rw-r--r--server/red_common.h23
-rw-r--r--server/red_tunnel_worker.c36
-rw-r--r--server/red_worker.c113
-rw-r--r--server/reds.c4
-rw-r--r--server/snd_worker.c16
6 files changed, 87 insertions, 109 deletions
diff --git a/server/glz_encoder_config.h b/server/glz_encoder_config.h
index a2b9b580..938949bc 100644
--- a/server/glz_encoder_config.h
+++ b/server/glz_encoder_config.h
@@ -18,6 +18,7 @@
#ifndef _H_GLZ_ENCODER_CONFIG
#define _H_GLZ_ENCODER_CONFIG
+#include <spice/macros.h>
#include "lz_common.h"
typedef void GlzUsrImageContext;
@@ -56,9 +57,6 @@ struct GlzEncoderUsrContext {
#define INLINE inline
-#define FALSE 0
-#define TRUE 1
-
#endif
diff --git a/server/red_common.h b/server/red_common.h
index 6a43dc3a..4a847483 100644
--- a/server/red_common.h
+++ b/server/red_common.h
@@ -22,21 +22,7 @@
#include <openssl/ssl.h>
#include <spice/protocol.h>
-
-#ifndef MIN
-#define MIN(x, y) (((x) <= (y)) ? (x) : (y))
-#endif
-#ifndef MAX
-#define MAX(x, y) (((x) >= (y)) ? (x) : (y))
-#endif
-
-#ifndef ABS
-#define ABS(a) ((a) >= 0 ? (a) : -(a))
-#endif
-
-#ifndef ALIGN
-#define ALIGN(a, b) (((a) + ((b) - 1)) & ~((b) - 1))
-#endif
+#include <spice/macros.h>
#define ASSERT(x) if (!(x)) { \
printf("%s: ASSERT %s failed\n", __FUNCTION__, #x); \
@@ -53,9 +39,6 @@
abort(); \
}
-#define TRUE 1
-#define FALSE 0
-
#define red_error(format, ...) { \
printf("%s: " format "\n", __FUNCTION__, ## __VA_ARGS__ ); \
abort(); \
@@ -79,10 +62,6 @@
} \
}
-#define OFFSETOF(type, member) ((unsigned long)&((type *)0)->member)
-#define CONTAINEROF(ptr, type, member) \
- ((type *)((uint8_t *)(ptr) - OFFSETOF(type, member)))
-
typedef enum {
IMAGE_COMPRESS_INVALID,
IMAGE_COMPRESS_AUTO_GLZ,
diff --git a/server/red_tunnel_worker.c b/server/red_tunnel_worker.c
index 9a8c11ef..f3374de6 100644
--- a/server/red_tunnel_worker.c
+++ b/server/red_tunnel_worker.c
@@ -1678,9 +1678,9 @@ static void tunnel_channel_release_msg_rcv_buf(RedChannel *channel, SpiceDataHea
{
TunnelChannel *tunnel_channel = (TunnelChannel *)channel;
if (msg_header->type == SPICE_MSGC_TUNNEL_SOCKET_DATA) {
- ASSERT(!(CONTAINEROF(msg, RedSocketRawRcvBuf, buf)->base.usr_opaque));
+ ASSERT(!(SPICE_CONTAINEROF(msg, RedSocketRawRcvBuf, buf)->base.usr_opaque));
__tunnel_worker_free_socket_rcv_buf(tunnel_channel->worker,
- CONTAINEROF(msg, RedSocketRawRcvBuf, buf));
+ SPICE_CONTAINEROF(msg, RedSocketRawRcvBuf, buf));
}
}
@@ -2324,7 +2324,7 @@ static int tunnel_channel_handle_message(RedChannel *channel, SpiceDataHeader *h
}
return tunnel_channel_handle_socket_receive_data(tunnel_channel, sckt,
- CONTAINEROF(msg, RedSocketRawRcvBuf, buf),
+ SPICE_CONTAINEROF(msg, RedSocketRawRcvBuf, buf),
header->size - sizeof(SpiceMsgcTunnelSocketData));
}
case SPICE_MSGC_TUNNEL_SOCKET_FIN:
@@ -2591,7 +2591,7 @@ static void tunnel_channel_send_init(TunnelChannel *channel, PipeItem *item)
static void tunnel_channel_send_service_ip_map(TunnelChannel *channel, PipeItem *item)
{
- TunnelService *service = CONTAINEROF(item, TunnelService, pipe_item);
+ TunnelService *service = SPICE_CONTAINEROF(item, TunnelService, pipe_item);
channel->send_data.u.service_ip.service_id = service->id;
channel->send_data.u.service_ip.virtual_ip.type = SPICE_TUNNEL_IP_TYPE_IPv4;
@@ -2605,8 +2605,8 @@ static void tunnel_channel_send_service_ip_map(TunnelChannel *channel, PipeItem
static void tunnel_channel_send_socket_open(TunnelChannel *channel, PipeItem *item)
{
- RedSocketOutData *sckt_out_data = CONTAINEROF(item, RedSocketOutData, status_pipe_item);
- RedSocket *sckt = CONTAINEROF(sckt_out_data, RedSocket, out_data);
+ RedSocketOutData *sckt_out_data = SPICE_CONTAINEROF(item, RedSocketOutData, status_pipe_item);
+ RedSocket *sckt = SPICE_CONTAINEROF(sckt_out_data, RedSocket, out_data);
channel->send_data.u.socket_open.connection_id = sckt->connection_id;
channel->send_data.u.socket_open.service_id = sckt->far_service->id;
@@ -2626,8 +2626,8 @@ static void tunnel_channel_send_socket_open(TunnelChannel *channel, PipeItem *it
static void tunnel_channel_send_socket_fin(TunnelChannel *channel, PipeItem *item)
{
- RedSocketOutData *sckt_out_data = CONTAINEROF(item, RedSocketOutData, status_pipe_item);
- RedSocket *sckt = CONTAINEROF(sckt_out_data, RedSocket, out_data);
+ RedSocketOutData *sckt_out_data = SPICE_CONTAINEROF(item, RedSocketOutData, status_pipe_item);
+ RedSocket *sckt = SPICE_CONTAINEROF(sckt_out_data, RedSocket, out_data);
ASSERT(!sckt->out_data.ready_chunks_queue.head);
@@ -2652,8 +2652,8 @@ static void tunnel_channel_send_socket_fin(TunnelChannel *channel, PipeItem *ite
static void tunnel_channel_send_socket_close(TunnelChannel *channel, PipeItem *item)
{
- RedSocketOutData *sckt_out_data = CONTAINEROF(item, RedSocketOutData, status_pipe_item);
- RedSocket *sckt = CONTAINEROF(sckt_out_data, RedSocket, out_data);
+ RedSocketOutData *sckt_out_data = SPICE_CONTAINEROF(item, RedSocketOutData, status_pipe_item);
+ RedSocket *sckt = SPICE_CONTAINEROF(sckt_out_data, RedSocket, out_data);
// can happen when it is a forced close
if (sckt->out_data.ready_chunks_queue.head) {
@@ -2684,8 +2684,8 @@ static void tunnel_channel_send_socket_close(TunnelChannel *channel, PipeItem *i
static void tunnel_channel_send_socket_closed_ack(TunnelChannel *channel, PipeItem *item)
{
- RedSocketOutData *sckt_out_data = CONTAINEROF(item, RedSocketOutData, status_pipe_item);
- RedSocket *sckt = CONTAINEROF(sckt_out_data, RedSocket, out_data);
+ RedSocketOutData *sckt_out_data = SPICE_CONTAINEROF(item, RedSocketOutData, status_pipe_item);
+ RedSocket *sckt = SPICE_CONTAINEROF(sckt_out_data, RedSocket, out_data);
channel->send_data.u.socket_close_ack.connection_id = sckt->connection_id;
@@ -2709,8 +2709,8 @@ static void tunnel_channel_send_socket_closed_ack(TunnelChannel *channel, PipeIt
static void tunnel_channel_send_socket_token(TunnelChannel *channel, PipeItem *item)
{
- RedSocketOutData *sckt_out_data = CONTAINEROF(item, RedSocketOutData, token_pipe_item);
- RedSocket *sckt = CONTAINEROF(sckt_out_data, RedSocket, out_data);
+ RedSocketOutData *sckt_out_data = SPICE_CONTAINEROF(item, RedSocketOutData, token_pipe_item);
+ RedSocket *sckt = SPICE_CONTAINEROF(sckt_out_data, RedSocket, out_data);
/* notice that the num of tokens sent can be > SOCKET_TOKENS_TO_SEND, since
the sending is performed after the pipe item was pushed */
@@ -2736,8 +2736,8 @@ static void tunnel_channel_send_socket_token(TunnelChannel *channel, PipeItem *i
static void tunnel_channel_send_socket_out_data(TunnelChannel *channel, PipeItem *item)
{
- RedSocketOutData *sckt_out_data = CONTAINEROF(item, RedSocketOutData, data_pipe_item);
- RedSocket *sckt = CONTAINEROF(sckt_out_data, RedSocket, out_data);
+ RedSocketOutData *sckt_out_data = SPICE_CONTAINEROF(item, RedSocketOutData, data_pipe_item);
+ RedSocket *sckt = SPICE_CONTAINEROF(sckt_out_data, RedSocket, out_data);
ReadyTunneledChunk *chunk;
uint32_t total_push_size = 0;
uint32_t pushed_bufs_num = 0;
@@ -2792,8 +2792,8 @@ static void tunnel_channel_send_socket_out_data(TunnelChannel *channel, PipeItem
static void tunnel_worker_release_socket_out_data(TunnelWorker *worker, PipeItem *item)
{
- RedSocketOutData *sckt_out_data = CONTAINEROF(item, RedSocketOutData, data_pipe_item);
- RedSocket *sckt = CONTAINEROF(sckt_out_data, RedSocket, out_data);
+ RedSocketOutData *sckt_out_data = SPICE_CONTAINEROF(item, RedSocketOutData, data_pipe_item);
+ RedSocket *sckt = SPICE_CONTAINEROF(sckt_out_data, RedSocket, out_data);
ASSERT(sckt_out_data->ready_chunks_queue.head);
diff --git a/server/red_worker.c b/server/red_worker.c
index e8c986f6..1b8cd84d 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -1180,7 +1180,7 @@ static void cb_validate_virt(void *opaque, unsigned long virt, unsigned long fro
static void *op_get_virt_preload_group(SpiceVirtMapping *mapping, unsigned long addr, uint32_t add_size)
{
- RedWorker *worker = CONTAINEROF(mapping, RedWorker, preload_group_virt_mapping);
+ RedWorker *worker = SPICE_CONTAINEROF(mapping, RedWorker, preload_group_virt_mapping);
return (void *)get_virt(worker, addr, add_size,
worker->preload_group_id);
}
@@ -1188,7 +1188,7 @@ static void *op_get_virt_preload_group(SpiceVirtMapping *mapping, unsigned long
static void op_validate_virt_preload_group(SpiceVirtMapping *mapping, unsigned long virt,
unsigned long from_addr, uint32_t add_size)
{
- RedWorker *worker = CONTAINEROF(mapping, RedWorker, preload_group_virt_mapping);
+ RedWorker *worker = SPICE_CONTAINEROF(mapping, RedWorker, preload_group_virt_mapping);
int slot_id = get_memslot_id(worker, from_addr);
validate_virt(worker, virt, slot_id, add_size,
worker->preload_group_id);
@@ -1406,7 +1406,7 @@ static void red_pipe_clear(RedChannel *channel)
ring_remove(&item->link);
switch (item->type) {
case PIPE_ITEM_TYPE_DRAW:
- release_drawable(channel->worker, CONTAINEROF(item, Drawable, pipe_item));
+ release_drawable(channel->worker, SPICE_CONTAINEROF(item, Drawable, pipe_item));
break;
case PIPE_ITEM_TYPE_CURSOR:
red_release_cursor(channel->worker, (CursorItem *)item);
@@ -1432,14 +1432,14 @@ static void red_pipe_clear(RedChannel *channel)
break;
case PIPE_ITEM_TYPE_STREAM_CREATE:
red_display_release_stream((DisplayChannel *)channel,
- CONTAINEROF(item, StreamAgent, create_item));
+ SPICE_CONTAINEROF(item, StreamAgent, create_item));
break;
case PIPE_ITEM_TYPE_STREAM_CLIP:
red_display_release_stream_clip((DisplayChannel *)channel, (StreamClipItem*)item);
break;
case PIPE_ITEM_TYPE_STREAM_DESTROY:
red_display_release_stream((DisplayChannel *)channel,
- CONTAINEROF(item, StreamAgent, destroy_item));
+ SPICE_CONTAINEROF(item, StreamAgent, destroy_item));
break;
}
}
@@ -1655,14 +1655,14 @@ static inline void current_remove(RedWorker *worker, TreeItem *item)
if (now->type == TREE_ITEM_TYPE_DRAWABLE) {
ring_item = now->siblings_link.prev;
- remove_drawable(worker, CONTAINEROF(now, Drawable, tree_item));
+ remove_drawable(worker, SPICE_CONTAINEROF(now, Drawable, tree_item));
} else {
Container *container = (Container *)now;
ASSERT(now->type == TREE_ITEM_TYPE_CONTAINER);
if ((ring_item = ring_get_head(&container->items))) {
- now = CONTAINEROF(ring_item, TreeItem, siblings_link);
+ now = SPICE_CONTAINEROF(ring_item, TreeItem, siblings_link);
continue;
}
ring_item = now->siblings_link.prev;
@@ -1673,7 +1673,7 @@ static inline void current_remove(RedWorker *worker, TreeItem *item)
}
if ((ring_item = ring_next(&container->items, ring_item))) {
- now = CONTAINEROF(ring_item, TreeItem, siblings_link);
+ now = SPICE_CONTAINEROF(ring_item, TreeItem, siblings_link);
} else {
now = (TreeItem *)container;
}
@@ -1692,7 +1692,7 @@ static void current_tree_for_each(RedWorker *worker, void (*f)(TreeItem *, void
top_ring = ring;
for (;;) {
- TreeItem *now = CONTAINEROF(ring_item, TreeItem, siblings_link);
+ TreeItem *now = SPICE_CONTAINEROF(ring_item, TreeItem, siblings_link);
f(now, data);
@@ -1723,7 +1723,7 @@ static void red_current_clear(RedWorker *worker)
RingItem *ring_item;
while ((ring_item = ring_get_head(&worker->current))) {
- TreeItem *now = CONTAINEROF(ring_item, TreeItem, siblings_link);
+ TreeItem *now = SPICE_CONTAINEROF(ring_item, TreeItem, siblings_link);
current_remove(worker, now);
}
}
@@ -1753,7 +1753,7 @@ static void print_rgn(const char* prefix, const QRegion* rgn)
static void print_draw_item(const char* prefix, const DrawItem *draw_item)
{
const TreeItem *base = &draw_item->base;
- const Drawable *drawable = CONTAINEROF(draw_item, Drawable, tree_item);
+ const Drawable *drawable = SPICE_CONTAINEROF(draw_item, Drawable, tree_item);
printf("TEST: %s: draw id %u container %u effect %u",
prefix,
base->id, base->container ? base->container->base.id : 0,
@@ -1889,7 +1889,7 @@ static inline void __exclude_region(RedWorker *worker, TreeItem *item, QRegion *
}
} else {
if (frame_candidate) {
- Drawable *drawable = CONTAINEROF(draw, Drawable, tree_item);
+ Drawable *drawable = SPICE_CONTAINEROF(draw, Drawable, tree_item);
red_stream_maintenance(worker, frame_candidate, drawable);
}
region_exclude(&draw->base.rgn, &and_rgn);
@@ -1938,7 +1938,7 @@ static void exclude_region(RedWorker *worker, Ring *ring, RingItem *ring_item, Q
top_ring = ring;
for (;;) {
- TreeItem *now = CONTAINEROF(ring_item, TreeItem, siblings_link);
+ TreeItem *now = SPICE_CONTAINEROF(ring_item, TreeItem, siblings_link);
Container *container = now->container;
ASSERT(!region_is_empty(&now->rgn));
@@ -2001,7 +2001,7 @@ static void exclude_region(RedWorker *worker, Ring *ring, RingItem *ring_item, Q
top_ring = ring;
for (;;) {
- TreeItem *now = CONTAINEROF(ring_item, TreeItem, siblings_link);
+ TreeItem *now = SPICE_CONTAINEROF(ring_item, TreeItem, siblings_link);
Container *container = now->container;
ASSERT(!region_is_empty(&now->rgn));
@@ -2394,7 +2394,7 @@ static void red_detach_streams_behind(RedWorker *worker, QRegion *region)
DisplayChannel *channel = worker->display_channel;
while (item) {
- Stream *stream = CONTAINEROF(item, Stream, link);
+ Stream *stream = SPICE_CONTAINEROF(item, Stream, link);
item = ring_next(ring, item);
if (channel) {
@@ -2420,7 +2420,7 @@ static void red_stop_streams_behind(RedWorker *worker, QRegion *region)
RingItem *item = ring_get_head(ring);
while (item) {
- Stream *stream = CONTAINEROF(item, Stream, link);
+ Stream *stream = SPICE_CONTAINEROF(item, Stream, link);
stream->refs++;
if (stream->current && region_intersects(region, &stream->current->tree_item.base.rgn)) {
red_stop_stream_gracefully(worker, stream);
@@ -2446,7 +2446,7 @@ static void red_streams_update_clip(RedWorker *worker, Drawable *drawable)
item = ring_get_head(ring);
while (item) {
- Stream *stream = CONTAINEROF(item, Stream, link);
+ Stream *stream = SPICE_CONTAINEROF(item, Stream, link);
StreamAgent *agent;
item = ring_next(ring, item);
@@ -2476,7 +2476,7 @@ static inline unsigned int red_get_streams_timout(RedWorker *worker)
while ((item = ring_next(ring, item))) {
Stream *stream;
- stream = CONTAINEROF(item, Stream, link);
+ stream = SPICE_CONTAINEROF(item, Stream, link);
#ifdef STREAM_TRACE
red_time_t delta = (stream->last_time + RED_STREAM_TIMOUT) - now;
@@ -2507,7 +2507,7 @@ static inline void red_handle_streams_timout(RedWorker *worker)
red_time_t now = timespec_to_red_time(&time);
item = ring_get_head(ring);
while (item) {
- Stream *stream = CONTAINEROF(item, Stream, link);
+ Stream *stream = SPICE_CONTAINEROF(item, Stream, link);
#ifdef STREAM_TRACE
item = ring_next(ring, item);
if (now >= (stream->last_time + RED_STREAM_TIMOUT)) {
@@ -2628,8 +2628,8 @@ static void red_create_stream(RedWorker *worker, Drawable *drawable)
ASSERT(drawable->qxl_drawable->type == QXL_DRAW_COPY);
src_rect = &drawable->qxl_drawable->u.copy.src_area;
- stream_width = ALIGN(src_rect->right - src_rect->left, 2);
- stream_height = ALIGN(src_rect->bottom - src_rect->top, 2);
+ stream_width = SPICE_ALIGN(src_rect->right - src_rect->left, 2);
+ stream_height = SPICE_ALIGN(src_rect->bottom - src_rect->top, 2);
if (!(av_ctx = red_init_video_encoder(stream_width, stream_height))) {
goto error_1;
@@ -2699,7 +2699,7 @@ static void red_disply_start_streams(DisplayChannel *display_channel)
RingItem *item = ring;
while ((item = ring_next(ring, item))) {
- Stream *stream = CONTAINEROF(item, Stream, link);
+ Stream *stream = SPICE_CONTAINEROF(item, Stream, link);
red_dispaly_create_stream(display_channel, stream);
}
}
@@ -2850,8 +2850,8 @@ static void reset_rate(StreamAgent *stream_agent)
return;
}
- int stream_width = ALIGN(stream->width, 2);
- int stream_height = ALIGN(stream->height, 2);
+ int stream_width = SPICE_ALIGN(stream->width, 2);
+ int stream_height = SPICE_ALIGN(stream->height, 2);
new_ctx = red_init_video_encoder(stream_width, stream_height);
if (!new_ctx) {
@@ -3030,8 +3030,8 @@ static inline int red_current_add_equal(RedWorker *worker, DrawItem *item, TreeI
return FALSE;
}
- drawable = CONTAINEROF(item, Drawable, tree_item);
- other_drawable = CONTAINEROF(other_draw_item, Drawable, tree_item);
+ drawable = SPICE_CONTAINEROF(item, Drawable, tree_item);
+ other_drawable = SPICE_CONTAINEROF(other_draw_item, Drawable, tree_item);
if (item->effect == QXL_EFFECT_OPAQUE) {
int add_after = !!other_drawable->stream;
@@ -3091,7 +3091,7 @@ static inline void red_use_stream_trace(RedWorker *worker, Drawable *drawable)
item = ring_get_head(ring);
while (item) {
- Stream *stream = CONTAINEROF(item, Stream, link);
+ Stream *stream = SPICE_CONTAINEROF(item, Stream, link);
if (!stream->current && __red_is_next_stream_frame(worker,
drawable,
stream->width,
@@ -3124,7 +3124,7 @@ static void red_reset_stream_trace(RedWorker *worker)
RingItem *item = ring_get_head(ring);
while (item) {
- Stream *stream = CONTAINEROF(item, Stream, link);
+ Stream *stream = SPICE_CONTAINEROF(item, Stream, link);
item = ring_next(ring, item);
if (!stream->current) {
red_stop_stream(worker, stream);
@@ -3157,7 +3157,7 @@ static inline int red_current_add(RedWorker *worker, Drawable *drawable)
now = ring_next(ring, ring);
while (now) {
- TreeItem *sibling = CONTAINEROF(now, TreeItem, siblings_link);
+ TreeItem *sibling = SPICE_CONTAINEROF(now, TreeItem, siblings_link);
int test_res;
if (!region_bounds_intersects(&item->base.rgn, &sibling->rgn)) {
@@ -3295,7 +3295,7 @@ static inline int red_current_add(RedWorker *worker, Drawable *drawable)
now = ring_next(ring, ring);
while (now) {
- TreeItem *sibling = CONTAINEROF(now, TreeItem, siblings_link);
+ TreeItem *sibling = SPICE_CONTAINEROF(now, TreeItem, siblings_link);
int test_res;
if (!region_bounds_intersects(&item->base.rgn, &sibling->rgn)) {
@@ -3592,7 +3592,7 @@ static void free_one_drawable(RedWorker *worker, int force_glz_free)
Container *container;
ASSERT(ring_item);
- drawable = CONTAINEROF(ring_item, Drawable, list_link);
+ drawable = SPICE_CONTAINEROF(ring_item, Drawable, list_link);
if (drawable->red_glz_drawable && force_glz_free) {
ASSERT(worker->display_channel);
red_display_free_glz_drawable(worker->display_channel, drawable->red_glz_drawable);
@@ -3655,8 +3655,9 @@ static inline void red_process_drawable(RedWorker *worker, QXLDrawable *drawable
if (drawable->clip.type == SPICE_CLIP_TYPE_RECTS) {
QRegion rgn;
- region_init(&rgn);
- add_clip_rects(worker, &rgn, drawable->clip.data + OFFSETOF(QXLClipRects, chunk), group_id);
+ region_init(&
+ rgn);
+ add_clip_rects(worker, &rgn, drawable->clip.data + SPICE_OFFSETOF(QXLClipRects, chunk), group_id);
region_and(&item->tree_item.base.rgn, &rgn);
region_destroy(&rgn);
} else if (drawable->clip.type == SPICE_CLIP_TYPE_PATH) {
@@ -4314,11 +4315,11 @@ static inline void __red_collect_for_update(RedWorker *worker, Ring *ring, RingI
Ring *top_ring = ring;
for (;;) {
- TreeItem *now = CONTAINEROF(ring_item, TreeItem, siblings_link);
+ TreeItem *now = SPICE_CONTAINEROF(ring_item, TreeItem, siblings_link);
Container *container = now->container;
if (region_intersects(rgn, &now->rgn)) {
if (IS_DRAW_ITEM(now)) {
- Drawable *drawable = CONTAINEROF(now, Drawable, tree_item);
+ Drawable *drawable = SPICE_CONTAINEROF(now, Drawable, tree_item);
ring_add(items, &drawable->collect_link);
region_or(rgn, &now->rgn);
@@ -4326,7 +4327,7 @@ static inline void __red_collect_for_update(RedWorker *worker, Ring *ring, RingI
region_or(rgn, &drawable->tree_item.shadow->base.rgn);
}
} else if (now->type == TREE_ITEM_TYPE_SHADOW) {
- Drawable *owner = CONTAINEROF(((Shadow *)now)->owner, Drawable, tree_item);
+ Drawable *owner = SPICE_CONTAINEROF(((Shadow *)now)->owner, Drawable, tree_item);
if (!ring_item_is_linked(&owner->collect_link)) {
region_or(rgn, &now->rgn);
region_or(rgn, &owner->tree_item.base.rgn);
@@ -4375,7 +4376,7 @@ static void red_update_area(RedWorker *worker, const SpiceRect *area)
region_destroy(&rgn);
while ((ring_item = ring_get_head(&items))) {
- Drawable *drawable = CONTAINEROF(ring_item, Drawable, collect_link);
+ Drawable *drawable = SPICE_CONTAINEROF(ring_item, Drawable, collect_link);
Container *container;
ring_remove(ring_item);
@@ -4400,7 +4401,7 @@ static void red_update_area(RedWorker *worker, const SpiceRect *area)
region_init(&rgn);
region_add(&rgn, area);
while ((ring_item = ring_next(ring, ring_item))) {
- now = CONTAINEROF(ring_item, Drawable, list_link);
+ now = SPICE_CONTAINEROF(ring_item, Drawable, list_link);
if (region_intersects(&rgn, &now->tree_item.base.rgn)) {
last = now;
break;
@@ -4417,7 +4418,7 @@ static void red_update_area(RedWorker *worker, const SpiceRect *area)
Container *container;
ring_item = ring_get_tail(&worker->current_list);
- now = CONTAINEROF(ring_item, Drawable, list_link);
+ now = SPICE_CONTAINEROF(ring_item, Drawable, list_link);
red_draw_drawable(worker, now);
container = now->tree_item.base.container;
current_remove_drawable(worker, now);
@@ -4974,7 +4975,7 @@ static void red_display_handle_glz_drawables_to_free(DisplayChannel* channel)
pthread_mutex_lock(&channel->glz_drawables_inst_to_free_lock);
while ((ring_link = ring_get_head(&channel->glz_drawables_inst_to_free))) {
- GlzDrawableInstanceItem *drawable_instance = CONTAINEROF(ring_link,
+ GlzDrawableInstanceItem *drawable_instance = SPICE_CONTAINEROF(ring_link,
GlzDrawableInstanceItem,
free_link);
red_display_free_glz_drawable_instance(channel, drawable_instance);
@@ -4997,7 +4998,7 @@ static void red_display_free_glz_drawable(DisplayChannel *channel, RedGlzDrawabl
/* Last instance: red_display_free_glz_drawable_instance will free the drawable */
cont = FALSE;
}
- GlzDrawableInstanceItem *instance = CONTAINEROF(head_instance,
+ GlzDrawableInstanceItem *instance = SPICE_CONTAINEROF(head_instance,
GlzDrawableInstanceItem,
glz_link);
if (!ring_item_is_linked(&instance->free_link)) {
@@ -5028,7 +5029,7 @@ static void red_display_clear_glz_drawables(DisplayChannel *channel)
pthread_rwlock_wrlock(&channel->glz_dict->encode_lock);
while ((ring_link = ring_get_head(&channel->glz_drawables))) {
- RedGlzDrawable *drawable = CONTAINEROF(ring_link, RedGlzDrawable, link);
+ RedGlzDrawable *drawable = SPICE_CONTAINEROF(ring_link, RedGlzDrawable, link);
// no need to lock the to_free list, since we assured no other thread is encoding and
// thus not other thread access the to_free list of the channel
red_display_free_glz_drawable(channel, drawable);
@@ -5051,7 +5052,7 @@ static int red_display_free_some_independent_glz_drawables(DisplayChannel *chann
RingItem *ring_link = ring_get_head(&channel->glz_drawables);
while ((n < RED_RELEASE_BUNCH_SIZE) && (ring_link != NULL)) {
- RedGlzDrawable *glz_drawable = CONTAINEROF(ring_link, RedGlzDrawable, link);
+ RedGlzDrawable *glz_drawable = SPICE_CONTAINEROF(ring_link, RedGlzDrawable, link);
ring_link = ring_next(&channel->glz_drawables, ring_link);
if (!glz_drawable->drawable) {
red_display_free_glz_drawable(channel, glz_drawable);
@@ -5324,7 +5325,7 @@ static void glz_usr_free_image(GlzEncoderUsrContext *usr, GlzUsrImageContext *im
GlzData *lz_data = (GlzData *)usr;
GlzDrawableInstanceItem *glz_drawable_instance = (GlzDrawableInstanceItem *)image;
DisplayChannel *drawable_channel = glz_drawable_instance->red_glz_drawable->display_channel;
- DisplayChannel *this_channel = CONTAINEROF(lz_data, DisplayChannel, glz_data);
+ DisplayChannel *this_channel = SPICE_CONTAINEROF(lz_data, DisplayChannel, glz_data);
if (this_channel == drawable_channel) {
red_display_free_glz_drawable_instance(drawable_channel, glz_drawable_instance);
} else {
@@ -5524,12 +5525,12 @@ static inline int _stride_is_extra(SpiceBitmap *bitmap)
return (bitmap->x < bitmap->stride);
case SPICE_BITMAP_FMT_4BIT_BE:
case SPICE_BITMAP_FMT_4BIT_LE: {
- int bytes_width = ALIGN(bitmap->x, 2) >> 1;
+ int bytes_width = SPICE_ALIGN(bitmap->x, 2) >> 1;
return bytes_width < bitmap->stride;
}
case SPICE_BITMAP_FMT_1BIT_BE:
case SPICE_BITMAP_FMT_1BIT_LE: {
- int bytes_width = ALIGN(bitmap->x, 8) >> 3;
+ int bytes_width = SPICE_ALIGN(bitmap->x, 8) >> 3;
return bytes_width < bitmap->stride;
}
default:
@@ -6993,8 +6994,8 @@ static void red_display_send_stream_start(DisplayChannel *display_channel, Strea
stream_create->src_width = stream->width;
stream_create->src_height = stream->height;
- stream_create->stream_width = ALIGN(stream_create->src_width, 2);
- stream_create->stream_height = ALIGN(stream_create->src_height, 2);
+ stream_create->stream_width = SPICE_ALIGN(stream_create->src_width, 2);
+ stream_create->stream_height = SPICE_ALIGN(stream_create->src_height, 2);
stream_create->dest = stream->dest_area;
add_buf(channel, BUF_TYPE_RAW, stream_create, sizeof(*stream_create), 0, 0);
@@ -7178,7 +7179,7 @@ static void display_channel_push(RedWorker *worker)
red_display_reset_send_data(display_channel);
switch (pipe_item->type) {
case PIPE_ITEM_TYPE_DRAW: {
- Drawable *drawable = CONTAINEROF(pipe_item, Drawable, pipe_item);
+ Drawable *drawable = SPICE_CONTAINEROF(pipe_item, Drawable, pipe_item);
send_qxl_drawable(display_channel, drawable);
release_drawable(worker, drawable);
break;
@@ -7188,7 +7189,7 @@ static void display_channel_push(RedWorker *worker)
free(pipe_item);
break;
case PIPE_ITEM_TYPE_STREAM_CREATE: {
- StreamAgent *agent = CONTAINEROF(pipe_item, StreamAgent, create_item);
+ StreamAgent *agent = SPICE_CONTAINEROF(pipe_item, StreamAgent, create_item);
red_display_send_stream_start(display_channel, agent);
red_display_release_stream(display_channel, agent);
break;
@@ -7200,7 +7201,7 @@ static void display_channel_push(RedWorker *worker)
break;
}
case PIPE_ITEM_TYPE_STREAM_DESTROY: {
- StreamAgent *agent = CONTAINEROF(pipe_item, StreamAgent, destroy_item);
+ StreamAgent *agent = SPICE_CONTAINEROF(pipe_item, StreamAgent, destroy_item);
red_display_send_stream_end(display_channel, agent);
red_display_release_stream(display_channel, agent);
break;
@@ -7329,7 +7330,7 @@ static void __show_tree_call(TreeItem *item, void *data)
switch (item->type) {
case TREE_ITEM_TYPE_DRAWABLE: {
- Drawable *drawable = CONTAINEROF(item, Drawable, tree_item);
+ Drawable *drawable = SPICE_CONTAINEROF(item, Drawable, tree_item);
const int max_indent = 200;
char indent_str[max_indent + 1];
int indent_str_len;
@@ -8163,7 +8164,7 @@ static void display_channel_hold_item(void *item)
switch (((PipeItem *)item)->type) {
case PIPE_ITEM_TYPE_DRAW:
case PIPE_ITEM_TYPE_STREAM_CREATE:
- CONTAINEROF(item, Drawable, pipe_item)->refs++;
+ SPICE_CONTAINEROF(item, Drawable, pipe_item)->refs++;
break;
case PIPE_ITEM_TYPE_STREAM_CLIP:
((StreamClipItem *)item)->refs++;
@@ -8185,7 +8186,7 @@ static void display_channel_release_item(RedChannel *channel, void *item)
switch (((PipeItem *)item)->type) {
case PIPE_ITEM_TYPE_DRAW:
case PIPE_ITEM_TYPE_STREAM_CREATE:
- release_drawable(channel->worker, CONTAINEROF(item, Drawable, pipe_item));
+ release_drawable(channel->worker, SPICE_CONTAINEROF(item, Drawable, pipe_item));
break;
case PIPE_ITEM_TYPE_STREAM_CLIP:
red_display_release_stream_clip((DisplayChannel *)channel, (StreamClipItem *)item);
@@ -8689,7 +8690,7 @@ static void inline red_create_mem_slots(RedWorker *worker)
static void handle_dev_input(EventListener *listener, uint32_t events)
{
- RedWorker *worker = CONTAINEROF(listener, RedWorker, dev_listener);
+ RedWorker *worker = SPICE_CONTAINEROF(listener, RedWorker, dev_listener);
RedWorkeMessage message;
read_message(worker->channel, &message);
@@ -9054,7 +9055,7 @@ static void dump_palette(FILE *f, SpicePalette* plt)
static void dump_line(FILE *f, uint8_t* line, uint16_t n_pixel_bits, int width, int row_size)
{
int i;
- int copy_bytes_size = ALIGN(n_pixel_bits * width, 8) / 8;
+ int copy_bytes_size = SPICE_ALIGN(n_pixel_bits * width, 8) / 8;
fwrite(line, 1, copy_bytes_size, f);
if (row_size > copy_bytes_size) {
diff --git a/server/reds.c b/server/reds.c
index 7b8d15b3..3375bf1c 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -1766,7 +1766,7 @@ static int main_channel_restore_vdi_wqueue(MainMigrateData *data, uint8_t *pos,
if (inf->port == VDP_SERVER_PORT) {
VDInternalBuf *buf;
- if (inf->len > sizeof(*buf) - OFFSETOF(VDInternalBuf, header)) {
+ if (inf->len > sizeof(*buf) - SPICE_OFFSETOF(VDInternalBuf, header)) {
red_printf("bad buffer len");
reds_disconnect();
return FALSE;
@@ -1786,7 +1786,7 @@ static int main_channel_restore_vdi_wqueue(MainMigrateData *data, uint8_t *pos,
VDAgentExtBuf *buf;
state->num_tokens--;
- if (inf->len > sizeof(*buf) - OFFSETOF(VDAgentExtBuf, buf)) {
+ if (inf->len > sizeof(*buf) - SPICE_OFFSETOF(VDAgentExtBuf, buf)) {
red_printf("bad buffer len");
reds_disconnect();
return FALSE;
diff --git a/server/snd_worker.c b/server/snd_worker.c
index 3046bd1b..d9e5b625 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.c
@@ -842,7 +842,7 @@ static void snd_set_command(SndChannel *channel, uint32_t command)
static void snd_playback_start(PlaybackPlug *plug)
{
- PlaybackChannel *playback_channel = CONTAINEROF(plug, PlaybackChannel, plug);
+ PlaybackChannel *playback_channel = SPICE_CONTAINEROF(plug, PlaybackChannel, plug);
ASSERT(!playback_channel->base.active);
reds_desable_mm_timer();
@@ -857,7 +857,7 @@ static void snd_playback_start(PlaybackPlug *plug)
static void snd_playback_stop(PlaybackPlug *plug)
{
- PlaybackChannel *playback_channel = CONTAINEROF(plug, PlaybackChannel, plug);
+ PlaybackChannel *playback_channel = SPICE_CONTAINEROF(plug, PlaybackChannel, plug);
ASSERT(playback_channel->base.active);
reds_enable_mm_timer();
@@ -880,7 +880,7 @@ static void snd_playback_stop(PlaybackPlug *plug)
static void snd_playback_get_frame(PlaybackPlug *plug, uint32_t **frame, uint32_t *num_samples)
{
- PlaybackChannel *playback_channel = CONTAINEROF(plug, PlaybackChannel, plug);
+ PlaybackChannel *playback_channel = SPICE_CONTAINEROF(plug, PlaybackChannel, plug);
ASSERT(playback_channel->base.active);
if (!playback_channel->free_frames) {
@@ -896,7 +896,7 @@ static void snd_playback_get_frame(PlaybackPlug *plug, uint32_t **frame, uint32_
static void snd_playback_put_frame(PlaybackPlug *plug, uint32_t *samples)
{
- PlaybackChannel *playback_channel = CONTAINEROF(plug, PlaybackChannel, plug);
+ PlaybackChannel *playback_channel = SPICE_CONTAINEROF(plug, PlaybackChannel, plug);
AudioFrame *frame;
ASSERT(playback_channel->base.active);
@@ -904,7 +904,7 @@ static void snd_playback_put_frame(PlaybackPlug *plug, uint32_t *samples)
if (playback_channel->pending_frame) {
snd_playback_free_frame(playback_channel, playback_channel->pending_frame);
}
- frame = CONTAINEROF(samples, AudioFrame, samples);
+ frame = SPICE_CONTAINEROF(samples, AudioFrame, samples);
frame->time = reds_get_mm_time();
red_dispatcher_set_mm_time(frame->time);
playback_channel->pending_frame = frame;
@@ -1015,7 +1015,7 @@ static void snd_record_migrate(Channel *channel)
static void snd_record_start(RecordPlug *plug)
{
- RecordChannel *record_channel = CONTAINEROF(plug, RecordChannel, plug);
+ RecordChannel *record_channel = SPICE_CONTAINEROF(plug, RecordChannel, plug);
ASSERT(!record_channel->base.active);
record_channel->base.active = TRUE;
@@ -1031,7 +1031,7 @@ static void snd_record_start(RecordPlug *plug)
static void snd_record_stop(RecordPlug *plug)
{
- RecordChannel *record_channel = CONTAINEROF(plug, RecordChannel, plug);
+ RecordChannel *record_channel = SPICE_CONTAINEROF(plug, RecordChannel, plug);
ASSERT(record_channel->base.active);
record_channel->base.active = FALSE;
@@ -1045,7 +1045,7 @@ static void snd_record_stop(RecordPlug *plug)
static uint32_t snd_record_read(RecordPlug *plug, uint32_t num_samples, uint32_t *samples)
{
- RecordChannel *record_channel = CONTAINEROF(plug, RecordChannel, plug);
+ RecordChannel *record_channel = SPICE_CONTAINEROF(plug, RecordChannel, plug);
uint32_t read_pos;
uint32_t now;
uint32_t len;