Regenerate configure.
[glibc.git] / sunrpc / rpc_thread.c
blob0abe6dc17204012569e49a77fab5790437ff0273
1 #include <stdio.h>
2 #include <rpc/rpc.h>
3 #include <assert.h>
5 #include <libc-lock.h>
6 #include <libc-tsd.h>
7 #include <shlib-compat.h>
8 #include <libc-symbols.h>
11 /* Variable used in non-threaded applications or for the first thread. */
12 static struct rpc_thread_variables __libc_tsd_RPC_VARS_mem;
13 static __thread struct rpc_thread_variables *thread_rpc_vars
14 attribute_tls_model_ie;
17 * Task-variable destructor
19 void
20 __rpc_thread_destroy (void)
22 struct rpc_thread_variables *tvp = thread_rpc_vars;
24 if (tvp != NULL) {
25 __rpc_thread_svc_cleanup ();
26 __rpc_thread_clnt_cleanup ();
27 __rpc_thread_key_cleanup ();
28 free (tvp->clnt_perr_buf_s);
29 free (tvp->clntraw_private_s);
30 free (tvp->svcraw_private_s);
31 free (tvp->authdes_cache_s);
32 free (tvp->authdes_lru_s);
33 free (tvp->svc_xports_s);
34 free (tvp->svc_pollfd_s);
35 if (tvp != &__libc_tsd_RPC_VARS_mem)
36 free (tvp);
37 thread_rpc_vars = NULL;
40 text_set_element (__libc_subfreeres, __rpc_thread_destroy);
43 * Initialize RPC multi-threaded operation
45 static void
46 rpc_thread_multi (void)
48 thread_rpc_vars = &__libc_tsd_RPC_VARS_mem;
52 struct rpc_thread_variables *
53 __rpc_thread_variables (void)
55 __libc_once_define (static, once);
56 struct rpc_thread_variables *tvp = thread_rpc_vars;
58 if (tvp == NULL) {
59 __libc_once (once, rpc_thread_multi);
60 tvp = thread_rpc_vars;
61 if (tvp == NULL) {
62 tvp = calloc (1, sizeof *tvp);
63 if (tvp != NULL)
64 thread_rpc_vars = tvp;
67 return tvp;
71 /* Global variables If we're single-threaded, or if this is the first
72 thread using the variable, use the existing global variable. This
73 provides backwards compatibility for existing applications which
74 dynamically link against this code. */
75 #undef svc_fdset
76 #undef rpc_createerr
77 #undef svc_pollfd
78 #undef svc_max_pollfd
80 fd_set *
81 __rpc_thread_svc_fdset (void)
83 struct rpc_thread_variables *tvp;
85 tvp = __rpc_thread_variables ();
86 if (tvp == &__libc_tsd_RPC_VARS_mem)
87 return &svc_fdset;
88 return &tvp->svc_fdset_s;
90 libc_hidden_nolink_sunrpc (__rpc_thread_svc_fdset, GLIBC_2_2_3)
92 struct rpc_createerr *
93 __rpc_thread_createerr (void)
95 struct rpc_thread_variables *tvp;
97 tvp = __rpc_thread_variables ();
98 if (tvp == &__libc_tsd_RPC_VARS_mem)
99 return &rpc_createerr;
100 return &tvp->rpc_createerr_s;
102 libc_hidden_nolink_sunrpc (__rpc_thread_createerr, GLIBC_2_2_3)
104 struct pollfd **
105 __rpc_thread_svc_pollfd (void)
107 struct rpc_thread_variables *tvp;
109 tvp = __rpc_thread_variables ();
110 if (tvp == &__libc_tsd_RPC_VARS_mem)
111 return &svc_pollfd;
112 return &tvp->svc_pollfd_s;
114 #ifdef EXPORT_RPC_SYMBOLS
115 libc_hidden_def (__rpc_thread_svc_pollfd)
116 #else
117 libc_hidden_nolink_sunrpc (__rpc_thread_svc_pollfd, GLIBC_2_2_3)
118 #endif
120 int *
121 __rpc_thread_svc_max_pollfd (void)
123 struct rpc_thread_variables *tvp;
125 tvp = __rpc_thread_variables ();
126 if (tvp == &__libc_tsd_RPC_VARS_mem)
127 return &svc_max_pollfd;
128 return &tvp->svc_max_pollfd_s;
130 #ifdef EXPORT_RPC_SYMBOLS
131 libc_hidden_def (__rpc_thread_svc_max_pollfd)
132 #else
133 libc_hidden_nolink_sunrpc (__rpc_thread_svc_max_pollfd, GLIBC_2_2_3)
134 #endif