/usr/include/ITK-4.12/itkAtomicIntDetail.h is in libinsighttoolkit4-dev 4.12.2-dfsg1-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | /*=========================================================================
*
* Copyright Insight Software Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
/*=========================================================================
*
* Program: Visualization Toolkit
* Module: vtkAtomicInt.h
*
* Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
* All rights reserved.
* See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
*
* This software is distributed WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the above copyright notice for more information.
*
*=========================================================================*/
#ifndef itkAtomicIntDetail_h
#define itkAtomicIntDetail_h
#include "itkMacro.h"
#include "itkIntTypes.h"
#include "itkSimpleFastMutexLock.h"
#include "itkConceptChecking.h"
#if ITK_COMPILER_CXX_ATOMIC
# include <atomic>
#elif defined(ITK_HAVE_SYNC_BUILTINS)
# define ITK_GCC_ATOMICS_32
# define ITK_GCC_ATOMICS_64
#elif defined(__APPLE__)
# include <libkern/OSAtomic.h>
# define ITK_APPLE_ATOMICS_32
# if ITK_SIZEOF_VOID_P == 8 || defined(__i386__)
# define ITK_APPLE_ATOMICS_64
# endif
#elif defined(_WIN32) && defined(_MSC_VER)
# define ITK_WINDOWS_ATOMICS_32
# if ITK_SIZEOF_VOID_P == 8
# define ITK_WINDOWS_ATOMICS_64
# endif
#endif
namespace itk
{
namespace Detail
{
template <size_t VSize> class AtomicOps;
#if ITK_COMPILER_CXX_ATOMIC
template <size_t VSize> struct BaseType;
template <size_t VSize> class AtomicOps
{
public:
typedef typename BaseType<VSize>::Type AtomicType;
typedef typename BaseType<VSize>::Type ValueType;
};
#elif defined ITK_HAVE_SYNC_BUILTINS
template <size_t VSize> struct BaseType;
template <size_t VSize> class AtomicOps
{
public:
typedef typename BaseType<VSize>::Type AtomicType;
typedef typename BaseType<VSize>::Type ValueType;
static ValueType AddAndFetch(ValueType *ref, ValueType val)
{
return __sync_add_and_fetch(ref, val);
}
static ValueType SubAndFetch(ValueType *ref, ValueType val)
{
return __sync_sub_and_fetch(ref, val);
}
static ValueType PreIncrement(ValueType *ref)
{
return __sync_add_and_fetch(ref, 1);
}
static ValueType PreDecrement(ValueType *ref)
{
return __sync_sub_and_fetch(ref, 1);
}
static ValueType PostIncrement(ValueType *ref)
{
return __sync_fetch_and_add(ref, 1);
}
static ValueType PostDecrement(ValueType *ref)
{
return __sync_fetch_and_sub(ref, 1);
}
static ValueType Load(const ValueType *ref)
{
return __sync_add_and_fetch(const_cast<ValueType*>(ref), 0);
}
static void Store(ValueType *ref, ValueType val)
{
*static_cast<volatile ValueType*>(ref) = val;
__sync_synchronize();
}
};
#endif // defined ITK_HAVE_SYNC_BUILTINS
#if defined(ITK_GCC_ATOMICS_64) || ITK_COMPILER_CXX_ATOMIC
template<> struct BaseType<8>
{
itkAlignedTypedef( 8, int64_t, Type );
};
#elif defined(ITK_APPLE_ATOMICS_64)
template <> class AtomicOps<8>
{
public:
itkAlignedTypedef( 8, int64_t, AtomicType );
typedef int64_t ValueType;
static int64_t AddAndFetch(int64_t *ref, int64_t val)
{
return OSAtomicAdd64Barrier(val, ref);
}
static int64_t SubAndFetch(int64_t *ref, int64_t val)
{
return OSAtomicAdd64Barrier(-val, ref);
}
static int64_t PreIncrement(int64_t *ref)
{
return OSAtomicIncrement64Barrier(ref);
}
static int64_t PreDecrement(int64_t *ref)
{
return OSAtomicDecrement64Barrier(ref);
}
static int64_t PostIncrement(int64_t *ref)
{
int64_t val = OSAtomicIncrement64Barrier(ref);
return --val;
}
static int64_t PostDecrement(int64_t *ref)
{
int64_t val = OSAtomicDecrement64Barrier(ref);
return ++val;
}
static int64_t Load(const int64_t *ref)
{
OSMemoryBarrier();
return *static_cast<const volatile int64_t*>(ref);
}
static void Store(int64_t *ref, int64_t val)
{
*static_cast<volatile int64_t*>(ref) = val;
OSMemoryBarrier();
}
};
#else
template <> class ITKCommon_EXPORT AtomicOps<8>
{
public:
#if defined(ITK_WINDOWS_ATOMICS_64)
itkAlignedTypedef( 8, int64_t, AtomicType );
#else
struct ITKCommon_EXPORT AtomicType
{
int64_t var;
SimpleFastMutexLock *mutex;
AtomicType(int64_t init);
~AtomicType();
};
#endif
typedef int64_t ValueType;
static int64_t AddAndFetch(AtomicType *ref, int64_t val);
static int64_t SubAndFetch(AtomicType *ref, int64_t val);
static int64_t PreIncrement(AtomicType *ref);
static int64_t PreDecrement(AtomicType *ref);
static int64_t PostIncrement(AtomicType *ref);
static int64_t PostDecrement(AtomicType *ref);
static int64_t Load(const AtomicType *ref);
static void Store(AtomicType *ref, int64_t val);
};
#endif
#if defined(ITK_GCC_ATOMICS_32) || ITK_COMPILER_CXX_ATOMIC
template<> struct BaseType<4>
{
itkAlignedTypedef( 4, int32_t, Type );
};
#elif defined(ITK_APPLE_ATOMICS_32)
template <> class AtomicOps<4>
{
public:
itkAlignedTypedef( 4, int32_t, AtomicType );
typedef int32_t ValueType;
static int32_t AddAndFetch(int32_t *ref, int32_t val)
{
return OSAtomicAdd32Barrier(val, ref);
}
static int32_t SubAndFetch(int32_t *ref, int32_t val)
{
return OSAtomicAdd32Barrier(-val, ref);
}
static int32_t PreIncrement(int32_t *ref)
{
return OSAtomicIncrement32Barrier(ref);
}
static int32_t PreDecrement(int32_t *ref)
{
return OSAtomicDecrement32Barrier(ref);
}
static int32_t PostIncrement(int32_t *ref)
{
int32_t val = OSAtomicIncrement32Barrier(ref);
return --val;
}
static int32_t PostDecrement(int32_t *ref)
{
int32_t val = OSAtomicDecrement32Barrier(ref);
return ++val;
}
static int32_t Load(const int32_t *ref)
{
OSMemoryBarrier();
return *static_cast<const volatile int32_t*>(ref);
}
static void Store(int32_t *ref, int32_t val)
{
*static_cast<volatile int32_t*>(ref) = val;
OSMemoryBarrier();
}
};
#else
template <> class ITKCommon_EXPORT AtomicOps<4>
{
public:
#if defined(ITK_WINDOWS_ATOMICS_32)
itkAlignedTypedef( 4, int32_t, AtomicType );
#else
struct ITKCommon_EXPORT AtomicType
{
int32_t var;
SimpleFastMutexLock *mutex;
AtomicType(int32_t init);
~AtomicType();
};
#endif
typedef int32_t ValueType;
static int32_t AddAndFetch(AtomicType *ref, int32_t val);
static int32_t SubAndFetch(AtomicType *ref, int32_t val);
static int32_t PreIncrement(AtomicType *ref);
static int32_t PreDecrement(AtomicType *ref);
static int32_t PostIncrement(AtomicType *ref);
static int32_t PostDecrement(AtomicType *ref);
static int32_t Load(const AtomicType *ref);
static void Store(AtomicType *ref, int32_t val);
};
#endif
template <typename T>
struct IsAtomicSupportedIntegralType
{
typedef IsAtomicSupportedIntegralType Self;
struct Constraints {
typedef Concept::Detail::UniqueType_bool< true > TrueT;
typedef Concept::Detail::UniqueType_bool< NumericTraits<T>::is_specialized > SpecializedT;
typedef Concept::Detail::UniqueType_bool< NumericTraits<T>::is_integer > IntegralT;
typedef Concept::Detail::UniqueType_bool <sizeof(T) == 4 || sizeof(T) == 8 > SizeT;
void constraints()
{
IntegralT a = TrueT();
IntegralT b = TrueT();
IntegralT c = TrueT();
IgnoreUnusedVariable(a);
IgnoreUnusedVariable(b);
IgnoreUnusedVariable(c);
}
};
itkConceptConstraintsMacro();
};
} // end namespace Detail
} // end namespace itk
#endif
|