From 2706ee382341eb1c2e5f96c7d90f346696dbd0d8 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 17 Jul 2001 08:32:35 +0000 Subject: Update. 2001-07-17 Ulrich Drepper * inet/rcmd.c (iruserfopen): Disable implicit locking for the stream. * inet/ruserpass.c (ruserpass): Likewise. * nss/nsswitch.c (nss_parse_file): Likewise. * resolv/res_hconf.c (_res_hconf_init): Likewise. * resolv/res_init.c (__res_vinit): Likewise. * gmon/bb_exit_func.c (__bb_exit_func): Likewise. * misc/getpass.c (getpass): Likewise. * misc/getusershell.c (initshells): Likewise. * misc/getttyent.c (setttyent): Likewise. * misc/mntent_r.c (__setmntent): Likewise. * time/getdate.c (__getdate_r): Likewise. * time/tzfile.c (__tzfile_read): Likewise. * iconv/gconv_conf.c (read_conf_file): Likewise. * intl/localealias.c (read_alias_file): Disable implicit locking for the stream. Use _unlocked functions for glibc. * sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Disable implicit locking for the stream. (__get_nprocs_conf): Likewise. (phys_pages_info): Likewise. --- intl/localealias.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'intl') diff --git a/intl/localealias.c b/intl/localealias.c index 381264ba03..122b5807f9 100644 --- a/intl/localealias.c +++ b/intl/localealias.c @@ -30,6 +30,9 @@ #include #include +#if defined _LIBC || defined HAVE___FSETLOCKING +# include +#endif #include #ifdef __GNUC__ @@ -88,6 +91,7 @@ void free (); # define mempcpy __mempcpy # endif # define HAVE_MEMPCPY 1 +# define HAVE___FSETLOCKING 1 /* We need locking here since we can be called from different places. */ # include @@ -99,6 +103,15 @@ __libc_lock_define_initialized (static, lock); # define internal_function #endif +/* Some optimizations for glibc. */ +#ifdef _LIBC +# define FEOF(fp) feof_unlocked (fp) +# define FGETS(buf, n, fp) fgets_unlocked (buf, n, fp) +#else +# define FEOF(fp) feof (fp) +# define FGETS(buf, n, fp) fgets (buf, n, fp) +#endif + /* For those losing systems which don't have `alloca' we have to add some additional code emulating it. */ #ifdef HAVE_ALLOCA @@ -228,8 +241,13 @@ read_alias_file (fname, fname_len) if (fp == NULL) return 0; +#ifdef HAVE___FSETLOCKING + /* No threads present. */ + __fsetlocking (fp, FSETLOCKING_BYCALLER); +#endif + added = 0; - while (!feof (fp)) + while (!FEOF (fp)) { /* It is a reasonable approach to use a fix buffer here because a) we are only interested in the first two fields @@ -241,7 +259,7 @@ read_alias_file (fname, fname_len) char *value; char *cp; - if (fgets (buf, sizeof buf, fp) == NULL) + if (FGETS (buf, sizeof buf, fp) == NULL) /* EOF reached. */ break; @@ -251,7 +269,7 @@ read_alias_file (fname, fname_len) { char altbuf[BUFSIZ]; do - if (fgets (altbuf, sizeof altbuf, fp) == NULL) + if (FGETS (altbuf, sizeof altbuf, fp) == NULL) /* Make sure the inner loop will be left. The outer loop will exit at the `feof' test. */ break; -- cgit 1.4.1