Re: [PATCH] Documentation: Explain a second alternative for multi-line macros.

2007-01-01 Thread Jan Engelhardt
On Jan 1 2007 18:51, Segher Boessenkool wrote: >> If people want to return something from a ({ }) construct, they should do >> it >> explicitly, e.g. >> >> #define setcc(cc) ({ \ >> partial_status &= ~(SW_C0|SW_C1|SW_C2|SW_C3); \ >> partial_status |= (cc) & (SW_C0|SW_C1|SW_C2|SW_C3); \ >> partial

Re: [PATCH] Documentation: Explain a second alternative for multi-line macros.

2007-01-01 Thread Segher Boessenkool
If people want to return something from a ({ }) construct, they should do it explicitly, e.g. #define setcc(cc) ({ \ partial_status &= ~(SW_C0|SW_C1|SW_C2|SW_C3); \ partial_status |= (cc) & (SW_C0|SW_C1|SW_C2|SW_C3); \ partial_status; \ }) No, they generally should use

Re: [PATCH] Documentation: Explain a second alternative for multi-line macros.

2007-01-01 Thread Randy Dunlap
Robert P. J. Day wrote: On Mon, 1 Jan 2007, Christoph Hellwig wrote: On Sun, Dec 31, 2006 at 02:32:25PM -0500, Robert P. J. Day wrote: + (a) Enclose those statements in a do - while block: + + #define macrofun(a, b, c) \ + do {\ +

Re: [PATCH] Documentation: Explain a second alternative for multi-line macros.

2007-01-01 Thread Jan Engelhardt
On Dec 31 2006 19:23, Randy Dunlap wrote: >> > >> > #define setcc(cc) ({ \ >> > partial_status &= ~(SW_C0|SW_C1|SW_C2|SW_C3); \ >> > partial_status |= (cc) & (SW_C0|SW_C1|SW_C2|SW_C3); }) >> >> This _does_ return a value though, bad example. > > Where does it return a value? I don't see any use

Re: [PATCH] Documentation: Explain a second alternative for multi-line macros.

2007-01-01 Thread Robert P. J. Day
On Mon, 1 Jan 2007, Christoph Hellwig wrote: > On Sun, Dec 31, 2006 at 02:32:25PM -0500, Robert P. J. Day wrote: > > + (a) Enclose those statements in a do - while block: > > + > > + #define macrofun(a, b, c) \ > > + do {\ > > +

Re: [PATCH] Documentation: Explain a second alternative for multi-line macros.

2007-01-01 Thread Christoph Hellwig
On Sun, Dec 31, 2006 at 02:32:25PM -0500, Robert P. J. Day wrote: > + (a) Enclose those statements in a do - while block: > + > + #define macrofun(a, b, c) \ > + do {\ > + if (a == 5) \ > +

Re: [PATCH] Documentation: Explain a second alternative for multi-line macros.

2007-01-01 Thread Robert P. J. Day
On Mon, 1 Jan 2007, Segher Boessenkool wrote: > > > In this case, the second form > > > should be used when the macro needs to return a value (and you can't > > > use an inline function for whatever reason), whereas the first form > > > should be used at all other times. > > > > that's a fair poin

Re: [PATCH] Documentation: Explain a second alternative for multi-line macros.

2006-12-31 Thread Randy Dunlap
Segher Boessenkool wrote: #define setcc(cc) ({ \ partial_status &= ~(SW_C0|SW_C1|SW_C2|SW_C3); \ partial_status |= (cc) & (SW_C0|SW_C1|SW_C2|SW_C3); }) This _does_ return a value though, bad example. Where does it return a value? partial_status |= as I expected (or suspected). I

Re: [PATCH] Documentation: Explain a second alternative for multi-line macros.

2006-12-31 Thread Segher Boessenkool
#define setcc(cc) ({ \ partial_status &= ~(SW_C0|SW_C1|SW_C2|SW_C3); \ partial_status |= (cc) & (SW_C0|SW_C1|SW_C2|SW_C3); }) This _does_ return a value though, bad example. Where does it return a value? partial_status |= I don't see any uses of it Ah, that's a separate thing --

Re: [PATCH] Documentation: Explain a second alternative for multi-line macros.

2006-12-31 Thread Randy Dunlap
Segher Boessenkool wrote: In this case, the second form should be used when the macro needs to return a value (and you can't use an inline function for whatever reason), whereas the first form should be used at all other times. that's a fair point, although it's certainly not the coding style t

Re: [PATCH] Documentation: Explain a second alternative for multi-line macros.

2006-12-31 Thread Segher Boessenkool
In this case, the second form should be used when the macro needs to return a value (and you can't use an inline function for whatever reason), whereas the first form should be used at all other times. that's a fair point, although it's certainly not the coding style that's in play now. for exa

Re: [PATCH] Documentation: Explain a second alternative for multi-line macros.

2006-12-31 Thread Robert P. J. Day
On Sun, 31 Dec 2006, Muli Ben-Yehuda wrote: > On Sun, Dec 31, 2006 at 02:49:48PM -0500, Robert P. J. Day wrote: > > > there would appear to be *lots* of cases where the ({ }) notation > > is used when nothing is being returned. i'm not sure you can be > > that adamant about that distinction at th

Re: [PATCH] Documentation: Explain a second alternative for multi-line macros.

2006-12-31 Thread Randy Dunlap
On Sun, 31 Dec 2006 22:09:03 +0200 Muli Ben-Yehuda wrote: > On Sun, Dec 31, 2006 at 02:49:48PM -0500, Robert P. J. Day wrote: > > > there would appear to be *lots* of cases where the ({ }) notation is > > used when nothing is being returned. i'm not sure you can be that > > adamant about that di

Re: [PATCH] Documentation: Explain a second alternative for multi-line macros.

2006-12-31 Thread Muli Ben-Yehuda
On Sun, Dec 31, 2006 at 02:49:48PM -0500, Robert P. J. Day wrote: > there would appear to be *lots* of cases where the ({ }) notation is > used when nothing is being returned. i'm not sure you can be that > adamant about that distinction at this point. IMHO, the main point of CodingStyle is to c

Re: [PATCH] Documentation: Explain a second alternative for multi-line macros.

2006-12-31 Thread Robert P. J. Day
On Sun, 31 Dec 2006, Muli Ben-Yehuda wrote: > On Sun, Dec 31, 2006 at 02:32:25PM -0500, Robert P. J. Day wrote: > > > Generally, inline functions are preferable to macros resembling > > functions. > > This should be stressed, IMHO. We have too many macros which have no > reason to live. > > > -M

Re: [PATCH] Documentation: Explain a second alternative for multi-line macros.

2006-12-31 Thread Muli Ben-Yehuda
On Sun, Dec 31, 2006 at 02:32:25PM -0500, Robert P. J. Day wrote: > Generally, inline functions are preferable to macros resembling > functions. This should be stressed, IMHO. We have too many macros which have no reason to live. > -Macros with multiple statements should be enclosed in a do -

[PATCH] Documentation: Explain a second alternative for multi-line macros.

2006-12-31 Thread Robert P. J. Day
Add an explanation for defining multi-line macros using the ({ }) notation to CodingStyle. Signed-off-by: Robert P. J. Day <[EMAIL PROTECTED]> --- diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle index 9069189..1d0ddb8 100644 --- a/Documentation/CodingStyle +++ b/Documentati