From 61de9bcf6c0dc60185a84b07e0f8ad2f870b6799 Mon Sep 17 00:00:00 2001
From: rbmj <rbmj@verizon.net>
Date: Tue, 12 Jun 2012 07:54:20 -0400
Subject: [PATCH] Fixed compilation on VxWorks because of open()/mkdir()

VxWorks only has a single arg mkdir(), and kernel modules
only have a (fixed) three argument open() instead of the
compliant variadic version.  For open(), pass the mode
argument unconditionally so that we always use three
arguments.  This shouldn't break other platforms, as it will
just be ignored.  For mkdir(), added MKDIR_SINGLE_ARG
(similarly to TARGET_POSIX_IO) in order to only use one
argument to maintain compatibility.

Modified:
	*gcc/config/vxworks.h:  Added define for MKDIR_SINGLE_ARG
	*gcc/gcov-io.c (gcov_open): Pass in mode to open()
	 unconditionally to support non-variadic open()
	*libgcc/libgcov.c (create_file_directory):  Add check for
	 MKDIR_SINGLE_ARG to support single-argument mkdir()
---
 gcc/config/vxworks.h |    2 ++
 gcc/gcov-io.c        |    2 +-
 libgcc/libgcov.c     |    2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/config/vxworks.h b/gcc/config/vxworks.h
index 000de36..cd57f1a 100644
--- a/gcc/config/vxworks.h
+++ b/gcc/config/vxworks.h
@@ -117,6 +117,8 @@ extern void vxworks_asm_out_destructor (rtx symbol, int priority);
 
 /* Both kernels and RTPs have the facilities required by this macro.  */
 #define TARGET_POSIX_IO
+#define MKDIR_SINGLE_ARG
+
 
 /* A VxWorks implementation of TARGET_OS_CPP_BUILTINS.  */
 #define VXWORKS_OS_CPP_BUILTINS()					\
diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c
index 37c1c3e..13c1aa8 100644
--- a/gcc/gcov-io.c
+++ b/gcc/gcov-io.c
@@ -92,7 +92,7 @@ gcov_open (const char *name, int mode)
     {
       /* Read-only mode - acquire a read-lock.  */
       s_flock.l_type = F_RDLCK;
-      fd = open (name, O_RDONLY);
+      fd = open (name, O_RDONLY, S_IRUSR | S_IWUSR);
     }
   else
     {
diff --git a/libgcc/libgcov.c b/libgcc/libgcov.c
index 8ed8971..5c4fa1c 100644
--- a/libgcc/libgcov.c
+++ b/libgcc/libgcov.c
@@ -133,7 +133,7 @@ create_file_directory (char *filename)
 
         /* Try to make directory if it doesn't already exist.  */
         if (access (filename, F_OK) == -1
-#ifdef TARGET_POSIX_IO
+#if defined(TARGET_POSIX_IO) && !defined(MKDIR_SINGLE_ARG)
             && mkdir (filename, 0755) == -1
 #else
             && mkdir (filename) == -1
-- 
1.7.5.4

