diff options
| author | Gabriel Scherer <gabriel.scherer@gmail.com> | 2014-12-13 22:35:59 +0000 |
|---|---|---|
| committer | Gabriel Scherer <gabriel.scherer@gmail.com> | 2014-12-13 22:35:59 +0000 |
| commit | 186841ed3de95f7f021a6a8b9604e6aeff6c6f93 (patch) | |
| tree | 9d29cf61faef13f81d4b7a4fae43393c0b4ee410 /otherlibs | |
| parent | 05da4dd672c58dee80c9271fae0494b09105becd (diff) | |
| download | ocaml-186841ed3de95f7f021a6a8b9604e6aeff6c6f93.tar.gz | |
Allow Android builds with systhreads support.
From: Peter Zotov <whitequark@whitequark.org>
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15666 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs')
| -rw-r--r-- | otherlibs/systhreads/st_posix.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/otherlibs/systhreads/st_posix.h b/otherlibs/systhreads/st_posix.h index e0bc65e41d..1d87a22986 100644 --- a/otherlibs/systhreads/st_posix.h +++ b/otherlibs/systhreads/st_posix.h @@ -80,7 +80,12 @@ static void st_thread_exit(void) static void st_thread_kill(st_thread_id thr) { +#if !defined(__ANDROID__) + /* pthread_cancel is unsafe, as it does not allow the thread an opportunity + to free shared resources such as mutexes. Thus, it is not implemented + in Android's libc. */ pthread_cancel(thr); +#endif } /* Scheduling hints */ @@ -322,8 +327,10 @@ static void * caml_thread_tick(void * arg) /* Block all signals so that we don't try to execute an OCaml signal handler*/ sigfillset(&mask); pthread_sigmask(SIG_BLOCK, &mask, NULL); +#if !defined(__ANDROID__) /* Allow async cancellation */ pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); +#endif while(1) { /* select() seems to be the most efficient way to suspend the thread for sub-second intervals */ @@ -340,6 +347,15 @@ static void * caml_thread_tick(void * arg) /* "At fork" processing */ +#if defined(__ANDROID__) +/* Android's libc does not include declaration of pthread_atfork; + however, it implements it since API level 10 (Gingerbread). + The reason for the omission is that Android (GUI) applications + are not supposed to fork at all, however this workaround is still + included in case OCaml is used for an Android CLI utility. */ +int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)); +#endif + static int st_atfork(void (*fn)(void)) { return pthread_atfork(NULL, NULL, fn); |
