string.h: add __attribute__ ((pure)) to string functions

cdefs.h: Introduce the __purefunc attribute, which allows us to mark
certain functions as being "pure".

http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html

  Many functions have no effects except the return value and their
  return value depends only on the parameters and/or global variables.
  Such a function can be subject to common subexpression elimination
  and loop optimization just as an arithmetic operator would be.

string.h: Mark many commently used string functions as "pure", to
allow for additional compiler optimizations.

Change-Id: I42961f90f822b6dbcbc3fd72cdbe774a7adc8785
This commit is contained in:
Nick Kralevich
2012-03-21 08:48:18 -07:00
parent aac0dc97a9
commit a677907ee8
2 changed files with 21 additions and 19 deletions

View File

@@ -306,9 +306,11 @@
#if __GNUC_PREREQ__(2, 96)
#define __noreturn __attribute__((__noreturn__))
#define __mallocfunc __attribute__((malloc))
#define __purefunc __attribute__((pure))
#else
#define __noreturn
#define __mallocfunc
#define __purefunc
#endif
/*