mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-21 01:12:26 +08:00
4b23f9bda3
__libc_tsd_get, __libc_tsd_set): Add TYPE argument, use it as the type of the thread variable instead of void *. * sysdeps/mach/hurd/bits/libc-tsd.h (__libc_tsd_define, __libc_tsd_address, __libc_tsd_get, __libc_tsd_set): Likewise. * include/ctype.h (CTYPE_B, CTYPE_TOUPPER, CTYPE_TOLOWER): Adjust __libc_tsd_define arguments. (__ctype_b_loc, __ctype_toupper_loc, __ctype_tolower_loc): Adjust __libc_tsd_address arguments. Remove union hack. * include/rpc/rpc.h (RPC_VARS): Adjust __libc_tsd_define arguments. * sunrpc/rpc_thread.c (RPC_VARS): Likewise. (__rpc_thread_destroy, rpc_thread_multi, __rpc_thread_variables): Adjust __libc_tsd_{set,get} arguments. * ctype/ctype-info.c (CTYPE_B, CTYPE_TOUPPER, CTYPE_TOLOWER): Adjust __libc_tsd_define arguments. * locale/uselocale.c (__uselocale): Adjust __libc_tsd_{set,get} arguments. * locale/lc-ctype.c (_nl_postload_ctype): Likewise. * locale/global-locale.c (__libc_tsd_LOCALE): Adjust type. (LOCALE): Adjust __libc_tsd_define arguments. * locale/localeinfo.h (_NL_CURRENT_LOCALE): Adjust __libc_tsd_get arguments. (LOCALE): Adjust __libc_tsd_define arguments. * sysdeps/mach/hurd/malloc-machine.h (MALLOC): Adjust __libc_tsd_define arguments. (tsd_setspecific, tsd_getspecific): Adjust __libc_tsd_{set,get} arguments. nptl/ * sysdeps/pthread/malloc-machine.h (MALLOC): Adjust __libc_tsd_define arguments. (tsd_setspecific, tsd_getspecific): Adjust __libc_tsd_{set,get} arguments. 2008-11-07 Jakub Jelinek <jakub@redhat.com> * bits/libc-tsd.h (__libc_tsd_define, __libc_tsd_address, __libc_tsd_get, __libc_tsd_set): Add TYPE argument, use it as the type of the thread variable instead of void *. * sysdeps/mach/hurd/bits/libc-tsd.h (__libc_tsd_define, __libc_tsd_address, __libc_tsd_get, __libc_tsd_set): Likewise. * include/ctype.h (CTYPE_B, CTYPE_TOUPPER, CTYPE_TOLOWER): Adjust __libc_tsd_define arguments. (__ctype_b_loc, __ctype_toupper_loc, __ctype_tolower_loc): Adjust __libc_tsd_address arguments. Remove union hack. * include/rpc/rpc.h (RPC_VARS): Adjust __libc_tsd_define arguments. * sunrpc/rpc_thread.c (RPC_VARS): Likewise. (__rpc_thread_destroy, rpc_thread_multi, __rpc_thread_variables): Adjust __libc_tsd_{set,get} arguments. * ctype/ctype-info.c (CTYPE_B, CTYPE_TOUPPER, CTYPE_TOLOWER): Adjust __libc_tsd_define arguments. * locale/uselocale.c (__uselocale): Adjust __libc_tsd_{set,get} arguments. * locale/lc-ctype.c (_nl_postload_ctype): Likewise. * locale/global-locale.c (__libc_tsd_LOCALE): Adjust type. (LOCALE): Adjust __libc_tsd_define arguments. * locale/localeinfo.h (_NL_CURRENT_LOCALE): Adjust __libc_tsd_get arguments. (LOCALE): Adjust __libc_tsd_define arguments. * sysdeps/mach/hurd/malloc-machine.h (MALLOC): Adjust __libc_tsd_define arguments. (tsd_setspecific, tsd_getspecific): Adjust __libc_tsd_{set,get} arguments.
139 lines
3.3 KiB
C
139 lines
3.3 KiB
C
#include <stdio.h>
|
|
#include <bits/libc-lock.h>
|
|
#include <rpc/rpc.h>
|
|
#include <assert.h>
|
|
|
|
#include <bits/libc-lock.h>
|
|
#include <bits/libc-tsd.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)
|
|
|
|
/*
|
|
* Task-variable destructor
|
|
*/
|
|
void __attribute__ ((section ("__libc_thread_freeres_fn")))
|
|
__rpc_thread_destroy (void)
|
|
{
|
|
struct rpc_thread_variables *tvp
|
|
= __libc_tsd_get (struct rpc_thread_variables *, RPC_VARS);
|
|
|
|
if (tvp != NULL) {
|
|
__rpc_thread_svc_cleanup ();
|
|
__rpc_thread_clnt_cleanup ();
|
|
__rpc_thread_key_cleanup ();
|
|
free (tvp->clnt_perr_buf_s);
|
|
free (tvp->clntraw_private_s);
|
|
free (tvp->svcraw_private_s);
|
|
free (tvp->authdes_cache_s);
|
|
free (tvp->authdes_lru_s);
|
|
free (tvp->svc_xports_s);
|
|
free (tvp->svc_pollfd_s);
|
|
if (tvp != &__libc_tsd_RPC_VARS_mem)
|
|
free (tvp);
|
|
__libc_tsd_set (struct rpc_thread_variables *, 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);
|
|
}
|
|
|
|
|
|
struct rpc_thread_variables *
|
|
__rpc_thread_variables (void)
|
|
{
|
|
__libc_once_define (static, once);
|
|
struct rpc_thread_variables *tvp;
|
|
|
|
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);
|
|
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);
|
|
}
|
|
}
|
|
return tvp;
|
|
}
|
|
|
|
|
|
/* Global variables If we're single-threaded, or if this is the first
|
|
thread using the variable, use the existing global variable. This
|
|
provides backwards compatability for existing applications which
|
|
dynamically link against this code. */
|
|
#undef svc_fdset
|
|
#undef rpc_createerr
|
|
#undef svc_pollfd
|
|
#undef svc_max_pollfd
|
|
|
|
fd_set *
|
|
__rpc_thread_svc_fdset (void)
|
|
{
|
|
struct rpc_thread_variables *tvp;
|
|
|
|
tvp = __rpc_thread_variables ();
|
|
if (tvp == &__libc_tsd_RPC_VARS_mem)
|
|
return &svc_fdset;
|
|
return &tvp->svc_fdset_s;
|
|
}
|
|
libc_hidden_def (__rpc_thread_svc_fdset)
|
|
|
|
struct rpc_createerr *
|
|
__rpc_thread_createerr (void)
|
|
{
|
|
struct rpc_thread_variables *tvp;
|
|
|
|
tvp = __rpc_thread_variables ();
|
|
if (tvp == &__libc_tsd_RPC_VARS_mem)
|
|
return &rpc_createerr;
|
|
return &tvp->rpc_createerr_s;
|
|
}
|
|
libc_hidden_def (__rpc_thread_createerr)
|
|
|
|
struct pollfd **
|
|
__rpc_thread_svc_pollfd (void)
|
|
{
|
|
struct rpc_thread_variables *tvp;
|
|
|
|
tvp = __rpc_thread_variables ();
|
|
if (tvp == &__libc_tsd_RPC_VARS_mem)
|
|
return &svc_pollfd;
|
|
return &tvp->svc_pollfd_s;
|
|
}
|
|
libc_hidden_def (__rpc_thread_svc_pollfd)
|
|
|
|
int *
|
|
__rpc_thread_svc_max_pollfd (void)
|
|
{
|
|
struct rpc_thread_variables *tvp;
|
|
|
|
tvp = __rpc_thread_variables ();
|
|
if (tvp == &__libc_tsd_RPC_VARS_mem)
|
|
return &svc_max_pollfd;
|
|
return &tvp->svc_max_pollfd_s;
|
|
}
|
|
libc_hidden_def (__rpc_thread_svc_max_pollfd)
|
|
|
|
#endif /* _RPC_THREAD_SAFE_ */
|