ObjFW  Check-in [716b1fc2b3]

Overview
Comment:Don't use C11's noreturn

It causes just too much trouble: It breaks with some old versions of
Clang, where noreturn does not work correctly, and OS X headers break if
noreturn is defined, requiring an ugly and fragile workaround. It's just
not worth the trouble it causes, as the same functionality is available
through __attribute__((__noreturn__)).

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 716b1fc2b3eada5bdfb32dc8fa10e29af847dd01f07be8c456f716e180e4c94c
User & Date: js on 2014-07-19 09:55:06
Other Links: manifest | tags
Context
2014-07-19
10:47
Split threading.m into per-platform files check-in: 8abe07a0a3 user: js tags: trunk
09:55
Don't use C11's noreturn check-in: 716b1fc2b3 user: js tags: trunk
09:35
Minor build system clean-ups check-in: 0278f0b43b user: js tags: trunk
Changes

Modified src/OFApplication.h from [4b9b47fc09] to [ce851e8072].

160
161
162
163
164
165
166
167

168
169
170
171
172
173
174

175
176
177
178
179
180
181
160
161
162
163
164
165
166

167
168
169
170
171
172
173

174
175
176
177
178
179
180
181







-
+






-
+







 * @return The environment of the application
 */
+ (OFDictionary*)environment;

/*!
 * @brief Terminates the application.
 */
+ (void)terminate OF_METHOD_NORETURN;
+ (void)terminate OF_NO_RETURN;

/*!
 * @brief Terminates the application with the specified status.
 *
 * @param status The status with which the application will terminate
 */
+ (void)terminateWithStatus: (int)status OF_METHOD_NORETURN;
+ (void)terminateWithStatus: (int)status OF_NO_RETURN;

/*!
 * @brief Gets args and argv.
 *
 * @param argc A pointer where a pointer to argc should be stored
 * @param argv A pointer where a pointer to argv should be stored
 */
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
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







-
+






-
+












 * @param delegate The delegate for the application
 */
- (void)setDelegate: (id <OFApplicationDelegate>)delegate;

/*!
 * @brief Terminates the application.
 */
- (void)terminate OF_METHOD_NORETURN;
- (void)terminate OF_NO_RETURN;

/*!
 * @brief Terminates the application with the specified status.
 *
 * @param status The status with which the application will terminate
 */
- (void)terminateWithStatus: (int)status OF_METHOD_NORETURN;
- (void)terminateWithStatus: (int)status OF_NO_RETURN;
@end

@interface OFObject (OFApplicationDelegate) <OFApplicationDelegate>
@end

#ifdef __cplusplus
extern "C" {
#endif
extern int of_application_main(int*, char**[], Class);
#ifdef __cplusplus
}
#endif

Modified src/OFObject.h from [94f4198362] to [9b8af1df33].

878
879
880
881
882
883
884
885

886
887
888
889
890
891
892
878
879
880
881
882
883
884

885
886
887
888
889
890
891
892







-
+







 * @brief Handles messages which are not understood by the receiver.
 *
 * @warning If you override this method, you must make sure that it never
 *	    returns.
 *
 * @param selector The selector not understood by the receiver
 */
- (void)doesNotRecognizeSelector: (SEL)selector OF_METHOD_NORETURN;
- (void)doesNotRecognizeSelector: (SEL)selector OF_NO_RETURN;
@end

/*!
 * @protocol OFCopying OFObject.h ObjFW/OFObject.h
 *
 * @brief A protocol for the creation of copies.
 */

Modified src/OFThread.h from [4ccbd9a433] to [bd27888ffe].

141
142
143
144
145
146
147
148

149
150
151
152
153
154
155

156
157
158
159
160
161
162
141
142
143
144
145
146
147

148
149
150
151
152
153
154

155
156
157
158
159
160
161
162







-
+






-
+







 */
+ (void)yield;

#ifdef OF_HAVE_THREADS
/*!
 * @brief Terminates the current thread, letting it return nil.
 */
+ (void)terminate OF_METHOD_NORETURN;
+ (void)terminate OF_NO_RETURN;

/*!
 * @brief Terminates the current thread, letting it return the specified object.
 *
 * @param object The object which the terminated thread will return
 */
+ (void)terminateWithObject: (id)object OF_METHOD_NORETURN;
+ (void)terminateWithObject: (id)object OF_NO_RETURN;

