<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 19, 2017 at 8:16 AM, Sebastian Huber <span dir="ltr"><<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
we have to make some trade-offs in the implementation with respect to the error checking. The operations get a pointer to the synchronization object, e.g.<br>
<br>
int sem_post(sem_t *sem);<br>
<br>
int pthread_mutex_lock(pthread_mut<wbr>ex_t *mutex);<br>
<br>
Do we want to check for NULL pointers?<br></blockquote><div><br></div><div>Is newlib consistently using the non-NULL declaration on the argument?</div><div><br></div><div>Newlib/Cygwin folks have been pretty insistent that they do not want to</div><div>check for NULL on the shared methods.</div><div><br></div><div>Personally I hate to delete NULL argument pointer checks. Would a </div><div>long-term compromise be to move them to argument checking macros</div><div>that are enabled with --enable-rtems-debug?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Do we want to check for other obviously invalid pointer values, e.g. SEM_FAILED?<br></blockquote><div><br></div><div>IMO Yes</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">
<br>
Do we want to check if the object has been initialized?</blockquote><div><br></div><div>Yes. We want to have predictable behavior.</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"> </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
glibc uses no checks at all.<br></blockquote><div><br></div><div>Performance over correctness? That doesn't seem like a good trade.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
FreeBSD checks that the object has been initialized. For this purpose it embeds a magic value field in the object structure. The drawback is that if we also do this, the objects are not zero-initialized and thus cannot reside in the BSS section.<br></blockquote><div><br></div><div>This is an impossible trade. Some systems have big Flash and small RAM.</div><div>Others are the opposite.</div><div><br></div><div>I would rather follow the FreeBSD model and know the object is initialized.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Destruction of synchronization objects in use is undefined behaviour according to POSIX. Do we want to flush waiting threads during destruction? This is a complex operation.<br></blockquote><div><br></div><div>We have over 20 years of defined behavior in this case. I think</div><div>we flush and return the same error we always did. Otherwise,</div><div>we get a deadlock.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
What you think?<div class="HOEnZb"><div class="h5"><br>
<br>
-- <br>
Sebastian Huber, embedded brains GmbH<br>
<br>
Address : <a href="https://maps.google.com/?q=Dornierstr.+4&entry=gmail&source=g">Dornierstr. 4</a>, D-82178 Puchheim, Germany<br>
Phone   : <a href="tel:%2B49%2089%20189%2047%2041-16" value="+4989189474116" target="_blank">+49 89 189 47 41-16</a><br>
Fax     : <a href="tel:%2B49%2089%20189%2047%2041-09" value="+4989189474109" target="_blank">+49 89 189 47 41-09</a><br>
E-Mail  : <a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brain<wbr>s.de</a><br>
PGP     : Public key available on request.<br>
<br>
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.<br>
<br>
______________________________<wbr>_________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman<wbr>/listinfo/devel</a></div></div></blockquote></div><br></div></div>