2 Copyright 2005-2011 Intel Corporation. All Rights Reserved.
4 This file is part of Threading Building Blocks.
6 Threading Building Blocks is free software; you can redistribute it
7 and/or modify it under the terms of the GNU General Public License
8 version 2 as published by the Free Software Foundation.
10 Threading Building Blocks is distributed in the hope that it will be
11 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with Threading Building Blocks; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 As a special exception, you may use this file as part of a free software
20 library without restriction. Specifically, if other files instantiate
21 templates or use macros or inline functions from this file, or you compile
22 this file and link it with other files to produce an executable, this
23 file does not by itself cause the resulting executable to be covered by
24 the GNU General Public License. This exception does not however
25 invalidate any other reasons why the executable file might be covered by
26 the GNU General Public License.
29 #if !defined(__TBB_machine_H) || defined(__TBB_machine_gcc_generic_H)
30 #error Do not include this file directly; include tbb_machine.h instead
33 #define __TBB_machine_gcc_generic_H
38 #define __TBB_WORDSIZE __SIZEOF_INT__
40 // For some reason straight mapping does not work on mingw
41 #if __BYTE_ORDER__==__ORDER_BIG_ENDIAN__
42 #define __TBB_BIG_ENDIAN 0
43 #elif __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__
44 #define __TBB_BIG_ENDIAN 1
46 #error Unsupported endianness
49 /** As this generic implementation has absolutely no information about underlying
50 hardware, its performance most likely will be sub-optimal because of full memory
51 fence usages where a more lightweight synchronization means (or none at all)
52 could suffice. Thus if you use this header to enable TBB on a new platform,
53 consider forking it and relaxing below helpers as appropriate. **/
54 #define __TBB_acquire_consistency_helper() __sync_synchronize()
55 #define __TBB_release_consistency_helper() __sync_synchronize()
56 #define __TBB_full_memory_fence() __sync_synchronize()
57 #define __TBB_control_consistency_helper() __sync_synchronize()
59 #define __TBB_MACHINE_DEFINE_ATOMICS(S,T) \
60 inline T __TBB_machine_cmpswp##S( volatile void *ptr, T value, T comparand ) { \
61 return __sync_val_compare_and_swap(reinterpret_cast<volatile T *>(ptr),comparand,value); \
64 __TBB_MACHINE_DEFINE_ATOMICS(1,int8_t)
65 __TBB_MACHINE_DEFINE_ATOMICS(2,int16_t)
66 __TBB_MACHINE_DEFINE_ATOMICS(4,int32_t)
67 __TBB_MACHINE_DEFINE_ATOMICS(8,int64_t)
69 #undef __TBB_MACHINE_DEFINE_ATOMICS
71 #define __TBB_USE_GENERIC_FETCH_ADD 1
72 #define __TBB_USE_GENERIC_FETCH_STORE 1
73 #define __TBB_USE_GENERIC_HALF_FENCED_LOAD_STORE 1
74 #define __TBB_USE_GENERIC_RELAXED_LOAD_STORE 1