All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] misc: Remove pre-C99/C11 checks
@ 2026-06-13 17:51 Philippe Mathieu-Daudé
  2026-06-13 17:51 ` [PATCH 1/2] hw/xen/interface: Remove pre-C99 checks Philippe Mathieu-Daudé
  2026-06-13 17:51 ` [PATCH 2/2] qom/object: Remove pre-C11 check Philippe Mathieu-Daudé
  0 siblings, 2 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-06-13 17:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Edgar E. Iglesias, xen-devel, Daniel P. Berrangé,
	Anthony PERARD, Paolo Bonzini, Stefano Stabellini,
	Philippe Mathieu-Daudé

We uses C11 since 5 years now, time to
remove few obsolete __STDC_VERSION__ checks.

Philippe Mathieu-Daudé (2):
  hw/xen/interface: Remove pre-C99 checks
  qom/object: Remove pre-C11 check

 include/hw/xen/interface/physdev.h    |  2 +-
 include/hw/xen/interface/version.h    |  5 ++---
 include/hw/xen/interface/xen-compat.h |  2 --
 include/hw/xen/interface/xen.h        | 14 --------------
 qom/object.c                          | 14 +-------------
 5 files changed, 4 insertions(+), 33 deletions(-)

-- 
2.53.0



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] hw/xen/interface: Remove pre-C99 checks
  2026-06-13 17:51 [PATCH 0/2] misc: Remove pre-C99/C11 checks Philippe Mathieu-Daudé
@ 2026-06-13 17:51 ` Philippe Mathieu-Daudé
  2026-06-13 18:13   ` Bastian Blank
  2026-06-13 17:51 ` [PATCH 2/2] qom/object: Remove pre-C11 check Philippe Mathieu-Daudé
  1 sibling, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-06-13 17:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Edgar E. Iglesias, xen-devel, Daniel P. Berrangé,
	Anthony PERARD, Paolo Bonzini, Stefano Stabellini,
	Philippe Mathieu-Daudé

We mandate a compiler supporting C99 since 2019-01-17 in
commit 7be41675f7c ("configure: Force the C standard to gnu99"),
thus supporting flexible array members. Remove what is now dead
code.

Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
 include/hw/xen/interface/physdev.h    |  2 +-
 include/hw/xen/interface/version.h    |  5 ++---
 include/hw/xen/interface/xen-compat.h |  2 --
 include/hw/xen/interface/xen.h        | 14 --------------
 4 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/include/hw/xen/interface/physdev.h b/include/hw/xen/interface/physdev.h
index f0c0d4727c0..8da03b685ad 100644
--- a/include/hw/xen/interface/physdev.h
+++ b/include/hw/xen/interface/physdev.h
@@ -283,7 +283,7 @@ struct physdev_pci_device_add {
      * First element ([0]) is PXM domain associated with the device (if
      * XEN_PCI_DEV_PXM is set)
      */
-    uint32_t optarr[XEN_FLEX_ARRAY_DIM];
+    uint32_t optarr[0];
 };
 typedef struct physdev_pci_device_add physdev_pci_device_add_t;
 DEFINE_XEN_GUEST_HANDLE(physdev_pci_device_add_t);
diff --git a/include/hw/xen/interface/version.h b/include/hw/xen/interface/version.h
index 9c78b4f3b6a..41ff28c7ee5 100644
--- a/include/hw/xen/interface/version.h
+++ b/include/hw/xen/interface/version.h
@@ -77,9 +77,8 @@ typedef char xen_commandline_t[1024];
  */
 #define XENVER_build_id 10
 struct xen_build_id {
-        uint32_t        len; /* IN: size of buf[]. */
-        unsigned char   buf[XEN_FLEX_ARRAY_DIM];
-                             /* OUT: Variable length buffer with build_id. */
+        uint32_t        len;    /* IN: size of buf[]. */
+        unsigned char   buf[0]; /* OUT: Variable length buffer with build_id. */
 };
 typedef struct xen_build_id xen_build_id_t;
 
diff --git a/include/hw/xen/interface/xen-compat.h b/include/hw/xen/interface/xen-compat.h
index 97fe6984989..582c0182367 100644
--- a/include/hw/xen/interface/xen-compat.h
+++ b/include/hw/xen/interface/xen-compat.h
@@ -24,6 +24,4 @@
 #error "These header files do not support the requested interface version."
 #endif
 
-#define COMPAT_FLEX_ARRAY_DIM XEN_FLEX_ARRAY_DIM
-
 #endif /* __XEN_PUBLIC_XEN_COMPAT_H__ */
diff --git a/include/hw/xen/interface/xen.h b/include/hw/xen/interface/xen.h
index 920567e0062..a6f4aa61993 100644
--- a/include/hw/xen/interface/xen.h
+++ b/include/hw/xen/interface/xen.h
@@ -36,15 +36,6 @@ DEFINE_XEN_GUEST_HANDLE(uint64_t);
 DEFINE_XEN_GUEST_HANDLE(xen_pfn_t);
 DEFINE_XEN_GUEST_HANDLE(xen_ulong_t);
 
-/* Define a variable length array (depends on compiler). */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-#define XEN_FLEX_ARRAY_DIM
-#elif defined(__GNUC__)
-#define XEN_FLEX_ARRAY_DIM  0
-#else
-#define XEN_FLEX_ARRAY_DIM  1 /* variable size */
-#endif
-
 /* Turn a plain number into a C unsigned (long (long)) constant. */
 #define __xen_mk_uint(x)  x ## U
 #define __xen_mk_ulong(x) x ## UL
@@ -986,13 +977,8 @@ typedef struct {
       ((d) >>  8) & 0xFF, ((d) >>  0) & 0xFF,                           \
                 e1, e2, e3, e4, e5, e6}}
 
-#if defined(__STDC_VERSION__) ? __STDC_VERSION__ >= 199901L : defined(__GNUC__)
 #define XEN_DEFINE_UUID(a, b, c, d, e1, e2, e3, e4, e5, e6)             \
     ((xen_uuid_t)XEN_DEFINE_UUID_(a, b, c, d, e1, e2, e3, e4, e5, e6))
-#else
-#define XEN_DEFINE_UUID(a, b, c, d, e1, e2, e3, e4, e5, e6)             \
-    XEN_DEFINE_UUID_(a, b, c, d, e1, e2, e3, e4, e5, e6)
-#endif /* __STDC_VERSION__ / __GNUC__ */
 
 #endif /* !__ASSEMBLY__ */
 
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] qom/object: Remove pre-C11 check
  2026-06-13 17:51 [PATCH 0/2] misc: Remove pre-C99/C11 checks Philippe Mathieu-Daudé
  2026-06-13 17:51 ` [PATCH 1/2] hw/xen/interface: Remove pre-C99 checks Philippe Mathieu-Daudé
