sd-varlink: drop pointless bitfield

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)
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-04-29 11:23:01 +02:00
parent 2e591bb1e7
commit 01bf2b9f52
+1 -1
View 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;