diff --git a/sys/sys/kobj.h b/sys/sys/kobj.h --- a/sys/sys/kobj.h +++ b/sys/sys/kobj.h @@ -220,7 +220,7 @@ * slow way. */ #ifdef KOBJ_STATS -#define KOBJOPLOOKUP(OPS,OP) do { \ +#define KOBJOPLOOKUP(OPS, OP) __extension__ ({ \ kobjop_desc_t _desc = &OP##_##desc; \ kobj_method_t **_cep = \ &OPS->cache[_desc->id & (KOBJ_CACHE_SIZE-1)]; \ @@ -231,10 +231,10 @@ kobj_lookup_misses++; \ } else \ kobj_lookup_hits++; \ - _m = _ce->func; \ -} while (0) + (OP##_t *)(_ce->func); \ +}) #else -#define KOBJOPLOOKUP(OPS,OP) do { \ +#define KOBJOPLOOKUP(OPS, OP) __extension__ ({ \ kobjop_desc_t _desc = &OP##_##desc; \ kobj_method_t **_cep = \ &OPS->cache[_desc->id & (KOBJ_CACHE_SIZE-1)]; \ @@ -242,8 +242,8 @@ if (_ce->desc != _desc) \ _ce = kobj_lookup_method(OPS->cls, \ _cep, _desc); \ - _m = _ce->func; \ -} while (0) + (OP##_t *)(_ce->func); \ +}) #endif kobj_method_t* kobj_lookup_method(kobj_class_t cls, diff --git a/sys/tools/makeobjops.awk b/sys/tools/makeobjops.awk --- a/sys/tools/makeobjops.awk +++ b/sys/tools/makeobjops.awk @@ -320,16 +320,16 @@ line_width, length(prototype))); } printh("{"); - printh("\tkobjop_t _m;"); + printh("\t" mname "_t *_m;"); if (ret != "void") printh("\t" ret " rc;"); if (!static) firstvar = "((kobj_t)" firstvar ")"; if (prolog != "") printh(prolog); - printh("\tKOBJOPLOOKUP(" firstvar "->ops," mname ");"); + printh("\t_m = KOBJOPLOOKUP(" firstvar "->ops, " mname ");"); rceq = (ret != "void") ? "rc = " : ""; - printh("\t" rceq "((" mname "_t *) _m)(" varname_list ");"); + printh("\t" rceq "_m(" varname_list ");"); if (epilog != "") printh(epilog); if (ret != "void")