OSDN Git Service

merge from gcc
authordj <dj>
Mon, 11 Apr 2005 19:32:03 +0000 (19:32 +0000)
committerdj <dj>
Mon, 11 Apr 2005 19:32:03 +0000 (19:32 +0000)
libiberty/ChangeLog
libiberty/Makefile.in
libiberty/config.in
libiberty/configure
libiberty/configure.ac
libiberty/fopen_unlocked.c [new file with mode: 0644]
libiberty/functions.texi

index 169c821..df6106e 100644 (file)
@@ -1,3 +1,15 @@
+2005-04-11  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * Makefile.in (CFILES): Add fopen_unlocked.c.
+       (REQUIRED_OFILES): Add ./fopen_unlocked.o.
+       Regenerate dependencies.
+
+       * configure.ac: Check for stdio_ext.h and __fsetlocking.
+
+       * fopen_unlocked.c: New file.
+
+       * functions.texi, configure, config.in: Regenerate.
+
 2005-04-04  Ian Lance Taylor  <ian@airs.com>
 
        * testsuite/test-pexecute.c (TEST_PEX_RUN): Move variable
index 78957ee..6804015 100644 (file)
@@ -132,6 +132,7 @@ CFILES = alloca.c argv.c asprintf.c atexit.c                                \
         cp-demint.c cplus-dem.c                                        \
        dyn-string.c                                                    \
        fdmatch.c ffs.c fibheap.c floatformat.c fnmatch.c               \
+        fopen_unlocked.c                                               \
        getcwd.c getopt.c getopt1.c getpagesize.c getpwd.c getruntime.c \
          gettimeofday.c                                                 \
        hashtab.c hex.c                                                 \
@@ -165,6 +166,7 @@ REQUIRED_OFILES = ./regex.o ./cplus-dem.o ./cp-demangle.o ./md5.o   \
        ./choose-temp.o ./concat.o ./cp-demint.o                        \
        ./dyn-string.o                                                  \
        ./fdmatch.o ./fibheap.o ./floatformat.o ./fnmatch.o             \
+        ./fopen_unlocked.o                                             \
        ./getopt.o ./getopt1.o ./getpwd.o ./getruntime.o                \
        ./hashtab.o ./hex.o                                             \
        ./lbasename.o ./lrealpath.o                                     \
@@ -584,6 +586,13 @@ $(CONFIGURED_OFILES): stamp-picdir
        else true; fi
        $(COMPILE.c) $(srcdir)/fnmatch.c $(OUTPUT_OPTION)
 
+./fopen_unlocked.o: $(srcdir)/fopen_unlocked.c config.h $(INCDIR)/ansidecl.h \
+       $(INCDIR)/libiberty.h
+       if [ x"$(PICFLAG)" != x ]; then \
+         $(COMPILE.c) $(PICFLAG) $(srcdir)/fopen_unlocked.c -o pic/$@; \
+       else true; fi
+       $(COMPILE.c) $(srcdir)/fopen_unlocked.c $(OUTPUT_OPTION)
+
 ./getcwd.o: $(srcdir)/getcwd.c config.h
        if [ x"$(PICFLAG)" != x ]; then \
          $(COMPILE.c) $(PICFLAG) $(srcdir)/getcwd.c -o pic/$@; \
@@ -1041,7 +1050,7 @@ $(CONFIGURED_OFILES): stamp-picdir
        else true; fi
        $(COMPILE.c) $(srcdir)/vsprintf.c $(OUTPUT_OPTION)
 
-./waitpid.o: $(srcdir)/waitpid.c config.h
+./waitpid.o: $(srcdir)/waitpid.c config.h $(INCDIR)/ansidecl.h
        if [ x"$(PICFLAG)" != x ]; then \
          $(COMPILE.c) $(PICFLAG) $(srcdir)/waitpid.c -o pic/$@; \
        else true; fi
index ad71e76..d50aff9 100644 (file)
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
 
+/* Define to 1 if you have the <stdio_ext.h> header file. */
+#undef HAVE_STDIO_EXT_H
+
 /* Define to 1 if you have the <stdlib.h> header file. */
 #undef HAVE_STDLIB_H
 
 /* Define if you have the _system_configuration variable. */
 #undef HAVE__SYSTEM_CONFIGURATION
 
