Bug 61649 - fixincludes update for solaris___restrict in sys/feature_tests.h on Illumos
Summary: fixincludes update for solaris___restrict in sys/feature_tests.h on Illumos
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.7.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-29 17:11 UTC by Richard PALO
Modified: 2021-07-24 16:36 UTC (History)
3 users (show)

See Also:
Host:
Target: Illumos
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
patch to existing fixincludes/inclhack.def from gcc-4.7.3 (546 bytes, text/plain)
2014-06-29 17:11 UTC, Richard PALO
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard PALO 2014-06-29 17:11:38 UTC
Created attachment 33031 [details]
patch to existing fixincludes/inclhack.def from gcc-4.7.3

Due to an update to sys/feature_tests.h as indicated here (https://illumos.org/issues/2941), Illumos has "broken" the fixincludes solaris___restrict hack as is evident by the current result in $PREFIX/gcc47/lib/.../include-fixed/sys/feature_tests.h

/*
 * The following macro defines a value for the ISO C99 restrict
 * keyword so that _RESTRICT_KYWD resolves to "restrict" if
 * an ISO C99 compiler is used and "" (null string) if any other
 * compiler is used. This allows for the use of single prototype
 * declarations regardless of compiler version.
 */
#if (defined(__STDC__) && defined(_STDC_C99)) && !defined(__cplusplus)
#ifdef __cplusplus
#define	_RESTRICT_KYWD	__restrict
#else
#define	_RESTRICT_KYWD	restrict
#endif
#else
#define	_RESTRICT_KYWD
#endif


The attached patch seem to work around this by allowing both the standard and the Illumos forms to be updated.

The test/base/sys/feature_tests.h patch is as follows:
--- fixincludes/tests/base/sys/feature_tests.h.orig	2010-06-21 15:27:29.000000000 +0000
+++ fixincludes/tests/base/sys/feature_tests.h
@@ -10,6 +10,7 @@
 
 
 #if defined( SOLARIS___RESTRICT_CHECK )
+#if (defined(__STDC__) && defined(_STDC_C99))
 #ifdef __cplusplus
 #define	_RESTRICT_KYWD	__restrict
 #else
Comment 1 Richard PALO 2014-11-22 10:55:36 UTC
given https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52168,
it seems necessary to update the test_text line with a newline appended
as follows so that check.sh doesn't balk:
>+    test_text = "#if (defined(__STDC__) && defined(_STDC_C99))\n"
>+    	        "#define	_RESTRICT_KYWD	restrict";
Comment 2 Jonathan Wakely 2014-11-25 11:30:31 UTC
(In reply to Richard PALO from comment #0)
> 
> The test/base/sys/feature_tests.h patch is as follows:
> --- fixincludes/tests/base/sys/feature_tests.h.orig	2010-06-21
> 15:27:29.000000000 +0000
> +++ fixincludes/tests/base/sys/feature_tests.h
> @@ -10,6 +10,7 @@
>  
>  
>  #if defined( SOLARIS___RESTRICT_CHECK )
> +#if (defined(__STDC__) && defined(_STDC_C99))
>  #ifdef __cplusplus
>  #define	_RESTRICT_KYWD	__restrict
>  #else

Shouldn't there be a corresponding #endif added to that file?
Comment 3 Richard PALO 2014-11-25 12:33:18 UTC
No. Prior to fixincludes, sys/feature_tests.h in SunOS looks like the following:

#if (defined(__STDC__) && defined(_STDC_C99))
#define _RESTRICT_KYWD  restrict
#else
#define _RESTRICT_KYWD
#endif


Illumos has since https://www.illumos.org/issues/2941 the following:

#if (defined(__STDC__) && defined(_STDC_C99)) && !defined(__cplusplus)
#define _RESTRICT_KYWD  restrict
#else
#define _RESTRICT_KYWD
#endif


The net effect of my patch is to support both variants in producing the following:

#if (defined(__STDC__) && defined(_STDC_C99))
#ifdef __cplusplus
#define _RESTRICT_KYWD __restrict
#else
#define _RESTRICT_KYWD  restrict
#endif
#else
#define _RESTRICT_KYWD
#endif
Comment 4 Richard PALO 2014-11-25 12:41:12 UTC

> 
> The test/base/sys/feature_tests.h patch is as follows:
> --- fixincludes/tests/base/sys/feature_tests.h.orig	2010-06-21
> 15:27:29.000000000 +0000
> +++ fixincludes/tests/base/sys/feature_tests.h
> @@ -10,6 +10,7 @@
>  
>  
>  #if defined( SOLARIS___RESTRICT_CHECK )
> +#if (defined(__STDC__) && defined(_STDC_C99))
>  #ifdef __cplusplus
>  #define	_RESTRICT_KYWD	__restrict
>  #else


Perhaps I should remind as well that the file is a diff with only a certain number of lines as context... so in that respect, it isn't necessary either.
Comment 5 Richard PALO 2015-07-02 14:53:33 UTC
kind reminder to push these two patches:
1) https://gcc.gnu.org/bugzilla/attachment.cgi?id=33031
2) and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61649#c1 (*)
* NB https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52168

I believe I already answered Jonathan's question in that since
only a [preceeding] line of context is being added, there is no
additional '#endif' to add.

BTW, this line of context is necessary anyway, because if either
Oracle Solaris or Illumos change this code section, for example by 
fixing it as gcc currently does here, it will prevent fixincl.x from
action which would actually *break* the file.