Mercurial > hg > octave-nkf > gnulib-hg
comparison lib/memchr2.c @ 14610:b427a1938336
use _GL_ATTRIBUTE_CONST and _GL_ATTRIBUTE_PURE
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Sun, 24 Apr 2011 19:02:10 +0200 |
parents | 97fc9a21a8fb |
children | 6ef4f1f39105 |
comparison
equal
deleted
inserted
replaced
14609:97b99ef6c731 | 14610:b427a1938336 |
---|---|
27 | 27 |
28 #include <limits.h> | 28 #include <limits.h> |
29 #include <stdint.h> | 29 #include <stdint.h> |
30 #include <string.h> | 30 #include <string.h> |
31 | 31 |
32 /* The attribute __pure__ was added in gcc 2.96. */ | |
33 #undef _GL_ATTRIBUTE_PURE | |
34 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) | |
35 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) | |
36 #else | |
37 # define _GL_ATTRIBUTE_PURE /* empty */ | |
38 #endif | |
39 | |
32 /* Return the first address of either C1 or C2 (treated as unsigned | 40 /* Return the first address of either C1 or C2 (treated as unsigned |
33 char) that occurs within N bytes of the memory region S. If | 41 char) that occurs within N bytes of the memory region S. If |
34 neither byte appears, return NULL. */ | 42 neither byte appears, return NULL. */ |
35 void * | 43 void * _GL_ATTRIBUTE_PURE |
36 memchr2 (void const *s, int c1_in, int c2_in, size_t n) | 44 memchr2 (void const *s, int c1_in, int c2_in, size_t n) |
37 { | 45 { |
38 /* On 32-bit hardware, choosing longword to be a 32-bit unsigned | 46 /* On 32-bit hardware, choosing longword to be a 32-bit unsigned |
39 long instead of a 64-bit uintmax_t tends to give better | 47 long instead of a 64-bit uintmax_t tends to give better |
40 performance. On 64-bit hardware, unsigned long is generally 64 | 48 performance. On 64-bit hardware, unsigned long is generally 64 |