<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">
<blockquote type="cite">
<p><span style="color: rgb(36, 39, 41); font-family: Arial,
"Helvetica Neue", Helvetica, sans-serif;
font-size: 15px; line-height: 19.5px; background-color:
rgb(255, 248, 220);">Either way like I said I'm not strongly
motivated to change it just caught my attention.</span></p>
</blockquote>
Well if you have time it would be really cool if you could a)
identify such cases before we run into issues with some gcc
versions again and b) leave the people who added the code and/or
are responsible for this part of the driver a note to fix it.<br>
<br>
We really had a headache with those things because of the coding
style in the atom headers and I would really like to avoid that in
the future.<br>
<br>
Thanks in advance,<br>
Christian.<br>
<br>
Am 18.08.2016 um 17:53 schrieb StDenis, Tom:<br>
</div>
<blockquote
cite="mid:DM5PR12MB11323E186DB7B5F065790EA9F7150@DM5PR12MB1132.namprd12.prod.outlook.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Thanks Alex and Christian,</p>
<p><br>
</p>
<p>Yup turns out [0] is not ISO C but [] is (from the googles)</p>
<p><br>
</p>
<p><strong style="margin: 0px; padding: 0px; border: 0px;
font-size: 15px; color: rgb(36, 39, 41); font-family: Arial,
"Helvetica Neue", Helvetica, sans-serif;
line-height: 19.5px; background-color: rgb(255, 248, 220);">C99
6.7.2.1, §16</strong><span style="color: rgb(36, 39, 41);
font-family: Arial, "Helvetica Neue", Helvetica,
sans-serif; font-size: 15px; line-height: 19.5px;
background-color: rgb(255, 248, 220);">: As a special case,
the last element of a structure with more than one named
member may have an incomplete array type; this is called a
flexible array member.</span><br>
</p>
<p><span style="color: rgb(36, 39, 41); font-family: Arial,
"Helvetica Neue", Helvetica, sans-serif;
font-size: 15px; line-height: 19.5px; background-color:
rgb(255, 248, 220);"><br>
</span></p>
<p><span style="color: rgb(36, 39, 41); font-family: Arial,
"Helvetica Neue", Helvetica, sans-serif;
font-size: 15px; line-height: 19.5px; background-color:
rgb(255, 248, 220);">Either way like I said I'm not strongly
motivated to change it just caught my attention.</span></p>
<p><span style="color: rgb(36, 39, 41); font-family: Arial,
"Helvetica Neue", Helvetica, sans-serif;
font-size: 15px; line-height: 19.5px; background-color:
rgb(255, 248, 220);"><br>
</span></p>
<p><font color="#242729" face="Arial, Helvetica Neue, Helvetica,
sans-serif"><span style="font-size: 15px; line-height:
19.5px; background-color: rgb(255, 248, 220);">Cheers,</span></font></p>
<p><font color="#242729" face="Arial, Helvetica Neue, Helvetica,
sans-serif"><span style="font-size: 15px; line-height:
19.5px; background-color: rgb(255, 248, 220);">Tom</span></font></p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt"
color="#000000" face="Calibri, sans-serif"><b>From:</b>
Deucher, Alexander<br>
<b>Sent:</b> Thursday, August 18, 2016 11:50<br>
<b>To:</b> StDenis, Tom; Alex Deucher<br>
<b>Cc:</b> Christian König; amd-gfx list<br>
<b>Subject:</b> RE: tidy'ing up cz_hwmgr.c</font>
<div> </div>
</div>
<div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;">
<span style="font-size:11.0pt;
font-family:"Calibri","sans-serif";
color:#1F497D">IIRC, zero sized arrays are not
technically allowed in C, although gcc allows them.
As I said, some versions of gcc worked, others
didn't. I'm not sure why. Also, my example was
slightly wrong. atombios.h uses arrays of size 1, not
0. So my example should look like:</span></p>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;">
<span style="font-size:11.0pt;
font-family:"Calibri","sans-serif";
color:#1F497D"> </span></p>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">struct table {</span></p>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> uint16_t size;</span></p>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> struct element elements[1];</span></p>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">};</span></p>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;">
<span style="font-size:11.0pt;
font-family:"Calibri","sans-serif";
color:#1F497D"> </span></p>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;">
<span style="font-size:11.0pt;
font-family:"Calibri","sans-serif";
color:#1F497D">atombios.h uses [1] since I don't think
[0] is portable. The same indexing issue applies to
[1].</span></p>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;">
<span style="font-size:11.0pt;
font-family:"Calibri","sans-serif";
color:#1F497D"> </span></p>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;">
<span style="font-size:11.0pt;
font-family:"Calibri","sans-serif";
color:#1F497D">Alex</span></p>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;">
<span style="font-size:11.0pt;
font-family:"Calibri","sans-serif";
color:#1F497D"> </span></p>
<div style="border:none; border-left:solid blue 1.5pt;
padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none; border-top:solid #B5C4DF
1.0pt; padding:3.0pt 0in 0in 0in">
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;">
<b><span style="font-size:10.0pt;
font-family:"Tahoma","sans-serif"">From:</span></b><span
style="font-size:10.0pt;
font-family:"Tahoma","sans-serif"">
amd-gfx
[<a class="moz-txt-link-freetext" href="mailto:amd-gfx-bounces@lists.freedesktop.org">mailto:amd-gfx-bounces@lists.freedesktop.org</a>]
<b>On Behalf Of </b>StDenis, Tom<br>
<b>Sent:</b> Thursday, August 18, 2016 11:40 AM<br>
<b>To:</b> Alex Deucher<br>
<b>Cc:</b> Christian König; amd-gfx list<br>
<b>Subject:</b> Re: tidy'ing up cz_hwmgr.c</span></p>
</div>
</div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;">
</p>
<div id="divtagdefaultwrapper">
<p style="background:white"><span
style="font-family:"Calibri","sans-serif";
color:black">It had to be something more
complicated because this demo program</span></p>
<p style="background:white"><span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">#include <stdio.h></span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">#include <stdlib.h></span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">struct one {</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">char *foo;</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">int bar[0];</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">};</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">struct two {</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">char *foo;</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">int bar[1];</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">};</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">int main(void)</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">{</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">struct one *a = calloc(1,
sizeof(struct one) + 4 * sizeof(int));</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">struct two *b = calloc(1,
sizeof(struct two) + 3 * sizeof(int));</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">int x;</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">printf("a == %p\n", a);</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">for (x = 0; x < 4; x++)</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">printf("&a.bar[%d] = %p\n", x,
&a->bar[x]);</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">printf("b == %p\n", b);</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">for (x = 0; x < 4; x++)</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">printf("&b.bar[%d] = %p\n", x,
&b->bar[x]);</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">return 0;</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">}</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
<p style="background:white"><span
style="font-family:"Calibri","sans-serif";
color:black">produces this output</span></p>
<p style="background:white"><span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">tom@fx8:~$ gcc test.c -o test</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">tom@fx8:~$ ./test</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">a == 0x1fd4010</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">&a.bar[0] = 0x1fd4018</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">&a.bar[1] = 0x1fd401c</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">&a.bar[2] = 0x1fd4020</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">&a.bar[3] = 0x1fd4024</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">b == 0x1fd4030</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">&b.bar[0] = 0x1fd4038</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">&b.bar[1] = 0x1fd403c</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">&b.bar[2] = 0x1fd4040</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span style="font-family:"Courier New";
color:black">&b.bar[3] = 0x1fd4044</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">Which is exactly what you'd expect.
I'm not strongly advocating we change the PP code
just noting it's not really clear that it's
correct from a first reading and in theory would
be better with [0]. </span></p>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
<p style="margin: 0in 0in 0.0001pt; font-size: 12pt;
font-family: "Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">Tom</span></p>
<div>
<div style="text-align: center; margin: 0in 0in
0.0001pt; font-size: 12pt; font-family:
"Times New Roman", serif; background:
white;" align="center">
<span
style="font-family:"Calibri","sans-serif";
color:black">
<hr width="98%" align="center" size="2">
</span></div>
<div id="divRplyFwdMsg">
<p style="margin: 0in 0in 0.0001pt; font-size:
12pt; font-family: "Times New Roman",
serif; background: white;">
<b><span style="font-size:11.0pt;
font-family:"Calibri","sans-serif";
color:black">From:</span></b><span
style="font-size:11.0pt;
font-family:"Calibri","sans-serif";
color:black"> Alex Deucher <<a
moz-do-not-send="true"
href="mailto:alexdeucher@gmail.com"
style="color: blue; text-decoration:
underline;">alexdeucher@gmail.com</a>><br>
<b>Sent:</b> Thursday, August 18, 2016 11:33<br>
<b>To:</b> StDenis, Tom<br>
<b>Cc:</b> Christian König; amd-gfx list<br>
<b>Subject:</b> Re: tidy'ing up cz_hwmgr.c</span><span
style="font-family:"Calibri","sans-serif";
color:black">
</span></p>
<div>
<p style="margin: 0in 0in 0.0001pt; font-size:
12pt; font-family: "Times New
Roman", serif; background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
</div>
<div>
<div>
<div>
<div>
<div>
<p style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family:
"Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">The problem we ran into
was when we had a struct like this:</span></p>
</div>
<p style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family: "Times
New Roman", serif; background:
white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">struct table {</span></p>
</div>
<p style="margin: 0in 0in 0.0001pt; font-size:
12pt; font-family: "Times New
Roman", serif; background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> uint16_t size;</span></p>
</div>
<p style="margin: 0in 0in 0.0001pt; font-size:
12pt; font-family: "Times New
Roman", serif; background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> struct element elements[0];</span></p>
<div>
<div>
<p style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family: "Times
New Roman", serif; background:
white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">};</span></p>
<div>
<div>
<div>
<p style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family:
"Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family:
"Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">and then we would try
and index the array:</span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family:
"Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">for (i = 0; i <
table->size; i++) {</span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family:
"Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> element =
&table->elements[i];</span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family:
"Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">}</span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family:
"Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">element ended up off
in the weeds. The only thing that
seems to make some versions of gcc
happy was pointer arithmetic.
E.g.,</span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family:
"Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family:
"Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">element = (struct
element *)((char
*)&table->elements[0] +
(sizeof(struct element) * i));</span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family:
"Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">Alex</span></p>
</div>
<div>
<p style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family:
"Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
<div>
<p style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family:
"Times New Roman",
serif; background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">On Thu, Aug 18,
2016 at 11:21 AM, StDenis, Tom
<<a moz-do-not-send="true"
href="mailto:Tom.StDenis@amd.com"
target="_blank" style="color:
blue; text-decoration:
underline;">Tom.StDenis@amd.com</a>>
wrote:</span></p>
<div>
<div>
<p style="background:white"><span
style="font-family:"Calibri","sans-serif";
color:black">Any modern GCC
should support [0] at the
tail of a struct. This came
up because when I was
reading the code I saw they
allocated 7 slots (plus the
size of the struct) but then
fill 8 slots. It's just
weird <img
id="_x0000_i1026" alt="��"
tabindex="0"
style="-webkit-user-select:
none;"
src="cid:part3.F176A269.01DFF465@vodafone.de"
width="19" border="0"
height="19"></span></p>
<p style="background:white"><span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
<p style="background:white"><span
style="font-family:"Calibri","sans-serif";
color:black">Using [0] in
the struct and allocating
for 8 entries makes more
sense and is clearer to
read.</span></p>
<p style="background:white"><span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
<p style="background:white"><span
style="font-family:"Calibri","sans-serif";
color:black">Tom</span></p>
<p style="margin: 0in 0in
0.0001pt; font-size: 12pt;
font-family: "Times New
Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
<div>
<div style="text-align:
center; margin: 0in 0in
0.0001pt; font-size: 12pt;
font-family: "Times New
Roman", serif;
background: white;"
align="center">
<span
style="font-family:"Calibri","sans-serif";
color:black">
<hr width="98%"
align="center" size="2">
</span></div>
<div>
<p style="margin: 0in 0in
0.0001pt; font-size: 12pt;
font-family: "Times
New Roman", serif;
background: white;">
<b><span
style="font-size:11.0pt;
font-family:"Calibri","sans-serif"; color:black">From:</span></b><span
style="font-size:11.0pt;
font-family:"Calibri","sans-serif"; color:black">
Christian König <<a
moz-do-not-send="true"
href="mailto:deathsimple@vodafone.de" target="_blank" style="color:
blue; text-decoration:
underline;">deathsimple@vodafone.de</a>><br>
<b>Sent:</b> Thursday,
August 18, 2016 11:17<br>
<b>To:</b> StDenis, Tom;
amd-gfx list<br>
<b>Subject:</b> Re:
tidy'ing up cz_hwmgr.c</span><span
style="font-family:"Calibri","sans-serif";
color:black">
</span></p>
<div>
<p style="margin: 0in 0in
0.0001pt; font-size:
12pt; font-family:
"Times New
Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
</div>
<div>
<div>
<div>
<div>
<blockquote
style="margin-top:5.0pt;
margin-bottom:5.0pt">
<div>
<p style="margin:
0in 0in
0.0001pt;
font-size: 12pt;
font-family:
"Times New
Roman",
serif;
background:
white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">Has
a [1] array at
the tail which
is then
kzalloc'ed
with N-1
entries.
Shouldn't that
just be a [0]
with N entries
allocated for
clarity?</span></p>
</div>
</blockquote>
<p style="margin: 0in
0in 0.0001pt;
font-size: 12pt;
font-family:
"Times New
Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">Actually
the starting
address of a
dynamic array
should be manually
calculated instead
of using [1] or
[0].<br>
<br>
We had tons of
problems with that
because some gcc
versions get this
wrong and the
atombios code used
this as well.<br>
<br>
Alex how did we
resolved such
issues?<br>
<br>
Regards,<br>
Christian.<br>
<br>
Am 18.08.2016 um
16:26 schrieb
StDenis, Tom:</span></p>
</div>
<blockquote
style="margin-top:5.0pt;
margin-bottom:5.0pt">
<div>
<p
style="background:white"><span
style="font-family:"Calibri","sans-serif";
color:black">Tidying
up cz_hwmgr.c I
noted a couple
of things but
first is </span></p>
<p
style="background:white"><span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
<div>
<p style="margin:
0in 0in
0.0001pt;
font-size: 12pt;
font-family:
"Times New
Roman",
serif;
background:
white;">
<span
style="font-family:"Courier
New";
color:black">static
bool
cz_dpm_check_smu_features(struct
pp_hwmgr
*hwmgr,</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin:
0in 0in
0.0001pt;
font-size: 12pt;
font-family:
"Times New
Roman",
serif;
background:
white;">
<span
style="font-family:"Courier
New";
color:black">unsigned
long
check_feature);</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
<div>
<p style="margin:
0in 0in
0.0001pt;
font-size: 12pt;
font-family:
"Times New
Roman",
serif;
background:
white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
<div>
<p style="margin:
0in 0in
0.0001pt;
font-size: 12pt;
font-family:
"Times New
Roman",
serif;
background:
white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">Which
will return
"true" if the
smu call fails
<b>or</b> the
feature is
set. </span></p>
</div>
<div>
<p style="margin:
0in 0in
0.0001pt;
font-size: 12pt;
font-family:
"Times New
Roman",
serif;
background:
white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
<div>
<p style="margin:
0in 0in
0.0001pt;
font-size: 12pt;
font-family:
"Times New
Roman",
serif;
background:
white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">The
structure </span></p>
</div>
<div>
<p style="margin:
0in 0in
0.0001pt;
font-size: 12pt;
font-family:
"Times New
Roman",
serif;
background:
white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
<div>
<div>
<p
style="margin:
0in 0in
0.0001pt;
font-size:
12pt;
font-family:
"Times
New
Roman",
serif;
background:
white;">
<span
style="font-family:"Courier
New";
color:black">struct
phm_clock_voltage_dependency_table;</span><span
style="font-family:"Calibri","sans-serif";
color:black"></span></p>
</div>
</div>
<div>
<p style="margin:
0in 0in
0.0001pt;
font-size: 12pt;
font-family:
"Times New
Roman",
serif;
background:
white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
<div>
<p style="margin:
0in 0in
0.0001pt;
font-size: 12pt;
font-family:
"Times New
Roman",
serif;
background:
white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">Has
a [1] array at
the tail which
is then
kzalloc'ed
with N-1
entries.
Shouldn't that
just be a [0]
with N entries
allocated for
clarity?</span></p>
</div>
<div>
<p style="margin:
0in 0in
0.0001pt;
font-size: 12pt;
font-family:
"Times New
Roman",
serif;
background:
white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
<div>
<p style="margin:
0in 0in
0.0001pt;
font-size: 12pt;
font-family:
"Times New
Roman",
serif;
background:
white;">
<span
style="font-family:"Calibri","sans-serif";
color:black">Tom</span></p>
</div>
<div>
<p style="margin:
0in 0in
0.0001pt;
font-size: 12pt;
font-family:
"Times New
Roman",
serif;
background:
white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
</div>
<p style="margin: 0in
0in 0.0001pt;
font-size: 12pt;
font-family:
"Times New
Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"><br>
<br>
</span></p>
<pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: "Courier New"; background: white;"><span style="color:black">_______________________________________________</span></pre>
<pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: "Courier New"; background: white;"><span style="color:black">amd-gfx mailing list</span></pre>
<pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: "Courier New"; background: white;"><span style="color:black"><a moz-do-not-send="true" href="mailto:amd-gfx@lists.freedesktop.org" target="_blank" style="color: blue; text-decoration: underline;">amd-gfx@lists.freedesktop.org</a></span></pre>
<pre style="margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: "Courier New"; background: white;"><span style="color:black"><a moz-do-not-send="true" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" target="_blank" style="color: blue; text-decoration: underline;">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></span></pre>
</blockquote>
<p
style="background:white"><span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
</div>
</div>
</div>
</div>
</div>
<p style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family:
"Times New Roman",
serif; background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"><br>
_______________________________________________<br>
amd-gfx mailing list<br>
<a moz-do-not-send="true"
href="mailto:amd-gfx@lists.freedesktop.org"
style="color: blue;
text-decoration: underline;">amd-gfx@lists.freedesktop.org</a><br>
<a moz-do-not-send="true"
href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx"
target="_blank" style="color:
blue; text-decoration:
underline;">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></span></p>
</div>
<p style="margin: 0in 0in 0.0001pt;
font-size: 12pt; font-family:
"Times New Roman", serif;
background: white;">
<span
style="font-family:"Calibri","sans-serif";
color:black"> </span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
amd-gfx mailing list
<a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
</pre>
</blockquote>
<p><br>
</p>
</body>
</html>