aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-04-28 21:56:46 +0000
committerUlrich Drepper <drepper@redhat.com>1999-04-28 21:56:46 +0000
commit390500b147a8063ea4be7313ec38cada26f9235a (patch)
treeedf14c04a0a46992ce4c04eeaf604fab99a9d960
parentfbb9cc9129ae3efdb1652b175f57956033102876 (diff)
downloadglibc-390500b147a8063ea4be7313ec38cada26f9235a.zip
glibc-390500b147a8063ea4be7313ec38cada26f9235a.tar.gz
glibc-390500b147a8063ea4be7313ec38cada26f9235a.tar.bz2
Update.
1999-04-28 Ulrich Drepper <drepper@cygnus.com> * manager.c (pthread_allocate_stack): Optimize initialization of new thread descriptor.
-rw-r--r--argp/argp-ba.c4
-rw-r--r--argp/argp-help.c8
-rw-r--r--argp/argp-parse.c4
-rw-r--r--argp/argp-pv.c4
-rw-r--r--argp/argp-pvh.c4
-rw-r--r--catgets/catgets.c95
-rw-r--r--catgets/open_catalog.c27
-rw-r--r--ctype/ctype-extn.c23
-rw-r--r--grp/initgroups.c13
-rw-r--r--iconv/gconv.h2
-rw-r--r--iconv/gconv_close.c3
-rw-r--r--iconv/gconv_conf.c11
-rw-r--r--iconv/gconv_db.c9
-rw-r--r--iconv/gconv_open.c72
-rw-r--r--include/string.h2
-rw-r--r--include/time.h4
-rw-r--r--inet/ether_hton.c4
-rw-r--r--inet/ether_line.c4
-rw-r--r--inet/ether_ntoh.c4
-rw-r--r--inet/getnameinfo.c10
-rw-r--r--inet/getnetgrent_r.c4
-rw-r--r--inet/ruserpass.c50
-rw-r--r--intl/finddomain.c5
-rw-r--r--intl/loadmsgcat.c4
-rw-r--r--intl/localealias.c12
-rw-r--r--io/ftw.c6
-rw-r--r--libio/iopopen.c4
-rw-r--r--libio/oldiopopen.c4
-rw-r--r--linuxthreads/ChangeLog5
-rw-r--r--linuxthreads/manager.c27
30 files changed, 197 insertions, 231 deletions
diff --git a/argp/argp-ba.c b/argp/argp-ba.c
index 5d58cc6..5657c27 100644
--- a/argp/argp-ba.c
+++ b/argp/argp-ba.c
@@ -1,5 +1,5 @@
/* 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.
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
messages), embedded in a sentence that says something like `Report bugs to
ADDR.'. */
-const char *argp_program_bug_address = 0;
+const char *argp_program_bug_address;
diff --git a/argp/argp-help.c b/argp/argp-help.c
index d78060d..f5d96fb 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -1376,19 +1376,17 @@ argp_args_usage (const struct argp *argp, const struct argp_state *state,
if (fdoc)
{
const char *cp = fdoc;
- nl = strchr (cp, '\n');
- if (nl)
+ nl = __strchrnul (cp, '\n');
+ if (*nl != '\0')
/* This is a `multi-level' args doc; advance to the correct position
as determined by our state in LEVELS, and update LEVELS. */
{
int i;
multiple = 1;
for (i = 0; i < *our_level; i++)
- cp = nl + 1, nl = strchr (cp, '\n');
+ cp = nl + 1, nl = __strchrnul (cp, '\n');
(*levels)++;
}
- if (! nl)
- nl = cp + strlen (cp);
/* Manually do line wrapping so that it (probably) won't get wrapped at
any embedded spaces. */
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index e59f614..758129a 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -1,5 +1,5 @@
/* 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.
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
you can force the program to continue by attaching a debugger and setting
it to 0 yourself. */
-volatile int _argp_hang = 0;
+volatile int _argp_hang;
#define OPT_PROGNAME -2
#define OPT_USAGE -3
diff --git a/argp/argp-pv.c b/argp/argp-pv.c
index 27d714b..5061074 100644
--- a/argp/argp-pv.c
+++ b/argp/argp-pv.c
@@ -1,5 +1,5 @@
/* 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.
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
print this this string followed by a newline and exit (unless the
ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
-const char *argp_program_version = 0;
+const char *argp_program_version;
diff --git a/argp/argp-pvh.c b/argp/argp-pvh.c
index ed60aa9..2d0bd39 100644
--- a/argp/argp-pvh.c
+++ b/argp/argp-pvh.c
@@ -1,5 +1,5 @@
/* 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.
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
current parsing state, and then exits (unless the ARGP_NO_EXIT flag is
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);
diff --git a/catgets/catgets.c b/catgets/catgets.c
index 55de30e..c6fd13d 100644
--- a/catgets/catgets.c
+++ b/catgets/catgets.c
@@ -33,23 +33,12 @@ nl_catd
catopen (const char *cat_name, int flag)
{
__nl_catd result;
- const char *env_var;
- const char *nlspath;
-
- result = (__nl_catd) malloc (sizeof (*result));
- if (result == NULL)
- /* We cannot get enough memory. */
- 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;
- }
+ const char *env_var = NULL;
+ const char *nlspath = NULL;
+ size_t cat_name_len = strlen (cat_name) + 1;
+ size_t env_var_len = 0;
+ size_t nlspath_len = 0;
+ char *endp;
if (strchr (cat_name, '/') == NULL)
{
@@ -57,32 +46,19 @@ catopen (const char *cat_name, int flag)
{
env_var = getenv ("LC_ALL");
if (env_var == NULL)
- {
- env_var = getenv ("LC_MESSAGES");
- if (env_var == NULL)
- {
- env_var = getenv ("LANG");
- if (env_var == NULL)
- env_var = "C";
- }
- }
- }
- else
- {
- env_var = getenv ("LANG");
- if (env_var == NULL)
- env_var = "C";
- }
+ env_var = getenv ("LC_MESSAGES");
- result->env_var = __strdup (env_var);
- if (result->env_var == NULL)
- {
- free ((void *) result->cat_name);
- free ((void *) result);
- __set_errno (ENOMEM);
- return (nl_catd) -1;
+ if (env_var != NULL)
+ goto have_env_var;
}
+ env_var = getenv ("LANG");
+ if (env_var == NULL)
+ env_var = "C";
+
+ have_env_var:
+ env_var_len = strlen (env_var) + 1;
+
nlspath = __secure_getenv ("NLSPATH");
if (nlspath != NULL && *nlspath != '\0')
{
@@ -92,25 +68,32 @@ catopen (const char *cat_name, int flag)
__stpcpy (__stpcpy (__stpcpy (tmp, nlspath), ":"), NLSPATH);
nlspath = tmp;
+
+ nlspath_len = len;
}
else
- nlspath = NLSPATH;
-
- result->nlspath = __strdup (nlspath);
- if (result->nlspath == NULL)
{
- free ((void *) result->cat_name);
- free ((void *) result->env_var);
- free ((void *) result);
- __set_errno (ENOMEM);
- return (nl_catd) -1;
+ nlspath = NLSPATH;
+
+ nlspath_len = sizeof NLSPATH;
}
}
- else
- {
- result->env_var = NULL;
- result->nlspath = NULL;
- }
+
+ result = (__nl_catd) malloc (sizeof (*result) + cat_name_len
+ + env_var_len + nlspath_len);
+ 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);
@@ -179,10 +162,6 @@ catclose (nl_catd catalog_desc)
return -1;
}
- if (catalog->nlspath)
- free ((void *) catalog->nlspath);
- if (catalog->env_var)
- free ((void *) catalog->env_var);
free ((void *) catalog);
return 0;
diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
index e4b61d7..4b619e4 100644
--- a/catgets/open_catalog.c
+++ b/catgets/open_catalog.c
@@ -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.
- 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
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 */
- if (fd < 0 || __fstat (fd, &st) < 0)
+ if (fd < 0)
+ goto unlock_return;
+
+ if (__fxstat (_STAT_VER, fd, &st) < 0)
{
catalog->status = nonexisting;
- goto unlock_return;
+ goto close_unlock_return;
}
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. */
__set_errno (EINVAL);
catalog->status = nonexisting;
- goto unlock_return;
+ goto close_unlock_return;
}
catalog->file_size = st.st_size;
@@ -226,7 +229,7 @@ __open_catalog (__nl_catd catalog)
if (catalog->file_ptr == NULL)
{
catalog->status = nonexisting;
- goto unlock_return;
+ goto close_unlock_return;
}
todo = st.st_size;
/* Save read, handle partial reads. */
@@ -238,7 +241,7 @@ __open_catalog (__nl_catd catalog)
{
free ((void *) catalog->file_ptr);
catalog->status = nonexisting;
- goto unlock_return;
+ goto close_unlock_return;
}
todo -= now;
}
@@ -246,10 +249,6 @@ __open_catalog (__nl_catd catalog)
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
it is written using the correct byte order. Else we have to swap
the values. */
@@ -269,7 +268,7 @@ __open_catalog (__nl_catd catalog)
#endif /* _POSIX_MAPPED_FILES */
free (catalog->file_ptr);
catalog->status = nonexisting;
- goto unlock_return;
+ goto close_unlock_return;
}
#define SWAP(x) (swapping ? SWAPU32 (x) : (x))
@@ -320,8 +319,8 @@ __open_catalog (__nl_catd catalog)
}
/* Release the lock again. */
+ close_unlock_return:
+ __close (fd);
unlock_return:
- if (fd != -1)
- __close (fd);
__libc_lock_unlock (catalog->lock);
}
diff --git a/ctype/ctype-extn.c b/ctype/ctype-extn.c
index 5daba66..cfc8b87 100644
--- a/ctype/ctype-extn.c
+++ b/ctype/ctype-extn.c
@@ -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.
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. */
int
-isblank (int c)
+__isblank (int c)
{
return __isctype (c, _ISblank);
}
+weak_alias (__isblank, isblank)
int
_tolower (int c)
{
- return c < -128 || c > 255 ? c : __ctype_tolower[c];
+ return __ctype_tolower[c];
}
int
_toupper (int c)
{
- return c < -128 || c > 255 ? c : __ctype_toupper[c];
+ return __ctype_toupper[c];
}
int
@@ -43,11 +44,14 @@ toascii (int c)
{
return __toascii (c);
}
+weak_alias (toascii, __toascii_l)
+
int
isascii (int c)
{
return __isascii (c);
}
+weak_alias (isascii, __isascii_l)
int
@@ -55,14 +59,3 @@ __isblank_l (int c, __locale_t 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);
-}
diff --git a/grp/initgroups.c b/grp/initgroups.c
index 93f78eb..0296625 100644
--- a/grp/initgroups.c
+++ b/grp/initgroups.c
@@ -52,7 +52,7 @@ static enum nss_status
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)
{
- struct group grpbuf, *g;
+ struct group grpbuf;
size_t buflen = __sysconf (_SC_GETPW_R_SIZE_MAX);
char *tmpbuf;
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)
goto done;
- g = &grpbuf;
- if (g->gr_gid != group)
+ if (grpbuf.gr_gid != group)
{
char **m;
- for (m = g->gr_mem; *m != NULL; ++m)
+ for (m = grpbuf.gr_mem; *m != NULL; ++m)
if (strcmp (*m, user) == 0)
{
/* Matches user. Insert this group. */
if (*start == *size && limit <= 0)
{
/* Need a bigger buffer. */
- groups = realloc (groups, *size * sizeof (*groups));
+ groups = realloc (groups, 2 * *size * sizeof (*groups));
if (groups == NULL)
goto done;
*size *= 2;
}
- groups[*start] = g->gr_gid;
+ groups[*start] = grpbuf.gr_gid;
*start += 1;
if (*start == limit)
@@ -196,7 +195,7 @@ initgroups (user, group)
/* This is really only for debugging. */
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
&& nss_next_action (nip, status) == NSS_ACTION_RETURN)
diff --git a/iconv/gconv.h b/iconv/gconv.h
index 6576b06..4b71ccf 100644
--- a/iconv/gconv.h
+++ b/iconv/gconv.h
@@ -123,7 +123,7 @@ typedef struct gconv_info
{
size_t nsteps;
struct gconv_step *steps;
- struct gconv_step_data *data;
+ struct gconv_step_data data[0];
} *gconv_t;
#endif /* gconv.h */
diff --git a/iconv/gconv_close.c b/iconv/gconv_close.c
index de0937d..2fe8424 100644
--- a/iconv/gconv_close.c
+++ b/iconv/gconv_close.c
@@ -1,5 +1,5 @@
/* 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.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -44,7 +44,6 @@ __gconv_close (gconv_t cd)
while (!(drunp++)->is_last);
/* Free the data allocated for the descriptor. */
- free (cd->data);
free (cd);
/* Close the participating modules. */
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index a0aae43..dce913d 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -67,8 +67,7 @@ static struct gconv_module builtin_modules[] =
#undef BUILTIN_TRANSFORMATION
#undef BUILTIN_ALIAS
-static const char *
-builtin_aliases[] =
+static const char *builtin_aliases[] =
{
#define BUILTIN_TRANSFORMATION(From, ConstPfx, ConstLen, To, Cost, Name, \
Fct, Init, End, MinF, MaxF, MinT, MaxT)
@@ -201,14 +200,16 @@ add_alias (char *rp, void *modules)
malloc (sizeof (struct gconv_alias) + (wp - from));
if (new_alias != NULL)
{
+ void **inserted;
+
new_alias->fromname = memcpy ((char *) new_alias
+ sizeof (struct gconv_alias),
from, wp - from);
new_alias->toname = new_alias->fromname + (to - from);
- if (__tfind (new_alias, &__gconv_alias_db, __gconv_alias_compare) != NULL
- || (__tsearch (new_alias, &__gconv_alias_db, __gconv_alias_compare)
- == NULL))
+ inserted = (void **) __tsearch (new_alias, &__gconv_alias_db,
+ __gconv_alias_compare);
+ if (inserted == NULL || *inserted != (void **) new_alias)
/* Something went wrong, free this entry. */
free (new_alias);
}
diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c
index fdc3064..4abc1ae 100644
--- a/iconv/gconv_db.c
+++ b/iconv/gconv_db.c
@@ -139,14 +139,17 @@ add_derivation (const char *fromset, const char *toset,
malloc (sizeof (struct known_derivation) + fromset_len + toset_len);
if (new_deriv != NULL)
{
- new_deriv->from = memcpy (new_deriv + 1, fromset, fromset_len);
- new_deriv->to = memcpy ((char *) new_deriv->from + fromset_len,
+ new_deriv->from = (char *) (new_deriv + 1);
+ new_deriv->to = memcpy (__mempcpy (new_deriv + 1, fromset, fromset_len),
toset, toset_len);
new_deriv->steps = handle;
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
is not tragically but in case we use the memory debugging facilities
diff --git a/iconv/gconv_open.c b/iconv/gconv_open.c
index fb5f88b..f3b6dfa 100644
--- a/iconv/gconv_open.c
+++ b/iconv/gconv_open.c
@@ -1,5 +1,5 @@
/* 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.
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)
{
/* 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)
res = GCONV_NOMEM;
else
@@ -47,47 +48,41 @@ __gconv_open (const char *toset, const char *fromset, gconv_t *handle)
result->steps = steps;
result->nsteps = nsteps;
- /* Allocate array for the step data. */
- result->data = (struct gconv_step_data *)
- calloc (nsteps, sizeof (struct gconv_step_data));
+ /* Clear the array for the step data. */
+ memset (result->data, '\0',
+ nsteps * sizeof (struct gconv_step_data));
- if (result->data == NULL)
- res = GCONV_NOMEM;
- else
+ /* Call all initialization functions for the transformation
+ step implemenations. */
+ for (cnt = 0; cnt < nsteps; ++cnt)
{
- /* Call all initialization functions for the transformation
- step implemenations. */
- struct gconv_step_data *data = result->data;
+ /* If this is the last step we must not allocate an
+ output buffer. */
+ result->data[cnt].is_last = cnt == nsteps - 1;
- for (cnt = 0; cnt < nsteps; ++cnt)
- {
- /* If this is the last step we must not allocate an output
- buffer. */
- data[cnt].is_last = cnt == nsteps - 1;
+ /* Reset the counter. */
+ result->data[cnt].invocation_counter = 0;
- /* Reset the counter. */
- data[cnt].invocation_counter = 0;
+ /* It's a regular use. */
+ result->data[cnt].internal_use = 0;
- /* It's a regular use. */
- data[cnt].internal_use = 0;
+ /* We use the `mbstate_t' member in DATA. */
+ result->data[cnt].statep = &result->data[cnt].__state;
- /* We use the `mbstate_t' member in DATA. */
- data[cnt].statep = &data[cnt].__state;
+ /* Allocate the buffer. */
+ if (!result->data[cnt].is_last)
+ {
+ size_t size = (GCONV_NCHAR_GOAL
+ * steps[cnt].max_needed_to);
- /* Allocate the buffer. */
- if (!data[cnt].is_last)
+ result->data[cnt].outbuf = (char *) malloc (size);
+ if (result->data[cnt].outbuf == NULL)
{
- size_t size = (GCONV_NCHAR_GOAL
- * steps[cnt].max_needed_to);
-
- data[cnt].outbuf = (char *) malloc (size);
- if (data[cnt].outbuf == NULL)
- {
- res = GCONV_NOMEM;
- break;
- }
- data[cnt].outbufend = data[cnt].outbuf + size;
+ res = GCONV_NOMEM;
+ break;
}
+ 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->data != NULL)
- {
- while (cnt-- > 0)
- free (result->data[cnt].outbuf);
-
- free (result->data);
- }
+ while (cnt-- > 0)
+ free (result->data[cnt].outbuf);
free (result);
result = NULL;
diff --git a/include/string.h b/include/string.h
index c225d65..4d610ba 100644
--- a/include/string.h
+++ b/include/string.h
@@ -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 char *__strchrnul __P ((__const char *__s, int __c));
+
#endif
diff --git a/include/time.h b/include/time.h
index 444679d..fcfb3fe 100644
--- a/include/time.h
+++ b/include/time.h
@@ -22,7 +22,9 @@ extern size_t __tzname_cur_max;
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,
struct tm *tp));
extern void __tzfile_default __P ((const char *std, const char *dst,
diff --git a/inet/ether_hton.c b/inet/ether_hton.c
index 4e24fbb..92353c1 100644
--- a/inet/ether_hton.c
+++ b/inet/ether_hton.c
@@ -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.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -44,7 +44,7 @@ extern int __nss_ethers_lookup (service_user **nip, const char *name,
int
ether_hostton (const char *hostname, struct ether_addr *addr)
{
- static service_user *startp = NULL;
+ static service_user *startp;
static lookup_function start_fct;
service_user *nip;
lookup_function fct;
diff --git a/inet/ether_line.c b/inet/ether_line.c
index 889be0a4..0911499 100644
--- a/inet/ether_line.c
+++ b/inet/ether_line.c
@@ -62,9 +62,7 @@ ether_line (const char *line, struct ether_addr *addr, char *hostname)
}
/* Remove trailing white space. */
- cp = strchr (line, '#');
- if (cp == NULL)
- cp = strchr (line, '\0');
+ cp = __strchrnul (line, '#');
while (cp > line && isspace (cp[-1]))
--cp;
*cp = '\0';
diff --git a/inet/ether_ntoh.c b/inet/ether_ntoh.c
index ab3650f..6937201 100644
--- a/inet/ether_ntoh.c
+++ b/inet/ether_ntoh.c
@@ -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.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -45,7 +45,7 @@ extern int __nss_ethers_lookup (service_user **nip, const char *name,
int
ether_ntohost (char *hostname, const struct ether_addr *addr)
{
- static service_user *startp = NULL;
+ static service_user *startp;
static lookup_function start_fct;
service_user *nip;
lookup_function fct;
diff --git a/inet/getnameinfo.c b/inet/getnameinfo.c
index f31d3b9..b69bdbe 100644
--- a/inet/getnameinfo.c
+++ b/inet/getnameinfo.c
@@ -66,15 +66,15 @@ static char *
internal_function
nrl_domainname (void)
{
- static char *domain = NULL;
- static int first = 1;
+ static char *domain;
+ static int not_first;
- if (first)
+ if (not_first)
{
__libc_lock_define_initialized (static, lock);
__libc_lock_lock (lock);
- if (first)
+ if (not_first)
{
char *c;
struct hostent *h, th;
@@ -82,7 +82,7 @@ nrl_domainname (void)
char *tmpbuf = alloca (tmpbuflen);
int herror;
- first = 0;
+ not_first = 1;
while (__gethostbyname_r ("localhost", &th, tmpbuf, tmpbuflen, &h,
&herror))
diff --git a/inet/getnetgrent_r.c b/inet/getnetgrent_r.c
index d344379..4bbba38 100644
--- a/inet/getnetgrent_r.c
+++ b/inet/getnetgrent_r.c
@@ -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.
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)
{
/* Remember the first service_entry, it's always the same. */
- static service_user *startp = NULL;
+ static service_user *startp;
int no_more;
if (startp == NULL)
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index d8ea79a..2673fc5 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*/
-#ifndef lint
+#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)ruserpass.c 8.3 (Berkeley) 4/2/94";
#endif /* not lint */
@@ -61,18 +61,35 @@ static FILE *cfile;
static char tokval[100];
-static struct toktab {
- const char *tokstr;
+static 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;
} toktab[]= {
- { "default", DEFAULT },
- { "login", LOGIN },
- { "password", PASSWD },
- { "passwd", PASSWD },
- { "account", ACCOUNT },
- { "machine", MACHINE },
- { "macdef", MACDEF },
- { NULL, 0 }
+ { TOK_DEFAULT_IDX, DEFAULT },
+ { TOK_LOGIN_IDX, LOGIN },
+ { TOK_PASSWORD_IDX, PASSWD },
+ { TOK_PASSWD_IDX, PASSWD },
+ { TOK_ACCOUNT_IDX, ACCOUNT },
+ { TOK_MACHINE_IDX, MACHINE },
+ { TOK_MACDEF_IDX, MACDEF }
};
@@ -106,8 +123,7 @@ ruserpass(host, aname, apass)
}
if (__gethostname(myname, sizeof(myname)) < 0)
myname[0] = '\0';
- if ((mydomain = strchr(myname, '.')) == NULL)
- mydomain = "";
+ mydomain = __strchrnul(myname, '.');
next:
while ((t = token())) switch(t) {
@@ -262,7 +278,7 @@ token()
{
char *cp;
int c;
- struct toktab *t;
+ int i;
if (feof_unlocked(cfile) || ferror_unlocked(cfile))
return (0);
@@ -290,8 +306,8 @@ token()
*cp = 0;
if (tokval[0] == 0)
return (0);
- for (t = toktab; t->tokstr; t++)
- if (!strcmp(t->tokstr, tokval))
- return (t->tval);
+ for (i = 0; i < sizeof (toktab) / sizeof (toktab[0]); ++i)
+ if (!strcmp(&tokstr[toktab[i].tokstr_off], tokval))
+ return toktab[i].tval;
return (ID);
}
diff --git a/intl/finddomain.c b/intl/finddomain.c
index 7734fbf..a3083b1 100644
--- a/intl/finddomain.c
+++ b/intl/finddomain.c
@@ -47,11 +47,6 @@ void free ();
# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
# endif
#endif
-#if !HAVE_STRCHR && !defined _LIBC
-# ifndef strchr
-# define strchr index
-# endif
-#endif
#if defined HAVE_UNISTD_H || defined _LIBC
# include <unistd.h>
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
index 480e6bc..76887e8 100644
--- a/intl/loadmsgcat.c
+++ b/intl/loadmsgcat.c
@@ -1,5 +1,5 @@
/* 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
the C library, however.
@@ -63,7 +63,7 @@
/* We need a sign, whether a new catalog was loaded, which can be associated
with all translations. This is important if the translations are
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
diff --git a/intl/localealias.c b/intl/localealias.c
index 0c35b7a..9f2c510 100644
--- a/intl/localealias.c
+++ b/intl/localealias.c
@@ -1,5 +1,5 @@
/* 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
the C library, however.
@@ -150,12 +150,12 @@ struct alias_map
};
-static char *string_space = NULL;
-static size_t string_space_act = 0;
-static size_t string_space_max = 0;
+static char *string_space;
+static size_t string_space_act;
+static size_t string_space_max;
static struct alias_map *map;
-static size_t nmap = 0;
-static size_t maxmap = 0;
+static size_t nmap;
+static size_t maxmap;
/* Prototypes for local functions. */
diff --git a/io/ftw.c b/io/ftw.c
index 2d4a837..f1e2fd9 100644
--- a/io/ftw.c
+++ b/io/ftw.c
@@ -78,7 +78,7 @@ struct ftw_data
/* Conversion array for flag values. It is the identity mapping for
`nftw' calls, otherwise it maps the values to those know by
`ftw'. */
- int *cvt_arr;
+ const int *cvt_arr;
/* Callback function. We always use the `nftw' form. */
NFTW_FUNC_T func;
@@ -95,12 +95,12 @@ struct ftw_data
/* Internally we use the FTW_* constants used for `nftw'. When the
process called `ftw' we must reduce the flag to the known flags
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
};
-static int ftw_arr[] =
+static const int ftw_arr[] =
{
FTW_F, FTW_D, FTW_DNR, FTW_NS, FTW_F, FTW_D, FTW_NS
};
diff --git a/libio/iopopen.c b/libio/iopopen.c
index 3f3868d..6b2d7f5 100644
--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -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.
Written by Per Bothner <bothner@cygnus.com>.
@@ -101,7 +101,7 @@ struct _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_new_proc_open (fp, command, mode)
diff --git a/libio/oldiopopen.c b/libio/oldiopopen.c
index c2e7f25..c4116ba 100644
--- a/libio/oldiopopen.c
+++ b/libio/oldiopopen.c
@@ -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.
Written by Per Bothner <bothner@cygnus.com>.
@@ -102,7 +102,7 @@ struct _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_old_proc_open (fp, command, mode)
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index 27dff1e..b058c7f 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -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>
* sysdeps/arm/Implies: Removed since cmpxchg/no-cmpxchg
diff --git a/linuxthreads/manager.c b/linuxthreads/manager.c
index 9657cc5..6bafc86 100644
--- a/linuxthreads/manager.c
+++ b/linuxthreads/manager.c
@@ -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_bottom = new_thread_bottom;
*out_guardaddr = guardaddr;
@@ -316,34 +318,16 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
/* Allocate new thread identifier */
pthread_threads_counter += PTHREAD_THREADS_MAX;
new_thread_id = sseg + pthread_threads_counter;
- /* Initialize the thread descriptor */
- new_thread->p_nextwaiting = NULL;
+ /* Initialize the thread descriptor. Elements which have to be
+ initialized to zero already have this value. */
new_thread->p_tid = new_thread_id;
- new_thread->p_priority = 0;
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_canceltype = PTHREAD_CANCEL_DEFERRED;
- new_thread->p_canceled = 0;
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_errno = 0;
- new_thread->p_in_sighandler = NULL;
- new_thread->p_sigwaiting = 0;
new_thread->p_guardaddr = guardaddr;
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_nr = sseg;
/* 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 */
new_thread->p_start_args.schedpolicy = -1;
if (attr != NULL) {
+ new_thread->p_detached = attr->__detachstate;
+ new_thread->p_userstack = attr->__stackaddr_set;
+
switch(attr->__inheritsched) {
case PTHREAD_EXPLICIT_SCHED:
new_thread->p_start_args.schedpolicy = attr->__schedpolicy;