CoreFoundation_Prefix.h [plain text]
#define _DARWIN_UNLIMITED_SELECT 1
#include <CoreFoundation/CFBase.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#if DEPLOYMENT_TARGET_WINDOWS && defined(__cplusplus)
extern "C" {
#endif
#define SystemIntegrityCheck(A, B) do {} while (0)
#if INCLUDE_OBJC
#include <objc/objc.h>
#else
typedef signed char BOOL;
typedef char * id;
typedef char * Class;
#define YES (BOOL)1
#define NO (BOOL)0
#define nil NULL
#endif
#define CRSetCrashLogMessage(A) do {} while (0)
#define CRSetCrashLogMessage2(A) do {} while (0)
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI
#import <libkern/OSAtomic.h>
#import <pthread.h>
#endif
#define DISPATCH_HELPER_FUNCTIONS(PREFIX, QNAME) \
static Boolean __ ## PREFIX ## SyncDispatchIsSafe(dispatch_queue_t Q) { \
dispatch_queue_t C = dispatch_get_current_queue(); \
return (!C || Q != C) ? true : false; \
} \
\
static dispatch_queue_t __ ## PREFIX ## Queue(void) { \
static volatile dispatch_queue_t __ ## PREFIX ## dq = NULL; \
if (!__ ## PREFIX ## dq) { \
dispatch_queue_t dq = dispatch_queue_create(# QNAME, NULL); \
void * volatile *loc = (void * volatile *)&__ ## PREFIX ## dq; \
if (!OSAtomicCompareAndSwapPtrBarrier(NULL, dq, loc)) { \
dispatch_release(dq); \
} \
} \
return __ ## PREFIX ## dq; \
} \
#define LIBAUTO_STUB 1
#ifndef LIBAUTO_STUB
#if DEPLOYMENT_TARGET_MACOSX
#include <auto_zone.h>
#endif
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED
#include <objc/objc-auto.h>
#endif
#endif // LIBAUTO_STUB
#if DEPLOYMENT_TARGET_WINDOWS
#if defined(__x86_64__)
typedef unsigned int boolean_t;
#else
typedef int boolean_t;
#endif
#endif
#if DEPLOYMENT_TARGET_LINUX
#define __private_extern__
#define __strong
#define __weak
#define strtod_l(a,b,locale) strtod(a,b)
#define strtoul_l(a,b,c,locale) strtoul(a,b,c)
#define strtol_l(a,b,c,locale) strtol(a,b,c)
#define strtoll_l(a,b,c,locale) strtoll(a,b,c)
#define strncasecmp_l(a, b, c, d) strncasecmp(a, b, c)
#define fprintf_l(a,locale,b,...) fprintf(a, b, __VA_ARGS__)
#define strlcat(a,b,c) strncat(a,b,c)
#define strlcpy(a,b,c) strncpy(a,b,c)
#define issetugid() 0
bool OSAtomicCompareAndSwapPtr(void *oldp, void *newp, void *volatile *dst);
bool OSAtomicCompareAndSwapLong(long oldl, long newl, long volatile *dst);
bool OSAtomicCompareAndSwapPtrBarrier(void *oldp, void *newp, void *volatile *dst);
int32_t OSAtomicDecrement32Barrier(volatile int32_t *dst);
int32_t OSAtomicIncrement32Barrier(volatile int32_t *dst);
int32_t OSAtomicIncrement32(volatile int32_t *theValue);
int32_t OSAtomicDecrement32(volatile int32_t *theValue);
int32_t OSAtomicAdd32( int32_t theAmount, volatile int32_t *theValue );
int32_t OSAtomicAdd32Barrier( int32_t theAmount, volatile int32_t *theValue );
bool OSAtomicCompareAndSwap32Barrier( int32_t oldValue, int32_t newValue, volatile int32_t *theValue );
void OSMemoryBarrier();
#include <malloc.h>
CF_INLINE size_t malloc_size(void *memblock) {
return malloc_usable_size(memblock);
}
#endif
#if DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
#if !defined(MIN)
#define MIN(A,B) ((A) < (B) ? (A) : (B))
#endif
#if !defined(MAX)
#define MAX(A,B) ((A) > (B) ? (A) : (B))
#endif
#if !defined(ABS)
#define ABS(A) ((A) < 0 ? (-(A)) : (A))
#endif
#endif
#if DEPLOYMENT_TARGET_WINDOWS
#define MAXPATHLEN MAX_PATH
#undef MAX_PATH
#undef INVALID_HANDLE_VALUE
#define ino_t _ino_t
#define off_t _off_t
#define mode_t uint16_t
#define __private_extern__ extern
#define __builtin_expect(P1,P2) P1
CF_EXPORT int _NS_stat(const char *name, struct _stat *st);
CF_EXPORT int _NS_mkdir(const char *name);
CF_EXPORT int _NS_rmdir(const char *name);
CF_EXPORT int _NS_chmod(const char *name, int mode);
CF_EXPORT int _NS_unlink(const char *name);
CF_EXPORT char *_NS_getcwd(char *dstbuf, size_t size); CF_EXPORT char *_NS_getenv(const char *name);
CF_EXPORT int _NS_rename(const char *oldName, const char *newName);
CF_EXPORT int _NS_open(const char *name, int oflag, int pmode = 0);
CF_EXPORT int _NS_chdir(const char *name);
CF_EXPORT int _NS_mkstemp(char *name, int bufSize);
CF_EXPORT int _NS_access(const char *name, int amode);
#define BOOL WINDOWS_BOOL
#define WIN32_LEAN_AND_MEAN
#ifndef WINVER
#define WINVER 0x0501
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501
#endif
#define FD_SETSIZE 1024
#include <winsock2.h>
#include <windows.h>
#include <pthread.h>
#undef BOOL
#ifndef HAVE_STRUCT_TIMESPEC
#define HAVE_STRUCT_TIMESPEC 1
struct timespec {
long tv_sec;
long tv_nsec;
};
#endif
#define __PRETTY_FUNCTION__ __FUNCTION__
#define malloc_default_zone() (void *)0
#define malloc_zone_from_ptr(a) (void *)0
#define malloc_zone_malloc(zone,size) malloc(size)
#define malloc_zone_memalign(zone,align,size) malloc(size)
#define malloc_zone_calloc(zone,count,size) calloc(count,size)
#define bcopy(b1,b2,len) memmove(b2, b1, (size_t)(len))
typedef int malloc_zone_t;
typedef int uid_t;
typedef int gid_t;
#define geteuid() 0
#define getuid() 0
#define getegid() 0
#define fsync(a) _commit(a)
#define malloc_create_zone(a,b) 123
#define malloc_set_zone_name(zone,name)
#define malloc_zone_realloc(zone,ptr,size) realloc(ptr,size)
#define malloc_zone_free(zone,ptr) free(ptr)
#define OSSpinLockLock(A) __CFSpinLock(A)
#define OSSpinLockUnlock(A) __CFSpinUnlock(A)
typedef int32_t OSSpinLock;
#define OS_SPINLOCK_INIT 0
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <malloc.h>
CF_INLINE size_t malloc_size(void *memblock) {
return _msize(memblock);
}
CF_INLINE uint64_t mach_absolute_time() {
LARGE_INTEGER count;
QueryPerformanceCounter(&count);
return (uint64_t)count.QuadPart;
}
CF_INLINE long long llabs(long long v) {
if (v < 0) return -v;
return v;
}
#define strtod_l(a,b,locale) strtod(a,b)
#define strtoul_l(a,b,c,locale) strtoul(a,b,c)
#define strtol_l(a,b,c,locale) strtol(a,b,c)
#define strtoll_l(a,b,c,locale) _strtoi64(a,b,c)
#define strncasecmp_l(a, b, c, d) _strnicmp(a, b, c)
#define snprintf _snprintf
#define fprintf_l(a,locale,b,...) fprintf(a, b, __VA_ARGS__)
#define strlcat(a,b,c) strncat(a,b,c)
#define strlcpy(a,b,c) strncpy(a,b,c)
#define sleep(x) Sleep(1000*x)
#define issetugid() 0
CF_EXPORT bool OSAtomicCompareAndSwapPtr(void *oldp, void *newp, void *volatile *dst);
CF_EXPORT bool OSAtomicCompareAndSwapLong(long oldl, long newl, long volatile *dst);
CF_EXPORT bool OSAtomicCompareAndSwapPtrBarrier(void *oldp, void *newp, void *volatile *dst);
CF_EXPORT int32_t OSAtomicDecrement32Barrier(volatile int32_t *dst);
CF_EXPORT int32_t OSAtomicIncrement32Barrier(volatile int32_t *dst);
CF_EXPORT int32_t OSAtomicIncrement32(volatile int32_t *theValue);
CF_EXPORT int32_t OSAtomicDecrement32(volatile int32_t *theValue);
CF_EXPORT int32_t OSAtomicAdd32( int32_t theAmount, volatile int32_t *theValue );
CF_EXPORT int32_t OSAtomicAdd32Barrier( int32_t theAmount, volatile int32_t *theValue );
CF_EXPORT bool OSAtomicCompareAndSwap32Barrier( int32_t oldValue, int32_t newValue, volatile int32_t *theValue );
#include <io.h>
#include <fcntl.h>
#include <errno.h>
#endif
#if DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_WINDOWS
#include <stdarg.h>
CF_INLINE int flsl( long mask ) {
int idx = 0;
while (mask != 0) mask = (unsigned long)mask >> 1, idx++;
return idx;
}
CF_INLINE int popcountll(long long x) {
int count = 0;
while (x) {
count++;
x &= x - 1; }
return count;
}
__private_extern__ int asprintf(char **ret, const char *format, ...);
#endif
#ifdef LIBAUTO_STUB
#include <stddef.h>
enum {OBJC_GENERATIONAL = (1 << 0)};
enum {
OBJC_RATIO_COLLECTION = (0 << 0),
OBJC_GENERATIONAL_COLLECTION = (1 << 0),
OBJC_FULL_COLLECTION = (2 << 0),
OBJC_EXHAUSTIVE_COLLECTION = (3 << 0),
OBJC_COLLECT_IF_NEEDED = (1 << 3),
OBJC_WAIT_UNTIL_DONE = (1 << 4),
};
enum {
AUTO_TYPE_UNKNOWN = -1,
AUTO_UNSCANNED = (1 << 0),
AUTO_OBJECT = (1 << 1),
AUTO_POINTERS_ONLY = (1 << 2),
AUTO_MEMORY_SCANNED = !AUTO_UNSCANNED,
AUTO_MEMORY_UNSCANNED = AUTO_UNSCANNED,
AUTO_MEMORY_ALL_POINTERS = AUTO_POINTERS_ONLY,
AUTO_MEMORY_ALL_WEAK_POINTERS = (AUTO_UNSCANNED | AUTO_POINTERS_ONLY),
AUTO_OBJECT_SCANNED = AUTO_OBJECT,
AUTO_OBJECT_UNSCANNED = AUTO_OBJECT | AUTO_UNSCANNED,
AUTO_OBJECT_ALL_POINTERS = AUTO_OBJECT | AUTO_POINTERS_ONLY
};
typedef unsigned long auto_memory_type_t;
typedef struct _auto_zone_t auto_zone_t;
typedef struct auto_weak_callback_block {
struct auto_weak_callback_block *next;
void (*callback_function)(void *arg1, void *arg2);
void *arg1;
void *arg2;
} auto_weak_callback_block_t;
CF_INLINE void *objc_memmove_collectable(void *a, const void *b, size_t c) { return memmove(a, b, c); }
CF_INLINE void *objc_collectableZone(void) { return 0; }
CF_INLINE void *auto_zone_allocate_object(void *zone, size_t size, auto_memory_type_t type, int rc, int clear) { return 0; }
CF_INLINE const void *auto_zone_base_pointer(void *zone, const void *ptr) { return 0; }
CF_INLINE void auto_zone_set_scan_exactly(void *zone, void *ptr) {}
CF_INLINE void auto_zone_retain(void *zone, void *ptr) {}
CF_INLINE unsigned int auto_zone_release(void *zone, void *ptr) { return 0; }
CF_INLINE unsigned int auto_zone_retain_count(void *zone, const void *ptr) { return 0; }
CF_INLINE void auto_zone_set_unscanned(void *zone, void *ptr) {}
CF_INLINE void auto_zone_set_nofinalize(void *zone, void *ptr) {}
CF_INLINE int auto_zone_is_finalized(void *zone, const void *ptr) { return 0; }
CF_INLINE size_t auto_zone_size(void *zone, const void *ptr) { return 0; }
CF_INLINE void auto_register_weak_reference(void *zone, const void *referent, void **referrer, uintptr_t *counter, void **listHead, void **listElement) {}
CF_INLINE void auto_unregister_weak_reference(void *zone, const void *referent, void **referrer) {}
CF_INLINE int auto_zone_is_valid_pointer(void *zone, const void *ptr) { return 0; }
CF_INLINE BOOL objc_isAuto(id object) { return 0; }
CF_INLINE void* auto_read_weak_reference(void *zone, void **referrer) { void *result = *referrer; return result; }
CF_INLINE void auto_assign_weak_reference(void *zone, const void *value, const void **location, auto_weak_callback_block_t *block) { *location = (void *)value; }
CF_INLINE auto_memory_type_t auto_zone_get_layout_type(void *zone, void *ptr) { return AUTO_UNSCANNED; }
CF_INLINE int auto_zone_set_write_barrier(void *zone, const void *dest, const void *new_value) { return false; }
CF_INLINE void objc_assertRegisteredThreadWithCollector(void) {}
CF_INLINE void objc_registerThreadWithCollector(void) {}
CF_INLINE uintptr_t _object_getExternalHash(id obj) {
return (uintptr_t)obj;
}
CF_INLINE BOOL objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation)
{ return OSAtomicCompareAndSwapPtr((void *)predicate, (void *)replacement, (void * volatile *)objectLocation); }
CF_INLINE BOOL objc_atomicCompareAndSwapPtrBarrier(id predicate, id replacement, volatile id *objectLocation)
{ return OSAtomicCompareAndSwapPtrBarrier((void *)predicate, (void *)replacement, (void * volatile *)objectLocation); }
CF_INLINE BOOL objc_atomicCompareAndSwapGlobal(id predicate, id replacement, volatile id *objectLocation)
{ return OSAtomicCompareAndSwapPtr((void *)predicate, (void *)replacement, (void * volatile *)objectLocation); }
CF_INLINE BOOL objc_atomicCompareAndSwapGlobalBarrier(id predicate, id replacement, volatile id *objectLocation)
{ return OSAtomicCompareAndSwapPtrBarrier((void *)predicate, (void *)replacement, (void * volatile *)objectLocation); }
CF_INLINE BOOL objc_atomicCompareAndSwapInstanceVariable(id predicate, id replacement, volatile id *objectLocation)
{ return OSAtomicCompareAndSwapPtr((void *)predicate, (void *)replacement, (void * volatile *)objectLocation); }
CF_INLINE BOOL objc_atomicCompareAndSwapInstanceVariableBarrier(id predicate, id replacement, volatile id *objectLocation)
{ return OSAtomicCompareAndSwapPtrBarrier((void *)predicate, (void *)replacement, (void * volatile *)objectLocation); }
CF_INLINE id objc_assign_strongCast(id val, id *dest)
{ return (*dest = val); }
CF_INLINE id objc_assign_global(id val, id *dest)
{ return (*dest = val); }
CF_INLINE id objc_assign_ivar(id val, id dest, ptrdiff_t offset)
{ return (*(id*)((char *)dest+offset) = val); }
CF_INLINE id objc_read_weak(id *location)
{ return *location; }
CF_INLINE id objc_assign_weak(id value, id *location)
{ return (*location = value); }
CF_INLINE void objc_finalizeOnMainThread(Class cls) { }
CF_INLINE BOOL objc_is_finalized(void *ptr) { return NO; }
CF_INLINE void objc_clear_stack(unsigned long options) { }
CF_INLINE BOOL objc_collectingEnabled(void) { return NO; }
CF_INLINE void objc_start_collector_thread(void) { }
CF_INLINE void objc_collect(unsigned long options) { }
#endif
#if DEPLOYMENT_TARGET_WINDOWS && defined(__cplusplus)
} #endif