public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix gcc/gcov.c and libgcc/libgcov.c to fix build on VxWorks
@ 2012-06-01 18:40 rbmj
  2012-06-01 18:43 ` rbmj
  0 siblings, 1 reply; 11+ messages in thread
From: rbmj @ 2012-06-01 18:40 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1644 bytes --]

Hi everyone,

These fixes are to allow building on vxWorks.  Currently there are two 
issues:

1.  VxWorks does not have a variadic open - it must receive three 
arguments.  gcc/gcov.c however opens a file for reading and does not 
pass in a mode argument, which causes an error on vxWorks.  This just 
adds a platform-based ifdef around this.  I am aware that this is 
against coding conventions, and if that is an issue, I can think of two 
resolutions.  One, an autoconf macro to check for a non-variadic open, 
or two, 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).

2.  VxWorks has a two argument mkdir().  libgcc/libgcov.c uses mkdir() 
and calls it with two arguments if TARGET_POSIX_IO is defined and only 
one argument otherwise.  I don't know what TARGET_POSIX_IO is, but if 
it's anything more than just mkdir(), this is probably correct, as 
vxworks is only partially POSIX compliant.  Again, another 
platform-based ifdef, so if that is anathema, it can be replaced by more 
autoconf hackery.

The patch as-is compiles targeting on vxworks and bootstraps on a native 
x86_64-linux-gnu build (which makes sense, since it doesn't touch 
anything for non-vxworks).

Gerald Pfeifer has volunteered to apply the patch if approved.

Also, in an earlier message [1] Janne Blomqvist mentioned that newer 
versions of VxWorks do have the variadic open(), and this is true.  
However, as far as I know, this version is still not available for 
kernel modules, only real-time processes.

Thanks,

Robert Mason

[-- Attachment #2: 03-gcov-vxworks.patch --]
[-- Type: text/x-patch, Size: 2358 bytes --]

From ad3b2df4d172eea2e0edfd61153133b25a7ed640 Mon Sep 17 00:00:00 2001
From: rbmj <rbmj@verizon.net>
Date: Wed, 30 May 2012 08:42:37 -0400
Subject: [PATCH 3/5] Make changes to gcov to allow compilation targeting
 vxworks.

gcc/gcov-io.c: add mode argument to open() on vxworks
libgcc/libgcov.c: fall back to single argument mkdir() on vxworks
---
 gcc/ChangeLog    |    5 +++++
 gcc/gcov-io.c    |    4 ++++
 libgcc/ChangeLog |    5 +++++
 libgcc/libgcov.c |    2 +-
 4 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 71451d2..c362fc6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
 2012-05-30  Robert Mason  <rbmj@verizon.net>
     
+	* gcov-io.c (gcov_open):  VxWorks does not have variadic open(), so pass
+	in a mode argument (ignored for O_RDONLY) on that platform.
+
+2012-05-30  Robert Mason  <rbmj@verizon.net>
+    
 	* config/rs6000/vxworks.h: Fix bad macro SUBSUBTARGET_OVERRIDE_OPTIONS.
 
 2012-05-29  Joseph Myers  <joseph@codesourcery.com>
diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c
index 37c1c3e..823067a 100644
--- a/gcc/gcov-io.c
+++ b/gcc/gcov-io.c
@@ -92,7 +92,11 @@ gcov_open (const char *name, int mode)
     {
       /* Read-only mode - acquire a read-lock.  */
       s_flock.l_type = F_RDLCK;
+#ifdef __VXWORKS__
+      fd = open (name, O_RDONLY, 0666);
+#else
       fd = open (name, O_RDONLY);
+#endif
     }
   else
     {
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index 5c048f5..04a6653 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-30  Robert Mason  <rbmj@verizon.net>
+    
+    * libgcov.c (create_file_directory):  VxWorks does not have two-argument
+    mkdir, so fall back to the single-argument call on that platform.
+
 2012-05-25  Ian Lance Taylor  <iant@google.com>
 
 	* config/i386/morestack.S (__morestack_non_split): Check whether
diff --git a/libgcc/libgcov.c b/libgcc/libgcov.c
index 8ed8971..27117b4 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(__VXWORKS__)
             && mkdir (filename, 0755) == -1
 #else
             && mkdir (filename) == -1
-- 
1.7.5.4


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Fix gcc/gcov.c and libgcc/libgcov.c to fix build on VxWorks
  2012-06-01 18:40 Fix gcc/gcov.c and libgcc/libgcov.c to fix build on VxWorks rbmj
@ 2012-06-01 18:43 ` rbmj
  2012-06-11 12:00   ` [Ping] " rbmj
  0 siblings, 1 reply; 11+ messages in thread
From: rbmj @ 2012-06-01 18:43 UTC (permalink / raw)
  To: gcc-patches

On 06/01/2012 02:40 PM, rbmj wrote:
> Hi everyone,
>
> These fixes are to allow building on vxWorks.  Currently there are two 
> issues:
>
> 1.  VxWorks does not have a variadic open - it must receive three 
> arguments.  gcc/gcov.c however opens a file for reading and does not 
> pass in a mode argument, which causes an error on vxWorks.  This just 
> adds a platform-based ifdef around this.  I am aware that this is 
> against coding conventions, and if that is an issue, I can think of 
> two resolutions.  One, an autoconf macro to check for a non-variadic 
> open, or two, 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).
>
> 2.  VxWorks has a two argument mkdir().  libgcc/libgcov.c uses mkdir() 
> and calls it with two arguments if TARGET_POSIX_IO is defined and only 
> one argument otherwise.  I don't know what TARGET_POSIX_IO is, but if 
> it's anything more than just mkdir(), this is probably correct, as 
> vxworks is only partially POSIX compliant.  Again, another 
> platform-based ifdef, so if that is anathema, it can be replaced by 
> more autoconf hackery.
>
> The patch as-is compiles targeting on vxworks and bootstraps on a 
> native x86_64-linux-gnu build (which makes sense, since it doesn't 
> touch anything for non-vxworks).
>
> Gerald Pfeifer has volunteered to apply the patch if approved.
>
> Also, in an earlier message [1] Janne Blomqvist mentioned that newer 
> versions of VxWorks do have the variadic open(), and this is true.  
> However, as far as I know, this version is still not available for 
> kernel modules, only real-time processes.
>
> Thanks,
>
> Robert Mason

Sorry, forgot to add in the link.
[1]: http://gcc.gnu.org/ml/gcc-patches/2012-05/msg01102.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Ping] Fix gcc/gcov.c and libgcc/libgcov.c to fix build on VxWorks
  2012-06-01 18:43 ` rbmj
