예제 #1
0
void fcrystal_tuple_sort(const sint *const handle, const sint *const n,
                         sint   Ai[], const sint *const mi,
                         slong  Al[], const sint *const ml,
                         double Ad[], const sint *const md,
                         const sint keys[], const sint *const nkey)
{
  const size_t size_i = (*mi)*sizeof(sint),
               size_l = (*ml)*sizeof(slong),
               size_d = (*md)*sizeof(double);
  int init=0;
  sint nk = *nkey;
  buffer *buf;
  CHECK_HANDLE("crystal_tuple_sort");
  buf = &handle_array[*handle]->data;
  if(nk<=0) return;
  while(--nk>=0) {
    sint k = keys[nk]-1;
    if(k<0 || k>=*mi+*ml)
      fail(1,__FILE__,__LINE__,"crystal_tuple_sort: invalid key");
    else if(k<*mi) sortp     (buf,init, (uint *)&Ai[k],    *n,size_i);
    else           sortp_long(buf,init, (ulong*)&Al[k-*mi],*n,size_l);
    init=1;
  }
  if(*mi) sarray_permute_buf_(ALIGNOF(sint  ),size_i,Ai,*n, buf);
  if(*ml) sarray_permute_buf_(ALIGNOF(slong ),size_l,Al,*n, buf);
  if(*md) sarray_permute_buf_(ALIGNOF(double),size_d,Ad,*n, buf);
}
예제 #2
0
파일: edit_picking.c 프로젝트: vaplv/foo
/*******************************************************************************
 *
 * Picking functions
 *
 ******************************************************************************/
enum edit_error
edit_create_picking
  (struct app* app,
   struct edit_imgui* imgui,
   struct edit_model_instance_selection* instance_selection,
   struct mem_allocator* allocator,
   struct edit_picking** out_picking)
{
  struct edit_picking* picking = NULL;
  enum edit_error edit_err = EDIT_NO_ERROR;
  enum sl_error sl_err = SL_NO_ERROR;

  if(UNLIKELY(!app || !instance_selection || !allocator || !out_picking)) {
    edit_err = EDIT_INVALID_ARGUMENT;
    goto error;
  }

  picking = MEM_CALLOC(allocator, 1, sizeof(struct edit_picking));
  if(!picking) {
    edit_err = EDIT_MEMORY_ERROR;
    goto error;
  }
  ref_init(&picking->ref);
  APP(ref_get(app));
  picking->app = app;
  EDIT(imgui_ref_get(imgui));
  picking->imgui = imgui;
  EDIT(model_instance_selection_ref_get(instance_selection));
  picking->instance_selection = instance_selection;
  picking->allocator = allocator;

  sl_err = sl_create_hash_table
    (sizeof(uint32_t),
     ALIGNOF(uint32_t),
     sizeof(uint32_t),
     ALIGNOF(uint32_t),
     hash_uint32,
     eq_uint32,
     allocator,
     &picking->picked_instances_htbl);
  if(sl_err != SL_NO_ERROR) {
    edit_err = sl_to_edit_error(sl_err);
    goto error;
  }

exit:
  if(out_picking)
    *out_picking = picking;
  return edit_err;
error:
  if(picking) {
    EDIT(picking_ref_put(picking));
    picking = NULL;
  }
  goto exit;
}
예제 #3
0
파일: smoke.cpp 프로젝트: travitch/humidor
int main() {
  printf("Class align=%d and size=%d\n",
      ALIGNOF(Smoke::Class), sizeof(Smoke::Class));
  printf("Method align=%d and size=%d\n",
      ALIGNOF(Smoke::Method), sizeof(Smoke::Method));
  printf("Type align=%d and size=%d\n",
      ALIGNOF(Smoke::Type), sizeof(Smoke::Type));

  return 0;
}
예제 #4
0
파일: P6num.c 프로젝트: MattOates/MoarVM
static void mk_storage_spec(MVMThreadContext *tc, MVMuint16 bits, MVMStorageSpec *spec) {
    spec->bits = bits;
    spec->inlineable      = MVM_STORAGE_SPEC_INLINED;
    spec->boxed_primitive = MVM_STORAGE_SPEC_BP_NUM;
    spec->can_box         = MVM_STORAGE_SPEC_CAN_BOX_NUM;
    switch (bits) {
        case 64: spec->align = ALIGNOF(MVMnum64); break;
        case 32: spec->align = ALIGNOF(MVMnum32); break;
        default: spec->align = ALIGNOF(MVMnum64); break;
    }
}
예제 #5
0
파일: P6int.c 프로젝트: MasterDuke17/MoarVM
static void mk_storage_spec(MVMThreadContext *tc, MVMuint16 bits, MVMuint16 is_unsigned, MVMStorageSpec *spec) {
    /* create storage spec */
    spec->inlineable      = MVM_STORAGE_SPEC_INLINED;
    spec->boxed_primitive = MVM_STORAGE_SPEC_BP_INT;
    spec->can_box         = MVM_STORAGE_SPEC_CAN_BOX_INT;
    spec->bits            = bits;
    spec->is_unsigned     = is_unsigned;
    switch (bits) {
    case 64: spec->align = ALIGNOF(MVMint64); break;
    case 32: spec->align = ALIGNOF(MVMint32); break;
    case 16: spec->align = ALIGNOF(MVMint16); break;
    default: spec->align = ALIGNOF(MVMint8);  break;
    }
}
예제 #6
0
파일: res.c 프로젝트: 3AN03A/libxcb
int
xcb_res_query_client_resources_sizeof (const void  *_buffer  /**< */)
{
    char *xcb_tmp = (char *)_buffer;
    const xcb_res_query_client_resources_reply_t *_aux = (xcb_res_query_client_resources_reply_t *)_buffer;
    unsigned int xcb_buffer_len = 0;
    unsigned int xcb_block_len = 0;
    unsigned int xcb_pad = 0;
    unsigned int xcb_align_to;


    xcb_block_len += sizeof(xcb_res_query_client_resources_reply_t);
    xcb_tmp += xcb_block_len;
    /* types */
    xcb_block_len += _aux->num_types * sizeof(xcb_res_type_t);
    xcb_tmp += xcb_block_len;
    xcb_align_to = ALIGNOF(xcb_res_type_t);
    /* insert padding */
    xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    xcb_buffer_len += xcb_block_len + xcb_pad;
    if (0 != xcb_pad) {
        xcb_tmp += xcb_pad;
        xcb_pad = 0;
    }
    xcb_block_len = 0;

    return xcb_buffer_len;
}
예제 #7
0
파일: shape.c 프로젝트: csulmone/X11
int
xcb_shape_get_rectangles_sizeof (const void  *_buffer  /**< */)
{
    char *xcb_tmp = (char *)_buffer;
    const xcb_shape_get_rectangles_reply_t *_aux = (xcb_shape_get_rectangles_reply_t *)_buffer;
    unsigned int xcb_buffer_len = 0;
    unsigned int xcb_block_len = 0;
    unsigned int xcb_pad = 0;
    unsigned int xcb_align_to;


    xcb_block_len += sizeof(xcb_shape_get_rectangles_reply_t);
    xcb_tmp += xcb_block_len;
    /* rectangles */
    xcb_block_len += _aux->rectangles_len * sizeof(xcb_rectangle_t);
    xcb_tmp += xcb_block_len;
    xcb_align_to = ALIGNOF(xcb_rectangle_t);
    /* insert padding */
    xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    xcb_buffer_len += xcb_block_len + xcb_pad;
    if (0 != xcb_pad) {
        xcb_tmp += xcb_pad;
        xcb_pad = 0;
    }
    xcb_block_len = 0;

    return xcb_buffer_len;
}
예제 #8
0
파일: record.c 프로젝트: 3AN03A/libxcb
int
xcb_record_enable_context_sizeof (const void  *_buffer  /**< */)
{
    char *xcb_tmp = (char *)_buffer;
    const xcb_record_enable_context_reply_t *_aux = (xcb_record_enable_context_reply_t *)_buffer;
    unsigned int xcb_buffer_len = 0;
    unsigned int xcb_block_len = 0;
    unsigned int xcb_pad = 0;
    unsigned int xcb_align_to;


    xcb_block_len += sizeof(xcb_record_enable_context_reply_t);
    xcb_tmp += xcb_block_len;
    /* data */
    xcb_block_len += (_aux->length * 4) * sizeof(uint8_t);
    xcb_tmp += xcb_block_len;
    xcb_align_to = ALIGNOF(uint8_t);
    /* insert padding */
    xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    xcb_buffer_len += xcb_block_len + xcb_pad;
    if (0 != xcb_pad) {
        xcb_tmp += xcb_pad;
        xcb_pad = 0;
    }
    xcb_block_len = 0;

    return xcb_buffer_len;
}
예제 #9
0
파일: record.c 프로젝트: 3AN03A/libxcb
int
xcb_record_unregister_clients_sizeof (const void  *_buffer  /**< */)
{
    char *xcb_tmp = (char *)_buffer;
    const xcb_record_unregister_clients_request_t *_aux = (xcb_record_unregister_clients_request_t *)_buffer;
    unsigned int xcb_buffer_len = 0;
    unsigned int xcb_block_len = 0;
    unsigned int xcb_pad = 0;
    unsigned int xcb_align_to;


    xcb_block_len += sizeof(xcb_record_unregister_clients_request_t);
    xcb_tmp += xcb_block_len;
    /* client_specs */
    xcb_block_len += _aux->num_client_specs * sizeof(xcb_record_client_spec_t);
    xcb_tmp += xcb_block_len;
    xcb_align_to = ALIGNOF(xcb_record_client_spec_t);
    /* insert padding */
    xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    xcb_buffer_len += xcb_block_len + xcb_pad;
    if (0 != xcb_pad) {
        xcb_tmp += xcb_pad;
        xcb_pad = 0;
    }
    xcb_block_len = 0;

    return xcb_buffer_len;
}
예제 #10
0
파일: spawn.c 프로젝트: matyler/mtPaint
static char *remember_temp_file(char *name, int type, int rgb)
{
	static wjmem *tempstore;
	tempfile *tmp, *tm0;

	if ((tempstore || (tempstore = wjmemnew(0, 0))) &&
		(tmp = wjmalloc(tempstore, offsetof(tempfile, name) +
		strlen(name) + 1, ALIGNOF(tempfile))))
	{
		tmp->type = type;
		tmp->rgb = rgb;
		strcpy(tmp->name, name);
		if (mem_tempfiles) /* Have anchor - insert after it */
		{
			tm0 = tmp->id = mem_tempfiles;
			tmp->next = tm0->next;
			tm0->next = (void *)tmp;
		}
		else /* No anchor - insert before all */
		{
			tmp->next = tempchain;
			mem_tempfiles = tempchain = tmp->id = (void *)tmp;
		}
		return (tmp->name);
	}
	return (NULL); // Failed to allocate
}
예제 #11
0
int
xcb_xc_misc_get_xid_list_sizeof (const void  *_buffer  /**< */)
{
    char *xcb_tmp = (char *)_buffer;
    const xcb_xc_misc_get_xid_list_reply_t *_aux = (xcb_xc_misc_get_xid_list_reply_t *)_buffer;
    unsigned int xcb_buffer_len = 0;
    unsigned int xcb_block_len = 0;
    unsigned int xcb_pad = 0;
    unsigned int xcb_align_to = 0;


    xcb_block_len += sizeof(xcb_xc_misc_get_xid_list_reply_t);
    xcb_tmp += xcb_block_len;
    xcb_buffer_len += xcb_block_len;
    xcb_block_len = 0;
    /* ids */
    xcb_block_len += _aux->ids_len * sizeof(uint32_t);
    xcb_tmp += xcb_block_len;
    xcb_align_to = ALIGNOF(uint32_t);
    /* insert padding */
    xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    xcb_buffer_len += xcb_block_len + xcb_pad;
    if (0 != xcb_pad) {
        xcb_tmp += xcb_pad;
        xcb_pad = 0;
    }
    xcb_block_len = 0;

    return xcb_buffer_len;
}
예제 #12
0
파일: record.c 프로젝트: 3AN03A/libxcb
int
xcb_record_get_context_sizeof (const void  *_buffer  /**< */)
{
    char *xcb_tmp = (char *)_buffer;
    const xcb_record_get_context_reply_t *_aux = (xcb_record_get_context_reply_t *)_buffer;
    unsigned int xcb_buffer_len = 0;
    unsigned int xcb_block_len = 0;
    unsigned int xcb_pad = 0;
    unsigned int xcb_align_to;

    unsigned int i;
    unsigned int xcb_tmp_len;

    xcb_block_len += sizeof(xcb_record_get_context_reply_t);
    xcb_tmp += xcb_block_len;
    /* intercepted_clients */
    for(i=0; i<_aux->num_intercepted_clients; i++) {
        xcb_tmp_len = xcb_record_client_info_sizeof(xcb_tmp);
        xcb_block_len += xcb_tmp_len;
        xcb_tmp += xcb_tmp_len;
    }
    xcb_align_to = ALIGNOF(xcb_record_client_info_t);
    /* insert padding */
    xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    xcb_buffer_len += xcb_block_len + xcb_pad;
    if (0 != xcb_pad) {
        xcb_tmp += xcb_pad;
        xcb_pad = 0;
    }
    xcb_block_len = 0;

    return xcb_buffer_len;
}
예제 #13
0
void fcrystal_ituple_sort(const sint *handle,
                          sint A[], const sint *m, const sint *n,
                          const sint keys[], const sint *nkey)
{
  const size_t size = (*m)*sizeof(sint);
  sint nk = *nkey;
  buffer *buf;
  CHECK_HANDLE("crystal_ituple_sort");
  buf = &handle_array[*handle]->data;
  if(--nk>=0) {
    sortp(buf,0, (uint*)&A[keys[nk]-1],*n,size);
    while(--nk>=0)
      sortp(buf,1, (uint*)&A[keys[nk]-1],*n,size);
    sarray_permute_buf_(ALIGNOF(sint),size,A,*n, buf);
  }
}
예제 #14
0
파일: mcache.c 프로젝트: deadcafe/JohnDoe
struct mcache *
mc_create(struct mcache *parent,
	  const char *name,
	  size_t size,
	  void (*destroy_cb)(struct mcache *, void *),
	  void *destroy_arg)
{
	struct mcache *cache;
	struct mc_chunk *chunk;
	struct mc_obj *obj;

	if ((chunk = alloc_chunk(size)) == NULL)
		return NULL;
	obj = split_obj(chunk, TAILQ_FIRST(&chunk->objs),
			ALIGNOF(sizeof(*cache)));
	cache = (struct mcache *) (obj->body);
	cache->name = name;
	cache->parent = NULL;
	chunk->cache = cache;
#ifdef ENABLE_MC_DEBUG
	obj->file = name;
	obj->func = __func__;
	obj->line = 0;
#endif
	TAILQ_INIT(&cache->chunks);
	TAILQ_INSERT_HEAD(&cache->chunks, chunk, node);
	TAILQ_INIT(&cache->childs);
	cache->chunk_num = 1;
	cache->child_num = 0;
	if ((cache->destroy_cb = destroy_cb) == NULL)
		destroy_arg = NULL;
	cache->destroy_arg = destroy_arg;
	link_cache(parent, cache);

	DBGTRACE("%s(%d): %s parent:%p size:%lu cache:%p\n",
		 __func__, __LINE__, name, parent, size, cache);
	return cache;
}
예제 #15
0
xcb_shape_query_version_cookie_t
xcb_shape_query_version (xcb_connection_t *c)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_QUERY_VERSION,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_shape_query_version_cookie_t xcb_ret;
    xcb_shape_query_version_request_t xcb_out;


    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_shape_query_version_cookie_t
