1999-04-28  Ulrich Drepper  <drepper@cygnus.com>

	* manager.c (pthread_allocate_stack): Optimize initialization of new
	thread descriptor.
This commit is contained in:
Ulrich Drepper 1999-04-28 21:56:46 +00:00
parent fbb9cc9129
commit 390500b147
30 changed files with 199 additions and 233 deletions

View File

@ -1,5 +1,5 @@
/* Default definition for ARGP_PROGRAM_BUG_ADDRESS. /* Default definition for ARGP_PROGRAM_BUG_ADDRESS.
Copyright (C) 1996, 1997 Free Software Foundation, Inc. Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>. Written by Miles Bader <miles@gnu.ai.mit.edu>.
@ -23,4 +23,4 @@
the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help
messages), embedded in a sentence that says something like `Report bugs to messages), embedded in a sentence that says something like `Report bugs to
ADDR.'. */ ADDR.'. */
const char *argp_program_bug_address = 0; const char *argp_program_bug_address;

View File

@ -1376,19 +1376,17 @@ argp_args_usage (const struct argp *argp, const struct argp_state *state,
if (fdoc) if (fdoc)
{ {
const char *cp = fdoc; const char *cp = fdoc;
nl = strchr (cp, '\n'); nl = __strchrnul (cp, '\n');
if (nl) if (*nl != '\0')
/* This is a `multi-level' args doc; advance to the correct position /* This is a `multi-level' args doc; advance to the correct position
as determined by our state in LEVELS, and update LEVELS. */ as determined by our state in LEVELS, and update LEVELS. */
{ {
int i; int i;
multiple = 1; multiple = 1;
for (i = 0; i < *our_level; i++) for (i = 0; i < *our_level; i++)
cp = nl + 1, nl = strchr (cp, '\n'); cp = nl + 1, nl = __strchrnul (cp, '\n');
(*levels)++; (*levels)++;
} }
if (! nl)
nl = cp + strlen (cp);
/* Manually do line wrapping so that it (probably) won't get wrapped at /* Manually do line wrapping so that it (probably) won't get wrapped at
any embedded spaces. */ any embedded spaces. */

View File

@ -1,5 +1,5 @@
/* Hierarchial argument parsing, layered over getopt /* Hierarchial argument parsing, layered over getopt
Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>. Written by Miles Bader <miles@gnu.ai.mit.edu>.
@ -76,7 +76,7 @@
for one second intervals, decrementing _ARGP_HANG until it's zero. Thus for one second intervals, decrementing _ARGP_HANG until it's zero. Thus
you can force the program to continue by attaching a debugger and setting you can force the program to continue by attaching a debugger and setting
it to 0 yourself. */ it to 0 yourself. */
volatile int _argp_hang = 0; volatile int _argp_hang;
#define OPT_PROGNAME -2 #define OPT_PROGNAME -2
#define OPT_USAGE -3 #define OPT_USAGE -3

View File

@ -1,5 +1,5 @@
/* Default definition for ARGP_PROGRAM_VERSION. /* Default definition for ARGP_PROGRAM_VERSION.
Copyright (C) 1996, 1997 Free Software Foundation, Inc. Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>. Written by Miles Bader <miles@gnu.ai.mit.edu>.
@ -22,4 +22,4 @@
--version is added (unless the ARGP_NO_HELP flag is used), which will --version is added (unless the ARGP_NO_HELP flag is used), which will
print this this string followed by a newline and exit (unless the print this this string followed by a newline and exit (unless the
ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */ ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
const char *argp_program_version = 0; const char *argp_program_version;

View File

@ -1,5 +1,5 @@
/* Default definition for ARGP_PROGRAM_VERSION_HOOK. /* Default definition for ARGP_PROGRAM_VERSION_HOOK.
Copyright (C) 1996, 1997 Free Software Foundation, Inc. Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>. Written by Miles Bader <miles@gnu.ai.mit.edu>.
@ -29,4 +29,4 @@
this function with a stream to print the version to and a pointer to the this function with a stream to print the version to and a pointer to the
current parsing state, and then exits (unless the ARGP_NO_EXIT flag is current parsing state, and then exits (unless the ARGP_NO_EXIT flag is
used). This variable takes precedent over ARGP_PROGRAM_VERSION. */ used). This variable takes precedent over ARGP_PROGRAM_VERSION. */
void (*argp_program_version_hook) (FILE *stream, struct argp_state *state) = 0; void (*argp_program_version_hook) (FILE *stream, struct argp_state *state);

View File

@ -33,23 +33,12 @@ nl_catd
catopen (const char *cat_name, int flag) catopen (const char *cat_name, int flag)
{ {
__nl_catd result; __nl_catd result;
const char *env_var; const char *env_var = NULL;
const char *nlspath; const char *nlspath = NULL;
size_t cat_name_len = strlen (cat_name) + 1;
result = (__nl_catd) malloc (sizeof (*result)); size_t env_var_len = 0;
if (result == NULL) size_t nlspath_len = 0;
/* We cannot get enough memory. */ char *endp;
return (nl_catd) -1;
result->status = closed;
result->cat_name = __strdup (cat_name);
if (result->cat_name == NULL)
{
free (result);
__set_errno (ENOMEM);
return (nl_catd) -1;
}
if (strchr (cat_name, '/') == NULL) if (strchr (cat_name, '/') == NULL)
{ {
@ -57,31 +46,18 @@ catopen (const char *cat_name, int flag)
{ {
env_var = getenv ("LC_ALL"); env_var = getenv ("LC_ALL");
if (env_var == NULL) if (env_var == NULL)
{ env_var = getenv ("LC_MESSAGES");
env_var = getenv ("LC_MESSAGES");
if (env_var == NULL) if (env_var != NULL)
{ goto have_env_var;
env_var = getenv ("LANG");
if (env_var == NULL)
env_var = "C";
}
}
}
else
{
env_var = getenv ("LANG");
if (env_var == NULL)
env_var = "C";
} }
result->env_var = __strdup (env_var); env_var = getenv ("LANG");
if (result->env_var == NULL) if (env_var == NULL)
{ env_var = "C";
free ((void *) result->cat_name);
free ((void *) result); have_env_var:
__set_errno (ENOMEM); env_var_len = strlen (env_var) + 1;
return (nl_catd) -1;
}
nlspath = __secure_getenv ("NLSPATH"); nlspath = __secure_getenv ("NLSPATH");
if (nlspath != NULL && *nlspath != '\0') if (nlspath != NULL && *nlspath != '\0')
@ -92,25 +68,32 @@ catopen (const char *cat_name, int flag)
__stpcpy (__stpcpy (__stpcpy (tmp, nlspath), ":"), NLSPATH); __stpcpy (__stpcpy (__stpcpy (tmp, nlspath), ":"), NLSPATH);
nlspath = tmp; nlspath = tmp;
nlspath_len = len;
} }
else else
nlspath = NLSPATH;
result->nlspath = __strdup (nlspath);
if (result->nlspath == NULL)
{ {
free ((void *) result->cat_name); nlspath = NLSPATH;
free ((void *) result->env_var);
free ((void *) result); nlspath_len = sizeof NLSPATH;
__set_errno (ENOMEM);
return (nl_catd) -1;
} }
} }
else
{ result = (__nl_catd) malloc (sizeof (*result) + cat_name_len
result->env_var = NULL; + env_var_len + nlspath_len);
result->nlspath = NULL; if (result == NULL)
} /* We cannot get enough memory. */
return (nl_catd) -1;
result->status = closed;
result->cat_name = endp = (char *) (result + 1);
endp = __mempcpy (endp, cat_name, cat_name_len);
result->env_var = cat_name_len != 0 ? endp : NULL;
endp = __mempcpy (endp, env_var, env_var_len);
result->nlspath = nlspath_len != 0 ? endp : NULL;
memcpy (endp, nlspath, nlspath_len);
__libc_lock_init (result->lock); __libc_lock_init (result->lock);
@ -179,10 +162,6 @@ catclose (nl_catd catalog_desc)
return -1; return -1;
} }
if (catalog->nlspath)
free ((void *) catalog->nlspath);
if (catalog->env_var)
free ((void *) catalog->env_var);
free ((void *) catalog); free ((void *) catalog);
return 0; return 0;

