<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">erickreyes@google.com</a>><br></div><div>---</div><div> testcases/misc/math/float/main.c | 20 +++++++++++++++++++-</div><div> 1 file changed, 19 insertions(+), 1 deletion(-)</div><div><br></div><div>diff --git a/testcases/misc/math/float/main.c b/testcases/misc/math/float/main.c</div><div>index d71ca18e6..64d1475e4 100644</div><div>--- a/testcases/misc/math/float/main.c</div><div>+++ b/testcases/misc/math/float/main.c</div><div>@@ -115,6 +115,18 @@ int main(int argc, char *argv[])</div><div> <span style="white-space:pre">   </span>/*int time=1; */</div><div> <span style="white-space:pre">    </span>int i;</div><div> </div><div>+<span style="white-space:pre">      </span>sigset_t signals_set;</div><div>+</div><div>+<span style="white-space:pre">        </span>/*</div><div>+<span style="white-space:pre">   </span> * Use SIGUSR2 to terminate our signal handler</div><div>+<span style="white-space:pre">       </span> */</div><div>+<span style="white-space:pre">  </span>sigemptyset(&signals_set);</div><div>+<span style="white-space:pre">       </span>sigaddset(&signals_set, SIGUSR2);</div><div>+</div><div>+<span style="white-space:pre">        </span>retval = pthread_sigmask(SIG_BLOCK, &signals_set, NULL);</div><div>+<span style="white-space:pre"> </span>if (retval != 0)</div><div>+<span style="white-space:pre">             </span>sys_error("main : pthread_sigmask FAILED", __LINE__);</div><div>+</div><div> <span style="white-space:pre">     </span>/* Generate test ID from invocation name */</div><div> <span style="white-space:pre"> </span>if ((TCID = strrchr(argv[0], '/')) != NULL)</div><div> <span style="white-space:pre">         </span>TCID++;</div><div>@@ -299,7 +311,7 @@ finished:</div><div> <span style="white-space:pre">         </span>SAFE_FREE(pcom);</div><div> </div><div> <span style="white-space:pre">   </span>}</div><div>-<span style="white-space:pre">    </span>pthread_cancel(sig_hand);</div><div>+<span style="white-space:pre">    </span>pthread_kill(sig_hand, SIGUSR2);</div><div> <span style="white-space:pre">    </span>pthread_join(sig_hand, NULL);</div><div> <span style="white-space:pre">       </span>SAFE_FREE(tabcom);</div><div> <span style="white-space:pre">  </span>SAFE_FREE(threads);</div><div>@@ -338,6 +350,7 @@ static void *handle_signals(void *arg)</div><div> <span style="white-space:pre">        </span>sigaddset(&signals_set, SIGQUIT);</div><div> <span style="white-space:pre">       </span>sigaddset(&signals_set, SIGTERM);</div><div> <span style="white-space:pre">       </span>sigaddset(&signals_set, SIGUSR1);</div><div>+<span style="white-space:pre">        </span>sigaddset(&signals_set, SIGUSR2);</div><div> <span style="white-space:pre">       </span>sigaddset(&signals_set, SIGALRM);</div><div> <span style="white-space:pre">       </span>while (1) {</div><div> <span style="white-space:pre">         </span>if (debug)</div><div>@@ -348,6 +361,11 @@ static void *handle_signals(void *arg)</div><div> <span style="white-space:pre">                        </span>tst_resm(TINFO, "Signal handler caught signal %d", sig);</div><div> </div><div> <span style="white-space:pre">         </span>switch (sig) {</div><div>+<span style="white-space:pre">               </span>case SIGUSR2:</div><div>+<span style="white-space:pre">                </span>    if (debug)</div><div>+<span style="white-space:pre">                     </span>tst_resm(TINFO, "Signal handler received termination request, exiting");</div><div>+<span style="white-space:pre">           </span>    pthread_exit(NULL);</div><div>+<span style="white-space:pre">            </span>    break;</div><div> <span style="white-space:pre">                </span>case SIGALRM:</div><div> <span style="white-space:pre">               </span>case SIGUSR1:</div><div> <span style="white-space:pre">               </span>case SIGINT:</div><div>-- </div><div>2.16.1.291.g4437f3f132-goog</div><div><br></div></div>