diff options
Diffstat (limited to 'string')
-rw-r--r-- | string/argz.h | 2 | ||||
-rw-r--r-- | string/string.h | 28 |
2 files changed, 17 insertions, 13 deletions
diff --git a/string/argz.h b/string/argz.h index 71e94c9167..d5847cb425 100644 --- a/string/argz.h +++ b/string/argz.h @@ -154,4 +154,6 @@ argz_next (char *__argz, size_t __argz_len, __const char *__entry) } #endif /* optimizing GCC2 */ +__END_DECLS + #endif /* argz.h */ diff --git a/string/string.h b/string/string.h index a434c3ab81..3cac382529 100644 --- a/string/string.h +++ b/string/string.h @@ -181,15 +181,6 @@ extern size_t strlen __P ((__const char *__s)); /* Find the length of STRING, but scan at most MAXLEN characters. If no '\0' terminator is found in that many characters, return MAXLEN. */ extern size_t strnlen __P ((__const char *__string, size_t __maxlen)); - -# ifdef __OPTIMIZE__ -extern __inline size_t -strnlen (__const char *__string, size_t __maxlen) -{ - __const char *__end = (__const char *) memchr (__string, '\0', __maxlen); - return __end ? __end - __string : __maxlen; -} -# endif #endif @@ -272,23 +263,34 @@ extern char *strfry __P ((char *__string)); /* Frobnicate N bytes of S. */ extern __ptr_t memfrob __P ((__ptr_t __s, size_t __n)); -#endif -#if defined __USE_MISC || !defined basename +# ifndef basename /* Return the file name within directory of FILENAME. We don't declare the function if the `basename' macro is available (defined in <libgen.h>) which makes the XPG version of this function available. */ extern char *basename __P ((__const char *__filename)); +# endif #endif /* Some functions might be implemented as optimized inline assembler - functions. */ -#if !defined __NO_STRING_INLINES && defined __OPTIMIZE__ + functions. Only include this file if we really want them. */ +#if defined __USE_STRING_INLINES && defined __OPTIMIZE__ # include <bits/string.h> #endif + +/* Now provide some generic optimizations. */ +#if defined __GNUC__ && __GNUC__ >= 2 && defined __OPTIMIZE__ +extern __inline size_t +strnlen (__const char *__string, size_t __maxlen) +{ + __const char *__end = (__const char *) memchr (__string, '\0', __maxlen); + return __end ? __end - __string : __maxlen; +} +#endif + __END_DECLS #endif /* string.h */ |