libssh 0.9.5 The SSH library

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 int ssh_threads_init(void);
53 void ssh_threads_finalize(void);
54 const char *ssh_threads_get_type(void);
55
56 void ssh_mutex_lock(SSH_MUTEX *mutex);
57 void ssh_mutex_unlock(SSH_MUTEX *mutex);
58
59 struct ssh_threads_callbacks_struct *ssh_threads_get_default(void);
60 int crypto_thread_init(struct ssh_threads_callbacks_struct *user_callbacks);
61 void crypto_thread_finalize(void);
62
63#endif /* THREADS_H_ */
ssh_threads_callbacks_struct
Definition: callbacks.h:917