]> git.sesse.net Git - casparcg/blob - tbb30_20100406oss/include/tbb/machine/xbox360_ppc.h
2.0.2: Updated to boost 1.48.
[casparcg] / tbb30_20100406oss / include / tbb / machine / xbox360_ppc.h
1 /*
2     Copyright 2005-2010 Intel Corporation.  All Rights Reserved.
3
4     This file is part of Threading Building Blocks.
5
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.
9
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.
14
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
18
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.
27 */
28
29 #ifndef __TBB_machine_H
30 #error Do not include this file directly; include tbb_machine.h instead
31 #endif
32
33 #define NONET
34 #define NOD3D
35 #include "xtl.h"    
36 #include "ppcintrinsics.h"
37
38 #if _MSC_VER >= 1300
39 extern "C" void _ReadWriteBarrier();
40 #pragma intrinsic(_ReadWriteBarrier)
41 #define __TBB_release_consistency_helper() _ReadWriteBarrier()
42 #endif
43
44 inline void __TBB_rel_acq_fence() { __lwsync(); }
45
46 #define __TBB_WORDSIZE 4
47 #define __TBB_BIG_ENDIAN 1
48
49 //todo: define __TBB_DECL_FENCED_ATOMICS and define acquire/release primitives to maximize performance
50
51 typedef __int64 int64_t;  //required for definition of Store8/Load8 in atomic.h
52 typedef unsigned char uint8_t;  //same reason
53
54 inline __int32 __TBB_machine_cmpswp4(volatile void *ptr, __int32 value, __int32 comparand )
55 {                               
56  __lwsync();
57  __int32 result = InterlockedCompareExchange((volatile LONG*)ptr, value, comparand);
58  __lwsync();
59  return result;
60 }
61
62 inline __int64 __TBB_machine_cmpswp8(volatile void *ptr, __int64 value, __int64 comparand )
63 {
64  __lwsync();
65  __int64 result = InterlockedCompareExchange64((volatile LONG64*)ptr, value, comparand);
66  __lwsync();
67  return result;
68 }
69
70 #pragma optimize( "", off )
71 inline void __TBB_machine_pause (__int32 delay ) 
72 {
73  for (__int32 i=0; i<delay; i++) {;};
74 }
75 #pragma optimize( "", on ) 
76
77
78 #define __TBB_CompareAndSwap4(P,V,C) __TBB_machine_cmpswp4(P,V,C)
79 #define __TBB_CompareAndSwap8(P,V,C) __TBB_machine_cmpswp8(P,V,C)
80 #define __TBB_CompareAndSwapW(P,V,C) __TBB_machine_cmpswp4(P,V,C)
81 #define __TBB_Yield()  Sleep(0)
82 #define __TBB_Pause(V) __TBB_machine_pause(V)
83 #define __TBB_fence_for_acquire() __lwsync()
84 #define __TBB_fence_for_release() __lwsync()
85