Skip to content

[libc][posix/io/stdio] rename libc.c as posix/stdio.c #7930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions bsp/allwinner/libraries/libos/include/misc/support.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#define __SUPPORT_H__
#include <typedef.h>
#include <kapi.h>
#include <libc.h>

/*
* Generic macro to convert pointers to values for comparison purposes.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#ifndef _USB_LIST_H_
#define _USB_LIST_H_

#include <libc.h>
#include <log.h>
#include <hal_osal.h>
//#include "usb_host_config.h"
Expand Down
2 changes: 1 addition & 1 deletion components/dfs/dfs_v1/src/dfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#endif

#ifdef RT_USING_POSIX_STDIO
#include <libc.h>
#include <posix/stdio.h>
#endif /* RT_USING_POSIX_STDIO */

/* Global variables */
Expand Down
6 changes: 3 additions & 3 deletions components/libc/compilers/armlibc/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <sys/stat.h>
#include <compiler_private.h>
#ifdef RT_USING_POSIX_STDIO
#include "libc.h"
#include <posix/stdio.h>
#endif /* RT_USING_POSIX_STDIO */

#define DBG_TAG "armlibc.syscalls"
Expand Down Expand Up @@ -153,7 +153,7 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
if (fh == STDIN)
{
#ifdef RT_USING_POSIX_STDIO
if (libc_stdio_get_console() < 0)
if (rt_posix_stdio_get_console() < 0)
{
LOG_W("Do not invoke standard output before initializing Compiler");
return 0; /* error, but keep going */
Expand Down Expand Up @@ -375,7 +375,7 @@ int fgetc(FILE *f)
#ifdef RT_USING_POSIX_STDIO
char ch;

if (libc_stdio_get_console() < 0)
if (rt_posix_stdio_get_console() < 0)
{
LOG_W("Do not invoke standard output before initializing Compiler");
return 0;
Expand Down
87 changes: 0 additions & 87 deletions components/libc/compilers/common/cstdio.c

This file was deleted.

34 changes: 34 additions & 0 deletions components/libc/compilers/common/cunistd.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-08-16 Meco Man first version
*/

#include <rtthread.h>
#include <unistd.h>
#include <sys/errno.h>

int isatty(int fd)
{
#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
if(fd == STDOUT_FILENO || fd == STDERR_FILENO)
{
return 1;
}
#endif /* defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) */

#ifdef RT_USING_POSIX_STDIO
if(fd == STDIN_FILENO)
{
return 1;
}
#endif /* RT_USING_POSIX_STDIO */

rt_set_errno(ENOTTY);
return 0;
}
RTM_EXPORT(isatty);
4 changes: 2 additions & 2 deletions components/libc/compilers/dlib/syscall_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <LowLevelIOInterface.h>
#include <unistd.h>
#ifdef RT_USING_POSIX_STDIO
#include "libc.h"
#include <posix/stdio.h>
#endif /* RT_USING_POSIX_STDIO */
#include <compiler_private.h>
#define DBG_TAG "dlib.syscall.read"
Expand Down Expand Up @@ -40,7 +40,7 @@ size_t __read(int handle, unsigned char *buf, size_t len)
if (handle == _LLIO_STDIN)
{
#ifdef RT_USING_POSIX_STDIO
if (libc_stdio_get_console() < 0)
if (rt_posix_stdio_get_console() < 0)
{
LOG_W("Do not invoke standard input before initializing Compiler");
return 0; /* error, but keep going */
Expand Down
4 changes: 2 additions & 2 deletions components/libc/compilers/newlib/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <sys/errno.h>
#include <sys/stat.h>
#ifdef RT_USING_POSIX_STDIO
#include "libc.h"
#include <posix/stdio.h>
#endif /* RT_USING_POSIX_STDIO */
#ifdef RT_USING_MODULE
#include <dlmodule.h>
Expand Down Expand Up @@ -225,7 +225,7 @@ _ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
if (fd == STDIN_FILENO)
{
#ifdef RT_USING_POSIX_STDIO
if (libc_stdio_get_console() < 0)
if (rt_posix_stdio_get_console() < 0)
{
LOG_W("Do not invoke standard input before initializing Compiler");
return 0;
Expand Down
20 changes: 2 additions & 18 deletions components/libc/posix/io/stdio/SConscript
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
# RT-Thread building script for component

import os
from building import *

src = []
cwd = GetCurrentDir()
CPPPATH = [cwd]
group = []

if GetDepend('RT_USING_POSIX_STDIO'):
src += ['libc.c']

group = DefineGroup('POSIX', src, depend = [''], CPPPATH = CPPPATH)

list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
group = group + SConscript(os.path.join(d, 'SConscript'))
src = ['stdio.c']
group = DefineGroup('POSIX', src, depend = ['RT_USING_POSIX_STDIO'], CPPPATH = [GetCurrentDir()])

Return('group')
30 changes: 0 additions & 30 deletions components/libc/posix/io/stdio/libc.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-06-07 Meco Man first version
* 2017/10/15 bernard the first version
*/

#ifndef __POSIX_STDIO_H__
#define __POSIX_STDIO_H__

#include <rtconfig.h>
#include <stdio.h>
#include <sys/types.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <sys/types.h>

#ifdef DFS_USING_POSIX
int rt_posix_stdio_init(void);
int rt_posix_stdio_get_console(void);
int rt_posix_stdio_set_console(const char* device_name, int mode);
ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
ssize_t getline(char **lineptr, size_t *n, FILE *stream);
#endif /* DFS_USING_POSIX */

#ifdef __cplusplus
}
Expand Down
Loading