1 ////////////////////////////////////////////////////////////////
2 //
3 //  opthelper.h includes some #defines which help to make optimizations easier and better readable
4 //
5 //	copyright (c) 2013  Ingo Weyrich
6 //
7 //	this is free software: you can redistribute it and/or modify
8 //	it under the terms of the GNU General Public License as published by
9 //	the Free Software Foundation, either version 3 of the License, or
10 //	(at your option) any later version.
11 //
12 //	This program is distributed in the hope that it will be useful,
13 //	but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //	GNU General Public License for more details.
16 //
17 //	You should have received a copy of the GNU General Public License
18 //	along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 //
20 ////////////////////////////////////////////////////////////////
21 
22 #ifndef OPTHELPER_H
23 	#define	OPTHELPER_H
24 
25 	#ifdef __SSE2__
26 		#include "sleefsseavx.c"
27 		#ifdef __GNUC__
28 			#ifdef WIN32
29 				// needed for actual versions of GCC with 32-Bit Windows
30 				#define SSEFUNCTION __attribute__((force_align_arg_pointer))
31 			#else
32 				#define SSEFUNCTION
33 			#endif
34 		#else
35 			#define SSEFUNCTION
36 		#endif
37 	#else
38 		#ifdef __SSE__
39 			#ifdef __GNUC__
40 				#ifdef WIN32
41 					// needed for actual versions of GCC with 32-Bit Windows
42 					#define SSEFUNCTION __attribute__((force_align_arg_pointer))
43 				#else
44 					#define SSEFUNCTION
45 				#endif
46 			#else
47 				#define SSEFUNCTION
48 			#endif
49 		#else
50 			#define SSEFUNCTION
51 		#endif
52 	#endif
53 
54 	#ifdef __GNUC__
55 		#define RESTRICT 	__restrict__
56 		#define LIKELY(x)   __builtin_expect (!!(x), 1)
57 		#define UNLIKELY(x) __builtin_expect (!!(x), 0)
58 	#else
59 		#define RESTRICT
60 		#define LIKELY(x)    (x)
61 		#define UNLIKELY(x)  (x)
62 	#endif
63 #endif
64