glibc/sunrpc/rpc_thread.c
Roland McGrath 8784cc18e1 2002-08-05 Jakub Jelinek <jakub@redhat.com>
* include/wchar.h (wcrtomb, wcscmp, wcsftime, wcsspn, wcschr, wcscoll,
        wcspbrk): Add libc_hidden_proto.
        * time/strftime.c (my_strftime): Add libc_hidden_def.
        (strftime): Remove libc_hidden_def.
        * wcsmbs/wcschr.c (wcschr): Add libc_hidden_def.
        * wcsmbs/wcspbrk.c (wcspbrk): Likewise.
        * wcsmbs/wcsspn.c (wcsspn): Likewise.
        * wcsmbs/wcscmp.c (wcscmp): Likewise.
        * wcsmbs/wcrtomb.c (wcrtomb): Add libc_hidden_weak.
        * wcsmbs/wcscoll.c (wcscoll): Likewise.

        * include/rpc/rpc.h (__rpc_thread_svc_max_pollfd,
        __rpc_thread_svc_pollfd, __rpc_thread_svc_fdset,
        __rpc_thread_createerr): Add libc_hidden_proto.
        * sunrpc/rpc_thread.c (__rpc_thread_svc_max_pollfd,
        __rpc_thread_svc_pollfd, __rpc_thread_svc_fdset,
        __rpc_thread_createerr): Add libc_hidden_def.

        * include/rpc/clnt.h (clnt_sperrno, clnt_spcreateerror,
        clnt_perror, clnt_sperror, _rpc_dtablesize): Add libc_hidden_proto.
        * sunrpc/clnt_perr.c (clnt_sperrno, clnt_spcreateerror,
        clnt_perror, clnt_sperror): Add libc_hidden_def.
        * sunrpc/rpc_dtable.c (_rpc_dtablesize): Likewise.

        * include/rpc/des_crypt.h (des_setparity, ecb_crypt, cbc_crypt): Add
        libc_hidden_proto.
        * sunrpc/des_crypt.c (ecb_crypt, cbc_crypt): Add libc_hidden_proto.
        * sunrpc/des_soft.c (des_setparity): Likewise.

        * include/rpc/auth.h (key_encryptsession_pk, key_decryptsession_pk):
        Add libc_hidden_proto.
        * sunrpc/key_call.c (key_encryptsession_pk, key_decryptsession_pk):
        Add libc_hidden_def.
2002-08-05 22:11:14 +00:00

127 lines
2.7 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 (, RPC_VARS)
/*
* Task-variable destructor
*/
void
__rpc_thread_destroy (void)
{
struct rpc_thread_variables *tvp = __libc_tsd_get (RPC_VARS);
if (tvp != NULL && tvp != &__libc_tsd_RPC_VARS_mem) {
__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);
}
}
/*
* Initialize RPC multi-threaded operation
*/
static void
rpc_thread_multi (void)
{
__libc_tsd_set (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 (RPC_VARS);
if (tvp == NULL) {
__libc_once (once, rpc_thread_multi);
tvp = __libc_tsd_get (RPC_VARS);
if (tvp == NULL) {
tvp = calloc (1, sizeof *tvp);
if (tvp != NULL)
__libc_tsd_set (RPC_VARS, tvp);
else
tvp = __libc_tsd_get (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_ */