ObjFW  Check-in [abe75c42dc]

Overview
Comment:Make objc_error() more generic
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: abe75c42dc92dd67e3f825429d0b369a3bf7f819023c884be6d2df042c5f8e71
User & Date: js on 2020-12-21 19:42:48
Other Links: manifest | tags
Context
2020-12-21
19:43
OFFileURLHandler: Fix brainfart check-in: c3ca6861ab user: js tags: trunk
19:42
Make objc_error() more generic check-in: abe75c42dc user: js tags: trunk
02:34
Don't use OFMutex in constructors check-in: f02b51feba user: js tags: trunk
Changes

Modified src/macros.h from [42109558ee] to [c797af37de].

146
147
148
149
150
151
152



153
154
155
156
157
158
159
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162







+
+
+








#ifdef __GNUC__
# define OF_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
#else
# define OF_GCC_VERSION 0
#endif

#define OF_STRINGIFY(s) OF_STRINGIFY2(s)
#define OF_STRINGIFY2(s) #s

#ifndef __has_feature
# define __has_feature(x) 0
#endif

#ifndef __has_attribute
# define __has_attribute(x) 0
#endif
354
355
356
357
358
359
360
361
362
363
364






365
366
367
368
369
370
371
357
358
359
360
361
362
363




364
365
366
367
368
369
370
371
372
373
374
375
376







-
-
-
-
+
+
+
+
+
+







# endif
#endif

#define OF_RETAIN_COUNT_MAX UINT_MAX
#define OF_NOT_FOUND SIZE_MAX

#ifdef OBJC_COMPILING_RUNTIME
# define OF_ENSURE(cond)						   \
	do {								   \
		if OF_UNLIKELY (!(cond))				   \
			OBJC_ERROR("Failed to ensure condition:\n" #cond); \
# define OF_ENSURE(cond)						\
	do {								\
		if OF_UNLIKELY (!(cond))				\
			objc_error("ObjFWRT @ " __FILE__ ":"		\
			    OF_STRINGIFY(__LINE__),			\
			    "Failed to ensure condition:\n" #cond);	\
	} while(0)
#else
# define OF_ENSURE(cond)						\
	do {								\
		if OF_UNLIKELY (!(cond)) {				\
			fprintf(stderr, "Failed to ensure condition "	\
			    "in " __FILE__ ":%d:\n" #cond "\n",		\

Modified src/runtime/misc.m from [2faf8bad32] to [9b223ad2b4].

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
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







-
+


-
+
-









-
-
-
-







void
objc_setEnumerationMutationHandler(objc_enumeration_mutation_handler_t handler)
{
	enumerationMutationHandler = handler;
}

void
objc_error(const char *file, unsigned int line, const char *format, ...)
objc_error(const char *title, const char *format, ...)
{
#ifdef OF_AMIGAOS
# define BUF_LEN 256
# define BUF_LEN 512
	char title[BUF_LEN];
	char message[BUF_LEN];
	int status;
	va_list args;
	struct Library *IntuitionBase;
# ifdef OF_AMIGAOS4
	struct IntuitionIFace *IIntuition;
# endif
	struct EasyStruct easy;

	status = snprintf(title, BUF_LEN, "ObjFWRT @ %s:%u", file, line);
	if (status <= 0 || status >= BUF_LEN)
		title[0] = '\0';

	va_start(args, format);
	status = vsnprintf(message, BUF_LEN, format, args);
	if (status <= 0 || status >= BUF_LEN)
		message[0] = '\0';
	va_end(args);

# ifndef OF_AMIGAOS4
107
108
109
110
111
112
113
114

115
116
117
118
119
120
121
122
123
124
125
102
103
104
105
106
107
108

109
110
111
112
113
114
115
116
117
118
119
120







-
+











	exit(EXIT_FAILURE);
# undef BUF_LEN
#else
	va_list args;

	va_start(args, format);

	fprintf(stderr, "[ObjFWRT @ %s:%u] ", file, line);
	fprintf(stderr, "[%s] ", title);
	vfprintf(stderr, format, args);
	fprintf(stderr, "\n");
	fflush(stderr);

	va_end(args);

	abort();
#endif

	OF_UNREACHABLE
}

Modified src/runtime/private.h from [ddffadab35] to [a61212a55a].

339
340
341
342
343
344
345
346
347
348





349
350
351
352
353
354
355
339
340
341
342
343
344
345



346
347
348
349
350
351
352
353
354
355
356
357







-
-
-
+
+
+
+
+







	uint8_t i = idx >> 8;
	uint8_t j = idx;

	return dtable->buckets[i]->buckets[j];
#endif
}

extern void OF_NO_RETURN_FUNC objc_error(const char *_Nonnull file,
    unsigned int line, const char *_Nonnull format, ...);
#define OBJC_ERROR(...) objc_error(__FILE__, __LINE__, __VA_ARGS__)
extern void OF_NO_RETURN_FUNC objc_error(const char *_Nonnull title,
    const char *_Nonnull format, ...);
#define OBJC_ERROR(...)							\
	objc_error("ObjFWRT @ " __FILE__ ":" OF_STRINGIFY(__LINE__),	\
	    __VA_ARGS__)

#if defined(OF_ELF)
# if defined(OF_X86_64) || defined(OF_X86) || defined(OF_POWERPC) || \
    defined(OF_ARM64) || defined(OF_ARM) || \
    defined(OF_MIPS64_N64) || defined(OF_MIPS) || \
    defined(OF_SPARC64) || defined(OF_SPARC)
#  define OF_ASM_LOOKUP