Nugget
atomic_macros.h
1 // Copyright (c) Electronic Arts Inc. All rights reserved.
4 
5 
6 #ifndef EASTL_ATOMIC_INTERNAL_MACROS_H
7 #define EASTL_ATOMIC_INTERNAL_MACROS_H
8 
9 #if defined(EA_PRAGMA_ONCE_SUPPORTED)
10  #pragma once
11 #endif
12 
13 
15 //
16 // The reason for the implementation separating out into a compiler and architecture
17 // folder is as follows.
18 //
19 // The compiler directory is meant to implement atomics using the compiler provided
20 // intrinsics. This also implies that usually the same compiler instrinsic implementation
21 // can be used for any architecture the compiler supports. If a compiler provides intrinsics
22 // to support barriers or atomic operations, then that implementation should be in the
23 // compiler directory.
24 //
25 // The arch directory is meant to manually implement atomics for a specific architecture
26 // such as power or x86. There may be some compiler specific code in this directory because
27 // GCC inline assembly syntax may be different than another compiler as an example.
28 //
29 // The arch directory can also be used to implement some atomic operations ourselves
30 // if we deem the compiler provided implementation to be inefficient for the given
31 // architecture or we need to do some things manually for a given compiler.
32 //
33 // The atomic_macros directory implements the macros that the rest of the atomic
34 // library uses. These macros will expand to either the compiler or arch implemented
35 // macro. The arch implemented macro is given priority over the compiler implemented
36 // macro if both are implemented otherwise whichever is implemented is chosen or
37 // an error is emitted if none are implemented.
38 //
39 // The implementation being all macros has a couple nice side effects as well.
40 //
41 // 1. All the implementation ends up funneling into one low level macro implementation
42 // which makes it easy to verify correctness, reduce copy-paste errors and differences
43 // in various platform implementations.
44 //
45 // 2. Allows for the implementation to be implemented efficiently on compilers that do not
46 // directly implement the C++ memory model in their intrinsics such as msvc.
47 //
48 // 3. Allows for the implementation of atomics that may not be supported on the given platform,
49 // such as 128-bit atomics on 32-bit platforms since the macros will only ever be expanded
50 // on platforms that support said features. This makes implementing said features pretty easy
51 // since we do not have to worry about complicated feature detection in the low level implementations.
52 //
53 // The macro implementation may asume that all passed in types are trivially constructible thus it is
54 // free to create local variables of the passed in types as it may please.
55 // It may also assume that all passed in types are trivially copyable as well.
56 // It cannot assume any passed in type is any given type thus is a specific type if needed, it must do an
57 // EASTL_ATOMIC_TYPE_PUN_CAST() to the required type.
58 //
59 
60 
61 #include "compiler/compiler.h"
62 #include "arch/arch.h"
63 
64 #include "atomic_macros/atomic_macros.h"
65 
66 
67 #endif /* EASTL_ATOMIC_INTERNAL_MACROS_H */