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
20 __rpc_thread_destroy (void)
22 struct rpc_thread_variables
*tvp
= thread_rpc_vars
;
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
)
37 thread_rpc_vars
= NULL
;
40 text_set_element (__libc_subfreeres
, __rpc_thread_destroy
);
43 * Initialize RPC multi-threaded operation
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
;
59 __libc_once (once
, rpc_thread_multi
);
60 tvp
= thread_rpc_vars
;
62 tvp
= calloc (1, sizeof *tvp
);
64 thread_rpc_vars
= 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. */
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
)
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
)
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
)
112 return &tvp
->svc_pollfd_s
;
114 #ifdef EXPORT_RPC_SYMBOLS
115 libc_hidden_def (__rpc_thread_svc_pollfd
)
117 libc_hidden_nolink_sunrpc (__rpc_thread_svc_pollfd
, GLIBC_2_2_3
)
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
)
133 libc_hidden_nolink_sunrpc (__rpc_thread_svc_max_pollfd
, GLIBC_2_2_3
)