#define _GNU_SOURCE
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <sys/uio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <time.h>
#include <ffi.h>
#include "wayland-util.h"
#include "wayland-private.h"
#include "wayland-os.h"
static inline uint32_t
div_roundup(uint32_t n, size_t a)
{ … }
struct wl_ring_buffer { … };
#define MAX_FDS_OUT …
#define CLEN …
struct wl_connection { … };
static inline size_t
size_pot(uint32_t size_bits)
{ … }
static size_t
ring_buffer_capacity(const struct wl_ring_buffer *b) { … }
static size_t
ring_buffer_mask(const struct wl_ring_buffer *b, size_t i) { … }
static int
ring_buffer_put(struct wl_ring_buffer *b, const void *data, size_t count)
{ … }
static void
ring_buffer_put_iov(struct wl_ring_buffer *b, struct iovec *iov, int *count)
{ … }
static void
ring_buffer_get_iov(struct wl_ring_buffer *b, struct iovec *iov, int *count)
{ … }
static void
ring_buffer_copy(struct wl_ring_buffer *b, void *data, size_t count)
{ … }
static size_t
ring_buffer_size(struct wl_ring_buffer *b)
{ … }
static char *
ring_buffer_tail(const struct wl_ring_buffer *b)
{ … }
static uint32_t
get_max_size_bits_for_size(size_t buffer_size)
{ … }
static int
ring_buffer_allocate(struct wl_ring_buffer *b, size_t size_bits)
{ … }
static size_t
ring_buffer_get_bits_for_size(struct wl_ring_buffer *b, size_t net_size)
{ … }
static bool
ring_buffer_is_max_size_reached(struct wl_ring_buffer *b)
{ … }
static int
ring_buffer_ensure_space(struct wl_ring_buffer *b, size_t count)
{ … }
static void
ring_buffer_close_fds(struct wl_ring_buffer *buffer, int32_t count)
{ … }
void
wl_connection_set_max_buffer_size(struct wl_connection *connection,
size_t max_buffer_size)
{ … }
struct wl_connection *
wl_connection_create(int fd, size_t max_buffer_size)
{ … }
static void
close_fds(struct wl_ring_buffer *buffer, int max)
{ … }
void
wl_connection_close_fds_in(struct wl_connection *connection, int max)
{ … }
int
wl_connection_destroy(struct wl_connection *connection)
{ … }
void
wl_connection_copy(struct wl_connection *connection, void *data, size_t size)
{ … }
void
wl_connection_consume(struct wl_connection *connection, size_t size)
{ … }
static void
build_cmsg(struct wl_ring_buffer *buffer, char *data, size_t *clen)
{ … }
static int
decode_cmsg(struct wl_ring_buffer *buffer, struct msghdr *msg)
{ … }
int
wl_connection_flush(struct wl_connection *connection)
{ … }
uint32_t
wl_connection_pending_input(struct wl_connection *connection)
{ … }
int
wl_connection_read(struct wl_connection *connection)
{ … }
int
wl_connection_write(struct wl_connection *connection,
const void *data, size_t count)
{ … }
int
wl_connection_queue(struct wl_connection *connection,
const void *data, size_t count)
{ … }
int
wl_message_count_arrays(const struct wl_message *message)
{ … }
int
wl_connection_get_fd(struct wl_connection *connection)
{ … }
static int
wl_connection_put_fd(struct wl_connection *connection, int32_t fd)
{ … }
const char *
get_next_argument(const char *signature, struct argument_details *details)
{ … }
int
arg_count_for_signature(const char *signature)
{ … }
int
wl_message_get_since(const struct wl_message *message)
{ … }
void
wl_argument_from_va_list(const char *signature, union wl_argument *args,
int count, va_list ap)
{ … }
static void
wl_closure_clear_fds(struct wl_closure *closure)
{ … }
static struct wl_closure *
wl_closure_init(const struct wl_message *message, uint32_t size,
int *num_arrays, union wl_argument *args)
{ … }
struct wl_closure *
wl_closure_marshal(struct wl_object *sender, uint32_t opcode,
union wl_argument *args,
const struct wl_message *message)
{ … }
struct wl_closure *
wl_closure_vmarshal(struct wl_object *sender, uint32_t opcode, va_list ap,
const struct wl_message *message)
{ … }
struct wl_closure *
wl_connection_demarshal(struct wl_connection *connection,
uint32_t size,
struct wl_map *objects,
const struct wl_message *message)
{ … }
bool
wl_object_is_zombie(struct wl_map *map, uint32_t id)
{ … }
int
wl_closure_lookup_objects(struct wl_closure *closure, struct wl_map *objects)
{ … }
static void
convert_arguments_to_ffi(const char *signature, uint32_t flags,
union wl_argument *args,
int count, ffi_type **ffi_types, void** ffi_args)
{ … }
void
wl_closure_invoke(struct wl_closure *closure, uint32_t flags,
struct wl_object *target, uint32_t opcode, void *data)
{ … }
void
wl_closure_dispatch(struct wl_closure *closure, wl_dispatcher_func_t dispatcher,
struct wl_object *target, uint32_t opcode)
{ … }
static int
copy_fds_to_connection(struct wl_closure *closure,
struct wl_connection *connection)
{ … }
static uint32_t
buffer_size_for_closure(struct wl_closure *closure)
{ … }
static int
serialize_closure(struct wl_closure *closure, uint32_t *buffer,
size_t buffer_count)
{ … }
int
wl_closure_send(struct wl_closure *closure, struct wl_connection *connection)
{ … }
int
wl_closure_queue(struct wl_closure *closure, struct wl_connection *connection)
{ … }
void
wl_closure_print(struct wl_closure *closure, struct wl_object *target,
int send, int discarded, uint32_t (*n_parse)(union wl_argument *arg),
const char *queue_name)
{ … }
static int
wl_closure_close_fds(struct wl_closure *closure)
{ … }
void
wl_closure_destroy(struct wl_closure *closure)
{ … }