Some platforms provide getcontext() but it does not work
[openssl.git] / crypto / async / arch / async_posix.c
index 57cce7b4c48e84c7e0bb0a5c3d10a3d675d7cc5e..33f2a3fa1ea21f7f42237c589e088bca19904676 100644 (file)
 # include <stddef.h>
 # include <unistd.h>
 
-pthread_key_t posixctx;
-pthread_key_t posixpool;
-
 #define STACKSIZE       32768
 
-int async_global_init(void)
+int ASYNC_is_capable(void)
 {
-    if (pthread_key_create(&posixctx, NULL) != 0
-            || pthread_key_create(&posixpool, NULL) != 0)
-        return 0;
+    ucontext_t ctx;
 
-    return 1;
+    /*
+     * Some platforms provide getcontext() but it does not work (notably
+     * MacOSX PPC64). Check for a working getcontext();
+     */
+    return getcontext(&ctx) == 0;
 }
 
 void async_local_cleanup(void)
 {
 }
 
-void async_global_cleanup(void)
-{
-}
-
 int async_fibre_makecontext(async_fibre *fibre)
 {
     fibre->env_init = 0;
@@ -103,36 +98,4 @@ void async_fibre_free(async_fibre *fibre)
     fibre->fibre.uc_stack.ss_sp = NULL;
 }
 
-int async_pipe(OSSL_ASYNC_FD *pipefds)
-{
-    if (pipe(pipefds) == 0)
-        return 1;
-
-    return 0;
-}
-
-int async_close_fd(OSSL_ASYNC_FD fd)
-{
-    if (close(fd) != 0)
-        return 0;
-
-    return 1;
-}
-
-int async_write1(OSSL_ASYNC_FD fd, const void *buf)
-{
-    if (write(fd, buf, 1) > 0)
-        return 1;
-
-    return 0;
-}
-
-int async_read1(OSSL_ASYNC_FD fd, void *buf)
-{
-    if (read(fd, buf, 1) > 0)
-        return 1;
-
-    return 0;
-}
-
 #endif