base.hpp (2740B)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | /* Relacy Race Detector * Copyright (c) 2008-2010, Dmitry S. Vyukov * All rights reserved. * This software is provided AS-IS with no warranty, either express or implied. * This software is distributed under a license and may not be copied, * modified or distributed except as expressly authorized under the * terms of the license contained in the file LICENSE.TXT in this distribution. */ #ifndef RL_BASE_HPP #define RL_BASE_HPP #ifdef _MSC_VER # pragma once #endif #include "pch.hpp" #include "platform.hpp" namespace rl { size_t const subsequent_timed_wait_limit = 4; } #define RL_TEST #ifdef RL_JAVA_MODE # define RL_GC # define RL_NO_MALLOC # define RL_JAVA_API # define RL_JAVA_MM #endif #ifdef RL_CLI_MODE # define RL_GC # define RL_NO_MALLOC # define RL_CLI_API # define RL_CLI_MM #endif #ifdef RL_POSIX_MODE # define RL_POSIX_API #endif #ifdef RL_WIN_MODE # define RL_WIN_API #endif #ifdef RL_CPP_MODE # define RL_CPP_API # define RL_CPP_MM #endif #if defined(RL_JAVA_MM) || defined(RL_CLI_MM) # define RL_IMPROVED_SEQ_CST_FENCE # define RL_IMPROVED_SEQ_CST_RMW #endif namespace rl { #define RL_NOCOPY(CLASS) \ private: \ CLASS(CLASS const&); \ CLASS& operator = (CLASS const&); /**/ template<typename T = void> class nocopy { nocopy(nocopy const&); nocopy& operator = (nocopy const&); protected: nocopy() {} }; template<size_t sz, size_t base = 4> struct align_pad { template<bool perfect, bool fit, int fake> struct helper { struct type { char pad [base - sz]; }; }; template<int fake> struct helper<true, true, fake> { struct type {}; }; template<bool perfect, int fake> struct helper<perfect, false, fake> { typedef typename align_pad<sz, base * 2>::type type; }; typedef typename helper<sz == base, sz <= base, 0>::type type; }; template<typename T> struct aligned : T, align_pad<sizeof(T)>::type {}; template<typename T> T val(T x) { return x; } } #include "defs.hpp" #define RL_INFO ::rl::debug_info(__FUNCTION__, __FILE__, __LINE__) #define $ RL_INFO #ifdef RL_DO_ASSERT # if RL_DO_ASSERT # define RL_DO_ASSERT_IMPL # endif #else # ifdef _DEBUG # define RL_DO_ASSERT_IMPL # endif #endif #ifdef _MSC_VER # define RL_INT3() __debugbreak(); abort() #else # define RL_INT3() abort() #endif #ifdef RL_DO_ASSERT_IMPL # define RL_VERIFY(x) do { if (!((void)0, (x))) { \ ::rl::assert_failed(#x, $); RL_INT3(); } } while ((void)0, 0) #else # define RL_VERIFY(x) (void)0 #endif #endif |