comparison fft/native/bqvec/src/Barrier.cpp @ 29:cf59817a5983

Build stuff for native
author Chris Cannam
date Sat, 17 Oct 2015 15:00:08 +0100
parents
children
comparison
equal deleted inserted replaced
28:77fca9c01e46 29:cf59817a5983
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 bqvec
5
6 A small library for vector arithmetic and allocation in C++ using
7 raw C pointer arrays.
8
9 Copyright 2007-2015 Particular Programs Ltd.
10
11 Permission is hereby granted, free of charge, to any person
12 obtaining a copy of this software and associated documentation
13 files (the "Software"), to deal in the Software without
14 restriction, including without limitation the rights to use, copy,
15 modify, merge, publish, distribute, sublicense, and/or sell copies
16 of the Software, and to permit persons to whom the Software is
17 furnished to do so, subject to the following conditions:
18
19 The above copyright notice and this permission notice shall be
20 included in all copies or substantial portions of the Software.
21
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 Except as contained in this notice, the names of Chris Cannam and
31 Particular Programs Ltd shall not be used in advertising or
32 otherwise to promote the sale, use or other dealings in this
33 Software without prior written authorization.
34 */
35
36 #include "Barrier.h"
37
38 namespace breakfastquay {
39
40 void system_memorybarrier()
41 {
42 #if defined __APPLE__
43
44 OSMemoryBarrier();
45
46 #elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
47
48 __sync_synchronize();
49
50 #elif defined _WIN32
51
52 #if defined __MSVC__
53 MemoryBarrier();
54 #else /* (mingw) */
55 LONG Barrier = 0;
56 __asm__ __volatile__("xchgl %%eax,%0 "
57 : "=r" (Barrier));
58 #endif
59
60 #else
61 #warning "No memory barrier defined"
62 #endif
63
64 }
65
66 }
67