vSMC
vSMC: Scalable Monte Carlo
common.h
Go to the documentation of this file.
1 //============================================================================
2 // vSMC/include/vsmc/rng/internal/common.h
3 //----------------------------------------------------------------------------
4 // vSMC: Scalable Monte Carlo
5 //----------------------------------------------------------------------------
6 // Copyright (c) 2013,2014, Yan Zhou
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // Redistributions of source code must retain the above copyright notice,
13 // this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright notice,
16 // this list of conditions and the following disclaimer in the documentation
17 // and/or other materials provided with the distribution.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 // POSSIBILITY OF SUCH DAMAGE.
30 //============================================================================
31 
32 #ifndef VSMC_RNG_INTERNAL_COMMON_H
33 #define VSMC_RNG_INTERNAL_COMMON_H
34 
35 #ifdef __OPENCL_VERSION__
36  #ifndef VSMC_HAS_OPENCL_DOUBLE
37  #define VSMC_HAS_OPENCL_DOUBLE 0
38  #endif
39  #ifndef UINT64_C
40  #define UINT64_C(x) ((ulong)(x##UL))
41  #endif
42  #ifndef VSMC_STATIC_INLINE
43  #if defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 120
44  #define VSMC_STATIC_INLINE static inline
45  #else
46  #define VSMC_STATIC_INLINE inline
47  #endif
48  #endif // VSMC_STATIC_INLINE
49 #else // __OPENCL_VERSION__
50  #ifndef VSMC_HAS_OPENCL_DOUBLE
51  #define VSMC_HAS_OPENCL_DOUBLE 1
52  #endif
53  #ifndef __STDC_CONSTANT_MACROS
54  #define __STDC_CONSTANT_MACROS
55  #endif
56  #include <stdint.h>
57  #ifndef UINT64_C
58  #error __STDC_CONSTANT_MACROS not defined before #include<stdint.h>
59  #endif
60  #ifdef __cplusplus
61  #ifndef VSMC_STATIC_INLINE
62  #define VSMC_STATIC_INLINE inline
63  #endif
64  #include <cmath>
65  #else // __cplusplus
66  #ifndef VSMC_STATIC_INLINE
67  #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
68  #define VSMC_STATIC_INLINE static inline
69  #else
70  #define VSMC_STATIC_INLINE static
71  #endif
72  #endif // VSMC_STATIC_INLINE
73  #include <math.h>
74  #endif // __cplusplus
75 #endif // __OPENCL_VERSION__
76 
77 #endif // VSMC_RNG_INTERNAL_COMMON_H