ObjFW  Check-in [169832c303]

Overview
Comment:runtime: Use exit(1) instead of abort() on AmigaOS

This prevents leaking resources like open files.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 169832c303989b747e63f6d40236bbdd5c4ac2cf303f63e89809dc5b868d19a2
User & Date: js on 2020-12-20 03:32:34
Other Links: manifest | tags
Context
2020-12-20
03:50
runtime/linklib: Show errors with requester check-in: e9b359a922 user: js tags: trunk
03:32
runtime: Use exit(1) instead of abort() on AmigaOS check-in: 169832c303 user: js tags: trunk
03:06
Let OF_ENSURE use OBJC_ERROR in runtime check-in: 8f271bed22 user: js tags: trunk
Changes

Modified configure.ac from [259fce4552] to [3bbb9e4b54].

57
58
59
60
61
62
63


64
65
66
67
68
69
70
71
72
			AC_SUBST(SFDC_TARGET, m68k-amigaos)
			AC_SUBST(SFD_FILE, amigaos3.sfd)
			AC_SUBST(SFDC_INLINE_H, inline.h)
			dnl For 68000, GCC emits calls to helper functions that
			dnl do not work properly in a library.
			t="-mcpu=68020 -fbaserel -noixemul"
			AC_SUBST(AMIGA_LIB_CFLAGS, "$t -ffreestanding")


			AC_SUBST(AMIGA_LIB_LDFLAGS,
				"$t -resident -nostartfiles -ldebug -lc")
		])

		AC_SUBST(LIBBASES_M, libbases.m)
		;;
	powerpc-*-amigaos*)
		CPPFLAGS="$CPPFLAGS -D__USE_INLINE__"








>
>
|
<







57
58
59
60
61
62
63
64
65
66

67
68
69
70
71
72
73
			AC_SUBST(SFDC_TARGET, m68k-amigaos)
			AC_SUBST(SFD_FILE, amigaos3.sfd)
			AC_SUBST(SFDC_INLINE_H, inline.h)
			dnl For 68000, GCC emits calls to helper functions that
			dnl do not work properly in a library.
			t="-mcpu=68020 -fbaserel -noixemul"
			AC_SUBST(AMIGA_LIB_CFLAGS, "$t -ffreestanding")
			t="$t -resident -nostartfiles -nodefaultlibs"
			t="$t -ldebug -lc"
			AC_SUBST(AMIGA_LIB_LDFLAGS, $t)

		])

		AC_SUBST(LIBBASES_M, libbases.m)
		;;
	powerpc-*-amigaos*)
		CPPFLAGS="$CPPFLAGS -D__USE_INLINE__"

Modified src/runtime/amiga-library.m from [d04f6c69e6] to [aa5ebeffcc].

43
44
45
46
47
48
49







50
51
52
53
54
55
56

/* This always needs to be the first thing in the file. */
int
_start()
{
	return -1;
}








