1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-05 19:35:52 +03:00
* sysdeps/generic/strstr.c (strstr): Update.  New optimized version.
This commit is contained in:
Ulrich Drepper
2001-12-14 22:17:03 +00:00
parent 0ce9cf883d
commit 638621aff9
5 changed files with 75 additions and 80 deletions

View File

@@ -1,5 +1,7 @@
2001-12-14 Ulrich Drepper <drepper@redhat.com> 2001-12-14 Ulrich Drepper <drepper@redhat.com>
* sysdeps/generic/strstr.c (strstr): Update. New optimized version.
* crypt/md5.h: Define md5_uintptr. * crypt/md5.h: Define md5_uintptr.
2001-12-13 Ulrich Drepper <drepper@redhat.com> 2001-12-13 Ulrich Drepper <drepper@redhat.com>

View File

@@ -1,3 +1,9 @@
2001-12-14 Ulrich Drepper <drepper@redhat.com>
* man/pthread_atfork.man: Adjust description of mutex handling
after fork for current implementation.
* linuxthreads.texi: Likewise [PR libc/2519].
2001-12-13 Andreas Schwab <schwab@suse.de> 2001-12-13 Andreas Schwab <schwab@suse.de>
* specific.c (pthread_key_delete): Don't contact the thread * specific.c (pthread_key_delete): Don't contact the thread

View File

@@ -1395,12 +1395,10 @@ pocess image.
To understand the purpose of @code{pthread_atfork}, recall that To understand the purpose of @code{pthread_atfork}, recall that
@code{fork} duplicates the whole memory space, including mutexes in @code{fork} duplicates the whole memory space, including mutexes in
their current locking state, but only the calling thread: other threads their current locking state, but only the calling thread: other threads
are not running in the child process. Thus, if a mutex is locked by a are not running in the child process. The mutexes are not usable after
thread other than the thread calling @code{fork}, that mutex will remain the @code{fork} and must be initialized with @code{pthread_mutex_init}
locked forever in the child process, possibly blocking the execution of in the child process. This is a limitation of the current
the child process. Or if some shared data, such as a linked list, was in the implementation and might or might not be present in future versions.
middle of being updated by a thread in the parent process, the child
will get a copy of the incompletely updated data which it cannot use.
To avoid this, install handlers with @code{pthread_atfork} as follows: have the To avoid this, install handlers with @code{pthread_atfork} as follows: have the
@var{prepare} handler lock the mutexes (in locking order), and the @var{prepare} handler lock the mutexes (in locking order), and the
@@ -1627,4 +1625,3 @@ of a mapping of user threads to kernel threads. It exists for source
compatibility. However, it will return the value that was set by the compatibility. However, it will return the value that was set by the
last call to @code{pthread_setconcurrency}. last call to @code{pthread_setconcurrency}.
@end deftypefun @end deftypefun

View File

@@ -30,15 +30,10 @@ while the |parent| and |child| handlers are called in FIFO order
To understand the purpose of !pthread_atfork!, recall that !fork!(2) To understand the purpose of !pthread_atfork!, recall that !fork!(2)
duplicates the whole memory space, including mutexes in their current duplicates the whole memory space, including mutexes in their current
locking state, but only the calling thread: other threads are not locking state, but only the calling thread: other threads are not
running in the child process. Thus, if a mutex is locked by a thread running in the child process. The mutexes are not usable after the
other than the thread calling !fork!, that mutex will remain locked !fork! and must be initialized with |pthread_mutex_init| in the child
forever in the child process, possibly blocking the execution of the process. This is a limitation of the current implementation and might
child process. To avoid this, install handlers with !pthread_atfork! or might not be present in future versions.
as follows: the |prepare| handler locks the global mutexes (in locking
order), and the |parent| and |child| handlers unlock them (in
reverse order). Alternatively, |prepare| and |parent| can be set to
!NULL! and |child| to a function that calls !pthread_mutex_init! on
the global mutexes.
.SH "RETURN VALUE" .SH "RETURN VALUE"

View File

@@ -1,5 +1,5 @@
/* Return the offset of one string within another. /* Return the offset of one string within another.
Copyright (C) 1994, 1996, 1997, 2000 Free Software Foundation, Inc. Copyright (C) 1994, 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@@ -43,85 +43,80 @@ strstr (phaystack, pneedle)
const char *phaystack; const char *phaystack;
const char *pneedle; const char *pneedle;
{ {
register const unsigned char *haystack, *needle; const unsigned char *haystack, *needle;
register chartype b, c; chartype b;
const unsigned char *rneedle;
haystack = (const unsigned char *) phaystack; haystack = (const unsigned char *) phaystack;
needle = (const unsigned char *) pneedle;
b = *needle; if (b = *(needle = (const unsigned char *) pneedle))
if (b != '\0')
{ {
haystack--; /* possible ANSI violation */ chartype c;
do haystack--; /* possible ANSI violation */
{
c = *++haystack;
if (c == '\0')
goto ret0;
}
while (c != b);
c = *++needle; {
if (c == '\0') chartype a;
do
if (!(a = *++haystack))
goto ret0;
while (a != b);
}
if (!(c = *++needle))
goto foundneedle; goto foundneedle;
++needle; ++needle;
goto jin; goto jin;
for (;;) for (;;)
{ {
register chartype a; {
register const unsigned char *rhaystack, *rneedle; chartype a;
if (0)
do jin:{
{ if ((a = *++haystack) == c)
goto crest;
}
else
a = *++haystack; a = *++haystack;
if (a == '\0')
goto ret0;
if (a == b)
break;
a = *++haystack;
if (a == '\0')
goto ret0;
shloop:
;
}
while (a != b);
jin: a = *++haystack;
if (a == '\0')
goto ret0;
if (a != c)
goto shloop;
rhaystack = haystack-- + 1;
rneedle = needle;
a = *rneedle;
if (*rhaystack == a)
do do
{ {
if (a == '\0') for (; a != b; a = *++haystack)
goto foundneedle; {
++rhaystack; if (!a)
a = *++needle; goto ret0;
if (*rhaystack != a) if ((a = *++haystack) == b)
break; break;
if (a == '\0') if (!a)
goto foundneedle; goto ret0;
++rhaystack; }
a = *++needle;
} }
while (*rhaystack == a); while ((a = *++haystack) != c);
}
needle = rneedle; /* took the register-poor approach */ crest:
{
if (a == '\0') chartype a;
break; {
} const unsigned char *rhaystack;
if (*(rhaystack = haystack-- + 1) == (a = *(rneedle = needle)))
do
{
if (!a)
goto foundneedle;
if (*++rhaystack != (a = *++needle))
break;
if (!a)
goto foundneedle;
}
while (*++rhaystack == (a = *++needle));
needle = rneedle; /* took the register-poor aproach */
}
if (!a)
break;
}
}
} }
foundneedle: foundneedle:
return (char*) haystack; return (char *) haystack;
ret0: ret0:
return 0; return 0;
} }