diff options
author | Edward O'Callaghan <eocallaghan@auroraux.org> | 2009-09-12 15:47:39 +0000 |
---|---|---|
committer | Edward O'Callaghan <eocallaghan@auroraux.org> | 2009-09-12 15:47:39 +0000 |
commit | 09870645031d5a05c7c3b9a66a53348a0d82ae52 (patch) | |
tree | 7beefb79a8ff14bd0f7e58b0b75d8c8db0e7ddd6 | |
parent | e80e978d6aa211056beddf4582390e374d1935ab (diff) |
Generalize Blocks code and intergrate with cmake build system more.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@81613 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | BlocksRuntime/Block.h | 15 | ||||
-rw-r--r-- | BlocksRuntime/Block_private.h | 27 | ||||
-rw-r--r-- | ConfigureChecks.cmake | 2 | ||||
-rw-r--r-- | test/CMakeLists.txt | 1 |
4 files changed, 29 insertions, 16 deletions
diff --git a/BlocksRuntime/Block.h b/BlocksRuntime/Block.h index 406e2b3df..477040c75 100644 --- a/BlocksRuntime/Block.h +++ b/BlocksRuntime/Block.h @@ -33,26 +33,31 @@ # endif #endif +#include <config.h> + +#if defined( HAVE_AVAILABILITY_MACROS_H ) && defined( HAVE_TARGET_CONDITIONALS_H ) #include <AvailabilityMacros.h> #include <TargetConditionals.h> +#endif /* HAVE_AVAILABILITY_MACROS_H and HAVE_TARGET_CONDITIONALS_H. */ #if __cplusplus extern "C" { #endif -// Create a heap based copy of a Block or simply add a reference to an existing one. -// This must be paired with Block_release to recover memory, even when running -// under Objective-C Garbage Collection. +/* Create a heap based copy of a Block or simply add a reference to an existing one. + * This must be paired with Block_release to recover memory, even when running + * under Objective-C Garbage Collection. + */ BLOCK_EXPORT void *_Block_copy(const void *aBlock); -// Lose the reference, and if heap based and last reference, recover the memory +/* Lose the reference, and if heap based and last reference, recover the memory. */ BLOCK_EXPORT void _Block_release(const void *aBlock); #if __cplusplus } #endif -// Type correct macros +/* Type correct macros. */ #define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__))) #define Block_release(...) _Block_release((const void *)(__VA_ARGS__)) diff --git a/BlocksRuntime/Block_private.h b/BlocksRuntime/Block_private.h index 620184679..e5ea8c004 100644 --- a/BlocksRuntime/Block_private.h +++ b/BlocksRuntime/Block_private.h @@ -33,8 +33,12 @@ # endif #endif +#include <config.h> + +#if defined( HAVE_AVAILABILITY_MACROS_H ) && defined( HAVE_TARGET_CONDITIONALS_H ) #include <AvailabilityMacros.h> #include <TargetConditionals.h> +#endif /* HAVE_AVAILABILITY_MACROS_H and HAVE_TARGET_CONDITIONALS_H. */ #include <stdbool.h> @@ -43,18 +47,18 @@ extern "C" { #endif - enum { BLOCK_REFCOUNT_MASK = (0xffff), BLOCK_NEEDS_FREE = (1 << 24), BLOCK_HAS_COPY_DISPOSE = (1 << 25), - BLOCK_HAS_CTOR = (1 << 26), /* helpers have C++ code */ + BLOCK_HAS_CTOR = (1 << 26), /* Helpers have C++ code. */ BLOCK_IS_GC = (1 << 27), BLOCK_IS_GLOBAL = (1 << 28), - BLOCK_HAS_DESCRIPTOR = (1 << 29), + BLOCK_HAS_DESCRIPTOR = (1 << 29) }; -/* revised new layout */ + +/* Revised new layout. */ struct Block_descriptor { unsigned long int reserved; unsigned long int size; @@ -62,17 +66,17 @@ struct Block_descriptor { void (*dispose)(void *); }; + struct Block_layout { void *isa; int flags; int reserved; void (*invoke)(void *, ...); struct Block_descriptor *descriptor; - /* imported variables */ + /* Imported variables. */ }; - struct Block_byref { void *isa; struct Block_byref *forwarding; @@ -83,6 +87,7 @@ struct Block_byref { /* long shared[0]; */ }; + struct Block_byref_header { void *isa; struct Block_byref *forwarding; @@ -91,15 +96,15 @@ struct Block_byref_header { }; -/* Runtime support functions used by compiler when generating copy/dispose helpers */ +/* Runtime support functions used by compiler when generating copy/dispose helpers. */ enum { - /* see function implementation for a more complete description of these fields and combinations */ + /* See function implementation for a more complete description of these fields and combinations */ BLOCK_FIELD_IS_OBJECT = 3, /* id, NSObject, __attribute__((NSObject)), block, ... */ BLOCK_FIELD_IS_BLOCK = 7, /* a block variable */ BLOCK_FIELD_IS_BYREF = 8, /* the on stack structure holding the __block variable */ BLOCK_FIELD_IS_WEAK = 16, /* declared __weak, only used in byref copy helpers */ - BLOCK_BYREF_CALLER = 128, /* called from __block (byref) copy/dispose support routines. */ + BLOCK_BYREF_CALLER = 128 /* called from __block (byref) copy/dispose support routines. */ }; /* Runtime entry point called by compiler when assigning objects inside copy helper routines */ @@ -114,7 +119,7 @@ BLOCK_EXPORT void _Block_object_dispose(const void *object, const int flags); /* Other support functions */ -/* runtime entry to get total size of a closure */ +/* Runtime entry to get total size of a closure */ BLOCK_EXPORT unsigned long int Block_size(void *block_basic); @@ -158,7 +163,7 @@ BLOCK_EXPORT const char *_Block_dump(const void *block); struct Block_basic { void *isa; int Block_flags; /* int32_t */ - int Block_size; /* XXX should be packed into Block_flags */ + int Block_size; /* XXX should be packed into Block_flags */ void (*Block_invoke)(void *); void (*Block_copy)(void *dst, void *src); /* iff BLOCK_HAS_COPY_DISPOSE */ void (*Block_dispose)(void *); /* iff BLOCK_HAS_COPY_DISPOSE */ diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 8b027bc38..0516d7fc2 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -9,6 +9,8 @@ SET( SOURCEDIR ${CMAKE_SOURCE_DIR} ) # HEADER FILES CHECK_INCLUDE_FILE( sys/byteorder.h HAVE_SYS_BYTEORDER_H ) +CHECK_INCLUDE_FILE( AvailabilityMacros.h HAVE_AVAILABILITY_MACROS_H ) +CHECK_INCLUDE_FILE( TargetConditionals.h HAVE_TARGET_CONDITIONALS_H ) # FUNCTIONS CHECK_FUNCTION_EXISTS( sysconf HAVE_SYSCONF ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a7f31949e..325ed1a38 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,6 +8,7 @@ TARGET_LINK_LIBRARIES( ${CompilerRT_LIBRARY} ) SET( TEST_TARGET_LIBRARIES ${CompilerRT_LIBRARY}-Common ) +INCLUDE( MacroAddCheckTest ) # create tests # MACRO_ADD_CHECK_TEST( foo foo.c ${TEST_TARGET_LIBRARIES} ) |