mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
stdlib/String: fix a race in _StringBuffer.grow()
rdar://17855614 Swift SVN r20960
This commit is contained in:
40
stdlib/unittest/SwiftBlockToCFunctionThunks.cpp
Normal file
40
stdlib/unittest/SwiftBlockToCFunctionThunks.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
//===--- ObjCBlockToFunctionAdapter.cpp -----------------------------------===//
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
///
|
||||
/// \file This file implements C thunks that call ObjC blocks. These thunks
|
||||
/// can be used to implement block-based wrappers for APIs that accept a function
|
||||
/// pointer and a context pointer.
|
||||
///
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
extern "C" void *swift_stdlib_getTypeMetadata(void *, void *T) {
|
||||
return T;
|
||||
}
|
||||
|
||||
extern "C" void *swift_stdlib_executeSwiftClosure(
|
||||
void *Context, const void *ParamMetadata, const void *ResultMetadata);
|
||||
|
||||
template <typename Result, typename Param>
|
||||
using FunctionPointerType = Result (*)(Param);
|
||||
|
||||
static void *executeBlock_VoidPtr_VoidPtr(void *Context) {
|
||||
const void **MetadataPointers = reinterpret_cast<const void **>(Context);
|
||||
return swift_stdlib_executeSwiftClosure(Context, MetadataPointers[0],
|
||||
MetadataPointers[1]);
|
||||
}
|
||||
|
||||
/// Returns a thunk for a 'void *(*)(void *context)' C function.
|
||||
extern "C" FunctionPointerType<void *, void *>
|
||||
swift_stdlib_getExecuteBlockFunctionPtr_VoidPtr_VoidPtr() {
|
||||
return &executeBlock_VoidPtr_VoidPtr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user