zephyr/lib/libc/minimal/source/stdout/fprintf.c
Peter Bigot 7cf9a8c102 libc: switch to cbprintf as basis for printf functionality
The minimal libc provided by Zephyr can use the Zephyr system
implementation rather than have its own implementation.

When combined with CBPRINTF_NANO some sprintf tests must be
skipped as they assume a more capable libc.  Add an overlay
that supports testing this non-default combination.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-11-13 06:38:01 -05:00

57 lines
938 B
C

/* fprintf.c */
/*
* Copyright (c) 1997-2010, 2013-2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdarg.h>
#include <stdio.h>
#include <sys/cbprintf.h>
#define DESC(d) ((void *)d)
int fprintf(FILE *_MLIBC_RESTRICT F, const char *_MLIBC_RESTRICT format, ...)
{
va_list vargs;
int r;
va_start(vargs, format);
r = cbvprintf(fputc, DESC(F), format, vargs);
va_end(vargs);
return r;
}
int vfprintf(FILE *_MLIBC_RESTRICT F, const char *_MLIBC_RESTRICT format,
va_list vargs)
{
int r;
r = cbvprintf(fputc, DESC(F), format, vargs);
return r;
}
int printf(const char *_MLIBC_RESTRICT format, ...)
{
va_list vargs;
int r;
va_start(vargs, format);
r = cbvprintf(fputc, DESC(stdout), format, vargs);
va_end(vargs);
return r;
}
int vprintf(const char *_MLIBC_RESTRICT format, va_list vargs)
{
int r;
r = cbvprintf(fputc, DESC(stdout), format, vargs);
return r;
}