This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Prototype make_temp_file


This patch moves the make_temp_file prototype to a central location.
I don't have any mips system, but I don't think removing that cruft
will break anything.

Wed Sep  8 12:10:56 CEST 1999	Marc Espie <espie@cvs.openbsd.org>
	* config/mips/mips.c (make_temp_file):  Delete, use libiberty standard
	version instead.
	* collect2.c:  Rely on libiberty.h for make_temp_file.
	* gcc.c:  Likewise.


Wed Sep  8 12:10:56 CEST 1999	Marc Espie <espie@cvs.openbsd.org>
	* libiberty.h:  Prototype and document make_temp_file.
	* choose_temp.c (make_temp_file):  Constify to agree with prototype.

Index: gcc/config/mips/mips.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/mips/mips.c,v
retrieving revision 1.67
diff -u -r1.67 mips.c
--- mips.c	1999/09/08 00:21:45	1.67
+++ mips.c	1999/09/08 09:55:42
@@ -92,7 +92,6 @@
 static void block_move_loop			PROTO ((rtx, rtx, int, int,
 							rtx, rtx));
 static void block_move_call			PROTO ((rtx, rtx, rtx));
-static FILE *make_temp_file			PROTO ((void));
 static void save_restore_insns			PROTO ((int, rtx,
 							long, FILE *));
 static void mips16_output_gp_offset		PROTO ((FILE *, rtx));
@@ -5111,59 +5110,6 @@
 }
 #endif
 
-/* Compute a string to use as a temporary file name.  */
-
-/* On MSDOS, write temp files in current dir
-   because there's no place else we can expect to use.  */
-#if __MSDOS__
-#ifndef P_tmpdir
-#define P_tmpdir "./"
-#endif
-#endif
-
-static FILE *
-make_temp_file ()
-{
-  FILE *stream;
-  const char *base = getenv ("TMPDIR");
-  int len;
-
-  if (base == 0)
-    {
-#ifdef P_tmpdir
-      if (access (P_tmpdir, R_OK | W_OK) == 0)
-	base = P_tmpdir;
-      else
-#endif
-	if (access ("/usr/tmp", R_OK | W_OK) == 0)
-	  base = "/usr/tmp/";
-	else
-	  base = "/tmp/";
-    }
-
-  len = strlen (base);
-  /* temp_filename is global, so we must use malloc, not alloca.  */
-  temp_filename = (char *) xmalloc (len + sizeof("/ctXXXXXX"));
-  strcpy (temp_filename, base);
-  if (len > 0 && temp_filename[len-1] != '/')
-    temp_filename[len++] = '/';
-
-  strcpy (temp_filename + len, "ctXXXXXX");
-  mktemp (temp_filename);
-
-  stream = fopen (temp_filename, "w+");
-  if (!stream)
-    pfatal_with_name (temp_filename);
-
-#ifndef __MSDOS__
-  /* In MSDOS, we cannot unlink the temporary file until we are finished using
-     it.  Otherwise, we delete it now, so that it will be gone even if the
-     compiler happens to crash.  */
-  unlink (temp_filename);
-#endif
-  return stream;
-}
-
 /* Emit a new filename to a stream.  If this is MIPS ECOFF, watch out
    for .file's that start within a function.  If we are smuggling stabs, try to
    put out a MIPS ECOFF file and a stab.  */
@@ -5341,7 +5287,7 @@
   if (TARGET_FILE_SWITCHING && ! TARGET_MIPS16)
     {
       asm_out_data_file = stream;
-      asm_out_text_file = make_temp_file ();
+      asm_out_text_file = make_temp_file (NULL);
     }
 
   else
Index: gcc/collect2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/collect2.c,v
retrieving revision 1.79
diff -u -r1.79 collect2.c
--- collect2.c	1999/09/07 02:36:26	1.79
+++ collect2.c	1999/09/08 09:55:44
@@ -52,8 +52,6 @@
 /* Obstack allocation and deallocation routines.  */
 #define obstack_chunk_alloc xmalloc
 #define obstack_chunk_free free
-
-extern char *make_temp_file PROTO ((const char *));
 
 /* On certain systems, we have code that works by scanning the object file
    directly.  But this code uses system-specific header files and library
Index: gcc/gcc.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/gcc.c,v
retrieving revision 1.111
diff -u -r1.111 gcc.c
--- gcc.c	1999/09/07 05:47:53	1.111
+++ gcc.c	1999/09/08 09:55:48
@@ -1269,8 +1269,6 @@
 
 #ifdef MKTEMP_EACH_FILE
 
-extern char *make_temp_file PROTO((const char *));
-
 /* This is the list of suffixes and codes (%g/%u/%U) and the associated
    temp file.  */
 
Index: include/libiberty.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/include/libiberty.h,v
retrieving revision 1.7
diff -u -r1.7 libiberty.h
--- libiberty.h	1999/09/08 08:20:11	1.7
+++ libiberty.h	1999/09/08 10:48:27
@@ -60,9 +60,13 @@
 
 extern long get_run_time PARAMS ((void));
 
-/* Choose a temporary directory to use for scratch files.  */
+/* Choose a temporary directory to use for scratch files, DEPRECATED */
 
 extern char *choose_temp_base PARAMS ((void));
+
+/* Create a temporary file with a given suffix (optional) */
+
+extern char *make_temp_file PARAMS ((const char *));
 
 /* Allocate memory filled with spaces.  Allocates using malloc.  */
 
Index: libiberty/choose-temp.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/libiberty/choose-temp.c,v
retrieving revision 1.13
diff -u -r1.13 choose-temp.c
--- choose-temp.c	1999/07/14 17:29:38	1.13
+++ choose-temp.c	1999/09/08 10:48:28
@@ -148,7 +148,7 @@
 
 char *
 make_temp_file (suffix)
-     char *suffix;
+     const char *suffix;
 {
   char *base = 0;
   char *temp_filename;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]