vchan: introduce features macros

Use features macros (QREXEC_RING_V2 and ASYNC_INIT) instead of directly
depending on building environment. The macros are turned on (when required) in
libvchan.h based on target system.
This commit is contained in:
Marek Marczykowski 2012-06-03 16:38:30 +02:00
parent f01b1b40ac
commit 22207ddf75
3 changed files with 17 additions and 9 deletions

View File

@ -62,7 +62,7 @@ static int fill_ctrl(struct libvchan *ctrl, struct vchan_interface *ring, int ri
return 0;
}
#ifdef WINNT
#ifdef QREXEC_RING_V2
static int ring_init(struct libvchan *ctrl)
{
struct gntmem_handle* h;
@ -158,9 +158,11 @@ static int server_interface_init(struct libvchan *ctrl, int devno)
ctrl->evport = port;
ctrl->devno = devno;
#ifdef QREXEC_RING_V2
snprintf(buf, sizeof buf, "device/vchan/%d/version", devno);
if (!xs_write(xs, 0, buf, "2", strlen("2")))
goto fail2;
#endif
snprintf(ref, sizeof ref, "%d", ctrl->ring_ref);
snprintf(buf, sizeof buf, "device/vchan/%d/ring-ref", devno);
@ -170,10 +172,10 @@ static int server_interface_init(struct libvchan *ctrl, int devno)
snprintf(buf, sizeof buf, "device/vchan/%d/event-channel", devno);
if (!xs_write(xs, 0, buf, ref, strlen(ref)))
goto fail2;
// do not block in stubdom - libvchan_server_handle_connected will be
// called on first input
#ifndef CONFIG_STUBDOM
// wait for the peer to arrive
// do not block in stubdom and windows - libvchan_server_handle_connected will be
// called on first input
#ifdef ASYNC_INIT
// wait for the peer to arrive
if (xc_evtchn_pending(evfd) == -1)
goto fail2;
xc_evtchn_unmask(ctrl->evfd, ctrl->evport);

View File

@ -28,11 +28,19 @@
#include <xs.h>
typedef HANDLE EVTCHN;
#define snprintf _snprintf
#else
#else /* WINNT */
#include <stdint.h>
typedef int EVTCHN;
#endif
#endif /* WINNT */
/* config vchan features */
#ifdef WINNT
#define QREXEC_RING_V2
#define ASYNC_INIT
#endif /* WINNT */
#ifdef CONFIG_STUBDOM
#define ASYNC_INIT
#endif /* CONFIG_STUBDOM */
#include <xenctrl.h>
typedef uint32_t VCHAN_RING_IDX;

View File

@ -9,8 +9,6 @@ USE_MSVCRT=1
DLLDEF=libvchan.def
C_DEFINES = $(C_DEFINES) /DCONFIG_STUBDOM
INCLUDES=$(INCLUDES); \
..\win\include;\