<div dir="ltr">Hi,<div><br></div><div>Any chance this can be reviewed? This would add support for 4 tests on Android.</div><div><br></div><div>Thanks</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 21, 2018 at 11:48 AM, Erick Reyes <span dir="ltr"><<a href="mailto:erickreyes@google.com" target="_blank">erickreyes@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Android does not implement pthread_cancel. The function is replaced<br></div><div>by a no-op in a compatibility header. In most cases, the only side</div><div>effect is that threads cannot be interrupted and have to exit normally.</div><div>However, floating point tests are calling pthread_cancel and waiting for</div><div>a thread doing pthread_sigwait to be finished (Which will never happen).</div><div><br></div><div>This patch implements the same logic using pthread_kill with SIGUSR2</div><div>instead, allowing the tests to run under Android.</div><div><br></div><div>Signed-off-by: Erick Reyes <<a href="mailto:erickreyes@google.com" target="_blank">erickreyes@google.com</a>><br></div><div>---</div><div> testcases/misc/math/float/<wbr>main.c | 20 +++++++++++++++++++-</div><div> 1 file changed, 19 insertions(+), 1 deletion(-)</div><div><br></div><div>diff --git a/testcases/misc/math/float/<wbr>main.c b/testcases/misc/math/float/<wbr>main.c</div><div>index d71ca18e6..64d1475e4 100644</div><div>--- a/testcases/misc/math/float/<wbr>main.c</div><div>+++ b/testcases/misc/math/float/<wbr>main.c</div><div>@@ -115,6 +115,18 @@ int main(int argc, char *argv[])</div><div> <span style="white-space:pre-wrap">  </span>/*int time=1; */</div><div> <span style="white-space:pre-wrap">       </span>int i;</div><div> </div><div>+<span style="white-space:pre-wrap"> </span>sigset_t signals_set;</div><div>+</div><div>+<span style="white-space:pre-wrap">   </span>/*</div><div>+<span style="white-space:pre-wrap">      </span> * Use SIGUSR2 to terminate our signal handler</div><div>+<span style="white-space:pre-wrap">  </span> */</div><div>+<span style="white-space:pre-wrap">     </span>sigemptyset(&signals_set);</div><div>+<span style="white-space:pre-wrap">  </span>sigaddset(&signals_set, SIGUSR2);</div><div>+</div><div>+<span style="white-space:pre-wrap">   </span>retval = pthread_sigmask(SIG_BLOCK, &signals_set, NULL);</div><div>+<span style="white-space:pre-wrap">    </span>if (retval != 0)</div><div>+<span style="white-space:pre-wrap">                </span>sys_error("main : pthread_sigmask FAILED", __LINE__);</div><div>+</div><div> <span style="white-space:pre-wrap">        </span>/* Generate test ID from invocation name */</div><div> <span style="white-space:pre-wrap">    </span>if ((TCID = strrchr(argv[0], '/')) != NULL)</div><div> <span style="white-space:pre-wrap">            </span>TCID++;</div><div>@@ -299,7 +311,7 @@ finished:</div><div> <span style="white-space:pre-wrap">            </span>SAFE_FREE(pcom);</div><div> </div><div> <span style="white-space:pre-wrap">      </span>}</div><div>-<span style="white-space:pre-wrap">       </span>pthread_cancel(sig_hand);</div><div>+<span style="white-space:pre-wrap">       </span>pthread_kill(sig_hand, SIGUSR2);</div><div> <span style="white-space:pre-wrap">       </span>pthread_join(sig_hand, NULL);</div><div> <span style="white-space:pre-wrap">  </span>SAFE_FREE(tabcom);</div><div> <span style="white-space:pre-wrap">     </span>SAFE_FREE(threads);</div><div>@@ -338,6 +350,7 @@ static void *handle_signals(void *arg)</div><div> <span style="white-space:pre-wrap">   </span>sigaddset(&signals_set, SIGQUIT);</div><div> <span style="white-space:pre-wrap">  </span>sigaddset(&signals_set, SIGTERM);</div><div> <span style="white-space:pre-wrap">  </span>sigaddset(&signals_set, SIGUSR1);</div><div>+<span style="white-space:pre-wrap">   </span>sigaddset(&signals_set, SIGUSR2);</div><div> <span style="white-space:pre-wrap">  </span>sigaddset(&signals_set, SIGALRM);</div><div> <span style="white-space:pre-wrap">  </span>while (1) {</div><div> <span style="white-space:pre-wrap">            </span>if (debug)</div><div>@@ -348,6 +361,11 @@ static void *handle_signals(void *arg)</div><div> <span style="white-space:pre-wrap">                   </span>tst_resm(TINFO, "Signal handler caught signal %d", sig);</div><div> </div><div> <span style="white-space:pre-wrap">            </span>switch (sig) {</div><div>+<span style="white-space:pre-wrap">          </span>case SIGUSR2:</div><div>+<span style="white-space:pre-wrap">           </span>    if (debug)</div><div>+<span style="white-space:pre-wrap">                        </span>tst_resm(TINFO, "Signal handler received termination request, exiting");</div><div>+<span style="white-space:pre-wrap">              </span>    pthread_exit(NULL);</div><div>+<span style="white-space:pre-wrap">               </span>    break;</div><div> <span style="white-space:pre-wrap">           </span>case SIGALRM:</div><div> <span style="white-space:pre-wrap">          </span>case SIGUSR1:</div><div> <span style="white-space:pre-wrap">          </span>case SIGINT:</div><span class="HOEnZb"><font color="#888888"><div>-- </div><div>2.16.1.291.g4437f3f132-goog</div><div><br></div></font></span></div>
</blockquote></div><br></div>