[llvm-commits] [compiler-rt] r81613 - in /compiler-rt/trunk: BlocksRuntime/Block.h BlocksRuntime/Block_private.h ConfigureChecks.cmake test/CMakeLists.txt

Edward O'Callaghan eocallaghan at auroraux.org
Sat Sep 12 08:47:39 PDT 2009


Author: evocallaghan
Date: Sat Sep 12 10:47:39 2009
New Revision: 81613

URL: http://llvm.org/viewvc/llvm-project?rev=81613&view=rev
Log:
Generalize Blocks code and intergrate with cmake build system more.

Modified:
    compiler-rt/trunk/BlocksRuntime/Block.h
    compiler-rt/trunk/BlocksRuntime/Block_private.h
    compiler-rt/trunk/ConfigureChecks.cmake
    compiler-rt/trunk/test/CMakeLists.txt

Modified: compiler-rt/trunk/BlocksRuntime/Block.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/BlocksRuntime/Block.h?rev=81613&r1=81612&r2=81613&view=diff

==============================================================================
--- compiler-rt/trunk/BlocksRuntime/Block.h (original)
+++ compiler-rt/trunk/BlocksRuntime/Block.h Sat Sep 12 10:47:39 2009
@@ -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__))

Modified: compiler-rt/trunk/BlocksRuntime/Block_private.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/BlocksRuntime/Block_private.h?rev=81613&r1=81612&r2=81613&view=diff

==============================================================================
--- compiler-rt/trunk/BlocksRuntime/Block_private.h (original)
+++ compiler-rt/trunk/BlocksRuntime/Block_private.h Sat Sep 12 10:47:39 2009
@@ -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 @@
 #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 @@
     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 @@
     /* long shared[0]; */
 };
 
+
 struct Block_byref_header {
     void *isa;
     struct Block_byref *forwarding;
@@ -91,15 +96,15 @@
 };
 
 
-/* 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 @@
 
 /* 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 @@
 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 */

Modified: compiler-rt/trunk/ConfigureChecks.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/ConfigureChecks.cmake?rev=81613&r1=81612&r2=81613&view=diff

==============================================================================
--- compiler-rt/trunk/ConfigureChecks.cmake (original)
+++ compiler-rt/trunk/ConfigureChecks.cmake Sat Sep 12 10:47:39 2009
@@ -9,6 +9,8 @@
 
 # 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 )

Modified: compiler-rt/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/CMakeLists.txt?rev=81613&r1=81612&r2=81613&view=diff

==============================================================================
--- compiler-rt/trunk/test/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/CMakeLists.txt Sat Sep 12 10:47:39 2009
@@ -8,6 +8,7 @@
 
 SET( TEST_TARGET_LIBRARIES ${CompilerRT_LIBRARY}-Common )
 
+INCLUDE( MacroAddCheckTest )
 # create tests
 # MACRO_ADD_CHECK_TEST( foo foo.c ${TEST_TARGET_LIBRARIES} )
 





More information about the llvm-commits mailing list