1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

Only use strncmp optimization if count argument is constant.

This commit is contained in:
Ulrich Drepper
1999-02-16 21:21:52 +00:00
parent 6686d05a25
commit d30da2a800

View File

@ -688,11 +688,12 @@ __stpcpy_small (char *__dest,
/* Compare N characters of S1 and S2. */ /* Compare N characters of S1 and S2. */
#ifndef _HAVE_STRING_ARCH_strncmp #ifndef _HAVE_STRING_ARCH_strncmp
# define strncmp(s1, s2, n) \ # define strncmp(s1, s2, n) \
(__extension__ (__builtin_constant_p (s1) && strlen (s1) < ((size_t) (n)) \ (__extension__ (__builtin_constant_p (n) \
? strcmp (s1, s2) \ && ((__builtin_constant_p (s1) \
: (__builtin_constant_p (s2) && strlen (s2) < ((size_t) (n))\ && strlen (s1) < ((size_t) (n))) \
? strcmp (s1, s2) \ || (__builtin_constant_p (s2) \
: strncmp (s1, s2, n)))) && strlen (s2) < ((size_t) (n)))) \
? strcmp (s1, s2) : strncmp (s1, s2, n)))
#endif #endif