ObjFW  Check-in [c5b3c8ea87]

Overview
Comment:Add nullability annotations to remaining headers

This explicitly excludes threading.h, as adding nullability annotations
requires adding them everywhere in the file. However, the types in there
are implementation defined, and might be pointers or not: Adding none
when it's a pointer would be an error, and adding one when it's not a
pointer would be an error, too.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c5b3c8ea8791be22ceda9eb2668e663dc51b8a6bbcc4bbcbe8d566ded23f0ccc
User & Date: js on 2017-05-14 14:18:26
Other Links: manifest | tags
Context
2017-05-14
21:29
Add OFHTTPCookieManager check-in: 28bacc2aa0 user: js tags: trunk
14:18
Add nullability annotations to remaining headers check-in: c5b3c8ea87 user: js tags: trunk
02:15
runtime: Add nullability annotations check-in: 8c7e612885 user: js tags: trunk
Changes

Modified src/crc32.h from [cd55eac12e] to [c923eabd0c].

22
23
24
25
26
27
28
29

30
31
32
#endif

#import "macros.h"

#ifdef __cplusplus
extern "C" {
#endif
extern uint32_t of_crc32(uint32_t crc, unsigned char *bytes, size_t length);

#ifdef __cplusplus
}
#endif







|
>



22
23
24
25
26
27
28
29
30
31
32
33
#endif

#import "macros.h"

#ifdef __cplusplus
extern "C" {
#endif
extern uint32_t of_crc32(uint32_t crc, unsigned char *_Nonnull bytes,
    size_t length);
#ifdef __cplusplus
}
#endif

Modified src/runtime/runtime-private.h from [a994a21929] to [1aa5ac440a].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37





38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127

128
129
130
131
132
133
134
135
136
137


138
139
140
141
142

143

144
145
146
147
148
149

150

151
152
153

154

155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
 */

#include "config.h"

#include "platform.h"

struct objc_abi_class {
	struct objc_abi_class *metaclass;
	const char *superclass;
	const char *name;
	unsigned long version;
	unsigned long info;
	long instance_size;
	void *ivars;
	struct objc_abi_method_list *methodlist;
	void *dtable;
	void *subclass_list;
	void *sibling_class;
	void *protocols;
	void *gc_object_type;
	long abi_version;
	int32_t **ivar_offsets;
	void *properties;





};

struct objc_abi_method {
	const char *name;
	const char *types;
	IMP imp;
};

struct objc_abi_method_list {
	struct objc_abi_method_list *next;
	unsigned int count;
	struct objc_abi_method methods[1];
};

struct objc_abi_selector {
	const char *name;
	const char *types;
};

struct objc_abi_category {
	const char *category_name;
	const char *class_name;
	struct objc_abi_method_list *instance_methods;
	struct objc_abi_method_list *class_methods;
	struct objc_protocol_list *protocols;
};

struct objc_abi_method_description {
	const char *name;
	const char *types;
};

struct objc_abi_method_description_list {
	int count;
	struct objc_abi_method_description list[1];
};

struct objc_abi_static_instances {
	const char *class_name;
	id instances[1];
};

struct objc_abi_symtab {
	unsigned long unknown;
	struct objc_abi_selector *sel_refs;
	uint16_t cls_def_cnt;
	uint16_t cat_def_cnt;
	void *defs[1];
};

struct objc_abi_module {
	unsigned long version;	/* 9 = non-fragile */
	unsigned long size;
	const char *name;
	struct objc_abi_symtab *symtab;
};

struct objc_hashtable_bucket {
	const void *key, *obj;
	uint32_t hash;
};

struct objc_hashtable {
	uint32_t (*hash)(const void *key);
	bool (*equal)(const void *key1, const void *key2);

	uint32_t count, size;
	struct objc_hashtable_bucket **data;
};

struct objc_sparsearray {
	struct objc_sparsearray_data {
		void *next[256];
	} *data;
	uint8_t index_size;
};

