]> git.saurik.com Git - apple/objc4.git/blame - runtime/objc-auto.mm
objc4-818.2.tar.gz
[apple/objc4.git] / runtime / objc-auto.mm
CommitLineData
2bfd4448 1/*
b3962a83 2 * Copyright (c) 2004-2007 Apple Inc. All rights reserved.
2bfd4448
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
2bfd4448
A
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
2bfd4448 23
66799735 24#define OBJC_DECLARE_SYMBOLS 1
7257e56c 25#include "objc-private.h"
66799735 26#include "objc-auto.h"
7257e56c 27
c1e772c4 28// GC is no longer supported.
7af964d1 29
c1e772c4 30#if OBJC_NO_GC_API
31875a97
A
31
32// No GC and no GC symbols needed. We're done here.
c1e772c4
A
33# if SUPPORT_GC_COMPAT
34# error inconsistent config settings
35# endif
31875a97 36
c1e772c4 37#else
31875a97
A
38
39// No GC but we do need to export GC symbols.
31875a97 40
c1e772c4
A
41# if !SUPPORT_GC_COMPAT
42# error inconsistent config settings
43# endif
44
66799735
A
45void objc_collect(unsigned long options __unused) { }
46BOOL objc_collectingEnabled(void) { return NO; }
47void objc_setCollectionThreshold(size_t threshold __unused) { }
48void objc_setCollectionRatio(size_t ratio __unused) { }
49void objc_startCollectorThread(void) { }
31875a97
A
50
51#if TARGET_OS_WIN32
66799735 52BOOL objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation)
31875a97
A
53 { void *original = InterlockedCompareExchangePointer((void * volatile *)objectLocation, (void *)replacement, (void *)predicate); return (original == predicate); }
54
66799735 55BOOL objc_atomicCompareAndSwapPtrBarrier(id predicate, id replacement, volatile id *objectLocation)
31875a97
A
56 { void *original = InterlockedCompareExchangePointer((void * volatile *)objectLocation, (void *)replacement, (void *)predicate); return (original == predicate); }
57#else
66799735 58BOOL objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation)
31875a97
A
59 { return OSAtomicCompareAndSwapPtr((void *)predicate, (void *)replacement, (void * volatile *)objectLocation); }
60
66799735 61BOOL objc_atomicCompareAndSwapPtrBarrier(id predicate, id replacement, volatile id *objectLocation)
31875a97
A
62 { return OSAtomicCompareAndSwapPtrBarrier((void *)predicate, (void *)replacement, (void * volatile *)objectLocation); }
63#endif
64
66799735 65BOOL objc_atomicCompareAndSwapGlobal(id predicate, id replacement, volatile id *objectLocation)
31875a97
A
66 { return objc_atomicCompareAndSwapPtr(predicate, replacement, objectLocation); }
67
66799735 68BOOL objc_atomicCompareAndSwapGlobalBarrier(id predicate, id replacement, volatile id *objectLocation)
31875a97
A
69 { return objc_atomicCompareAndSwapPtrBarrier(predicate, replacement, objectLocation); }
70
66799735 71BOOL objc_atomicCompareAndSwapInstanceVariable(id predicate, id replacement, volatile id *objectLocation)
31875a97
A
72 { return objc_atomicCompareAndSwapPtr(predicate, replacement, objectLocation); }
73
66799735 74BOOL objc_atomicCompareAndSwapInstanceVariableBarrier(id predicate, id replacement, volatile id *objectLocation)
31875a97
A
75 { return objc_atomicCompareAndSwapPtrBarrier(predicate, replacement, objectLocation); }
76
66799735 77id objc_assign_strongCast(id val, id *dest)
31875a97
A
78 { return (*dest = val); }
79
66799735 80id objc_assign_global(id val, id *dest)
31875a97
A
81 { return (*dest = val); }
82
66799735 83id objc_assign_threadlocal(id val, id *dest)
31875a97
A
84 { return (*dest = val); }
85
66799735 86id objc_assign_ivar(id val, id dest, ptrdiff_t offset)
31875a97
A
87 { return (*(id*)((char *)dest+offset) = val); }
88
66799735 89id objc_read_weak(id *location)
31875a97
A
90 { return *location; }
91
66799735 92id objc_assign_weak(id value, id *location)
31875a97
A
93 { return (*location = value); }
94
66799735 95void *objc_memmove_collectable(void *dst, const void *src, size_t size)
31875a97
A
96 { return memmove(dst, src, size); }
97
66799735
A
98void objc_finalizeOnMainThread(Class cls __unused) { }
99BOOL objc_is_finalized(void *ptr __unused) { return NO; }
100void objc_clear_stack(unsigned long options __unused) { }
31875a97 101
66799735
A
102BOOL objc_collecting_enabled(void) { return NO; }
103void objc_set_collection_threshold(size_t threshold __unused) { }
104void objc_set_collection_ratio(size_t ratio __unused) { }
105void objc_start_collector_thread(void) { }
31875a97 106
66799735 107id objc_allocate_object(Class cls, int extra)
31875a97
A
108 { return class_createInstance(cls, extra); }
109
66799735
A
110void objc_registerThreadWithCollector() { }
111void objc_unregisterThreadWithCollector() { }
112void objc_assertRegisteredThreadWithCollector() { }
31875a97 113
66799735
A
114malloc_zone_t* objc_collect_init(int(*callback)() __unused) { return nil; }
115malloc_zone_t* objc_collectableZone() { return nil; }
31875a97 116
66799735
A
117BOOL objc_isAuto(id object __unused) { return NO; }
118BOOL objc_dumpHeap(char *filename __unused, unsigned long length __unused)
31875a97
A
119 { return NO; }
120
c1e772c4 121// not OBJC_NO_GC_API
7af964d1 122#endif