Auto init/deinit libcrypto
[openssl.git] / crypto / async / async_locl.h
index ad85fa074e09d298894086e99e8e2f0564ab3875..53a192b3299fd5f61efb1c76fde8d198907c1f7e 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;
+    OSSL_ASYNC_FD wait_fd;
+    OSSL_ASYNC_FD wake_fd;
 };
 
-DECLARE_STACK_OF(ASYNC_JOB)
+DEFINE_STACK_OF(ASYNC_JOB)
+
+struct async_pool_st {
+    STACK_OF(ASYNC_JOB) *jobs;
+    size_t curr_size;
+    size_t max_size;
+};
 
-void ASYNC_start_func(void);
-STACK_OF(ASYNC_JOB) *async_get_pool(void);
-int 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);
+int async_global_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);