[PATCH] Allow usage of union wait for wait() functions and macros

Christopher Faylor cgf-use-the-mailinglist-please@cygwin.com
Thu Oct 6 02:37:00 GMT 2011


On Wed, Oct 05, 2011 at 11:17:58PM +0200, Christian Franke wrote:
>Christopher Faylor wrote:
>> On Wed, Oct 05, 2011 at 12:57:44PM +0200, Christian Franke wrote:
>>> ...
>>> diff --git a/winsup/cygwin/include/cygwin/wait.h b/winsup/cygwin/include/cygwin/wait.h
>>> index bed81b7..e4edba2 100644
>>> --- a/winsup/cygwin/include/cygwin/wait.h
>>> +++ b/winsup/cygwin/include/cygwin/wait.h
>>> @@ -1,6 +1,6 @@
>>> /* cygwin/wait.h
>>>
>>> -   Copyright 2006, 2009 Red Hat, Inc.
>>> +   Copyright 2006, 2009, 2011 Red Hat, Inc.
>>>
>>> This file is part of Cygwin.
>>>
>>> @@ -16,6 +16,9 @@ details. */
>>> #define WCONTINUED 8
>>> #define __W_CONTINUED	0xffff
>>>
>>> +/* Will be redefined in sys/wait.h.  */
>>> +#define __wait_status_to_int(w)  (w)
>>> +
>> Why is this necessary?  It doesn't look like it is ever expanded in cygwin/wait.h.
>
>This would be needed if cygwin/wait.h is included separately without 
>sys/wait.h
>(e.g. stdlib.h -> cygwin/stdlib.h -> cygwin/wait.h)
>and some W*() macro is actually used.
>
>
>> If a redefinition is necessary why not put it all in one place?
>
>The W*() macros and union wait are closely related. So a probably better 
>approach would be to move union wait to cygwin/wait.h and define 
>__wait_status_to_int() only there.
>
>But then C++ compile may fail because cygwin/wait.h is sometimes 
>included indirectly inside an extern "C" block:
>w32api/shlobj.h -> extern "C" { w32api/ole2.h ...-> stdlib.h ...-> 
>cygwin/wait.h }

Ok.  I see that Linux's use of similar macros is convoluted too.
I really would rather keep this all together but I guess it isn't
possible without redesigning stdlib.h and */wait.h.

>> And why is redefinition needed inside Cygwin?
>
>It is not redefined in the __INSIDE_CYGWIN__ case.
>
>
>>> ...
>>> +
>>> +#endif
>> Could you add a comment here and at the #else indicating what they refer to
>> like #else /* !(defined(__cplusplus) || defined(__INSIDE_CYGWIN__)) and
>> #endif (defined(__cplusplus) || defined(__INSIDE_CYGWIN__) ?
>
>OK.
>
>
>> Also since Cygwin is C++ why do you need the __INSIDE_CYGWIN__ here?
>
>There are still ten *.c files in winsup/cygwin :-)

% cd winsup/cygwin
% grep wait.h **/*.c
%

cgf



More information about the Cygwin-patches mailing list