aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/libgcrypt/libgcrypt-1.2.2/src/ath.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/libgcrypt/libgcrypt-1.2.2/src/ath.h')
-rwxr-xr-xlinden/indra/libgcrypt/libgcrypt-1.2.2/src/ath.h132
1 files changed, 132 insertions, 0 deletions
diff --git a/linden/indra/libgcrypt/libgcrypt-1.2.2/src/ath.h b/linden/indra/libgcrypt/libgcrypt-1.2.2/src/ath.h
new file mode 100755
index 0000000..5fc0e53
--- /dev/null
+++ b/linden/indra/libgcrypt/libgcrypt-1.2.2/src/ath.h
@@ -0,0 +1,132 @@
1/* ath.h - Thread-safeness library.
2 Copyright (C) 2002, 2003, 2004 g10 Code GmbH
3
4 This file is part of Libgcrypt.
5
6 Libgcrypt is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of
9 the License, or (at your option) any later version.
10
11 Libgcrypt is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with Libgcrypt; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA. */
20
21#ifndef ATH_H
22#define ATH_H
23
24#ifdef _WIN32
25#include <windows.h>
26#else
27#include <sys/types.h>
28#include <sys/socket.h>
29#endif
30#include <gpg-error.h>
31
32#include <config.h>
33
34
35/* Define _ATH_EXT_SYM_PREFIX if you want to give all external symbols
36 a prefix. */
37#define _ATH_EXT_SYM_PREFIX _gcry_
38
39#ifdef _ATH_EXT_SYM_PREFIX
40#define _ATH_PREFIX1(x,y) x ## y
41#define _ATH_PREFIX2(x,y) _ATH_PREFIX1(x,y)
42#define _ATH_PREFIX(x) _ATH_PREFIX2(_ATH_EXT_SYM_PREFIX,x)
43#define ath_install _ATH_PREFIX(ath_install)
44#define ath_init _ATH_PREFIX(ath_init)
45#define ath_mutex_init _ATH_PREFIX(ath_mutex_init)
46#define ath_mutex_destroy _ATH_PREFIX(ath_mutex_destroy)
47#define ath_mutex_lock _ATH_PREFIX(ath_mutex_lock)
48#define ath_mutex_unlock _ATH_PREFIX(ath_mutex_unlock)
49#define ath_read _ATH_PREFIX(ath_read)
50#define ath_write _ATH_PREFIX(ath_write)
51#define ath_select _ATH_PREFIX(ath_select)
52#define ath_waitpid _ATH_PREFIX(ath_waitpid)
53#define ath_connect _ATH_PREFIX(ath_connect)
54#define ath_accept _ATH_PREFIX(ath_accept)
55#define ath_sendmsg _ATH_PREFIX(ath_sendmsg)
56#define ath_recvmsg _ATH_PREFIX(ath_recvmsg)
57#endif
58
59
60enum ath_thread_option
61 {
62 ATH_THREAD_OPTION_DEFAULT = 0,
63 ATH_THREAD_OPTION_USER = 1,
64 ATH_THREAD_OPTION_PTH = 2,
65 ATH_THREAD_OPTION_PTHREAD = 3
66 };
67
68struct ath_ops
69{
70 enum ath_thread_option option;
71 int (*init) (void);
72 int (*mutex_init) (void **priv);
73 int (*mutex_destroy) (void *priv);
74 int (*mutex_lock) (void *priv);
75 int (*mutex_unlock) (void *priv);
76 ssize_t (*read) (int fd, void *buf, size_t nbytes);
77 ssize_t (*write) (int fd, const void *buf, size_t nbytes);
78#ifdef _WIN32
79 ssize_t (*select) (int nfd, void *rset, void *wset, void *eset,
80 struct timeval *timeout);
81 ssize_t (*waitpid) (pid_t pid, int *status, int options);
82 int (*accept) (int s, void *addr, int *length_ptr);
83 int (*connect) (int s, void *addr, socklen_t length);
84 int (*sendmsg) (int s, const void *msg, int flags);
85 int (*recvmsg) (int s, void *msg, int flags);
86#else
87 ssize_t (*select) (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
88 struct timeval *timeout);
89 ssize_t (*waitpid) (pid_t pid, int *status, int options);
90 int (*accept) (int s, struct sockaddr *addr, socklen_t *length_ptr);
91 int (*connect) (int s, struct sockaddr *addr, socklen_t length);
92 int (*sendmsg) (int s, const struct msghdr *msg, int flags);
93 int (*recvmsg) (int s, struct msghdr *msg, int flags);
94#endif
95};
96
97gpg_err_code_t ath_install (struct ath_ops *ath_ops, int check_only);
98int ath_init (void);
99
100
101/* Functions for mutual exclusion. */
102typedef void *ath_mutex_t;
103#define ATH_MUTEX_INITIALIZER 0
104
105int ath_mutex_init (ath_mutex_t *mutex);
106int ath_mutex_destroy (ath_mutex_t *mutex);
107int ath_mutex_lock (ath_mutex_t *mutex);
108int ath_mutex_unlock (ath_mutex_t *mutex);
109
110/* Replacement for the POSIX functions, which can be used to allow
111 other (user-level) threads to run. */
112ssize_t ath_read (int fd, void *buf, size_t nbytes);
113ssize_t ath_write (int fd, const void *buf, size_t nbytes);
114#ifdef _WIN32
115ssize_t ath_select (int nfd, void *rset, void *wset, void *eset,
116 struct timeval *timeout);
117ssize_t ath_waitpid (pid_t pid, int *status, int options);
118int ath_accept (int s, void *addr, int *length_ptr);
119int ath_connect (int s, void *addr, int length);
120int ath_sendmsg (int s, const void *msg, int flags);
121int ath_recvmsg (int s, void *msg, int flags);
122#else
123ssize_t ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
124 struct timeval *timeout);
125ssize_t ath_waitpid (pid_t pid, int *status, int options);
126int ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr);
127int ath_connect (int s, struct sockaddr *addr, socklen_t length);
128int ath_sendmsg (int s, const struct msghdr *msg, int flags);
129int ath_recvmsg (int s, struct msghdr *msg, int flags);
130#endif
131
132#endif /* ATH_H */