ObjFW  Check-in [e2fcdcb6bd]

Overview
Comment:Add signal and sscanf to amiga-library.m

sscanf() is used internally by strtod().

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | amiga-library
Files: files | file ages | folders
SHA3-256: e2fcdcb6bd49ede46fad14bf9939c664e81f0d4179b8556f2aada5ce4f2dc9d7
User & Date: js on 2020-06-07 21:14:32
Other Links: branch diff | manifest | tags
Context
2020-06-07
21:32
Clean up a little check-in: fa90c6cb2c user: js tags: amiga-library
21:14
Add signal and sscanf to amiga-library.m check-in: e2fcdcb6bd user: js tags: amiga-library
20:25
Switch to -fbaserel32 and -resident32 check-in: 35cec55099 user: js tags: amiga-library
Changes

Modified src/amiga-library.h from [3e0d609d4b] to [d45496454a].

23
24
25
26
27
28
29

30
31
32
33
34
35
36
#  define OF_M68K_ARG(type, name, reg) type name = (type)REG_##reg;
# else
#  define OF_M68K_ARG(type, name, reg)		\
	register type reg_##name __asm__(#reg);	\
	type name = reg_##name;
# endif


struct of_libc {
	/*
	 * Needed by the runtime. Some of them are also used by ObjFW, but we
	 * need all of them to pass them along to the runtime.
	 */
	void *_Nullable (*_Nonnull malloc)(size_t);
	void *_Nullable (*_Nonnull calloc)(size_t, size_t);







>







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#  define OF_M68K_ARG(type, name, reg) type name = (type)REG_##reg;
# else
#  define OF_M68K_ARG(type, name, reg)		\
	register type reg_##name __asm__(#reg);	\
	type name = reg_##name;
# endif

typedef void (*of_sig_t)(int);
struct of_libc {
	/*
	 * Needed by the runtime. Some of them are also used by ObjFW, but we
	 * need all of them to pass them along to the runtime.
	 */
	void *_Nullable (*_Nonnull malloc)(size_t);
	void *_Nullable (*_Nonnull calloc)(size_t, size_t);
66
67
68
69
70
71
72





73
74
75
76

77
78
79
80
	void *_Nullable (*_Nonnull __deregister_frame_info)(
	    const void *_Nonnull);
# endif

	/* Needed only by ObjFW. */
	int (*_Nonnull vsnprintf)(const char *_Nonnull restrict, size_t,
	    const char *_Nonnull restrict, va_list);





	void (*_Nonnull exit)(int);
	char *_Nullable (*_Nonnull setlocale)(int, const char *_Nullable);
	int (*_Nonnull _Unwind_Backtrace)(int (*_Nonnull)(void *_Nonnull,
	    void *_Null_unspecified), void *_Null_unspecified);

};

extern bool of_init(unsigned int version, struct of_libc *libc, FILE **sF);
#endif







>
>
>
>
>




>




67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
	void *_Nullable (*_Nonnull __deregister_frame_info)(
	    const void *_Nonnull);
# endif

	/* Needed only by ObjFW. */
	int (*_Nonnull vsnprintf)(const char *_Nonnull restrict, size_t,
	    const char *_Nonnull restrict, va_list);
# ifdef OF_AMIGAOS_M68K
	/* strtod() uses sscanf() internally */
	int (*_Nonnull vsscanf)(const char *_Nonnull restrict,
	    const char *_Nonnull restrict, va_list);
# endif
	void (*_Nonnull exit)(int);
	char *_Nullable (*_Nonnull setlocale)(int, const char *_Nullable);
	int (*_Nonnull _Unwind_Backtrace)(int (*_Nonnull)(void *_Nonnull,
	    void *_Null_unspecified), void *_Null_unspecified);
	of_sig_t _Nullable (*_Nonnull signal)(int, of_sig_t _Nullable);
};

extern bool of_init(unsigned int version, struct of_libc *libc, FILE **sF);
#endif

Modified src/amiga-library.m from [35e8c01732] to [963ac93332].

522
523
524
525
526
527
528















529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547






548
549
550
551
552
553
554
int
vsnprintf(char *restrict str, size_t size, const char *restrict fmt,
    va_list args)
{
	return libc.vsnprintf(str, size, fmt, args);
}
















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

	OF_UNREACHABLE
}

char *
setlocale(int category, const char *locale)
{
	return libc.setlocale(category, locale);
}

int
_Unwind_Backtrace(int (*callback)(void *, void *), void *data)
{
	return libc._Unwind_Backtrace(callback, data);
}







#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
static CONST_APTR functionTable[] = {
#ifdef OF_MORPHOS
	(CONST_APTR)FUNCARRAY_BEGIN,
	(CONST_APTR)FUNCARRAY_32BIT_NATIVE,







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



















>
>
>
>
>
>







522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
int
vsnprintf(char *restrict str, size_t size, const char *restrict fmt,
    va_list args)
{
	return libc.vsnprintf(str, size, fmt, args);
}

#ifdef OF_AMIGAOS_M68K
int
sscanf(const char *restrict str, const char *restrict fmt, ...)
{
	int ret;
	va_list args;

	va_start(args, fmt);
	ret = libc.vsscanf(str, fmt, args);
	va_end(args);

	return ret;
}
#endif

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

	OF_UNREACHABLE
}

char *
setlocale(int category, const char *locale)
{
	return libc.setlocale(category, locale);
}

int
_Unwind_Backtrace(int (*callback)(void *, void *), void *data)
{
	return libc._Unwind_Backtrace(callback, data);
}

of_sig_t
signal(int sig, of_sig_t func)
{
	return libc.signal(sig, func);
}

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
static CONST_APTR functionTable[] = {
#ifdef OF_MORPHOS
	(CONST_APTR)FUNCARRAY_BEGIN,
	(CONST_APTR)FUNCARRAY_32BIT_NATIVE,