From 6073aca2967c8dbda36216f7f2bef87ded55e473 Mon Sep 17 00:00:00 2001
From: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 13 Jul 2005 16:28:25 +0000
Subject: [PATCH] 2005-07-13  H.J. Lu  <hongjiu.lu@intel.com>

	* config/alpha/linux.h (TARGET_HAS_F_SETLKW): Renamed to ...
	(TARGET_POSIX_IO): This.
	* config/darwin.h: Likewise.
	* config/freebsd.h: Likewise.
	* config/linux.h: Likewise.
	* config/lynx.h: Likewise.
	* config/netbsd.h: Likewise.
	* config/rs6000/linux64.h: Likewise.
	* config/rs6000/linux.h: Likewise.
	* config/s390/tpf.h: Likewise.
	* config/sh/embed-elf.h: Likewise.
	* config/sparc/linux64.h: Likewise.
	* config/sparc/linux.h: Likewise.
	* config/svr4.h: Likewise.
	* gcov-io.h: Likewise.

	* doc/tm.texi: Updated.

	* libgcov.c (create_file_directory): Defined only if
	TARGET_POSIX_IO is defined.
	(gcov_exit): Call create_file_directory only if TARGET_POSIX_IO
	is defined.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101973 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog               | 25 +++++++++++++++++++++++++
 gcc/config/alpha/linux.h    |  2 +-
 gcc/config/darwin.h         |  2 +-
 gcc/config/freebsd.h        |  2 +-
 gcc/config/linux.h          |  2 +-
 gcc/config/lynx.h           |  4 ++--
 gcc/config/netbsd.h         |  4 ++--
 gcc/config/rs6000/linux.h   |  2 +-
 gcc/config/rs6000/linux64.h |  2 +-
 gcc/config/s390/tpf.h       |  2 +-
 gcc/config/sh/embed-elf.h   |  2 +-
 gcc/config/sparc/linux.h    |  2 +-
 gcc/config/sparc/linux64.h  |  2 +-
 gcc/config/svr4.h           |  2 +-
 gcc/doc/tm.texi             | 11 ++++++-----
 gcc/gcov-io.h               |  2 +-
 gcc/libgcov.c               |  4 ++++
 17 files changed, 51 insertions(+), 21 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8a4ccc0c03f8..03ca42bd23a3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,28 @@
+2005-07-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* config/alpha/linux.h (TARGET_HAS_F_SETLKW): Renamed to ...
+	(TARGET_POSIX_IO): This.
+	* config/darwin.h: Likewise.
+	* config/freebsd.h: Likewise.
+	* config/linux.h: Likewise.
+	* config/lynx.h: Likewise.
+	* config/netbsd.h: Likewise.
+	* config/rs6000/linux64.h: Likewise.
+	* config/rs6000/linux.h: Likewise.
+	* config/s390/tpf.h: Likewise.
+	* config/sh/embed-elf.h: Likewise.
+	* config/sparc/linux64.h: Likewise.
+	* config/sparc/linux.h: Likewise.
+	* config/svr4.h: Likewise.
+	* gcov-io.h: Likewise.
+
+	* doc/tm.texi: Updated.
+
+	* libgcov.c (create_file_directory): Defined only if
+	TARGET_POSIX_IO is defined.
+	(gcov_exit): Call create_file_directory only if TARGET_POSIX_IO
+	is defined.
+
 2005-07-13  Jan Hubicka  <jh@suse.cz>
 
 	* tree-ssa-operands.c (get_expr_operands): Fix typo in previous patch.
diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h
index 2509fe9eef05..0773462692d4 100644
--- a/gcc/config/alpha/linux.h
+++ b/gcc/config/alpha/linux.h
@@ -71,7 +71,7 @@ Boston, MA 02110-1301, USA.  */
    runtime library.  */
 #define TARGET_C99_FUNCTIONS 1
 
-#define TARGET_HAS_F_SETLKW
+#define TARGET_POSIX_IO
 
 #define LINK_GCC_C_SEQUENCE_SPEC \
   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index b5cb068007bf..c33e2030e4a9 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -1026,7 +1026,7 @@ void darwin_register_objc_includes (const char *, const char *, int);
 void add_framework_path (char *);
 #define TARGET_OPTF add_framework_path
 
-#define TARGET_HAS_F_SETLKW
+#define TARGET_POSIX_IO
 
 /* All new versions of Darwin have C99 functions.  */
 #define TARGET_C99_FUNCTIONS 1
