mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-07 02:39:48 +09:00
threads: Automatically call ssh_init on load
This makes unnecessary to call ssh_init() when the library is dynamically loaded. Also removes the threads shared library. The used threads implementation is chosen in configuration time, changing the ssh_threads_get_default() depending on the available threads library. Internally, it is expected a threads implementation providing: - void ssh_mutex_lock(void **mutex); - void ssh_mutex_unlock(void **mutex); - struct ssh_threads_callbacks_struct *ssh_threads_get_default(void); and a crypto implementation providing: - int crypto_thread_init(struct ssh_threads_callbacks_struct *user_callbacks); - void crypto_thread_finalize(void); This adds internal threads implementation for pthreads and noop. Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
6a077fe750
commit
83b43443e5
@@ -24,8 +24,33 @@
|
||||
#include <libssh/libssh.h>
|
||||
#include <libssh/callbacks.h>
|
||||
|
||||
#if HAVE_PTHREAD
|
||||
|
||||
#include <pthread.h>
|
||||
#define SSH_MUTEX pthread_mutex_t
|
||||
|
||||
#if defined _GNU_SOURCE
|
||||
#define SSH_MUTEX_STATIC_INIT PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
|
||||
#else
|
||||
#define SSH_MUTEX_STATIC_INIT PTHREAD_MUTEX_INITIALIZER
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
# define SSH_MUTEX void *
|
||||
#define SSH_MUTEX_STATIC_INIT NULL
|
||||
|
||||
#endif
|
||||
|
||||
int ssh_threads_init(void);
|
||||
void ssh_threads_finalize(void);
|
||||
const char *ssh_threads_get_type(void);
|
||||
|
||||
void ssh_mutex_lock(SSH_MUTEX *mutex);
|
||||
void ssh_mutex_unlock(SSH_MUTEX *mutex);
|
||||
|
||||
struct ssh_threads_callbacks_struct *ssh_threads_get_default(void);
|
||||
int crypto_thread_init(struct ssh_threads_callbacks_struct *user_callbacks);
|
||||
void crypto_thread_finalize(void);
|
||||
|
||||
#endif /* THREADS_H_ */
|
||||
|
||||
Reference in New Issue
Block a user