Path: blob/main/contrib/llvm-project/compiler-rt/lib/BlocksRuntime/Block.h
35259 views
/*1* Block.h2*3* Copyright 2008-2010 Apple, Inc. Permission is hereby granted, free of charge,4* to any person obtaining a copy of this software and associated documentation5* files (the "Software"), to deal in the Software without restriction,6* including without limitation the rights to use, copy, modify, merge, publish,7* distribute, sublicense, and/or sell copies of the Software, and to permit8* persons to whom the Software is furnished to do so, subject to the following9* conditions:10*11* The above copyright notice and this permission notice shall be included in12* all copies or substantial portions of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE17* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*22*/2324#ifndef _BLOCK_H_25#define _BLOCK_H_2627#if !defined(BLOCK_EXPORT)28# if defined(__cplusplus)29# define BLOCK_EXPORT extern "C"30# else31# define BLOCK_EXPORT extern32# endif33#endif3435#if defined(__cplusplus)36extern "C" {37#endif3839/* Create a heap based copy of a Block or simply add a reference to an existing one.40* This must be paired with Block_release to recover memory, even when running41* under Objective-C Garbage Collection.42*/43BLOCK_EXPORT void *_Block_copy(const void *aBlock);4445/* Lose the reference, and if heap based and last reference, recover the memory. */46BLOCK_EXPORT void _Block_release(const void *aBlock);4748#if defined(__cplusplus)49}50#endif5152/* Type correct macros. */5354#define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__)))55#define Block_release(...) _Block_release((const void *)(__VA_ARGS__))565758#endif596061