Fix TARGET_SOFT_FLOAT patterns in pa.md
[official-gcc.git] / libobjc / objc-private / module-abi-8.h
blob4dc3c5b94b7eb601571c14282ee7f3d611d1b7d1
1 /* Definitions of Module Structures used by ABI version 8
2 Copyright (C) 1993-2021 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under the
7 terms of the GNU General Public License as published by the Free Software
8 Foundation; either version 3, or (at your option) any later version.
10 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 details.
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
24 #ifndef __objc_private_module_abi_8_INCLUDE_GNU
25 #define __objc_private_module_abi_8_INCLUDE_GNU
27 /* For every class which happens to have statically allocated instances in
28 this module, one OBJC_STATIC_INSTANCES is allocated by the compiler.
29 INSTANCES is NULL terminated and points to all statically allocated
30 instances of this class. */
31 struct objc_static_instances
33 char *class_name;
34 #ifdef __cplusplus
35 id instances[1];
36 #else
37 id instances[0];
38 #endif
41 /* Whereas a Module (defined further down) is the root (typically) of a file,
42 a Symtab is the root of the class and category definitions within the
43 module.
45 A Symtab contains a variable length array of pointers to classes and
46 categories defined in the module. */
47 struct objc_symtab
49 unsigned long sel_ref_cnt; /* Unused (always set to 0). */
50 struct objc_selector *refs; /* The table of selectors referenced in
51 this module. This is terminated by a
52 selector with NULL sel_id and NULL
53 sel_types. Note that we use the type
54 'struct objc_selector *' and not
55 'SEL' (which is 'const struct
56 objc_selector *') because the sel_id
57 of these selectors is patched up by
58 the runtime when the module is
59 loaded. */
60 unsigned short cls_def_cnt; /* Number of classes compiled (defined)
61 in the module. */
62 unsigned short cat_def_cnt; /* Number of categories compiled
63 (defined) in the module. */
64 void *defs[1]; /* Variable array of pointers.
65 cls_def_cnt of type Class followed by
66 cat_def_cnt of type Category_t,
67 followed by a NULL terminated array
68 of objc_static_instances. */
71 /* The compiler generates one of these structures for each module that
72 composes the executable (eg main.m).
74 This data structure is the root of the definition tree for the
75 module.
77 A collect program runs between ld stages and creates a ObjC ctor
78 array. That array holds a pointer to each module structure of the
79 executable. */
80 struct objc_module
82 unsigned long version; /* Version of the Module data
83 structure. */
84 unsigned long size; /* sizeof(Module) according to the
85 compiler - only used to sanity check
86 that it matches sizeof(Module)
87 according to the runtime. */
88 const char* name; /* Name of the file used to compile the
89 module - not set by modern compilers
90 for security reasons. */
91 struct objc_symtab *symtab; /* Pointer to the Symtab of the module.
92 The Symtab holds an array of pointers
93 to the classes and categories defined
94 in the module. */
97 /* The compiler generates one of these structures for a class that has
98 instance variables defined in its specification. */
99 struct objc_ivar
101 const char* ivar_name; /* Name of the instance variable as entered
102 in the class definition. */
103 const char* ivar_type; /* Description of the Ivar's type. Useful
104 for debuggers. */
105 int ivar_offset; /* Byte offset from the base address of the
106 instance structure to the variable. */
109 struct objc_ivar_list
111 int ivar_count; /* Number of structures (Ivar)
112 contained in the list. One
113 structure per instance variable
114 defined in the class. */
115 struct objc_ivar ivar_list[1]; /* Variable length structure. */
118 /* The compiler generates one (or more) of these structures for a
119 class that has methods defined in its specification.
121 The implementation of a class can be broken into separate pieces in
122 a file and categories can break them across modules. To handle this
123 problem is a singly linked list of methods. */
124 struct objc_method
126 SEL method_name; /* This variable is the method's name.
127 The compiler puts a char* here, and
128 it's replaced by a real SEL at runtime
129 when the method is registered. */
130 const char* method_types; /* Description of the method's parameter
131 list. Used when registering the
132 selector with the runtime. When that
133 happens, method_name will contain the
134 method's parameter list. */
135 IMP method_imp; /* Address of the method in the
136 executable. */
139 struct objc_method_list
141 struct objc_method_list* method_next; /* This variable is used to
142 link a method list to
143 another. It is a singly
144 linked list. */
145 int method_count; /* Number of methods defined
146 in this structure. */
147 struct objc_method method_list[1]; /* Variable length
148 structure. */
151 /* Note that a 'struct objc_method_description' as embedded inside a
152 Protocol uses the same trick as a 'struct objc_method': the
153 method_name is a 'char *' according to the compiler, who puts the
154 method name as a string in there. At runtime, the selectors need
155 to be registered, and the method_name then becomes a SEL. */
156 struct objc_method_description_list
158 int count;
159 struct objc_method_description list[1];
162 struct objc_protocol {
163 struct objc_class* class_pointer;
164 char *protocol_name;
165 struct objc_protocol_list *protocol_list;
166 struct objc_method_description_list *instance_methods, *class_methods;
170 struct objc_protocol_list
172 struct objc_protocol_list *next;
173 size_t count;
174 struct objc_protocol *list[1];
178 The compiler generates one of these structures for each class.
180 This structure is the definition for classes.
182 This structure is generated by the compiler in the executable and
183 used by the run-time during normal messaging operations. Therefore
184 some members change type. The compiler generates "char* const" and
185 places a string in the following member variables: super_class.
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;
230 /* This is used to assure consistent access to the info field of
231 classes. */
232 #ifndef HOST_BITS_PER_LONG
233 # define HOST_BITS_PER_LONG (sizeof(long)*8)
234 #endif
236 #define __CLS_INFO(cls) ((cls)->info)
237 #define __CLS_ISINFO(cls, mask) ((__CLS_INFO(cls)&mask)==mask)
238 #define __CLS_SETINFO(cls, mask) (__CLS_INFO(cls) |= mask)
239 #define __CLS_SETNOTINFO(cls, mask) (__CLS_INFO(cls) &= ~mask)
241 /* The structure is of type MetaClass */
242 #define _CLS_META 0x2L
243 #define CLS_ISMETA(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_META))
245 /* The structure is of type Class */
246 #define _CLS_CLASS 0x1L
247 #define CLS_ISCLASS(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_CLASS))
249 /* The class is initialized within the runtime. This means that it
250 has had correct super and sublinks assigned. */
251 #define _CLS_RESOLV 0x8L
252 #define CLS_ISRESOLV(cls) __CLS_ISINFO(cls, _CLS_RESOLV)
253 #define CLS_SETRESOLV(cls) __CLS_SETINFO(cls, _CLS_RESOLV)
255 /* The class has been send a +initialize message or a such is not
256 defined for this class. */
257 #define _CLS_INITIALIZED 0x04L
258 #define CLS_ISINITIALIZED(cls) __CLS_ISINFO(cls, _CLS_INITIALIZED)
259 #define CLS_SETINITIALIZED(cls) __CLS_SETINFO(cls, _CLS_INITIALIZED)
261 /* The class is being constructed; it has been allocated using
262 objc_allocateClassPair(), but has not been registered yet by using
263 objc_registerClassPair(). This means it is possible to freely add
264 instance variables to the class, but it can't be used for anything
265 yet. */
266 #define _CLS_IN_CONSTRUCTION 0x10L
267 #define CLS_IS_IN_CONSTRUCTION(cls) __CLS_ISINFO(cls, _CLS_IN_CONSTRUCTION)
268 #define CLS_SET_IN_CONSTRUCTION(cls) __CLS_SETINFO(cls, _CLS_IN_CONSTRUCTION)
269 #define CLS_SET_NOT_IN_CONSTRUCTION(cls) __CLS_SETNOTINFO(cls, _CLS_IN_CONSTRUCTION)
271 /* The class number of this class. This must be the same for both the
272 class and its meta class object. */
273 #define CLS_GETNUMBER(cls) (__CLS_INFO(cls) >> (HOST_BITS_PER_LONG/2))
274 #define CLS_SETNUMBER(cls, num) \
275 ({ (cls)->info <<= (HOST_BITS_PER_LONG/2); \
276 (cls)->info >>= (HOST_BITS_PER_LONG/2); \
277 __CLS_SETINFO(cls, (((unsigned long)num) << (HOST_BITS_PER_LONG/2))); })
279 /* The compiler generates one of these structures for each category.
280 A class may have many categories and contain both instance and
281 factory methods. */
282 struct objc_category
284 const char* category_name; /* Name of the category.
285 Name contained in the
286 () of the category
287 definition. */
288 const char* class_name; /* Name of the class to
289 which the category
290 belongs. */
291 struct objc_method_list *instance_methods; /* Linked list of
292 instance methods
293 defined in the
294 category. NULL
295 indicates no instance
296 methods defined. */
297 struct objc_method_list *class_methods; /* Linked list of
298 factory methods
299 defined in the
300 category. NULL
301 indicates no class
302 methods defined. */
303 struct objc_protocol_list *protocols; /* List of Protocols
304 conformed to. */
307 #endif /* __objc_private_module_abi_8_INCLUDE_GNU */