Browse Source

Marked memcmp/strcmp as "pure" functions, to allow gcc to optimise

away code such as

  if ( strcmp ( some_string, "some_value" ) != 0 ) {
     DBG ( "Bad value received!" );
  }
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
82342e0b8f
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      src/include/string.h

+ 5
- 3
src/include/string.h View File

47
 char * strncpy(char * dest,const char *src,size_t count);
47
 char * strncpy(char * dest,const char *src,size_t count);
48
 char * strcat(char * dest, const char * src);
48
 char * strcat(char * dest, const char * src);
49
 char * strncat(char *dest, const char *src, size_t count);
49
 char * strncat(char *dest, const char *src, size_t count);
50
-int strcmp(const char * cs,const char * ct);
51
-int strncmp(const char * cs,const char * ct,size_t count);
50
+int __attribute__ (( pure )) strcmp(const char * cs,const char * ct);
51
+int __attribute__ (( pure )) strncmp(const char * cs,const char * ct,
52
+				     size_t count);
52
 char * strchr(const char * s, int c);
53
 char * strchr(const char * s, int c);
53
 char * strrchr(const char * s, int c);
54
 char * strrchr(const char * s, int c);
54
 size_t strlen(const char * s);
55
 size_t strlen(const char * s);
60
 void * memset(void * s,int c,size_t count);
61
 void * memset(void * s,int c,size_t count);
61
 char * bcopy(const char * src, char * dest, int count);
62
 char * bcopy(const char * src, char * dest, int count);
62
 void * memmove(void * dest,const void *src,size_t count);
63
 void * memmove(void * dest,const void *src,size_t count);
63
-int memcmp(const void * cs,const void * ct,size_t count);
64
+int __attribute__ (( pure )) memcmp(const void * cs,const void * ct,
65
+				    size_t count);
64
 void * memscan(void * addr, int c, size_t size);
66
 void * memscan(void * addr, int c, size_t size);
65
 char * strstr(const char * s1,const char * s2);
67
 char * strstr(const char * s1,const char * s2);
66
 void * memchr(const void *s, int c, size_t n);
68
 void * memchr(const void *s, int c, size_t n);

Loading…
Cancel
Save