On Thu, 27 Feb, at 12:09:21PM, H. Peter Anvin wrote:
> 
> That being said, is there a reason we can't simply write this as:
> 
>       efi_system_table_##bits##_t table;
> 
>       /* ... */
> 
>       func = (typeof(func))(unsigned long)table->con_out;
>       c->text_output = *func;

Oh, yeah that's much better. I was being overly cautious with trying to
not dereference the pointers in the regular efi_system_table_t, and what
you've written is much more compact both in terms of C and generated
object code. Things end up looking like this,

---

#define BOOT_SERVICES(bits)                                             \
static void setup_boot_services##bits(struct efi_config *c)             \
{                                                                       \
        efi_system_table_##bits##_t *table;                             \
        efi_boot_services_##bits##_t *bt;                               \
                                                                        \
        table = (typeof(table))sys_table;                               \
                                                                        \
        c->text_output = table->con_out;                                \
                                                                        \
        bt = (typeof(bt))(unsigned long)(table->boottime);              \
                                                                        \
        c->allocate_pool = bt->allocate_pool;                           \
        c->allocate_pages = bt->allocate_pages;                         \
        c->get_memory_map = bt->get_memory_map;                         \
        c->free_pool = bt->free_pool;                                   \
        c->free_pages = bt->free_pages;                                 \
        c->locate_handle = bt->locate_handle;                           \
        c->handle_protocol = bt->handle_protocol;                       \
        c->exit_boot_services = bt->exit_boot_services;                 \
}
BOOT_SERVICES(32);
BOOT_SERVICES(64);

-- 
Matt Fleming, Intel Open Source Technology Center
--
To unsubscribe from this list: send the line "unsubscribe linux-efi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to