git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC/PATCH 1/2] Teach Solaris that _XOPEN_SOURCE=600 really menas XPG6

From
Junio C Hamano <gitster@pobox.com>
Date
May 28, 2009, 20:37 UTC
Message-ID
<7viqjlge16.fsf@alter.siamese.dyndns.org>
In-Reply-To
<WLNdjYtfqcg2bT6yOBtAykIqOBTeSLRUdlB6-sTM2KzTjwOmzN3fLg@cipher.nrlssc.navy.mil>
Brandon Casey <casey@nrlssc.navy.mil> writes:
Show 7 quoted lines
> So we either require compiling with a c99 compiler (by ensuring that
> _XPG6 is set) or exclude compiling with a c99 compiler on sun (by
> ensuring that _XPG6 is not set).  Actually, this would only affect Solaris
> versions which support XPG6.  Solaris 11 and 10 do.  I don't know about
> Solaris 9 and 8.  Solaris 7 doesn't.
>
> Which do we want to do?

If possible, both ;-), because people would have or want to use different compilers.

I use "gcc -std=c99" on all platforms I compile git on (for details see "Make" in the 'todo' branch; I have a checkout of the todo branch at Meta/ and say "Meta/Make --pedantic" from the toplevel), and that is how I noticed this breakage on OpenSolaris 08.11 (it identifies itself as 5.11, so presumably it falls into "Solaris 11" category you cited above?)

Show 8 quoted lines
>> diff --git a/git-compat-util.h b/git-compat-util.h
>> index c7cf2d5..4236647 100644
>> --- a/git-compat-util.h
>> +++ b/git-compat-util.h
>> @@ -41,8 +41,10 @@
>>  
>>  #if !defined(__APPLE__) && !defined(__FreeBSD__)  && !defined(__USLC__) && !defined(_M_UNIX)
>>  #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */

Judging from their header files, I guess Sun's attitude is incompatible with the above comment for _XOPEN_SOURCE. We say "... need 500" and set it to 600 because we merely mean "need to be at least 500" by "need 500", but Sun wants us to be very precise. So instead of saying __sun__, we could do something more explicit with a huge comment...

	#if !defined(__APPLE__) ...
        # define _XOPEN_SOURCE 600
        /*
         * On Solaris, when _XOPEN_EXTENDED is set, its header file
         * forces the programs to be XPG4v2, defeating the _XOPEN_SOURCE
         * setting we just made to say we are XPG6.  Also on Solaris,
         * XPG6 programs must be compiled with a c99 compiler, while
         * non XPG6 programs must be compiled with a pre-c99 compiler.
         */
        # if defined(__sun__) && !(__STDC_VERSION__ - 0 >= 199901L)
        # define _XOPEN_EXTENDED 1 /* AIX 5.3L wants this */
        # endif
	#endif

We might want to flatten this a bit more to special case Solaris, which might make it easier to maintain, e.g.

	#if defined(__sun__)
        # ... whatever _XOPEN_SOURCE and _XOPEN_EXTENDED magic
        # ... Solaris wants
        #elif !defined(__APPLE__) && ...
        # ... existing code
        #endif
Previous: Jeff KingNext: Tomas Carnecky
Message 8 of 15 in “OpenSolaris 2008.11 portability fixes”
  1. 0/2 OpenSolaris 2008.11 portability fixesJunio C Hamano, May 23, 2009
  2. 1/2 Teach Solaris that _XOPEN_SOURCE=600 really menas XPG6Junio C Hamano, May 23, 2009
  3. 2/2 OpenSolaris 200811 (SunOS 5.11) does not want OLD_ICONVJunio C Hamano, May 23, 2009
  4. Brandon CaseyMay 28, 2009
  5. Jeff KingMay 28, 2009
  6. Brandon CaseyMay 28, 2009
  7. Jeff KingMay 28, 2009
  8. Junio C HamanoMay 28, 2009
  9. Tomas CarneckyJun 11, 2009
  10. Brandon CaseyJun 11, 2009
  11. Tomas CarneckyJun 11, 2009
  12. Brandon CaseyJun 11, 2009
  13. Tomas CarneckyJun 11, 2009
  14. Brandon CaseyJun 11, 2009
  15. Junio C HamanoJun 11, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.