Re: question about __v annotation

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

 



>
> 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.

Thus c code with:

ret = readb(c);

will assign ret to __v which in turn is the value returned from __raw_readb().

Thus the above macro structure is the standard way to return a value
from a macro.  You will find similar macro usage throughout the
kernel.

Greg

--
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