]> git.ipfire.org Git - thirdparty/gcc.git/blob - libobjc/objc/runtime.h
7b16f1b09eac08c1ce9a19c37870ce394132addf
[thirdparty/gcc.git] / libobjc / objc / runtime.h
1 /* GNU Objective-C Runtime API.
2 Copyright (C) 2010 Free Software Foundation, Inc.
3 Contributed by Nicola Pero <nicola.pero@meta-innovation.com>
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3, or (at your option) any
10 later version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License for more details.
16
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
20
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
25
26 #ifndef __objc_runtime_INCLUDE_GNU
27 #define __objc_runtime_INCLUDE_GNU
28
29 #include "objc.h"
30
31 /* The following is temporary, until all code from objc-api.h has been
32 moved into this file and objc-api.h will include runtime.h. */
33 #include "objc-api.h"
34
35 /* 'objc_enumerationMutation()' is called when a collection is
36 mutated while being "fast enumerated". That is a hard error, and
37 objc_enumerationMutation is called to deal with it. 'collection'
38 is the collection object that was mutated during an enumeration.
39
40 objc_enumerationMutation() will invoke the mutation handler if any
41 is set. Then, it will abort the program.
42
43 Compatibility note: the Apple runtime will not abort the program
44 after calling the mutation handler.
45 */
46 objc_EXPORT void objc_enumerationMutation (id collection);
47
48 /* 'objc_set_enumeration_mutation_handler' can be used to set a
49 function that will be called (instead of aborting) when a fast
50 enumeration is mutated during enumeration. The handler will be
51 called with the 'collection' being mutated as the only argument and
52 it should not return; it should either exit the program, or could
53 throw an exception. The recommended implementation is to throw an
54 exception - the user can then use exception handlers to deal with
55 it.
56
57 This function is not thread safe (other threads may be trying to
58 invoke the enumeration mutation handler while you are changing it!)
59 and should be called during during the program initialization
60 before threads are started. It is mostly reserved for "Foundation"
61 libraries; in the case of GNUstep, GNUstep Base may be using this
62 function to improve the standard enumeration mutation handling.
63 You probably shouldn't use this function unless you are writing
64 your own Foundation library.
65 */
66 objc_EXPORT void objc_set_enumeration_mutation_handler (void (*handler)(id));
67
68 /* This structure (used during fast enumeration) is automatically
69 defined by the compiler (it is as if this definition was always
70 included in all Objective-C files). Note that it is usually
71 defined again with the name of NSFastEnumeration by "Foundation"
72 libraries such as GNUstep Base. And if NSFastEnumeration is
73 defined, the compiler will use it instead of
74 __objcFastEnumerationState when doing fast enumeration.
75 */
76 /*
77 struct __objcFastEnumerationState
78 {
79 unsigned long state;
80 id *itemsPtr;
81 unsigned long *mutationsPtr;
82 unsigned long extra[5];
83 };
84 */
85 /* For compatibility with the Apple/NeXT runtime. */
86 #define objc_setEnumerationMutationHandler objc_set_enumeration_mutation_handler
87
88 #endif