After seeing 'n' responses, wakeup up to 'n' waiting threads

Previously we only woke 1 thread from the sequence even after
seeing several slots become free.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Resynchronise memory barriers with mirage-platform

We name our functions directly after the C macros to make code
inspection and comparison easier.

Since a mirage kernel uses OCaml from this component and C stubs
from mirage-platform, this commit must be pulled in sync with
the mirage-platform change.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Add a missing 'to_string' function.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Fix handling of event counters

The 'ack_requests' function is badly named because it has
no side-effect on the ring: it simply advances the host's private
'consumer' pointer and upcalls to the application.

The C macros have a 'final check for requests' concept where
the backend, which is about to block, writes the event pointer
to point to the next index it would like to read from. If a
frontend sees the event pointer with a low number, it means that
the backend is still working and will eventually see the new
data. If the frontend sees the event pointer appear in the middle
of the slots it has just written, it must signal the backend to
wake up.

Note this means that the backend should be written in a synchronous
style, with one single thread owning the ring, managing the pointers
and blocking. It is unsafe to let parallel threads access the ring.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>