Follow-up Comment #2, bug #28058 (project avr-libc):

Although not completely to the topic, as it again is related to
<avr/pgmspace> , I would propose also the following addition:

__attribute__((__always_inline__)) static inline size_t strlen_P(PGM_P s);

static inline size_t strlen_P(PGM_P s) {
  return __builtin_constant_p(__builtin_strlen(s))
     ? __builtin_strlen(s) : __strlen_P(s);
} 

and rename the existing strlen_P() function to __strlen_P(s) (including the
appropriate change in library function).

This allows the compiler to avoid call of the library function when length of
string is known at compile time.

The same change could be made to the far counterpart (strlen_PF()), in the
unlikely event that Carlos Lamas' library gets included into the official
avr-libc.

This item has been discussed on avrfreaks.net
<http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=92866&start=20&postdays=0&postorder=asc&highlight=>.

Jan Waclawek

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?28058>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/


_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Reply via email to