powerpc: Add space for HWCAP3/HWCAP4 in the TCB for future Power.
[glibc.git] / sunrpc / rpc_thread.c
bloba04b7ec47fa4760cac6a635f4373405372aa1a71
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;
42 * Initialize RPC multi-threaded operation
44 static void
45 rpc_thread_multi (void)
47 thread_rpc_vars = &__libc_tsd_RPC_VARS_mem;
51 struct rpc_thread_variables *
52 __rpc_thread_variables (void)
54 __libc_once_define (static, once);
55 struct rpc_thread_variables *tvp = thread_rpc_vars;
57 if (tvp == NULL) {
58 __libc_once (once, rpc_thread_multi);
59 tvp = thread_rpc_vars;
60 if (tvp == NULL) {
61 tvp = calloc (1, sizeof *tvp);
62 if (tvp != NULL)
63 thread_rpc_vars = tvp;
66 return tvp;
70 /* Global variables If we're single-threaded, or if this is the first
71 thread using the variable, use the existing global variable. This
72 provides backwards compatibility for existing applications which
73 dynamically link against this code. */
74 #undef svc_fdset
75 #undef rpc_createerr
76 #undef svc_pollfd
77 #undef svc_max_pollfd
79 fd_set *
80 __rpc_thread_svc_fdset (void)
82 struct rpc_thread_variables *tvp;
84 tvp = __rpc_thread_variables ();
85 if (tvp == &__libc_tsd_RPC_VARS_mem)
86 return &svc_fdset;
87 return &tvp->svc_fdset_s;
89 libc_hidden_nolink_sunrpc (__rpc_thread_svc_fdset, GLIBC_2_2_3)
91 struct rpc_createerr *
92 __rpc_thread_createerr (void)
94 struct rpc_thread_variables *tvp;
96 tvp = __rpc_thread_variables ();
97 if (tvp == &__libc_tsd_RPC_VARS_mem)
98 return &rpc_createerr;
99 return &tvp->rpc_createerr_s;
101 libc_hidden_nolink_sunrpc (__rpc_thread_createerr, GLIBC_2_2_3)
103 struct pollfd **
104 __rpc_thread_svc_pollfd (void)
106 struct rpc_thread_variables *tvp;
108 tvp = __rpc_thread_variables ();
109 if (tvp == &__libc_tsd_RPC_VARS_mem)
110 return &svc_pollfd;
111 return &tvp->svc_pollfd_s;
113 #ifdef EXPORT_RPC_SYMBOLS
114 libc_hidden_def (__rpc_thread_svc_pollfd)
115 #else
116 libc_hidden_nolink_sunrpc (__rpc_thread_svc_pollfd, GLIBC_2_2_3)
117 #endif
119 int *
120 __rpc_thread_svc_max_pollfd (void)
122 struct rpc_thread_variables *tvp;
124 tvp = __rpc_thread_variables ();
125 if (tvp == &__libc_tsd_RPC_VARS_mem)
126 return &svc_max_pollfd;
127 return &tvp->svc_max_pollfd_s;
129 #ifdef EXPORT_RPC_SYMBOLS
130 libc_hidden_def (__rpc_thread_svc_max_pollfd)
131 #else
132 libc_hidden_nolink_sunrpc (__rpc_thread_svc_max_pollfd, GLIBC_2_2_3)
133 #endif