struct objc_dtable {
	struct objc_dtable_level2 {
#ifdef OF_SELUID24
		struct objc_dtable_level3 {
			IMP buckets[256];
		} *buckets[256];
#else
		IMP buckets[256];
#endif
	} *buckets[256];
};

extern void objc_register_all_categories(struct objc_abi_symtab *);
extern struct objc_category **objc_categories_for_class(Class);

extern void objc_unregister_all_categories(void);
extern void objc_initialize_class(Class);
extern void objc_update_dtable(Class);
extern void objc_register_all_classes(struct objc_abi_symtab *);
extern Class objc_classname_to_class(const char *, bool);
extern void objc_unregister_class(Class);
extern void objc_unregister_all_classes(void);
extern uint32_t objc_hash_string(const void *);
extern bool objc_equal_string(const void *, const void *);
extern struct objc_hashtable *objc_hashtable_new(uint32_t (*)(const void *),


    bool (*)(const void *, const void *), uint32_t);
extern struct objc_hashtable_bucket objc_deleted_bucket;
extern void objc_hashtable_set(struct objc_hashtable *, const void *,
    const void *);
extern void *objc_hashtable_get(struct objc_hashtable *, const void *);

extern void objc_hashtable_delete(struct objc_hashtable *, const void *);

extern void objc_hashtable_free(struct objc_hashtable *);
extern void objc_register_selector(struct objc_abi_selector *);
extern void objc_register_all_selectors(struct objc_abi_symtab *);
extern void objc_unregister_all_selectors(void);
extern struct objc_sparsearray *objc_sparsearray_new(uint8_t);
extern void *objc_sparsearray_get(struct objc_sparsearray *, uintptr_t);

extern void objc_sparsearray_set(struct objc_sparsearray *, uintptr_t, void *);

extern void objc_sparsearray_free(struct objc_sparsearray *);
extern struct objc_dtable *objc_dtable_new(void);
extern void objc_dtable_copy(struct objc_dtable *, struct objc_dtable *);

extern void objc_dtable_set(struct objc_dtable *, uint32_t, IMP);

extern void objc_dtable_free(struct objc_dtable *);
extern void objc_dtable_cleanup(void);
extern void objc_init_static_instances(struct objc_abi_symtab *);
extern void objc_forget_pending_static_instances(void);
#ifdef OF_HAVE_THREADS
extern void objc_global_mutex_lock(void);
extern void objc_global_mutex_unlock(void);
extern void objc_global_mutex_free(void);
#else
# define objc_global_mutex_lock()
# define objc_global_mutex_unlock()
# define objc_global_mutex_free()
#endif

