[llvm-commits] [compiler-rt] r82504 - in /compiler-rt/trunk: BlocksRuntime/Block.h BlocksRuntime/Block_private.h BlocksRuntime/CMakeLists.txt BlocksRuntime/runtime.c CMakeLists.txt ConfigureChecks.cmake config.h.cmake lib/apple_versioning.c

Shantonu Sen ssen at apple.com
Mon Sep 21 17:49:12 PDT 2009


Author: ssen
Date: Mon Sep 21 19:49:12 2009
New Revision: 82504

URL: http://llvm.org/viewvc/llvm-project?rev=82504&view=rev
Log:
1) Remove cmake-specific #define usage from the exported
Block.h/Block_private.h headers, since clients won't know what to
set. These are moved into runtime.c as appropriate

2) Use cmake checks for CAS builtins, instead of guessing based on GCC
#defines (which aren't set by clang and llvm-gcc anyway)

3) "#pragma mark" isn't supported by FSF gcc, so "#if 0" it out. It
should still show up in IDEs that support it

4) Fix some compiler warnings. GCC 4.3.3 seems super strict about
%p. function pointers can't be cast to void * either.

5) Avoid a warning for apple_versioning.c that "ISO C does not allow
empty files"


Modified:
    compiler-rt/trunk/BlocksRuntime/Block.h
    compiler-rt/trunk/BlocksRuntime/Block_private.h
    compiler-rt/trunk/BlocksRuntime/CMakeLists.txt
    compiler-rt/trunk/BlocksRuntime/runtime.c
    compiler-rt/trunk/CMakeLists.txt
    compiler-rt/trunk/ConfigureChecks.cmake
    compiler-rt/trunk/config.h.cmake
    compiler-rt/trunk/lib/apple_versioning.c

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

==============================================================================
--- compiler-rt/trunk/BlocksRuntime/Block.h (original)
+++ compiler-rt/trunk/BlocksRuntime/Block.h Mon Sep 21 19:49:12 2009
@@ -22,8 +22,8 @@
  *
  */
 
-#ifndef _Block_H_
-#define _Block_H_
+#ifndef _BLOCK_H_
+#define _BLOCK_H_
 
 #if !defined(BLOCK_EXPORT)
 #   if defined(__cplusplus)
@@ -33,14 +33,7 @@
 #   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
+#if defined(__cplusplus)
 extern "C" {
 #endif
 
@@ -53,7 +46,7 @@
 /* Lose the reference, and if heap based and last reference, recover the memory. */
 BLOCK_EXPORT void _Block_release(const void *aBlock);
 
-#if __cplusplus
+#if defined(__cplusplus)
 }
 #endif
 

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

==============================================================================
--- compiler-rt/trunk/BlocksRuntime/Block_private.h (original)
+++ compiler-rt/trunk/BlocksRuntime/Block_private.h Mon Sep 21 19:49:12 2009
@@ -33,16 +33,9 @@
 #   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>
 
-#if __cplusplus
+#if defined(__cplusplus)
 extern "C" {
 #endif
 
@@ -171,9 +164,9 @@
 };
 
 
-#if __cplusplus
+#if defined(__cplusplus)
 }
 #endif
 
 
-#endif
+#endif /* _BLOCK_PRIVATE_H_ */

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

==============================================================================
--- compiler-rt/trunk/BlocksRuntime/CMakeLists.txt (original)
+++ compiler-rt/trunk/BlocksRuntime/CMakeLists.txt Mon Sep 21 19:49:12 2009
@@ -6,3 +6,8 @@
  )
 
 ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SRCS})
+SET_TARGET_PROPERTIES( ${PROJECT_NAME} PROPERTIES
+  INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib )
+
+INSTALL( TARGETS ${PROJECT_NAME} DESTINATION lib )
+INSTALL( FILES Block.h Block_private.h DESTINATION include )

Modified: compiler-rt/trunk/BlocksRuntime/runtime.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/BlocksRuntime/runtime.c?rev=82504&r1=82503&r2=82504&view=diff

