Patchwork [Ping] Fix gcc/gcov.c and libgcc/libgcov.c to fix build on VxWorks

login
register
mail settings
Submitter rbmj
Date June 24, 2012, 10:54 p.m.
Message ID <4FE79AC0.8090107@verizon.net>
Download mbox | patch
Permalink /patch/166915/
State New
Headers show

Comments

rbmj - June 24, 2012, 10:54 p.m.
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
Bruce Korb - June 25, 2012, 2:36 p.m.
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. :)

Patch

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