Skip to content

Commit de18565

Browse files
tagunilnashif
authored andcommitted
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 <[email protected]>
1 parent eb4f2fb commit de18565

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lib/libc/arcmwdt/include/stdio.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2024 Synopsys
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef LIB_LIBC_ARCMWDT_INCLUDE_STDIO_H_
8+
#define LIB_LIBC_ARCMWDT_INCLUDE_STDIO_H_
9+
10+
#include_next <stdio.h>
11+
12+
#ifdef fileno
13+
#undef fileno
14+
#endif
15+
16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif
19+
20+
extern int fileno(FILE *file);
21+
22+
#ifdef __cplusplus
23+
}
24+
#endif
25+
26+
#endif /* LIB_LIBC_ARCMWDT_INCLUDE_STDIO_H_ */

lib/libc/arcmwdt/libc-hooks.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ int _write(int fd, const char *buf, unsigned int nbytes)
7171
}
7272
#endif
7373

74+
#ifndef CONFIG_POSIX_DEVICE_IO
75+
__weak int fileno(FILE *file)
76+
{
77+
return _fileno(file);
78+
}
79+
#endif
80+
7481
/*
7582
* It's require to implement _isatty to have STDIN/STDOUT/STDERR buffered
7683
* properly.

0 commit comments

Comments
 (0)