Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_printf_wrapper.c Source File

mbed_printf_wrapper.c

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2017 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifdef MBED_MINIMAL_PRINTF
00018 
00019 #include "mbed_printf_implementation.h"
00020 
00021 #include <limits.h>
00022 
00023 
00024 #if defined(__GNUC__)   /* GCC        */
00025 #define SUPER_PRINTF     __real_printf
00026 #define SUB_PRINTF       __wrap_printf
00027 #define SUPER_SPRINTF    __real_sprintf
00028 #define SUB_SPRINTF      __wrap_sprintf
00029 #define SUPER_SNPRINTF   __real_snprintf
00030 #define SUB_SNPRINTF     __wrap_snprintf
00031 #define SUPER_VPRINTF    __real_vprintf
00032 #define SUB_VPRINTF      __wrap_vprintf
00033 #define SUPER_VSPRINTF   __real_vsprintf
00034 #define SUB_VSPRINTF     __wrap_vsprintf
00035 #define SUPER_VSNPRINTF  __real_vsnprintf
00036 #define SUB_VSNPRINTF    __wrap_vsnprintf
00037 #define SUPER_FPRINTF  __real_fprintf
00038 #define SUB_FPRINTF    __wrap_fprintf
00039 #define SUPER_VFPRINTF __real_vfprintf
00040 #define SUB_VFPRINTF   __wrap_vfprintf
00041 #elif defined(TOOLCHAIN_ARM) /* ARMC5/ARMC6 */\
00042  || defined(__ICCARM__)      /* IAR        */
00043 #define SUPER_PRINTF     $Super$$printf
00044 #define SUB_PRINTF       $Sub$$printf
00045 #define SUPER_SPRINTF    $Super$$sprintf
00046 #define SUB_SPRINTF      $Sub$$sprintf
00047 #define SUPER_SNPRINTF   $Super$$snprintf
00048 #define SUB_SNPRINTF     $Sub$$snprintf
00049 #define SUPER_VPRINTF    $Super$$vprintf
00050 #define SUB_VPRINTF      $Sub$$vprintf
00051 #define SUPER_VSPRINTF   $Super$$vsprintf
00052 #define SUB_VSPRINTF     $Sub$$vsprintf
00053 #define SUPER_VSNPRINTF  $Super$$vsnprintf
00054 #define SUB_VSNPRINTF    $Sub$$vsnprintf
00055 #define SUPER_FPRINTF    $Super$$fprintf
00056 #define SUB_FPRINTF      $Sub$$fprintf
00057 #define SUPER_VFPRINTF   $Super$$vfprintf
00058 #define SUB_VFPRINTF     $Sub$$vfprintf
00059 #else
00060 #warning "This compiler is not yet supported."
00061 #endif
00062 
00063 int SUB_PRINTF(const char *format, ...)
00064 {
00065     va_list arguments;
00066     va_start(arguments, format);
00067     int result = mbed_minimal_formatted_string(NULL, LONG_MAX, format, arguments, stdout);
00068     va_end(arguments);
00069 
00070     return result;
00071 }
00072 
00073 int SUB_SPRINTF(char *buffer, const char *format, ...)
00074 {
00075     va_list arguments;
00076     va_start(arguments, format);
00077     int result = mbed_minimal_formatted_string(buffer, LONG_MAX, format, arguments, NULL);
00078     va_end(arguments);
00079 
00080     return result;
00081 }
00082 
00083 int SUB_SNPRINTF(char *buffer, size_t length, const char *format, ...)
00084 {
00085     va_list arguments;
00086     va_start(arguments, format);
00087     int result = mbed_minimal_formatted_string(buffer, length, format, arguments, NULL);
00088     va_end(arguments);
00089 
00090     return result;
00091 }
00092 
00093 int SUB_VPRINTF(const char *format, va_list arguments)
00094 {
00095     return mbed_minimal_formatted_string(NULL, LONG_MAX, format, arguments, stdout);
00096 }
00097 
00098 int SUB_VSPRINTF(char *buffer, const char *format, va_list arguments)
00099 {
00100     return mbed_minimal_formatted_string(buffer, LONG_MAX, format, arguments, NULL);
00101 }
00102 
00103 int SUB_VSNPRINTF(char *buffer, size_t length, const char *format, va_list arguments)
00104 {
00105     return mbed_minimal_formatted_string(buffer, length, format, arguments, NULL);
00106 }
00107 
00108 int SUB_FPRINTF(FILE *stream, const char *format, ...)
00109 {
00110     va_list arguments;
00111     va_start(arguments, format);
00112     int result = mbed_minimal_formatted_string(NULL, LONG_MAX, format, arguments, stream);
00113     va_end(arguments);
00114 
00115     return result;
00116 }
00117 
00118 int SUB_VFPRINTF(FILE *stream, const char *format, va_list arguments)
00119 {
00120     return mbed_minimal_formatted_string(NULL, LONG_MAX, format, arguments, stream);
00121 }
00122 
00123 #endif // MBED_MINIMAL_PRINTF