1
0
Fork 0

change(printf): removed PRINTF_OVERRIDE_LIBC option

Removed the PRINTF_OVERRIDE_LIBC option. Basically this it not necessary and the ptintf() macro define can be used all the time.
development
Marco Paland 7 years ago
parent 735abbca13
commit 893c5056ff

@ -36,6 +36,14 @@
#include "printf.h" #include "printf.h"
// define this globally (e.g. gcc -DPRINTF_INCLUDE_CONFIG_H ...) to include the
// printf_config.h header file
// default: undefined
#ifdef PRINTF_INCLUDE_CONFIG_H
#include "printf_config.h"
#endif
// 'ntoa' conversion buffer size, this must be big enough to hold one converted // 'ntoa' conversion buffer size, this must be big enough to hold one converted
// numeric number including padded zeros (dynamically created on stack) // numeric number including padded zeros (dynamically created on stack)
// default: 32 byte // default: 32 byte
@ -699,11 +707,7 @@ static int _vsnprintf(out_fct_type out, char* buffer, const size_t maxlen, const
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#ifndef PRINTF_OVERRIDE_LIBC
int printf(const char* format, ...)
#else
int printf_(const char* format, ...) int printf_(const char* format, ...)
#endif
{ {
va_list va; va_list va;
va_start(va, format); va_start(va, format);
@ -714,11 +718,7 @@ int printf_(const char* format, ...)
} }
#ifndef PRINTF_OVERRIDE_LIBC
int sprintf(char* buffer, const char* format, ...)
#else
int sprintf_(char* buffer, const char* format, ...) int sprintf_(char* buffer, const char* format, ...)
#endif
{ {
va_list va; va_list va;
va_start(va, format); va_start(va, format);
@ -728,11 +728,7 @@ int sprintf_(char* buffer, const char* format, ...)
} }
#ifndef PRINTF_OVERRIDE_LIBC
int snprintf(char* buffer, size_t count, const char* format, ...)
#else
int snprintf_(char* buffer, size_t count, const char* format, ...) int snprintf_(char* buffer, size_t count, const char* format, ...)
#endif
{ {
va_list va; va_list va;
va_start(va, format); va_start(va, format);
@ -742,21 +738,13 @@ int snprintf_(char* buffer, size_t count, const char* format, ...)
} }
#ifndef PRINTF_OVERRIDE_LIBC
int vsnprintf(char* buffer, size_t count, const char* format, va_list va)
#else
int vsnprintf_(char* buffer, size_t count, const char* format, va_list va) int vsnprintf_(char* buffer, size_t count, const char* format, va_list va)
#endif
{ {
return _vsnprintf(_out_buffer, buffer, count, format, va); return _vsnprintf(_out_buffer, buffer, count, format, va);
} }
#ifndef PRINTF_OVERRIDE_LIBC
int fctprintf(void (*out)(char character, void* arg), void* arg, const char* format, ...) int fctprintf(void (*out)(char character, void* arg), void* arg, const char* format, ...)
#else
int fctprintf_(void (*out)(char character, void* arg), void* arg, const char* format, ...)
#endif
{ {
va_list va; va_list va;
va_start(va, format); va_start(va, format);

@ -35,13 +35,6 @@
#include <stdarg.h> #include <stdarg.h>
#include <stddef.h> #include <stddef.h>
// define this globally (e.g. gcc -DPRINTF_INCLUDE_CONFIG_H ...) to include the
// printf_config.h header file
// default: undefined
#ifdef PRINTF_INCLUDE_CONFIG_H
#include "printf_config.h"
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -56,19 +49,16 @@ extern "C" {
void _putchar(char character); void _putchar(char character);
// if PRINTF_OVERRIDE_LIBC is is defined, the regular printf() API is overridden by macro defines
// and internal underscore-appended functions like printf_() are used to avoid conflicts with
// LIBC defined printf() functions.
// default: undefined
#ifndef PRINTF_OVERRIDE_LIBC
/** /**
* Tiny printf implementation * Tiny printf implementation
* You have to implement _putchar if you use printf() * You have to implement _putchar if you use printf()
* To avoid conflicts with the regular printf() API it is overridden by macro defines
* and internal underscore-appended functions like printf_() are used
* \param format A string that specifies the format of the output * \param format A string that specifies the format of the output
* \return The number of characters that are written into the array, not counting the terminating null character * \return The number of characters that are written into the array, not counting the terminating null character
*/ */
int printf(const char* format, ...); #define printf printf_
int printf_(const char* format, ...);
/** /**
@ -78,7 +68,8 @@ int printf(const char* format, ...);
* \param format A string that specifies the format of the output * \param format A string that specifies the format of the output
* \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character * \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character
*/ */
int sprintf(char* buffer, const char* format, ...); #define sprintf sprintf_
int sprintf_(char* buffer, const char* format, ...);
/** /**
@ -89,8 +80,10 @@ int sprintf(char* buffer, const char* format, ...);
* \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character * \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character
* If the formatted string is truncated the buffer size (count) is returned * If the formatted string is truncated the buffer size (count) is returned
*/ */
int snprintf(char* buffer, size_t count, const char* format, ...); #define snprintf snprintf_
int vsnprintf(char* buffer, size_t count, const char* format, va_list va); #define vsnprintf vsnprintf_
int snprintf_(char* buffer, size_t count, const char* format, ...);
int vsnprintf_(char* buffer, size_t count, const char* format, va_list va);
/** /**
@ -103,23 +96,6 @@ int vsnprintf(char* buffer, size_t count, const char* format, va_list va);
*/ */
int fctprintf(void (*out)(char character, void* arg), void* arg, const char* format, ...); int fctprintf(void (*out)(char character, void* arg), void* arg, const char* format, ...);
#else // PRINTF_OVERRIDE_LIBC
// override the LIBC defined function names
#define printf printf_
#define sprintf sprintf_
#define snprintf snprintf_
#define vsnprintf vsnprintf_
#define fctprintf fctprintf_
int printf_(const char* format, ...);
int sprintf_(char* buffer, const char* format, ...);
int snprintf_(char* buffer, size_t count, const char* format, ...);
int vsnprintf_(char* buffer, size_t count, const char* format, va_list va);
int fctprintf_(void (*out)(char character, void* arg), void* arg, const char* format, ...);
#endif // PRINTF_OVERRIDE_LIBC
#ifdef __cplusplus #ifdef __cplusplus
} }

Loading…
Cancel
Save