2 Copyright © 1995-2018, The AROS Development Team. All rights reserved.
5 C99 assert() stdc.library support
7 #include <proto/exec.h>
11 #include <aros/arossupportbase.h>
12 #include <intuition/intuition.h>
13 #include <aros/debug.h>
17 #include "__stdc_intbase.h"
18 #include "__optionallibs.h"
20 /*****************************************************************************
33 This is a function that is used for implementation of the C99 assert()
37 expr - The expression to evaluate. The type of the expression does
38 not matter, only if its zero/NULL or not.
39 file - Name of the source file.
40 line - Line number of assert() call.
43 The function doesn't return.
46 Different versions of this function are available. This function
47 is used when a program is using stdc.library but not
48 stdcio.library or posixc.library.
49 Because no normal DOS file I/O is available an attempt will be made
50 to display the assertion in a requester and thus deviating from the
51 C99 standard that says it to go to the error stream.
62 ******************************************************************************/
64 struct StdCIntBase
*StdCBase
=
65 (struct StdCIntBase
*)__aros_getbase_StdCBase();
67 if (__intuition_available(StdCBase
))
69 struct EasyStruct es
=
71 sizeof(struct EasyStruct
),
73 (CONST_STRPTR
)"Failed Assertion",
74 (CONST_STRPTR
)"Assertion (%s) failed in %s:%u",
78 stdcEasyRequest(StdCBase
->StdCIntuitionBase
, NULL
, &es
, NULL
, expr
, file
, line
);
81 kprintf("Assertion (%s) failed in %s:%u", expr
, file
, line
);
86 AROS_MAKE_ASM_SYM(typeof(__assert
), __assert
, AROS_CSYM_FROM_ASM_NAME(__assert
), AROS_CSYM_FROM_ASM_NAME(__stdc_assert
));
87 AROS_EXPORT_ASM_SYM(AROS_CSYM_FROM_ASM_NAME(__assert
));