@ 2026-06-13 17:51 ` Philippe Mathieu-Daudé
  2026-06-15  5:05   ` Markus Armbruster
  1 sibling, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-06-13 17:51 UTC (permalink / raw)
  To: qemu-devel
  Cc: Edgar E. Iglesias, xen-devel, Daniel P. Berrangé,
	Anthony PERARD, Paolo Bonzini, Stefano Stabellini,
	Philippe Mathieu-Daudé

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@oss.qualcomm.com>
---
 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 {
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] hw/xen/interface: Remove pre-C99 checks
  2026-06-13 17:51 ` [PATCH 1/2] hw/xen/interface: Remove pre-C99 checks Philippe Mathieu-Daudé
@ 2026-06-13 18:13   ` Bastian Blank
  2026-06-14 16:40     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 6+ messages in thread
From: Bastian Blank @ 2026-06-13 18:13 UTC (permalink / raw)
  To: xen-devel, qemu-devel

On Sat, Jun 13, 2026 at 07:51:50PM +0200, Philippe Mathieu-Daudé wrote:
> We mandate a compiler supporting C99 since 2019-01-17 in
> commit 7be41675f7c ("configure: Force the C standard to gnu99"),
> thus supporting flexible array members. Remove what is now dead
> code.

> +    uint32_t optarr[0];

This is no flexible array member. "optarr[]" would be.

https://www.gnu.org/software/c-intro-and-ref/manual/html_node/Flexible-Array-Fields.html

Or are you talking about something different?

Bastian

-- 
The best diplomat I know is a fully activated phaser bank.
		-- Scotty


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] hw/xen/interface: Remove pre-C99 checks
  2026-06-13 18:13   ` Bastian Blank
@ 2026-06-14 16:40     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-06-14 16:40 UTC (permalink / raw)
  To: Bastian Blank, xen-devel, qemu-devel

On 13/6/26 20:13, Bastian Blank wrote:
> On Sat, Jun 13, 2026 at 07:51:50PM +0200, Philippe Mathieu-Daudé wrote:
>> We mandate a compiler supporting C99 since 2019-01-17 in
>> commit 7be41675f7c ("configure: Force the C standard to gnu99"),
>> thus supporting flexible array members. Remove what is now dead
>> code.
> 
>> +    uint32_t optarr[0];
> 
> This is no flexible array member. "optarr[]" would be.

Oops yes you are right... This is what we want here.

> 
> https://www.gnu.org/software/c-intro-and-ref/manual/html_node/Flexible-Array-Fields.html
> 
> Or are you talking about something different?
> 
> Bastian
> 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] qom/object: Remove pre-C11 check
  2026-06-13 17:51 ` [PATCH 2/2] qom/object: Remove pre-C11 check Philippe Mathieu-Daudé
@ 2026-06-15  5:05   ` Markus Armbruster
  0 siblings, 0 replies; 6+ messages in thread
From: Markus Armbruster @ 2026-06-15  5:05 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Edgar E. Iglesias, xen-devel, Daniel P. Berrangé,
	Anthony PERARD, Paolo Bonzini, Stefano Stabellini

Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> 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@oss.qualcomm.com>

> ---
>  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@redhat.com>

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().



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-06-15  5:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-13 17:51 [PATCH 0/2] misc: Remove pre-C99/C11 checks Philippe Mathieu-Daudé
2026-06-13 17:51 ` [PATCH 1/2] hw/xen/interface: Remove pre-C99 checks Philippe Mathieu-Daudé
2026-06-13 18:13   ` Bastian Blank
2026-06-14 16:40     ` Philippe Mathieu-Daudé
2026-06-13 17:51 ` [PATCH 2/2] qom/object: Remove pre-C11 check Philippe Mathieu-Daudé
2026-06-15  5:05   ` Markus Armbruster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.