libssh  0.10.90
The SSH library
Loading...
Searching...
No Matches
threads.h
1/*
2 * This file is part of the SSH Library
3 *
4 * Copyright (c) 2010 by Aris Adamantiadis
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef THREADS_H_
22#define THREADS_H_
23
24#include <libssh/libssh.h>
25#include <libssh/callbacks.h>
26
27#if HAVE_PTHREAD
28
29#include <pthread.h>
30#define SSH_MUTEX pthread_mutex_t
31
32#if defined(PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP)
33#define SSH_MUTEX_STATIC_INIT PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
34#else
35#define SSH_MUTEX_STATIC_INIT PTHREAD_MUTEX_INITIALIZER
36#endif
37
38#elif (defined _WIN32) || (defined _WIN64)
39
40#include <windows.h>
41#include <winbase.h>
42#define SSH_MUTEX CRITICAL_SECTION *
43#define SSH_MUTEX_STATIC_INIT NULL
44
45#else
46
47# define SSH_MUTEX void *
48#define SSH_MUTEX_STATIC_INIT NULL
49
50#endif
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55
56int ssh_threads_init(void);
57void ssh_threads_finalize(void);
58const char *ssh_threads_get_type(void);
59
60void ssh_mutex_lock(SSH_MUTEX *mutex);
61void ssh_mutex_unlock(SSH_MUTEX *mutex);
62
63struct ssh_threads_callbacks_struct *ssh_threads_get_default(void);
64int crypto_thread_init(struct ssh_threads_callbacks_struct *user_callbacks);
65void crypto_thread_finalize(void);
66
67#ifdef __cplusplus
68}
69#endif
70
71#endif /* THREADS_H_ */
struct ssh_threads_callbacks_struct * ssh_threads_get_default(void)
Returns a pointer to the appropriate callbacks structure for the environment, to be used with ssh_thr...
Definition noop.c:65