On 06/11/2012 08:01 AM, Paolo Bonzini wrote:
Il 11/06/2012 13:56, rbmj ha scritto:
... simply pass the extra mode argument in unconditionally,
as it should be transparent to the function and ignored if it is
variadic (I'm no expert on calling conventions though).
Yes, please do this.
Done.
VxWorks should define TARGET_POSIX_IO if it has both access and mkdir. Please add it to gcc/config/vxworks.h if this is the case.

I misspoke in my earlier email - sorry for my lack of attention to detail. The issue is that VxWorks does *not* have a two argument mkdir(). It does have TARGET_POSIX_IO. Undefing TARGET_POSIX_IO seems non-optimal as it disables some functionality that can still be implemented, just omitting the mode argument. With this in mind, I defined MKDIR_SINGLE_ARG in gcc/config/vxworks.h, and then added a check for this define. This is a slightly less ugly solution than I had earlier.

An updated patch is attached. It's in git format-patch format, so the commit message is at the top.

Robert
>From 61de9bcf6c0dc60185a84b07e0f8ad2f870b6799 Mon Sep 17 00:00:00 2001
From: rbmj <r...@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

Reply via email to