+/* Define to 1 if you have the `__fsetlocking' function. */
+#undef HAVE___FSETLOCKING
+
 /* Define if the host machine stores words of multi-word integers in
    big-endian order. */
 #undef HOST_WORDS_BIG_ENDIAN
index 3aa3963..adc0962 100755 (executable)
@@ -3540,7 +3540,8 @@ host_makefile_frag=${frag}
 
 
 
-for ac_header in sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h
+
+for ac_header in sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_header" >&5
@@ -4818,7 +4819,7 @@ vars="sys_errlist sys_nerr sys_siglist"
 
 checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
 checkfuncs="$checkfuncs realpath canonicalize_file_name pstat_getstatic pstat_getdynamic sysmp"
-checkfuncs="$checkfuncs getsysinfo table sysctl wait3 wait4"
+checkfuncs="$checkfuncs getsysinfo table sysctl wait3 wait4 __fsetlocking"
 
 # These are neither executed nor required, but they help keep
 # autoheader happy without adding a bunch of text to acconfig.h.
@@ -4890,6 +4891,7 @@ if test "x" = "y"; then
 
 
 
+
 for ac_func in asprintf atexit basename bcmp bcopy bsearch bzero calloc clock \
   getcwd getpagesize gettimeofday index insque mkstemps memchr memcmp memcpy \
   memmove mempcpy memset putenv random rename rindex sigsetmask \
@@ -4898,7 +4900,7 @@ for ac_func in asprintf atexit basename bcmp bcopy bsearch bzero calloc clock \
   vsprintf waitpid getrusage on_exit psignal strerror strsignal \
   sysconf times sbrk gettimeofday ffs snprintf vsnprintf \
   pstat_getstatic pstat_getdynamic sysmp getsysinfo table sysctl wait3 wait4 \
-  realpath canonicalize_file_name
+  realpath canonicalize_file_name __fsetlocking
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
index 9f47491..cd31f6a 100644 (file)
@@ -159,7 +159,7 @@ AC_SUBST_FILE(host_makefile_frag)
 # It's OK to check for header files.  Although the compiler may not be
 # able to link anything, it had better be able to at least compile
 # something.
-AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h)
+AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h)
 AC_HEADER_SYS_WAIT
 AC_HEADER_TIME
 
@@ -268,7 +268,7 @@ vars="sys_errlist sys_nerr sys_siglist"
 
 checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
 checkfuncs="$checkfuncs realpath canonicalize_file_name pstat_getstatic pstat_getdynamic sysmp"
-checkfuncs="$checkfuncs getsysinfo table sysctl wait3 wait4"
+checkfuncs="$checkfuncs getsysinfo table sysctl wait3 wait4 __fsetlocking"
 
 # These are neither executed nor required, but they help keep
 # autoheader happy without adding a bunch of text to acconfig.h.
@@ -281,7 +281,7 @@ if test "x" = "y"; then
   vsprintf waitpid getrusage on_exit psignal strerror strsignal \
   sysconf times sbrk gettimeofday ffs snprintf vsnprintf \
   pstat_getstatic pstat_getdynamic sysmp getsysinfo table sysctl wait3 wait4 \
-  realpath canonicalize_file_name)
+  realpath canonicalize_file_name __fsetlocking)
   AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
   AC_DEFINE(HAVE_SYS_NERR,    1, [Define if you have the sys_nerr variable.])
   AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
