mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-01 10:06:57 +03:00
Fix strnlen change
This commit is contained in:
@ -1,5 +1,9 @@
|
|||||||
2011-10-23 Ulrich Drepper <drepper@gmail.com>
|
2011-10-23 Ulrich Drepper <drepper@gmail.com>
|
||||||
|
|
||||||
|
* string/strnlen.c: Don't define STRNLEN, reverse logic.
|
||||||
|
Remove unused variable magic_bits.
|
||||||
|
* sysdeps/i386/i686/multiarch/rtld-strnlen.c: New file.
|
||||||
|
|
||||||
* string/strnlen.c: Define and use STRNLEN macro.
|
* string/strnlen.c: Define and use STRNLEN macro.
|
||||||
* sysdeps/i386/i686/multiarch/Makefile [string] (sysdep_routines):
|
* sysdeps/i386/i686/multiarch/Makefile [string] (sysdep_routines):
|
||||||
Add strnlen-sse2, strnlen-c, wcslen-sse2, and wcslen-c.
|
Add strnlen-sse2, strnlen-c, wcslen-sse2, and wcslen-c.
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
# include <stddef.h>
|
# include <stddef.h>
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# include <list.h>
|
//# include <list.h>
|
||||||
# include <sysdep.h>
|
# include <sysdep.h>
|
||||||
# include <kernel-features.h>
|
# include <kernel-features.h>
|
||||||
|
|
||||||
|
@ -27,16 +27,16 @@
|
|||||||
/* Find the length of S, but scan at most MAXLEN characters. If no
|
/* Find the length of S, but scan at most MAXLEN characters. If no
|
||||||
'\0' terminator is found in that many characters, return MAXLEN. */
|
'\0' terminator is found in that many characters, return MAXLEN. */
|
||||||
|
|
||||||
#ifndef STRNLEN
|
#ifdef STRNLEN
|
||||||
# define STRNLEN __strnlen
|
# define __strnlen STRNLEN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
STRNLEN (const char *str, size_t maxlen)
|
__strnlen (const char *str, size_t maxlen)
|
||||||
{
|
{
|
||||||
const char *char_ptr, *end_ptr = str + maxlen;
|
const char *char_ptr, *end_ptr = str + maxlen;
|
||||||
const unsigned long int *longword_ptr;
|
const unsigned long int *longword_ptr;
|
||||||
unsigned long int longword, magic_bits, himagic, lomagic;
|
unsigned long int longword, himagic, lomagic;
|
||||||
|
|
||||||
if (maxlen == 0)
|
if (maxlen == 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -70,14 +70,12 @@ STRNLEN (const char *str, size_t maxlen)
|
|||||||
|
|
||||||
The 1-bits make sure that carries propagate to the next 0-bit.
|
The 1-bits make sure that carries propagate to the next 0-bit.
|
||||||
The 0-bits provide holes for carries to fall into. */
|
The 0-bits provide holes for carries to fall into. */
|
||||||
magic_bits = 0x7efefeffL;
|
|
||||||
himagic = 0x80808080L;
|
himagic = 0x80808080L;
|
||||||
lomagic = 0x01010101L;
|
lomagic = 0x01010101L;
|
||||||
if (sizeof (longword) > 4)
|
if (sizeof (longword) > 4)
|
||||||
{
|
{
|
||||||
/* 64-bit version of the magic. */
|
/* 64-bit version of the magic. */
|
||||||
/* Do the shift in two steps to avoid a warning if long has 32 bits. */
|
/* Do the shift in two steps to avoid a warning if long has 32 bits. */
|
||||||
magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL;
|
|
||||||
himagic = ((himagic << 16) << 16) | himagic;
|
himagic = ((himagic << 16) << 16) | himagic;
|
||||||
lomagic = ((lomagic << 16) << 16) | lomagic;
|
lomagic = ((lomagic << 16) << 16) | lomagic;
|
||||||
}
|
}
|
||||||
|
1
sysdeps/i386/i686/multiarch/rtld-strnlen.c
Normal file
1
sysdeps/i386/i686/multiarch/rtld-strnlen.c
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include <string/strnlen.c>
|
Reference in New Issue
Block a user