This file is indexed.

/usr/include/sipxtapi/os/OsAtomics.h is in libsipxtapi-dev 3.3.0~test17-2.1.

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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
//
// Copyright (C) 2008 SIPez LLC. 
// Licensed to SIPfoundry under a Contributor Agreement. 
//
// Copyright (C) 2008 SIPfoundry Inc.
// Licensed by SIPfoundry under the LGPL license.
//
// $$
///////////////////////////////////////////////////////////////////////////////

// Author: Alexander Chemeris <Alexander DOT Chemeris AT SIPez DOT com>

#ifndef _OsAtomics_H_ // [
#define _OsAtomics_H_

#ifdef HAVE_C_ATOMICS // [
#  include <cstdatomic>

typedef atomic_int OsAtomicInt;
typedef atomic_uint OsAtomicUInt;
typedef atomic_long OsAtomicLong;
typedef atomic_ulong OsAtomicULong;
typedef atomic_address OsAtomicVoidPtr;

#define OsAtomicLight OsAtomic

#elif defined(ANDROID) // HAVE_C_ATOMICS ][ ANDROID

#include <os/OsAtomicsAndroid.h>

#else // ANDROID ][

#ifdef __arm__
#warning ARM version of OsAtomics need to be fixed to support ARM features.
#endif

#  include <os/OsLock.h>
#  include <os/OsMutex.h>
#  include <stddef.h>
#  include <os/OsIntTypes.h>

typedef enum memory_order {
   memory_order_relaxed, memory_order_consume, memory_order_acquire,
   memory_order_release, memory_order_acq_rel, memory_order_seq_cst
} memory_order;

template<class T>
class OsAtomic
{
public:
   bool is_lock_free() const
   {return false;}

   void store(T val, memory_order  = memory_order_seq_cst)
   {OsLock lock(mMutex); mVal = val;}

   T load(memory_order = memory_order_seq_cst) const
   {OsLock lock(mMutex); return mVal;}

   operator T() const
   {return load();}

//   T exchange(T val, memory_order = memory_order_seq_cst);
//   bool compare_exchange(T &, T , memory_order, memory_order);
//   bool compare_exchange(T &, T , memory_order = memory_order_seq_cst);

   void fence(memory_order) const
   {};

   T fetch_add(T val, memory_order = memory_order_seq_cst)
   {OsLock lock(mMutex); T temp = mVal; mVal += val; return temp;}

   T fetch_sub(T val, memory_order = memory_order_seq_cst)
   {OsLock lock(mMutex); T temp = mVal; mVal -= val; return temp;}

   T fetch_and(T val, memory_order = memory_order_seq_cst)
   {OsLock lock(mMutex); T temp = mVal; mVal &= val; return temp;}

   T fetch_or(T val, memory_order = memory_order_seq_cst)
   {OsLock lock(mMutex); T temp = mVal; mVal |= val; return temp;}

   T fetch_xor(T val, memory_order = memory_order_seq_cst)
   {OsLock lock(mMutex); T temp = mVal; mVal ^= val; return temp;}

   OsAtomic<T>() : mMutex(0) {};

   explicit OsAtomic<T>(T val) : mVal(val), mMutex(0) {};

   T operator=(T val)
   {store(val); return val;}

   T operator++(int)
   {return fetch_add(1);}

   T operator--(int)
   {return fetch_sub(1);}

   T operator++()
   {return operator+=(1);}

   T operator--()
   {return operator-=(1);}

   T operator+=(T val)
   {OsLock lock(mMutex); mVal += val; return mVal;}

   T operator-=(T val)
   {OsLock lock(mMutex); mVal -= val; return mVal;}

   T operator&=(T val)
   {OsLock lock(mMutex); mVal &= val; return mVal;}

   T operator|=(T val)
   {OsLock lock(mMutex); mVal |= val; return mVal;}

   T operator^=(T val)
   {OsLock lock(mMutex); mVal ^= val; return mVal;}

private:
   T       mVal;
   mutable OsMutex mMutex;

   // Prohibit use of copy constructor and operator=
   OsAtomic<T>(const OsAtomic<T>&);
   OsAtomic<T>& operator=(const OsAtomic<T>&);
};

typedef OsAtomic<int> OsAtomicInt;
typedef OsAtomic<unsigned int> OsAtomicUInt;
typedef OsAtomic<long> OsAtomicLong;
typedef OsAtomic<unsigned long> OsAtomicULong;

class OsAtomicBool {
public:
   bool is_lock_free() const
   {return false;}

   OsAtomicBool() : mMutex(0) {};

   explicit OsAtomicBool(bool val) : mVal(val), mMutex(0) {};

   void store(bool val, memory_order  = memory_order_seq_cst)
   {OsLock lock(mMutex); mVal = val;}

   bool load(memory_order = memory_order_seq_cst) const
   {OsLock lock(mMutex); return mVal;}

   bool operator=(bool val)
   {store(val); return val;}

   operator bool() const
   {return load();}

//   bool exchange(bool, memory_order = memory_order_seq_cst);
//   bool compare_exchange(bool&, bool, memory_order, memory_order);
//   bool compare_exchange(bool&, bool, memory_order = memory_order_seq_cst);

   void fence(memory_order) const
   {}

private:
   bool     mVal;
   mutable OsMutex mMutex;

   // Prohibit use of copy constructor and operator=
   OsAtomicBool(const OsAtomicBool&);
   OsAtomicBool& operator=(const OsAtomicBool&);
};

class OsAtomicVoidPtr
{
public:
   bool is_lock_free() const
   {return false;}

   void store(void* val, memory_order  = memory_order_seq_cst)
   {OsLock lock(mMutex); mVal = val;}

   void* load(memory_order = memory_order_seq_cst) const
   {OsLock lock(mMutex); return mVal;}