# ifdef OF_HAVE_BLOCKS
/*!
 * @brief Initializes an already allocated thread with the specified block.
 *
 * @param threadBlock A block which is executed by the thread
 * @return An initialized OFThread.

Modified src/OFThread.m from [fc3b904999] to [4615b52a3c].

238
239
240
241
242
243
244
245
246


247
248
249
250
251
252
253
238
239
240
241
242
243
244


245
246
247
248
249
250
251
252
253







-
-
+
+







#ifdef OF_HAVE_THREADS
+ (void)terminate
{
	[self terminateWithObject: nil];

	/*
	 * For some reason, Clang thinks terminateWithObject: can return - even
	 * though it is declared noreturn - and warns that terminate returns
	 * while being declared noreturn.
	 * though it is declared OF_NO_RETURN - and warns that terminate
	 * returns while being declared OF_NO_RETURN.
	 */
	OF_UNREACHABLE
}

+ (void)terminateWithObject: (id)object
{
	OFThread *thread = of_tlskey_get(threadSelfKey);

Modified src/macros.h from [605fc19a18] to [d03270f705].

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
40
41
42
43
44
45
46






















47
48
49
50
51
52
53







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-








#if defined(__GNUC__)
# define restrict __restrict__
#elif __STDC_VERSION__ < 199901L
# define restrict
#endif

#if __STDC_VERSION__ >= 201112L
# ifdef OF_HAVE_STDNORETURN_H
#  include <stdnoreturn.h>
# else
#  define noreturn _Noreturn
# endif
#elif defined(__GNUC__)
# define noreturn __attribute__((__noreturn__))
#else
# define noreturn
#endif

/*
 * Work around Apple's libc headers breaking by defining noreturn.
 * They use __attribute__((noreturn)) where they should be using
 * __attribute__((__noreturn__)).
 */
#if defined(__APPLE__) && defined(__dead2)
# undef __dead2
# define __dead2 __attribute__((__noreturn__))
#endif

#if __STDC_VERSION__ >= 201112L && !defined(static_assert)
/* C11 compiler, but old libc */
# define static_assert _Static_assert
#endif

#if defined(OF_HAVE__THREAD_LOCAL)
# define OF_HAVE_COMPILER_TLS
173
174
175
176
177
178
179
180

181
182
183

184
185
186
187
188
189
190
151
152
153
154
155
156
157

158
159
160

161
162
163
164
165
166
167
168







-
+


-
+







# define OF_UNREACHABLE __builtin_unreachable();
#else
# define OF_UNREACHABLE abort();
#endif

#if defined(__clang__) || __GCC_VERSION__ >= 406
# define OF_SENTINEL __attribute__((__sentinel__))
# define OF_METHOD_NORETURN __attribute__((__noreturn__))
# define OF_NO_RETURN __attribute__((__noreturn__))
#else
# define OF_SENTINEL
# define OF_METHOD_NORETURN
# define OF_NO_RETURN
#endif

#if __has_attribute(__objc_requires_super__)
# define OF_REQUIRES_SUPER __attribute__((__objc_requires_super__))
#else
# define OF_REQUIRES_SUPER
#endif

Modified src/threading.h from [25e6067bdf] to [e7a7a55554].

85
86
87
88
89
90
91
92

93
94
95
96
97
98
99
85
86
87
88
89
90
91

92
93
94
95
96
97
98
99







-
+







# error of_thread_is_current not implemented!
# error of_thread_current not implemented!
#endif

extern bool of_thread_new(of_thread_t *thread, id (*function)(id), id data);
extern bool of_thread_join(of_thread_t thread);
extern bool of_thread_detach(of_thread_t thread);
extern void noreturn of_thread_exit(void);
extern void OF_NO_RETURN of_thread_exit(void);
extern void of_once(of_once_t *control, void (*func)(void));
extern bool of_mutex_new(of_mutex_t *mutex);
extern bool of_mutex_lock(of_mutex_t *mutex);
extern bool of_mutex_trylock(of_mutex_t *mutex);
extern bool of_mutex_unlock(of_mutex_t *mutex);
extern bool of_mutex_free(of_mutex_t *mutex);
extern bool of_rmutex_new(of_rmutex_t *rmutex);

Modified src/threading.m from [fb1fdd6d5c] to [5edf77ca14].

67
68
69
70
71
72
73
74

75
76
77
78
79
80
81
67
68
69
70
71
72
73

74
75
76
77
78
79
80
81







-
+







	/* FIXME */
	return true;
#else
# error of_thread_detach not implemented!
#endif
}

void noreturn
void OF_NO_RETURN
of_thread_exit(void)
{
#if defined(OF_HAVE_PTHREADS)
	pthread_exit(NULL);
#elif defined(_WIN32)
	ExitThread(0);
#else