xref: /rk3399_ARM-atf/lib/libc/putchar.c (revision 61f72a34250d063da67f4fc2b0eb8c3fda3376be)
1*61f72a34SRoberto Vargas /*
2*61f72a34SRoberto Vargas  * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
3*61f72a34SRoberto Vargas  *
4*61f72a34SRoberto Vargas  * SPDX-License-Identifier: BSD-3-Clause
5*61f72a34SRoberto Vargas  */
6*61f72a34SRoberto Vargas 
7*61f72a34SRoberto Vargas #include <stdio.h>
8*61f72a34SRoberto Vargas #include <console.h>
9*61f72a34SRoberto Vargas 
10*61f72a34SRoberto Vargas /* Putchar() should either return the character printed or EOF in case of error.
11*61f72a34SRoberto Vargas  * Our current console_putc() function assumes success and returns the
12*61f72a34SRoberto Vargas  * character. Write all other printing functions in terms of putchar(), if
13*61f72a34SRoberto Vargas  * possible, so they all benefit when this is improved.
14*61f72a34SRoberto Vargas  */
15*61f72a34SRoberto Vargas int putchar(int c)
16*61f72a34SRoberto Vargas {
17*61f72a34SRoberto Vargas 	int res;
18*61f72a34SRoberto Vargas 	if (console_putc((unsigned char)c) >= 0)
19*61f72a34SRoberto Vargas 		res = c;
20*61f72a34SRoberto Vargas 	else
21*61f72a34SRoberto Vargas 		res = EOF;
22*61f72a34SRoberto Vargas 
23*61f72a34SRoberto Vargas 	return res;
24*61f72a34SRoberto Vargas }
25