lib: libc: arcmwdt: replace the fileno macro

The fileno macro defined in ARC MWDT headers conflicts with the fileno()
function defined in lib/posix/options/device_io.c. We should undefine it
and replace with a POSIX-compliant declaration and a weak definition.

Signed-off-by: Ilya Tagunov <Ilya.Tagunov@synopsys.com>
This commit is contained in:
Ilya Tagunov 2024-11-12 16:43:49 +00:00 committed by Anas Nashif
parent eb4f2fb44a
commit de18565e2a
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2024 Synopsys
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef LIB_LIBC_ARCMWDT_INCLUDE_STDIO_H_
#define LIB_LIBC_ARCMWDT_INCLUDE_STDIO_H_
#include_next <stdio.h>
#ifdef fileno
#undef fileno
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern int fileno(FILE *file);
#ifdef __cplusplus
}
#endif
#endif /* LIB_LIBC_ARCMWDT_INCLUDE_STDIO_H_ */

View File

@ -71,6 +71,13 @@ int _write(int fd, const char *buf, unsigned int nbytes)
}
#endif
#ifndef CONFIG_POSIX_DEVICE_IO
__weak int fileno(FILE *file)
{
return _fileno(file);
}
#endif
/*
* It's require to implement _isatty to have STDIN/STDOUT/STDERR buffered
* properly.