Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / libobjc / objc-private / module-abi-8.h
blob3ed836c518fd89d9175a13368e8e47fc38f22cdd
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 SEL 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. */
55 unsigned short cls_def_cnt; /* Number of classes compiled (defined)
56 in the module. */
57 unsigned short cat_def_cnt; /* Number of categories compiled
58 (defined) in the module. */
59 void *defs[1]; /* Variable array of pointers.
60 cls_def_cnt of type Class followed by
61 cat_def_cnt of type Category_t,
62 followed by a NULL terminated array
63 of objc_static_instances. */
66 /* The compiler generates one of these structures for each module that
67 composes the executable (eg main.m).
69 This data structure is the root of the definition tree for the
70 module.
72 A collect program runs between ld stages and creates a ObjC ctor
73 array. That array holds a pointer to each module structure of the
74 executable. */
75 struct objc_module
77 unsigned long version; /* Version of the Module data
78 structure. */
79 unsigned long size; /* sizeof(Module) according to the
80 compiler - only used to sanity check
81 that it matches sizeof(Module)
82 according to the runtime. */
83 const char* name; /* Name of the file used to compile the
84 module - not set by modern compilers
85 for security reasons. */
86 struct objc_symtab *symtab; /* Pointer to the Symtab of the module.
87 The Symtab holds an array of pointers
88 to the classes and categories defined
89 in the module. */
92 /* The compiler generates one of these structures for a class that has
93 instance variables defined in its specification. */
94 struct objc_ivar
96 const char* ivar_name; /* Name of the instance variable as entered
97 in the class definition. */
98 const char* ivar_type; /* Description of the Ivar's type. Useful
99 for debuggers. */
100 int ivar_offset; /* Byte offset from the base address of the
101 instance structure to the variable. */
104 struct objc_ivar_list
106 int ivar_count; /* Number of structures (Ivar)
107 contained in the list. One
108 structure per instance variable
109 defined in the class. */
110 struct objc_ivar ivar_list[1]; /* Variable length structure. */
113 /* The compiler generates one (or more) of these structures for a
114 class that has methods defined in its specification.
116 The implementation of a class can be broken into separate pieces in
117 a file and categories can break them across modules. To handle this
118 problem is a singly linked list of methods. */
119 struct objc_method
121 SEL method_name; /* This variable is the method's name.
122 The compiler puts a char* here, and
123 it's replaced by a real SEL at runtime
124 when the method is registered. */
125 const char* method_types; /* Description of the method's parameter
126 list. Used when registering the
127 selector with the runtime. When that
128 happens, method_name will contain the
129 method's parameter list. */
130 IMP method_imp; /* Address of the method in the
131 executable. */
134 struct objc_method_list
136 struct objc_method_list* method_next; /* This variable is used to
137 link a method list to
138 another. It is a singly
139 linked list. */
140 int method_count; /* Number of methods defined
141 in this structure. */
142 struct objc_method method_list[1]; /* Variable length
143 structure. */
146 /* Currently defined in Protocol.m (that definition should go away
147 once we include this file). Note that a 'struct
148 objc_method_description' as embedded inside a Protocol uses the
149 same trick as a 'struct objc_method': the method_name is a 'char *'
150 according to the compiler, who puts the method name as a string in
151 there. At runtime, the selectors need to be registered, and the
152 method_name then becomes a SEL. */
153 struct objc_method_description_list
155 int count;
156 struct objc_method_description list[1];
159 /* Currently defined by objc/objc.h. */
161 struct objc_protocol {
162 struct objc_class* class_pointer;
163 char *protocol_name;
164 struct objc_protocol_list *protocol_list;
165 struct objc_method_description_list *instance_methods, *class_methods;
169 struct objc_protocol_list
171 struct objc_protocol_list *next;
172 size_t count;
173 Protocol *list[1];
177 The compiler generates one of these structures for each class.
179 This structure is the definition for classes.
181 This structure is generated by the compiler in the executable and
182 used by the run-time during normal messaging operations. Therefore
183 some members change type. The compiler generates "char* const" and
184 places a string in the following member variables: super_class.
186 #ifndef __objc_STRUCT_OBJC_CLASS_defined
187 struct objc_class {
188 struct objc_class* class_pointer; /* Pointer to the class's meta
189 class. */
190 struct objc_class* super_class; /* Pointer to the super
191 class. NULL for class
192 Object. */
193 const char* name; /* Name of the class. */
194 long version; /* Unknown. */
195 unsigned long info; /* Bit mask. See class masks
196 defined below. */
197 long instance_size; /* Size in bytes of the class.
198 The sum of the class
199 definition and all super
200 class definitions. */
201 #ifdef _WIN64
202 /* We pad the structure manually to prevent warning when -Wpadded is
203 used. The compiler automatically pads the structures that it
204 generates, so this manually padded structure still matches the
205 one generated by the compiler, but if we don't pad manually,
206 -Wpadded detects that padding is being added and generates
207 annoying warnings. This hack is necessary as on LLP64 targets
208 sizeof (long) isn't equal to sizeof (void *). */
209 long pad;
210 #endif
211 struct objc_ivar_list* ivars; /* Pointer to a structure that
212 describes the instance
213 variables in the class
214 definition. NULL indicates
215 no instance variables.
216 Does not include super
217 class variables. */
218 struct objc_method_list* methods; /* Linked list of instance
219 methods defined for the
220 class. */
221 struct sarray * dtable; /* Pointer to instance method
222 dispatch table. */
223 struct objc_class* subclass_list; /* Subclasses */
224 struct objc_class* sibling_class;
226 struct objc_protocol_list *protocols; /* Protocols conformed to */
227 void* gc_object_type;
229 #endif /* __objc_STRUCT_OBJC_CLASS_defined */
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))); })
281 /* The compiler generates one of these structures for each category.
282 A class may have many categories and contain both instance and
283 factory methods. */
284 struct objc_category
286 const char* category_name; /* Name of the category.
287 Name contained in the
288 () of the category
289 definition. */
290 const char* class_name; /* Name of the class to
291 which the category
292 belongs. */
293 struct objc_method_list *instance_methods; /* Linked list of
294 instance methods
295 defined in the
296 category. NULL
297 indicates no instance
298 methods defined. */
299 struct objc_method_list *class_methods; /* Linked list of
300 factory methods
301 defined in the
302 category. NULL
303 indicates no class
304 methods defined. */
305 struct objc_protocol_list *protocols; /* List of Protocols
306 conformed to. */
309 #endif /* __objc_private_module_abi_8_INCLUDE_GNU */