about summary refs log tree commit diff
path: root/stdio-common
diff options
context:
space:
mode:
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/Versions2
-rw-r--r--stdio-common/tempnam.c2
-rw-r--r--stdio-common/tmpfile.c28
-rw-r--r--stdio-common/tmpfile64.c12
4 files changed, 30 insertions, 14 deletions
diff --git a/stdio-common/Versions b/stdio-common/Versions
index 6191e0b97d..11e0900f01 100644
--- a/stdio-common/Versions
+++ b/stdio-common/Versions
@@ -45,6 +45,6 @@ libc {
     printf_size; printf_size_info;
 
     # t*
-    tmpfile64;
+    tmpfile; tmpfile64;
   }
 }
diff --git a/stdio-common/tempnam.c b/stdio-common/tempnam.c
index 8683643c76..5d4960f216 100644
--- a/stdio-common/tempnam.c
+++ b/stdio-common/tempnam.c
@@ -37,5 +37,5 @@ tempnam (const char *dir, const char *pfx)
   if (__gen_tempname (buf, 0, 0))
     return NULL;
 
-  return strdup (buf);
+  return __strdup (buf);
 }
diff --git a/stdio-common/tmpfile.c b/stdio-common/tmpfile.c
index 6b9dfd44b0..4a9e4e2e0a 100644
--- a/stdio-common/tmpfile.c
+++ b/stdio-common/tmpfile.c
@@ -19,16 +19,18 @@
 #include <stdio.h>
 #include <unistd.h>
 
-#ifdef _USE_IN_LIBIO
-# define fdopen _IO_new_fdopen
+#ifdef USE_IN_LIBIO
+# include <iolibio.h>
+# define __fdopen _IO_fdopen
+# define tmpfile __new_tmpfile
 #endif
 
 /* This returns a new stream opened on a temporary file (generated
-   by tmpnam) The file is opened with mode "w+b" (binary read/write).
+   by tmpnam).  The file is opened with mode "w+b" (binary read/write).
    If we couldn't generate a unique filename or the file couldn't
    be opened, NULL is returned.  */
 FILE *
-tmpfile ()
+tmpfile (void)
 {
   char buf[FILENAME_MAX];
   int fd;
@@ -36,15 +38,27 @@ tmpfile ()
 
   if (__path_search (buf, FILENAME_MAX, NULL, "tmpf"))
     return NULL;
-  if ((fd = __gen_tempname (buf, 1, 0)) < 0)
+  fd = __gen_tempname (buf, 1, 0);
+  if (fd < 0)
     return NULL;
 
   /* Note that this relies on the Unix semantics that
      a file is not really removed until it is closed.  */
   (void) remove (buf);
 
-  if ((f = fdopen (fd, "w+b")) == NULL)
-    close (fd);
+  if ((f = __fdopen (fd, "w+b")) == NULL)
+    __close (fd);
 
   return f;
 }
+
+#ifdef USE_IN_LIBIO
+# undef tmpfile
+# if defined PIC && DO_VERSIONING
+default_symbol_version (__new_tmpfile, tmpfile, GLIBC_2.1);
+# else
+#  ifdef weak_alias
+weak_alias (__new_tmpfile, tmpfile)
+#  endif
+# endif
+#endif
diff --git a/stdio-common/tmpfile64.c b/stdio-common/tmpfile64.c
index a7fce66a86..0f3a0044a4 100644
--- a/stdio-common/tmpfile64.c
+++ b/stdio-common/tmpfile64.c
@@ -19,8 +19,9 @@
 #include <stdio.h>
 #include <unistd.h>
 
-#ifdef _USE_IN_LIBIO
-# define fdopen _IO_new_fdopen
+#ifdef USE_IN_LIBIO
+# include <iolibio.h>
+# define __fdopen _IO_fdopen
 #endif
 
 /* This returns a new stream opened on a temporary file (generated
@@ -36,15 +37,16 @@ tmpfile64 ()
 
   if (__path_search (buf, FILENAME_MAX, NULL, "tmpf"))
     return NULL;
-  if ((fd = __gen_tempname (buf, 1, 1)) < 0)
+  fd = __gen_tempname (buf, 1, 1);
+  if (fd < 0)
     return NULL;
 
   /* Note that this relies on the Unix semantics that
      a file is not really removed until it is closed.  */
   (void) remove (buf);
 
-  if ((f = fdopen (fd, "w+b")) == NULL)
-    close (fd);
+  if ((f = __fdopen (fd, "w+b")) == NULL)
+    __close (fd);
 
   return f;
 }