You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			23 lines
		
	
	
		
			570 B
		
	
	
	
		
			C
		
	
			
		
		
	
	
			23 lines
		
	
	
		
			570 B
		
	
	
	
		
			C
		
	
| /*! \file
 | |
|  *  \brief Helper for cache alignment
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include "../debug/assert.h"
 | |
| 
 | |
| // Helper for aligning to cache line (to prevent false sharing)
 | |
| #ifndef CACHE_LINE_SIZE
 | |
| #define CACHE_LINE_SIZE 64
 | |
| #endif
 | |
| #define cache_aligned alignas(CACHE_LINE_SIZE)
 | |
| 
 | |
| /*!
 | |
|  *  \def assert_cache_aligned(TYPE)
 | |
|  *  \brief Compile time check of cache alignment
 | |
|  *  \param TYPE data type to check
 | |
|  */
 | |
| #define assert_cache_aligned(TYPE)                   \
 | |
|   static_assert(sizeof(TYPE) % CACHE_LINE_SIZE == 0, \
 | |
|                 STRINGIFY(TYPE) "Not aligned on cache boundary")
 |