]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | //---------------------------------------------------------------------------// |
2 | // Copyright (c) 2017 Denis Demidov <dennis.demidov@gmail.com> | |
3 | // | |
4 | // Distributed under the Boost Software License, Version 1.0 | |
5 | // See accompanying file LICENSE_1_0.txt or copy at | |
6 | // http://www.boost.org/LICENSE_1_0.txt | |
7 | // | |
8 | // See http://boostorg.github.com/compute for more information. | |
9 | //---------------------------------------------------------------------------// | |
10 | ||
11 | // size_t and ptrdiff_t need special treatment on OSX since those are not | |
12 | // typedefs for ulong and long here: | |
13 | #if defined(__APPLE__) && !defined(BOOST_COMPUTE_TYPES_SIZE_T_HPP) | |
14 | #define BOOST_COMPUTE_TYPES_SIZE_T_HPP | |
15 | ||
16 | #include <sstream> | |
17 | ||
18 | #include <boost/mpl/if.hpp> | |
19 | ||
20 | #include <boost/compute/type_traits/is_fundamental.hpp> | |
21 | #include <boost/compute/type_traits/type_name.hpp> | |
22 | #include <boost/compute/detail/meta_kernel.hpp> | |
23 | ||
24 | namespace boost { | |
25 | namespace compute { | |
26 | ||
27 | template <> struct is_fundamental<size_t> : boost::true_type {}; | |
28 | template <> struct is_fundamental<ptrdiff_t> : boost::true_type {}; | |
29 | ||
30 | namespace detail { | |
31 | ||
32 | template <> struct type_name_trait<size_t> | |
33 | : type_name_trait< | |
34 | boost::mpl::if_c<sizeof(size_t) == sizeof(cl_uint), cl_uint, cl_ulong>::type | |
35 | > | |
36 | {}; | |
37 | ||
38 | template <> struct type_name_trait<ptrdiff_t> | |
39 | : type_name_trait< | |
40 | boost::mpl::if_c<sizeof(ptrdiff_t) == sizeof(cl_int), cl_int, cl_long>::type | |
41 | > | |
42 | {}; | |
43 | ||
44 | inline meta_kernel& operator<<(meta_kernel &k, size_t v) { | |
45 | std::ostringstream s; | |
46 | s << v; | |
47 | return k << s.str(); | |
48 | } | |
49 | ||
50 | inline meta_kernel& operator<<(meta_kernel &k, ptrdiff_t v) { | |
51 | std::ostringstream s; | |
52 | s << v; | |
53 | return k << s.str(); | |
54 | } | |
55 | ||
56 | } // end detail namespace | |
57 | } // end compute namespace | |
58 | } // end boost namespace | |
59 | ||
60 | #endif |