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:
		
							parent
							
								
									f01b1b40ac
								
							
						
					
					
						commit
						22207ddf75
					
				
							
								
								
									
										12
									
								
								vchan/init.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								vchan/init.c
									
									
									
									
									
								
							| @ -62,7 +62,7 @@ static int fill_ctrl(struct libvchan *ctrl, struct vchan_interface *ring, int ri | |||||||
| 	return 0;	 | 	return 0;	 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #ifdef WINNT | #ifdef QREXEC_RING_V2 | ||||||
| static int ring_init(struct libvchan *ctrl) | static int ring_init(struct libvchan *ctrl) | ||||||
| { | { | ||||||
| 	struct gntmem_handle*	h; | 	struct gntmem_handle*	h; | ||||||
| @ -158,9 +158,11 @@ static int server_interface_init(struct libvchan *ctrl, int devno) | |||||||
| 	ctrl->evport = port; | 	ctrl->evport = port; | ||||||
| 	ctrl->devno = devno; | 	ctrl->devno = devno; | ||||||
| 
 | 
 | ||||||
|  | #ifdef QREXEC_RING_V2 | ||||||
| 	snprintf(buf, sizeof buf, "device/vchan/%d/version", devno); | 	snprintf(buf, sizeof buf, "device/vchan/%d/version", devno); | ||||||
| 	if (!xs_write(xs, 0, buf, "2", strlen("2"))) | 	if (!xs_write(xs, 0, buf, "2", strlen("2"))) | ||||||
| 		goto fail2; | 		goto fail2; | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| 	snprintf(ref, sizeof ref, "%d", ctrl->ring_ref); | 	snprintf(ref, sizeof ref, "%d", ctrl->ring_ref); | ||||||
| 	snprintf(buf, sizeof buf, "device/vchan/%d/ring-ref", devno); | 	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); | 	snprintf(buf, sizeof buf, "device/vchan/%d/event-channel", devno); | ||||||
| 	if (!xs_write(xs, 0, buf, ref, strlen(ref))) | 	if (!xs_write(xs, 0, buf, ref, strlen(ref))) | ||||||
| 		goto fail2; | 		goto fail2; | ||||||
| 		// do not block in stubdom - libvchan_server_handle_connected will be
 | 	// do not block in stubdom and windows - libvchan_server_handle_connected will be
 | ||||||
| 		// called on first input
 | 	// called on first input
 | ||||||
| #ifndef CONFIG_STUBDOM | #ifdef ASYNC_INIT | ||||||
|         // wait for the peer to arrive
 | 	// wait for the peer to arrive
 | ||||||
| 	if (xc_evtchn_pending(evfd) == -1) | 	if (xc_evtchn_pending(evfd) == -1) | ||||||
| 		goto fail2; | 		goto fail2; | ||||||
|         xc_evtchn_unmask(ctrl->evfd, ctrl->evport); |         xc_evtchn_unmask(ctrl->evfd, ctrl->evport); | ||||||
|  | |||||||
| @ -28,11 +28,19 @@ | |||||||
| #include <xs.h> | #include <xs.h> | ||||||
| typedef HANDLE EVTCHN; | typedef HANDLE EVTCHN; | ||||||
| #define snprintf _snprintf | #define snprintf _snprintf | ||||||
| #else | #else /* WINNT */ | ||||||
| #include <stdint.h> | #include <stdint.h> | ||||||
| typedef int EVTCHN; | 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> | #include <xenctrl.h> | ||||||
| typedef uint32_t VCHAN_RING_IDX; | typedef uint32_t VCHAN_RING_IDX; | ||||||
|  | |||||||
| @ -9,8 +9,6 @@ USE_MSVCRT=1 | |||||||
| 
 | 
 | ||||||
| DLLDEF=libvchan.def | DLLDEF=libvchan.def | ||||||
| 
 | 
 | ||||||
| C_DEFINES = $(C_DEFINES)  /DCONFIG_STUBDOM |  | ||||||
| 
 |  | ||||||
| INCLUDES=$(INCLUDES); \ | INCLUDES=$(INCLUDES); \ | ||||||
|                     ..\win\include;\ |                     ..\win\include;\ | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Marek Marczykowski
						Marek Marczykowski