configure.ac: Substitute `with_cpu'.
[official-gcc.git] / libobjc / objc-private / module-abi-8.h
blob06846e796904c41b19cfc42d80781edb33949da3
1 /* Definitions of Module Structures used by ABI version 8
2 Copyright (C) 1993, 1995, 1996, 1997, 2001, 2002, 2003, 2004, 2005,
3 2007, 2009, 2010 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under the
8 terms of the GNU General Public License as published by the Free Software
9 Foundation; either version 3, or (at your option) any later version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 details.
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
25 #ifndef __objc_private_module_abi_8_INCLUDE_GNU
26 #define __objc_private_module_abi_8_INCLUDE_GNU
28 /* For every class which happens to have statically allocated instances in
29 this module, one OBJC_STATIC_INSTANCES is allocated by the compiler.
30 INSTANCES is NULL terminated and points to all statically allocated
31 instances of this class. */
32 struct objc_static_instances
34 char *class_name;
35 #ifdef __cplusplus
36 id instances[1];
37 #else
38 id instances[0];
39 #endif
42 /* Whereas a Module (defined further down) is the root (typically) of a file,
43 a Symtab is the root of the class and category definitions within the
44 module.
46 A Symtab contains a variable length array of pointers to classes and
47 categories defined in the module. */
48 struct objc_symtab
50 unsigned long sel_ref_cnt; /* Unused (always set to 0). */
51 struct objc_selector *refs; /* The table of selectors referenced in
52 this module. This is terminated by a
53 selector with NULL sel_id and NULL
54 sel_types. Note that we use the type
55 'struct objc_selector *' and not
56 'SEL' (which is 'const struct
57 objc_selector *') because the sel_id
58 of these selectors is patched up by
59 the runtime when the module is
60 loaded. */
61 unsigned short cls_def_cnt; /* Number of classes compiled (defined)
62 in the module. */
63 unsigned short cat_def_cnt; /* Number of categories compiled
64 (defined) in the module. */
65 void *defs[1]; /* Variable array of pointers.
66 cls_def_cnt of type Class followed by
67 cat_def_cnt of type Category_t,
68 followed by a NULL terminated array
69 of objc_static_instances. */
72 /* The compiler generates one of these structures for each module that
73 composes the executable (eg main.m).
75 This data structure is the root of the definition tree for the
76 module.
78 A collect program runs between ld stages and creates a ObjC ctor
79 array. That array holds a pointer to each module structure of the
80 executable. */
81 struct objc_module
83 unsigned long version; /* Version of the Module data
84 structure. */
85 unsigned long size; /* sizeof(Module) according to the
86 compiler - only used to sanity check
87 that it matches sizeof(Module)
88 according to the runtime. */
89 const char* name; /* Name of the file used to compile the
90 module - not set by modern compilers
91 for security reasons. */
92 struct objc_symtab *symtab; /* Pointer to the Symtab of the module.
93 The Symtab holds an array of pointers
94 to the classes and categories defined
95 in the module. */
98 /* The compiler generates one of these structures for a class that has
99 instance variables defined in its specification. */
100 struct objc_ivar
102 const char* ivar_name; /* Name of the instance variable as entered
103 in the class definition. */
104 const char* ivar_type; /* Description of the Ivar's type. Useful
105 for debuggers. */
106 int ivar_offset; /* Byte offset from the base address of the
107 instance structure to the variable. */
110 struct objc_ivar_list
112 int ivar_count; /* Number of structures (Ivar)
113 contained in the list. One
114 structure per instance variable
115 defined in the class. */
116 struct objc_ivar ivar_list[1]; /* Variable length structure. */
119 /* The compiler generates one (or more) of these structures for a
120 class that has methods defined in its specification.
122 The implementation of a class can be broken into separate pieces in
123 a file and categories can break them across modules. To handle this
124 problem is a singly linked list of methods. */
125 struct objc_method
127 SEL method_name; /* This variable is the method's name.
128 The compiler puts a char* here, and
129 it's replaced by a real SEL at runtime
130 when the method is registered. */
131 const char* method_types; /* Description of the method's parameter
132 list. Used when registering the
133 selector with the runtime. When that
134 happens, method_name will contain the
135 method's parameter list. */
136 IMP method_imp; /* Address of the method in the
137 executable. */
140 struct objc_method_list
142 struct objc_method_list* method_next; /* This variable is used to
143 link a method list to
144 another. It is a singly
145 linked list. */
146 int method_count; /* Number of methods defined
147 in this structure. */
148 struct objc_method method_list[1]; /* Variable length
149 structure. */
152 /* Note that a 'struct objc_method_description' as embedded inside a
153 Protocol uses the same trick as a 'struct objc_method': the
154 method_name is a 'char *' according to the compiler, who puts the
155 method name as a string in there. At runtime, the selectors need
156 to be registered, and the method_name then becomes a SEL. */
157 struct objc_method_description_list
159 int count;
160 struct objc_method_description list[1];
163 struct objc_protocol {
164 struct objc_class* class_pointer;
165 char *protocol_name;
166 struct objc_protocol_list *protocol_list;
167 struct objc_method_description_list *instance_methods, *class_methods;
171 struct objc_protocol_list
173 struct objc_protocol_list *next;
174 size_t count;
175 struct objc_protocol *list[1];
179 The compiler generates one of these structures for each class.
181 This structure is the definition for classes.
183 This structure is generated by the compiler in the executable and
184 used by the run-time during normal messaging operations. Therefore
185 some members change type. The compiler generates "char* const" and
186 places a string in the following member variables: super_class.
188 struct objc_class {
189 struct objc_class* class_pointer; /* Pointer to the class's meta
190 class. */
191 struct objc_class* super_class; /* Pointer to the super
192 class. NULL for class
193 Object. */
194 const char* name; /* Name of the class. */
195 long version; /* Unknown. */
196 unsigned long info; /* Bit mask. See class masks
197 defined below. */
198 long instance_size; /* Size in bytes of the class.
199 The sum of the class
200 definition and all super
201 class definitions. */
202 #ifdef _WIN64
203 /* We pad the structure manually to prevent warning when -Wpadded is
204 used. The compiler automatically pads the structures that it
205 generates, so this manually padded structure still matches the
206 one generated by the compiler, but if we don't pad manually,
207 -Wpadded detects that padding is being added and generates
208 annoying warnings. This hack is necessary as on LLP64 targets
209 sizeof (long) isn't equal to sizeof (void *). */
210 long pad;
211 #endif
212 struct objc_ivar_list* ivars; /* Pointer to a structure that
213 describes the instance
214 variables in the class
215 definition. NULL indicates
216 no instance variables.
217 Does not include super
218 class variables. */
219 struct objc_method_list* methods; /* Linked list of instance
220 methods defined for the
221 class. */
222 struct sarray * dtable; /* Pointer to instance method
223 dispatch table. */
224 struct objc_class* subclass_list; /* Subclasses */
225 struct objc_class* sibling_class;
227 struct objc_protocol_list *protocols; /* Protocols conformed to */
228 void* gc_object_type;
231 /* This is used to assure consistent access to the info field of
232 classes. */
233 #ifndef HOST_BITS_PER_LONG
234 # define HOST_BITS_PER_LONG (sizeof(long)*8)
235 #endif
237 #define __CLS_INFO(cls) ((cls)->info)
238 #define __CLS_ISINFO(cls, mask) ((__CLS_INFO(cls)&mask)==mask)
239 #define __CLS_SETINFO(cls, mask) (__CLS_INFO(cls) |= mask)
240 #define __CLS_SETNOTINFO(cls, mask) (__CLS_INFO(cls) &= ~mask)
242 /* The structure is of type MetaClass */
243 #define _CLS_META 0x2L
244 #define CLS_ISMETA(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_META))
246 /* The structure is of type Class */
247 #define _CLS_CLASS 0x1L
248 #define CLS_ISCLASS(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_CLASS))
250 /* The class is initialized within the runtime. This means that it
251 has had correct super and sublinks assigned. */
252 #define _CLS_RESOLV 0x8L
253 #define CLS_ISRESOLV(cls) __CLS_ISINFO(cls, _CLS_RESOLV)
254 #define CLS_SETRESOLV(cls) __CLS_SETINFO(cls, _CLS_RESOLV)
256 /* The class has been send a +initialize message or a such is not
257 defined for this class. */
258 #define _CLS_INITIALIZED 0x04L
259 #define CLS_ISINITIALIZED(cls) __CLS_ISINFO(cls, _CLS_INITIALIZED)
260 #define CLS_SETINITIALIZED(cls) __CLS_SETINFO(cls, _CLS_INITIALIZED)
262 /* The class is being constructed; it has been allocated using
263 objc_allocateClassPair(), but has not been registered yet by using
264 objc_registerClassPair(). This means it is possible to freely add
265 instance variables to the class, but it can't be used for anything
266 yet. */
267 #define _CLS_IN_CONSTRUCTION 0x10L
268 #define CLS_IS_IN_CONSTRUCTION(cls) __CLS_ISINFO(cls, _CLS_IN_CONSTRUCTION)
269 #define CLS_SET_IN_CONSTRUCTION(cls) __CLS_SETINFO(cls, _CLS_IN_CONSTRUCTION)
270 #define CLS_SET_NOT_IN_CONSTRUCTION(cls) __CLS_SETNOTINFO(cls, _CLS_IN_CONSTRUCTION)
272 /* The class number of this class. This must be the same for both the
273 class and its meta class object. */
274 #define CLS_GETNUMBER(cls) (__CLS_INFO(cls) >> (HOST_BITS_PER_LONG/2))
275 #define CLS_SETNUMBER(cls, num) \
276 ({ (cls)->info <<= (HOST_BITS_PER_LONG/2); \
277 (cls)->info >>= (HOST_BITS_PER_LONG/2); \
278 __CLS_SETINFO(cls, (((unsigned long)num) << (HOST_BITS_PER_LONG/2))); })
280 /* The compiler generates one of these structures for each category.
281 A class may have many categories and contain both instance and
282 factory methods. */
283 struct objc_category
285 const char* category_name; /* Name of the category.
286 Name contained in the
287 () of the category
288 definition. */
289 const char* class_name; /* Name of the class to
290 which the category
291 belongs. */
292 struct objc_method_list *instance_methods; /* Linked list of
293 instance methods
294 defined in the
295 category. NULL
296 indicates no instance
297 methods defined. */
298 struct objc_method_list *class_methods; /* Linked list of
299 factory methods
300 defined in the
301 category. NULL
302 indicates no class
303 methods defined. */
304 struct objc_protocol_list *protocols; /* List of Protocols
305 conformed to. */
308 #endif /* __objc_private_module_abi_8_INCLUDE_GNU */