<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div>Set LGTM. I don't feed the need for _Generic() either.<br></div><div><br></div><div>On Fri, Aug 7, 2020, at 19:55, Marvin Scholz wrote:<br></div><blockquote type="cite" id="qt" style=""><div style="font-family:sans-serif;"><div style="white-space:normal;"><p dir="auto">Trying to use _Generic to ensure the expression has the expected type.<br></p><p dir="auto"></p><div>How would you do the static assertion, it would lead to<br></div><div> the exactly same issue as I am hitting here, no?<br></div><p></p><p dir="auto">On 7 Aug 2020, at 19:52, Rémi Denis-Courmont wrote:<br></p></div><blockquote style="border-left-color:rgb(119, 119, 119);border-left-style:solid;border-left-width:2px;color:rgb(119, 119, 119);margin-top:0px;margin-right:0px;margin-bottom:5px;margin-left:0px;padding-left:5px;"><div id="qt-D9C5BB4A-4402-4673-9FD3-85ECB33CC4CB"><div>I don't know what you're trying to do there, and that does not look like a static assertion to me.<br></div><div><br></div><div class="qt-gmail_quote"><div>Le 7 août 2020 16:37:47 GMT+03:00, Marvin Scholz <epirat07@gmail.com> a écrit :<br></div><blockquote class="qt-gmail_quote" style="margin-top:0pt;margin-right:0pt;margin-bottom:0pt;margin-left:0.8ex;border-left-color:rgb(204, 204, 204);border-left-style:solid;border-left-width:1px;padding-left:1ex;"><pre class="qt-k9mail"><div><br></div><div><br></div><div>On 7 Aug 2020, at 14:42, Rémi Denis-Courmont wrote:<br></div><div><br></div><blockquote class="qt-gmail_quote" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-color:rgb(114, 159, 207);border-left-style:solid;border-left-width:1px;padding-left:1ex;"><div> Hi,<br></div><div><br></div><div> You can use _Generic() if you want to match types. No need for <br></div><div> compiler-dependent ifdef'ery.<br></div><div><br></div><div> Might be overkill here though.<br></div></blockquote><div><br></div><div>I thought about that too but the following does not work:<br></div><div><br></div><div># define VLC_ALIGNOF(t, expr) \<br></div><div> (_Generic(expr, t: _Alignof(t)))<br></div><div><br></div><div>atomic_uint *addr;<br></div><div>VLC_ALIGNOFT(atomic_uint, *addr);<br></div><div><br></div><div>This fails to compile with:<br></div><div>error: '_Generic' selector of type 'unsigned int' is not compatible with <br></div><div>any association<br></div><div><br></div><div>><br></div><blockquote class="qt-gmail_quote" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-color:rgb(114, 159, 207);border-left-style:solid;border-left-width:1px;padding-left:1ex;"><div>Le 7 août 2020 07:55:35 GMT+03:00, Steve Lhomme <robux4@ycbcr.xyz> a <br></div><div>écrit :<br></div><blockquote class="qt-gmail_quote" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-color:rgb(173, 127, 168);border-left-style:solid;border-left-width:1px;padding-left:1ex;"><div> OK for both. Although it would be nice to have a safety check in case<br></div><div> the underlying type changes and the alignof is not valid anymore.<br></div><div><br></div><div> May a static_assert when compiling with GCC, like<br></div><div> #if defined(__GNUC__) && !defined(__llvm__) &&<br></div><div> !defined(__INTEL_COMPILER)<br></div><div> static_assert(alignof(*addr) == alignof(atomic_uint), "type <br></div><div> mismatch");<br></div><div> #endif<br></div><div><br></div><div><br></div><div> On 2020-08-07 6:44, Marvin Scholz wrote:<br></div><blockquote class="qt-gmail_quote" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-color:rgb(138, 226, 52);border-left-style:solid;border-left-width:1px;padding-left:1ex;"><div> Using alignof not on a type but an expression is a GNU extension and<br></div><div> causes the following warning:<br></div><div><br></div><div> warning: '_Alignof' applied to an expression is a GNU extension<hr> src/posix/wait.c | 2 +-<br></div><div> 1 file changed, 1 insertion(+), 1 deletion(-)<br></div><div><br></div><div> diff --git a/src/posix/wait.c b/src/posix/wait.c<br></div><div> index 584cc493b1a..3fa6890193a 100644<br></div><div> --- a/src/posix/wait.c<br></div><div> +++ b/src/posix/wait.c<br></div><div> @@ -52,7 +52,7 @@ static struct wait_bucket<br></div><div> static struct wait_bucket *wait_bucket_get(atomic_uint *addr)<br></div><div> {<br></div><div> uintptr_t u = (uintptr_t)addr;<br></div><div> - size_t idx = (u / alignof (*addr)) % ARRAY_SIZE(wait_buckets);<br></div><div> + size_t idx = (u / alignof (atomic_uint)) %<br></div></blockquote><div>ARRAY_SIZE(wait_buckets);<br></div><blockquote class="qt-gmail_quote" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-color:rgb(138, 226, 52);border-left-style:solid;border-left-width:1px;padding-left:1ex;"><div> return &wait_buckets[idx];<br></div><div> }<br></div><div> -- <br></div><div> 2.24.3 (Apple Git-128)<hr> vlc-devel mailing list<br></div><div> To unsubscribe or modify your subscription options:<br></div><div> <a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div></blockquote><div><hr>vlc-devel mailing list<br></div><div>To unsubscribe or modify your subscription options:<br></div><div><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div></blockquote><div>-- <br></div><div>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez <br></div><div>excuser ma brièveté.<br></div></blockquote><div><br></div><div><br></div><blockquote class="qt-gmail_quote" style="margin-top:0pt;margin-right:0pt;margin-bottom:1ex;margin-left:0.8ex;border-left-color:rgb(114, 159, 207);border-left-style:solid;border-left-width:1px;padding-left:1ex;"><div><hr>vlc-devel mailing list<br></div><div>To unsubscribe or modify your subscription options:<br></div><div><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div></blockquote><div><hr>vlc-devel mailing list<br></div><div>To unsubscribe or modify your subscription options:<br></div><div><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div></pre></blockquote></div><div><br></div><div>-- <br></div><div>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.<br></div></div></blockquote><div style="white-space:normal;"><blockquote style="border-left-color:rgb(119, 119, 119);border-left-style:solid;border-left-width:2px;color:rgb(119, 119, 119);margin-top:0px;margin-right:0px;margin-bottom:5px;margin-left:0px;padding-left:5px;"><br></blockquote><blockquote style="border-left-color:rgb(119, 119, 119);border-left-style:solid;border-left-width:2px;color:rgb(119, 119, 119);margin-top:0px;margin-right:0px;margin-bottom:5px;margin-left:0px;padding-left:5px;"><p dir="auto"></p><div>_______________________________________________<br></div><div> vlc-devel mailing list<br></div><div> To unsubscribe or modify your subscription options:<br></div><div> <a href="https://mailman.videolan.org/listinfo/vlc-devel" style="color:rgb(119, 119, 119);">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div><p></p></blockquote></div></div><div>_______________________________________________<br></div><div>vlc-devel mailing list<br></div><div>To unsubscribe or modify your subscription options:<br></div><div><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></div></blockquote><div><br></div></body></html>