xcb_shape_query_version_unchecked (xcb_connection_t *c)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_QUERY_VERSION,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_shape_query_version_cookie_t xcb_ret;
    xcb_shape_query_version_request_t xcb_out;


    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_shape_query_version_reply_t *
xcb_shape_query_version_reply (xcb_connection_t                  *c,
                               xcb_shape_query_version_cookie_t   cookie  /**< */,
                               xcb_generic_error_t              **e)
{
    return (xcb_shape_query_version_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
}

int
xcb_shape_rectangles_sizeof (const void  *_buffer,
                             uint32_t     rectangles_len)
{
    char *xcb_tmp = (char *)_buffer;
    unsigned int xcb_buffer_len = 0;
    unsigned int xcb_block_len = 0;
    unsigned int xcb_pad = 0;
    unsigned int xcb_align_to = 0;


    xcb_block_len += sizeof(xcb_shape_rectangles_request_t);
    xcb_tmp += xcb_block_len;
    xcb_buffer_len += xcb_block_len;
    xcb_block_len = 0;
    /* rectangles */
    xcb_block_len += rectangles_len * sizeof(xcb_rectangle_t);
    xcb_tmp += xcb_block_len;
    xcb_align_to = ALIGNOF(xcb_rectangle_t);
    /* insert padding */
    xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    xcb_buffer_len += xcb_block_len + xcb_pad;
    if (0 != xcb_pad) {
        xcb_tmp += xcb_pad;
        xcb_pad = 0;
    }
    xcb_block_len = 0;

    return xcb_buffer_len;
}

xcb_void_cookie_t
xcb_shape_rectangles_checked (xcb_connection_t      *c,
                              xcb_shape_op_t         operation,
                              xcb_shape_kind_t       destination_kind,
                              uint8_t                ordering,
                              xcb_window_t           destination_window,
                              int16_t                x_offset,
                              int16_t                y_offset,
                              uint32_t               rectangles_len,
                              const xcb_rectangle_t *rectangles)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 4,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_RECTANGLES,
        .isvoid = 1
    };

    struct iovec xcb_parts[6];
    xcb_void_cookie_t xcb_ret;
    xcb_shape_rectangles_request_t xcb_out;

    xcb_out.operation = operation;
    xcb_out.destination_kind = destination_kind;
    xcb_out.ordering = ordering;
    xcb_out.pad0 = 0;
    xcb_out.destination_window = destination_window;
    xcb_out.x_offset = x_offset;
    xcb_out.y_offset = y_offset;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    /* xcb_rectangle_t rectangles */
    xcb_parts[4].iov_base = (char *) rectangles;
    xcb_parts[4].iov_len = rectangles_len * sizeof(xcb_rectangle_t);
    xcb_parts[5].iov_base = 0;
    xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_shape_rectangles (xcb_connection_t      *c,
                      xcb_shape_op_t         operation,
                      xcb_shape_kind_t       destination_kind,
                      uint8_t                ordering,
                      xcb_window_t           destination_window,
                      int16_t                x_offset,
                      int16_t                y_offset,
                      uint32_t               rectangles_len,
                      const xcb_rectangle_t *rectangles)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 4,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_RECTANGLES,
        .isvoid = 1
    };

    struct iovec xcb_parts[6];
    xcb_void_cookie_t xcb_ret;
    xcb_shape_rectangles_request_t xcb_out;

    xcb_out.operation = operation;
    xcb_out.destination_kind = destination_kind;
    xcb_out.ordering = ordering;
    xcb_out.pad0 = 0;
    xcb_out.destination_window = destination_window;
    xcb_out.x_offset = x_offset;
    xcb_out.y_offset = y_offset;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    /* xcb_rectangle_t rectangles */
    xcb_parts[4].iov_base = (char *) rectangles;
    xcb_parts[4].iov_len = rectangles_len * sizeof(xcb_rectangle_t);
    xcb_parts[5].iov_base = 0;
    xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_rectangle_t *
xcb_shape_rectangles_rectangles (const xcb_shape_rectangles_request_t *R)
{
    return (xcb_rectangle_t *) (R + 1);
}

int
xcb_shape_rectangles_rectangles_length (const xcb_shape_rectangles_request_t *R)
{
    return (((R->length * 4) - sizeof(xcb_shape_rectangles_request_t))/sizeof(xcb_rectangle_t));
}

xcb_rectangle_iterator_t
xcb_shape_rectangles_rectangles_iterator (const xcb_shape_rectangles_request_t *R)
{
    xcb_rectangle_iterator_t i;
    i.data = (xcb_rectangle_t *) (R + 1);
    i.rem = (((R->length * 4) - sizeof(xcb_shape_rectangles_request_t))/sizeof(xcb_rectangle_t));
    i.index = (char *) i.data - (char *) R;
    return i;
}

xcb_void_cookie_t
xcb_shape_mask_checked (xcb_connection_t *c,
                        xcb_shape_op_t    operation,
                        xcb_shape_kind_t  destination_kind,
                        xcb_window_t      destination_window,
                        int16_t           x_offset,
                        int16_t           y_offset,
                        xcb_pixmap_t      source_bitmap)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_MASK,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_shape_mask_request_t xcb_out;

    xcb_out.operation = operation;
    xcb_out.destination_kind = destination_kind;
    memset(xcb_out.pad0, 0, 2);
    xcb_out.destination_window = destination_window;
    xcb_out.x_offset = x_offset;
    xcb_out.y_offset = y_offset;
    xcb_out.source_bitmap = source_bitmap;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_shape_mask (xcb_connection_t *c,
                xcb_shape_op_t    operation,
                xcb_shape_kind_t  destination_kind,
                xcb_window_t      destination_window,
                int16_t           x_offset,
                int16_t           y_offset,
                xcb_pixmap_t      source_bitmap)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_MASK,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_shape_mask_request_t xcb_out;

    xcb_out.operation = operation;
    xcb_out.destination_kind = destination_kind;
    memset(xcb_out.pad0, 0, 2);
    xcb_out.destination_window = destination_window;
    xcb_out.x_offset = x_offset;
    xcb_out.y_offset = y_offset;
    xcb_out.source_bitmap = source_bitmap;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_shape_combine_checked (xcb_connection_t *c,
                           xcb_shape_op_t    operation,
                           xcb_shape_kind_t  destination_kind,
                           xcb_shape_kind_t  source_kind,
                           xcb_window_t      destination_window,
                           int16_t           x_offset,
                           int16_t           y_offset,
                           xcb_window_t      source_window)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_COMBINE,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_shape_combine_request_t xcb_out;

    xcb_out.operation = operation;
    xcb_out.destination_kind = destination_kind;
    xcb_out.source_kind = source_kind;
    xcb_out.pad0 = 0;
    xcb_out.destination_window = destination_window;
    xcb_out.x_offset = x_offset;
    xcb_out.y_offset = y_offset;
    xcb_out.source_window = source_window;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_shape_combine (xcb_connection_t *c,
                   xcb_shape_op_t    operation,
                   xcb_shape_kind_t  destination_kind,
                   xcb_shape_kind_t  source_kind,
                   xcb_window_t      destination_window,
                   int16_t           x_offset,
                   int16_t           y_offset,
                   xcb_window_t      source_window)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_COMBINE,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_shape_combine_request_t xcb_out;

    xcb_out.operation = operation;
    xcb_out.destination_kind = destination_kind;
    xcb_out.source_kind = source_kind;
    xcb_out.pad0 = 0;
    xcb_out.destination_window = destination_window;
    xcb_out.x_offset = x_offset;
    xcb_out.y_offset = y_offset;
    xcb_out.source_window = source_window;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_shape_offset_checked (xcb_connection_t *c,
                          xcb_shape_kind_t  destination_kind,
                          xcb_window_t      destination_window,
                          int16_t           x_offset,
                          int16_t           y_offset)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_OFFSET,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_shape_offset_request_t xcb_out;

    xcb_out.destination_kind = destination_kind;
    memset(xcb_out.pad0, 0, 3);
    xcb_out.destination_window = destination_window;
    xcb_out.x_offset = x_offset;
    xcb_out.y_offset = y_offset;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_shape_offset (xcb_connection_t *c,
                  xcb_shape_kind_t  destination_kind,
                  xcb_window_t      destination_window,
                  int16_t           x_offset,
                  int16_t           y_offset)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_OFFSET,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_shape_offset_request_t xcb_out;

    xcb_out.destination_kind = destination_kind;
    memset(xcb_out.pad0, 0, 3);
    xcb_out.destination_window = destination_window;
    xcb_out.x_offset = x_offset;
    xcb_out.y_offset = y_offset;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_shape_query_extents_cookie_t
