delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/01/12/14:24:33

X-Spam-Check-By: sourceware.org
Date: Thu, 12 Jan 2006 14:24:23 -0500
From: Christopher Faylor <cgf-no-personal-reply-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Define _POSIX_SOURCE in cygwin's features.h?
Message-ID: <20060112192423.GI30108@trixie.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
References: <20060112185350 DOT GG30108 AT trixie DOT casa DOT cgf DOT cx> <SERRANObC8wSA1XvpFV000000cb AT SERRANO DOT CAM DOT ARTIMI DOT COM>
Mime-Version: 1.0
In-Reply-To: <SERRANObC8wSA1XvpFV000000cb@SERRANO.CAM.ARTIMI.COM>
User-Agent: Mutt/1.5.11
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Thu, Jan 12, 2006 at 07:06:43PM -0000, Dave Korn wrote:
>Christopher Faylor wrote:
>>If I could easily make cygwin behave exactly the same way so that a
>>buffer overrun that worked on linux went undetected on cygwin, too, I'd
>>do that?  If there was some linker option to ensure that, I'd use it.
>>
>>The point of cygwin isn't that it is a place where you find bugs which
>>you should have fixed on linux.  Every place where there is a barrier
>>to porting a program from linux to cygwin is YA opportunity for someone
>>to give up in disgust or (maybe worse) send a "I get compile error"
>>message here.
>>
>>But, I understand your opinion on the matter.
>
>I understand yours too, and it's equally valid.  I'm curious why
>someone's application would want to test _POSIX_SOURCE - it should be
>the app that sets it or not and it should just know.  But if they've
>handed the responsibility to auto* to determine when to use it, and
>auto* decides YES for Linux, then I agree it should certainly DTST on
>Cygwin.

This particular application was ircd.  It was testing _POSIX_SOURCE (and
a few other defines) to determine whether it should use setsid or a
two-argument version of setpgrp, e.g.:

#ifdef _POSIX_SOURCE
    setsid ();
#else
    setpgr(..., ...);
#endif

Again, I should have tested what I was talking about.  It turns out that
_POSIX_SOURCE *is* turned on by default on in glibc regardless of
whether you define _GNU_SOURCE or not.  So that would explain why this
application built.

Apparently _POSIX_SOURCE is turned on by this segment of features.h:

  #if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \
       !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)
  # define _POSIX_SOURCE  1
  # if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
  #  define _POSIX_C_SOURCE       2
  # else
  #  define _POSIX_C_SOURCE       199506L
  # endif
  #endif

The application in question *could* have done things differently but
there is no way that this irc user would have been capable of making any
changes to accomplish this.  I was wondering if anyone had specific
examples where defining _POSIX_SOURCE would help or hurt existing
applications.  I understand that it wouldn't be as simple as just
defining _POSIX_SOURCE in a header and then walking away but I'm willing
to look into fixing up the cygwin header files to "do the right thing"
(for all I know, they already do) when _POSIX_SOURCE is defined.

cgf

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019