[lkml]   [1996]   [Jun]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Problem: __inline__ functions in the kernel & cli()/sti() latency measurement

On Tue, 11 Jun 1996, Warner Losh wrote:
> Also, you can't reutrn a value from a macro like that. You can from
> an inline function.

GNU C _does_ allow you to return a value from a C macro, and I think it's
even used by Linux someplace:

#define MACRO_RETURNS_ARG(x) ({ \
int __temp_value = x; \
printf("returning %d\n", __temp_value); \
__temp_value; \

The "({ .. })" syntax is a "block expression", and the last statement in
the block is the value of the whole expression. ("__tmp_value" used here
to get the "x" evaluated only once - you can use other gcc extensions
like "__typeof__" to do more generic macros)

It's sometimes useful, but most of the time it's just plain stupid to use
it, because it only works with gcc (when it comes to the kernel that's
ok, but..)


 \ /
  Last update: 2005-03-22 13:37    [W:0.027 / U:8.848 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site