[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] [bug #28058] parameter checking in pgm_read_xxx()

From: Jan Waclawek
Subject: [avr-libc-dev] [bug #28058] parameter checking in pgm_read_xxx()
Date: Sat, 22 May 2010 13:01:21 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)

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

This item has been discussed on avrfreaks.net

Jan Waclawek


Reply to this item at:


  Message sent via/by Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]