mirror of
https://github.com/AntonioND/wf-picolibc.git
synced 2025-06-18 16:45:37 -04:00
libc/tinystdio: Rework how smaller printf functions work
Instead of using the C preprocessor to rename all of the printf and scanf functions, use the linker to re-direct the lowest level functions (vfprintf and vfscanf) to the custom versions. This requires placing the definition of the C preprocessor names on the compile and link lines where the .specs file can see them, but avoids linking multiple printf/scanf variants into applications. Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
ac0831a08c
commit
9d80f9c07b
@ -8,14 +8,33 @@ conversion operations might be needed by the application.
|
||||
|
||||
Picolibc handles this by providing multiple printf and scanf
|
||||
implementations in the library with varying levels of conversion
|
||||
support. The application developer selects among these at compile time
|
||||
based on knowledge of the requirements of the application. The
|
||||
selection is done using a preprocessor define which maps the
|
||||
public printf and scanf names to internal names.
|
||||
support. The application developer selects among these at compile and
|
||||
link time based on knowledge of the requirements of the
|
||||
application. The selection is done using a compiler command line
|
||||
definition of a preprocessor symbol which maps the public printf and
|
||||
scanf names to internal names in the linker.
|
||||
|
||||
The function name mapping happens in stdio.h, so the preprocessor
|
||||
definition must be set before stdio.h is included the first time. This
|
||||
is easily done by adding the flag to the compiler command line.
|
||||
The function name mapping happens in picolibc.specs file which scans
|
||||
the compiler command line looking for the preprocessor token and uses
|
||||
that to add --defsym options when linking. This means the preprocessor
|
||||
definition must be set on the command line and not in a file.
|
||||
|
||||
Using the defsym approach, rather than renaming the functions with the
|
||||
C preprocessor has a couple of benefits:
|
||||
|
||||
* Printf uses within picolibc (which are all integer-only) now share
|
||||
whichever printf the application needs, avoiding including both
|
||||
integer-only and float versions
|
||||
|
||||
* Printf optimizations in the compiler which map to puts or fputs now
|
||||
work even when using integer-only or float printf functions.
|
||||
|
||||
Because the linker gets --defsym flags for both vfprintf and vfscanf,
|
||||
those functions will always get included in the link process. To avoid
|
||||
linking them into the application when they aren't otherwise needed,
|
||||
picolibc.specs includes the --gc-sections linker flag. This causes
|
||||
those functions to be discarded if they aren't used in the
|
||||
application.
|
||||
|
||||
## Printf and Scanf levels in Picolibc
|
||||
|
||||
@ -26,15 +45,24 @@ be selected when building applications:
|
||||
both float and double conversions. This is what you get with no
|
||||
pre-processor definition.
|
||||
|
||||
* PICOLIBC_INTEGER_PRINTF_SCANF. This removes support for all
|
||||
float and double conversions.
|
||||
* PICOLIBC_INTEGER_PRINTF_SCANF. This removes support for all float
|
||||
and double conversions. The picolibc.specs stanza that matches this
|
||||
option maps __i_vfprintf to vfprintf and __i_vfscanf to
|
||||
vfscanf. This is equivalent to adding this when linking your
|
||||
application:
|
||||
|
||||
cc -Wl,--defsym=vfprintf=__i_vfprintf -Wl,--defsym=vfscanf=__i_vfscanf
|
||||
|
||||
* PICOLIBC_FLOAT_PRINTF_SCANF. This provides support for float, but
|
||||
not double conversions. To use this mode, float values must be
|
||||
passed to printf using the printf_float macro.
|
||||
not double conversions. When picolibc.specs finds
|
||||
-DPICOLIBC_FLOAT_PRINTF_SCANF on the command line during linking,
|
||||
it maps __f_vfprintf to vfprintf and __f_vfscanf to vfscanf. This
|
||||
is equivalent to adding this when linking your application:
|
||||
|
||||
PICOLIBC_FLOAT_PRINTF_SCANF requires a special macro for float
|
||||
values, to make it easier to switch between that and the default
|
||||
cc -Wl,--defsym=vfprintf=__i_vfprintf -Wl,--defsym=vfscanf=__i_vfscanf
|
||||
|
||||
PICOLIBC_FLOAT_PRINTF_SCANF requires a special macro for float values:
|
||||
`printf_float`. To make it easier to switch between that and the default
|
||||
level, that macro is also correctly defined for the other two levels.
|
||||
|
||||
Here's an example program to experiment with these options:
|
||||
@ -50,7 +78,7 @@ Now we can build and run it with the default options:
|
||||
$ riscv64-unknown-elf-gcc -Os -march=rv32imac -mabi=ilp32 --specs=picolibc.specs --oslib=semihost -Wl,--defsym=__flash=0x80000000 -Wl,--defsym=__flash_size=0x00200000 -Wl,--defsym=__ram=0x80200000 -Wl,--defsym=__ram_size=0x200000 -o printf.elf printf.c
|
||||
$ riscv64-unknown-elf-size printf.elf
|
||||
text data bss dec hex filename
|
||||
9284 16 8 9308 245c printf.elf
|
||||
8998 24 8 9030 2346 printf.elf
|
||||
$ qemu-system-riscv32 -chardev stdio,mux=on,id=stdio0 -semihosting-config enable=on,chardev=stdio0 -monitor none -serial none -machine virt,accel=tcg -kernel printf.elf -nographic -bios none
|
||||
2⁶¹ = 2305843009213693952 π ≃ 3.141592653589793
|
||||
|
||||
@ -60,7 +88,7 @@ although the floating point value has reduced precision:
|
||||
$ riscv64-unknown-elf-gcc -DPICOLIBC_FLOAT_PRINTF_SCANF -Os -march=rv32imac -mabi=ilp32 --specs=picolibc.specs --oslib=semihost -Wl,--defsym=__flash=0x80000000 -Wl,--defsym=__flash_size=0x00200000 -Wl,--defsym=__ram=0x80200000 -Wl,--defsym=__ram_size=0x200000 -o printf-float.elf printf.c
|
||||
$ riscv64-unknown-elf-size printf-float.elf
|
||||
text data bss dec hex filename
|
||||
6540 16 8 6564 19a4 printf-float.elf
|
||||
6214 24 8 6246 1866 printf-float.elf
|
||||
$ qemu-system-riscv32 -chardev stdio,mux=on,id=stdio0 -semihosting-config enable=on,chardev=stdio0 -monitor none -serial none -machine virt,accel=tcg -kernel printf-float.elf -nographic -bios none
|
||||
2⁶¹ = 2305843009213693952 π ≃ 3.1415927
|
||||
|
||||
@ -70,7 +98,7 @@ the values correctly:
|
||||
$ riscv64-unknown-elf-gcc -DPICOLIBC_INTEGER_PRINTF_SCANF -Os -march=rv32imac -mabi=ilp32 --specs=picolibc.specs --oslib=semihost -Wl,--defsym=__flash=0x80000000 -Wl,--defsym=__flash_size=0x00200000 -Wl,--defsym=__ram=0x80200000 -Wl,--defsym=__ram_size=0x200000 -o printf-int.elf printf.c
|
||||
$ riscv64-unknown-elf-size printf-int.elf
|
||||
text data bss dec hex filename
|
||||
2336 16 8 2360 938 printf-int.elf
|
||||
2266 24 8 2298 8fa printf-int.elf
|
||||
$ qemu-system-riscv32 -chardev stdio,mux=on,id=stdio0 -semihosting-config enable=on,chardev=stdio0 -monitor none -serial none -machine virt,accel=tcg -kernel printf-int.elf -nographic -bios none
|
||||
2⁶¹ = 0 π ≃ *float*
|
||||
|
||||
|
23
meson.build
23
meson.build
@ -253,12 +253,31 @@ specs_data.set(
|
||||
specs_extra
|
||||
)
|
||||
|
||||
if tinystdio
|
||||
specs_printf=('%{DPICOLIBC_FLOAT_PRINTF_SCANF:--defsym=vfprintf=__f_vfprintf}' +
|
||||
' %{DPICOLIBC_FLOAT_PRINTF_SCANF:--defsym=vfscanf=__f_vfscanf}' +
|
||||
' %{DPICOLIBC_INTEGER_PRINTF_SCANF:--defsym=vfprintf=__i_vfprintf}' +
|
||||
' %{DPICOLIBC_INTEGER_PRINTF_SCANF:--defsym=vfscanf=__i_vfscanf}')
|
||||
else
|
||||
specs_printf=''
|
||||
endif
|
||||
|
||||
specs_data.set(
|
||||
'SPECS_PRINTF',
|
||||
specs_printf
|
||||
)
|
||||
|
||||
picolibc_specs = configure_file(input: 'picolibc.specs.in',
|
||||
output: '@BASENAME@',
|
||||
configuration: specs_data,
|
||||
install_dir: specs_dir,
|
||||
install: true)
|
||||
|
||||
test_specs = configure_file(input: 'test.specs.in',
|
||||
output: '@BASENAME@',
|
||||
configuration: specs_data,
|
||||
install: false)
|
||||
|
||||
install_data('picolibc.ld',
|
||||
install_dir: lib_dir)
|
||||
|
||||
@ -551,6 +570,10 @@ if has_semihost
|
||||
# Make sure all of the tests get re-linked if the linker scripts change
|
||||
|
||||
test_link_depends += test_link_dep + files('picolibc.ld') + [picolibc_specs]
|
||||
else
|
||||
test_link_depends += test_specs
|
||||
test_c_args += ['--specs', '@0@/@1@'.format(meson.current_build_dir(), test_specs)]
|
||||
test_link_args += test_c_args
|
||||
endif
|
||||
|
||||
subdir('picocrt')
|
||||
|
@ -59,7 +59,7 @@ __assert_func (const char *file,
|
||||
const char *func,
|
||||
const char *failedexpr)
|
||||
{
|
||||
__i_fprintf(stderr,
|
||||
fprintf(stderr,
|
||||
"assertion \"%s\" failed: file \"%s\", line %d%s%s\n",
|
||||
failedexpr, file, line,
|
||||
func ? ", function: " : "", func ? func : "");
|
||||
|
@ -24,7 +24,7 @@ __eprintf (format, file, line, expression)
|
||||
unsigned int line;
|
||||
const char *expression;
|
||||
{
|
||||
(void) __i_fprintf (stderr, format, file, line, expression);
|
||||
(void) fprintf (stderr, format, file, line, expression);
|
||||
abort ();
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ not portable.
|
||||
void
|
||||
mstats (char *s)
|
||||
{
|
||||
__i_fprintf (stderr, "Memory allocation statistics %s\n", s);
|
||||
fprintf (stderr, "Memory allocation statistics %s\n", s);
|
||||
malloc_stats ();
|
||||
}
|
||||
|
||||
|
@ -369,18 +369,18 @@ void nano_free (void * free_p)
|
||||
if (!q || p_to_free->signature != 0xbeeff00d) {
|
||||
int i;
|
||||
chunk *busy;
|
||||
__i_fprintf(stderr, "Free block which is not busy\n");
|
||||
fprintf(stderr, "Free block which is not busy\n");
|
||||
for (busy = busy_list; busy; busy = busy->busy) {
|
||||
int i;
|
||||
__i_fprintf(stderr, " 0x%08x %10lu:", (unsigned) (uintptr_t) busy, busy->size);
|
||||
fprintf(stderr, " 0x%08x %10lu:", (unsigned) (uintptr_t) busy, busy->size);
|
||||
for (i = 0; i < busy->malloc_backtrace_len; i++)
|
||||
__i_fprintf(stderr, " 0x%08x", (unsigned) (uintptr_t) busy->malloc_backtrace[i]);
|
||||
__i_fprintf(stderr, "\n");
|
||||
fprintf(stderr, " 0x%08x", (unsigned) (uintptr_t) busy->malloc_backtrace[i]);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
__i_fprintf(stderr, " 0x%08x %10lu:", (unsigned) (uintptr_t) p_to_free, p_to_free->size);
|
||||
fprintf(stderr, " 0x%08x %10lu:", (unsigned) (uintptr_t) p_to_free, p_to_free->size);
|
||||
for (i = 0; i < p_to_free->free_backtrace_len; i++)
|
||||
__i_fprintf(stderr, " 0x%08x", (unsigned) (uintptr_t) p_to_free->free_backtrace[i]);
|
||||
__i_fprintf(stderr, "\n");
|
||||
fprintf(stderr, " 0x%08x", (unsigned) (uintptr_t) p_to_free->free_backtrace[i]);
|
||||
fprintf(stderr, "\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -560,11 +560,11 @@ struct mallinfo nano_mallinfo(void)
|
||||
void nano_malloc_stats(void)
|
||||
{
|
||||
nano_mallinfo();
|
||||
__i_fprintf(stderr, "max system bytes = %10zu\n",
|
||||
fprintf(stderr, "max system bytes = %10zu\n",
|
||||
current_mallinfo.arena);
|
||||
__i_fprintf(stderr, "system bytes = %10zu\n",
|
||||
fprintf(stderr, "system bytes = %10zu\n",
|
||||
current_mallinfo.arena);
|
||||
__i_fprintf(stderr, "in use bytes = %10zu\n",
|
||||
fprintf(stderr, "in use bytes = %10zu\n",
|
||||
current_mallinfo.uordblks);
|
||||
#ifdef MALLOC_DEBUG
|
||||
chunk *busy;
|
||||
@ -573,12 +573,12 @@ void nano_malloc_stats(void)
|
||||
for (busy = busy_list; busy; busy = busy->busy) {
|
||||
int i;
|
||||
total_busy += busy->size;
|
||||
__i_fprintf(stderr, " 0x%08x %10zu:", (unsigned) (uintptr_t) busy, busy->size);
|
||||
fprintf(stderr, " 0x%08x %10zu:", (unsigned) (uintptr_t) busy, busy->size);
|
||||
for (i = 0; i < busy->malloc_backtrace_len; i++)
|
||||
__i_fprintf(stderr, " 0x%08x", (unsigned) (uintptr_t) busy->malloc_backtrace[i]);
|
||||
__i_fprintf(stderr, "\n");
|
||||
fprintf(stderr, " 0x%08x", (unsigned) (uintptr_t) busy->malloc_backtrace[i]);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
__i_fprintf(stderr, "busy bytes = %10u\n", total_busy);
|
||||
fprintf(stderr, "busy bytes = %10u\n", total_busy);
|
||||
#endif
|
||||
}
|
||||
#endif /* DEFINE_MALLOC_STATS */
|
||||
|
@ -60,7 +60,7 @@ strsignal (int signal)
|
||||
buffer = _signal_buf;
|
||||
#if defined(SIGRTMIN) && defined(SIGRTMAX)
|
||||
if ((signal >= SIGRTMIN) && (signal <= SIGRTMAX)) {
|
||||
__i_sprintf (buffer, "Real-time signal %d", signal - SIGRTMIN);
|
||||
sprintf (buffer, "Real-time signal %d", signal - SIGRTMIN);
|
||||
return buffer;
|
||||
}
|
||||
#endif
|
||||
@ -236,7 +236,7 @@ strsignal (int signal)
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
__i_sprintf (buffer, "Unknown signal %d", signal);
|
||||
sprintf (buffer, "Unknown signal %d", signal);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ asctime_r (const struct tm *__restrict tim_p,
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||
};
|
||||
|
||||
__i_sprintf (result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
|
||||
sprintf (result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
|
||||
day_name[tim_p->tm_wday],
|
||||
mon_name[tim_p->tm_mon],
|
||||
tim_p->tm_mday, tim_p->tm_hour, tim_p->tm_min,
|
||||
|
@ -295,7 +295,6 @@ locale, hard-coding the "C" locale settings.
|
||||
# define CQ(a) a /* character constant qualifier */
|
||||
# define SFLG /* %s flag (null for normal char) */
|
||||
# define _ctloc(x) (ctloclen = strlen (ctloc = _CurrentTimeLocale->x))
|
||||
# define snprintf __i_snprintf /* avoid to pull in FP functions. */
|
||||
# define TOLOWER(c) tolower((int)(unsigned char)(c))
|
||||
# define STRTOUL(c,p,b) strtoul((c),(p),(b))
|
||||
# define STRCPY(a,b) strcpy((a),(b))
|
||||
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
|
||||
#include <asnprintf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
|
||||
#include <asprintf.c>
|
@ -45,4 +45,14 @@ ecvtfbuf (float invalue,
|
||||
int *sign,
|
||||
char *ecvt_buf)
|
||||
{
|
||||
struct ftoa ftoa;
|
||||
|
||||
if (ndigit > FTOA_MAX_DIG)
|
||||
ndigit = FTOA_MAX_DIG;
|
||||
ndigit = __ftoa_engine(invalue, &ftoa, ndigit, 0);
|
||||
*sign = ftoa.flags & FTOA_MINUS;
|
||||
*decpt = ftoa.exp + 1;
|
||||
memcpy(ecvt_buf, ftoa.digits, ndigit);
|
||||
ecvt_buf[ndigit] = '\0';
|
||||
return ecvt_buf;
|
||||
}
|
||||
|
@ -45,4 +45,17 @@ fcvtfbuf(float invalue,
|
||||
int *sign,
|
||||
char *fcvt_buf)
|
||||
{
|
||||
struct ftoa ftoa;
|
||||
int ndigit;
|
||||
|
||||
ndigit = __ftoa_engine(invalue, &ftoa, FTOA_MAX_DIG, ndecimal + 1);
|
||||
*sign = ftoa.flags & FTOA_MINUS;
|
||||
if (ndigit > 0)
|
||||
*decpt = ftoa.exp + 1;
|
||||
else {
|
||||
*decpt = -ndecimal;
|
||||
}
|
||||
memcpy(fcvt_buf, ftoa.digits, ndigit);
|
||||
fcvt_buf[ndigit] = '\0';
|
||||
return fcvt_buf;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ int
|
||||
fgetc(FILE *stream)
|
||||
{
|
||||
int rv;
|
||||
uint16_t unget;
|
||||
__ungetc_t unget;
|
||||
|
||||
if ((stream->flags & __SRD) == 0)
|
||||
return EOF;
|
||||
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_INTEGER_PRINTF_SCANF
|
||||
|
||||
#include <fprintf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_INTEGER_PRINTF_SCANF
|
||||
|
||||
#include <fscanf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
|
||||
#include <fprintf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
|
||||
#include <fscanf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
|
||||
#include <fsnprintf.c>
|
@ -37,13 +37,13 @@
|
||||
#define _XOPEN_SOURCE_EXTENDED
|
||||
#include <_ansi.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "stdio_private.h"
|
||||
|
||||
char *
|
||||
gcvt (double invalue,
|
||||
int ndigit,
|
||||
char *buf)
|
||||
{
|
||||
sprintf(buf, "%.*g", ndigit, invalue);
|
||||
__d_sprintf(buf, "%.*g", ndigit, invalue);
|
||||
return buf;
|
||||
}
|
||||
|
@ -35,16 +35,16 @@
|
||||
|
||||
#define _XOPEN_SOURCE
|
||||
#define _XOPEN_SOURCE_EXTENDED
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
#include <_ansi.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "stdio_private.h"
|
||||
|
||||
char *
|
||||
gcvtf (float invalue,
|
||||
int ndigit,
|
||||
char *buf)
|
||||
{
|
||||
sprintf(buf, "%.*g", ndigit, printf_float(invalue));
|
||||
__f_sprintf(buf, "%.*g", ndigit, __printf_float(invalue));
|
||||
return buf;
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_INTEGER_PRINTF_SCANF
|
||||
|
||||
#include <printf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_INTEGER_PRINTF_SCANF
|
||||
|
||||
#include <scanf.c>
|
@ -36,14 +36,18 @@ srcs_tinystdio = [
|
||||
'clearerr.c',
|
||||
'ecvt_data.c',
|
||||
'ecvtf_data.c',
|
||||
'ecvtbuf.c',
|
||||
'ecvt.c',
|
||||
'ecvtbuf.c',
|
||||
'ecvtf.c',
|
||||
'ecvtfbuf.c',
|
||||
'fcvtbuf.c',
|
||||
'fcvt.c',
|
||||
'fcvtf.c',
|
||||
'fcvtfbuf.c',
|
||||
'gcvt.c',
|
||||
'gcvtbuf.c',
|
||||
'gcvtf.c',
|
||||
'gcvtfbuf.c',
|
||||
'fclose.c',
|
||||
'fdevopen.c',
|
||||
'feof.c',
|
||||
@ -54,62 +58,42 @@ srcs_tinystdio = [
|
||||
'fileno.c',
|
||||
'filestrget.c',
|
||||
'filestrput.c',
|
||||
'fiprintf.c',
|
||||
'fiscanf.c',
|
||||
'fprintf.c',
|
||||
'fprintff.c',
|
||||
'fputc.c',
|
||||
'fputs.c',
|
||||
'fread.c',
|
||||
'fscanf.c',
|
||||
'fscanff.c',
|
||||
'fseek.c',
|
||||
'ftell.c',
|
||||
'fwrite.c',
|
||||
'getchar.c',
|
||||
'gets.c',
|
||||
'iprintf.c',
|
||||
'iscanf.c',
|
||||
'perror.c',
|
||||
'printf.c',
|
||||
'printff.c',
|
||||
'putc.c',
|
||||
'putchar.c',
|
||||
'puts.c',
|
||||
'scanf.c',
|
||||
'scanff.c',
|
||||
'setbuf.c',
|
||||
'siprintf.c',
|
||||
'siscanf.c',
|
||||
'sniprintf.c',
|
||||
'snprintf.c',
|
||||
'snprintff.c',
|
||||
'sprintf.c',
|
||||
'sprintff.c',
|
||||
'sprintfd.c',
|
||||
'sscanf.c',
|
||||
'sscanff.c',
|
||||
'strtof.c',
|
||||
'strtod.c',
|
||||
'strtod_l.c',
|
||||
'ungetc.c',
|
||||
'vfiprintf.c',
|
||||
'vfiscanf.c',
|
||||
'vfprintf.c',
|
||||
'vfprintff.c',
|
||||
'vfscanf.c',
|
||||
'vfiscanf.c',
|
||||
'vfscanff.c',
|
||||
'viprintf.c',
|
||||
'viscanf.c',
|
||||
'vprintf.c',
|
||||
'vprintff.c',
|
||||
'vscanf.c',
|
||||
'vscanff.c',
|
||||
'vsiprintf.c',
|
||||
'vsniprintf.c',
|
||||
'vsnprintf.c',
|
||||
'vsnprintff.c',
|
||||
'vsprintf.c',
|
||||
'vsprintff.c',
|
||||
]
|
||||
|
||||
# exact float/string conversion code
|
||||
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
|
||||
#include <printf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
|
||||
#include <scanf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_INTEGER_PRINTF_SCANF
|
||||
|
||||
#include <sscanf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_INTEGER_PRINTF_SCANF
|
||||
|
||||
#include <snprintf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
|
||||
#include <snprintf.c>
|
@ -30,6 +30,7 @@
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_INTEGER_PRINTF_SCANF
|
||||
#define vfprintf __d_vfprintf
|
||||
#define sprintf __d_sprintf
|
||||
|
||||
#include <sprintf.c>
|
@ -30,6 +30,7 @@
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
#define vfprintf __f_vfprintf
|
||||
#define sprintf __f_sprintf
|
||||
|
||||
#include <sprintf.c>
|
||||
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
|
||||
#include "sscanf.c"
|
@ -571,14 +571,20 @@ extern int fclose(FILE *__stream);
|
||||
*/
|
||||
|
||||
#ifdef HAVE_FORMAT_ATTRIBUTE
|
||||
#define __FORMAT_ATTRIBUTE__(...) __attribute__((__format__ (__VA_ARGS__)))
|
||||
#ifdef PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
#pragma GCC diagnostic ignored "-Wformat"
|
||||
#define __FORMAT_ATTRIBUTE__(__a, __s, __f) __attribute__((__format__ (__a, __s, 0)))
|
||||
#else
|
||||
#define __FORMAT_ATTRIBUTE__(...)
|
||||
#define __FORMAT_ATTRIBUTE__(__a, __s, __f) __attribute__((__format__ (__a, __s, __f)))
|
||||
#endif
|
||||
#else
|
||||
#define __FORMAT_ATTRIBUTE__(__a, __s, __f)
|
||||
#endif
|
||||
|
||||
extern int vfprintf(FILE *__stream, const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(printf, 2, 0);
|
||||
extern int __i_vfprintf(FILE *__stream, const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(printf, 2, 0);
|
||||
extern int __f_vfprintf(FILE *__stream, const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(printf, 2, 0);
|
||||
#define __PRINTF_ATTRIBUTE__(__s, __f) __FORMAT_ATTRIBUTE__(printf, __s, __f)
|
||||
#define __SCANF_ATTRIBUTE__(__s, _f) __FORMAT_ATTRIBUTE__(scanf, __s, __f)
|
||||
|
||||
int vfprintf(FILE *__stream, const char *__fmt, va_list __ap) __PRINTF_ATTRIBUTE__(2, 0);
|
||||
|
||||
/**
|
||||
The function \c fputc sends the character \c c (though given as type
|
||||
@ -613,9 +619,8 @@ extern int putchar(int __c);
|
||||
The function \c printf performs formatted output to stream
|
||||
\c stdout. See \c vfprintf() for details.
|
||||
*/
|
||||
extern int printf(const char *__fmt, ...) __FORMAT_ATTRIBUTE__(printf, 1, 2);
|
||||
extern int __i_printf(const char *__fmt, ...) __FORMAT_ATTRIBUTE__(printf, 1, 2);
|
||||
extern int __f_printf(const char *__fmt, ...) __FORMAT_ATTRIBUTE__(printf, 1, 0);
|
||||
|
||||
int printf(const char *__fmt, ...) __PRINTF_ATTRIBUTE__(1, 2);
|
||||
|
||||
/**
|
||||
The function \c vprintf performs formatted output to stream
|
||||
@ -623,17 +628,13 @@ extern int __f_printf(const char *__fmt, ...) __FORMAT_ATTRIBUTE__(printf, 1, 0)
|
||||
|
||||
See vfprintf() for details.
|
||||
*/
|
||||
extern int vprintf(const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(printf, 1, 0);
|
||||
extern int __i_vprintf(const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(printf, 1, 0);
|
||||
extern int __f_vprintf(const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(printf, 1, 0);
|
||||
extern int vprintf(const char *__fmt, va_list __ap) __PRINTF_ATTRIBUTE__(1, 0);
|
||||
|
||||
/**
|
||||
Variant of \c printf() that sends the formatted characters
|
||||
to string \c s.
|
||||
*/
|
||||
extern int sprintf(char *__s, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(printf, 2, 3);
|
||||
extern int __i_sprintf(char *__s, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(printf, 2, 3);
|
||||
extern int __f_sprintf(char *__s, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(printf, 2, 0);
|
||||
extern int sprintf(char *__s, const char *__fmt, ...) __PRINTF_ATTRIBUTE__(2, 3);
|
||||
|
||||
/**
|
||||
Like \c sprintf(), but instead of assuming \c s to be of infinite
|
||||
@ -643,17 +644,13 @@ extern int __f_sprintf(char *__s, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(p
|
||||
Returns the number of characters that would have been written to
|
||||
\c s if there were enough space.
|
||||
*/
|
||||
extern int snprintf(char *__s, size_t __n, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(printf, 3, 4);
|
||||
extern int __i_snprintf(char *__s, size_t __n, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(printf, 3, 4);
|
||||
extern int __f_snprintf(char *__s, size_t __n, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(printf, 3, 0);
|
||||
extern int snprintf(char *__s, size_t __n, const char *__fmt, ...) __PRINTF_ATTRIBUTE__(3, 4);
|
||||
|
||||
/**
|
||||
Like \c sprintf() but takes a variable argument list for the
|
||||
arguments.
|
||||
*/
|
||||
extern int vsprintf(char *__s, const char *__fmt, va_list ap) __FORMAT_ATTRIBUTE__(printf, 2, 0);
|
||||
extern int __i_vsprintf(char *__s, const char *__fmt, va_list ap) __FORMAT_ATTRIBUTE__(printf, 2, 0);
|
||||
extern int __f_vsprintf(char *__s, const char *__fmt, va_list ap) __FORMAT_ATTRIBUTE__(printf, 2, 0);
|
||||
extern int vsprintf(char *__s, const char *__fmt, va_list ap) __PRINTF_ATTRIBUTE__(2, 0);
|
||||
|
||||
/**
|
||||
Like \c vsprintf(), but instead of assuming \c s to be of infinite
|
||||
@ -663,17 +660,13 @@ extern int __f_vsprintf(char *__s, const char *__fmt, va_list ap) __FORMAT_ATTRI
|
||||
Returns the number of characters that would have been written to
|
||||
\c s if there were enough space.
|
||||
*/
|
||||
extern int vsnprintf(char *__s, size_t __n, const char *__fmt, va_list ap) __FORMAT_ATTRIBUTE__(printf, 3, 0);
|
||||
extern int __i_vsnprintf(char *__s, size_t __n, const char *__fmt, va_list ap) __FORMAT_ATTRIBUTE__(printf, 3, 0);
|
||||
extern int __f_vsnprintf(char *__s, size_t __n, const char *__fmt, va_list ap) __FORMAT_ATTRIBUTE__(printf, 3, 0);
|
||||
extern int vsnprintf(char *__s, size_t __n, const char *__fmt, va_list ap) __PRINTF_ATTRIBUTE__(3, 0);
|
||||
|
||||
/**
|
||||
The function \c fprintf performs formatted output to \c stream.
|
||||
See \c vfprintf() for details.
|
||||
*/
|
||||
extern int fprintf(FILE *__stream, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(printf, 2, 3);
|
||||
extern int __i_fprintf(FILE *__stream, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(printf, 2, 3);
|
||||
extern int __f_fprintf(FILE *__stream, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(printf, 2, 0);
|
||||
extern int fprintf(FILE *__stream, const char *__fmt, ...) __PRINTF_ATTRIBUTE__(2, 3);
|
||||
|
||||
/**
|
||||
Write the string pointed to by \c str to stream \c stream.
|
||||
@ -809,8 +802,6 @@ extern int ferror(FILE *__stream);
|
||||
#endif /* !defined(__DOXYGEN__) */
|
||||
|
||||
extern int vfscanf(FILE *__stream, const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(scanf, 2, 0);
|
||||
extern int __i_vfscanf(FILE *__stream, const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(scanf, 2, 0);
|
||||
extern int __f_vfscanf(FILE *__stream, const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(scanf, 2, 0);
|
||||
|
||||
/**
|
||||
The function \c fscanf performs formatted input, reading the
|
||||
@ -819,8 +810,6 @@ extern int __f_vfscanf(FILE *__stream, const char *__fmt, va_list __ap) __FORMAT
|
||||
See vfscanf() for details.
|
||||
*/
|
||||
extern int fscanf(FILE *__stream, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(scanf, 2, 3);
|
||||
extern int __i_fscanf(FILE *__stream, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(scanf, 2, 3);
|
||||
extern int __f_fscanf(FILE *__stream, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(scanf, 2, 3);
|
||||
|
||||
/**
|
||||
The function \c scanf performs formatted input from stream \c stdin.
|
||||
@ -828,8 +817,6 @@ extern int __f_fscanf(FILE *__stream, const char *__fmt, ...) __FORMAT_ATTRIBUTE
|
||||
See vfscanf() for details.
|
||||
*/
|
||||
extern int scanf(const char *__fmt, ...) __FORMAT_ATTRIBUTE__(scanf, 1, 2);
|
||||
extern int __i_scanf(const char *__fmt, ...) __FORMAT_ATTRIBUTE__(scanf, 1, 2);
|
||||
extern int __f_scanf(const char *__fmt, ...) __FORMAT_ATTRIBUTE__(scanf, 1, 2);
|
||||
|
||||
/**
|
||||
The function \c vscanf performs formatted input from stream
|
||||
@ -838,8 +825,6 @@ extern int __f_scanf(const char *__fmt, ...) __FORMAT_ATTRIBUTE__(scanf, 1, 2);
|
||||
See vfscanf() for details.
|
||||
*/
|
||||
extern int vscanf(const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(scanf, 1, 0);
|
||||
extern int __i_vscanf(const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(scanf, 1, 0);
|
||||
extern int __f_vscanf(const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(scanf, 1, 0);
|
||||
|
||||
/**
|
||||
The function \c sscanf performs formatted input, reading the
|
||||
@ -848,8 +833,6 @@ extern int __f_vscanf(const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(scan
|
||||
See vfscanf() for details.
|
||||
*/
|
||||
extern int sscanf(const char *__buf, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(scanf, 2, 3);
|
||||
extern int __i_sscanf(const char *__buf, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(scanf, 2, 3);
|
||||
extern int __f_sscanf(const char *__buf, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(scanf, 2, 3);
|
||||
|
||||
/**
|
||||
Flush \c stream.
|
||||
@ -903,55 +886,6 @@ extern char *tmpnam (char *s);
|
||||
|
||||
#endif /* __ASSEMBLER */
|
||||
|
||||
#ifdef NEWLIB_INTEGER_PRINTF_SCANF
|
||||
#define PICOLIBC_INTEGER_PRINTF_SCANF
|
||||
#endif
|
||||
|
||||
#ifdef PICOLIBC_INTEGER_PRINTF_SCANF
|
||||
|
||||
#define PRINTF_LEVEL PRINTF_STD
|
||||
#define SCANF_LEVEL SCANF_STD
|
||||
|
||||
#define vsnprintf __i_vsnprintf
|
||||
#define vfprintf __i_vfprintf
|
||||
#define vprintf __i_vprintf
|
||||
#define fprintf __i_fprintf
|
||||
#define printf __i_printf
|
||||
#define sprintf __i_sprintf
|
||||
#define snprintf __i_snprintf
|
||||
#define asprintf __i_asprintf
|
||||
#define asnprintf __i_asnprintf
|
||||
|
||||
#define vfscanf __i_vfscanf
|
||||
#define scanf __i_scanf
|
||||
#define fscanf __i_fscanf
|
||||
#define sscanf __i_sscanf
|
||||
|
||||
#else
|
||||
|
||||
#ifdef PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
|
||||
#define vsnprintf __f_vsnprintf
|
||||
#define vfprintf __f_vfprintf
|
||||
#define vprintf __f_vprintf
|
||||
#define fprintf __f_fprintf
|
||||
#define printf __f_printf
|
||||
#define sprintf __f_sprintf
|
||||
#define snprintf __f_snprintf
|
||||
#define asprintf __f_asprintf
|
||||
#define asnprintf __f_asnprintf
|
||||
|
||||
#define vfscanf __f_vfscanf
|
||||
#define scanf __f_scanf
|
||||
#define fscanf __f_fscanf
|
||||
#define sscanf __f_sscanf
|
||||
|
||||
#define printf_float(x) __printf_float(x)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
static __inline uint32_t
|
||||
__printf_float(float f)
|
||||
{
|
||||
@ -962,7 +896,9 @@ __printf_float(float f)
|
||||
return u.u;
|
||||
}
|
||||
|
||||
#ifndef printf_float
|
||||
#ifdef PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
#define printf_float(x) __printf_float(x)
|
||||
#else
|
||||
#define printf_float(x) ((double) (x))
|
||||
#endif
|
||||
|
||||
|
@ -98,6 +98,12 @@ struct __file_posix {
|
||||
int read_off;
|
||||
};
|
||||
|
||||
int __d_vfprintf(FILE *__stream, const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(printf, 2, 0);
|
||||
int __f_vfprintf(FILE *__stream, const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(printf, 2, 0);
|
||||
|
||||
int __d_sprintf(char *__s, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(printf, 2, 0);
|
||||
int __f_sprintf(char *__s, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(printf, 2, 0);
|
||||
|
||||
int
|
||||
__posix_sflags (const char *mode, int *optr);
|
||||
|
||||
|
@ -35,7 +35,6 @@
|
||||
int
|
||||
ungetc(int c, FILE *stream)
|
||||
{
|
||||
|
||||
/*
|
||||
* Streams that are not readable, or streams that already had
|
||||
* had an ungetc() before will cause an error.
|
||||
@ -50,4 +49,3 @@ ungetc(int c, FILE *stream)
|
||||
|
||||
return (unsigned char) c;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_INTEGER_PRINTF_SCANF
|
||||
#define PRINTF_LEVEL PRINTF_STD
|
||||
#define vfprintf __i_vfprintf
|
||||
|
||||
#include <vfprintf.c>
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_INTEGER_PRINTF_SCANF
|
||||
#define SCANF_LEVEL SCANF_STD
|
||||
#define vfscanf __i_vfscanf
|
||||
|
||||
#include <vfscanf.c>
|
||||
|
@ -148,7 +148,6 @@ typedef long ultoa_signed_t;
|
||||
#define FL_NEGATIVE 0x40
|
||||
#define FL_LONG 0x80
|
||||
|
||||
|
||||
int
|
||||
vfprintf (FILE * stream, const char *fmt, va_list ap)
|
||||
{
|
||||
@ -881,4 +880,9 @@ int vfprintf (FILE * stream, const char *fmt, va_list ap)
|
||||
#undef my_putc
|
||||
}
|
||||
|
||||
#ifndef vfprintf
|
||||
int __d_vfprintf (FILE * stream, const char *fmt, va_list ap) __attribute__((alias("vfprintf"), nonnull));
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* PRINTF_LEVEL > PRINTF_MIN */
|
||||
|
@ -30,6 +30,8 @@
|
||||
|
||||
*/
|
||||
|
||||
#define PRINTF_LEVEL PRINTF_FLT
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
#define vfprintf __f_vfprintf
|
||||
|
||||
#include <vfprintf.c>
|
||||
|
@ -31,5 +31,6 @@
|
||||
*/
|
||||
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
#define vfscanf __f_vfscanf
|
||||
|
||||
#include "vfscanf.c"
|
||||
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_INTEGER_PRINTF_SCANF
|
||||
|
||||
#include <vprintf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_INTEGER_PRINTF_SCANF
|
||||
|
||||
#include <vscanf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
|
||||
#include <vprintf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
|
||||
#include <vscanf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_INTEGER_PRINTF_SCANF
|
||||
|
||||
#include <vsprintf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_INTEGER_PRINTF_SCANF
|
||||
|
||||
#include <vsnprintf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
|
||||
#include <vsnprintf.c>
|
@ -1,35 +0,0 @@
|
||||
/* Copyright © 2018 Keith Packard
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of the copyright holders nor the names of
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#define PICOLIBC_FLOAT_PRINTF_SCANF
|
||||
|
||||
#include <vsprintf.c>
|
@ -13,7 +13,7 @@
|
||||
%{!ftls-model:-ftls-model=@TLSMODEL@} %(picolibc_cc1plus) @CC1_SPEC@ @CC1PLUS_SPEC@
|
||||
|
||||
*link:
|
||||
-L@LIBDIR@/%M -L@LIBDIR@ %{!T:-Tpicolibc.ld} %(picolibc_link) @LINK_SPEC@
|
||||
@SPECS_PRINTF@ -L@LIBDIR@/%M -L@LIBDIR@ %{!T:-Tpicolibc.ld} %(picolibc_link) --gc-sections @LINK_SPEC@
|
||||
|
||||
*lib:
|
||||
--start-group -lc %{-oslib=*:--undefined=_exit} %{-oslib=*:-l%*} --end-group
|
||||
|
4
test.specs.in
Normal file
4
test.specs.in
Normal file
@ -0,0 +1,4 @@
|
||||
%rename link test_link
|
||||
|
||||
*link:
|
||||
@SPECS_PRINTF@ --gc-sections %(test_link)
|
@ -72,7 +72,7 @@ foreach target : targets
|
||||
test(t1 + target,
|
||||
executable(t1_name, 'printf_scanf.c',
|
||||
c_args: ['-DPICOLIBC_FLOAT_PRINTF_SCANF'] + _c_args,
|
||||
link_args: _link_args,
|
||||
link_args: ['-DPICOLIBC_FLOAT_PRINTF_SCANF'] + _link_args,
|
||||
link_with: _libs,
|
||||
link_depends: test_link_depends,
|
||||
include_directories: inc),
|
||||
@ -103,7 +103,7 @@ foreach target : targets
|
||||
test(t1 + target,
|
||||
executable(t1_name, ['printf-tests.c'],
|
||||
c_args: ['-DPICOLIBC_FLOAT_PRINTF_SCANF'] + _c_args,
|
||||
link_args: _link_args,
|
||||
link_args: ['-DPICOLIBC_FLOAT_PRINTF_SCANF'] + _link_args,
|
||||
link_with: _libs,
|
||||
include_directories: inc),
|
||||
env: ['MESON_SOURCE_ROOT=' + meson.source_root()])
|
||||
|
Loading…
Reference in New Issue
Block a user