os: use posix_fallocate in creating sharable buffers

If posix_fallocate is available, use it instead of ftruncate. Unlike
ftruncate, when posix_fallocate succeeds, it guarantees that you cannot
run out of disk space, when later writing to the mmap()'ed file.

With posix_fallocate, if os_create_anonymous_file() succeeds, the
program cannot get a SIGBUS later from accessing this file via mmap. If
there is insufficient disk space, the function fails and errno is set to
ENOSPC.

This is useful on systems, that limit the available buffer space by
having XDG_RUNTIME_DIR on a small tmpfs.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
cursor: handle running out of buffer space

If posix_fallocate is available, use it to detect when we are running
out of buffer space.

Propagate the failure properly through the various functions, stopping
loading cursors but keeping the cursors that were already successfully
loaded.

This may result in an animated cursor not having all of its images, or a
cursor theme not having all of its cursors. When that happens, the
failure is NOT communicated to the application. Instead, the application
will get NULL from wl_cursor_theme_get_cursor() for a cursor that was
not loaded successfully. If an animated cursor is missing only some
images, the animation is truncated but the cursor is still available.

This patch relies on the commit "os: use posix_fallocate in creating
sharable buffers" for defining HAVE_POSIX_FALLOCATE.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
client: Make wl_proxy_set_queue() with NULL revert to default queue

This will be useful in order to implement the
EGL_WL_create_wayland_buffer_from_image extension. The buffers created
within Mesa's Wayland platform are created using the the wl_drm object
as a proxy factory which means they will be set to use Mesa's internal
event queue. However, these buffers will be owned by the client
application so they ideally need to use the default event loop. This
function provides a way to set the proxy's event queue back to the
default.

krh: Edited from Neils original patch to just use wl_proxy_set_queue() with
a NULL argument instead of introducing a new function.
asserts: add assertf and dbg macros

assertf - formated output
dbg - debug message
also allows use normal assert
asserts: add ifdbg macro, change dbg macro format

New macro ifdbg prints message when condition is true
asserts: put few asserts into connection.c

Mostly checking functions' arguments
asserts: put some asserts into event-loop.c

mostly 'sanity' asserts (check functions arguments etc.)
assert: put some asserts into wayland-client.c
asserts: include stdio in wayland-assert.h

to have all-inclusive ;)
asserts: some asserts in wayland-util.c
asserts: check if epoll_ctl succeded
asserts: check epoll_ctl's return value
asserts: added asserts

usually just "sanity" asserts (checking function arguments etc.)
asserts: debug messages in wl_buffer_put

Move original ifdbg() before memcpy() so that it will be printed before
possible crash.
Add new ifdbg() that is printed upon count > 2 * sizeof data (that means
when it's possible to overflow)
asserts: add new asserts and dbg messages into event-loop.c
asserts: add new asserts and debug messages into wayland-server.c
dbg: comment out debug information

these situation seem to happen regulary, so don't let terminal be
flooded by them
asserts: print whether we got error or hangup
asserts: new asserts in wl_array

wl_array_{add, copy}
new asserts and dbg