diff mbox

[fixincludes] Fix posix_spawn* declarations in Solaris <spawn.h> (PR c++/49347)

Message ID yddsjpufkyy.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth July 25, 2011, 3:17 p.m. UTC
As discussed in the PR, the Solaris 10+ <spawn.h> header needs a fix to
make it work with g++.  The following patch implements it.

It passed a i386-pc-solaris2.11 bootstrap without regressions and make
check in fixincludes works without failures.

Ok for mainline?

Thanks.
	Rainer

Comments

Bruce Korb July 25, 2011, 3:49 p.m. UTC | #1
On 07/25/11 08:17, Rainer Orth wrote:
> As discussed in the PR, the Solaris 10+<spawn.h>  header needs a fix to
> make it work with g++.  The following patch implements it.
>
> It passed a i386-pc-solaris2.11 bootstrap without regressions and make
> check in fixincludes works without failures.
>
> Ok for mainline?

Hi Rainer,

 > some-function(char *const argv[_RESTRICT_KYWD], ...)

looks pretty broken to me.  How would it work with plain gcc?
Anyway, editing the _RESTRICT_KYWD into the correct place looks
correct to me, and I'm sure you tested.  "Ship it".  Methinks
all active branches, too....
Rainer Orth July 25, 2011, 3:55 p.m. UTC | #2
Hi Bruce,

>> some-function(char *const argv[_RESTRICT_KYWD], ...)
>
> looks pretty broken to me.  How would it work with plain gcc?

no idea, but both gcc -std=c99 and Sun Studio cc -xc99 do accept it.

> Anyway, editing the _RESTRICT_KYWD into the correct place looks
> correct to me, and I'm sure you tested.  "Ship it".  Methinks
> all active branches, too....

I'll restrict it to mainline and the 4.6 branch since this is the first
one that had the fix for

#define        _RESTRICT_KYWD  __restrict

in <sys/feature_tests.h>.

Thanks.
        Rainer
diff mbox

Patch

diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -3706,6 +3706,23 @@  fix = {
 
 
 /*
+ * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
+ * posix_spawn declarations, which doesn't work with C++.
+ */
+fix = {
+    hackname  = solaris_posix_spawn_restrict;
+    files     = spawn.h;
+    mach      = '*-*-solaris2*';
+    c_fix     = format;
+    c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
+    select    = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
+    test_text =
+    "char *const argv[_RESTRICT_KYWD],\n"
+    "char *const envp[_RESTRICT_KYWD]);";
+};
+
+
+/*
  * Sun Solaris 8 has what appears to be some gross workaround for
  * some old version of their c++ compiler.  G++ doesn't want it
  * either, but doesn't want to be tied to SunPRO version numbers.
diff --git a/fixincludes/tests/base/spawn.h b/fixincludes/tests/base/spawn.h
new file mode 100644
--- /dev/null
+++ b/fixincludes/tests/base/spawn.h
@@ -0,0 +1,15 @@ 
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+	"fixinc/tests/inc/spawn.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+
+
+#if defined( SOLARIS_POSIX_SPAWN_RESTRICT_CHECK )
+char *const *_RESTRICT_KYWD argv,
+char *const *_RESTRICT_KYWD envp);
+#endif  /* SOLARIS_POSIX_SPAWN_RESTRICT_CHECK */