delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/06/30/10:07:13

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Thu, 30 Jun 2011 16:06:23 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: bug in pipe() and pipe2()
Message-ID: <20110630140623.GF9552@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <4E0B9959 DOT 6060903 AT redhat DOT com> <20110630093825 DOT GC9552 AT calimero DOT vinschen DOT de> <4E0C6317 DOT 7080203 AT cs DOT utoronto DOT ca>
MIME-Version: 1.0
In-Reply-To: <4E0C6317.7080203@cs.utoronto.ca>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
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 Jun 30 07:50, Ryan Johnson wrote:
> On 30/06/2011 5:38 AM, Corinna Vinschen wrote:
> > I only see a very ugly workaround for this
> >problem.
> >
> >I checked it in, together with two more fixes to avoid a crash.
> >If somebody has a better solution, feel free to mention it.
> If you don't mind using a couple of gcc extensions (we are a
> gcc-only shop, right?):

Indeed.

> #define cnew(name, ...) ({                                              \
>             void* ptr = (void*) ccalloc (HEAP_FHANDLER, 1, sizeof
> (name)); \
>             ptr? new(ptr) name(__VA_ARGS__) : NULL;                     \
>         })
> 
> The macro's usage would change to look like a normal function call:
> 
> fhandler_base *fh = cnew(fhandler_nodevice);
> 
> You just need to check fh != NULL afterward. If the ctor for
> fhandler_nodevice took an argument 'x' it would follow as additional
> args to the cnew macro, rather than as an additional set of parens:
> 
> fhandler_base *fh = cnew(fhandler_nodevice, x);

Cool.  Thanks a lot.  I tried some ({ ... }) expression as well but
apparently gave up too early.  I applied your change since it's much
cleaner than my ugly hack.


Thanks again,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

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

- Raw text -


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