Add a function to detect if we have async or not
[openssl.git] / crypto / async / async_locl.h
index 4bfc37fe206e649a50774b91fd171874e8315c2c..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;
+typedef struct async_ctx_st async_ctx;
+typedef struct async_pool_st async_pool;
 
 #include "arch/async_win.h"
 #include "arch/async_posix.h"
 #include "arch/async_null.h"
 
 struct async_ctx_st {
-    ASYNC_FIBRE dispatcher;
+    async_fibre dispatcher;
     ASYNC_JOB *currjob;
+    unsigned int blocked;
 };
 
 struct async_job_st {
-    ASYNC_FIBRE fibrectx;
+    async_fibre fibrectx;
     int (*func) (void *);
     void *funcargs;
     int ret;
     int status;
-    int wake_set;
-    int wait_fd;
-    int 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;
+    size_t curr_size;
+    size_t max_size;
+};
+
+void async_local_cleanup(void);
+void async_start_func(void);
+async_ctx *async_get_ctx(void);
+
+void async_wait_ctx_reset_counts(ASYNC_WAIT_CTX *ctx);
 
-void ASYNC_start_func(void);
-STACK_OF(ASYNC_JOB) *async_get_pool(void);
-void async_set_pool(STACK_OF(ASYNC_JOB) *poolin, size_t curr_size,
-                    size_t max_size);
-void async_increment_pool_size(void);
-void async_release_job_to_pool(ASYNC_JOB *job);
-size_t async_pool_max_size(void);
-void async_release_pool(void);
-int async_pool_can_grow(void);