struct ObjFWRTBase {
	struct Library library;
	void *segList;
	struct ObjFWRTBase *parent;
	char *dataSeg;
	bool initialized;







>
>
>
>
>
>
>







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

/* This always needs to be the first thing in the file. */
int
_start()
{
	return -1;
}

#ifdef OF_AMIGAOS_M68K
void
__init_eh(void)
{
}
#endif

struct ObjFWRTBase {
	struct Library library;
	void *segList;
	struct ObjFWRTBase *parent;
	char *dataSeg;
	bool initialized;
592
593
594
595
596
597
598
599






600
601
602
603
604
605
606
607
608
609
610
int
vsnprintf(char *restrict str, size_t size, const char *restrict fmt,
    va_list args)
{
	return libc.vsnprintf(str, size, fmt, args);
}
#endif







void
abort(void)
{
	libc.abort();

	OF_UNREACHABLE
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
static CONST_APTR functionTable[] = {








>
>
>
>
>
>

|

|







599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
int
vsnprintf(char *restrict str, size_t size, const char *restrict fmt,
    va_list args)
{
	return libc.vsnprintf(str, size, fmt, args);
}
#endif

int
atexit(void (*function)(void))
{
	return libc.atexit(function);
}

void
exit(int status)
{
	libc.exit(status);

	OF_UNREACHABLE
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
static CONST_APTR functionTable[] = {

Modified src/runtime/linklib/linklib.m from [9324d0a33d] to [cc71dd731d].

113
114
115
116
117
118
119

120
121
122
123
124
125
126
127
		.__register_frame = __register_frame,
		.__deregister_frame = __deregister_frame,
#endif
		.get_errno = get_errno,
#ifdef OF_AMIGAOS_M68K
		.vsnprintf = vsnprintf,
#endif

		.abort = abort,
	};

	if (initialized)
		return;

	if ((ObjFWRTBase = OpenLibrary(OBJFWRT_AMIGA_LIB,
	    OBJFWRT_LIB_MINOR)) == NULL) {







>
|







113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
		.__register_frame = __register_frame,
		.__deregister_frame = __deregister_frame,
#endif
		.get_errno = get_errno,
#ifdef OF_AMIGAOS_M68K
		.vsnprintf = vsnprintf,
#endif
		.atexit = atexit,
		.exit = exit,
	};

	if (initialized)
		return;

	if ((ObjFWRTBase = OpenLibrary(OBJFWRT_AMIGA_LIB,
	    OBJFWRT_LIB_MINOR)) == NULL) {

Modified src/runtime/misc.m from [b6816d93b0] to [aa8c7fb972].

82
83
84
85
86
87
88


89
90
91
92
93
94
95
96
97
98
99
100
101
102

103
104
105
			(UBYTE *)"OK"
		};

		EasyRequest(NULL, &easy, NULL, (ULONG)message);

		CloseLibrary(IntuitionBase);
	}


# undef BUF_LEN
#else
	va_list args;

	va_start(args, format);

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

	va_end(args);
#endif
	abort();


	OF_UNREACHABLE
}







>
>












|

>



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
			(UBYTE *)"OK"
		};

		EasyRequest(NULL, &easy, NULL, (ULONG)message);

		CloseLibrary(IntuitionBase);
	}

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

	va_start(args, format);

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

	va_end(args);

	abort();
#endif

	OF_UNREACHABLE
}

Modified src/runtime/private.h from [85a2ea1403] to [62a0f3f2e0].

255
256
257
258
259
260
261

262
263
264
265
266
267
268
269
	void (*_Nonnull __deregister_frame)(void *_Nonnull);
# endif
	int *_Nonnull (*_Nonnull get_errno)(void);
# ifdef OF_AMIGAOS_M68K
	int (*_Nonnull vsnprintf)(char *restrict _Nonnull str, size_t size,
	    const char *_Nonnull restrict fmt, va_list args);
# endif

	void (*_Nonnull abort)(void);
};
#endif

#ifdef OBJC_COMPILING_AMIGA_LIBRARY
# if defined(__MORPHOS__)
#  include <ppcinline/macros.h>
#  define OBJC_M68K_ARG(type, name, reg) type name = (type)REG_##reg;







>
|







255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
	void (*_Nonnull __deregister_frame)(void *_Nonnull);
# endif
	int *_Nonnull (*_Nonnull get_errno)(void);
# ifdef OF_AMIGAOS_M68K
	int (*_Nonnull vsnprintf)(char *restrict _Nonnull str, size_t size,
	    const char *_Nonnull restrict fmt, va_list args);
# endif
	int (*_Nonnull atexit)(void (*_Nonnull)(void));
	void (*_Nonnull exit)(int);
};
#endif

#ifdef OBJC_COMPILING_AMIGA_LIBRARY
# if defined(__MORPHOS__)
#  include <ppcinline/macros.h>
#  define OBJC_M68K_ARG(type, name, reg) type name = (type)REG_##reg;