+2018-08-01 Richard Earnshaw <rearnsha@arm.com>
+
+ Copy over from GCC
+ 2018-07-26 Martin Liska <mliska@suse.cz>
+
+ PR lto/86548
+ * libiberty.h (make_temp_file_with_prefix): New function.
+
2018-07-30 Jim Wilson <jimw@sifive.com>
* opcode/riscv.h (INSN_TYPE, INSN_BRANCH, INSN_CONDBRANCH, INSN_JSR)
extern char *make_temp_file (const char *) ATTRIBUTE_MALLOC;
+/* Return a temporary file name with given PREFIX and SUFFIX
+ or NULL if unable to create one. */
+
+extern char *make_temp_file_with_prefix (const char *, const char *) ATTRIBUTE_MALLOC;
+
/* Remove a link to a file unless it is special. */
extern int unlink_if_ordinary (const char *);
+2018-08-01 Richard Earnshaw <rearnsha@arm.com>
+
+ Copy over from GCC
+ 2018-07-26 Martin Liska <mliska@suse.cz>
+
+ PR lto/86548
+ * make-temp-file.c (TEMP_FILE): Remove leading 'cc'.
+ (make_temp_file): Call make_temp_file_with_prefix with
+ first argument set to NULL.
+ (make_temp_file_with_prefix): Support also prefix.
+
2018-07-18 Eli Zaretskii <eliz@gnu.org>
PR gdb/23434
/* Name of temporary file.
mktemp requires 6 trailing X's. */
-#define TEMP_FILE "ccXXXXXX"
+#define TEMP_FILE "XXXXXX"
#define TEMP_FILE_LEN (sizeof(TEMP_FILE) - 1)
#if !defined(_WIN32) || defined(__CYGWIN__)
*/
char *
-make_temp_file (const char *suffix)
+make_temp_file_with_prefix (const char *prefix, const char *suffix)
{
const char *base = choose_tmpdir ();
char *temp_filename;
- int base_len, suffix_len;
+ int base_len, suffix_len, prefix_len;
int fd;
+ if (prefix == 0)
+ prefix = "cc";
+
if (suffix == 0)
suffix = "";
base_len = strlen (base);
+ prefix_len = strlen (prefix);
suffix_len = strlen (suffix);
temp_filename = XNEWVEC (char, base_len
+ TEMP_FILE_LEN
- + suffix_len + 1);
+ + suffix_len
+ + prefix_len + 1);
strcpy (temp_filename, base);
- strcpy (temp_filename + base_len, TEMP_FILE);
- strcpy (temp_filename + base_len + TEMP_FILE_LEN, suffix);
+ strcpy (temp_filename + base_len, prefix);
+ strcpy (temp_filename + base_len + prefix_len, TEMP_FILE);
+ strcpy (temp_filename + base_len + prefix_len + TEMP_FILE_LEN, suffix);
fd = mkstemps (temp_filename, suffix_len);
/* Mkstemps failed. It may be EPERM, ENOSPC etc. */
abort ();
return temp_filename;
}
+
+char *
+make_temp_file (const char *suffix)
+{
+ return make_temp_file_with_prefix (NULL, suffix);
+}