server: Use ringbuffer for socket backlog

Currently, the socket handler uses a linear buffer for the backlog data;
this means we need to shift up to 128kB of data after each socket
write().

This change introduces a single-producer-multiple-consumer ringbuffer,
to avoid the need for memmove()ing data around; we can simply update
pointers instead of shifting data.

We add this as a new file (ringbuffer.c), to make it a little more
modular. To mitigate the risk of subtle pointer arithmetic issues, we
add a set of tests too.

Change-Id: Ib7c5151d3cf1f588436f5461000b6fed22d0681c
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
diff --git a/Makefile.am b/Makefile.am
index e07d4ad..96fa9fb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,6 +11,7 @@
 	 console-server.c \
 	 console-server.h \
 	 util.c \
+	 ringbuffer.c \
 	 config.c \
 	 log-handler.c \
 	 socket-handler.c \
@@ -23,4 +24,4 @@
 	 console-socket.c \
 	 util.c
 
-#SUBDIRS = test
+SUBDIRS = test