Skip to content

Commit

Permalink
arch: Add up_nputs function to handle the non '\0' string correctly
Browse files Browse the repository at this point in the history
and change up_puts as a simple macro

Signed-off-by: Xiang Xiao <[email protected]>
  • Loading branch information
xiaoxiang781216 committed Jul 14, 2022
1 parent 82cd9b0 commit 6969767
Show file tree
Hide file tree
Showing 40 changed files with 252 additions and 242 deletions.
2 changes: 1 addition & 1 deletion arch/arm/src/common/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CMN_CSRCS += arm_allocateheap.c arm_assert.c arm_blocktask.c
CMN_CSRCS += arm_createstack.c arm_exit.c arm_fullcontextrestore.c
CMN_CSRCS += arm_initialize.c arm_lowputs.c
CMN_CSRCS += arm_modifyreg16.c arm_modifyreg32.c
CMN_CSRCS += arm_modifyreg8.c arm_puts.c arm_releasepending.c
CMN_CSRCS += arm_modifyreg8.c arm_nputs.c arm_releasepending.c
CMN_CSRCS += arm_releasestack.c arm_reprioritizertr.c arm_saveusercontext.c
CMN_CSRCS += arm_stackframe.c arm_switchcontext.c
CMN_CSRCS += arm_vfork.c arm_unblocktask.c arm_usestack.c
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/arm/src/common/arm_puts.c
* arch/arm/src/common/arm_nputs.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand Down Expand Up @@ -32,16 +32,16 @@
****************************************************************************/

/****************************************************************************
* Name: up_puts
* Name: up_nputs
*
* Description:
* This is a low-level helper function used to support debug.
*
****************************************************************************/

void up_puts(const char *str)
void up_nputs(const char *str, size_t len)
{
while (*str)
while (*str && len-- > 0)
{
up_putc(*str++);
}
Expand Down
16 changes: 13 additions & 3 deletions arch/arm/src/common/arm_semi_syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,25 @@ int up_putc(int ch)
}

/****************************************************************************
* Name: up_puts
* Name: up_nputs
*
* Description:
* Output a string on the console
*
****************************************************************************/

void up_puts(const char *str)
void up_nputs(const char *str, size_t len)
{
smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
if (len == ~((size_t)0))
{
smh_call(SEMI_SYSLOG_WRITE0, (char *)str);
}
else
{
while (len-- > 0)
{
up_putc(*str++);
}
}
}
#endif
2 changes: 1 addition & 1 deletion arch/avr/src/at32uc3/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ CMN_CSRCS += up_initialize.c up_initialstate.c
CMN_CSRCS += up_modifyreg8.c up_modifyreg16.c up_modifyreg32.c
CMN_CSRCS += up_releasepending.c up_releasestack.c up_reprioritizertr.c
CMN_CSRCS += up_schedulesigaction.c up_sigdeliver.c up_stackframe.c
CMN_CSRCS += up_unblocktask.c up_usestack.c up_doirq.c up_puts.c
CMN_CSRCS += up_unblocktask.c up_usestack.c up_doirq.c up_nputs.c

# Configuration-dependent common files

Expand Down
2 changes: 1 addition & 1 deletion arch/avr/src/at90usb/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CMN_CSRCS = up_allocateheap.c up_assert.c up_blocktask.c up_copystate.c
CMN_CSRCS += up_createstack.c up_doirq.c up_exit.c up_idle.c up_initialize.c
CMN_CSRCS += up_initialstate.c up_irq.c up_lowputs.c
CMN_CSRCS += up_mdelay.c up_modifyreg8.c up_modifyreg16.c up_modifyreg32.c
CMN_CSRCS += up_puts.c up_releasepending.c up_releasestack.c
CMN_CSRCS += up_nputs.c up_releasepending.c up_releasestack.c
CMN_CSRCS += up_reprioritizertr.c up_schedulesigaction.c up_sigdeliver.c
CMN_CSRCS += up_stackframe.c up_udelay.c up_unblocktask.c up_usestack.c

Expand Down
2 changes: 1 addition & 1 deletion arch/avr/src/atmega/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CMN_CSRCS = up_allocateheap.c up_assert.c up_blocktask.c up_copystate.c
CMN_CSRCS += up_createstack.c up_doirq.c up_exit.c up_idle.c up_initialize.c
CMN_CSRCS += up_initialstate.c up_irq.c up_lowputs.c
CMN_CSRCS += up_mdelay.c up_modifyreg8.c up_modifyreg16.c up_modifyreg32.c
CMN_CSRCS += up_puts.c up_releasepending.c up_releasestack.c
CMN_CSRCS += up_nputs.c up_releasepending.c up_releasestack.c
CMN_CSRCS += up_reprioritizertr.c up_schedulesigaction.c up_sigdeliver.c
CMN_CSRCS += up_stackframe.c up_udelay.c up_unblocktask.c up_usestack.c

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/avr/src/common/up_puts.c
* arch/avr/src/common/up_nputs.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand Down Expand Up @@ -44,16 +44,16 @@
****************************************************************************/

