Thread (25 messages) 25 messages, 7 authors, 2009-05-26

Re: [PATCH V4 1/5] The macro spin_event_timeout() takes a condition and timeout value

From: Geert Uytterhoeven <hidden>
Date: 2009-05-26 11:51:50
Also in: alsa-devel

On Tue, 26 May 2009, Timur Tabi wrote:
On Tue, May 26, 2009 at 2:29 AM, Geert Uytterhoeven
[off-list ref] wrote:
quoted
static inline function, returning rc, instead of a macro?
It won't work as an inline function ...
quoted
quoted
+     unsigned long __loops = tb_ticks_per_usec * timeout;                \
+     unsigned long __start = get_tbl();                                  \
+     while ((rc = (condition)) && (tb_ticks_since(__start) <= __loops)) \
There's no way to pass a expression to an inline function.  It has to
be a macro.  Here, the loop evaluates "condition" at every pass.  If
this were an inline function, "condition" would be evaluated once when
the function were called, and never again.
You're right, I missed that part. Sorry about that.

However, you can still improve useability by making the macro return the rc,
instead of letting the caller pass it, cfr. wait_event_timeout() and friends.

With kind regards,

Geert Uytterhoeven
Software Architect
Techsoft Centre

Technology and Software Centre Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

Phone:    +32 (0)2 700 8453
Fax:      +32 (0)2 700 8622
E-mail:   Geert.Uytterhoeven@sonycom.com
Internet: http://www.sony-europe.com/

A division of Sony Europe (Belgium) N.V.
VAT BE 0413.825.160 · RPR Brussels
Fortis · BIC GEBABEBB · IBAN BE41293037680010
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help