   operator void*() const
   {return load();}

//   void* exchange(void* val, memory_order = memory_order_seq_cst);
//   bool compare_exchange(void* &, void* , memory_order, memory_order);
//   bool compare_exchange(void* &, void* , memory_order = memory_order_seq_cst);

   void fence(memory_order) const
   {};

   void* fetch_add(ptrdiff_t val, memory_order = memory_order_seq_cst)
   {OsLock lock(mMutex); void* temp = mVal; mVal = (int8_t*)mVal + val; return temp;}

   void* fetch_sub(ptrdiff_t val, memory_order = memory_order_seq_cst)
   {OsLock lock(mMutex); void* temp = mVal; mVal = (int8_t*)mVal - val; return temp;}

   OsAtomicVoidPtr() : mMutex(0) {};

   explicit OsAtomicVoidPtr(void* val) : mVal(val), mMutex(0) {};

   void* operator=(void* val)
   {store(val); return val;}

   void* operator+=(ptrdiff_t val)
   {OsLock lock(mMutex); mVal = (int8_t*)mVal + val; return mVal;}

   void* operator-=(ptrdiff_t val)
   {OsLock lock(mMutex); mVal = (int8_t*)mVal - val; return mVal;}

private:
   void*       mVal;
   mutable OsMutex mMutex;

   // Prohibit use of copy constructor and operator=
   OsAtomicVoidPtr(const OsAtomicVoidPtr&);
   OsAtomicVoidPtr& operator=(const OsAtomicVoidPtr&);
};

template<class T>
class OsAtomicPtr : public OsAtomicVoidPtr
{
public:
   bool is_lock_free() const
   {return false;}

   void store(T* val, memory_order mo = memory_order_seq_cst)
   {OsAtomicVoidPtr::store((void*)val, mo);}

   T* load(memory_order mo = memory_order_seq_cst) const
   {return (T*)OsAtomicVoidPtr::load(mo);}

   operator T*() const
   {return (T*)OsAtomicVoidPtr::operator void*();}

//   T* exchange(T* val, memory_order mo = memory_order_seq_cst);
//   bool compare_exchange(T* &, T* , memory_order mo, memory_order mo);
//   bool compare_exchange(T* &, T* , memory_order mo = memory_order_seq_cst);

   void fence(memory_order mo) const
   {OsAtomicVoidPtr::fence(mo);}

   T* fetch_add(ptrdiff_t val, memory_order mo = memory_order_seq_cst)
   {return (T*)OsAtomicVoidPtr::fetch_add(val, mo);}

   T* fetch_sub(ptrdiff_t val, memory_order mo = memory_order_seq_cst)
   {return (T*)OsAtomicVoidPtr::fetch_sub(val, mo);}

   OsAtomicPtr() {};

   explicit OsAtomicPtr(T* val) : OsAtomicVoidPtr((void*)val) {};

   T* operator=(T* val)
   {return (T*)OsAtomicVoidPtr::operator=((void*)val);}

   T* operator+=(ptrdiff_t val)
   {return (T*)OsAtomicVoidPtr::operator+=(val);}

   T* operator-=(ptrdiff_t val)
   {return (T*)OsAtomicVoidPtr::operator-=(val);}

private:
   // Prohibit use of copy constructor and operator=
   OsAtomicPtr(const OsAtomicPtr&);
   OsAtomicPtr& operator=(const OsAtomicPtr&);
};


#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__amd64__) || defined (__arm__)// [
template<class T>
class OsAtomicLight
{
public:
   bool is_lock_free() const
   {return true;}

   void store(T val, memory_order  = memory_order_relaxed)
   {mVal = val;}

   T load(memory_order = memory_order_relaxed) const
   {return mVal;}

   operator T() const
   {return load();}

   void fence(memory_order) const
   {};

   OsAtomicLight<T>() {};

   explicit OsAtomicLight<T>(T val) : mVal(val) {};

   T operator=(T val)
   {store(val); return val;}

private:
   volatile T       mVal;

   // Prohibit use of copy constructor and operator=
   OsAtomicLight<T>(const OsAtomicLight<T>&);
   OsAtomicLight<T>& operator=(const OsAtomicLight<T>&);
};


template<class T>
class OsAtomicLightPtr
{
public:
   bool is_lock_free() const
   {return true;}

   void store(T* val, memory_order mo = memory_order_relaxed)
   {mVal = val;}

   const T* load(memory_order mo = memory_order_relaxed) const
   {return mVal;}

   T* load(memory_order mo = memory_order_relaxed)
   {return mVal;}

   operator const T*() const
   {return load();}

   operator T*()
   {return load();}

   void fence(memory_order mo) const
   {}

   OsAtomicLightPtr() {};

   explicit OsAtomicLightPtr(T* val) : mVal(val) {};

   T* operator=(T* val)
   {store(val); return val;}

private:
   T * volatile mVal;

   // Prohibit use of copy constructor and operator=
   OsAtomicLightPtr(const OsAtomicLightPtr&);
   OsAtomicLightPtr& operator=(const OsAtomicLightPtr&);
};

#else // X86/X86_64/ARM ][

#define OsAtomicLight OsAtomic
#define OsAtomicLightPtr OsAtomicPtr

#endif // !X86/X86_64/ARM

#endif // HAVE_C_ATOMICS ]

typedef OsAtomicLight<int> OsAtomicLightInt;
typedef OsAtomicLight<unsigned int> OsAtomicLightUInt;
typedef OsAtomicLight<long> OsAtomicLightLong;
typedef OsAtomicLight<unsigned long> OsAtomicLightULong;
typedef OsAtomicLight<bool> OsAtomicLightBool;

#endif // _OsAtomics_H_ ]