diff --git a/gcc/config/freebsd.h b/gcc/config/freebsd.h
index bf7a52e83d16..21dc81e6013a 100644
--- a/gcc/config/freebsd.h
+++ b/gcc/config/freebsd.h
@@ -84,4 +84,4 @@ Boston, MA 02110-1301, USA.  */
 /* Used by libgcc2.c.  We support file locking with fcntl / F_SETLKW.
    This enables the test coverage code to use file locking when exiting a
    program, which avoids race conditions if the program has forked.  */
-#define TARGET_HAS_F_SETLKW
+#define TARGET_POSIX_IO
diff --git a/gcc/config/linux.h b/gcc/config/linux.h
index c173d7bad623..3853fa42a005 100644
--- a/gcc/config/linux.h
+++ b/gcc/config/linux.h
@@ -103,4 +103,4 @@ Boston, MA 02110-1301, USA.  */
    is present in the runtime library.  */
 #define TARGET_C99_FUNCTIONS 1
 
-#define TARGET_HAS_F_SETLKW
+#define TARGET_POSIX_IO
diff --git a/gcc/config/lynx.h b/gcc/config/lynx.h
index 2805a57d336e..271fb626df39 100644
--- a/gcc/config/lynx.h
+++ b/gcc/config/lynx.h
@@ -173,6 +173,6 @@ Boston, MA 02110-1301, USA.  */
 # define NO_IMPLICIT_EXTERN_C
 #endif
 
-#ifndef TARGET_HAS_F_SETLKW
-# define TARGET_HAS_F_SETLKW
+#ifndef TARGET_POSIX_IO
+# define TARGET_POSIX_IO
 #endif
diff --git a/gcc/config/netbsd.h b/gcc/config/netbsd.h
index 2cc6f8058fab..5386b656512b 100644
--- a/gcc/config/netbsd.h
+++ b/gcc/config/netbsd.h
@@ -156,8 +156,8 @@ Boston, MA 02110-1301, USA.  */
     fprintf ((STREAM), "void __fini() {\n\t%s();\n}\n", (FUNC));	\
   } while (0)
 
-#undef TARGET_HAS_F_SETLKW
-#define TARGET_HAS_F_SETLKW
+#undef TARGET_POSIX_IO
+#define TARGET_POSIX_IO
 
 /* Handle #pragma weak and #pragma pack.  */
 
diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h
index 79eb199f9529..497fcca2bc15 100644
--- a/gcc/config/rs6000/linux.h
+++ b/gcc/config/rs6000/linux.h
@@ -110,7 +110,7 @@
 
 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
 
-#define TARGET_HAS_F_SETLKW
+#define TARGET_POSIX_IO
 
 #define MD_UNWIND_SUPPORT "config/rs6000/linux-unwind.h"
 
diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index 7343cbb8723f..31bf8ac86ed3 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -536,7 +536,7 @@ while (0)
 
 #define TARGET_ASM_FILE_END rs6000_elf_end_indicate_exec_stack
 
-#define TARGET_HAS_F_SETLKW
+#define TARGET_POSIX_IO
 
 #define LINK_GCC_C_SEQUENCE_SPEC \
   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
diff --git a/gcc/config/s390/tpf.h b/gcc/config/s390/tpf.h
index e8c7f80893ac..c1feaba09ae0 100644
--- a/gcc/config/s390/tpf.h
+++ b/gcc/config/s390/tpf.h
@@ -32,7 +32,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 #undef ASM_APP_OFF
 #define ASM_APP_OFF "#NO_APP\n"
 #define NO_IMPLICIT_EXTERN_C
-#define TARGET_HAS_F_SETLKW
+#define TARGET_POSIX_IO
 #undef MD_EXEC_PREFIX
 #undef MD_STARTFILE_PREFIX
 
diff --git a/gcc/config/sh/embed-elf.h b/gcc/config/sh/embed-elf.h
index 3c96f3fa2c97..2542c4c16bc6 100644
--- a/gcc/config/sh/embed-elf.h
+++ b/gcc/config/sh/embed-elf.h
@@ -23,4 +23,4 @@ Boston, MA 02110-1301, USA.  */
 #undef USER_LABEL_PREFIX
 #define USER_LABEL_PREFIX "_"
 