View File

@ -1,6 +1,6 @@
/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. /* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>. Contributed by Ulrich Drepper, <drepper@gnu.org>.
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
modify it under the terms of the GNU Library General Public License as modify it under the terms of the GNU Library General Public License as
@ -182,10 +182,13 @@ __open_catalog (__nl_catd catalog)
} }
/* Avoid dealing with directories and block devices */ /* Avoid dealing with directories and block devices */
if (fd < 0 || __fstat (fd, &st) < 0) if (fd < 0)
goto unlock_return;
if (__fxstat (_STAT_VER, fd, &st) < 0)
{ {
catalog->status = nonexisting; catalog->status = nonexisting;
goto unlock_return; goto close_unlock_return;
} }
if (!S_ISREG (st.st_mode) || st.st_size < sizeof (struct catalog_obj)) if (!S_ISREG (st.st_mode) || st.st_size < sizeof (struct catalog_obj))
{ {
@ -193,7 +196,7 @@ __open_catalog (__nl_catd catalog)
Use an reasonable error value. */ Use an reasonable error value. */
__set_errno (EINVAL); __set_errno (EINVAL);
catalog->status = nonexisting; catalog->status = nonexisting;
goto unlock_return; goto close_unlock_return;
} }
catalog->file_size = st.st_size; catalog->file_size = st.st_size;
@ -226,7 +229,7 @@ __open_catalog (__nl_catd catalog)
if (catalog->file_ptr == NULL) if (catalog->file_ptr == NULL)
{ {
catalog->status = nonexisting; catalog->status = nonexisting;
goto unlock_return; goto close_unlock_return;
} }
todo = st.st_size; todo = st.st_size;
/* Save read, handle partial reads. */ /* Save read, handle partial reads. */
@ -238,7 +241,7 @@ __open_catalog (__nl_catd catalog)
{ {
free ((void *) catalog->file_ptr); free ((void *) catalog->file_ptr);
catalog->status = nonexisting; catalog->status = nonexisting;
goto unlock_return; goto close_unlock_return;
} }
todo -= now; todo -= now;
} }
@ -246,10 +249,6 @@ __open_catalog (__nl_catd catalog)
catalog->status = malloced; catalog->status = malloced;
} }
/* We don't need the file anymore. */
__close (fd);
fd = -1;
/* Determine whether the file is a catalog file and if yes whether /* Determine whether the file is a catalog file and if yes whether
it is written using the correct byte order. Else we have to swap it is written using the correct byte order. Else we have to swap
the values. */ the values. */
@ -269,7 +268,7 @@ __open_catalog (__nl_catd catalog)
#endif /* _POSIX_MAPPED_FILES */ #endif /* _POSIX_MAPPED_FILES */
free (catalog->file_ptr); free (catalog->file_ptr);
catalog->status = nonexisting; catalog->status = nonexisting;
goto unlock_return; goto close_unlock_return;
} }
#define SWAP(x) (swapping ? SWAPU32 (x) : (x)) #define SWAP(x) (swapping ? SWAPU32 (x) : (x))
@ -320,8 +319,8 @@ __open_catalog (__nl_catd catalog)
} }
/* Release the lock again. */ /* Release the lock again. */
close_unlock_return:
__close (fd);
unlock_return: unlock_return:
if (fd != -1)
__close (fd);
__libc_lock_unlock (catalog->lock); __libc_lock_unlock (catalog->lock);
} }

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1991, 1997 Free Software Foundation, Inc. /* Copyright (C) 1991, 1997, 1999 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
@ -22,20 +22,21 @@
/* Real function versions of the non-ANSI ctype functions. */ /* Real function versions of the non-ANSI ctype functions. */
int int
isblank (int c) __isblank (int c)
{ {
return __isctype (c, _ISblank); return __isctype (c, _ISblank);
} }
weak_alias (__isblank, isblank)
int int
_tolower (int c) _tolower (int c)
{ {
return c < -128 || c > 255 ? c : __ctype_tolower[c]; return __ctype_tolower[c];
} }
int int
_toupper (int c) _toupper (int c)
{ {
return c < -128 || c > 255 ? c : __ctype_toupper[c]; return __ctype_toupper[c];
} }
int int
@ -43,11 +44,14 @@ toascii (int c)
{ {
return __toascii (c); return __toascii (c);
} }
weak_alias (toascii, __toascii_l)
int int
isascii (int c) isascii (int c)
{ {
return __isascii (c); return __isascii (c);
} }
weak_alias (isascii, __isascii_l)
int int
@ -55,14 +59,3 @@ __isblank_l (int c, __locale_t l)
{ {
return __isctype_l (c, _ISblank, l); return __isctype_l (c, _ISblank, l);
} }
int
__toascii_l (int c, __locale_t l)
{
return __toascii (c);
}
int
__isascii_l (int c, __locale_t l)
{
return __isascii (c);
}

