Re: question about __v annotation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2010-01-04 at 11:46 -0500, Greg Freemyer wrote:
> >
> > On Sat, Jan 2, 2010 at 8:10 AM, Shawn <citypw@xxxxxxxxx> wrote:
> >>
> >> hello guys,
> >>  I got a newbie confused when I was looking into the source code of
> >> s3c2440's RTC driver.I dont know what is __v excatly means.anyone can
> >> tell?thanks anyway!
> >>
> >> #define readb(c) ({ __u8  __v = __raw_readb(__mem_pci(c)); __v; })
> 
> On Sun, Jan 3, 2010 at 11:49 AM, Anand Arumugam <anand.arumug@xxxxxxxxx> wrote:
> > I think the last __v; inside the macro is to avoid compiler warning or error
> > that the unsigned 8-bit variable __v is not being used inside the scope
> > defined by the macro.
> 
> No,  I believe it is the value assigned to the statement sequence
> wrapped in the {} pair.
> 
> ie. {statement1; statement2; variable} evaluates to the value of the
> variable which is the last statement.
No.
"{statement1; statement2; variable}" is pure (from K&R times ) C (if you
fix the syntax error of the missing ";" before the closing "}") and this
is usually called a "compound statement".
It becomes an expression if you
- use a gcc (young enough to implement it) and
- put the "( and ")" around it.
And the the result of the last statement becomes the result of the
expression

	Bernd
-- 
mobil: +43 664 4416156          http://bernd.petrovitsch.priv.at/
    Linux Software Entwicklung, Beratung und Dienstleistungen


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux