Xiang,

If there is a small usage do you think flash will grow by 256 bytes? I would
be surprised.

Should you uses a config option?

David


-----Original Message-----
From: Xiang Xiao [mailto:xiaoxiang781...@gmail.com]
Sent: Monday, July 27, 2020 10:40 PM
To: dev@nuttx.apache.org
Subject: RE: Can we implement ctype functions through table?

Decorate the table with IPTR and access the element through up_romgetc, just
like printf series function.

> -----Original Message-----
> From: Gregory Nutt <spudan...@gmail.com>
> Sent: Tuesday, July 28, 2020 12:44 PM
> To: dev@nuttx.apache.org
> Subject: Re: Can we implement ctype functions through table?
>
> What about platforms like AVR?  That would not be a good decision for AVR
> since it is a harvard machine and cannot access data in
> ROM without special operations.
>
>
> On 7/27/2020 9:55 PM, Xiang Xiao wrote:
> > Hi all,
> > For example, here is isspace implementation:
> > #  define isspace(c) \
> >      ((c) == ' '  || (c) == '\t' || (c) == '\n' || (c) == '\r' || \
> >       (c) == '\f' || (c) == '\v')
> > The argument of c will evaluate 6 times, which make the following code
> > suddenly fail:
> > while (end != begin)
> >    {
> >      If (!isspace(*--end))
> >        {
> >           break;
> >        }
> >    }
> > But it work well with other libc implementation, because all other libc
> > utilize a table to classify  the char type:
> > https://github.com/bminor/newlib/blob/master/newlib/libc/include/ctype
> > .h#L97
> > https://github.com/bminor/glibc/blob/master/ctype/ctype.h#L197
> > and the argument only need evaluate once.
> > So my question is: can we implement ctype functions through table to
> > improve the compatibility?
> > Yes, the table need take more 256 bytes ROM space, but the complex
> > expression used in NuttX also bloat the code size, especially
> > considering ctype function is used very frequently.
> >
> > Thanks
> > Xiang
> >

Reply via email to