From: "J . A . Magallon" <jamagallon@able.es>
To: Davide Libenzi <davidel@xmailserver.org>
Cc: David Woodhouse <dwmw2@infradead.org>, linux-kernel@vger.kernel.org
Subject: Re: linux/macros.h(new) and linux/list.h(mod) ...
Date: Fri, 6 Jul 2001 00:10:29 +0200 [thread overview]
Message-ID: <20010706001029.A11790@werewolf.able.es> (raw)
In-Reply-To: <8505.994368672@redhat.com> <XFMail.20010705144521.davidel@xmailserver.org>
In-Reply-To: <XFMail.20010705144521.davidel@xmailserver.org>; from davidel@xmailserver.org on Thu, Jul 05, 2001 at 23:45:21 +0200
On 20010705 Davide Libenzi wrote:
>
>On 05-Jul-2001 David Woodhouse wrote:
>>
>> davidel@xmailserver.org said:
>>> This patch add a new linux/macros.h that is supposed to host utility
>>> macros that otherwise developers are forced to define in their files.
>>> This version contain only min(), max() and abs().
>>
>> Consider min(x++,y++). Try:
>>
>>#define min(x,y) ({ typeof((x)) _x = (x); typeof((y)) _y = (y); (_x>_y)?_y:_x;
>>#})
>>#define max(x,y) ({ typeof((x)) _x = (x); typeof((y)) _y = (y); (_x>_y)?_x:_y;
>>#})
>
>Yep, it's better.
And there could be others also usefull:
#define ztst(x,y) (x ?: y) // `x' if that is nonzero; otherwise, of `y'
If g++ extensions worked in plain C, you just could write:
#define min(x,y) (x <? y)
#define max(x,y) (x >? y)
--
J.A. Magallon # Let the source be with you...
mailto:jamagallon@able.es
Mandrake Linux release 8.1 (Cooker) for i586
Linux werewolf 2.4.6-ac1 #2 SMP Thu Jul 5 01:15:49 CEST 2001 i686
next prev parent reply other threads:[~2001-07-05 22:10 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-05 20:57 linux/macros.h(new) and linux/list.h(mod) Davide Libenzi
2001-07-05 21:31 ` David Woodhouse
2001-07-05 21:45 ` Davide Libenzi
2001-07-05 21:54 ` Hua Zhong
2001-07-05 21:58 ` David Woodhouse
2001-07-05 22:20 ` Hua Zhong
2001-07-05 22:06 ` Davide Libenzi
2001-07-05 22:10 ` J . A . Magallon [this message]
2001-07-05 22:33 ` Daniel Phillips
2001-07-05 22:43 ` David Woodhouse
2001-07-05 22:53 ` Davide Libenzi
2001-07-05 23:23 ` J . A . Magallon
2001-07-05 22:57 ` Alan Cox
2001-07-05 23:05 ` Matthew Dharm
2001-07-05 23:07 ` Alan Cox
2001-07-05 23:08 ` David Woodhouse
2001-07-06 1:51 ` Arnaldo Carvalho de Melo
2001-07-05 23:21 ` Davide Libenzi
[not found] ` <0107060149080M.03760@starship>
2001-07-05 23:54 ` Daniel Phillips
2001-07-06 17:38 ` Neil Booth
2001-07-06 22:02 ` Arnaldo Carvalho de Melo
2001-07-05 22:03 ` Kai Germaschewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010706001029.A11790@werewolf.able.es \
--to=jamagallon@able.es \
--cc=davidel@xmailserver.org \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox