* testsuite/util/testsuite_fs.h (nonexistent_path): Don't use tempnam.
authorJonathan Wakely <jwakely@redhat.com>
Wed, 20 May 2015 17:28:04 +0000 (18:28 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 20 May 2015 17:28:04 +0000 (18:28 +0100)
From-SVN: r223450

libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/util/testsuite_fs.h

index 50b1626cfb84fe6c412da71ada3260f3826b8e68..ce5573c473b3b5107f9aa5f966624e37886e48e9 100644 (file)
@@ -1,5 +1,7 @@
 2015-05-20  Jonathan Wakely  <jwakely@redhat.com>
 
+       * testsuite/util/testsuite_fs.h (nonexistent_path): Don't use tempnam.
+
        PR libstdc++/66078
        * include/bits/stl_iterator.h (__make_move_if_noexcept_iterator): Add
        overload for pointers.
index f404a7a7ff8c963fc7cc399732560b8dbd68b8c6..3873a609a5ffec6536baaa6d23025c6ec21790dc 100644 (file)
 #include <iostream>
 #include <string>
 #include <cstdio>
-#if defined(_GNU_SOURCE) || _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200112L
-# include <stdlib.h>
-# include <unistd.h>
-#endif
+#include <stdlib.h>
+#include <unistd.h>
 
 namespace __gnu_test
 {
@@ -84,12 +82,9 @@ namespace __gnu_test
     ::close(fd);
     p = tmp;
 #else
-    char* tmp = tempnam(".", "test.");
-    if (!tmp)
-      throw std::experimental::filesystem::filesystem_error("tempnam failed",
-         std::error_code(errno, std::generic_category()));
-    p = tmp;
-    ::free(tmp);
+    char buf[64];
+    std::sprintf(buf, "test.%lu", (unsigned long)::getpid());
+    p = buf;
 #endif
     return p;
   }