On 15/11/2024 12:15 pm, Luca Fancellu wrote: > >> On 15 Nov 2024, at 12:00, Andrew Cooper <andrew.coop...@citrix.com> wrote: >> >> On 15/11/2024 10:50 am, Luca Fancellu wrote: >>> diff --git a/xen/include/xen/xvmalloc.h b/xen/include/xen/xvmalloc.h >>> index 440d85a284bb..802be6687085 100644 >>> --- a/xen/include/xen/xvmalloc.h >>> +++ b/xen/include/xen/xvmalloc.h >>> @@ -40,20 +40,46 @@ >>> ((typeof(ptr))_xvrealloc(ptr, offsetof(typeof(*(ptr)), field[nr]), \ >>> __alignof__(typeof(*(ptr))))) >>> >>> +#if defined(CONFIG_HAS_VMAP) >>> + >>> /* Free any of the above. */ >>> void xvfree(void *va); >>> >>> +/* Underlying functions */ >>> +void *_xvmalloc(size_t size, unsigned int align); >>> +void *_xvzalloc(size_t size, unsigned int align); >>> +void *_xvrealloc(void *va, size_t size, unsigned int align); >>> + >>> +#else >>> + >>> +static inline void xvfree(void *va) >>> +{ >>> + xfree(va); >>> +} >>> + >>> +void *_xvmalloc(size_t size, unsigned int align) >>> +{ >>> + return _xmalloc(size, align); >>> +} >>> + >>> +void *_xvzalloc(size_t size, unsigned int align) >>> +{ >>> + return _xzalloc(size, align); >>> +} >>> + >>> +void *_xvrealloc(void *va, size_t size, unsigned int align) >>> +{ >>> + return _xrealloc(va, size, align); >>> +} >>> + >>> +#endif >> Does this really compile with the wrappers not being static inline ? >> >> That aside, could we not do this using conditional aliases, rather than >> wrapping the functions? It would certainly be shorter, code wise. > Do you mean something like below? > > #define xvfree xfree > #define _xvmalloc _xmalloc > […]
I mean __attribute__((__alias__(""))) There are two examples in tree already. See efi_compat_get_info() being aliased to efi_get_info() In this case, in the !HAS_VMAP case, we'd just declare _xmalloc() to have an alias called _xvmalloc() too. This avoids needing to wrap every function in the headers. ~Andrew