|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 2/2] qom/object: Remove pre-C11 check
Philippe Mathieu-Daudé <philmd@xxxxxxxxxxxxxxxx> writes:
> We mandate a compiler supporting C11 since 2021-06-15 in
> commit d22797ce36a ("configure: Use -std=gnu11"), thus the
> max_align_t type definition exists. Remove what is now dead
> code.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxxxxxxxx>
> ---
> qom/object.c | 14 +-------------
> 1 file changed, 1 insertion(+), 13 deletions(-)
>
> diff --git a/qom/object.c b/qom/object.c
> index 0ac201de4c1..f79b2cf3618 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -675,18 +675,6 @@ static void object_finalize(void *data)
> }
> }
>
> -/* Find the minimum alignment guaranteed by the system malloc. */
> -#if __STDC_VERSION__ >= 201112L
> -typedef max_align_t qemu_max_align_t;
> -#else
> -typedef union {
> - long l;
> - void *p;
> - double d;
> - long double ld;
> -} qemu_max_align_t;
> -#endif
> -
> static Object *object_new_with_type(Type type)
> {
> Object *obj;
> @@ -703,7 +691,7 @@ static Object *object_new_with_type(Type type)
> * Do not use qemu_memalign unless required. Depending on the
> * implementation, extra alignment implies extra overhead.
> */
> - if (likely(align <= __alignof__(qemu_max_align_t))) {
> + if (likely(align <= __alignof__(max_align_t))) {
> obj = g_malloc(size);
> obj_free = g_free;
> } else {
obj = qemu_memalign(align, size);
obj_free = qemu_vfree;
}
Reviewed-by: Markus Armbruster <armbru@xxxxxxxxxx>
Context leads me to qemu_try_memalign() via qemu_memalign():
#elif defined(CONFIG_ALIGNED_MALLOC)
ptr = _aligned_malloc(size, alignment);
#elif defined(CONFIG_VALLOC)
ptr = valloc(size);
#elif defined(CONFIG_MEMALIGN)
ptr = memalign(alignment, size);
#else
#error No function to allocate aligned memory available
#endif
C11 provides aligned_alloc().
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |