|  |  | @ -8,12 +8,26 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | #define SHM_SIZE SHM_HEADER+SHM_BODY |  |  |  | #define SHM_SIZE SHM_HEADER+SHM_BODY | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | // FIXME: add YIELD for linux, add single-core and multi-core compile targets for optimal speed
 | 
			
		
	
		
		
			
				
					
					|  |  |  | #ifdef LINUX_BUILD |  |  |  | #ifdef LINUX_BUILD | 
			
		
	
		
		
			
				
					
					|  |  |  |     // a full memory barrier! better be safe than sorry.
 |  |  |  |     // a full memory barrier! better be safe than sorry.
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     #define full_barrier asm volatile("" ::: "memory"); __sync_synchronize(); |  |  |  |     #define full_barrier asm volatile("" ::: "memory"); __sync_synchronize(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     #define SCHED_YIELD | 
			
		
	
		
		
			
				
					
					|  |  |  | #else |  |  |  | #else | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     // we need windows.h for Sleep()
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     #define _WIN32_WINNT 0x0501 // needed for INPUT struct
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     #define WINVER 0x0501                   // OpenThread(), PSAPI, Toolhelp32
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     #define WIN32_LEAN_AND_MEAN | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     #include <windows.h> | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     #define SCHED_YIELD Sleep(0); | 
			
		
	
		
		
			
				
					
					|  |  |  |     // FIXME: detect MSVC here and use the right barrier magic
 |  |  |  |     // FIXME: detect MSVC here and use the right barrier magic
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     #define full_barrier |  |  |  | 	#ifdef __MINGW32__ | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		#define full_barrier asm volatile("" ::: "memory"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	#else | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		#include <intrin.h> | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		#pragma intrinsic(_ReadWriteBarrier) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		#define full_barrier _ReadWriteBarrier(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	#endif | 
			
		
	
		
		
			
				
					
					|  |  |  | #endif |  |  |  | #endif | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -82,12 +96,12 @@ enum DF_ERROR | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | typedef struct |  |  |  | typedef struct | 
			
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  | { | 
			
		
	
		
		
			
				
					
					|  |  |  |     uint32_t pingpong; // = 0
 |  |  |  |     volatile uint32_t pingpong; // = 0
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } shm_cmd; |  |  |  | } shm_cmd; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | typedef struct |  |  |  | typedef struct | 
			
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  | { | 
			
		
	
		
		
			
				
					
					|  |  |  |     uint32_t pingpong; |  |  |  |     volatile uint32_t pingpong; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     uint32_t address; |  |  |  |     uint32_t address; | 
			
		
	
		
		
			
				
					
					|  |  |  |     uint32_t length; |  |  |  |     uint32_t length; | 
			
		
	
		
		
			
				
					
					|  |  |  | } shm_read; |  |  |  | } shm_read; | 
			
		
	
	
		
		
			
				
					|  |  | @ -97,25 +111,25 @@ typedef shm_read shm_bounce; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | typedef struct |  |  |  | typedef struct | 
			
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  | { | 
			
		
	
		
		
			
				
					
					|  |  |  |     uint32_t pingpong; |  |  |  |     volatile uint32_t pingpong; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } shm_ret_data; |  |  |  | } shm_ret_data; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | typedef struct |  |  |  | typedef struct | 
			
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  | { | 
			
		
	
		
		
			
				
					
					|  |  |  |     uint32_t pingpong; |  |  |  |     volatile uint32_t pingpong; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     uint32_t address; |  |  |  |     uint32_t address; | 
			
		
	
		
		
			
				
					
					|  |  |  | } shm_read_small; |  |  |  | } shm_read_small; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | typedef struct |  |  |  | typedef struct | 
			
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  | { | 
			
		
	
		
		
			
				
					
					|  |  |  |     uint32_t pingpong; |  |  |  |     volatile uint32_t pingpong; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     uint32_t address; |  |  |  |     uint32_t address; | 
			
		
	
		
		
			
				
					
					|  |  |  |     uint32_t value; |  |  |  |     uint32_t value; | 
			
		
	
		
		
			
				
					
					|  |  |  | } shm_write_small; |  |  |  | } shm_write_small; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | typedef struct |  |  |  | typedef struct | 
			
		
	
		
		
			
				
					
					|  |  |  | { |  |  |  | { | 
			
		
	
		
		
			
				
					
					|  |  |  |     uint32_t pingpong; |  |  |  |     volatile uint32_t pingpong; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     uint32_t value; |  |  |  |     uint32_t value; | 
			
		
	
		
		
			
				
					
					|  |  |  | } shm_retval; |  |  |  | } shm_retval; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |