Add a function to detect if we have async or not
[openssl.git] / crypto / async / async_locl.h
index a463bf1c229e9b49c1716f26c42269011ebd9879..7fa1f26c005c2795e53682578e63f6bd9de43c4a 100644 (file)
@@ -1,4 +1,3 @@
-/* crypto/async/async_locl.h */
 /*
  * Written by Matt Caswell (matt@openssl.org) for the OpenSSL project.
  */
  * ====================================================================
  */
 
-#include <openssl/async.h>
+/*
+ * Must do this before including any header files, because on MacOS/X <stlib.h>
+ * includes <signal.h> which includes <ucontext.h>
+ */
+#if defined(__APPLE__) && defined(__MACH__) && !defined(_XOPEN_SOURCE)
+# define _XOPEN_SOURCE          /* Otherwise incomplete ucontext_t structure */
+# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
+#include <internal/async.h>
 #include <openssl/crypto.h>
 
 typedef struct async_ctx_st async_ctx;
@@ -73,12 +81,26 @@ struct async_job_st {
     void *funcargs;
     int ret;
     int status;
-    int wake_set;
-    OSSL_ASYNC_FD wait_fd;
-    OSSL_ASYNC_FD wake_fd;
+    ASYNC_WAIT_CTX *waitctx;
 };
 
-DECLARE_STACK_OF(ASYNC_JOB)
+struct fd_lookup_st {
+    const void *key;
+    OSSL_ASYNC_FD fd;
+    void *custom_data;
+    void (*cleanup)(ASYNC_WAIT_CTX *, const void *, OSSL_ASYNC_FD, void *);
+    int add;
+    int del;
+    struct fd_lookup_st *next;
+};
+
+struct async_wait_ctx_st {
+    struct fd_lookup_st *fds;
+    size_t numadd;
+    size_t numdel;
+};
+
+DEFINE_STACK_OF(ASYNC_JOB)
 
 struct async_pool_st {
     STACK_OF(ASYNC_JOB) *jobs;
@@ -86,12 +108,9 @@ struct async_pool_st {
     size_t max_size;
 };
 
-int async_global_init(void);
-int async_local_init(void);
 void async_local_cleanup(void);
-void async_global_cleanup(void);
 void async_start_func(void);
-int async_pipe(OSSL_ASYNC_FD *pipefds);
-int async_close_fd(OSSL_ASYNC_FD fd);
-int async_write1(OSSL_ASYNC_FD fd, const void *buf);
-int async_read1(OSSL_ASYNC_FD fd, void *buf);
+async_ctx *async_get_ctx(void);
+
+void async_wait_ctx_reset_counts(ASYNC_WAIT_CTX *ctx);
+