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             #if defined(WIN32) && !defined( __x86_64__ )
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                 #if defined(WIN32) && !defined( __x86_64__ )
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         #if (!defined(WIN32) || defined( __x86_64__ ))
59             #define ALIGNED64 __attribute__ ((aligned (64)))
60             #define ALIGNED16 __attribute__ ((aligned (16)))
61         #else // there is a bug in gcc 4.7.x when using openmp and aligned memory and -O3, also needed for WIN32 builds
62             #define ALIGNED64
63             #define ALIGNED16
64         #endif
65     #else
66         #define RESTRICT
67         #define LIKELY(x)    (x)
68         #define UNLIKELY(x)  (x)
69         #define ALIGNED64
70         #define ALIGNED16
71     #endif
72 #endif
73