FORTIFY_SOURCE: strcat / strncat optimize
__strcat_chk and __strncat_chk are slightly inefficient, because they end up traversing over the same memory region two times. This change optimizes __strcat_chk / __strncat_chk so they only access the memory once. Although I haven't benchmarked these changes, it should improve the performance of these functions. __strlen_chk - expose this function, even if -D_FORTIFY_SOURCE isn't defined. This is needed to compile libc itself without -D_FORTIFY_SOURCE. Change-Id: Id2c70dff55a276b47c59db27a03734d659f84b74
This commit is contained in:
@@ -49,6 +49,7 @@ extern char* strchr(const char *, int) __purefunc;
|
||||
extern char* strrchr(const char *, int) __purefunc;
|
||||
|
||||
extern size_t strlen(const char *) __purefunc;
|
||||
extern size_t __strlen_chk(const char *, size_t);
|
||||
extern int strcmp(const char *, const char *) __purefunc;
|
||||
extern char* strcpy(char* __restrict, const char* __restrict);
|
||||
extern char* strcat(char* __restrict, const char* __restrict);
|
||||
@@ -207,8 +208,6 @@ size_t strlcat(char* __restrict dest, const char* __restrict src, size_t size) {
|
||||
return __strlcat_chk(dest, src, size, bos);
|
||||
}
|
||||
|
||||
extern size_t __strlen_chk(const char *, size_t);
|
||||
|
||||
__BIONIC_FORTIFY_INLINE
|
||||
size_t strlen(const char *s) {
|
||||
size_t bos = __bos(s);
|
||||
|
Reference in New Issue
Block a user