2121#include <limits.h>
2222
2323
24- #if defined(__GNUC__ ) /* GCC */
25- #define SUPER_PRINTF __real_printf
26- #define SUB_PRINTF __wrap_printf
27- #define SUPER_SPRINTF __real_sprintf
28- #define SUB_SPRINTF __wrap_sprintf
29- #define SUPER_SNPRINTF __real_snprintf
30- #define SUB_SNPRINTF __wrap_snprintf
31- #define SUPER_VPRINTF __real_vprintf
32- #define SUB_VPRINTF __wrap_vprintf
33- #define SUPER_VSPRINTF __real_vsprintf
34- #define SUB_VSPRINTF __wrap_vsprintf
35- #define SUPER_VSNPRINTF __real_vsnprintf
36- #define SUB_VSNPRINTF __wrap_vsnprintf
37- #define SUPER_FPRINTF __real_fprintf
38- #define SUB_FPRINTF __wrap_fprintf
39- #define SUPER_VFPRINTF __real_vfprintf
40- #define SUB_VFPRINTF __wrap_vfprintf
41- #elif defined(TOOLCHAIN_ARM ) /* ARMC5/ARMC6 */ \
42- || defined(__ICCARM__ ) /* IAR */
43- #define SUPER_PRINTF $Super$$printf
44- #define SUB_PRINTF $Sub$$printf
45- #define SUPER_SPRINTF $Super$$sprintf
46- #define SUB_SPRINTF $Sub$$sprintf
47- #define SUPER_SNPRINTF $Super$$snprintf
48- #define SUB_SNPRINTF $Sub$$snprintf
49- #define SUPER_VPRINTF $Super$$vprintf
50- #define SUB_VPRINTF $Sub$$vprintf
51- #define SUPER_VSPRINTF $Super$$vsprintf
52- #define SUB_VSPRINTF $Sub$$vsprintf
53- #define SUPER_VSNPRINTF $Super$$vsnprintf
54- #define SUB_VSNPRINTF $Sub$$vsnprintf
55- #define SUPER_FPRINTF $Super$$fprintf
56- #define SUB_FPRINTF $Sub$$fprintf
57- #define SUPER_VFPRINTF $Super$$vfprintf
58- #define SUB_VFPRINTF $Sub$$vfprintf
24+ #if defined(__ARMCC_VERSION ) || defined(__ICCARM__ )
25+ # define PREFIX (x ) $Sub$$##x
26+ #elif defined(__GNUC__ )
27+ # define PREFIX (x ) __wrap_##x
5928#else
6029#warning "This compiler is not yet supported."
6130#endif
6231
63- int SUB_PRINTF (const char * format , ...)
32+ int PREFIX ( printf ) (const char * format , ...)
6433{
6534 va_list arguments ;
6635 va_start (arguments , format );
@@ -70,7 +39,7 @@ int SUB_PRINTF(const char *format, ...)
7039 return result ;
7140}
7241
73- int SUB_SPRINTF (char * buffer , const char * format , ...)
42+ int PREFIX ( sprintf ) (char * buffer , const char * format , ...)
7443{
7544 va_list arguments ;
7645 va_start (arguments , format );
@@ -80,7 +49,7 @@ int SUB_SPRINTF(char *buffer, const char *format, ...)
8049 return result ;
8150}
8251
83- int SUB_SNPRINTF (char * buffer , size_t length , const char * format , ...)
52+ int PREFIX ( snprintf ) (char * buffer , size_t length , const char * format , ...)
8453{
8554 va_list arguments ;
8655 va_start (arguments , format );
@@ -90,22 +59,22 @@ int SUB_SNPRINTF(char *buffer, size_t length, const char *format, ...)
9059 return result ;
9160}
9261
93- int SUB_VPRINTF (const char * format , va_list arguments )
62+ int PREFIX ( vprintf ) (const char * format , va_list arguments )
9463{
9564 return mbed_minimal_formatted_string (NULL , LONG_MAX , format , arguments , stdout );
9665}
9766
98- int SUB_VSPRINTF (char * buffer , const char * format , va_list arguments )
67+ int PREFIX ( vsprintf ) (char * buffer , const char * format , va_list arguments )
9968{
10069 return mbed_minimal_formatted_string (buffer , LONG_MAX , format , arguments , NULL );
10170}
10271
103- int SUB_VSNPRINTF (char * buffer , size_t length , const char * format , va_list arguments )
72+ int PREFIX ( vsnprintf ) (char * buffer , size_t length , const char * format , va_list arguments )
10473{
10574 return mbed_minimal_formatted_string (buffer , length , format , arguments , NULL );
10675}
10776
108- int SUB_FPRINTF (FILE * stream , const char * format , ...)
77+ int PREFIX ( fprintf ) (FILE * stream , const char * format , ...)
10978{
11079 va_list arguments ;
11180 va_start (arguments , format );
@@ -115,7 +84,7 @@ int SUB_FPRINTF(FILE *stream, const char *format, ...)
11584 return result ;
11685}
11786
118- int SUB_VFPRINTF (FILE * stream , const char * format , va_list arguments )
87+ int PREFIX ( vfprintf ) (FILE * stream , const char * format , va_list arguments )
11988{
12089 return mbed_minimal_formatted_string (NULL , LONG_MAX , format , arguments , stream );
12190}
0 commit comments