Guard against too fast deletion of wl_buffers

When creating a wl_buffer using the android_wlegl protocol the server
registers with the native handle only when it processes the request later.
If the client destroys the wl_buffer and the native handle before the server
registers with it, the native handle will be gone and trying to register it
will fail. The server will then send a protocol error because it cannot know
the handle was valid when the client issued the request.
To solve it, register a wl_callback after creating the wl_buffer, which
will be used to block before destroying a buffer if the done event was not
fired yet.

Done-with: Jonas Ådahl <jadahl@gmail.com>
Merge pull request #230 from giucam/buffer_race

Guard against too fast deletion of wl_buffers
fix finishswap stuck forever in sync fence

Turns out on nexus5, not setting the flush flag makes client wait
forever in the finishswap fence.
increase runtime of test_glesv2

It was discovered that a file descriptor leak on fbdev mode would
manifest in a frozen client after around 15s. Therefore increase runtime
of the test and make runtime configurable.
Merge pull request #232 from heeen/master

Two changes for EGL and gles
Make binding helper macros available to out of tree components

Signed-off-by: Simon Busch <morphis@gravedo.de>
Switch to CLOCK_MONOTONIC_RAW instead of CLOCK_REALTIME

Using CLOCK_REALTIME can cause problems as it's time value is influenced by different
sources where CLOCK_MONOTONIC_RAW is not. CLOCK_MONOTONIC isn't safe to use as on
linux systems it can be influenced by NTP as well.

Signed-off-by: Simon Busch <morphis@gravedo.de>
properties: when property service is not available list properties from cache

Signed-off-by: Simon Busch <morphis@gravedo.de>
Redirect access to /dev/log/* to /dev/log_*

Android has a different log management approach and defines different log buffers (system,
main, events, radio) which are normally in Android available at /dev/log/{system,main,events,
radio}. In libhybris environments /dev/log is already occupied by the system logging
daemon (syslogd, journald, ...) so mapping isn't possible. To avoid patching the android
parts to use /dev/log_* directly instead of /dev/log/* we're installing a hook for the
open system call which checks for possible redirects. The implementend mechanism is
extensible so other redirects can be added easily.

Signed-off-by: Simon Busch <morphis@gravedo.de>
Merge pull request #231 from webOS-ports/for-upstream

For upstream
Add wayland-server support to nullws

Adds support for running a wayland compositor off of nullws.
This allows for platforms that have trouble bringing up fbdev and
hwcomposer to run a wayland compositor using null EGL platform for the
compositor.

tested using nexus5, qml-compositor and hellogl_es2 client.
Merge pull request #233 from heeen/null-compositor

Add wayland-server support to nullws
Add additional android specific kernel headers

Binder and Android alarm interfaces are needed from userspace at compile time and we
should ship the same as Android does with it's kernel header package.

Signed-off-by: Simon Busch <morphis@gravedo.de>
Generate pkg-config configuration file for our header package

Signed-off-by: Simon Busch <morphis@gravedo.de>
Cleanup the buffers from the list once destroyed

Since we dispatch the wayland queue in destroyBuffer() a wl_buffer.release
event may come while we're still mid-through deleting all the buffers.
When getting a release event we go through the list of the buffers, and so
we risk of accessing a deleted buffer object. To fix this remove the deleted
buffers from the list as soon as possible.
Merge pull request #234 from webOS-ports/kernel-headers

Kernel headers
Merge pull request #235 from giucam/master

Cleanup the buffers from the list once destroyed
egl:fbdev: lazily allocate buffers.

No point in reallocating the buffers 3-4 times before we start drawing.
Instead, delay creating them until the first dequeu.

This incidientally fixes an issue where we fail to allocate a third
buffer beceause setBufferCount gets called after queueBuffer().
Because one buffer is locked by the fb device (due to the post())
we end up with only being able to reallocate 2 buffers this time
and the application continues with 2 buffers rather than 3.
Hook __system_property_get

Normally we don't have to wrap __system_property_get (libc.so) as it is only used
through the property_get (libcutils.so) function. However when property_get is used
internally in libcutils.so we don't have any chance to hook our replacement in.
Therefore we have to hook __system_property_get too and just replace it with the
implementation of our internal property handling

This was discovered when debugfs was mounted to /sys/kernel/debug. Once this is done the
internal atrace functionality of Android is activated which sits also in libcutils. It
needs additionally to the mounted debugfs a property set to enable the trace
functionality. As soon as this property was tried to read through bionic the whole
process crashed. With hooking __system_property_get everything works again.

Signed-off-by: Simon Busch <morphis@gravedo.de>
propcache: Remove one unnecessary strdup().

By simply returning the already allocated value, we avoid an unnecessary
allocation, as the caller already copies the value anyway.