diff options
author | deischen <deischen@FreeBSD.org> | 2001-01-24 13:01:12 +0000 |
---|---|---|
committer | deischen <deischen@FreeBSD.org> | 2001-01-24 13:01:12 +0000 |
commit | 1635c221b7b2678beeeb2b5fa728edd7c8c3735b (patch) | |
tree | d7d4f61b9e319a781a335702fe846592726c22b9 /lib/libc/rpc/pmap_rmt.c | |
parent | 08685e9e9fd9de1e8dc51cada55659344adaf0cc (diff) | |
download | FreeBSD-src-1635c221b7b2678beeeb2b5fa728edd7c8c3735b.zip FreeBSD-src-1635c221b7b2678beeeb2b5fa728edd7c8c3735b.tar.gz |
Remove _THREAD_SAFE and make libc thread-safe by default by
adding (weak definitions to) stubs for some of the pthread
functions. If the threads library is linked in, the real
pthread functions will pulled in.
Use the following convention for system calls wrapped by the
threads library:
__sys_foo - actual system call
_foo - weak definition to __sys_foo
foo - weak definition to __sys_foo
Change all libc uses of system calls wrapped by the threads
library from foo to _foo. In order to define the prototypes
for _foo(), we introduce namespace.h and un-namespace.h
(suggested by bde). All files that need to reference these
system calls, should include namespace.h before any standard
includes, then include un-namespace.h after the standard
includes and before any local includes. <db.h> is an exception
and shouldn't be included in between namespace.h and
un-namespace.h namespace.h will define foo to _foo, and
un-namespace.h will undefine foo.
Try to eliminate some of the recursive calls to MT-safe
functions in libc/stdio in preparation for adding a mutex
to FILE. We have recursive mutexes, but would like to avoid
using them if possible.
Remove uneeded includes of <errno.h> from a few files.
Add $FreeBSD$ to a few files in order to pass commitprep.
Approved by: -arch
Diffstat (limited to 'lib/libc/rpc/pmap_rmt.c')
-rw-r--r-- | lib/libc/rpc/pmap_rmt.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/libc/rpc/pmap_rmt.c b/lib/libc/rpc/pmap_rmt.c index f36acf1..298c956 100644 --- a/lib/libc/rpc/pmap_rmt.c +++ b/lib/libc/rpc/pmap_rmt.c @@ -41,6 +41,7 @@ static char *rcsid = "$FreeBSD$"; * Copyright (C) 1984, Sun Microsystems, Inc. */ +#include "namespace.h" #include <rpc/rpc.h> #include <rpc/pmap_prot.h> #include <rpc/pmap_clnt.h> @@ -54,6 +55,8 @@ static char *rcsid = "$FreeBSD$"; #include <net/if.h> #include <sys/ioctl.h> #include <arpa/inet.h> +#include "un-namespace.h" + #define MAX_BROADCAST_SIZE 1400 static struct timeval timeout = { 3, 0 }; @@ -177,7 +180,7 @@ getbroadcastnets(addrs, sock, buf) ifc.ifc_len = UDPMSGSIZE; ifc.ifc_buf = buf; - if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) { + if (_ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) { perror("broadcast: ioctl (get interface configuration)"); return (0); } @@ -190,7 +193,7 @@ getbroadcastnets(addrs, sock, buf) if (ifr->ifr_addr.sa_family != AF_INET) continue; memcpy(&ifreq, ifr, sizeof(ifreq)); - if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifreq) < 0) { + if (_ioctl(sock, SIOCGIFFLAGS, (char *)&ifreq) < 0) { perror("broadcast: ioctl (get interface flags)"); continue; } @@ -198,7 +201,7 @@ getbroadcastnets(addrs, sock, buf) (ifreq.ifr_flags & IFF_UP)) { sin = (struct sockaddr_in *)&ifr->ifr_addr; #ifdef SIOCGIFBRDADDR /* 4.3BSD */ - if (ioctl(sock, SIOCGIFBRDADDR, (char *)&ifreq) < 0) { + if (_ioctl(sock, SIOCGIFBRDADDR, (char *)&ifreq) < 0) { addr = inet_makeaddr(inet_netof(sin->sin_addr), INADDR_ANY); @@ -263,13 +266,13 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) * initialization: create a socket, a broadcast address, and * preserialize the arguments into a send buffer. */ - if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { + if ((sock = _socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { perror("Cannot create socket for broadcast rpc"); stat = RPC_CANTSEND; goto done_broad; } #ifdef SO_BROADCAST - if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) { + if (_setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) { perror("Cannot set socket option SO_BROADCAST"); stat = RPC_CANTSEND; goto done_broad; @@ -332,7 +335,7 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) for (t.tv_sec = 4; t.tv_sec <= 14; t.tv_sec += 2) { for (i = 0; i < nets; i++) { baddr.sin_addr = addrs[i]; - if (sendto(sock, outbuf, outlen, 0, + if (_sendto(sock, outbuf, outlen, 0, (struct sockaddr *)&baddr, sizeof (struct sockaddr)) != outlen) { perror("Cannot send broadcast packet"); @@ -350,8 +353,8 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) msg.acpted_rply.ar_results.proc = xdr_rmtcallres; /* XXX we know the other bits are still clear */ FD_SET(sock, fds); - tv = t; /* for select() that copies back */ - switch (select(sock + 1, fds, NULL, NULL, &tv)) { + tv = t; /* for _select() that copies back */ + switch (_select(sock + 1, fds, NULL, NULL, &tv)) { case 0: /* timed out */ stat = RPC_TIMEDOUT; @@ -367,7 +370,7 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) } /* end of select results switch */ try_again: fromlen = sizeof(struct sockaddr); - inlen = recvfrom(sock, inbuf, UDPMSGSIZE, 0, + inlen = _recvfrom(sock, inbuf, UDPMSGSIZE, 0, (struct sockaddr *)&raddr, &fromlen); if (inlen < 0) { if (errno == EINTR) |