This file is indexed.

/usr/include/d2/4.6/std/atomics.d is in libphobos2-4.6-dev 0.29.1-4.6.3-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
// Written in the D programming language.

/**
Implements processor dependent parts of the atomics library.

Macros:
    WIKI = Phobos/Atomics
    
Copyright: Copyright Bartosz Milewski 2008 - 2009.
License:   <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
Authors:   Bartosz Milewski

         Copyright Bartosz Milewski 2008 - 2009.
Distributed under the Boost Software License, Version 1.0.
   (See accompanying file LICENSE_1_0.txt or copy at
         http://www.boost.org/LICENSE_1_0.txt)
*/

version (D_InlineAsm_X86)
{

/**
Compare And Swap. The engine behind lock-free algorithms.

In one atomic operation, it tests the contents of $(D addr) and, if it's eqaul to $(D old), overwrites it with $(D new_val) and returns $(D true). Otherwise returns $(D false). 
*/
bool CAS(uint * addr, uint old, uint new_val)
{
asm {
    mov EDX, addr;
    mov ECX, new_val;
    mov EAX, old;
    lock;
    cmpxchg [EDX], ECX;
    setz DL;
    movzx EAX, DL;
  }
}

/** 
Stops the compiler from performing code motion across the barrier.
It's not a memory fence.
*/
void compiler_fence()
{
asm {
  }
}

// The x86 implements processor-order memory model, so fences are not strictly necessary.
// 

/** Memory read fence (includes compiler fence)
*/
void read_fence()
{
asm {
  }
}

/** Memory write fence (includes compiler fence)
*/
void write_fence()
{
asm {
  }
}

} // D_InlineAsm_X86

unittest
{
    uint x = 1;
        bool success = CAS(&x, 1, 2);
        assert(success);
        assert(x == 2);
        
        success = CAS(&x, 1, 3);
        assert(!success);
        assert(x == 2);
}