[libc] Add libc_stdio_get_console .

This commit is contained in:
armink 2018-01-12 16:55:47 +08:00
parent f54c8bab3c
commit 392a33d6c5
6 changed files with 19 additions and 0 deletions

View File

@ -31,6 +31,7 @@
int libc_system_init(void);
int libc_stdio_set_console(const char* device_name, int mode);
int libc_stdio_get_console(void);
int libc_stdio_read (void *buffer, size_t size);
int libc_stdio_write(const void *buffer, size_t size);

View File

@ -58,6 +58,11 @@ int libc_stdio_set_console(const char* device_name, int mode)
return std_fd;
}
int libc_stdio_get_console(void)
{
return std_fd;
}
int libc_stdio_read(void *buffer, size_t size)
{
return read(std_fd, buffer, size);

View File

@ -32,6 +32,7 @@
int libc_system_init(void);
int libc_stdio_set_console(const char* device_name, int mode);
int libc_stdio_get_console(void);
int libc_stdio_read (void *buffer, size_t size);
int libc_stdio_write(const void *buffer, size_t size);

View File

@ -58,6 +58,10 @@ int libc_stdio_set_console(const char* device_name, int mode)
return std_fd;
}
int libc_stdio_get_console(void) {
return std_fd;
}
int libc_stdio_read(void *buffer, size_t size)
{
return read(std_fd, buffer, size);

View File

@ -38,6 +38,7 @@
int libc_system_init(void);
int libc_stdio_set_console(const char* device_name, int mode);
int libc_stdio_get_console(void);
/* some time related function */
int libc_set_time(const struct timespec *time);

View File

@ -83,3 +83,10 @@ int libc_stdio_set_console(const char* device_name, int mode)
return fileno(std_console);
}
int libc_stdio_get_console(void) {
if (std_console)
return fileno(std_console);
else
return -1;
}