[ofw] [PATCH] typeof() not supported in Windows WDK compiler

Smith, Stan stan.smith at intel.com
Thu Oct 1 17:29:45 PDT 2009


Jason Gunthorpe wrote:
> On Thu, Oct 01, 2009 at 03:59:00PM -0700, Sean Hefty wrote:
>>> diff --git a/opensm/opensm/osm_drop_mgr.c
>>> b/opensm/opensm/osm_drop_mgr.c index 4f98cc9..8fe5129 100644 +++
>>> b/opensm/opensm/osm_drop_mgr.c @@ -209,8 +209,13 @@ static void
>>>     drop_mgr_remove_port(osm_sm_t * sm, IN osm_port_t * p_port)
>>> drop_mgr_clean_physp(sm, p_port->p_physp);
>>>
>>>     while (!cl_is_qlist_empty(&p_port->mcm_list)) {
>>> +#ifndef __WIN__
>>>             mcm_port = cl_item_obj(cl_qlist_head(&p_port->mcm_list),
>>>                                    mcm_port, list_item);
>>> +#else
>>> +           mcm_port = cl_item_obj(cl_qlist_head(&p_port->mcm_list),
>>> +                                  mcm_port, list_item, (osm_mcm_port_t*) );
>>> +#endif
>>
>> I'd find this more readable if it were #ifdef rather than #ifndef.
>>
>> That said, I've got to believe that there's a better way to handle
>> these changes.  I just don't know what it is.
>
> Hmm
>
> How about

Do the Sun guys use gcc?

>
> #ifdef __GCC_
> #define cl_item_obj(item_ptr, obj_ptr, item_field) (typeof(obj_ptr)) \
>         ((void *)item_ptr - (unsigned
> long)&((typeof(obj_ptr))0)->item_field) #else
> #define cl_item_obj(item_ptr, obj_ptr, item_field) (typeof(obj_ptr)) \
>   (void *)((uint8_t*)item_ptr - ((uintptr_t)(&(obj_ptr)->item_field) -
>   ((uintptr_t)&(obj_ptr))))
> #endif

Interesting, worth a try.

>
> And rely on the C implicit cast from void* to an object type, and rely
> on compiles with gcc to do the extra type checking.

'compiles with gcc' ?

>
> Jason




More information about the ofw mailing list