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" llvm-svn: 82504
This commit is contained in:
parent
8c500100f6
commit
33f6acbbf1
@ -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 @@ BLOCK_EXPORT void *_Block_copy(const void *aBlock);
|
||||
/* 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
|
||||
|
||||
|
||||
@ -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 @@ struct Block_basic {
|
||||
};
|
||||
|
||||
|
||||
#if __cplusplus
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
#endif /* _BLOCK_PRIVATE_H_ */
|
||||
|
||||
@ -6,3 +6,8 @@ SET( SRCS
|
||||
)
|
||||
|
||||
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 )
|
||||
|
||||
@ -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 @@ static __inline bool OSAtomicCompareAndSwapInt(int oldi, int newi, int volatile
|
||||
* 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 @@ static __inline bool OSAtomicCompareAndSwapInt(int oldi, int newi, int volatile
|
||||
{
|
||||
return __sync_bool_compare_and_swap(dst, oldi, newi);
|
||||
}
|
||||
#else
|
||||
#error unknown atomic compare-and-swap primitive
|
||||
#endif
|
||||
|
||||
|
||||
@ -143,7 +157,7 @@ static int latching_decr_int(int *where) {
|
||||
/***********************
|
||||
GC support stub routines
|
||||
************************/
|
||||
#if !TARGET_OS_WIN32
|
||||
#if 0
|
||||
#pragma mark GC Support Routines
|
||||
#endif
|
||||
|
||||
@ -171,11 +185,7 @@ static void _Block_release_object_default(const void *ptr) {
|
||||
}
|
||||
|
||||
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 @@ void _Block_use_RR( void (*retain)(const void *),
|
||||
Internal Support routines for copying
|
||||
********************************************************************************/
|
||||
|
||||
#if !TARGET_OS_WIN32
|
||||
#if 0
|
||||
#pragma mark Copy/Release support
|
||||
#endif
|
||||
|
||||
@ -429,7 +439,7 @@ static void _Block_byref_release(const void *arg) {
|
||||
*
|
||||
***********************************************************/
|
||||
|
||||
#if !TARGET_OS_WIN32
|
||||
#if 0
|
||||
#pragma mark SPI/API
|
||||
#endif
|
||||
|
||||
@ -460,7 +470,7 @@ void _Block_release(void *arg) {
|
||||
;
|
||||
}
|
||||
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 @@ unsigned long int Block_size(void *arg) {
|
||||
}
|
||||
|
||||
|
||||
#if !TARGET_OS_WIN32
|
||||
#if 0
|
||||
#pragma mark Compiler SPI entry points
|
||||
#endif
|
||||
|
||||
@ -595,7 +605,7 @@ void _Block_object_dispose(const void *object, const int flags) {
|
||||
/*******************
|
||||
Debugging support
|
||||
********************/
|
||||
#if !TARGET_OS_WIN32
|
||||
#if 0
|
||||
#pragma mark Debugging
|
||||
#endif
|
||||
|
||||
@ -612,7 +622,7 @@ const char *_Block_dump(const void *block) {
|
||||
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 @@ const char *_Block_dump(const void *block) {
|
||||
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 @@ const char *_Block_dump(const void *block) {
|
||||
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_dump(const void *block) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -26,13 +26,6 @@ INCLUDE_DIRECTORIES(
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
install(DIRECTORY include
|
||||
DESTINATION .
|
||||
PATTERN ".svn" EXCLUDE
|
||||
PATTERN "*.cmake" EXCLUDE
|
||||
PATTERN "*.in" EXCLUDE
|
||||
)
|
||||
|
||||
SET( Achitectures
|
||||
i386 x86_64 ppc arm
|
||||
)
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
INCLUDE( CheckIncludeFile )
|
||||
INCLUDE( CheckFunctionExists )
|
||||
INCLUDE( CheckSymbolExists )
|
||||
INCLUDE( CheckCSourceCompiles )
|
||||
|
||||
SET( PACKAGE ${PACKAGE_NAME} )
|
||||
SET( VERSION ${PACKAGE_VERSION} )
|
||||
@ -11,6 +13,26 @@ SET( SOURCEDIR ${CMAKE_SOURCE_DIR} )
|
||||
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 )
|
||||
|
||||
@ -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}
|
||||
|
||||
@ -143,5 +143,8 @@ NOT_HERE_BEFORE_10_6(__gcc_qsub)
|
||||
NOT_HERE_BEFORE_10_6(__trampoline_setup)
|
||||
#endif /* __ppc__ */
|
||||
|
||||
#else /* !__APPLE__ */
|
||||
|
||||
#endif /* __APPLE__*/
|
||||
extern int avoid_empty_file;
|
||||
|
||||
#endif /* !__APPLE__*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user