<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 7, 2018 at 3:58 PM, Chris Johns <span dir="ltr"><<a href="mailto:chrisj@rtems.org" target="_blank">chrisj@rtems.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-im gmail-HOEnZb">On 08/05/2018 03:56, Joel Sherrill wrote:<br>
> <br>
</span><span class="gmail-im gmail-HOEnZb">> I have attached a workaround.<br>
<br>
</span><span class="gmail-im gmail-HOEnZb">Looks like a solution to me.<br></span></blockquote><div><br></div><div>Good enough for now. All basename() calls should come from rld. </div><div><br></div><div>Eventually all dirname() calls should also.</div><div><br></div><div>Luckily no file uses both so we don't have to include libgen.h when</div><div>for dirname() and screw up basename().</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-im gmail-HOEnZb">
<br>
</span><span class="gmail-im gmail-HOEnZb">> It seems that libgen.h has this:<br>
> <br>
> ==============================<wbr>==========================<br>
> /* Return final component of PATH.<br>
> <br>
>    This is the weird XPG version of this function.  It sometimes will<br>
>    modify its argument.  Therefore we normally use the GNU version (in<br>
>    <string.h>) and only if this header is included make the XPG<br>
>    version available under the real name.  */<br>
> extern char *__xpg_basename (char *__path) __THROW;<br>
> #define basename        __xpg_basename<br>
> ==============================<wbr>==========================<br>
><br>
<br>
</span><span class="gmail-im gmail-HOEnZb">Oh yuck, who would ever work in standards. ;)<br>
<br>
Is this function allowed to be redefined as a macro?<br></span></blockquote><div><br></div><div><a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/basename.html">http://pubs.opengroup.org/onlinepubs/9699919799/functions/basename.html</a><br></div><div><a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/dirname.html">http://pubs.opengroup.org/onlinepubs/9699919799/functions/dirname.html</a><br></div><div><br></div><div>Neither seems to say anything about that. Both have language like this:</div><div><br></div><div>"

<span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">The<span> </span></span><i style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">dirname</i><span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">() function may modify the string pointed to by<span> </span></span><i style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">path</i><span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">, and may return a pointer to static storage that may then be overwritten by a subsequent call to<span> </span></span><i style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">dirname</i><span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">()."</span></div><div><span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div><span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">It really would be better to have our own implementations and not</span></div><div><span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">use the standard basename() and dirname(). The POSIX ones</span></div><div><span style="color:rgb(0,0,0);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13.3333px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">are not thread-safe.</span></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-im gmail-HOEnZb">
<br>
</span><span class="gmail-im gmail-HOEnZb">> Chris has used basename as a method name and even though that should<br>
> be perfectly acceptable, the macro above gets expanded, the name <br>
> gets changed (in some places) to rld::path::__xpg_basename()<br>
> <br>
>       r.lowSourceLine = rld::path::basename (location);<br>
> <br>
> IMO the fix is to add dirname to rld-files, use rld basename and dirname<br>
> exclusively, and avoid libgen.h at all costs.<br>
<br>
</span><span class="gmail-im gmail-HOEnZb">Wouldn't the world be so much simpler if there was only Linux? ;)<br></span></blockquote><div><br></div><div>The methods as defined by POSIX aren't thread-safe and can </div><div>modify the caller's string. Suck by design. :)</div><div><br></div><div>Having one mono-culture is easy but it doesn't make it right</div><div>even when conformant. :)</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-im gmail-HOEnZb">
<br>
</span><span class="gmail-im gmail-HOEnZb">> I didn't do that much work. I got lucky in a couple of files by removing the<br>
> include of libgen.h since it wasn't needed but I had to leave it in one place.<br>
> <br>
> $ grep dirname *.cc<br>
> GcovData.cc:    dirname( path );<br>
> <br>
> Hopefully this lets you all proceed with Chris' patches and my slight hack<br>
> in place.<br>
> <br>
> Ultimate solution is probably simple. We just need to hear from Chris.<br>
<br>
</span><div class="gmail-HOEnZb"><div class="gmail-h5">This is fine. I am slowing move covoar to use more and more of the rtemstoolkit.<br>
<br>
I will merge these changes into a v2 patch set.<br></div></div></blockquote><div><br></div><div>Are you adding dirname()? Or does that need a ticket?</div><div><br></div><div>--joel</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5">
<br>
Chris<br>
</div></div></blockquote></div><br></div></div>