Files
tomer doron faa9f17905 expose the underlying lifecycle for composition reasons (#70)
motivation: application frameworks thae use ServiceLifecycle may need to expose their underlying  lifecycle so they can be also composed into larger systems

changes:
* expose ServiceLifecycle::underlying
* make sure backtrace installer is only called once per process
* add swift-atomics dependency (>=5.2 and above)
* add atomic helper (<5.2)
2021-03-13 11:20:42 -08:00

30 lines
1.0 KiB
C

//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftServiceLifecycle open source project
//
// Copyright (c) 2021 Apple Inc. and the SwiftServiceLifecycle project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftServiceLifecycle project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#include <CLifecycleAtomics.h>
#include <stdlib.h>
#include <stdatomic.h>
struct c_lifecycle_atomic_bool *c_lifecycle_atomic_bool_create(bool value) {
struct c_lifecycle_atomic_bool *wrapper = malloc(sizeof(*wrapper));
atomic_init(&wrapper->value, value);
return wrapper;
}
bool c_lifecycle_atomic_bool_compare_and_exchange(struct c_lifecycle_atomic_bool *wrapper, bool expected, bool desired) {
bool expected_copy = expected;
return atomic_compare_exchange_strong(&wrapper->value, &expected_copy, desired);
}