@ 2012-06-11 12:00   ` rbmj
  2012-06-11 12:03     ` Paolo Bonzini
  0 siblings, 1 reply; 11+ messages in thread
From: rbmj @ 2012-06-11 12:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: bonzini

Hi everyone,

Ping RE: http://gcc.gnu.org/ml/gcc-patches/2012-06/msg00086.html

Thanks,

Robert Mason

On 06/01/2012 02:43 PM, rbmj wrote:
> On 06/01/2012 02:40 PM, rbmj wrote:
>> Hi everyone,
>>
>> These fixes are to allow building on vxWorks.  Currently there are 
>> two issues:
>>
>> 1.  VxWorks does not have a variadic open - it must receive three 
>> arguments.  gcc/gcov.c however opens a file for reading and does not 
>> pass in a mode argument, which causes an error on vxWorks.  This just 
>> adds a platform-based ifdef around this.  I am aware that this is 
>> against coding conventions, and if that is an issue, I can think of 
>> two resolutions.  One, an autoconf macro to check for a non-variadic 
>> open, or two, 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).
>>
>> 2.  VxWorks has a two argument mkdir().  libgcc/libgcov.c uses 
>> mkdir() and calls it with two arguments if TARGET_POSIX_IO is defined 
>> and only one argument otherwise.  I don't know what TARGET_POSIX_IO 
>> is, but if it's anything more than just mkdir(), this is probably 
>> correct, as vxworks is only partially POSIX compliant.  Again, 
>> another platform-based ifdef, so if that is anathema, it can be 
>> replaced by more autoconf hackery.
>>
>> The patch as-is compiles targeting on vxworks and bootstraps on a 
>> native x86_64-linux-gnu build (which makes sense, since it doesn't 
>> touch anything for non-vxworks).
>>
>> Gerald Pfeifer has volunteered to apply the patch if approved.
>>
>> Also, in an earlier message [1] Janne Blomqvist mentioned that newer 
>> versions of VxWorks do have the variadic open(), and this is true.  
>> However, as far as I know, this version is still not available for 
>> kernel modules, only real-time processes.
>>
>> Thanks,
>>
>> Robert Mason
>
> Sorry, forgot to add in the link.
> [1]: http://gcc.gnu.org/ml/gcc-patches/2012-05/msg01102.html
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Ping] Fix gcc/gcov.c and libgcc/libgcov.c to fix build on VxWorks
  2012-06-11 12:00   ` [Ping] " rbmj
@ 2012-06-11 12:03     ` Paolo Bonzini
  2012-06-12 12:18       ` rbmj
  2012-06-22 23:21       ` rbmj
  0 siblings, 2 replies; 11+ messages in thread
From: Paolo Bonzini @ 2012-06-11 12:03 UTC (permalink / raw)
  To: rbmj; +Cc: gcc-patches

Il 11/06/2012 13:56, rbmj ha scritto:
>>> 1.  VxWorks does not have a variadic open - it must receive three
>>> arguments.  gcc/gcov.c however opens a file for reading and does not
>>> pass in a mode argument, which causes an error on vxWorks.  This just
>>> adds a platform-based ifdef around this.  I am aware that this is
>>> against coding conventions, and if that is an issue, I can think of
>>> two resolutions.  [...] 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.

>>> 2.  VxWorks has a two argument mkdir().  libgcc/libgcov.c uses
>>> mkdir() and calls it with two arguments if TARGET_POSIX_IO is defined
>>> and only one argument otherwise.  I don't know what TARGET_POSIX_IO
>>> is, but if it's anything more than just mkdir(), this is probably
>>> correct, as vxworks is only partially POSIX compliant.  Again,
>>> another platform-based ifdef, so if that is anathema, it can be
>>> replaced by more autoconf hackery.

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.

Paolo

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Ping] Fix gcc/gcov.c and libgcc/libgcov.c to fix build on VxWorks
  2012-06-11 12:03     ` Paolo Bonzini
@ 2012-06-12 12:18       ` rbmj
  2012-06-20 21:29         ` rbmj
  2012-06-22 23:21       ` rbmj
  1 sibling, 1 reply; 11+ messages in thread
From: rbmj @ 2012-06-12 12:18 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1049 bytes --]

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

[-- Attachment #2: gcov.patch --]
[-- Type: text/x-patch, Size: 2394 bytes --]

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Ping] Fix gcc/gcov.c and libgcc/libgcov.c to fix build on VxWorks
  2012-06-12 12:18       ` rbmj
@ 2012-06-20 21:29         ` rbmj
  2012-06-22  2:24           ` Hans-Peter Nilsson
  0 siblings, 1 reply; 11+ messages in thread
From: rbmj @ 2012-06-20 21:29 UTC (permalink / raw)
  To: gcc-patches

On 06/12/2012 08:16 AM, rbmj wrote:
> On 06/11/2012 08:01 AM, Paolo Bonzini wrote:
>> 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.

There is an alternate solution- I could use fixincludes to add a macro 
to wrap over mkdir on VxWorks.  A couple of possible ways to do this:

1.  Define a normal macro to posix-ify it, i.e. #define mkdir(a, b) 
((mkdir)(a)).  Since this would hide single-argument mkdir, it would 
probably be best to wrap it in #ifdef IN_GCC in order to avoid breaking 
existing vxWorks code.

2.  Make a variadic macro to allow for posix compatibility, i.e. #define 
mkdir(a, ...) ((mkdir)(a)).  I'm not sure if this works outside of C99 
mode - I know GCC supports it as an extension in C89 mode, but AFAIK the 
semantics are slightly different.  I'm also not sure about g++.  This 
does have the advantage though that it doesn't break any existing code.  
However, it does allow nonsensical 20 argument mkdir as well.

Either of these or the one in my previous email should work.  Which (or 
a different one entirely) would be preferred?

Thanks,

Robert

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Ping] Fix gcc/gcov.c and libgcc/libgcov.c to fix build on VxWorks
  2012-06-20 21:29         ` rbmj
@ 2012-06-22  2:24           ` Hans-Peter Nilsson
  2012-06-22 20:22             ` rbmj
  0 siblings, 1 reply; 11+ messages in thread
From: Hans-Peter Nilsson @ 2012-06-22  2:24 UTC (permalink / raw)
  To: rbmj; +Cc: gcc-patches

On Wed, 20 Jun 2012, rbmj wrote:
> There is an alternate solution- I could use fixincludes to add a macro to wrap
> over mkdir on VxWorks.  A couple of possible ways to do this:
>
> 1.  Define a normal macro to posix-ify it, i.e. #define mkdir(a, b)
> ((mkdir)(a)).  Since this would hide single-argument mkdir, it would probably
> be best to wrap it in #ifdef IN_GCC in order to avoid breaking existing
> vxWorks code.

