Re: [PATCH] conf: force 8 byte alignment for virObjectEvent

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/3/20 5:22 AM, Daniel P. Berrangé wrote:

Forcing 8-byte alignment on virObjectEventPtr removes the
alignment increase during casts to subclasses.

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---

Technically a build-breaker, but since we don't have any existing
usage of __attribute__((aligned)), I wanted to get a second opinion
on this approach.

One alternative approach would be to switch one of the current "int"
fields in virObjectEvent to "long long".


-struct _virObjectEvent {
+struct  __attribute__((aligned(4))) _virObjectEvent {
      virObject parent;
      int eventID;
      virObjectMeta meta;

As in this, although it makes the struct larger on 32-bit platforms (which may in turn affect cache usage):

struct _virObjectEvent {
    virObject parent;
    long long eventID;
...

Another possibility: use the extension of unnamed unions (but if we're going to rely on gcc extensions, __attribute__ is nicer than unnamed unions):

struct _virObjectEvent {
    union {
        virObject parent;
        long long alignment_;
    };
    int eventID;
...

We already limit ourselves to gcc and clang because of __attribute__((cleanup)), so I don't see any problem with your approach.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux