lib: utils/serial: Optimize semihosting_putc implementation
PATCH 1/1 lib: utils/serial: Optimize semihosting_putc implementation
From: Chen Pei <[email protected]>
For some debuggers that do not implement SYSWRITEC and SYSREADC operations, we can use SYSWRITE and SYSREAD instead like the implementation of semihosting_getc().
--- lib/utils/serial/semihosting.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
lib/utils/serial/semihosting.c +4 -1
@@ -162,7 +162,10 @@ static long semihosting_write(long fd, const void *memp, size_t len)static void semihosting_putc (char ch) { -semihosting_trap (SYSWRITEC , &ch); +if (semihosting_outfd <0 ) +semihosting_trap (SYSWRITEC , &ch); +else +semihosting_write (semihosting_outfd, &ch,1 ); }static unsigned long semihosting_puts (const char *str,unsigned long len)
Signature · 1 line
2.25.1
PATCH 1/1 lib: utils/serial: Optimize semihosting_putc implementation
? 2023-10-17???? 19:53 +0800?cp0613 at linux.alibaba.com???
Quoted 19 lines
From: Chen Pei <[email protected]>
For some debuggers that do not implement SYSWRITEC and SYSREADC operations, we can use SYSWRITE and SYSREAD instead like the implementation of
semihosting_getc().Signed-off-by Chen Pei <[email protected]>---
?lib/utils/serial/semihosting.c | 5 ++++-
?1 file changed, 4 insertions(+), 1 deletion(-)lib/utils/serial/semihosting.c +0
-0@@ -162,7 +162,10 @@ static long semihosting_write(long fd, const void *memp, size_t len)?
?static voidsemihosting_putc(char ch)
?{
lib/utils/serial/semihosting.c static long semihosting_write(long fd, const void *memp, size_t len) · line 168
Quoted 5 lines
lib/utils/serial/semihosting.c +4
-1-semihosting_trap (SYSWRITEC , &ch); +if (semihosting_outfd <0 ) +semihosting_trap (SYSWRITEC , &ch); +else +semihosting_write (semihosting_outfd, &ch,1 );
The code can be simplified by calling semihosting_puts directly, otherwise look good to me.
Quoted 7 lines
?}
?
?static unsigned longsemihosting_puts(const char *str, unsigned long len)Signature · 1 line
2.25.1