]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-varlink: drop pointless bitfield
authorZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Wed, 29 Apr 2026 08:54:43 +0000 (10:54 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Wed, 29 Apr 2026 09:23:01 +0000 (11:23 +0200)
As is often the case, in this case because of alignment, we are actually
not saving any space. With the bitfield we are using one bit of the 8 bytes
allocated, and without the bitfield we are using 8 bits of that.

But we're paying a price in generated code, at every access site to the
field:

$ diff <(objdump -S build/libsystemd.so.old) <(objdump -S build/libsystemd.so.new)
...
       v->protocol_upgrade = false;
-   fa2d2: 48 8b 45 a8           mov    -0x58(%rbp),%rax
-   fa2d6: 0f b6 90 90 01 00 00  movzbl 0x190(%rax),%edx
-   fa2dd: 83 e2 fe              and    $0xfffffffe,%edx
-   fa2e0: 88 90 90 01 00 00     mov    %dl,0x190(%rax)
+   fa2a9: 48 8b 45 a8           mov    -0x58(%rbp),%rax
+   fa2ad: c6 80 90 01 00 00 00  movb   $0x0,0x190(%rax)

src/libsystemd/sd-varlink/varlink-internal.h

index 8087c2c43246498276a36aa332ca91178818cf1f..ff359852f488f56f70cdbba87cfeb53c45f68a4f 100644 (file)
@@ -107,7 +107,7 @@ typedef struct sd_varlink {
          * ensure the caller's contract is honored. The transport-layer "stop reading at the
          * next message boundary" behavior is governed independently by the JsonStream's
          * bounded_reads flag. */
-        bool protocol_upgrade:1;
+        bool protocol_upgrade;
 
         void *userdata;