Beware, if you go this route, I think you need to evaluate the
"mode" argument (b above), i.e. something like "#define mkdir(a,
b) ((b), (mkdir) (a))".

brgds, H-P

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Ping] Fix gcc/gcov.c and libgcc/libgcov.c to fix build on VxWorks
  2012-06-22  2:24           ` Hans-Peter Nilsson
@ 2012-06-22 20:22             ` rbmj
  0 siblings, 0 replies; 11+ messages in thread
From: rbmj @ 2012-06-22 20:22 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: gcc-patches

On 06/21/2012 09:40 PM, Hans-Peter Nilsson wrote:
> On Wed, 20 Jun 2012, rbmj wrote:
>> There is an alternate solution- I could use fixincludes to add a macro to wrap
>> over mkdir on VxWorks.  A couple of possible ways to do this:
>>
>> 1.  Define a normal macro to posix-ify it, i.e. #define mkdir(a, b)
>> ((mkdir)(a)).  Since this would hide single-argument mkdir, it would probably
>> be best to wrap it in #ifdef IN_GCC in order to avoid breaking existing
>> vxWorks code.
> Beware, if you go this route, I think you need to evaluate the
> "mode" argument (b above), i.e. something like "#define mkdir(a,
> b) ((b), (mkdir) (a))".
>
>
Yes, you're correct.  I think then that this makes the normal macro a 
better option than the variadic macro, even though the variadic is more 
compatible.  Wrapping the mkdir macro in IN_GCC should provide an 
adequate guard to prevent the macro from expanding in code that relies 
on the non-compliant signature.

I would ask who in the world puts expressions with side effects in as 
the mode argument and then relies on those side effects for something 
other than the (ignored) mode, but I know better :-P.

I think this is better than the previous solution as it doesn't require 
touching GCC itself per-se, and instead deals with header 
incompatibilities where they should be dealt with in fixincludes.  I'll 
write up a patch and put that with the other fixincludes patches I've 
submitted.

Thanks,

Robert

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Ping] Fix gcc/gcov.c and libgcc/libgcov.c to fix build on VxWorks
  2012-06-11 12:03     ` Paolo Bonzini
  2012-06-12 12:18       ` rbmj
@ 2012-06-22 23:21       ` rbmj
  2012-06-25  3:18         ` rbmj
  1 sibling, 1 reply; 11+ messages in thread
From: rbmj @ 2012-06-22 23:21 UTC (permalink / raw)
  To: gcc-patches, Gerald Pfeifer

On 06/11/2012 08:01 AM, Paolo Bonzini wrote:
> Il 11/06/2012 13:56, rbmj ha scritto:
>>>> 1.  VxWorks does not have a variadic open - it must receive three
>>>> arguments.  gcc/gcov.c however opens a file for reading and does not
>>>> pass in a mode argument, which causes an error on vxWorks.  This just
>>>> adds a platform-based ifdef around this.  I am aware that this is
>>>> against coding conventions, and if that is an issue, I can think of
>>>> two resolutions.  [...] 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.
OK, I've prepared a patch.  I would venture to say it is obvious.  I'll 
mock up a separate patch that resolves the mkdir() issue.

Robert Mason

Changes:

gcc/gcov-io.c: pass mode argument unconditionally to be
     compatible with non-variadic open() (e.g. on VxWorks).

---
  gcc/gcov-io.c |    3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c
index 37c1c3e..28ed52f 100644
--- a/gcc/gcov-io.c
+++ b/gcc/gcov-io.c
@@ -92,7 +92,8 @@ 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);
+      /* pass mode (ignored) for compatibility */
+      fd = open (name, O_RDONLY, S_IRUSR | S_IWUSR);
      }
    else
      {
-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Ping] Fix gcc/gcov.c and libgcc/libgcov.c to fix build on VxWorks
  2012-06-22 23:21       ` rbmj
@ 2012-06-25  3:18         ` rbmj
  2012-06-25 14:42           ` Bruce Korb
  0 siblings, 1 reply; 11+ messages in thread
From: rbmj @ 2012-06-25  3:18 UTC (permalink / raw)
  To: gcc-patches; +Cc: gerald, bkorb

[-- Attachment #1: Type: text/plain, Size: 1490 bytes --]

On 06/22/2012 06:52 PM, rbmj wrote:
> On 06/11/2012 08:01 AM, Paolo Bonzini wrote:
>> Il 11/06/2012 13:56, rbmj ha scritto:
>>>>> 1.  VxWorks does not have a variadic open - it must receive three
>>>>> arguments.  gcc/gcov.c however opens a file for reading and does not
>>>>> pass in a mode argument, which causes an error on vxWorks.  This just
>>>>> adds a platform-based ifdef around this.  I am aware that this is
>>>>> against coding conventions, and if that is an issue, I can think of
>>>>> two resolutions.  [...] 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.
> OK, I've prepared a patch.  I would venture to say it is obvious.  
> I'll mock up a separate patch that resolves the mkdir() issue.
>

OK, so in addition to that small change, here's a fixincludes rule to 
resolve the mkdir() issue, which I've tested and works correctly.  It 
depends on my patch [1] to allow fixincludes to run on VxWorks (note 
that gcc/configure needs to be regened for that patch), and (as a 
fixincludes rule patch) needs fixincl.x to be regened with 
fixincludes/genfixes.  Patch is attached.

This patch, together with the patch in my previous mail [2], resolves 
bug 53264.

Thanks,

Robert Mason

[1] http://gcc.gnu.org/ml/gcc-patches/2012-06/msg00383.html
[2] http://gcc.gnu.org/ml/gcc-patches/2012-06/msg01508.html


[-- Attachment #2: mkdir.patch --]
[-- Type: text/x-patch, Size: 1467 bytes --]

From 0e14c471820d4a44b372e4e1c9248b39f65e23c4 Mon Sep 17 00:00:00 2001
From: rbmj <rbmj@verizon.net>
Date: Sat, 23 Jun 2012 17:38:41 -0400
Subject: [PATCH] Added vxworks_mkdir_macro fix.

This adds a macro to POSIX-ify VxWorks' mkdir() function by
including a macro that wraps the function and takes an (ignored,
but still evaluated) mode argument.

Modified:
	*fixincludes/inclhack.def (vxworks_mkdir_macro): add hack
	*fixincludes/fixincl.x: Regenerate
---
 fixincludes/inclhack.def |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index d122b6d..95b6607 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -4488,6 +4488,27 @@ fix = {
 	test_text	= "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
 };
 
+/*
+ *  Wrap VxWorks mkdir to be posix compliant
+ */
+fix = {
+	hackname	= vxworks_mkdir_macro;
+	files	   	= sys/stat.h;
+	mach		= "*-*-vxworks*";
+
+	c_fix		= format;
+	c_fix_arg	= "%0\n"
+		"#ifdef IN_GCC\n"
+		"#define mkdir(dir, mode) ((mode), (mkdir)(dir))\n"
+		"#endif\n";
+	c_fix_arg	= "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
+				"\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
+				"(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
+				"\\)[\t ]*;";
+	
+	test_text	= "extern STATUS mkdir (const char * _qwerty) ;";
+};
+
 
 /*
  *  Fix VxWorks <time.h> to not require including <vxTypes.h>.
-- 
1.7.5.4


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Ping] Fix gcc/gcov.c and libgcc/libgcov.c to fix build on VxWorks
  2012-06-25  3:18         ` rbmj
@ 2012-06-25 14:42           ` Bruce Korb
  0 siblings, 0 replies; 11+ messages in thread
From: Bruce Korb @ 2012-06-25 14:42 UTC (permalink / raw)
  To: rbmj; +Cc: gcc-patches

On 06/24/12 15:54, rbmj wrote:
+	c_fix_arg	= "%0\n"
+		"#ifdef IN_GCC\n"
+		"#define mkdir(dir, mode) ((mode), (mkdir)(dir))\n"
+		"#endif\n";
+	c_fix_arg	= "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
+				"\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
+				"(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
+				"\\)[\t ]*;";
+	
+	test_text	= "extern STATUS mkdir (const char * _qwerty) ;";

How gross.  Approved. :)

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-06-25 14:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-01 18:40 Fix gcc/gcov.c and libgcc/libgcov.c to fix build on VxWorks rbmj
2012-06-01 18:43 ` rbmj
2012-06-11 12:00   ` [Ping] " rbmj
2012-06-11 12:03     ` Paolo Bonzini
2012-06-12 12:18       ` rbmj
2012-06-20 21:29         ` rbmj
2012-06-22  2:24           ` Hans-Peter Nilsson
2012-06-22 20:22             ` rbmj
2012-06-22 23:21       ` rbmj
2012-06-25  3:18         ` rbmj
2012-06-25 14:42           ` Bruce Korb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).