static inline IMP
objc_dtable_get(const struct objc_dtable *dtable, uint32_t idx)
{
#ifdef OF_SELUID24
	uint8_t i = idx >> 16;
	uint8_t j = idx >>  8;
	uint8_t k = idx;

	return dtable->buckets[i]->buckets[j]->buckets[k];







|
|
|



|
|
|
|
|
|
|

|
|
>
>
>
>
>



|
<
|



|




|
|
|
<
<
<
<
<
|
|
|



|
|








|
|




|


|





|
|



|




|
|
>

|




|
|







|
|

|

|


|
|
>

|
|
|
|
|

|
|
|
>
>
|

|
|
|
>
|
>
|
|
|

|
|
>
|
>
|
|
|
>
|
>
|

|











|
|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

47
48
49
50
51
52
53
54
55
56
57
58





59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
 */

#include "config.h"

#include "platform.h"

struct objc_abi_class {
	struct objc_abi_class *_Nonnull metaclass;
	const char *_Nullable superclass;
	const char *_Nonnull name;
	unsigned long version;
	unsigned long info;
	long instance_size;
	void *_Nullable ivars;
	struct objc_abi_method_list *_Nullable methodlist;
	void *_Nullable dtable;
	void *_Nullable subclass_list;
	void *_Nullable sibling_class;
	void *_Nullable protocols;
	void *_Nullable gc_object_type;
	long abi_version;
	int32_t *_Nonnull *_Nullable ivar_offsets;
	void *_Nullable properties;
};

struct objc_abi_selector {
	const char *_Nonnull name;
	const char *_Nullable types;
};

struct objc_abi_method {
	struct objc_abi_selector sel;

	IMP _Nonnull imp;
};

struct objc_abi_method_list {
	struct objc_abi_method_list *_Nullable next;
	unsigned int count;
	struct objc_abi_method methods[1];
};

struct objc_abi_category {
	const char *_Nonnull category_name;
	const char *_Nonnull class_name;





	struct objc_abi_method_list *_Nullable instance_methods;
	struct objc_abi_method_list *_Nullable class_methods;
	struct objc_protocol_list *_Nullable protocols;
};

struct objc_abi_method_description {
	const char *_Nonnull name;
	const char *_Nonnull types;
};

struct objc_abi_method_description_list {
	int count;
	struct objc_abi_method_description list[1];
};

struct objc_abi_static_instances {
	const char *_Nonnull class_name;
	id _Nullable instances[1];
};

struct objc_abi_symtab {
	unsigned long unknown;
	struct objc_abi_selector *_Nullable sel_refs;
	uint16_t cls_def_cnt;
	uint16_t cat_def_cnt;
	void *_Nonnull defs[1];
};

struct objc_abi_module {
	unsigned long version;	/* 9 = non-fragile */
	unsigned long size;
	const char *_Nullable name;
	struct objc_abi_symtab *_Nonnull symtab;
};

struct objc_hashtable_bucket {
	const void *_Nonnull key, *_Nonnull obj;
	uint32_t hash;
};

struct objc_hashtable {
	uint32_t (*_Nonnull hash)(const void *_Nonnull key);
	bool (*_Nonnull equal)(const void *_Nonnull key1,
	    const void *_Nonnull key2);
	uint32_t count, size;
	struct objc_hashtable_bucket *_Nonnull *_Nullable data;
};

struct objc_sparsearray {
	struct objc_sparsearray_data {
		void *_Nullable next[256];
	} *_Nonnull data;
	uint8_t index_size;
};

struct objc_dtable {
	struct objc_dtable_level2 {
#ifdef OF_SELUID24
		struct objc_dtable_level3 {
			IMP _Nullable buckets[256];
		} *_Nonnull buckets[256];
#else
		IMP _Nullable buckets[256];
#endif
	} *_Nonnull buckets[256];
};

extern void objc_register_all_categories(struct objc_abi_symtab *_Nonnull);
extern struct objc_category *_Nullable *_Nullable
    objc_categories_for_class(Class _Nonnull);
extern void objc_unregister_all_categories(void);
extern void objc_initialize_class(Class _Nonnull);
extern void objc_update_dtable(Class _Nonnull);
extern void objc_register_all_classes(struct objc_abi_symtab *_Nonnull);
extern Class _Nullable objc_classname_to_class(const char *_Nonnull, bool);
extern void objc_unregister_class(Class _Nonnull);
extern void objc_unregister_all_classes(void);
extern uint32_t objc_hash_string(const void *_Nonnull);
extern bool objc_equal_string(const void *_Nonnull, const void *_Nonnull);
extern struct objc_hashtable *_Nonnull objc_hashtable_new(
    uint32_t (*_Nonnull)(const void *_Nonnull),
    bool (*_Nonnull)(const void *_Nonnull, const void *_Nonnull),
    uint32_t);
extern struct objc_hashtable_bucket objc_deleted_bucket;
extern void objc_hashtable_set(struct objc_hashtable *_Nonnull,
    const void *_Nonnull, const void *_Nonnull);
extern void *_Nullable objc_hashtable_get(struct objc_hashtable *_Nonnull,
    const void *_Nonnull);
extern void objc_hashtable_delete(struct objc_hashtable *_Nonnull,
    const void *_Nonnull);
extern void objc_hashtable_free(struct objc_hashtable *_Nonnull);
extern void objc_register_selector(struct objc_abi_selector *_Nonnull);
extern void objc_register_all_selectors(struct objc_abi_symtab *_Nonnull);
extern void objc_unregister_all_selectors(void);
extern struct objc_sparsearray *_Nonnull objc_sparsearray_new(uint8_t);
extern void *_Nullable objc_sparsearray_get(struct objc_sparsearray *_Nonnull,
    uintptr_t);
extern void objc_sparsearray_set(struct objc_sparsearray *_Nonnull, uintptr_t,
    void *_Nullable);
extern void objc_sparsearray_free(struct objc_sparsearray *_Nonnull);
extern struct objc_dtable *_Nonnull objc_dtable_new(void);
extern void objc_dtable_copy(struct objc_dtable *_Nonnull,
    struct objc_dtable *_Nonnull);
extern void objc_dtable_set(struct objc_dtable *_Nonnull, uint32_t,
    IMP _Nullable);
extern void objc_dtable_free(struct objc_dtable *_Nonnull);
extern void objc_dtable_cleanup(void);
extern void objc_init_static_instances(struct objc_abi_symtab *_Nonnull);
extern void objc_forget_pending_static_instances(void);
#ifdef OF_HAVE_THREADS
extern void objc_global_mutex_lock(void);
extern void objc_global_mutex_unlock(void);
extern void objc_global_mutex_free(void);
#else
# define objc_global_mutex_lock()
# define objc_global_mutex_unlock()
# define objc_global_mutex_free()
#endif

static inline IMP _Nullable
objc_dtable_get(const struct objc_dtable *_Nonnull dtable, uint32_t idx)
{
#ifdef OF_SELUID24
	uint8_t i = idx >> 16;
	uint8_t j = idx >>  8;
	uint8_t k = idx;

	return dtable->buckets[i]->buckets[j]->buckets[k];

Modified src/threading.h from [f3dd04ca64] to [e37b27b008].

134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
{
	return pthread_getspecific(key);
}

static OF_INLINE bool
of_tlskey_set(of_tlskey_t key, void *ptr)
{
	return !pthread_setspecific(key, ptr);
}
#elif defined(OF_WINDOWS)
static OF_INLINE void *
of_tlskey_get(of_tlskey_t key)
{
	return TlsGetValue(key);
}







|







134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
{
	return pthread_getspecific(key);
}

static OF_INLINE bool
of_tlskey_set(of_tlskey_t key, void *ptr)
{
	return (pthread_setspecific(key, ptr) == 0);
}
#elif defined(OF_WINDOWS)
static OF_INLINE void *
of_tlskey_get(of_tlskey_t key)
{
	return TlsGetValue(key);
}
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
static OF_INLINE bool
of_spinlock_new(of_spinlock_t *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
	*spinlock = 0;
	return true;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
	return !pthread_spin_init(spinlock, 0);
#else
	return of_mutex_new(spinlock);
#endif
}

static OF_INLINE bool
of_spinlock_trylock(of_spinlock_t *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
	if (of_atomic_int_cmpswap(spinlock, 0, 1)) {
		of_memory_barrier_acquire();
		return true;
	}

	return false;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
	return !pthread_spin_trylock(spinlock);
#else
	return of_mutex_trylock(spinlock);
#endif
}

static OF_INLINE bool
of_spinlock_lock(of_spinlock_t *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
	size_t i;

	for (i = 0; i < OF_SPINCOUNT; i++)
		if (of_spinlock_trylock(spinlock))
			return true;

	while (!of_spinlock_trylock(spinlock))
		of_thread_yield();

	return true;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
	return !pthread_spin_lock(spinlock);
#else
	return of_mutex_lock(spinlock);
#endif
}

static OF_INLINE bool
of_spinlock_unlock(of_spinlock_t *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
	bool ret = of_atomic_int_cmpswap(spinlock, 1, 0);

	of_memory_barrier_release();

	return ret;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
	return !pthread_spin_unlock(spinlock);
#else
	return of_mutex_unlock(spinlock);
#endif
}

static OF_INLINE bool
of_spinlock_free(of_spinlock_t *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
	return true;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
	return !pthread_spin_destroy(spinlock);
#else
	return of_mutex_free(spinlock);
#endif
}







|
















|




















|















|











|




169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
static OF_INLINE bool
of_spinlock_new(of_spinlock_t *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
	*spinlock = 0;
	return true;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
	return (pthread_spin_init(spinlock, 0) == 0);
#else
	return of_mutex_new(spinlock);
#endif
}

static OF_INLINE bool
of_spinlock_trylock(of_spinlock_t *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
	if (of_atomic_int_cmpswap(spinlock, 0, 1)) {
		of_memory_barrier_acquire();
		return true;
	}

	return false;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
	return (pthread_spin_trylock(spinlock) == 0);
#else
	return of_mutex_trylock(spinlock);
#endif
}

static OF_INLINE bool
of_spinlock_lock(of_spinlock_t *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
	size_t i;

	for (i = 0; i < OF_SPINCOUNT; i++)
		if (of_spinlock_trylock(spinlock))
			return true;

	while (!of_spinlock_trylock(spinlock))
		of_thread_yield();

	return true;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
	return (pthread_spin_lock(spinlock) == 0);
#else
	return of_mutex_lock(spinlock);
#endif
}

static OF_INLINE bool
of_spinlock_unlock(of_spinlock_t *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
	bool ret = of_atomic_int_cmpswap(spinlock, 1, 0);

	of_memory_barrier_release();

	return ret;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
	return (pthread_spin_unlock(spinlock) == 0);
#else
	return of_mutex_unlock(spinlock);
#endif
}

static OF_INLINE bool
of_spinlock_free(of_spinlock_t *spinlock)
{
#if defined(OF_HAVE_ATOMIC_OPS)
	return true;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
	return (pthread_spin_destroy(spinlock) == 0);
#else
	return of_mutex_free(spinlock);
#endif
}

Modified src/unicode.h from [4902be8d2e] to [e96c8158b3].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#define OF_UNICODE_LOWERCASE_TABLE_SIZE 0x1EA
#define OF_UNICODE_TITLECASE_TABLE_SIZE 0x1EA
#define OF_UNICODE_CASEFOLDING_TABLE_SIZE 0x1EA

#ifdef __cplusplus
extern "C" {
#endif
extern const of_unichar_t *const
    of_unicode_uppercase_table[OF_UNICODE_UPPERCASE_TABLE_SIZE];
extern const of_unichar_t *const
    of_unicode_lowercase_table[OF_UNICODE_LOWERCASE_TABLE_SIZE];
extern const of_unichar_t *const
    of_unicode_titlecase_table[OF_UNICODE_TITLECASE_TABLE_SIZE];
extern const of_unichar_t *const
    of_unicode_casefolding_table[OF_UNICODE_CASEFOLDING_TABLE_SIZE];
#ifdef __cplusplus
}
#endif







|

|

|

|




20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#define OF_UNICODE_LOWERCASE_TABLE_SIZE 0x1EA
#define OF_UNICODE_TITLECASE_TABLE_SIZE 0x1EA
#define OF_UNICODE_CASEFOLDING_TABLE_SIZE 0x1EA

#ifdef __cplusplus
extern "C" {
#endif
extern const of_unichar_t *const _Nonnull
    of_unicode_uppercase_table[OF_UNICODE_UPPERCASE_TABLE_SIZE];
extern const of_unichar_t *const _Nonnull
    of_unicode_lowercase_table[OF_UNICODE_LOWERCASE_TABLE_SIZE];
extern const of_unichar_t *const _Nonnull
    of_unicode_titlecase_table[OF_UNICODE_TITLECASE_TABLE_SIZE];
extern const of_unichar_t *const _Nonnull
    of_unicode_casefolding_table[OF_UNICODE_CASEFOLDING_TABLE_SIZE];
#ifdef __cplusplus
}
#endif