diff --git a/kal/posix/musl_src/stdio/__fdopen.c b/kal/posix/musl_src/stdio/__fdopen.c index e89f930d..bc50be7d 100644 --- a/kal/posix/musl_src/stdio/__fdopen.c +++ b/kal/posix/musl_src/stdio/__fdopen.c @@ -6,6 +6,11 @@ #include #include +int ioctl(int fd, int req, ...) +{ + return 0; +} + FILE *__fdopen(int fd, const char *mode) { FILE *f; diff --git a/kal/posix/musl_src/stdio/fclose.c b/kal/posix/musl_src/stdio/fclose.c index bd6a890d..eeba0ffb 100644 --- a/kal/posix/musl_src/stdio/fclose.c +++ b/kal/posix/musl_src/stdio/fclose.c @@ -4,10 +4,10 @@ static void dummy(FILE *f) { } weak_alias(dummy, __unlist_locked_file); -int fclose(FILE *f) +int __fclose(FILE *f) { int r; - + FLOCK(f); r = fflush(f); r |= f->close(f); @@ -34,3 +34,4 @@ int fclose(FILE *f) return r; } +weak_alias(__fclose, fclose); \ No newline at end of file diff --git a/kal/posix/musl_src/stdio/fflush.c b/kal/posix/musl_src/stdio/fflush.c index 71606ac9..d755f8f1 100644 --- a/kal/posix/musl_src/stdio/fflush.c +++ b/kal/posix/musl_src/stdio/fflush.c @@ -5,16 +5,16 @@ static FILE *volatile dummy = 0; weak_alias(dummy, __stdout_used); weak_alias(dummy, __stderr_used); -int fflush(FILE *f) +int __fflush(FILE *f) { if (!f) { int r = 0; - if (__stdout_used) r |= fflush(__stdout_used); - if (__stderr_used) r |= fflush(__stderr_used); + if (__stdout_used) r |= __fflush(__stdout_used); + if (__stderr_used) r |= __fflush(__stderr_used); for (f=*__ofl_lock(); f; f=f->next) { FLOCK(f); - if (f->wpos != f->wbase) r |= fflush(f); + if (f->wpos != f->wbase) r |= __fflush(f); FUNLOCK(f); } __ofl_unlock(); @@ -45,3 +45,4 @@ int fflush(FILE *f) } weak_alias(fflush, fflush_unlocked); +weak_alias(__fflush, fflush); diff --git a/kal/posix/musl_src/stdio/fseek.c b/kal/posix/musl_src/stdio/fseek.c index 2fc16d84..4731d8a0 100644 --- a/kal/posix/musl_src/stdio/fseek.c +++ b/kal/posix/musl_src/stdio/fseek.c @@ -15,12 +15,12 @@ int __fseeko_unlocked(FILE *f, off_t off, int whence) f->wpos = f->wbase = f->wend = 0; /* Perform the underlying seek. */ - if (lseek(f->fd, (unsigned int)off, whence) < 0) return -1; + if (lseek(f->fd, off, whence) < 0) return -1; /* If seek succeeded, file is seekable and we discard read buffer. */ f->rpos = f->rend = 0; f->flags &= ~F_EOF; - + return 0; } diff --git a/kal/posix/src/fwrap.c b/kal/posix/src/fwrap.c new file mode 100644 index 00000000..c47b46bf --- /dev/null +++ b/kal/posix/src/fwrap.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. 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. + * + * 3. Neither the name of the copyright holder nor the names of its 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 HOLDER 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. + */ + +#include "stdio_impl.h" + +int __wrap_fclose(FILE *f) +{ + return __fclose(f); +} + +int __wrap_fflush(FILE *f) +{ + return __fflush(f); +} \ No newline at end of file