#include <stdio.h>
-#include <bits/libc-lock.h>
#include <rpc/rpc.h>
#include <assert.h>
-#include <bits/libc-lock.h>
+#include <libc-lock.h>
#include <libc-tsd.h>
+#include <shlib-compat.h>
+#include <libc-symbols.h>
-#ifdef _RPC_THREAD_SAFE_
/* Variable used in non-threaded applications or for the first thread. */
static struct rpc_thread_variables __libc_tsd_RPC_VARS_mem;
-__libc_tsd_define (, struct rpc_thread_variables *, RPC_VARS)
+static __thread struct rpc_thread_variables *thread_rpc_vars
+ attribute_tls_model_ie;
/*
* Task-variable destructor
*/
-void __attribute__ ((section ("__libc_thread_freeres_fn")))
+void
__rpc_thread_destroy (void)
{
- struct rpc_thread_variables *tvp
- = __libc_tsd_get (struct rpc_thread_variables *, RPC_VARS);
+ struct rpc_thread_variables *tvp = thread_rpc_vars;
if (tvp != NULL) {
__rpc_thread_svc_cleanup ();
free (tvp->svc_pollfd_s);
if (tvp != &__libc_tsd_RPC_VARS_mem)
free (tvp);
- __libc_tsd_set (struct rpc_thread_variables *, RPC_VARS, NULL);
+ thread_rpc_vars = NULL;
}
}
-#ifdef _LIBC_REENTRANT
-text_set_element (__libc_thread_subfreeres, __rpc_thread_destroy);
-#endif
text_set_element (__libc_subfreeres, __rpc_thread_destroy);
-
/*
* Initialize RPC multi-threaded operation
*/
static void
rpc_thread_multi (void)
{
- __libc_tsd_set (struct rpc_thread_variables *, RPC_VARS,
- &__libc_tsd_RPC_VARS_mem);
+ thread_rpc_vars = &__libc_tsd_RPC_VARS_mem;
}
__rpc_thread_variables (void)
{
__libc_once_define (static, once);
- struct rpc_thread_variables *tvp;
+ struct rpc_thread_variables *tvp = thread_rpc_vars;
- tvp = __libc_tsd_get (struct rpc_thread_variables *, RPC_VARS);
if (tvp == NULL) {
__libc_once (once, rpc_thread_multi);
- tvp = __libc_tsd_get (struct rpc_thread_variables *, RPC_VARS);
+ tvp = thread_rpc_vars;
if (tvp == NULL) {
tvp = calloc (1, sizeof *tvp);
if (tvp != NULL)
- __libc_tsd_set (struct rpc_thread_variables *,
- RPC_VARS, tvp);
- else
- tvp = __libc_tsd_get (struct rpc_thread_variables *,
- RPC_VARS);
+ thread_rpc_vars = tvp;
}
}
return tvp;
#else
libc_hidden_nolink_sunrpc (__rpc_thread_svc_max_pollfd, GLIBC_2_2_3)
#endif
-
-#endif /* _RPC_THREAD_SAFE_ */