Change [1] to [] for variable length structure elements (C99 - silences array out of bounds errors).

Added fields to the end of the class structure for strong / weak ivar bitmaps (not yet generated by any compiler).

Fixed definition of __sync_swap() so that it works on GCC again.
main
theraven 15 years ago
parent 219f921bc3
commit 4e7b476aa6

@ -1,5 +1,22 @@
#ifndef __OBJC_CLASS_H_INCLUDED
#define __OBJC_CLASS_H_INCLUDED
/**
* Overflow bitfield. Used for bitfields that are more than 63 bits.
*/
struct objc_bitfield
{
/**
* The number of elements in the values array.
*/
int32_t length;
/**
* An array of values. Each 32 bits is stored in the native endian for the
* platform.
*/
int32_t values[0];
};
struct objc_class
{
/**
@ -83,7 +100,9 @@ struct objc_class
*/
/**
* The version of the ABI used for this class. This is currently always zero.
* The version of the ABI used for this class. Zero indicates the ABI first
* implemented by clang 1.0. One indicates the presence of bitmaps
* indicating the offsets of strong, weak, and unretained ivars.
*/
long abi_version;
@ -108,6 +127,26 @@ struct objc_class
* the accessor methods for each property.
*/
struct objc_property_list *properties;
/**
* GC / ARC ABI: Fields below this point only exist if abi_version is >= 1.
*/
/**
* The location of all strong pointer ivars declared by this class.
*
* If the low bit of this field is 0, then this is a pointer to an
* objc_bitfield structure. If the low bit is 1, then the remaining 63
* bits are set, from low to high, for each ivar in the object that is a
* strong pointer.
*/
int64_t strong_pointers;
/**
* The location of all zeroing weak pointer ivars declared by this class.
* The format of this field is the same as the format of the
* strong_pointers field.
*/
int64_t weak_pointers;
};
/**

@ -130,7 +130,7 @@ static void parse_struct(const char **type, type_parser callback, void *context)
inline static void round_up(size_t *v, size_t b)
{
if (0 == b)
if (0 == b)
{
return;
}

@ -61,7 +61,7 @@ struct objc_slot* objc_get_slot(Class cls, SEL selector);
#ifndef __has_builtin
# define __has_builtin(x) 0
#endif
#if __has_builtin(__sync_swap)
#if !__has_builtin(__sync_swap)
#define __sync_swap __sync_lock_test_and_set
#endif

@ -41,7 +41,7 @@ struct objc_ivar_list
int count;
/**
* An array of instance variable metadata structures. Note that this array
* has count elements, not 1.
* has count elements.
*/
struct objc_ivar ivar_list[1];
struct objc_ivar ivar_list[];
};

@ -37,7 +37,7 @@ struct objc_method_list
*/
int count;
/**
* An array of methods. Note that the actual size of this is count, not 1.
* An array of methods. Note that the actual size of this is count.
*/
struct objc_method methods[1];
struct objc_method methods[];
};

@ -37,7 +37,7 @@ struct objc_symbol_table_abi_8
* Current compilers only use this for constant strings. The runtime
* permits other types.
*/
void *definitions[1];
void *definitions[];
};
/**
@ -98,5 +98,5 @@ struct objc_static_instance_list
/**
* NULL-terminated array of statically-allocated instances.
*/
id instances[1];
id instances[];
};

@ -95,6 +95,6 @@ struct objc_property_list
/**
* List of properties.
*/
struct objc_property properties[1];
struct objc_property properties[];
};

@ -12,7 +12,7 @@ struct objc_method_description_list
* field points to the name, not to the index of the uniqued version of the
* name. You must not use them for dispatch.
*/
struct objc_selector methods[1];
struct objc_selector methods[];
};
@ -116,6 +116,6 @@ struct objc_protocol_list
*
* The instances in this array may be any version of protocols.
*/
Protocol2 *list[1];
Protocol2 *list[];
};

Loading…
Cancel
Save