-#undef TARGET_HAS_F_SETLKW
+#undef TARGET_POSIX_IO
diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
index 87a043e53cf0..c90080e1eed7 100644
--- a/gcc/config/sparc/linux.h
+++ b/gcc/config/sparc/linux.h
@@ -208,7 +208,7 @@ do {									\
    runtime library.  */
 #define TARGET_C99_FUNCTIONS 1
 
-#define TARGET_HAS_F_SETLKW
+#define TARGET_POSIX_IO
 
 #undef LINK_GCC_C_SEQUENCE_SPEC
 #define LINK_GCC_C_SEQUENCE_SPEC \
diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
index 82860fea24e8..d7ebb86e945e 100644
--- a/gcc/config/sparc/linux64.h
+++ b/gcc/config/sparc/linux64.h
@@ -342,7 +342,7 @@ do {									\
    runtime library.  */
 #define TARGET_C99_FUNCTIONS 1
 
-#define TARGET_HAS_F_SETLKW
+#define TARGET_POSIX_IO
 
 #undef LINK_GCC_C_SEQUENCE_SPEC
 #define LINK_GCC_C_SEQUENCE_SPEC \
diff --git a/gcc/config/svr4.h b/gcc/config/svr4.h
index 74aa296a892d..6fa88fcd821d 100644
--- a/gcc/config/svr4.h
+++ b/gcc/config/svr4.h
@@ -203,4 +203,4 @@ Boston, MA 02110-1301, USA.
 #undef  WCHAR_TYPE_SIZE
 #define WCHAR_TYPE_SIZE BITS_PER_WORD
 
-#define TARGET_HAS_F_SETLKW
+#define TARGET_POSIX_IO
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 4eeb15669841..5feacf5668e6 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -9275,12 +9275,13 @@ You need only define this macro if the default of @samp{"LIBRARY_PATH"}
 is wrong.
 @end defmac
 
-@defmac TARGET_HAS_F_SETLKW
-Define this macro if the target supports file locking with fcntl / F_SETLKW@.
-Note that this functionality is part of POSIX@.
-Defining @code{TARGET_HAS_F_SETLKW} will enable the test coverage code
+@defmac TARGET_POSIX_IO
+Define this macro if the target supports the following POSIX@ file
+functions, access, mkdir and  file locking with fcntl / F_SETLKW@.
+Defining @code{TARGET_POSIX_IO} will enable the test coverage code
 to use file locking when exiting a program, which avoids race conditions
-if the program has forked.
+if the program has forked. It will also create directories at run-time
+for cross-profiling.  @xref{Cross-profiling}.
 @end defmac
 
 @defmac MAX_CONDITIONAL_EXECUTE
diff --git a/gcc/gcov-io.h b/gcc/gcov-io.h
index 045f6657ace9..f3607d978908 100644
--- a/gcc/gcov-io.h
+++ b/gcc/gcov-io.h
@@ -195,7 +195,7 @@ typedef signed gcov_type __attribute__ ((mode (QI)));
 #endif
 
 
-#if defined (TARGET_HAS_F_SETLKW)
+#if defined (TARGET_POSIX_IO)
 #define GCOV_LOCKED 1
 #else
 #define GCOV_LOCKED 0
diff --git a/gcc/libgcov.c b/gcc/libgcov.c
index 09f3522537a7..de44d911f017 100644
--- a/gcc/libgcov.c
+++ b/gcc/libgcov.c
@@ -91,6 +91,7 @@ static gcov_unsigned_t gcov_crc32;
 /* Size of the longest file name. */
 static size_t gcov_max_filename = 0;
 
+#ifdef TARGET_POSIX_IO
 /* Make sure path component of the given FILENAME exists, create 
    missing directories. FILENAME must be writable. 
    Returns zero on success, or -1 if an error occurred.  */
@@ -122,6 +123,7 @@ create_file_directory (char *filename)
       };
   return 0;
 }
+#endif
 
 /* Check if VERSION of the info block PTR matches libgcov one.
    Return 1 on success, or zero in case of versions mismatch.
@@ -299,6 +301,7 @@ gcov_exit (void)
       
       if (!gcov_open (gi_filename))
 	{
+#ifdef TARGET_POSIX_IO
 	  /* Open failed likely due to missed directory.
 	     Create directory and retry to open file. */
           if (create_file_directory (gi_filename))
@@ -306,6 +309,7 @@ gcov_exit (void)
 	      fprintf (stderr, "profiling:%s:Skip\n", gi_filename);
 	      continue;
 	    }
+#endif
 	  if (!gcov_open (gi_filename))
 	    {
               fprintf (stderr, "profiling:%s:Cannot open\n", gi_filename);
-- 
GitLab