diff --git a/libiberty/fopen_unlocked.c b/libiberty/fopen_unlocked.c
new file mode 100644 (file)
index 0000000..b193dfd
--- /dev/null
@@ -0,0 +1,93 @@
+/* Implement fopen_unlocked and related functions.
+   Copyright (C) 2005 Free Software Foundation, Inc.
+   Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/*
+
+@deftypefn Extension FILE * fopen_unlocked (const char *@var{path}, const char * @var{mode})
+
+Opens and returns a @code{FILE} pointer via @code{fopen}.  If the
+operating system supports it, ensure that the stream is setup to avoid
+any multi-threaded locking.  Otherwise return the @code{FILE} pointer
+unchanged.
+
+@end deftypefn
+
+@deftypefn Extension FILE * fdopen_unlocked (int @var{fildes}, const char * @var{mode})
+
+Opens and returns a @code{FILE} pointer via @code{fdopen}.  If the
+operating system supports it, ensure that the stream is setup to avoid
+any multi-threaded locking.  Otherwise return the @code{FILE} pointer
+unchanged.
+
+@end deftypefn
+
+@deftypefn Extension FILE * freopen_unlocked (const char * @var{path}, const char * @var{mode}, FILE * @var{stream})
+
+Opens and returns a @code{FILE} pointer via @code{freopen}.  If the
+operating system supports it, ensure that the stream is setup to avoid
+any multi-threaded locking.  Otherwise return the @code{FILE} pointer
+unchanged.
+
+@end deftypefn
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <stdio.h>
+#ifdef HAVE_STDIO_EXT_H
+#include <stdio_ext.h>
+#endif
+
+#include "libiberty.h"
+
+FILE *
+fopen_unlocked (const char *path, const char *mode)            
+{
+  FILE *const fp = fopen (path, mode);
+#if defined(HAVE___FSETLOCKING) && defined(FSETLOCKING_BYCALLER)
+  if (fp)
+    __fsetlocking (fp, FSETLOCKING_BYCALLER);
+#endif
+  return fp;
+}
+
+FILE *
+fdopen_unlocked (int fildes, const char *mode)
+{
+  FILE *const fp = fdopen (fildes, mode);
+#if defined(HAVE___FSETLOCKING) && defined(FSETLOCKING_BYCALLER)
+  if (fp)
+    __fsetlocking (fp, FSETLOCKING_BYCALLER);
+#endif
+  return fp;
+}
+
+FILE *
+freopen_unlocked (const char *path, const char *mode, FILE *stream)
+{
+  FILE *const fp = freopen (path, mode, stream);
+#if defined(HAVE___FSETLOCKING) && defined(FSETLOCKING_BYCALLER)
+  if (fp)
+    __fsetlocking (fp, FSETLOCKING_BYCALLER);
+#endif
+  return fp;
+}
index 75f9824..47d40ec 100644 (file)
@@ -362,6 +362,16 @@ and inode numbers.
 
 @end deftypefn
 
+@c fopen_unlocked.c:32
+@deftypefn Extension FILE * fdopen_unlocked (int @var{fildes}, const char * @var{mode})
+
+Opens and returns a @code{FILE} pointer via @code{fdopen}.  If the
+operating system supports it, ensure that the stream is setup to avoid
+any multi-threaded locking.  Otherwise return the @code{FILE} pointer
+unchanged.
+
+@end deftypefn
+
 @c ffs.c:3
 @deftypefn Supplemental int ffs (int @var{valu})
 
@@ -421,6 +431,16 @@ Ignores case when performing the comparison.
 
 @end deftypefn
 
+@c fopen_unlocked.c:23
+@deftypefn Extension FILE * fopen_unlocked (const char *@var{path}, const char * @var{mode})
+
+Opens and returns a @code{FILE} pointer via @code{fopen}.  If the
+operating system supports it, ensure that the stream is setup to avoid
+any multi-threaded locking.  Otherwise return the @code{FILE} pointer
+unchanged.
+
+@end deftypefn
+
 @c argv.c:94
 @deftypefn Extension void freeargv (char **@var{vector})
 
@@ -431,6 +451,16 @@ itself.
 
 @end deftypefn
 
+@c fopen_unlocked.c:41
+@deftypefn Extension FILE * freopen_unlocked (const char * @var{path}, const char * @var{mode}, FILE * @var{stream})
+
+Opens and returns a @code{FILE} pointer via @code{freopen}.  If the
+operating system supports it, ensure that the stream is setup to avoid
+any multi-threaded locking.  Otherwise return the @code{FILE} pointer
+unchanged.
+
+@end deftypefn
+
 @c getruntime.c:82
 @deftypefn Replacement long get_run_time (void)