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,8 +47,9 @@ char * strcpy(char * dest,const char *src);
47 47
 char * strncpy(char * dest,const char *src,size_t count);
48 48
 char * strcat(char * dest, const char * src);
49 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 53
 char * strchr(const char * s, int c);
53 54
 char * strrchr(const char * s, int c);
54 55
 size_t strlen(const char * s);
@@ -60,7 +61,8 @@ char * strsep(char **s, const char *ct);
60 61
 void * memset(void * s,int c,size_t count);
61 62
 char * bcopy(const char * src, char * dest, int count);
62 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 66
 void * memscan(void * addr, int c, size_t size);
65 67
 char * strstr(const char * s1,const char * s2);
66 68
 void * memchr(const void *s, int c, size_t n);

Loading…
Cancel
Save