• Ryan Roberts's avatar
    tools/nolibc/stdio: add setvbuf() to set buffering mode · 4893c22e
    Ryan Roberts authored
    Add a minimal implementation of setvbuf(), which error checks the mode
    argument (as required by spec) and returns. Since nolibc never buffers
    output, nothing needs to be done.
    
    The kselftest framework recently added a call to setvbuf(). As a result,
    any tests that use the kselftest framework and nolibc cause a compiler
    error due to missing function. This provides an urgent fix for the
    problem which is preventing arm64 testing on linux-next.
    
    Example:
    
    clang --target=aarch64-linux-gnu -fintegrated-as
    -Werror=unknown-warning-option -Werror=ignored-optimization-argument
    -Werror=option-ignored -Werror=unused-command-line-argument
    --target=aarch64-linux-gnu -fintegrated-as
    -fno-asynchronous-unwind-tables -fno-ident -s -Os -nostdlib \
    -include ../../../../include/nolibc/nolibc.h -I../..\
    -static -ffreestanding -Wall za-fork.c
    build/kselftest/arm64/fp/za-fork-asm.o
    -o build/kselftest/arm64/fp/za-fork
    In file included from <built-in>:1:
    In file included from ./../../../../include/nolibc/nolibc.h:97:
    In file included from ./../../../../include/nolibc/arch.h:25:
    ./../../../../include/nolibc/arch-aarch64.h:178:35: warning: unknown
    attribute 'optimize' ignored [-Wunknown-attributes]
    void __attribute__((weak,noreturn,optimize("omit-frame-pointer")))
    __no_stack_protector _start(void)
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from za-fork.c:12:
    ../../kselftest.h:123:2: error: call to undeclared function 'setvbuf';
    ISO C99 and later do not support implicit function declarations
    [-Wimplicit-function-declaration]
            setvbuf(stdout, NULL, _IOLBF, 0);
            ^
    ../../kselftest.h:123:24: error: use of undeclared identifier '_IOLBF'
            setvbuf(stdout, NULL, _IOLBF, 0);
                                  ^
    1 warning and 2 errors generated.
    Signed-off-by: default avatarRyan Roberts <ryan.roberts@arm.com>
    Reported-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
    Link: https://lore.kernel.org/linux-kselftest/CA+G9fYus3Z8r2cg3zLv8uH8MRrzLFVWdnor02SNr=rCz+_WGVg@mail.gmail.com/Reviewed-by: default avatarMark Brown <broonie@kernel.org>
    Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
    4893c22e
stdio.h 7 KB