xcb_shape_query_extents (xcb_connection_t *c,
                         xcb_window_t      destination_window)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_QUERY_EXTENTS,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_shape_query_extents_cookie_t xcb_ret;
    xcb_shape_query_extents_request_t xcb_out;

    xcb_out.destination_window = destination_window;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_shape_query_extents_cookie_t
xcb_shape_query_extents_unchecked (xcb_connection_t *c,
                                   xcb_window_t      destination_window)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_QUERY_EXTENTS,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_shape_query_extents_cookie_t xcb_ret;
    xcb_shape_query_extents_request_t xcb_out;

    xcb_out.destination_window = destination_window;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_shape_query_extents_reply_t *
xcb_shape_query_extents_reply (xcb_connection_t                  *c,
                               xcb_shape_query_extents_cookie_t   cookie  /**< */,
                               xcb_generic_error_t              **e)
{
    return (xcb_shape_query_extents_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
}

xcb_void_cookie_t
xcb_shape_select_input_checked (xcb_connection_t *c,
                                xcb_window_t      destination_window,
                                uint8_t           enable)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_SELECT_INPUT,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_shape_select_input_request_t xcb_out;

    xcb_out.destination_window = destination_window;
    xcb_out.enable = enable;
    memset(xcb_out.pad0, 0, 3);

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_shape_select_input (xcb_connection_t *c,
                        xcb_window_t      destination_window,
                        uint8_t           enable)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_SELECT_INPUT,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_shape_select_input_request_t xcb_out;

    xcb_out.destination_window = destination_window;
    xcb_out.enable = enable;
    memset(xcb_out.pad0, 0, 3);

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_shape_input_selected_cookie_t
xcb_shape_input_selected (xcb_connection_t *c,
                          xcb_window_t      destination_window)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_INPUT_SELECTED,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_shape_input_selected_cookie_t xcb_ret;
    xcb_shape_input_selected_request_t xcb_out;

    xcb_out.destination_window = destination_window;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_shape_input_selected_cookie_t
xcb_shape_input_selected_unchecked (xcb_connection_t *c,
                                    xcb_window_t      destination_window)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_INPUT_SELECTED,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_shape_input_selected_cookie_t xcb_ret;
    xcb_shape_input_selected_request_t xcb_out;

    xcb_out.destination_window = destination_window;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_shape_input_selected_reply_t *
xcb_shape_input_selected_reply (xcb_connection_t                   *c,
                                xcb_shape_input_selected_cookie_t   cookie  /**< */,
                                xcb_generic_error_t               **e)
{
    return (xcb_shape_input_selected_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
}

int
xcb_shape_get_rectangles_sizeof (const void  *_buffer)
{
    char *xcb_tmp = (char *)_buffer;
    const xcb_shape_get_rectangles_reply_t *_aux = (xcb_shape_get_rectangles_reply_t *)_buffer;
    unsigned int xcb_buffer_len = 0;
    unsigned int xcb_block_len = 0;
    unsigned int xcb_pad = 0;
    unsigned int xcb_align_to = 0;


    xcb_block_len += sizeof(xcb_shape_get_rectangles_reply_t);
    xcb_tmp += xcb_block_len;
    xcb_buffer_len += xcb_block_len;
    xcb_block_len = 0;
    /* rectangles */
    xcb_block_len += _aux->rectangles_len * sizeof(xcb_rectangle_t);
    xcb_tmp += xcb_block_len;
    xcb_align_to = ALIGNOF(xcb_rectangle_t);
    /* insert padding */
    xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    xcb_buffer_len += xcb_block_len + xcb_pad;
    if (0 != xcb_pad) {
        xcb_tmp += xcb_pad;
        xcb_pad = 0;
    }
    xcb_block_len = 0;

    return xcb_buffer_len;
}

xcb_shape_get_rectangles_cookie_t
xcb_shape_get_rectangles (xcb_connection_t *c,
                          xcb_window_t      window,
                          xcb_shape_kind_t  source_kind)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_GET_RECTANGLES,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_shape_get_rectangles_cookie_t xcb_ret;
    xcb_shape_get_rectangles_request_t xcb_out;

    xcb_out.window = window;
    xcb_out.source_kind = source_kind;
    memset(xcb_out.pad0, 0, 3);

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_shape_get_rectangles_cookie_t
xcb_shape_get_rectangles_unchecked (xcb_connection_t *c,
                                    xcb_window_t      window,
                                    xcb_shape_kind_t  source_kind)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_shape_id,
        .opcode = XCB_SHAPE_GET_RECTANGLES,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_shape_get_rectangles_cookie_t xcb_ret;
    xcb_shape_get_rectangles_request_t xcb_out;

    xcb_out.window = window;
    xcb_out.source_kind = source_kind;
    memset(xcb_out.pad0, 0, 3);

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_rectangle_t *
xcb_shape_get_rectangles_rectangles (const xcb_shape_get_rectangles_reply_t *R)
{
    return (xcb_rectangle_t *) (R + 1);
}

int
xcb_shape_get_rectangles_rectangles_length (const xcb_shape_get_rectangles_reply_t *R)
{
    return R->rectangles_len;
}

xcb_rectangle_iterator_t
xcb_shape_get_rectangles_rectangles_iterator (const xcb_shape_get_rectangles_reply_t *R)
{
    xcb_rectangle_iterator_t i;
    i.data = (xcb_rectangle_t *) (R + 1);
    i.rem = R->rectangles_len;
    i.index = (char *) i.data - (char *) R;
    return i;
}

xcb_shape_get_rectangles_reply_t *
xcb_shape_get_rectangles_reply (xcb_connection_t                   *c,
                                xcb_shape_get_rectangles_cookie_t   cookie  /**< */,
                                xcb_generic_error_t               **e)
{
    return (xcb_shape_get_rectangles_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
}
예제 #16
0
파일: mcache.c 프로젝트: deadcafe/JohnDoe
		if (!next)
			break;
	}
}

void *
_mc_alloc_raw(struct mcache *cache,
	      size_t size,
	      const char *file __attribute__((unused)),
	      const char *func __attribute__((unused)),
	      size_t line __attribute__((unused)))
{
	struct mc_chunk *chunk;
	struct mc_obj *obj = NULL;

	size = ALIGNOF(size);
	chunk = TAILQ_FIRST(&cache->chunks);
	if (chunk->size - sizeof(*chunk) - sizeof(*obj) < size)
		return NULL;
	while (!obj) {
		obj = TAILQ_FIRST(&chunk->objs);
		if (obj->size >= sizeof(*obj) + size) {
			obj = split_obj(chunk, obj, size);
		} else {
			if (cache->reserve) {
				chunk = cache->reserve;
				cache->reserve = NULL;
				create_obj(chunk);
			} else if ((chunk = alloc_chunk(chunk->size)) == NULL)
				return NULL;
			chunk->cache = cache;
예제 #17
0
xcb_xinerama_query_version_cookie_t
xcb_xinerama_query_version (xcb_connection_t *c,
                            uint8_t           major,
                            uint8_t           minor)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_xinerama_id,
        .opcode = XCB_XINERAMA_QUERY_VERSION,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_xinerama_query_version_cookie_t xcb_ret;
    xcb_xinerama_query_version_request_t xcb_out;

    xcb_out.major = major;
    xcb_out.minor = minor;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_xinerama_query_version_cookie_t
xcb_xinerama_query_version_unchecked (xcb_connection_t *c,
                                      uint8_t           major,
                                      uint8_t           minor)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_xinerama_id,
        .opcode = XCB_XINERAMA_QUERY_VERSION,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_xinerama_query_version_cookie_t xcb_ret;
    xcb_xinerama_query_version_request_t xcb_out;

    xcb_out.major = major;
    xcb_out.minor = minor;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_xinerama_query_version_reply_t *
xcb_xinerama_query_version_reply (xcb_connection_t                     *c,
                                  xcb_xinerama_query_version_cookie_t   cookie  /**< */,
                                  xcb_generic_error_t                 **e)
{
    return (xcb_xinerama_query_version_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
}

xcb_xinerama_get_state_cookie_t
xcb_xinerama_get_state (xcb_connection_t *c,
                        xcb_window_t      window)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_xinerama_id,
        .opcode = XCB_XINERAMA_GET_STATE,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_xinerama_get_state_cookie_t xcb_ret;
    xcb_xinerama_get_state_request_t xcb_out;

    xcb_out.window = window;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_xinerama_get_state_cookie_t
xcb_xinerama_get_state_unchecked (xcb_connection_t *c,
                                  xcb_window_t      window)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_xinerama_id,
        .opcode = XCB_XINERAMA_GET_STATE,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_xinerama_get_state_cookie_t xcb_ret;
    xcb_xinerama_get_state_request_t xcb_out;

    xcb_out.window = window;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_xinerama_get_state_reply_t *
xcb_xinerama_get_state_reply (xcb_connection_t                 *c,
                              xcb_xinerama_get_state_cookie_t   cookie  /**< */,
                              xcb_generic_error_t             **e)
{
    return (xcb_xinerama_get_state_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
}

xcb_xinerama_get_screen_count_cookie_t
xcb_xinerama_get_screen_count (xcb_connection_t *c,
                               xcb_window_t      window)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_xinerama_id,
        .opcode = XCB_XINERAMA_GET_SCREEN_COUNT,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_xinerama_get_screen_count_cookie_t xcb_ret;
    xcb_xinerama_get_screen_count_request_t xcb_out;

    xcb_out.window = window;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_xinerama_get_screen_count_cookie_t
xcb_xinerama_get_screen_count_unchecked (xcb_connection_t *c,
                                         xcb_window_t      window)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_xinerama_id,
        .opcode = XCB_XINERAMA_GET_SCREEN_COUNT,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_xinerama_get_screen_count_cookie_t xcb_ret;
    xcb_xinerama_get_screen_count_request_t xcb_out;

    xcb_out.window = window;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_xinerama_get_screen_count_reply_t *
xcb_xinerama_get_screen_count_reply (xcb_connection_t                        *c,
                                     xcb_xinerama_get_screen_count_cookie_t   cookie  /**< */,
                                     xcb_generic_error_t                    **e)
{
    return (xcb_xinerama_get_screen_count_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
}

xcb_xinerama_get_screen_size_cookie_t
xcb_xinerama_get_screen_size (xcb_connection_t *c,
                              xcb_window_t      window,
                              uint32_t          screen)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_xinerama_id,
        .opcode = XCB_XINERAMA_GET_SCREEN_SIZE,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_xinerama_get_screen_size_cookie_t xcb_ret;
    xcb_xinerama_get_screen_size_request_t xcb_out;

    xcb_out.window = window;
    xcb_out.screen = screen;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_xinerama_get_screen_size_cookie_t
xcb_xinerama_get_screen_size_unchecked (xcb_connection_t *c,
                                        xcb_window_t      window,
                                        uint32_t          screen)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_xinerama_id,
        .opcode = XCB_XINERAMA_GET_SCREEN_SIZE,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_xinerama_get_screen_size_cookie_t xcb_ret;
    xcb_xinerama_get_screen_size_request_t xcb_out;

    xcb_out.window = window;
    xcb_out.screen = screen;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_xinerama_get_screen_size_reply_t *
xcb_xinerama_get_screen_size_reply (xcb_connection_t                       *c,
                                    xcb_xinerama_get_screen_size_cookie_t   cookie  /**< */,
                                    xcb_generic_error_t                   **e)
{
    return (xcb_xinerama_get_screen_size_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
}

xcb_xinerama_is_active_cookie_t
xcb_xinerama_is_active (xcb_connection_t *c)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_xinerama_id,
        .opcode = XCB_XINERAMA_IS_ACTIVE,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_xinerama_is_active_cookie_t xcb_ret;
    xcb_xinerama_is_active_request_t xcb_out;


    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_xinerama_is_active_cookie_t
xcb_xinerama_is_active_unchecked (xcb_connection_t *c)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_xinerama_id,
        .opcode = XCB_XINERAMA_IS_ACTIVE,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_xinerama_is_active_cookie_t xcb_ret;
    xcb_xinerama_is_active_request_t xcb_out;


    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_xinerama_is_active_reply_t *
xcb_xinerama_is_active_reply (xcb_connection_t                 *c,
                              xcb_xinerama_is_active_cookie_t   cookie  /**< */,
                              xcb_generic_error_t             **e)
{
    return (xcb_xinerama_is_active_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
}

int
xcb_xinerama_query_screens_sizeof (const void  *_buffer)
{
    char *xcb_tmp = (char *)_buffer;
    const xcb_xinerama_query_screens_reply_t *_aux = (xcb_xinerama_query_screens_reply_t *)_buffer;
    unsigned int xcb_buffer_len = 0;
    unsigned int xcb_block_len = 0;
    unsigned int xcb_pad = 0;
    unsigned int xcb_align_to = 0;


    xcb_block_len += sizeof(xcb_xinerama_query_screens_reply_t);
    xcb_tmp += xcb_block_len;
    xcb_buffer_len += xcb_block_len;
    xcb_block_len = 0;
    /* screen_info */
    xcb_block_len += _aux->number * sizeof(xcb_xinerama_screen_info_t);
    xcb_tmp += xcb_block_len;
    xcb_align_to = ALIGNOF(xcb_xinerama_screen_info_t);
    /* insert padding */
    xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    xcb_buffer_len += xcb_block_len + xcb_pad;
    if (0 != xcb_pad) {
        xcb_tmp += xcb_pad;
        xcb_pad = 0;
    }
    xcb_block_len = 0;

    return xcb_buffer_len;
}

xcb_xinerama_query_screens_cookie_t
xcb_xinerama_query_screens (xcb_connection_t *c)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_xinerama_id,
        .opcode = XCB_XINERAMA_QUERY_SCREENS,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_xinerama_query_screens_cookie_t xcb_ret;
    xcb_xinerama_query_screens_request_t xcb_out;


    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_xinerama_query_screens_cookie_t
xcb_xinerama_query_screens_unchecked (xcb_connection_t *c)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_xinerama_id,
        .opcode = XCB_XINERAMA_QUERY_SCREENS,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_xinerama_query_screens_cookie_t xcb_ret;
    xcb_xinerama_query_screens_request_t xcb_out;


    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_xinerama_screen_info_t *
xcb_xinerama_query_screens_screen_info (const xcb_xinerama_query_screens_reply_t *R)
{
    return (xcb_xinerama_screen_info_t *) (R + 1);
}

int
xcb_xinerama_query_screens_screen_info_length (const xcb_xinerama_query_screens_reply_t *R)
{
    return R->number;
}

xcb_xinerama_screen_info_iterator_t
xcb_xinerama_query_screens_screen_info_iterator (const xcb_xinerama_query_screens_reply_t *R)
{
    xcb_xinerama_screen_info_iterator_t i;
    i.data = (xcb_xinerama_screen_info_t *) (R + 1);
    i.rem = R->number;
    i.index = (char *) i.data - (char *) R;
    return i;
}

xcb_xinerama_query_screens_reply_t *
xcb_xinerama_query_screens_reply (xcb_connection_t                     *c,
                                  xcb_xinerama_query_screens_cookie_t   cookie  /**< */,
                                  xcb_generic_error_t                 **e)
{
    return (xcb_xinerama_query_screens_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
}
예제 #18
0
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.

/*=============================================================================
	GenericPlatformAtomics.cpp: Generic implementations of atomic functions
=============================================================================*/

#include "CorePrivatePCH.h"

static_assert(sizeof(FInt128) == 16, "FInt128 size must be 16 bytes.");
static_assert(ALIGNOF(FInt128) == 16, "FInt128 alignment must equals 16.");
예제 #19
0
xcb_present_query_version_cookie_t
xcb_present_query_version (xcb_connection_t *c,
                           uint32_t          major_version,
                           uint32_t          minor_version)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_present_id,
        .opcode = XCB_PRESENT_QUERY_VERSION,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_present_query_version_cookie_t xcb_ret;
    xcb_present_query_version_request_t xcb_out;

    xcb_out.major_version = major_version;
    xcb_out.minor_version = minor_version;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_present_query_version_cookie_t
xcb_present_query_version_unchecked (xcb_connection_t *c,
                                     uint32_t          major_version,
                                     uint32_t          minor_version)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_present_id,
        .opcode = XCB_PRESENT_QUERY_VERSION,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_present_query_version_cookie_t xcb_ret;
    xcb_present_query_version_request_t xcb_out;

    xcb_out.major_version = major_version;
    xcb_out.minor_version = minor_version;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_present_query_version_reply_t *
xcb_present_query_version_reply (xcb_connection_t                    *c,
                                 xcb_present_query_version_cookie_t   cookie  /**< */,
                                 xcb_generic_error_t                **e)
{
    return (xcb_present_query_version_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
}

int
xcb_present_pixmap_sizeof (const void  *_buffer,
                           uint32_t     notifies_len)
{
    char *xcb_tmp = (char *)_buffer;
    unsigned int xcb_buffer_len = 0;
    unsigned int xcb_block_len = 0;
    unsigned int xcb_pad = 0;
    unsigned int xcb_align_to = 0;


    xcb_block_len += sizeof(xcb_present_pixmap_request_t);
    xcb_tmp += xcb_block_len;
    xcb_buffer_len += xcb_block_len;
    xcb_block_len = 0;
    /* notifies */
    xcb_block_len += notifies_len * sizeof(xcb_present_notify_t);
    xcb_tmp += xcb_block_len;
    xcb_align_to = ALIGNOF(xcb_present_notify_t);
    /* insert padding */
    xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    xcb_buffer_len += xcb_block_len + xcb_pad;
    if (0 != xcb_pad) {
        xcb_tmp += xcb_pad;
        xcb_pad = 0;
    }
    xcb_block_len = 0;

    return xcb_buffer_len;
}

xcb_void_cookie_t
xcb_present_pixmap_checked (xcb_connection_t           *c,
                            xcb_window_t                window,
                            xcb_pixmap_t                pixmap,
                            uint32_t                    serial,
                            xcb_xfixes_region_t         valid,
                            xcb_xfixes_region_t         update,
                            int16_t                     x_off,
                            int16_t                     y_off,
                            xcb_randr_crtc_t            target_crtc,
                            xcb_sync_fence_t            wait_fence,
                            xcb_sync_fence_t            idle_fence,
                            uint32_t                    options,
                            uint64_t                    target_msc,
                            uint64_t                    divisor,
                            uint64_t                    remainder,
                            uint32_t                    notifies_len,
                            const xcb_present_notify_t *notifies)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 4,
        .ext = &xcb_present_id,
        .opcode = XCB_PRESENT_PIXMAP,
        .isvoid = 1
    };

    struct iovec xcb_parts[6];
    xcb_void_cookie_t xcb_ret;
    xcb_present_pixmap_request_t xcb_out;

    xcb_out.window = window;
    xcb_out.pixmap = pixmap;
    xcb_out.serial = serial;
    xcb_out.valid = valid;
    xcb_out.update = update;
    xcb_out.x_off = x_off;
    xcb_out.y_off = y_off;
    xcb_out.target_crtc = target_crtc;
    xcb_out.wait_fence = wait_fence;
    xcb_out.idle_fence = idle_fence;
    xcb_out.options = options;
    memset(xcb_out.pad0, 0, 4);
    xcb_out.target_msc = target_msc;
    xcb_out.divisor = divisor;
    xcb_out.remainder = remainder;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    /* xcb_present_notify_t notifies */
    xcb_parts[4].iov_base = (char *) notifies;
    xcb_parts[4].iov_len = notifies_len * sizeof(xcb_present_notify_t);
    xcb_parts[5].iov_base = 0;
    xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_present_pixmap (xcb_connection_t           *c,
                    xcb_window_t                window,
                    xcb_pixmap_t                pixmap,
                    uint32_t                    serial,
                    xcb_xfixes_region_t         valid,
                    xcb_xfixes_region_t         update,
                    int16_t                     x_off,
                    int16_t                     y_off,
                    xcb_randr_crtc_t            target_crtc,
                    xcb_sync_fence_t            wait_fence,
                    xcb_sync_fence_t            idle_fence,
                    uint32_t                    options,
                    uint64_t                    target_msc,
                    uint64_t                    divisor,
                    uint64_t                    remainder,
                    uint32_t                    notifies_len,
                    const xcb_present_notify_t *notifies)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 4,
        .ext = &xcb_present_id,
        .opcode = XCB_PRESENT_PIXMAP,
        .isvoid = 1
    };

    struct iovec xcb_parts[6];
    xcb_void_cookie_t xcb_ret;
    xcb_present_pixmap_request_t xcb_out;

    xcb_out.window = window;
    xcb_out.pixmap = pixmap;
    xcb_out.serial = serial;
    xcb_out.valid = valid;
    xcb_out.update = update;
    xcb_out.x_off = x_off;
    xcb_out.y_off = y_off;
    xcb_out.target_crtc = target_crtc;
    xcb_out.wait_fence = wait_fence;
    xcb_out.idle_fence = idle_fence;
    xcb_out.options = options;
    memset(xcb_out.pad0, 0, 4);
    xcb_out.target_msc = target_msc;
    xcb_out.divisor = divisor;
    xcb_out.remainder = remainder;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    /* xcb_present_notify_t notifies */
    xcb_parts[4].iov_base = (char *) notifies;
    xcb_parts[4].iov_len = notifies_len * sizeof(xcb_present_notify_t);
    xcb_parts[5].iov_base = 0;
    xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_present_notify_t *
xcb_present_pixmap_notifies (const xcb_present_pixmap_request_t *R)
{
    return (xcb_present_notify_t *) (R + 1);
}

int
xcb_present_pixmap_notifies_length (const xcb_present_pixmap_request_t *R)
{
    return (((R->length * 4) - sizeof(xcb_present_pixmap_request_t))/sizeof(xcb_present_notify_t));
}

xcb_present_notify_iterator_t
xcb_present_pixmap_notifies_iterator (const xcb_present_pixmap_request_t *R)
{
    xcb_present_notify_iterator_t i;
    i.data = (xcb_present_notify_t *) (R + 1);
    i.rem = (((R->length * 4) - sizeof(xcb_present_pixmap_request_t))/sizeof(xcb_present_notify_t));
    i.index = (char *) i.data - (char *) R;
    return i;
}

xcb_void_cookie_t
xcb_present_notify_msc_checked (xcb_connection_t *c,
                                xcb_window_t      window,
                                uint32_t          serial,
                                uint64_t          target_msc,
                                uint64_t          divisor,
                                uint64_t          remainder)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_present_id,
        .opcode = XCB_PRESENT_NOTIFY_MSC,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_present_notify_msc_request_t xcb_out;

    xcb_out.window = window;
    xcb_out.serial = serial;
    memset(xcb_out.pad0, 0, 4);
    xcb_out.target_msc = target_msc;
    xcb_out.divisor = divisor;
    xcb_out.remainder = remainder;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_present_notify_msc (xcb_connection_t *c,
                        xcb_window_t      window,
                        uint32_t          serial,
                        uint64_t          target_msc,
                        uint64_t          divisor,
                        uint64_t          remainder)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_present_id,
        .opcode = XCB_PRESENT_NOTIFY_MSC,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_present_notify_msc_request_t xcb_out;

    xcb_out.window = window;
    xcb_out.serial = serial;
    memset(xcb_out.pad0, 0, 4);
    xcb_out.target_msc = target_msc;
    xcb_out.divisor = divisor;
    xcb_out.remainder = remainder;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

void
xcb_present_event_next (xcb_present_event_iterator_t *i)
{
    --i->rem;
    ++i->data;
    i->index += sizeof(xcb_present_event_t);
}

xcb_generic_iterator_t
xcb_present_event_end (xcb_present_event_iterator_t i)
{
    xcb_generic_iterator_t ret;
    ret.data = i.data + i.rem;
    ret.index = i.index + ((char *) ret.data - (char *) i.data);
    ret.rem = 0;
    return ret;
}

xcb_void_cookie_t
xcb_present_select_input_checked (xcb_connection_t    *c,
                                  xcb_present_event_t  eid,
                                  xcb_window_t         window,
                                  uint32_t             event_mask)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_present_id,
        .opcode = XCB_PRESENT_SELECT_INPUT,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_present_select_input_request_t xcb_out;

    xcb_out.eid = eid;
    xcb_out.window = window;
    xcb_out.event_mask = event_mask;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_present_select_input (xcb_connection_t    *c,
                          xcb_present_event_t  eid,
                          xcb_window_t         window,
                          uint32_t             event_mask)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_present_id,
        .opcode = XCB_PRESENT_SELECT_INPUT,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_present_select_input_request_t xcb_out;

    xcb_out.eid = eid;
    xcb_out.window = window;
    xcb_out.event_mask = event_mask;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_present_query_capabilities_cookie_t
xcb_present_query_capabilities (xcb_connection_t *c,
                                uint32_t          target)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_present_id,
        .opcode = XCB_PRESENT_QUERY_CAPABILITIES,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_present_query_capabilities_cookie_t xcb_ret;
    xcb_present_query_capabilities_request_t xcb_out;

    xcb_out.target = target;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_present_query_capabilities_cookie_t
xcb_present_query_capabilities_unchecked (xcb_connection_t *c,
                                          uint32_t          target)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_present_id,
        .opcode = XCB_PRESENT_QUERY_CAPABILITIES,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_present_query_capabilities_cookie_t xcb_ret;
    xcb_present_query_capabilities_request_t xcb_out;

    xcb_out.target = target;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_present_query_capabilities_reply_t *
xcb_present_query_capabilities_reply (xcb_connection_t                         *c,
                                      xcb_present_query_capabilities_cookie_t   cookie  /**< */,
                                      xcb_generic_error_t                     **e)
{
    return (xcb_present_query_capabilities_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
}

int
xcb_present_redirect_notify_sizeof (const void  *_buffer,
                                    uint32_t     notifies_len)
{
    char *xcb_tmp = (char *)_buffer;
    unsigned int xcb_buffer_len = 0;
    unsigned int xcb_block_len = 0;
    unsigned int xcb_pad = 0;
    unsigned int xcb_align_to = 0;


    xcb_block_len += sizeof(xcb_present_redirect_notify_event_t);
    xcb_tmp += xcb_block_len;
    xcb_buffer_len += xcb_block_len;
    xcb_block_len = 0;
    /* notifies */
    xcb_block_len += notifies_len * sizeof(xcb_present_notify_t);
    xcb_tmp += xcb_block_len;
    xcb_align_to = ALIGNOF(xcb_present_notify_t);
    /* insert padding */
    xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    xcb_buffer_len += xcb_block_len + xcb_pad;
    if (0 != xcb_pad) {
        xcb_tmp += xcb_pad;
        xcb_pad = 0;
    }
    xcb_block_len = 0;

    return xcb_buffer_len;
}

xcb_present_notify_t *
xcb_present_redirect_notify_notifies (const xcb_present_redirect_notify_event_t *R)
{
    return (xcb_present_notify_t *) (R + 1);
}

int
xcb_present_redirect_notify_notifies_length (const xcb_present_redirect_notify_event_t *R)
{
    return (((R->length * 4) - sizeof(xcb_present_redirect_notify_event_t))/sizeof(xcb_present_notify_t));
}

xcb_present_notify_iterator_t
xcb_present_redirect_notify_notifies_iterator (const xcb_present_redirect_notify_event_t *R)
{
    xcb_present_notify_iterator_t i;
    i.data = (xcb_present_notify_t *) (R + 1);
    i.rem = (((R->length * 4) - sizeof(xcb_present_redirect_notify_event_t))/sizeof(xcb_present_notify_t));
    i.index = (char *) i.data - (char *) R;
    return i;
}
예제 #20
0
bool FPlatformVerificationTest::RunTest (const FString& Parameters)
{
	PTRINT Offset1 = VTABLE_OFFSET(TestC, TestB);
	PTRINT Offset2 = VTABLE_OFFSET(TestC, TestA);
	check(Offset1 == 64 + sizeof(void*));
	check(Offset2 == 0);
	int32 Test = 0x12345678;
#if PLATFORM_LITTLE_ENDIAN
	check(*(uint8*)&Test == 0x78);
#else
	check(*(uint8*)&Test == 0x12);
#endif
	check(FMath::IsNaN(sqrtf(-1.0f)));
	check(!FMath::IsFinite(sqrtf(-1.0f)));
	check(!FMath::IsFinite(-1.0f/TheCompilerDoesntKnowThisIsAlwaysZero));
	check(!FMath::IsFinite(1.0f/TheCompilerDoesntKnowThisIsAlwaysZero));
	check(!FMath::IsNaN(-1.0f/TheCompilerDoesntKnowThisIsAlwaysZero));
	check(!FMath::IsNaN(1.0f/TheCompilerDoesntKnowThisIsAlwaysZero));
	check(!FMath::IsNaN(MAX_FLT));
	check(FMath::IsFinite(MAX_FLT));
	check(!FMath::IsNaN(0.0f));
	check(FMath::IsFinite(0.0f));
	check(!FMath::IsNaN(1.0f));
	check(FMath::IsFinite(1.0f));
	check(!FMath::IsNaN(-1.e37f));
	check(FMath::IsFinite(-1.e37f));
	check(FMath::FloorLog2(0) == 0);
	check(FMath::FloorLog2(1) == 0);
	check(FMath::FloorLog2(2) == 1);
	check(FMath::FloorLog2(12) == 3);
	check(FMath::FloorLog2(16) == 4);

	FGenericPlatformMath::AutoTest();

#if WITH_EDITORONLY_DATA
	check(FPlatformProperties::HasEditorOnlyData());
#else
	check(!FPlatformProperties::HasEditorOnlyData());
#endif

	check(FPlatformProperties::HasEditorOnlyData() != FPlatformProperties::RequiresCookedData());

#if PLATFORM_LITTLE_ENDIAN
	check(FPlatformProperties::IsLittleEndian());
#else
	check(!FPlatformProperties::IsLittleEndian());
#endif
	check(FPlatformProperties::PlatformName());

	check(FString(FPlatformProperties::PlatformName()).Len() > 0); 

	static_assert(ALIGNOF(int32) == 4, "Align of int32 is not 4."); //Hmmm, this would be very strange, ok maybe, but strange

	MS_ALIGN(16) struct FTestAlign
	{
		uint8 Test;
	} GCC_ALIGN(16);

	static_assert(ALIGNOF(FTestAlign) == 16, "Align of FTestAlign is not 16.");

	FName::AutoTest();

	return true;
}
예제 #21
0
int
main(void)
{
	static const kernel_ulong_t unknown_loop_cmd =
		(kernel_ulong_t) 0xbadc0dedfeed4cedULL;
	static const kernel_ulong_t magic =
		(kernel_ulong_t) 0xdeadbeefbadc0dedULL;
	static const kernel_ulong_t kernel_mask =
		((kernel_ulong_t) -1) - ((unsigned long) -1L);

	TAIL_ALLOC_OBJECT_CONST_PTR(struct loop_info, info);
	TAIL_ALLOC_OBJECT_CONST_PTR(struct loop_info64, info64);

	/* Unknown loop commands */
	ioctl(-1, unknown_loop_cmd, magic);
	printf("ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE%s, 0x4c, %#x, %#x), "
	       "%#lx) = -1 EBADF (%m)\n",
	       _IOC_DIR((unsigned int) unknown_loop_cmd) & _IOC_NONE ?
	       "|_IOC_NONE" : "",
	       _IOC_NR((unsigned int) unknown_loop_cmd),
	       _IOC_SIZE((unsigned int) unknown_loop_cmd),
	       (unsigned long) magic);

	ioctl(-1, LOOP_SET_BLOCK_SIZE + 1, magic);
	printf("ioctl(-1, _IOC(0, 0x4c, %#x, %#x), %#lx) = "
	       "-1 EBADF (%m)\n",
	       _IOC_NR(LOOP_SET_BLOCK_SIZE + 1),
	       _IOC_SIZE(LOOP_SET_BLOCK_SIZE + 1),
	       (unsigned long) magic);

	ioctl(-1, LOOP_CTL_GET_FREE + 1, magic);
	printf("ioctl(-1, _IOC(0, 0x4c, %#x, %#x), %#lx) = "
	       "-1 EBADF (%m)\n",
	       _IOC_NR(LOOP_CTL_GET_FREE + 1),
	       _IOC_SIZE(LOOP_CTL_GET_FREE + 1),
	       (unsigned long) magic);

	/* LOOP_SET_FD */
	ioctl(-1, LOOP_SET_FD, magic);
	printf("ioctl(-1, LOOP_SET_FD, %d) = -1 EBADF (%m)\n",
	       (unsigned int) magic);

	/* LOOP_CLR_FD */
	ioctl(-1, LOOP_CLR_FD);
	printf("ioctl(-1, LOOP_CLR_FD) = -1 EBADF (%m)\n");

	/* LOOP_SET_STATUS */
	ioctl(-1, LOOP_SET_STATUS, NULL);
	printf("ioctl(-1, LOOP_SET_STATUS, NULL) = -1 EBADF (%m)\n");

	fill_memory(info, sizeof(*info));
	info->lo_flags = 0xdeface00;
	info->lo_name[0] = '\0';
	info->lo_encrypt_key[0] = '\0';
	info->lo_encrypt_key_size = 1;

	printf("ioctl(-1, LOOP_SET_STATUS, ");
	print_loop_info(info, true, NULL, "\\0", NULL);
	ioctl(-1, LOOP_SET_STATUS, info);
	printf(") = -1 EBADF (%m)\n");

	fill_memory(info, sizeof(*info));
	info->lo_encrypt_type = LO_CRYPT_NONE;
	info->lo_flags = LO_FLAGS_READ_ONLY;
	memset(info->lo_name, 'A', sizeof(info->lo_name));
	memset(info->lo_encrypt_key, 'B', sizeof(info->lo_encrypt_key));

	ioctl(-1, LOOP_SET_STATUS, (void *) info + ALIGNOF(info));
	printf("ioctl(-1, LOOP_SET_STATUS, %p) = -1 EBADF (%m)\n",
	       (void *) info + ALIGNOF(info));

	printf("ioctl(-1, LOOP_SET_STATUS, ");
	print_loop_info(info, false, "LO_CRYPT_NONE", NULL,
			"LO_FLAGS_READ_ONLY");
	ioctl(-1, LOOP_SET_STATUS, info);
	printf(") = -1 EBADF (%m)\n");

	/* LOOP_GET_STATUS */
	ioctl(-1, LOOP_GET_STATUS, NULL);
	printf("ioctl(-1, LOOP_GET_STATUS, NULL) = -1 EBADF (%m)\n");

	ioctl(-1, LOOP_GET_STATUS, (unsigned long) info | kernel_mask);
	printf("ioctl(-1, LOOP_GET_STATUS, %p) = -1 EBADF (%m)\n", info);

	/* LOOP_SET_STATUS64 */
	ioctl(-1, LOOP_SET_STATUS64, NULL);
	printf("ioctl(-1, LOOP_SET_STATUS64, NULL) = -1 EBADF (%m)\n");

	fill_memory(info64, sizeof(*info64));
	info64->lo_flags = 0xdec0de00;
	info64->lo_file_name[0] = '\0';
	info64->lo_crypt_name[0] = '\0';
	info64->lo_encrypt_key[0] = '\0';
	info64->lo_encrypt_key_size = 1;

	printf("ioctl(-1, LOOP_SET_STATUS64, ");
	print_loop_info64(info64, true, NULL, "\\0", NULL);
	ioctl(-1, LOOP_SET_STATUS64, info64);
	printf(") = -1 EBADF (%m)\n");

	fill_memory(info64, sizeof(*info64));
	info64->lo_flags = LO_FLAGS_READ_ONLY;
	info64->lo_encrypt_type = LO_CRYPT_NONE;
	memset(info64->lo_file_name, 'C', sizeof(info64->lo_file_name));
	memset(info64->lo_crypt_name, 'D', sizeof(info64->lo_crypt_name));
	memset(info64->lo_encrypt_key, 'E', sizeof(info64->lo_encrypt_key));

	ioctl(-1, LOOP_SET_STATUS64, (void *) info64 + ALIGNOF(info64));
	printf("ioctl(-1, LOOP_SET_STATUS64, %p) = -1 EBADF (%m)\n",
	       (void *) info64 + ALIGNOF(info64));

	printf("ioctl(-1, LOOP_SET_STATUS64, ");
	print_loop_info64(info64, false, "LO_CRYPT_NONE", NULL,
			  "LO_FLAGS_READ_ONLY");
	ioctl(-1, LOOP_SET_STATUS64, info64);
	printf(") = -1 EBADF (%m)\n");

	/* LOOP_GET_STATUS64 */
	ioctl(-1, LOOP_GET_STATUS64, NULL);
	printf("ioctl(-1, LOOP_GET_STATUS64, NULL) = -1 EBADF (%m)\n");

	ioctl(-1, LOOP_GET_STATUS64, (unsigned long) info64 | kernel_mask);
	printf("ioctl(-1, LOOP_GET_STATUS64, %p) = -1 EBADF (%m)\n", info64);

	/* LOOP_CHANGE_FD */
	ioctl(-1, LOOP_CHANGE_FD, magic);
	printf("ioctl(-1, LOOP_CHANGE_FD, %d) = -1 EBADF (%m)\n",
	       (unsigned int) magic);

	/* LOOP_SET_CAPACITY */
	ioctl(-1, LOOP_SET_CAPACITY);
	printf("ioctl(-1, LOOP_SET_CAPACITY) = -1 EBADF (%m)\n");

	/* LOOP_SET_DIRECT_IO */
	ioctl(-1, LOOP_SET_DIRECT_IO, magic);
	printf("ioctl(-1, LOOP_SET_DIRECT_IO, %lu) = -1 EBADF (%m)\n",
	       (unsigned long) magic);

	/* LOOP_SET_BLOCK_SIZE */
	ioctl(-1, LOOP_SET_BLOCK_SIZE, magic);
	printf("ioctl(-1, LOOP_SET_BLOCK_SIZE, %lu) = -1 EBADF (%m)\n",
	       (unsigned long) magic);

	/* LOOP_CTL_ADD */
	ioctl(-1, LOOP_CTL_ADD, magic);
	printf("ioctl(-1, LOOP_CTL_ADD, %d) = -1 EBADF (%m)\n",
	       (unsigned int) magic);

	/* LOOP_CTL_REMOVE */
	ioctl(-1, LOOP_CTL_REMOVE, magic);
	printf("ioctl(-1, LOOP_CTL_REMOVE, %d) = -1 EBADF (%m)\n",
	       (unsigned int) magic);

	/* LOOP_CTL_GET_FREE */
	ioctl(-1, LOOP_CTL_GET_FREE);
	printf("ioctl(-1, LOOP_CTL_GET_FREE) = -1 EBADF (%m)\n");

	puts("+++ exited with 0 +++");
	return 0;
}
예제 #22
0
xcb_screensaver_query_version_cookie_t
xcb_screensaver_query_version (xcb_connection_t *c,
                               uint8_t           client_major_version,
                               uint8_t           client_minor_version)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_screensaver_id,
        .opcode = XCB_SCREENSAVER_QUERY_VERSION,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_screensaver_query_version_cookie_t xcb_ret;
    xcb_screensaver_query_version_request_t xcb_out;

    xcb_out.client_major_version = client_major_version;
    xcb_out.client_minor_version = client_minor_version;
    memset(xcb_out.pad0, 0, 2);

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_screensaver_query_version_cookie_t
xcb_screensaver_query_version_unchecked (xcb_connection_t *c,
                                         uint8_t           client_major_version,
                                         uint8_t           client_minor_version)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_screensaver_id,
        .opcode = XCB_SCREENSAVER_QUERY_VERSION,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_screensaver_query_version_cookie_t xcb_ret;
    xcb_screensaver_query_version_request_t xcb_out;

    xcb_out.client_major_version = client_major_version;
    xcb_out.client_minor_version = client_minor_version;
    memset(xcb_out.pad0, 0, 2);

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_screensaver_query_version_reply_t *
xcb_screensaver_query_version_reply (xcb_connection_t                        *c,
                                     xcb_screensaver_query_version_cookie_t   cookie  /**< */,
                                     xcb_generic_error_t                    **e)
{
    return (xcb_screensaver_query_version_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
}

xcb_screensaver_query_info_cookie_t
xcb_screensaver_query_info (xcb_connection_t *c,
                            xcb_drawable_t    drawable)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_screensaver_id,
        .opcode = XCB_SCREENSAVER_QUERY_INFO,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_screensaver_query_info_cookie_t xcb_ret;
    xcb_screensaver_query_info_request_t xcb_out;

    xcb_out.drawable = drawable;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_screensaver_query_info_cookie_t
xcb_screensaver_query_info_unchecked (xcb_connection_t *c,
                                      xcb_drawable_t    drawable)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_screensaver_id,
        .opcode = XCB_SCREENSAVER_QUERY_INFO,
        .isvoid = 0
    };

    struct iovec xcb_parts[4];
    xcb_screensaver_query_info_cookie_t xcb_ret;
    xcb_screensaver_query_info_request_t xcb_out;

    xcb_out.drawable = drawable;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_screensaver_query_info_reply_t *
xcb_screensaver_query_info_reply (xcb_connection_t                     *c,
                                  xcb_screensaver_query_info_cookie_t   cookie  /**< */,
                                  xcb_generic_error_t                 **e)
{
    return (xcb_screensaver_query_info_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
}

xcb_void_cookie_t
xcb_screensaver_select_input_checked (xcb_connection_t *c,
                                      xcb_drawable_t    drawable,
                                      uint32_t          event_mask)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_screensaver_id,
        .opcode = XCB_SCREENSAVER_SELECT_INPUT,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_screensaver_select_input_request_t xcb_out;

    xcb_out.drawable = drawable;
    xcb_out.event_mask = event_mask;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_screensaver_select_input (xcb_connection_t *c,
                              xcb_drawable_t    drawable,
                              uint32_t          event_mask)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_screensaver_id,
        .opcode = XCB_SCREENSAVER_SELECT_INPUT,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_screensaver_select_input_request_t xcb_out;

    xcb_out.drawable = drawable;
    xcb_out.event_mask = event_mask;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

int
xcb_screensaver_set_attributes_value_list_serialize (void                                              **_buffer,
                                                     uint32_t                                            value_mask,
                                                     const xcb_screensaver_set_attributes_value_list_t  *_aux)
{
    char *xcb_out = *_buffer;
    unsigned int xcb_buffer_len = 0;
    unsigned int xcb_align_to = 0;
    unsigned int xcb_padding_offset = 0;

    unsigned int xcb_pad = 0;
    char xcb_pad0[3] = {0, 0, 0};
    struct iovec xcb_parts[16];
    unsigned int xcb_parts_idx = 0;
    unsigned int xcb_block_len = 0;
    unsigned int i;
    char *xcb_tmp;

    if(value_mask & XCB_CW_BACK_PIXMAP) {
        /* xcb_screensaver_set_attributes_value_list_t.background_pixmap */
        xcb_parts[xcb_parts_idx].iov_base = (char *) &_aux->background_pixmap;
        xcb_block_len += sizeof(xcb_pixmap_t);
        xcb_parts[xcb_parts_idx].iov_len = sizeof(xcb_pixmap_t);
        xcb_parts_idx++;
        xcb_align_to = ALIGNOF(xcb_pixmap_t);
    }
    if(value_mask & XCB_CW_BACK_PIXEL) {
        /* xcb_screensaver_set_attributes_value_list_t.background_pixel */
        xcb_parts[xcb_parts_idx].iov_base = (char *) &_aux->background_pixel;
        xcb_block_len += sizeof(uint32_t);
        xcb_parts[xcb_parts_idx].iov_len = sizeof(uint32_t);
        xcb_parts_idx++;
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_BORDER_PIXMAP) {
        /* xcb_screensaver_set_attributes_value_list_t.border_pixmap */
        xcb_parts[xcb_parts_idx].iov_base = (char *) &_aux->border_pixmap;
        xcb_block_len += sizeof(xcb_pixmap_t);
        xcb_parts[xcb_parts_idx].iov_len = sizeof(xcb_pixmap_t);
        xcb_parts_idx++;
        xcb_align_to = ALIGNOF(xcb_pixmap_t);
    }
    if(value_mask & XCB_CW_BORDER_PIXEL) {
        /* xcb_screensaver_set_attributes_value_list_t.border_pixel */
        xcb_parts[xcb_parts_idx].iov_base = (char *) &_aux->border_pixel;
        xcb_block_len += sizeof(uint32_t);
        xcb_parts[xcb_parts_idx].iov_len = sizeof(uint32_t);
        xcb_parts_idx++;
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_BIT_GRAVITY) {
        /* xcb_screensaver_set_attributes_value_list_t.bit_gravity */
        xcb_parts[xcb_parts_idx].iov_base = (char *) &_aux->bit_gravity;
        xcb_block_len += sizeof(uint32_t);
        xcb_parts[xcb_parts_idx].iov_len = sizeof(uint32_t);
        xcb_parts_idx++;
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_WIN_GRAVITY) {
        /* xcb_screensaver_set_attributes_value_list_t.win_gravity */
        xcb_parts[xcb_parts_idx].iov_base = (char *) &_aux->win_gravity;
        xcb_block_len += sizeof(uint32_t);
        xcb_parts[xcb_parts_idx].iov_len = sizeof(uint32_t);
        xcb_parts_idx++;
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_BACKING_STORE) {
        /* xcb_screensaver_set_attributes_value_list_t.backing_store */
        xcb_parts[xcb_parts_idx].iov_base = (char *) &_aux->backing_store;
        xcb_block_len += sizeof(uint32_t);
        xcb_parts[xcb_parts_idx].iov_len = sizeof(uint32_t);
        xcb_parts_idx++;
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_BACKING_PLANES) {
        /* xcb_screensaver_set_attributes_value_list_t.backing_planes */
        xcb_parts[xcb_parts_idx].iov_base = (char *) &_aux->backing_planes;
        xcb_block_len += sizeof(uint32_t);
        xcb_parts[xcb_parts_idx].iov_len = sizeof(uint32_t);
        xcb_parts_idx++;
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_BACKING_PIXEL) {
        /* xcb_screensaver_set_attributes_value_list_t.backing_pixel */
        xcb_parts[xcb_parts_idx].iov_base = (char *) &_aux->backing_pixel;
        xcb_block_len += sizeof(uint32_t);
        xcb_parts[xcb_parts_idx].iov_len = sizeof(uint32_t);
        xcb_parts_idx++;
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_OVERRIDE_REDIRECT) {
        /* xcb_screensaver_set_attributes_value_list_t.override_redirect */
        xcb_parts[xcb_parts_idx].iov_base = (char *) &_aux->override_redirect;
        xcb_block_len += sizeof(xcb_bool32_t);
        xcb_parts[xcb_parts_idx].iov_len = sizeof(xcb_bool32_t);
        xcb_parts_idx++;
        xcb_align_to = ALIGNOF(xcb_bool32_t);
    }
    if(value_mask & XCB_CW_SAVE_UNDER) {
        /* xcb_screensaver_set_attributes_value_list_t.save_under */
        xcb_parts[xcb_parts_idx].iov_base = (char *) &_aux->save_under;
        xcb_block_len += sizeof(xcb_bool32_t);
        xcb_parts[xcb_parts_idx].iov_len = sizeof(xcb_bool32_t);
        xcb_parts_idx++;
        xcb_align_to = ALIGNOF(xcb_bool32_t);
    }
    if(value_mask & XCB_CW_EVENT_MASK) {
        /* xcb_screensaver_set_attributes_value_list_t.event_mask */
        xcb_parts[xcb_parts_idx].iov_base = (char *) &_aux->event_mask;
        xcb_block_len += sizeof(uint32_t);
        xcb_parts[xcb_parts_idx].iov_len = sizeof(uint32_t);
        xcb_parts_idx++;
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_DONT_PROPAGATE) {
        /* xcb_screensaver_set_attributes_value_list_t.do_not_propogate_mask */
        xcb_parts[xcb_parts_idx].iov_base = (char *) &_aux->do_not_propogate_mask;
        xcb_block_len += sizeof(uint32_t);
        xcb_parts[xcb_parts_idx].iov_len = sizeof(uint32_t);
        xcb_parts_idx++;
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_COLORMAP) {
        /* xcb_screensaver_set_attributes_value_list_t.colormap */
        xcb_parts[xcb_parts_idx].iov_base = (char *) &_aux->colormap;
        xcb_block_len += sizeof(xcb_colormap_t);
        xcb_parts[xcb_parts_idx].iov_len = sizeof(xcb_colormap_t);
        xcb_parts_idx++;
        xcb_align_to = ALIGNOF(xcb_colormap_t);
    }
    if(value_mask & XCB_CW_CURSOR) {
        /* xcb_screensaver_set_attributes_value_list_t.cursor */
        xcb_parts[xcb_parts_idx].iov_base = (char *) &_aux->cursor;
        xcb_block_len += sizeof(xcb_cursor_t);
        xcb_parts[xcb_parts_idx].iov_len = sizeof(xcb_cursor_t);
        xcb_parts_idx++;
        xcb_align_to = ALIGNOF(xcb_cursor_t);
    }
    /* insert padding */
    xcb_pad = -(xcb_block_len + xcb_padding_offset) & (xcb_align_to - 1);
    xcb_buffer_len += xcb_block_len + xcb_pad;
    if (0 != xcb_pad) {
        xcb_parts[xcb_parts_idx].iov_base = xcb_pad0;
        xcb_parts[xcb_parts_idx].iov_len = xcb_pad;
        xcb_parts_idx++;
        xcb_pad = 0;
    }
    xcb_block_len = 0;
    xcb_padding_offset = 0;

    if (NULL == xcb_out) {
        /* allocate memory */
        xcb_out = malloc(xcb_buffer_len);
        *_buffer = xcb_out;
    }

    xcb_tmp = xcb_out;
    for(i=0; i<xcb_parts_idx; i++) {
        if (0 != xcb_parts[i].iov_base && 0 != xcb_parts[i].iov_len)
            memcpy(xcb_tmp, xcb_parts[i].iov_base, xcb_parts[i].iov_len);
        if (0 != xcb_parts[i].iov_len)
            xcb_tmp += xcb_parts[i].iov_len;
    }

    return xcb_buffer_len;
}

int
xcb_screensaver_set_attributes_value_list_unpack (const void                                   *_buffer,
                                                  uint32_t                                      value_mask,
                                                  xcb_screensaver_set_attributes_value_list_t  *_aux)
{
    char *xcb_tmp = (char *)_buffer;
    unsigned int xcb_buffer_len = 0;
    unsigned int xcb_block_len = 0;
    unsigned int xcb_pad = 0;
    unsigned int xcb_align_to = 0;
    unsigned int xcb_padding_offset = 0;


    if(value_mask & XCB_CW_BACK_PIXMAP) {
        /* xcb_screensaver_set_attributes_value_list_t.background_pixmap */
        _aux->background_pixmap = *(xcb_pixmap_t *)xcb_tmp;
        xcb_block_len += sizeof(xcb_pixmap_t);
        xcb_tmp += sizeof(xcb_pixmap_t);
        xcb_align_to = ALIGNOF(xcb_pixmap_t);
    }
    if(value_mask & XCB_CW_BACK_PIXEL) {
        /* xcb_screensaver_set_attributes_value_list_t.background_pixel */
        _aux->background_pixel = *(uint32_t *)xcb_tmp;
        xcb_block_len += sizeof(uint32_t);
        xcb_tmp += sizeof(uint32_t);
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_BORDER_PIXMAP) {
        /* xcb_screensaver_set_attributes_value_list_t.border_pixmap */
        _aux->border_pixmap = *(xcb_pixmap_t *)xcb_tmp;
        xcb_block_len += sizeof(xcb_pixmap_t);
        xcb_tmp += sizeof(xcb_pixmap_t);
        xcb_align_to = ALIGNOF(xcb_pixmap_t);
    }
    if(value_mask & XCB_CW_BORDER_PIXEL) {
        /* xcb_screensaver_set_attributes_value_list_t.border_pixel */
        _aux->border_pixel = *(uint32_t *)xcb_tmp;
        xcb_block_len += sizeof(uint32_t);
        xcb_tmp += sizeof(uint32_t);
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_BIT_GRAVITY) {
        /* xcb_screensaver_set_attributes_value_list_t.bit_gravity */
        _aux->bit_gravity = *(uint32_t *)xcb_tmp;
        xcb_block_len += sizeof(uint32_t);
        xcb_tmp += sizeof(uint32_t);
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_WIN_GRAVITY) {
        /* xcb_screensaver_set_attributes_value_list_t.win_gravity */
        _aux->win_gravity = *(uint32_t *)xcb_tmp;
        xcb_block_len += sizeof(uint32_t);
        xcb_tmp += sizeof(uint32_t);
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_BACKING_STORE) {
        /* xcb_screensaver_set_attributes_value_list_t.backing_store */
        _aux->backing_store = *(uint32_t *)xcb_tmp;
        xcb_block_len += sizeof(uint32_t);
        xcb_tmp += sizeof(uint32_t);
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_BACKING_PLANES) {
        /* xcb_screensaver_set_attributes_value_list_t.backing_planes */
        _aux->backing_planes = *(uint32_t *)xcb_tmp;
        xcb_block_len += sizeof(uint32_t);
        xcb_tmp += sizeof(uint32_t);
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_BACKING_PIXEL) {
        /* xcb_screensaver_set_attributes_value_list_t.backing_pixel */
        _aux->backing_pixel = *(uint32_t *)xcb_tmp;
        xcb_block_len += sizeof(uint32_t);
        xcb_tmp += sizeof(uint32_t);
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_OVERRIDE_REDIRECT) {
        /* xcb_screensaver_set_attributes_value_list_t.override_redirect */
        _aux->override_redirect = *(xcb_bool32_t *)xcb_tmp;
        xcb_block_len += sizeof(xcb_bool32_t);
        xcb_tmp += sizeof(xcb_bool32_t);
        xcb_align_to = ALIGNOF(xcb_bool32_t);
    }
    if(value_mask & XCB_CW_SAVE_UNDER) {
        /* xcb_screensaver_set_attributes_value_list_t.save_under */
        _aux->save_under = *(xcb_bool32_t *)xcb_tmp;
        xcb_block_len += sizeof(xcb_bool32_t);
        xcb_tmp += sizeof(xcb_bool32_t);
        xcb_align_to = ALIGNOF(xcb_bool32_t);
    }
    if(value_mask & XCB_CW_EVENT_MASK) {
        /* xcb_screensaver_set_attributes_value_list_t.event_mask */
        _aux->event_mask = *(uint32_t *)xcb_tmp;
        xcb_block_len += sizeof(uint32_t);
        xcb_tmp += sizeof(uint32_t);
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_DONT_PROPAGATE) {
        /* xcb_screensaver_set_attributes_value_list_t.do_not_propogate_mask */
        _aux->do_not_propogate_mask = *(uint32_t *)xcb_tmp;
        xcb_block_len += sizeof(uint32_t);
        xcb_tmp += sizeof(uint32_t);
        xcb_align_to = ALIGNOF(uint32_t);
    }
    if(value_mask & XCB_CW_COLORMAP) {
        /* xcb_screensaver_set_attributes_value_list_t.colormap */
        _aux->colormap = *(xcb_colormap_t *)xcb_tmp;
        xcb_block_len += sizeof(xcb_colormap_t);
        xcb_tmp += sizeof(xcb_colormap_t);
        xcb_align_to = ALIGNOF(xcb_colormap_t);
    }
    if(value_mask & XCB_CW_CURSOR) {
        /* xcb_screensaver_set_attributes_value_list_t.cursor */
        _aux->cursor = *(xcb_cursor_t *)xcb_tmp;
        xcb_block_len += sizeof(xcb_cursor_t);
        xcb_tmp += sizeof(xcb_cursor_t);
        xcb_align_to = ALIGNOF(xcb_cursor_t);
    }
    /* insert padding */
    xcb_pad = -(xcb_block_len + xcb_padding_offset) & (xcb_align_to - 1);
    xcb_buffer_len += xcb_block_len + xcb_pad;
    if (0 != xcb_pad) {
        xcb_tmp += xcb_pad;
        xcb_pad = 0;
    }
    xcb_block_len = 0;
    xcb_padding_offset = 0;

    return xcb_buffer_len;
}

int
xcb_screensaver_set_attributes_value_list_sizeof (const void  *_buffer,
                                                  uint32_t     value_mask)
{
    xcb_screensaver_set_attributes_value_list_t _aux;
    return xcb_screensaver_set_attributes_value_list_unpack(_buffer, value_mask, &_aux);
}

int
xcb_screensaver_set_attributes_sizeof (const void  *_buffer)
{
    char *xcb_tmp = (char *)_buffer;
    const xcb_screensaver_set_attributes_request_t *_aux = (xcb_screensaver_set_attributes_request_t *)_buffer;
    unsigned int xcb_buffer_len = 0;
    unsigned int xcb_block_len = 0;
    unsigned int xcb_pad = 0;
    unsigned int xcb_align_to = 0;


    xcb_block_len += sizeof(xcb_screensaver_set_attributes_request_t);
    xcb_tmp += xcb_block_len;
    xcb_buffer_len += xcb_block_len;
    xcb_block_len = 0;
    /* value_list */
    xcb_block_len += xcb_screensaver_set_attributes_value_list_sizeof(xcb_tmp, _aux->value_mask);
    xcb_tmp += xcb_block_len;
    xcb_align_to = ALIGNOF(char);
    /* insert padding */
    xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    xcb_buffer_len += xcb_block_len + xcb_pad;
    if (0 != xcb_pad) {
        xcb_tmp += xcb_pad;
        xcb_pad = 0;
    }
    xcb_block_len = 0;

    return xcb_buffer_len;
}

xcb_void_cookie_t
xcb_screensaver_set_attributes_checked (xcb_connection_t *c,
                                        xcb_drawable_t    drawable,
                                        int16_t           x,
                                        int16_t           y,
                                        uint16_t          width,
                                        uint16_t          height,
                                        uint16_t          border_width,
                                        uint8_t           _class,
                                        uint8_t           depth,
                                        xcb_visualid_t    visual,
                                        uint32_t          value_mask,
                                        const void       *value_list)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 3,
        .ext = &xcb_screensaver_id,
        .opcode = XCB_SCREENSAVER_SET_ATTRIBUTES,
        .isvoid = 1
    };

    struct iovec xcb_parts[5];
    xcb_void_cookie_t xcb_ret;
    xcb_screensaver_set_attributes_request_t xcb_out;

    xcb_out.drawable = drawable;
    xcb_out.x = x;
    xcb_out.y = y;
    xcb_out.width = width;
    xcb_out.height = height;
    xcb_out.border_width = border_width;
    xcb_out._class = _class;
    xcb_out.depth = depth;
    xcb_out.visual = visual;
    xcb_out.value_mask = value_mask;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    /* xcb_screensaver_set_attributes_value_list_t value_list */
    xcb_parts[4].iov_base = (char *) value_list;
    xcb_parts[4].iov_len =
      xcb_screensaver_set_attributes_value_list_sizeof (value_list, value_mask);

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_screensaver_set_attributes (xcb_connection_t *c,
                                xcb_drawable_t    drawable,
                                int16_t           x,
                                int16_t           y,
                                uint16_t          width,
                                uint16_t          height,
                                uint16_t          border_width,
                                uint8_t           _class,
                                uint8_t           depth,
                                xcb_visualid_t    visual,
                                uint32_t          value_mask,
                                const void       *value_list)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 3,
        .ext = &xcb_screensaver_id,
        .opcode = XCB_SCREENSAVER_SET_ATTRIBUTES,
        .isvoid = 1
    };

    struct iovec xcb_parts[5];
    xcb_void_cookie_t xcb_ret;
    xcb_screensaver_set_attributes_request_t xcb_out;

    xcb_out.drawable = drawable;
    xcb_out.x = x;
    xcb_out.y = y;
    xcb_out.width = width;
    xcb_out.height = height;
    xcb_out.border_width = border_width;
    xcb_out._class = _class;
    xcb_out.depth = depth;
    xcb_out.visual = visual;
    xcb_out.value_mask = value_mask;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    /* xcb_screensaver_set_attributes_value_list_t value_list */
    xcb_parts[4].iov_base = (char *) value_list;
    xcb_parts[4].iov_len =
      xcb_screensaver_set_attributes_value_list_sizeof (value_list, value_mask);

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_screensaver_set_attributes_aux_checked (xcb_connection_t                                  *c,
                                            xcb_drawable_t                                     drawable,
                                            int16_t                                            x,
                                            int16_t                                            y,
                                            uint16_t                                           width,
                                            uint16_t                                           height,
                                            uint16_t                                           border_width,
                                            uint8_t                                            _class,
                                            uint8_t                                            depth,
                                            xcb_visualid_t                                     visual,
                                            uint32_t                                           value_mask,
                                            const xcb_screensaver_set_attributes_value_list_t *value_list)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 3,
        .ext = &xcb_screensaver_id,
        .opcode = XCB_SCREENSAVER_SET_ATTRIBUTES,
        .isvoid = 1
    };

    struct iovec xcb_parts[5];
    xcb_void_cookie_t xcb_ret;
    xcb_screensaver_set_attributes_request_t xcb_out;
    void *xcb_aux0 = 0;

    xcb_out.drawable = drawable;
    xcb_out.x = x;
    xcb_out.y = y;
    xcb_out.width = width;
    xcb_out.height = height;
    xcb_out.border_width = border_width;
    xcb_out._class = _class;
    xcb_out.depth = depth;
    xcb_out.visual = visual;
    xcb_out.value_mask = value_mask;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    /* xcb_screensaver_set_attributes_value_list_t value_list */
    xcb_parts[4].iov_len =
      xcb_screensaver_set_attributes_value_list_serialize (&xcb_aux0, value_mask, value_list);
    xcb_parts[4].iov_base = xcb_aux0;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    free(xcb_aux0);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_screensaver_set_attributes_aux (xcb_connection_t                                  *c,
                                    xcb_drawable_t                                     drawable,
                                    int16_t                                            x,
                                    int16_t                                            y,
                                    uint16_t                                           width,
                                    uint16_t                                           height,
                                    uint16_t                                           border_width,
                                    uint8_t                                            _class,
                                    uint8_t                                            depth,
                                    xcb_visualid_t                                     visual,
                                    uint32_t                                           value_mask,
                                    const xcb_screensaver_set_attributes_value_list_t *value_list)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 3,
        .ext = &xcb_screensaver_id,
        .opcode = XCB_SCREENSAVER_SET_ATTRIBUTES,
        .isvoid = 1
    };

    struct iovec xcb_parts[5];
    xcb_void_cookie_t xcb_ret;
    xcb_screensaver_set_attributes_request_t xcb_out;
    void *xcb_aux0 = 0;

    xcb_out.drawable = drawable;
    xcb_out.x = x;
    xcb_out.y = y;
    xcb_out.width = width;
    xcb_out.height = height;
    xcb_out.border_width = border_width;
    xcb_out._class = _class;
    xcb_out.depth = depth;
    xcb_out.visual = visual;
    xcb_out.value_mask = value_mask;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    /* xcb_screensaver_set_attributes_value_list_t value_list */
    xcb_parts[4].iov_len =
      xcb_screensaver_set_attributes_value_list_serialize (&xcb_aux0, value_mask, value_list);
    xcb_parts[4].iov_base = xcb_aux0;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    free(xcb_aux0);
    return xcb_ret;
}

void *
xcb_screensaver_set_attributes_value_list (const xcb_screensaver_set_attributes_request_t *R)
{
    return (void *) (R + 1);
}

xcb_void_cookie_t
xcb_screensaver_unset_attributes_checked (xcb_connection_t *c,
                                          xcb_drawable_t    drawable)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_screensaver_id,
        .opcode = XCB_SCREENSAVER_UNSET_ATTRIBUTES,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_screensaver_unset_attributes_request_t xcb_out;

    xcb_out.drawable = drawable;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_screensaver_unset_attributes (xcb_connection_t *c,
                                  xcb_drawable_t    drawable)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_screensaver_id,
        .opcode = XCB_SCREENSAVER_UNSET_ATTRIBUTES,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_screensaver_unset_attributes_request_t xcb_out;

    xcb_out.drawable = drawable;

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_screensaver_suspend_checked (xcb_connection_t *c,
                                 uint8_t           suspend)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_screensaver_id,
        .opcode = XCB_SCREENSAVER_SUSPEND,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_screensaver_suspend_request_t xcb_out;

    xcb_out.suspend = suspend;
    memset(xcb_out.pad0, 0, 3);

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}

xcb_void_cookie_t
xcb_screensaver_suspend (xcb_connection_t *c,
                         uint8_t           suspend)
{
    static const xcb_protocol_request_t xcb_req = {
        .count = 2,
        .ext = &xcb_screensaver_id,
        .opcode = XCB_SCREENSAVER_SUSPEND,
        .isvoid = 1
    };

    struct iovec xcb_parts[4];
    xcb_void_cookie_t xcb_ret;
    xcb_screensaver_suspend_request_t xcb_out;

    xcb_out.suspend = suspend;
    memset(xcb_out.pad0, 0, 3);

    xcb_parts[2].iov_base = (char *) &xcb_out;
    xcb_parts[2].iov_len = sizeof(xcb_out);
    xcb_parts[3].iov_base = 0;
    xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;

    xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    return xcb_ret;
}
예제 #23
0
 * 
 * This library provides a cross-platform foundation library in C11 providing basic support data types and
 * functions to write applications and games in a platform-independent fashion. The latest source code is
 * always available at
 * 
 * https://github.com/rampantpixels/foundation_lib
 * 
 * This library is put in the public domain; you can redistribute it and/or modify it without any restrictions.
 *
 */

#include <foundation/foundation.h>
#include <foundation/internal.h>


FOUNDATION_STATIC_ASSERT( ALIGNOF(object_base_t) >= 8, "object_base_t alignment" );
FOUNDATION_STATIC_ASSERT( ALIGNOF(objectmap_t) >= 8, "objectmap_t alignment" );


void _object_initialize( object_base_t* obj, object_t id )
{
	obj->id = id;
	atomic_store32( &obj->ref, 1 );
}


object_t _object_ref( object_base_t* obj )
{
	int32_t ref;
	if( obj ) do
	{