mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-21 21:12:47 +00:00
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.
This commit is contained in:
parent
b5f271555e
commit
2532bd2f81
@ -78,7 +78,9 @@
|
||||
ret; /* return value */ \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_inc__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_inc__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(ptr)) != 1 && sizeof(*(ptr)) != 2 && \
|
||||
sizeof(*(ptr)) != 4 && (sizeof(long) != 8 || sizeof(*(ptr)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_inc__(__FILE__,__LINE__); \
|
||||
0; \
|
||||
}) \
|
||||
)
|
||||
@ -121,7 +123,9 @@
|
||||
ret; /* return value */ \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_dec__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_dec__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(ptr)) != 1 && sizeof(*(ptr)) != 2 && \
|
||||
sizeof(*(ptr)) != 4 && (sizeof(long) != 8 || sizeof(*(ptr)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_dec__(__FILE__,__LINE__); \
|
||||
0; \
|
||||
}) \
|
||||
)
|
||||
@ -150,7 +154,9 @@
|
||||
: "cc"); \
|
||||
} else { \
|
||||
void __unsupported_argument_size_for_pl_inc_noret__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_inc_noret__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(ptr)) != 1 && sizeof(*(ptr)) != 2 && \
|
||||
sizeof(*(ptr)) != 4 && (sizeof(long) != 8 || sizeof(*(ptr)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_inc_noret__(__FILE__,__LINE__); \
|
||||
} \
|
||||
})
|
||||
|
||||
@ -178,7 +184,9 @@
|
||||
: "cc"); \
|
||||
} else { \
|
||||
void __unsupported_argument_size_for_pl_dec_noret__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_dec_noret__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(ptr)) != 1 && sizeof(*(ptr)) != 2 && \
|
||||
sizeof(*(ptr)) != 4 && (sizeof(long) != 8 || sizeof(*(ptr)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_dec_noret__(__FILE__,__LINE__); \
|
||||
} \
|
||||
})
|
||||
|
||||
@ -208,7 +216,9 @@
|
||||
: "cc"); \
|
||||
} else { \
|
||||
void __unsupported_argument_size_for_pl_add__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_add__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(ptr)) != 1 && sizeof(*(ptr)) != 2 && \
|
||||
sizeof(*(ptr)) != 4 && (sizeof(long) != 8 || sizeof(*(ptr)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_add__(__FILE__,__LINE__); \
|
||||
} \
|
||||
})
|
||||
|
||||
@ -238,7 +248,9 @@
|
||||
: "cc"); \
|
||||
} else { \
|
||||
void __unsupported_argument_size_for_pl_sub__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_sub__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(ptr)) != 1 && sizeof(*(ptr)) != 2 && \
|
||||
sizeof(*(ptr)) != 4 && (sizeof(long) != 8 || sizeof(*(ptr)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_sub__(__FILE__,__LINE__); \
|
||||
} \
|
||||
})
|
||||
|
||||
@ -268,7 +280,9 @@
|
||||
: "cc"); \
|
||||
} else { \
|
||||
void __unsupported_argument_size_for_pl_and__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_and__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(ptr)) != 1 && sizeof(*(ptr)) != 2 && \
|
||||
sizeof(*(ptr)) != 4 && (sizeof(long) != 8 || sizeof(*(ptr)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_and__(__FILE__,__LINE__); \
|
||||
} \
|
||||
})
|
||||
|
||||
@ -298,7 +312,9 @@
|
||||
: "cc"); \
|
||||
} else { \
|
||||
void __unsupported_argument_size_for_pl_or__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_or__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(ptr)) != 1 && sizeof(*(ptr)) != 2 && \
|
||||
sizeof(*(ptr)) != 4 && (sizeof(long) != 8 || sizeof(*(ptr)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_or__(__FILE__,__LINE__); \
|
||||
} \
|
||||
})
|
||||
|
||||
@ -328,7 +344,9 @@
|
||||
: "cc"); \
|
||||
} else { \
|
||||
void __unsupported_argument_size_for_pl_xor__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_xor__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(ptr)) != 1 && sizeof(*(ptr)) != 2 && \
|
||||
sizeof(*(ptr)) != 4 && (sizeof(long) != 8 || sizeof(*(ptr)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_xor__(__FILE__,__LINE__); \
|
||||
} \
|
||||
})
|
||||
|
||||
@ -363,7 +381,9 @@
|
||||
ret; /* return value */ \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_bts__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_bts__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(ptr)) != 1 && sizeof(*(ptr)) != 2 && \
|
||||
sizeof(*(ptr)) != 4 && (sizeof(long) != 8 || sizeof(*(ptr)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_bts__(__FILE__,__LINE__); \
|
||||
0; \
|
||||
}) \
|
||||
)
|
||||
@ -407,7 +427,9 @@
|
||||
ret; /* return value */ \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_xadd__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_xadd__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(ptr)) != 1 && sizeof(*(ptr)) != 2 && \
|
||||
sizeof(*(ptr)) != 4 && (sizeof(long) != 8 || sizeof(*(ptr)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_xadd__(__FILE__,__LINE__); \
|
||||
0; \
|
||||
}) \
|
||||
)
|
||||
@ -446,7 +468,9 @@
|
||||
ret; /* return value */ \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_xchg__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_xchg__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(ptr)) != 1 && sizeof(*(ptr)) != 2 && \
|
||||
sizeof(*(ptr)) != 4 && (sizeof(long) != 8 || sizeof(*(ptr)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_xchg__(__FILE__,__LINE__); \
|
||||
0; \
|
||||
}) \
|
||||
)
|
||||
@ -490,7 +514,9 @@
|
||||
ret; /* return value */ \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_cmpxchg__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_cmpxchg__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(ptr)) != 1 && sizeof(*(ptr)) != 2 && \
|
||||
sizeof(*(ptr)) != 4 && (sizeof(long) != 8 || sizeof(*(ptr)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_cmpxchg__(__FILE__,__LINE__); \
|
||||
0; \
|
||||
}) \
|
||||
)
|
||||
|
@ -69,7 +69,8 @@
|
||||
!__pl_r; /* return value */ \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_try_r__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_try_r__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(lock)) != 4 && (sizeof(long) != 8 || sizeof(*(lock)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_try_r__(__FILE__,__LINE__); \
|
||||
0; \
|
||||
}) \
|
||||
)
|
||||
@ -89,7 +90,8 @@
|
||||
pl_sub(lock, PLOCK32_RL_1); \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_drop_r__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_drop_r__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(lock)) != 4 && (sizeof(long) != 8 || sizeof(*(lock)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_drop_r__(__FILE__,__LINE__); \
|
||||
}) \
|
||||
)
|
||||
|
||||
@ -117,7 +119,8 @@
|
||||
!__pl_r; /* return value */ \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_try_s__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_try_s__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(lock)) != 4 && (sizeof(long) != 8 || sizeof(*(lock)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_try_s__(__FILE__,__LINE__); \
|
||||
0; \
|
||||
}) \
|
||||
)
|
||||
@ -137,7 +140,8 @@
|
||||
pl_sub(lock, PLOCK32_SL_1 + PLOCK32_RL_1); \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_drop_s__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_drop_s__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(lock)) != 4 && (sizeof(long) != 8 || sizeof(*(lock)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_drop_s__(__FILE__,__LINE__); \
|
||||
}) \
|
||||
)
|
||||
|
||||
@ -149,7 +153,8 @@
|
||||
pl_sub(lock, PLOCK32_SL_1); \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_stor__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_stor__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(lock)) != 4 && (sizeof(long) != 8 || sizeof(*(lock)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_stor__(__FILE__,__LINE__); \
|
||||
}) \
|
||||
)
|
||||
|
||||
@ -167,7 +172,8 @@
|
||||
__pl_r = pl_deref_int(lock); \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_stow__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_stow__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(lock)) != 4 && (sizeof(long) != 8 || sizeof(*(lock)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_stow__(__FILE__,__LINE__); \
|
||||
}) \
|
||||
)
|
||||
|
||||
@ -179,7 +185,8 @@
|
||||
pl_sub(lock, PLOCK32_WL_1); \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_wtos__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_wtos__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(lock)) != 4 && (sizeof(long) != 8 || sizeof(*(lock)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_wtos__(__FILE__,__LINE__); \
|
||||
}) \
|
||||
)
|
||||
|
||||
@ -191,7 +198,8 @@
|
||||
pl_sub(lock, PLOCK32_WL_1 | PLOCK32_SL_1); \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_wtor__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_wtor__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(lock)) != 4 && (sizeof(long) != 8 || sizeof(*(lock)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_wtor__(__FILE__,__LINE__); \
|
||||
}) \
|
||||
)
|
||||
|
||||
@ -249,7 +257,8 @@
|
||||
!__pl_r; /* return value */ \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_try_w__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_try_w__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(lock)) != 4 && (sizeof(long) != 8 || sizeof(*(lock)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_try_w__(__FILE__,__LINE__); \
|
||||
0; \
|
||||
}) \
|
||||
)
|
||||
@ -269,7 +278,8 @@
|
||||
pl_sub(lock, PLOCK32_WL_1 | PLOCK32_SL_1 | PLOCK32_RL_1); \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_drop_w__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_drop_w__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(lock)) != 4 && (sizeof(long) != 8 || sizeof(*(lock)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_drop_w__(__FILE__,__LINE__); \
|
||||
}) \
|
||||
)
|
||||
|
||||
@ -301,7 +311,8 @@
|
||||
!__pl_r; /* return value */ \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_try_rtos__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_try_rtos__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(lock)) != 4 && (sizeof(long) != 8 || sizeof(*(lock)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_try_rtos__(__FILE__,__LINE__); \
|
||||
0; \
|
||||
}) \
|
||||
)
|
||||
@ -352,7 +363,8 @@
|
||||
!__pl_r; /* return value */ \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_try_a__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_try_a__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(lock)) != 4 && (sizeof(long) != 8 || sizeof(*(lock)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_try_a__(__FILE__,__LINE__); \
|
||||
0; \
|
||||
}) \
|
||||
)
|
||||
@ -372,7 +384,8 @@
|
||||
pl_sub(lock, PLOCK32_WL_1); \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_drop_a__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_drop_a__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(lock)) != 4 && (sizeof(long) != 8 || sizeof(*(lock)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_drop_a__(__FILE__,__LINE__); \
|
||||
}) \
|
||||
)
|
||||
|
||||
@ -421,7 +434,8 @@
|
||||
!__pl_r; /* return value */ \
|
||||
}) : ({ \
|
||||
void __unsupported_argument_size_for_pl_try_rtoa__(char *,int); \
|
||||
__unsupported_argument_size_for_pl_try_rtoa__(__FILE__,__LINE__); \
|
||||
if (sizeof(*(lock)) != 4 && (sizeof(long) != 8 || sizeof(*(lock)) != 8)) \
|
||||
__unsupported_argument_size_for_pl_try_rtoa__(__FILE__,__LINE__); \
|
||||
0; \
|
||||
}) \
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user