]> git.kaiwu.me - haproxy.git/commit
BUILD: threads/plock: fix a build issue on Clang without optimization
authorWilly Tarreau <w@1wt.eu>
Mon, 20 Nov 2017 18:25:18 +0000 (19:25 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 20 Nov 2017 20:06:35 +0000 (21:06 +0100)
commit2532bd2f8175d61a4303fef6f1aa7d3a24b746fc
tree7ebc75923a93070421e20dc1a0cb62e2b899efcb
parentb5f271555e9b86e60d60a6986a23c82adbde05fb
BUILD: threads/plock: fix a build issue on Clang without optimization

[ plock commit 4c53fd3a0b2b1892817cebd0db012a52f4087850 ]

Pieter Baauw reported a build issue affecting haproxy after plock was
included. It happens that expressions of the form :

     if ((const) ? (expr1) : (expr2))
       do_something()

always produce code for both expr1 and expr2 on Clang when building
without optimization. The resulting asm code is even funny, basically
doing :

     mov reg, 1
     cmp reg, 1
     ...

This causes our sizeof() tests to fail to build because we purposely
dereference a fake function that reports the location and nature of the
inconsistency, but this fake function appears in the object code despite
all conditions being there to avoid it.

However the compiler is still smart enough to optimize away code doing

    if (const)
       do_something()

So we simply repeat the condition before do_something(), and the dummy
function is not referenced anymore unless really required.
include/import/atomic-ops.h
include/import/plock.h