==============================================================================
--- compiler-rt/trunk/BlocksRuntime/runtime.c (original)
+++ compiler-rt/trunk/BlocksRuntime/runtime.c Mon Sep 21 19:49:12 2009
@@ -27,10 +27,23 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdint.h>
+#include <stdbool.h>
 
-#if TARGET_OS_MAC
+#include "config.h"
+
+#ifdef HAVE_AVAILABILITY_MACROS_H
+#include <AvailabilityMacros.h>
+#endif
+
+#ifdef HAVE_TARGET_CONDITIONALS_H
+#include <TargetConditionals.h>
+#endif
+
+#if defined(HAVE_OSATOMIC_COMPARE_AND_SWAP_INT) && defined(HAVE_OSATOMIC_COMPARE_AND_SWAP_LONG)
+#ifdef HAVE_LIBKERN_OSATOMIC_H
 #include <libkern/OSAtomic.h>
-#elif TARGET_OS_WIN32
+#endif
+#elif defined(__WIN32__)
 #define _CRT_SECURE_NO_WARNINGS 1
 #include <windows.h>
 static __inline bool OSAtomicCompareAndSwapLong(long oldl, long newl, long volatile *dst)
@@ -50,8 +63,7 @@
  * a 64-bit system, make sure we have an 8-byte atomic function
  * available.
  */
-#elif __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 && \
-      ((__SIZEOF_LONG__ != 8) || __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)
+#elif defined(HAVE_SYNC_BOOL_COMPARE_AND_SWAP_INT) && defined(HAVE_SYNC_BOOL_COMPARE_AND_SWAP_LONG)
 static __inline bool OSAtomicCompareAndSwapLong(long oldl, long newl, long volatile *dst)
 {
   return __sync_bool_compare_and_swap(dst, oldl, newl);
@@ -61,6 +73,8 @@
 {
   return __sync_bool_compare_and_swap(dst, oldi, newi);
 }
+#else
+#error unknown atomic compare-and-swap primitive
 #endif
 
 
@@ -143,7 +157,7 @@
 /***********************
 GC support stub routines
 ************************/
-#if !TARGET_OS_WIN32
+#if 0
 #pragma mark GC Support Routines
 #endif
 
@@ -171,11 +185,7 @@
 }
 
 static void _Block_assign_weak_default(const void *ptr, void *dest) {
-#if !TARGET_OS_WIN32
-    *(long *)dest = (long)ptr;
-#else
     *(void **)dest = (void *)ptr;
-#endif
 }
 
 static void _Block_memmove_default(void *dst, void *src, unsigned long size) {
@@ -260,7 +270,7 @@
 Internal Support routines for copying
 ********************************************************************************/
 
-#if !TARGET_OS_WIN32
+#if 0
 #pragma mark Copy/Release support
 #endif
 
@@ -429,7 +439,7 @@
  *
  ***********************************************************/
 
-#if !TARGET_OS_WIN32
+#if 0
 #pragma mark SPI/API
 #endif
 
@@ -460,7 +470,7 @@
         ;
     }
     else {
-        printf("Block_release called upon a stack Block: %p, ignored\n", aBlock);
+        printf("Block_release called upon a stack Block: %p, ignored\n", (void *)aBlock);
     }
 }
 
@@ -498,7 +508,7 @@
 }
 
 
-#if !TARGET_OS_WIN32
+#if 0
 #pragma mark Compiler SPI entry points
 #endif
 
@@ -595,7 +605,7 @@
 /*******************
 Debugging support
 ********************/
-#if !TARGET_OS_WIN32
+#if 0
 #pragma mark Debugging
 #endif
 
@@ -612,7 +622,7 @@
         printf("Block compiled by obsolete compiler, please recompile source for this Block\n");
         exit(1);
     }
-    cp += sprintf(cp, "^%p (new layout) =\n", closure);
+    cp += sprintf(cp, "^%p (new layout) =\n", (void *)closure);
     if (closure->isa == NULL) {
         cp += sprintf(cp, "isa: NULL\n");
     }
@@ -632,7 +642,7 @@
         cp += sprintf(cp, "isa: finalizing Block\n");
     }
     else {
-        cp += sprintf(cp, "isa?: %p\n", closure->isa);
+        cp += sprintf(cp, "isa?: %p\n", (void *)closure->isa);
     }
     cp += sprintf(cp, "flags:");
     if (closure->flags & BLOCK_HAS_DESCRIPTOR) {
@@ -651,16 +661,16 @@
         cp += sprintf(cp, " HASCTOR");
     }
     cp += sprintf(cp, "\nrefcount: %u\n", closure->flags & BLOCK_REFCOUNT_MASK);
-    cp += sprintf(cp, "invoke: %p\n", closure->invoke);
+    cp += sprintf(cp, "invoke: %#lx\n", (uintptr_t)closure->invoke);
     {
         struct Block_descriptor *dp = closure->descriptor;
-        cp += sprintf(cp, "descriptor: %p\n", dp);
+        cp += sprintf(cp, "descriptor: %p\n", (void *)dp);
         cp += sprintf(cp, "descriptor->reserved: %lu\n", dp->reserved);
         cp += sprintf(cp, "descriptor->size: %lu\n", dp->size);
 
         if (closure->flags & BLOCK_HAS_COPY_DISPOSE) {
-            cp += sprintf(cp, "descriptor->copy helper: %p\n", dp->copy);
-            cp += sprintf(cp, "descriptor->dispose helper: %p\n", dp->dispose);
+            cp += sprintf(cp, "descriptor->copy helper: %#lx\n", (uintptr_t)dp->copy);
+            cp += sprintf(cp, "descriptor->dispose helper: %#lx\n", (uintptr_t)dp->dispose);
         }
     }
     return buffer;
@@ -670,13 +680,13 @@
 const char *_Block_byref_dump(struct Block_byref *src) {
     static char buffer[256];
     char *cp = buffer;
-    cp += sprintf(cp, "byref data block %p contents:\n", src);
-    cp += sprintf(cp, "  forwarding: %p\n", src->forwarding);
+    cp += sprintf(cp, "byref data block %p contents:\n", (void *)src);
+    cp += sprintf(cp, "  forwarding: %p\n", (void *)src->forwarding);
     cp += sprintf(cp, "  flags: 0x%x\n", src->flags);
     cp += sprintf(cp, "  size: %d\n", src->size);
     if (src->flags & BLOCK_HAS_COPY_DISPOSE) {
-        cp += sprintf(cp, "  copy helper: %p\n", src->byref_keep);
-        cp += sprintf(cp, "  dispose helper: %p\n", src->byref_destroy);
+        cp += sprintf(cp, "  copy helper: %#lx\n", (uintptr_t)src->byref_keep);
+        cp += sprintf(cp, "  dispose helper: %#lx\n", (uintptr_t)src->byref_destroy);
     }
     return buffer;
 }

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

==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Mon Sep 21 19:49:12 2009
@@ -26,13 +26,6 @@
  ${CMAKE_CURRENT_BINARY_DIR}
 )
 
-install(DIRECTORY include
-  DESTINATION .
-  PATTERN ".svn" EXCLUDE
-  PATTERN "*.cmake" EXCLUDE
-  PATTERN "*.in" EXCLUDE
-  )
-
 SET( Achitectures
  i386 x86_64 ppc arm
  )

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

==============================================================================
--- compiler-rt/trunk/ConfigureChecks.cmake (original)
+++ compiler-rt/trunk/ConfigureChecks.cmake Mon Sep 21 19:49:12 2009
@@ -1,5 +1,7 @@
 INCLUDE( CheckIncludeFile )
 INCLUDE( CheckFunctionExists )