/****************************************************************************
* Name: up_puts
* Name: up_nputs
*
* Description:
* This is a low-level helper function used to support debug.
*
****************************************************************************/

void up_puts(const char *str)
void up_nputs(const char *str, size_t len)
{
while (*str)
while (*str && len-- > 0)
{
up_putc(*str++);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/ceva/src/common/up_puts.c
* arch/ceva/src/common/up_nputs.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand Down Expand Up @@ -30,16 +30,16 @@
****************************************************************************/

/****************************************************************************
* Name: up_puts
* Name: up_nputs
*
* Description:
* This is a low-level helper function used to support debug.
*
****************************************************************************/

void up_puts(const char *str)
void up_nputs(const char *str, size_t len)
{
while (*str)
while (*str && len-- > 0)
{
up_putc(*str++);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/sparc/src/common/up_puts.c
* arch/hc/src/common/up_nputs.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand All @@ -23,6 +23,7 @@
****************************************************************************/

#include <nuttx/config.h>

#include <nuttx/arch.h>

#include "up_internal.h"
Expand All @@ -44,18 +45,17 @@
****************************************************************************/

/****************************************************************************
* Name: up_puts
* Name: up_nputs
*
* Description:
* This is a low-level helper function used to support debug.
*
****************************************************************************/

void up_puts(const char *str)
void up_nputs(const char *str, size_t len)
{
while (*str)
while (*str && len-- > 0)
{
up_putc(*str++);
}
}

2 changes: 1 addition & 1 deletion arch/hc/src/m9s12/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ HEAD_ASRC = m9s12_vectors.S
CMN_CSRCS = up_allocateheap.c up_blocktask.c up_copystate.c up_createstack.c
CMN_CSRCS += up_doirq.c up_exit.c up_idle.c up_initialize.c
CMN_CSRCS += up_mdelay.c up_modifyreg16.c up_modifyreg32.c up_modifyreg8.c
CMN_CSRCS += up_puts.c up_releasepending.c up_releasestack.c up_reprioritizertr.c
CMN_CSRCS += up_nputs.c up_releasepending.c up_releasestack.c up_reprioritizertr.c
CMN_CSRCS += up_stackframe.c up_udelay.c up_unblocktask.c up_usestack.c

CHIP_ASRCS = m9s12_start.S m9s12_lowputc.S m9s12_saveusercontext.S
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/mips/src/common/mips_puts.c
* arch/mips/src/common/mips_nputs.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand Down Expand Up @@ -44,16 +44,16 @@
****************************************************************************/

/****************************************************************************
* Name: up_puts
* Name: up_nputs
*
* Description:
* This is a low-level helper function used to support debug.
*
****************************************************************************/

void up_puts(const char *str)
void up_nputs(const char *str, size_t len)
{
while (*str)
while (*str && len-- > 0)
{
up_putc(*str++);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/or1k/src/common/up_puts.c
* arch/or1k/src/common/up_nputs.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand Down Expand Up @@ -32,16 +32,16 @@
****************************************************************************/

/****************************************************************************
* Name: up_puts
* Name: up_nputs
*
* Description:
* This is a low-level helper function used to support debug.
*
****************************************************************************/

void up_puts(const char *str)
void up_nputs(const char *str, size_t len)
{
while (*str)
while (*str && len-- > 0)
{
up_putc(*str++);
}
Expand Down
2 changes: 1 addition & 1 deletion arch/or1k/src/mor1kx/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ CMN_CSRCS = up_initialize.c \
up_mdelay.c \
up_idle.c \
up_irq.c \
up_puts.c \
up_nputs.c \
up_uart.c \
up_timer.c \
up_doirq.c \
Expand Down
60 changes: 60 additions & 0 deletions arch/renesas/src/common/up_nputs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/****************************************************************************
* arch/renesas/src/common/up_nputs.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>
#include <nuttx/arch.h>

#include "up_internal.h"

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

/****************************************************************************
* Private Data
****************************************************************************/

/****************************************************************************
* Private Functions
****************************************************************************/

/****************************************************************************
* Public Functions
****************************************************************************/

/****************************************************************************
* Name: up_nputs
*
* Description:
* This is a low-level helper function used to support debug.
*
****************************************************************************/

void up_nputs(const char *str, size_t len)
{
while (*str && len-- > 0)
{
up_putc(*str++);
}
}
2 changes: 1 addition & 1 deletion arch/renesas/src/m16c/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ HEAD_ASRC = m16c_head.S

CMN_CSRCS = up_allocateheap.c up_assert.c up_blocktask.c
CMN_CSRCS += up_createstack.c up_doirq.c up_exit.c up_idle.c up_initialize.c
CMN_CSRCS += up_lowputs.c up_mdelay.c up_puts.c
CMN_CSRCS += up_lowputs.c up_mdelay.c up_nputs.c
CMN_CSRCS += up_releasepending.c up_releasestack.c up_reprioritizertr.c
CMN_CSRCS += up_stackframe.c up_udelay.c up_unblocktask.c up_usestack.c

Expand Down
2 changes: 1 addition & 1 deletion arch/renesas/src/rx65n/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ HEAD_ASRC = rx65n_head.S

CMN_CSRCS = up_allocateheap.c up_assert.c up_blocktask.c
CMN_CSRCS += up_createstack.c up_doirq.c up_exit.c up_idle.c up_initialize.c
CMN_CSRCS += up_lowputs.c up_mdelay.c up_puts.c
CMN_CSRCS += up_lowputs.c up_mdelay.c up_nputs.c
CMN_CSRCS += up_releasepending.c up_releasestack.c up_reprioritizertr.c
CMN_CSRCS += up_stackframe.c up_udelay.c up_unblocktask.c up_usestack.c

Expand Down
2 changes: 1 addition & 1 deletion arch/renesas/src/sh1/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ HEAD_ASRC = sh1_head.S
CMN_CSRCS = up_allocateheap.c up_assert.c up_blocktask.c
CMN_CSRCS += up_createstack.c up_doirq.c up_exit.c up_idle.c up_initialize.c
CMN_CSRCS += up_initialstate.c up_lowputs.c
CMN_CSRCS += up_mdelay.c up_puts.c up_releasepending.c up_releasestack.c
CMN_CSRCS += up_mdelay.c up_nputs.c up_releasepending.c up_releasestack.c
CMN_CSRCS += up_reprioritizertr.c up_stackframe.c up_udelay.c
CMN_CSRCS += sh1_schedulesigaction.c sh1_sigdeliver.c
CMN_CSRCS += up_unblocktask.c up_usestack.c
Expand Down
2 changes: 1 addition & 1 deletion arch/risc-v/src/common/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CMN_ASRCS += riscv_vectors.S riscv_exception_common.S riscv_mhartid.S
CMN_CSRCS += riscv_initialize.c riscv_swint.c riscv_mtimer.c
CMN_CSRCS += riscv_allocateheap.c riscv_createstack.c riscv_exit.c
CMN_CSRCS += riscv_assert.c riscv_blocktask.c riscv_copystate.c riscv_initialstate.c
CMN_CSRCS += riscv_modifyreg32.c riscv_puts.c
CMN_CSRCS += riscv_modifyreg32.c riscv_nputs.c
CMN_CSRCS += riscv_releasepending.c riscv_reprioritizertr.c
CMN_CSRCS += riscv_releasestack.c riscv_stackframe.c riscv_schedulesigaction.c
CMN_CSRCS += riscv_sigdeliver.c riscv_unblocktask.c riscv_usestack.c
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* arch/risc-v/src/common/riscv_puts.c
* arch/risc-v/src/common/riscv_nputs.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand Down Expand Up @@ -32,16 +32,16 @@
****************************************************************************/

/****************************************************************************
* Name: up_puts
* Name: up_nputs
*
* Description:
* This is a low-level helper function used to support debug.
*
****************************************************************************/

void up_puts(const char *str)
void up_nputs(const char *str, size_t len)
{
while (*str)
while (*str && len-- > 0)
{
up_putc(*str++);
}
Expand Down
2 changes: 1 addition & 1 deletion arch/sim/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ CSRCS = up_initialize.c up_idle.c up_interruptcontext.c up_initialstate.c
CSRCS += up_createstack.c up_usestack.c up_releasestack.c up_stackframe.c
CSRCS += up_unblocktask.c up_blocktask.c up_releasepending.c
CSRCS += up_reprioritizertr.c up_exit.c up_schedulesigaction.c
CSRCS += up_heap.c up_uart.c up_assert.c up_puts.c
CSRCS += up_heap.c up_uart.c up_assert.c up_nputs.c
CSRCS += up_copyfullstate.c
CSRCS += up_sigdeliver.c

Expand Down
Loading

0 comments on commit 6969767

Please sign in to comment.