Skip to content

Commit

Permalink
Merge pull request #46 from glessard/padded
Browse files Browse the repository at this point in the history
added non-atomic pointer wrappers padded and aligned to cache lines
  • Loading branch information
glessard authored Feb 8, 2019
2 parents 18c0c44 + 017b05b commit b2c3c71
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 43 deletions.
46 changes: 29 additions & 17 deletions Sources/CAtomics/include/CAtomics.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ SWIFT_ENUM(CASType, closed)

// atomic integer generation

#define CLANG_ATOMICS_STRUCT(swiftType, atomicType, alignment) \
typedef struct { volatile atomicType a __attribute__ ((aligned(alignment))); } swiftType;
#define CLANG_ATOMICS_STRUCT(swiftType, atomicType, atomName, alignment) \
typedef struct { volatile atomicType atomName __attribute__ ((aligned(alignment))); } swiftType;

#define CLANG_ATOMICS_IS_LOCK_FREE(swiftType) \
static __inline__ __attribute__((__always_inline__)) \
Expand Down Expand Up @@ -168,7 +168,7 @@ SWIFT_ENUM(CASType, closed)
}

#define CLANG_ATOMICS_GENERATE(swiftType, atomicType, parameterType, alignment) \
CLANG_ATOMICS_STRUCT(swiftType, atomicType, alignment) \
CLANG_ATOMICS_STRUCT(swiftType, atomicType, a, alignment) \
CLANG_ATOMICS_IS_LOCK_FREE(swiftType) \
CLANG_ATOMICS_INITIALIZE(swiftType, parameterType) \
CLANG_ATOMICS_CREATE(swiftType, parameterType) \
Expand Down Expand Up @@ -213,9 +213,9 @@ CLANG_ATOMICS_INT_GENERATE(AtomicUInt64, atomic_ullong, unsigned long long, _Ali
CLANG_ATOMICS_BOOL_GENERATE(AtomicBool, atomic_bool, _Bool, _Alignof(atomic_bool))

#ifdef __CACHE_LINE_WIDTH
CLANG_ATOMICS_INT_GENERATE(AtomicCacheLineAlignedInt, atomic_intptr_t, intptr_t, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_INT_GENERATE(AtomicCacheLineAlignedUInt, atomic_uintptr_t, uintptr_t, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_BOOL_GENERATE(AtomicCacheLineAlignedBool, atomic_bool, _Bool, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_INT_GENERATE(AtomicCacheAlignedInt, atomic_intptr_t, intptr_t, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_INT_GENERATE(AtomicCacheAlignedUInt, atomic_uintptr_t, uintptr_t, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_BOOL_GENERATE(AtomicCacheAlignedBool, atomic_bool, _Bool, __CACHE_LINE_WIDTH)
#endif

// pointer atomics
Expand Down Expand Up @@ -273,7 +273,7 @@ CLANG_ATOMICS_BOOL_GENERATE(AtomicCacheLineAlignedBool, atomic_bool, _Bool, __CA
}

#define CLANG_ATOMICS_POINTER_GENERATE(swiftType, atomicType, parameterType, nullability, alignment) \
CLANG_ATOMICS_STRUCT(swiftType, atomicType, alignment) \
CLANG_ATOMICS_STRUCT(swiftType, atomicType, a, alignment) \
CLANG_ATOMICS_IS_LOCK_FREE(swiftType) \
CLANG_ATOMICS_POINTER_INITIALIZE(swiftType, parameterType, nullability) \
CLANG_ATOMICS_POINTER_CREATE(swiftType, parameterType, nullability) \
Expand All @@ -290,10 +290,10 @@ CLANG_ATOMICS_POINTER_GENERATE(AtomicNonNullRawPointer, atomic_uintptr_t, const
CLANG_ATOMICS_POINTER_GENERATE(AtomicOptionalRawPointer, atomic_uintptr_t, const void*, _Nullable, _Alignof(atomic_uintptr_t))

#ifdef __CACHE_LINE_WIDTH
CLANG_ATOMICS_POINTER_GENERATE(AtomicCacheLineAlignedMutableRawPointer, atomic_uintptr_t, void*, _Nonnull, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_POINTER_GENERATE(AtomicCacheLineAlignedOptionalMutableRawPointer, atomic_uintptr_t, void*, _Nullable, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_POINTER_GENERATE(AtomicCacheLineAlignedRawPointer, atomic_uintptr_t, const void*, _Nonnull, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_POINTER_GENERATE(AtomicCacheLineAlignedOptionalRawPointer, atomic_uintptr_t, const void*, _Nullable, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_POINTER_GENERATE(AtomicCacheAlignedMutableRawPointer, atomic_uintptr_t, void*, _Nonnull, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_POINTER_GENERATE(AtomicCacheAlignedOptionalMutableRawPointer, atomic_uintptr_t, void*, _Nullable, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_POINTER_GENERATE(AtomicCacheAlignedRawPointer, atomic_uintptr_t, const void*, _Nonnull, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_POINTER_GENERATE(AtomicCacheAlignedOptionalRawPointer, atomic_uintptr_t, const void*, _Nullable, __CACHE_LINE_WIDTH)
#endif

struct opaque;
Expand Down Expand Up @@ -394,7 +394,7 @@ CLANG_ATOMICS_POINTER_GENERATE(AtomicOptionalOpaquePointer, atomic_uintptr_t, st
CLANG_ATOMICS_TAGGED_POINTER_INCREMENT(swiftType, pointerType, nullability)

#define CLANG_ATOMICS_ATOMIC_TAGGED_POINTER_GENERATE(atomicType, structType, alignment) \
CLANG_ATOMICS_STRUCT(atomicType, _Atomic(__UNION_TYPE), alignment) \
CLANG_ATOMICS_STRUCT(atomicType, _Atomic(__UNION_TYPE), a, alignment) \
CLANG_ATOMICS_IS_LOCK_FREE(atomicType) \
CLANG_ATOMICS_TAGGED_POINTER_INITIALIZE(atomicType, structType) \
CLANG_ATOMICS_TAGGED_POINTER_LOAD(atomicType, structType) \
Expand All @@ -404,19 +404,31 @@ CLANG_ATOMICS_POINTER_GENERATE(AtomicOptionalOpaquePointer, atomic_uintptr_t, st

CLANG_ATOMICS_TAGGED_POINTER_GENERATE(TaggedRawPointer, const void*, _Nonnull)
CLANG_ATOMICS_ATOMIC_TAGGED_POINTER_GENERATE(AtomicTaggedRawPointer, TaggedRawPointer, _Alignof(_Atomic(__UNION_TYPE)))
CLANG_ATOMICS_ATOMIC_TAGGED_POINTER_GENERATE(AtomicCacheLineAlignedTaggedRawPointer, TaggedRawPointer, __CACHE_LINE_WIDTH)

CLANG_ATOMICS_TAGGED_POINTER_GENERATE(TaggedOptionalRawPointer, const void*, _Nullable)
CLANG_ATOMICS_ATOMIC_TAGGED_POINTER_GENERATE(AtomicTaggedOptionalRawPointer, TaggedOptionalRawPointer, _Alignof(_Atomic(__UNION_TYPE)))
CLANG_ATOMICS_ATOMIC_TAGGED_POINTER_GENERATE(AtomicCacheLineAlignedTaggedOptionalRawPointer, TaggedOptionalRawPointer, __CACHE_LINE_WIDTH)

CLANG_ATOMICS_TAGGED_POINTER_GENERATE(TaggedMutableRawPointer, void*, _Nonnull)
CLANG_ATOMICS_ATOMIC_TAGGED_POINTER_GENERATE(AtomicTaggedMutableRawPointer, TaggedMutableRawPointer, _Alignof(_Atomic(__UNION_TYPE)))
CLANG_ATOMICS_ATOMIC_TAGGED_POINTER_GENERATE(AtomicCacheLineAlignedTaggedMutableRawPointer, TaggedMutableRawPointer, __CACHE_LINE_WIDTH)

CLANG_ATOMICS_TAGGED_POINTER_GENERATE(TaggedOptionalMutableRawPointer, void*, _Nullable)
CLANG_ATOMICS_ATOMIC_TAGGED_POINTER_GENERATE(AtomicTaggedOptionalMutableRawPointer, TaggedOptionalMutableRawPointer, _Alignof(_Atomic(__UNION_TYPE)))
CLANG_ATOMICS_ATOMIC_TAGGED_POINTER_GENERATE(AtomicCacheLineAlignedTaggedOptionalMutableRawPointer, TaggedOptionalMutableRawPointer, __CACHE_LINE_WIDTH)

#ifdef __CACHE_LINE_WIDTH
CLANG_ATOMICS_ATOMIC_TAGGED_POINTER_GENERATE(AtomicCacheAlignedTaggedRawPointer, TaggedRawPointer, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_ATOMIC_TAGGED_POINTER_GENERATE(AtomicCacheAlignedTaggedOptionalRawPointer, TaggedOptionalRawPointer, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_ATOMIC_TAGGED_POINTER_GENERATE(AtomicCacheAlignedTaggedMutableRawPointer, TaggedMutableRawPointer, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_ATOMIC_TAGGED_POINTER_GENERATE(AtomicCacheAlignedTaggedOptionalMutableRawPointer, TaggedOptionalMutableRawPointer, __CACHE_LINE_WIDTH)
#endif

// non-atomic padded pointer wrappers

#ifdef __CACHE_LINE_WIDTH
CLANG_ATOMICS_STRUCT(CacheAlignedRawPointer, const void *_Nonnull, pointer, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_STRUCT(CacheAlignedOptionalRawPointer, const void *_Nullable, pointer, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_STRUCT(CacheAlignedMutableRawPointer, void *_Nonnull, pointer, __CACHE_LINE_WIDTH)
CLANG_ATOMICS_STRUCT(CacheAlignedOptionalMutableRawPointer, void *_Nullable, pointer, __CACHE_LINE_WIDTH)
#endif

// fence

Expand All @@ -431,7 +443,7 @@ void CAtomicsThreadFence(enum MemoryOrder order)
#define __OPAQUE_UNMANAGED_LOCKED (uintptr_t)0x7
#define __OPAQUE_UNMANAGED_SPINMASK (char)0xc0

CLANG_ATOMICS_STRUCT(OpaqueUnmanagedHelper, atomic_uintptr_t, _Alignof(atomic_uintptr_t))
CLANG_ATOMICS_STRUCT(OpaqueUnmanagedHelper, atomic_uintptr_t, a, _Alignof(atomic_uintptr_t))
CLANG_ATOMICS_IS_LOCK_FREE(OpaqueUnmanagedHelper)
CLANG_ATOMICS_POINTER_INITIALIZE(OpaqueUnmanagedHelper, const void*, _Nullable)

Expand Down
68 changes: 52 additions & 16 deletions Tests/CAtomicsTests/CAtomicsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -789,14 +789,14 @@ extension CAtomicsBasicTests
XCTAssertEqual(r3, p.load(.relaxed))
}

public func testAtomicCacheLineAlignedMutableRawPointer()
public func testAtomicCacheAlignedMutableRawPointer()
{
let r0 = UnsafeMutableRawPointer(bitPattern: UInt.randomPositive())!
let r1 = UnsafeMutableRawPointer(bitPattern: UInt.randomPositive())!
let r2 = UnsafeMutableRawPointer(bitPattern: UInt.randomPositive())!
let r3 = UnsafeMutableRawPointer(bitPattern: UInt.randomPositive())!

var p = AtomicCacheLineAlignedMutableRawPointer(r3)
var p = AtomicCacheAlignedMutableRawPointer(r3)
XCTAssertEqual(r3, p.load(.relaxed))
XCTAssert(p.isLockFree())

Expand All @@ -822,14 +822,14 @@ extension CAtomicsBasicTests
XCTAssertEqual(r3, p.load(.relaxed))
}

public func testAtomicCacheLineAlignedOptionalMutableRawPointer()
public func testAtomicCacheAlignedOptionalMutableRawPointer()
{
let r0 = UnsafeMutableRawPointer(bitPattern: UInt.randomPositive())
let r1 = UnsafeMutableRawPointer(bitPattern: UInt.randomPositive())
let r2 = UnsafeMutableRawPointer(bitPattern: UInt.randomPositive())
let r3 = UnsafeMutableRawPointer(bitPattern: UInt.randomPositive())

var p = AtomicCacheLineAlignedOptionalMutableRawPointer(r3)
var p = AtomicCacheAlignedOptionalMutableRawPointer(r3)
XCTAssertEqual(r3, p.load(.relaxed))
XCTAssert(p.isLockFree())

Expand All @@ -855,14 +855,14 @@ extension CAtomicsBasicTests
XCTAssertEqual(r3, p.load(.relaxed))
}

public func testAtomicCacheLineAlignedRawPointer()
public func testAtomicCacheAlignedRawPointer()
{
let r0 = UnsafeRawPointer(bitPattern: UInt.randomPositive())!
let r1 = UnsafeRawPointer(bitPattern: UInt.randomPositive())!
let r2 = UnsafeRawPointer(bitPattern: UInt.randomPositive())!
let r3 = UnsafeRawPointer(bitPattern: UInt.randomPositive())!

var p = AtomicCacheLineAlignedRawPointer(r3)
var p = AtomicCacheAlignedRawPointer(r3)
XCTAssertEqual(r3, p.load(.relaxed))
XCTAssert(p.isLockFree())

Expand All @@ -888,14 +888,14 @@ extension CAtomicsBasicTests
XCTAssertEqual(r3, p.load(.relaxed))
}

public func testAtomicCacheLineAlignedOptionalRawPointer()
public func testAtomicCacheAlignedOptionalRawPointer()
{
let r0 = UnsafeRawPointer(bitPattern: UInt.randomPositive())
let r1 = UnsafeRawPointer(bitPattern: UInt.randomPositive())
let r2 = UnsafeRawPointer(bitPattern: UInt.randomPositive())
let r3 = UnsafeRawPointer(bitPattern: UInt.randomPositive())

var p = AtomicCacheLineAlignedOptionalRawPointer(r3)
var p = AtomicCacheAlignedOptionalRawPointer(r3)
XCTAssertEqual(r3, p.load(.relaxed))
XCTAssert(p.isLockFree())

Expand Down Expand Up @@ -1095,14 +1095,14 @@ extension CAtomicsBasicTests
XCTAssertEqual(r3, p.load(.relaxed))
}

public func testAtomicCacheLineAlignedTaggedRawPointer()
public func testAtomicCacheAlignedTaggedRawPointer()
{
let r0 = TaggedRawPointer(UnsafeRawPointer(bitPattern: UInt.randomPositive())!, tag: 0)
let r1 = TaggedRawPointer(UnsafeRawPointer(bitPattern: UInt.randomPositive())!, tag: 1)
let r2 = TaggedRawPointer(UnsafeRawPointer(bitPattern: UInt.randomPositive())!, tag: 2)
let r3 = r2.incremented()

var p = AtomicCacheLineAlignedTaggedRawPointer(r3)
var p = AtomicCacheAlignedTaggedRawPointer(r3)
XCTAssertEqual(r3, p.load(.relaxed))
XCTAssert(p.isLockFree())

Expand Down Expand Up @@ -1192,14 +1192,14 @@ extension CAtomicsBasicTests
XCTAssertEqual(r3, p.load(.relaxed))
}

public func testAtomicCacheLineAlignedTaggedMutableRawPointer()
public func testAtomicCacheAlignedTaggedMutableRawPointer()
{
let r0 = TaggedMutableRawPointer(UnsafeMutableRawPointer(bitPattern: UInt.randomPositive())!, tag: 0)
let r1 = TaggedMutableRawPointer(UnsafeMutableRawPointer(bitPattern: UInt.randomPositive())!, tag: 1)
let r2 = TaggedMutableRawPointer(UnsafeMutableRawPointer(bitPattern: UInt.randomPositive())!, tag: 2)
let r3 = r2.incremented()

var p = AtomicCacheLineAlignedTaggedMutableRawPointer(r3)
var p = AtomicCacheAlignedTaggedMutableRawPointer(r3)
XCTAssertEqual(r3, p.load(.relaxed))
XCTAssert(p.isLockFree())

Expand Down Expand Up @@ -1289,14 +1289,14 @@ extension CAtomicsBasicTests
XCTAssertEqual(r3, p.load(.relaxed))
}

public func testAtomicCacheLineAlignedTaggedOptionalRawPointer()
public func testAtomicCacheAlignedTaggedOptionalRawPointer()
{
let r0 = TaggedOptionalRawPointer(UnsafeRawPointer(bitPattern: UInt.randomPositive()), tag: 0)
let r1 = TaggedOptionalRawPointer(UnsafeRawPointer(bitPattern: UInt.randomPositive()), tag: 1)
let r2 = TaggedOptionalRawPointer(UnsafeRawPointer(bitPattern: UInt.randomPositive()), tag: 2)
let r3 = r2.incremented()

var p = AtomicCacheLineAlignedTaggedOptionalRawPointer(r3)
var p = AtomicCacheAlignedTaggedOptionalRawPointer(r3)
XCTAssertEqual(r3, p.load(.relaxed))
XCTAssert(p.isLockFree())

Expand Down Expand Up @@ -1386,14 +1386,14 @@ extension CAtomicsBasicTests
XCTAssertEqual(r3, p.load(.relaxed))
}

public func testAtomicCacheLineAlignedTaggedOptionalMutableRawPointer()
public func testAtomicCacheAlignedTaggedOptionalMutableRawPointer()
{
let r0 = TaggedOptionalMutableRawPointer(UnsafeMutableRawPointer(bitPattern: UInt.randomPositive()), tag: 0)
let r1 = TaggedOptionalMutableRawPointer(UnsafeMutableRawPointer(bitPattern: UInt.randomPositive()), tag: 1)
let r2 = TaggedOptionalMutableRawPointer(UnsafeMutableRawPointer(bitPattern: UInt.randomPositive()), tag: 2)
let r3 = r2.incremented()

var p = AtomicCacheLineAlignedTaggedOptionalMutableRawPointer(r3)
var p = AtomicCacheAlignedTaggedOptionalMutableRawPointer(r3)
XCTAssertEqual(r3, p.load(.relaxed))
XCTAssert(p.isLockFree())

Expand All @@ -1419,4 +1419,40 @@ extension CAtomicsBasicTests
XCTAssertEqual(r3, p.load(.relaxed))
}

public func testCacheAlignedPointers()
{
var p: UnsafeMutableRawPointer?

p = UnsafeMutableRawPointer(bitPattern: UInt.randomPositive())
let c1 = CacheAlignedOptionalRawPointer(pointer: p)
XCTAssert(MemoryLayout.size(ofValue: c1) > MemoryLayout.size(ofValue: c1.pointer))
XCTAssert(MemoryLayout.alignment(ofValue: c1) > MemoryLayout.alignment(ofValue: c1.pointer))
XCTAssert(MemoryLayout.stride(ofValue: c1) > MemoryLayout.stride(ofValue: c1.pointer))
if let p1 = c1.pointer
{
let c2 = CacheAlignedRawPointer(pointer: p1)
XCTAssert(MemoryLayout.size(ofValue: c2) > MemoryLayout.size(ofValue: c2.pointer))
XCTAssert(MemoryLayout.alignment(ofValue: c2) > MemoryLayout.alignment(ofValue: c2.pointer))
XCTAssert(MemoryLayout.stride(ofValue: c2) > MemoryLayout.stride(ofValue: c2.pointer))
let p2 = c2.pointer
XCTAssert(p1 == p2)
XCTAssert(Int(bitPattern: p2) == Int(bitPattern: p))
}

p = UnsafeMutableRawPointer(bitPattern: UInt.randomPositive())
let m1 = CacheAlignedOptionalMutableRawPointer(pointer: p)
XCTAssert(MemoryLayout.size(ofValue: m1) > MemoryLayout.size(ofValue: m1.pointer))
XCTAssert(MemoryLayout.alignment(ofValue: m1) > MemoryLayout.alignment(ofValue: m1.pointer))
XCTAssert(MemoryLayout.stride(ofValue: m1) > MemoryLayout.stride(ofValue: m1.pointer))
if let p1 = m1.pointer
{
let m2 = CacheAlignedMutableRawPointer(pointer: p1)
XCTAssert(MemoryLayout.size(ofValue: m2) > MemoryLayout.size(ofValue: m2.pointer))
XCTAssert(MemoryLayout.alignment(ofValue: m2) > MemoryLayout.alignment(ofValue: m2.pointer))
XCTAssert(MemoryLayout.stride(ofValue: m2) > MemoryLayout.stride(ofValue: m2.pointer))
let p2 = m2.pointer
XCTAssert(p1 == p2)
XCTAssert(Int(bitPattern: p2) == Int(bitPattern: p))
}
}
}
27 changes: 25 additions & 2 deletions Tests/CAtomicsTests/CAtomicsTests.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public class CAtomicsBasicTests: XCTestCase
}
}

% pointers = ['AtomicOptionalRawPointer', 'AtomicNonNullRawPointer', 'AtomicNonNullMutableRawPointer', 'AtomicOptionalMutableRawPointer', 'AtomicCacheLineAlignedMutableRawPointer', 'AtomicCacheLineAlignedOptionalMutableRawPointer', 'AtomicCacheLineAlignedRawPointer', 'AtomicCacheLineAlignedOptionalRawPointer', 'AtomicNonNullOpaquePointer', 'AtomicOptionalOpaquePointer']
% pointers = ['AtomicOptionalRawPointer', 'AtomicNonNullRawPointer', 'AtomicNonNullMutableRawPointer', 'AtomicOptionalMutableRawPointer', 'AtomicCacheAlignedMutableRawPointer', 'AtomicCacheAlignedOptionalMutableRawPointer', 'AtomicCacheAlignedRawPointer', 'AtomicCacheAlignedOptionalRawPointer', 'AtomicNonNullOpaquePointer', 'AtomicOptionalOpaquePointer']
extension CAtomicsBasicTests
{
% for type in pointers:
Expand Down Expand Up @@ -245,7 +245,7 @@ extension CAtomicsBasicTests
XCTAssertEqual(r3, r4)
}

% for aligned in ['', 'CacheLineAligned']:
% for aligned in ['', 'CacheAligned']:
% atomicType = 'Atomic' + aligned + taggedType
public func test${atomicType}()
{
Expand Down Expand Up @@ -284,4 +284,27 @@ extension CAtomicsBasicTests
% end
% end
% end
public func testCacheAlignedPointers()
{
var p: UnsafeMutableRawPointer?
% for mutable in ['', 'Mutable']:
% variable = 'm' if mutable is 'Mutable' else 'c'

p = UnsafeMutableRawPointer(bitPattern: UInt.randomPositive())
let ${variable}1 = CacheAlignedOptional${mutable}RawPointer(pointer: p)
XCTAssert(MemoryLayout.size(ofValue: ${variable}1) > MemoryLayout.size(ofValue: ${variable}1.pointer))
XCTAssert(MemoryLayout.alignment(ofValue: ${variable}1) > MemoryLayout.alignment(ofValue: ${variable}1.pointer))
XCTAssert(MemoryLayout.stride(ofValue: ${variable}1) > MemoryLayout.stride(ofValue: ${variable}1.pointer))
if let p1 = ${variable}1.pointer
{
let ${variable}2 = CacheAligned${mutable}RawPointer(pointer: p1)
XCTAssert(MemoryLayout.size(ofValue: ${variable}2) > MemoryLayout.size(ofValue: ${variable}2.pointer))
XCTAssert(MemoryLayout.alignment(ofValue: ${variable}2) > MemoryLayout.alignment(ofValue: ${variable}2.pointer))
XCTAssert(MemoryLayout.stride(ofValue: ${variable}2) > MemoryLayout.stride(ofValue: ${variable}2.pointer))
let p2 = ${variable}2.pointer
XCTAssert(p1 == p2)
XCTAssert(Int(bitPattern: p2) == Int(bitPattern: p))
}
% end
}
}
17 changes: 9 additions & 8 deletions Tests/CAtomicsTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import XCTest

extension CAtomicsBasicTests {
static let __allTests = [
("testAtomicCacheLineAlignedMutableRawPointer", testAtomicCacheLineAlignedMutableRawPointer),
("testAtomicCacheLineAlignedOptionalMutableRawPointer", testAtomicCacheLineAlignedOptionalMutableRawPointer),
("testAtomicCacheLineAlignedOptionalRawPointer", testAtomicCacheLineAlignedOptionalRawPointer),
("testAtomicCacheLineAlignedRawPointer", testAtomicCacheLineAlignedRawPointer),
("testAtomicCacheLineAlignedTaggedMutableRawPointer", testAtomicCacheLineAlignedTaggedMutableRawPointer),
("testAtomicCacheLineAlignedTaggedOptionalMutableRawPointer", testAtomicCacheLineAlignedTaggedOptionalMutableRawPointer),
("testAtomicCacheLineAlignedTaggedOptionalRawPointer", testAtomicCacheLineAlignedTaggedOptionalRawPointer),
("testAtomicCacheLineAlignedTaggedRawPointer", testAtomicCacheLineAlignedTaggedRawPointer),
("testAtomicCacheAlignedMutableRawPointer", testAtomicCacheAlignedMutableRawPointer),
("testAtomicCacheAlignedOptionalMutableRawPointer", testAtomicCacheAlignedOptionalMutableRawPointer),
("testAtomicCacheAlignedOptionalRawPointer", testAtomicCacheAlignedOptionalRawPointer),
("testAtomicCacheAlignedRawPointer", testAtomicCacheAlignedRawPointer),
("testAtomicCacheAlignedTaggedMutableRawPointer", testAtomicCacheAlignedTaggedMutableRawPointer),
("testAtomicCacheAlignedTaggedOptionalMutableRawPointer", testAtomicCacheAlignedTaggedOptionalMutableRawPointer),
("testAtomicCacheAlignedTaggedOptionalRawPointer", testAtomicCacheAlignedTaggedOptionalRawPointer),
("testAtomicCacheAlignedTaggedRawPointer", testAtomicCacheAlignedTaggedRawPointer),
("testAtomicNonNullMutableRawPointer", testAtomicNonNullMutableRawPointer),
("testAtomicNonNullOpaquePointer", testAtomicNonNullOpaquePointer),
("testAtomicNonNullRawPointer", testAtomicNonNullRawPointer),
Expand All @@ -21,6 +21,7 @@ extension CAtomicsBasicTests {
("testAtomicTaggedOptionalRawPointer", testAtomicTaggedOptionalRawPointer),
("testAtomicTaggedRawPointer", testAtomicTaggedRawPointer),
("testBool", testBool),
("testCacheAlignedPointers", testCacheAlignedPointers),
("testFence", testFence),
("testInt", testInt),
("testInt16", testInt16),
Expand Down

0 comments on commit b2c3c71

Please sign in to comment.