+INCLUDE( CheckSymbolExists )
+INCLUDE( CheckCSourceCompiles )
 
 SET( PACKAGE ${PACKAGE_NAME} )
 SET( VERSION ${PACKAGE_VERSION} )
@@ -11,6 +13,26 @@
 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 )
+CHECK_INCLUDE_FILE( libkern/OSAtomic.h HAVE_LIBKERN_OSATOMIC_H )
 
 # FUNCTIONS
 CHECK_FUNCTION_EXISTS( sysconf HAVE_SYSCONF )
+CHECK_SYMBOL_EXISTS( OSAtomicCompareAndSwapInt libkern/OSAtomic.h HAVE_OSATOMIC_COMPARE_AND_SWAP_INT )
+CHECK_SYMBOL_EXISTS( OSAtomicCompareAndSwapLong libkern/OSAtomic.h HAVE_OSATOMIC_COMPARE_AND_SWAP_LONG )
+
+# BUILTIN
+CHECK_C_SOURCE_COMPILES( "
+volatile int a;
+int main(int argc, char *argv[]) {
+  (void)__sync_bool_compare_and_swap(&a, 1, 2);
+  return 0;
+}
+" HAVE_SYNC_BOOL_COMPARE_AND_SWAP_INT )
+
+CHECK_C_SOURCE_COMPILES( "
+volatile long a;
+int main(int argc, char *argv[]) {
+  (void)__sync_bool_compare_and_swap(&a, 1, 2);
+  return 0;
+}
+" HAVE_SYNC_BOOL_COMPARE_AND_SWAP_LONG )

Modified: compiler-rt/trunk/config.h.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/config.h.cmake?rev=82504&r1=82503&r2=82504&view=diff

==============================================================================
--- compiler-rt/trunk/config.h.cmake (original)
+++ compiler-rt/trunk/config.h.cmake Mon Sep 21 19:49:12 2009
@@ -1,2 +1,12 @@
 #cmakedefine HAVE_SYS_BYTEORDER_H ${HAVE_SYS_BYTEORDER}
-#cmakedefine __Apple__ ${CMAKE_HOST_APPLE}
+#cmakedefine HAVE_AVAILABILITY_MACROS_H ${HAVE_AVAILABILITY_MACROS_H}
+#cmakedefine HAVE_TARGET_CONDITIONALS_H ${HAVE_TARGET_CONDITIONALS_H}
+#cmakedefine HAVE_LIBKERN_OSATOMIC_H ${HAVE_LIBKERN_OSATOMIC_H}
+
+#cmakedefine HAVE_SYSCONF ${HAVE_SYSCONF}
+
+#cmakedefine HAVE_OSATOMIC_COMPARE_AND_SWAP_INT ${HAVE_OSATOMIC_COMPARE_AND_SWAP_INT}
+#cmakedefine HAVE_OSATOMIC_COMPARE_AND_SWAP_LONG ${HAVE_OSATOMIC_COMPARE_AND_SWAP_LONG}
+
+#cmakedefine HAVE_SYNC_BOOL_COMPARE_AND_SWAP_INT ${HAVE_SYNC_BOOL_COMPARE_AND_SWAP_INT}
+#cmakedefine HAVE_SYNC_BOOL_COMPARE_AND_SWAP_LONG ${HAVE_SYNC_BOOL_COMPARE_AND_SWAP_LONG}

Modified: compiler-rt/trunk/lib/apple_versioning.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/apple_versioning.c?rev=82504&r1=82503&r2=82504&view=diff

==============================================================================
--- compiler-rt/trunk/lib/apple_versioning.c (original)
+++ compiler-rt/trunk/lib/apple_versioning.c Mon Sep 21 19:49:12 2009
@@ -143,5 +143,8 @@
 NOT_HERE_BEFORE_10_6(__trampoline_setup)
 #endif /* __ppc__ */
 
+#else /* !__APPLE__ */
 
-#endif /* __APPLE__*/
+extern int avoid_empty_file;
+
+#endif /* !__APPLE__*/





More information about the llvm-commits mailing list