View File

@ -52,7 +52,7 @@ static enum nss_status
compat_call (service_user *nip, const char *user, gid_t group, long int *start, compat_call (service_user *nip, const char *user, gid_t group, long int *start,
long int *size, gid_t *groups, long int limit, int *errnop) long int *size, gid_t *groups, long int limit, int *errnop)
{ {
struct group grpbuf, *g; struct group grpbuf;
size_t buflen = __sysconf (_SC_GETPW_R_SIZE_MAX); size_t buflen = __sysconf (_SC_GETPW_R_SIZE_MAX);
char *tmpbuf; char *tmpbuf;
enum nss_status status; enum nss_status status;
@ -90,25 +90,24 @@ compat_call (service_user *nip, const char *user, gid_t group, long int *start,
if (status != NSS_STATUS_SUCCESS) if (status != NSS_STATUS_SUCCESS)
goto done; goto done;
g = &grpbuf; if (grpbuf.gr_gid != group)
if (g->gr_gid != group)
{ {
char **m; char **m;
for (m = g->gr_mem; *m != NULL; ++m) for (m = grpbuf.gr_mem; *m != NULL; ++m)
if (strcmp (*m, user) == 0) if (strcmp (*m, user) == 0)
{ {
/* Matches user. Insert this group. */ /* Matches user. Insert this group. */
if (*start == *size && limit <= 0) if (*start == *size && limit <= 0)
{ {
/* Need a bigger buffer. */ /* Need a bigger buffer. */
groups = realloc (groups, *size * sizeof (*groups)); groups = realloc (groups, 2 * *size * sizeof (*groups));
if (groups == NULL) if (groups == NULL)
goto done; goto done;
*size *= 2; *size *= 2;
} }
groups[*start] = g->gr_gid; groups[*start] = grpbuf.gr_gid;
*start += 1; *start += 1;
if (*start == limit) if (*start == limit)
@ -196,7 +195,7 @@ initgroups (user, group)
/* This is really only for debugging. */ /* This is really only for debugging. */
if (NSS_STATUS_TRYAGAIN > status || status > NSS_STATUS_RETURN) if (NSS_STATUS_TRYAGAIN > status || status > NSS_STATUS_RETURN)
__libc_fatal ("illegal status in " __FUNCTION__); __libc_fatal ("illegal status in " __FUNCTION__);
if (status != NSS_STATUS_SUCCESS if (status != NSS_STATUS_SUCCESS
&& nss_next_action (nip, status) == NSS_ACTION_RETURN) && nss_next_action (nip, status) == NSS_ACTION_RETURN)

View File

@ -123,7 +123,7 @@ typedef struct gconv_info
{ {
size_t nsteps; size_t nsteps;
struct gconv_step *steps; struct gconv_step *steps;
struct gconv_step_data *data; struct gconv_step_data data[0];
} *gconv_t; } *gconv_t;
#endif /* gconv.h */ #endif /* gconv.h */

View File

@ -1,5 +1,5 @@
/* Release any resource associated with given conversion descriptor. /* Release any resource associated with given conversion descriptor.
Copyright (C) 1997, 1998 Free Software Foundation, Inc. Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@ -44,7 +44,6 @@ __gconv_close (gconv_t cd)
while (!(drunp++)->is_last); while (!(drunp++)->is_last);
/* Free the data allocated for the descriptor. */ /* Free the data allocated for the descriptor. */
free (cd->data);
free (cd); free (cd);
/* Close the participating modules. */ /* Close the participating modules. */

View File

@ -67,8 +67,7 @@ static struct gconv_module builtin_modules[] =
#undef BUILTIN_TRANSFORMATION #undef BUILTIN_TRANSFORMATION
#undef BUILTIN_ALIAS #undef BUILTIN_ALIAS
static const char * static const char *builtin_aliases[] =
builtin_aliases[] =
{ {
#define BUILTIN_TRANSFORMATION(From, ConstPfx, ConstLen, To, Cost, Name, \ #define BUILTIN_TRANSFORMATION(From, ConstPfx, ConstLen, To, Cost, Name, \
Fct, Init, End, MinF, MaxF, MinT, MaxT) Fct, Init, End, MinF, MaxF, MinT, MaxT)
@ -201,14 +200,16 @@ add_alias (char *rp, void *modules)
malloc (sizeof (struct gconv_alias) + (wp - from)); malloc (sizeof (struct gconv_alias) + (wp - from));
if (new_alias != NULL) if (new_alias != NULL)
{ {
void **inserted;
new_alias->fromname = memcpy ((char *) new_alias new_alias->fromname = memcpy ((char *) new_alias
+ sizeof (struct gconv_alias), + sizeof (struct gconv_alias),
from, wp - from); from, wp - from);
new_alias->toname = new_alias->fromname + (to - from); new_alias->toname = new_alias->fromname + (to - from);
if (__tfind (new_alias, &__gconv_alias_db, __gconv_alias_compare) != NULL inserted = (void **) __tsearch (new_alias, &__gconv_alias_db,
|| (__tsearch (new_alias, &__gconv_alias_db, __gconv_alias_compare) __gconv_alias_compare);
== NULL)) if (inserted == NULL || *inserted != (void **) new_alias)
/* Something went wrong, free this entry. */ /* Something went wrong, free this entry. */
free (new_alias); free (new_alias);
} }

View File

@ -139,14 +139,17 @@ add_derivation (const char *fromset, const char *toset,
malloc (sizeof (struct known_derivation) + fromset_len + toset_len); malloc (sizeof (struct known_derivation) + fromset_len + toset_len);
if (new_deriv != NULL) if (new_deriv != NULL)
{ {
new_deriv->from = memcpy (new_deriv + 1, fromset, fromset_len); new_deriv->from = (char *) (new_deriv + 1);
new_deriv->to = memcpy ((char *) new_deriv->from + fromset_len, new_deriv->to = memcpy (__mempcpy (new_deriv + 1, fromset, fromset_len),
toset, toset_len); toset, toset_len);
new_deriv->steps = handle; new_deriv->steps = handle;
new_deriv->nsteps = nsteps; new_deriv->nsteps = nsteps;
__tsearch (new_deriv, &known_derivations, derivation_compare); if (__tsearch (new_deriv, &known_derivations, derivation_compare)
== NULL)
/* There is some kind of memory allocation problem. */
free (new_deriv);
} }
/* Please note that we don't complain if the allocation failed. This /* Please note that we don't complain if the allocation failed. This
is not tragically but in case we use the memory debugging facilities is not tragically but in case we use the memory debugging facilities

View File

@ -1,5 +1,5 @@
/* Find matching transformation algorithms and initialize steps. /* Find matching transformation algorithms and initialize steps.
Copyright (C) 1997, 1998 Free Software Foundation, Inc. Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@ -38,7 +38,8 @@ __gconv_open (const char *toset, const char *fromset, gconv_t *handle)
if (res == GCONV_OK) if (res == GCONV_OK)
{ {
/* Allocate room for handle. */ /* Allocate room for handle. */
result = (gconv_t) malloc (sizeof (struct gconv_info)); result = (gconv_t) malloc (sizeof (struct gconv_info)
+ nsteps * sizeof (struct gconv_step_data));
if (result == NULL) if (result == NULL)
res = GCONV_NOMEM; res = GCONV_NOMEM;
else else
@ -47,47 +48,41 @@ __gconv_open (const char *toset, const char *fromset, gconv_t *handle)
result->steps = steps; result->steps = steps;
result->nsteps = nsteps; result->nsteps = nsteps;
/* Allocate array for the step data. */ /* Clear the array for the step data. */
result->data = (struct gconv_step_data *) memset (result->data, '\0',
calloc (nsteps, sizeof (struct gconv_step_data)); nsteps * sizeof (struct gconv_step_data));
if (result->data == NULL) /* Call all initialization functions for the transformation
res = GCONV_NOMEM; step implemenations. */
else for (cnt = 0; cnt < nsteps; ++cnt)
{ {
/* Call all initialization functions for the transformation /* If this is the last step we must not allocate an
step implemenations. */ output buffer. */
struct gconv_step_data *data = result->data; result->data[cnt].is_last = cnt == nsteps - 1;
for (cnt = 0; cnt < nsteps; ++cnt) /* Reset the counter. */
result->data[cnt].invocation_counter = 0;
/* It's a regular use. */
result->data[cnt].internal_use = 0;
/* We use the `mbstate_t' member in DATA. */
result->data[cnt].statep = &result->data[cnt].__state;
/* Allocate the buffer. */
if (!result->data[cnt].is_last)
{ {
/* If this is the last step we must not allocate an output size_t size = (GCONV_NCHAR_GOAL
buffer. */ * steps[cnt].max_needed_to);
data[cnt].is_last = cnt == nsteps - 1;
/* Reset the counter. */ result->data[cnt].outbuf = (char *) malloc (size);
data[cnt].invocation_counter = 0; if (result->data[cnt].outbuf == NULL)
/* It's a regular use. */
data[cnt].internal_use = 0;
/* We use the `mbstate_t' member in DATA. */
data[cnt].statep = &data[cnt].__state;
/* Allocate the buffer. */
if (!data[cnt].is_last)
{ {
size_t size = (GCONV_NCHAR_GOAL res = GCONV_NOMEM;
* steps[cnt].max_needed_to); break;
data[cnt].outbuf = (char *) malloc (size);
if (data[cnt].outbuf == NULL)
{
res = GCONV_NOMEM;
break;
}
data[cnt].outbufend = data[cnt].outbuf + size;
} }
result->data[cnt].outbufend = (result->data[cnt].outbuf
+ size);
} }
} }
} }
@ -100,13 +95,8 @@ __gconv_open (const char *toset, const char *fromset, gconv_t *handle)
if (result != NULL) if (result != NULL)
{ {
if (result->data != NULL) while (cnt-- > 0)
{ free (result->data[cnt].outbuf);
while (cnt-- > 0)
free (result->data[cnt].outbuf);
free (result->data);
}
free (result); free (result);
result = NULL; result = NULL;

View File

@ -18,4 +18,6 @@ extern char *__strndup __P ((__const char *__string, size_t __n));
extern __ptr_t __rawmemchr __P ((__const __ptr_t __s, int __c)); extern __ptr_t __rawmemchr __P ((__const __ptr_t __s, int __c));
extern char *__strchrnul __P ((__const char *__s, int __c));
#endif #endif

View File

@ -22,7 +22,9 @@ extern size_t __tzname_cur_max;
extern int __use_tzfile; extern int __use_tzfile;
extern void __tzfile_read __P ((const char *file));extern int __tzfile_compute __P ((time_t timer, int use_localtime, extern void __tzfile_read __P ((const char *file, size_t extra,
char **extrap));
extern int __tzfile_compute __P ((time_t timer, int use_localtime,
long int *leap_correct, int *leap_hit, long int *leap_correct, int *leap_hit,
struct tm *tp)); struct tm *tp));
extern void __tzfile_default __P ((const char *std, const char *dst, extern void __tzfile_default __P ((const char *std, const char *dst,

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996 Free Software Foundation, Inc. /* Copyright (C) 1996, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@ -44,7 +44,7 @@ extern int __nss_ethers_lookup (service_user **nip, const char *name,
int int
ether_hostton (const char *hostname, struct ether_addr *addr) ether_hostton (const char *hostname, struct ether_addr *addr)
{ {
static service_user *startp = NULL; static service_user *startp;
static lookup_function start_fct; static lookup_function start_fct;
service_user *nip; service_user *nip;
lookup_function fct; lookup_function fct;

View File

@ -62,9 +62,7 @@ ether_line (const char *line, struct ether_addr *addr, char *hostname)
} }
/* Remove trailing white space. */ /* Remove trailing white space. */
cp = strchr (line, '#'); cp = __strchrnul (line, '#');
if (cp == NULL)
cp = strchr (line, '\0');
while (cp > line && isspace (cp[-1])) while (cp > line && isspace (cp[-1]))
--cp; --cp;
*cp = '\0'; *cp = '\0';

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. /* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@ -45,7 +45,7 @@ extern int __nss_ethers_lookup (service_user **nip, const char *name,
int int
ether_ntohost (char *hostname, const struct ether_addr *addr) ether_ntohost (char *hostname, const struct ether_addr *addr)
{ {
static service_user *startp = NULL; static service_user *startp;
static lookup_function start_fct; static lookup_function start_fct;
service_user *nip; service_user *nip;
lookup_function fct; lookup_function fct;

View File

@ -66,15 +66,15 @@ static char *
internal_function internal_function
nrl_domainname (void) nrl_domainname (void)
{ {
static char *domain = NULL; static char *domain;
static int first = 1; static int not_first;
if (first) if (not_first)
{ {
__libc_lock_define_initialized (static, lock); __libc_lock_define_initialized (static, lock);
__libc_lock_lock (lock); __libc_lock_lock (lock);
if (first) if (not_first)
{ {
char *c; char *c;
struct hostent *h, th; struct hostent *h, th;
@ -82,7 +82,7 @@ nrl_domainname (void)
char *tmpbuf = alloca (tmpbuflen); char *tmpbuf = alloca (tmpbuflen);
int herror; int herror;
first = 0; not_first = 1;
while (__gethostbyname_r ("localhost", &th, tmpbuf, tmpbuflen, &h, while (__gethostbyname_r ("localhost", &th, tmpbuf, tmpbuflen, &h,
&herror)) &herror))

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. /* Copyright (C) 1996, 1997, 1998, 1999 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
@ -48,7 +48,7 @@ static enum nss_status
setup (void **fctp, const char *func_name, int all) setup (void **fctp, const char *func_name, int all)
{ {
/* Remember the first service_entry, it's always the same. */ /* Remember the first service_entry, it's always the same. */
static service_user *startp = NULL; static service_user *startp;
int no_more; int no_more;
if (startp == NULL) if (startp == NULL)

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#ifndef lint #if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)ruserpass.c 8.3 (Berkeley) 4/2/94"; static char sccsid[] = "@(#)ruserpass.c 8.3 (Berkeley) 4/2/94";
#endif /* not lint */ #endif /* not lint */
@ -61,18 +61,35 @@ static FILE *cfile;
static char tokval[100]; static char tokval[100];
static struct toktab { static const char tokstr[] =
const char *tokstr; {
#define TOK_DEFAULT_IDX 0
"default\0"
#define TOK_LOGIN_IDX (TOK_DEFAULT_IDX + sizeof "default")
"login\0"
#define TOK_PASSWORD_IDX (TOK_LOGIN_IDX + sizeof "login")
"password\0"
#define TOK_PASSWD_IDX (TOK_PASSWORD_IDX + sizeof "password")
"passwd\0"
#define TOK_ACCOUNT_IDX (TOK_PASSWD_IDX + sizeof "passwd")
"account\0"
#define TOK_MACHINE_IDX (TOK_ACCOUNT_IDX + sizeof "account")
"machine\0"
#define TOK_MACDEF_IDX (TOK_MACHINE_IDX + sizeof "machine")
"macdef"
};
static const struct toktab {
int tokstr_off;
int tval; int tval;
} toktab[]= { } toktab[]= {
{ "default", DEFAULT }, { TOK_DEFAULT_IDX, DEFAULT },
{ "login", LOGIN }, { TOK_LOGIN_IDX, LOGIN },
{ "password", PASSWD }, { TOK_PASSWORD_IDX, PASSWD },
{ "passwd", PASSWD }, { TOK_PASSWD_IDX, PASSWD },
{ "account", ACCOUNT }, { TOK_ACCOUNT_IDX, ACCOUNT },
{ "machine", MACHINE }, { TOK_MACHINE_IDX, MACHINE },
{ "macdef", MACDEF }, { TOK_MACDEF_IDX, MACDEF }
{ NULL, 0 }
}; };
@ -106,8 +123,7 @@ ruserpass(host, aname, apass)
} }
if (__gethostname(myname, sizeof(myname)) < 0) if (__gethostname(myname, sizeof(myname)) < 0)
myname[0] = '\0'; myname[0] = '\0';
if ((mydomain = strchr(myname, '.')) == NULL) mydomain = __strchrnul(myname, '.');
mydomain = "";
next: next:
while ((t = token())) switch(t) { while ((t = token())) switch(t) {
@ -262,7 +278,7 @@ token()
{ {
char *cp; char *cp;
int c; int c;
struct toktab *t; int i;
if (feof_unlocked(cfile) || ferror_unlocked(cfile)) if (feof_unlocked(cfile) || ferror_unlocked(cfile))
return (0); return (0);
@ -290,8 +306,8 @@ token()
*cp = 0; *cp = 0;
if (tokval[0] == 0) if (tokval[0] == 0)
return (0); return (0);
for (t = toktab; t->tokstr; t++) for (i = 0; i < sizeof (toktab) / sizeof (toktab[0]); ++i)
if (!strcmp(t->tokstr, tokval)) if (!strcmp(&tokstr[toktab[i].tokstr_off], tokval))
return (t->tval); return toktab[i].tval;
return (ID); return (ID);
} }

View File

@ -47,11 +47,6 @@ void free ();
# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) # define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
# endif # endif
#endif #endif
#if !HAVE_STRCHR && !defined _LIBC
# ifndef strchr
# define strchr index
# endif
#endif
#if defined HAVE_UNISTD_H || defined _LIBC #if defined HAVE_UNISTD_H || defined _LIBC
# include <unistd.h> # include <unistd.h>

View File

@ -1,5 +1,5 @@
/* Load needed message catalogs. /* Load needed message catalogs.
Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of This file is part of the GNU C Library. Its master source is NOT part of
the C library, however. the C library, however.
@ -63,7 +63,7 @@
/* We need a sign, whether a new catalog was loaded, which can be associated /* We need a sign, whether a new catalog was loaded, which can be associated
with all translations. This is important if the translations are with all translations. This is important if the translations are
cached by one of GCC's features. */ cached by one of GCC's features. */
int _nl_msg_cat_cntr = 0; int _nl_msg_cat_cntr;
/* Load the message catalogs specified by FILENAME. If it is no valid /* Load the message catalogs specified by FILENAME. If it is no valid

View File

@ -1,5 +1,5 @@
/* Handle aliases for locale names. /* Handle aliases for locale names.
Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of This file is part of the GNU C Library. Its master source is NOT part of
the C library, however. the C library, however.
@ -150,12 +150,12 @@ struct alias_map
}; };
static char *string_space = NULL; static char *string_space;
static size_t string_space_act = 0; static size_t string_space_act;
static size_t string_space_max = 0; static size_t string_space_max;
static struct alias_map *map; static struct alias_map *map;
static size_t nmap = 0; static size_t nmap;
static size_t maxmap = 0; static size_t maxmap;
/* Prototypes for local functions. */ /* Prototypes for local functions. */

View File

@ -78,7 +78,7 @@ struct ftw_data
/* Conversion array for flag values. It is the identity mapping for /* Conversion array for flag values. It is the identity mapping for
`nftw' calls, otherwise it maps the values to those know by `nftw' calls, otherwise it maps the values to those know by
`ftw'. */ `ftw'. */
int *cvt_arr; const int *cvt_arr;
/* Callback function. We always use the `nftw' form. */ /* Callback function. We always use the `nftw' form. */
NFTW_FUNC_T func; NFTW_FUNC_T func;
@ -95,12 +95,12 @@ struct ftw_data
/* Internally we use the FTW_* constants used for `nftw'. When the /* Internally we use the FTW_* constants used for `nftw'. When the
process called `ftw' we must reduce the flag to the known flags process called `ftw' we must reduce the flag to the known flags
for `ftw'. */ for `ftw'. */
static int nftw_arr[] = static const int nftw_arr[] =
{ {
FTW_F, FTW_D, FTW_DNR, FTW_NS, FTW_SL, FTW_DP, FTW_SLN FTW_F, FTW_D, FTW_DNR, FTW_NS, FTW_SL, FTW_DP, FTW_SLN
}; };
static int ftw_arr[] = static const int ftw_arr[] =
{ {
FTW_F, FTW_D, FTW_DNR, FTW_NS, FTW_F, FTW_D, FTW_NS FTW_F, FTW_D, FTW_DNR, FTW_NS, FTW_F, FTW_D, FTW_NS
}; };

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1993, 1997, 1998 Free Software Foundation, Inc. /* Copyright (C) 1993, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU IO Library. This file is part of the GNU IO Library.
Written by Per Bothner <bothner@cygnus.com>. Written by Per Bothner <bothner@cygnus.com>.
@ -101,7 +101,7 @@ struct _IO_proc_file
}; };
typedef struct _IO_proc_file _IO_proc_file; typedef struct _IO_proc_file _IO_proc_file;
static struct _IO_proc_file *proc_file_chain = NULL; static struct _IO_proc_file *proc_file_chain;
_IO_FILE * _IO_FILE *
_IO_new_proc_open (fp, command, mode) _IO_new_proc_open (fp, command, mode)

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1998 Free Software Foundation, Inc. /* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU IO Library. This file is part of the GNU IO Library.
Written by Per Bothner <bothner@cygnus.com>. Written by Per Bothner <bothner@cygnus.com>.
@ -102,7 +102,7 @@ struct _IO_proc_file
}; };
typedef struct _IO_proc_file _IO_proc_file; typedef struct _IO_proc_file _IO_proc_file;
static struct _IO_proc_file *old_proc_file_chain = NULL; static struct _IO_proc_file *old_proc_file_chain;
_IO_FILE * _IO_FILE *
_IO_old_proc_open (fp, command, mode) _IO_old_proc_open (fp, command, mode)

View File

@ -1,3 +1,8 @@
1999-04-28 Ulrich Drepper <drepper@cygnus.com>
* manager.c (pthread_allocate_stack): Optimize initialization of new
thread descriptor.
1999-04-16 Andreas Jaeger <aj@arthur.rhein-neckar.de> 1999-04-16 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* sysdeps/arm/Implies: Removed since cmpxchg/no-cmpxchg * sysdeps/arm/Implies: Removed since cmpxchg/no-cmpxchg

View File

@ -274,6 +274,8 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
} }
} }
} }
/* Clear the thread data structure. */
memset (new_thread, '\0', sizeof (*new_thread));
*out_new_thread = new_thread; *out_new_thread = new_thread;
*out_new_thread_bottom = new_thread_bottom; *out_new_thread_bottom = new_thread_bottom;
*out_guardaddr = guardaddr; *out_guardaddr = guardaddr;
@ -316,34 +318,16 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
/* Allocate new thread identifier */ /* Allocate new thread identifier */
pthread_threads_counter += PTHREAD_THREADS_MAX; pthread_threads_counter += PTHREAD_THREADS_MAX;
new_thread_id = sseg + pthread_threads_counter; new_thread_id = sseg + pthread_threads_counter;
/* Initialize the thread descriptor */ /* Initialize the thread descriptor. Elements which have to be
new_thread->p_nextwaiting = NULL; initialized to zero already have this value. */
new_thread->p_tid = new_thread_id; new_thread->p_tid = new_thread_id;
new_thread->p_priority = 0;
new_thread->p_lock = &(__pthread_handles[sseg].h_lock); new_thread->p_lock = &(__pthread_handles[sseg].h_lock);
new_thread->p_signal = 0;
new_thread->p_signal_jmp = NULL;
new_thread->p_cancel_jmp = NULL;
new_thread->p_terminated = 0;
new_thread->p_detached = attr == NULL ? 0 : attr->__detachstate;
new_thread->p_exited = 0;
new_thread->p_retval = NULL;
new_thread->p_joining = NULL;
new_thread->p_cleanup = NULL;
new_thread->p_cancelstate = PTHREAD_CANCEL_ENABLE; new_thread->p_cancelstate = PTHREAD_CANCEL_ENABLE;
new_thread->p_canceltype = PTHREAD_CANCEL_DEFERRED; new_thread->p_canceltype = PTHREAD_CANCEL_DEFERRED;
new_thread->p_canceled = 0;
new_thread->p_errnop = &new_thread->p_errno; new_thread->p_errnop = &new_thread->p_errno;
new_thread->p_errno = 0;
new_thread->p_h_errnop = &new_thread->p_h_errno; new_thread->p_h_errnop = &new_thread->p_h_errno;
new_thread->p_h_errno = 0;
new_thread->p_in_sighandler = NULL;
new_thread->p_sigwaiting = 0;
new_thread->p_guardaddr = guardaddr; new_thread->p_guardaddr = guardaddr;
new_thread->p_guardsize = guardsize; new_thread->p_guardsize = guardsize;
new_thread->p_userstack = attr != NULL && attr->__stackaddr_set;
memset (new_thread->p_specific, '\0',
PTHREAD_KEY_1STLEVEL_SIZE * sizeof (new_thread->p_specific[0]));
new_thread->p_self = new_thread; new_thread->p_self = new_thread;
new_thread->p_nr = sseg; new_thread->p_nr = sseg;
/* Initialize the thread handle */ /* Initialize the thread handle */
@ -353,6 +337,9 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
/* Determine scheduling parameters for the thread */ /* Determine scheduling parameters for the thread */
new_thread->p_start_args.schedpolicy = -1; new_thread->p_start_args.schedpolicy = -1;
if (attr != NULL) { if (attr != NULL) {
new_thread->p_detached = attr->__detachstate;
new_thread->p_userstack = attr->__stackaddr_set;
switch(attr->__inheritsched) { switch(attr->__inheritsched) {
case PTHREAD_EXPLICIT_SCHED: case PTHREAD_EXPLICIT_SCHED:
new_thread->p_start_args.schedpolicy = attr->__schedpolicy; new_thread->p_start_args.schedpolicy = attr->__schedpolicy;