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
This commit is contained in:
parent
e0aa5ab718
commit
d201fe46e3
lib/libc
Makefile
alpha
amd64
compat-43
db
gen
Makefile.inc_pthread_stubs.c_spinlock_stub.c_thread_init.carc4random.cclosedir.cdaemon.cdevname.cdisklabel.cexec.cfstab.cfts-compat.cfts.cgetcap.cgetcwd.cgetlogin.cgetpass.cgetpwent.cgetvfsent.cisatty.clockf.cnlist.copendir.cpause.cpopen.cposixshm.cpselect.cpsignal.creaddir.cscandir.cseekdir.csetjmperr.csetmode.csiginterrupt.csignal.csleep.csyslog.ctelldir.ctelldir.htermios.cttyname.cusleep.cvis.cwait.cwait3.cwaitpid.c
gmon
i386
ia64
include
locale
net
@ -16,9 +16,22 @@ INSTALL_PIC_ARCHIVE= yes
|
||||
PRECIOUSLIB= yes
|
||||
|
||||
#
|
||||
# Don't bother hiding any syscalls (like libc_r does).
|
||||
# This is a list of syscalls that are renamed as _thread_sys_{syscall}
|
||||
# so that libpthread and libc_r can override and/or replace them.
|
||||
# In the case of libc_r replacement functions are provided, whereas
|
||||
# libpthread can both override and provide replacement functions.
|
||||
#
|
||||
HIDDEN_SYSCALLS=
|
||||
HIDDEN_SYSCALLS= _exit.o accept.o aio_suspend.o bind.o close.o connect.o \
|
||||
dup.o dup2.o execve.o fchflags.o fchmod.o fchown.o fcntl.o \
|
||||
flock.o fpathconf.o fstat.o fstatfs.o fsync.o getdirentries.o \
|
||||
getpeername.o getsockname.o getsockopt.o ioctl.o \
|
||||
kevent.o listen.o \
|
||||
msync.o nanosleep.o nfssvc.o open.o poll.o read.o readv.o recvfrom.o \
|
||||
recvmsg.o sched_yield.o select.o sendfile.o sendmsg.o sendto.o \
|
||||
setsockopt.o shutdown.o sigaction.o sigaltstack.o \
|
||||
sigpending.o sigprocmask.o sigreturn.o \
|
||||
sigsuspend.o socket.o \
|
||||
socketpair.o wait4.o write.o writev.o
|
||||
|
||||
#
|
||||
# Include make rules that are shared with libc_r.
|
||||
|
@ -83,50 +83,41 @@ END(label);
|
||||
* Design note:
|
||||
*
|
||||
* The macros PSYSCALL() and PRSYSCALL() are intended for use where a
|
||||
* syscall needs to be renamed in the threaded library. When building
|
||||
* a normal library, they default to the traditional SYSCALL() and
|
||||
* RSYSCALL(). This avoids the need to #ifdef _THREAD_SAFE everywhere
|
||||
* that the renamed function needs to be called.
|
||||
* syscall needs to be renamed in the threaded library.
|
||||
*/
|
||||
#ifdef _THREAD_SAFE
|
||||
/*
|
||||
* For the thread_safe versions, we prepend _thread_sys_ to the function
|
||||
* For the thread_safe versions, we prepend __sys_ to the function
|
||||
* name so that the 'C' wrapper can go around the real name.
|
||||
*/
|
||||
#define PNAME(name) __CONCAT(__sys_,name)
|
||||
|
||||
#define PCALL(name) \
|
||||
CALL(___CONCAT(_thread_sys_,name))
|
||||
CALL(PNAME(name))
|
||||
|
||||
#define PLEAF(name, args) \
|
||||
LEAF(___CONCAT(_thread_sys_,name),args)
|
||||
LEAF(PNAME(name),args)
|
||||
|
||||
#define PEND(name) \
|
||||
END(___CONCAT(_thread_sys_,name))
|
||||
END(PNAME(name))
|
||||
|
||||
#define PSYSCALL(name) \
|
||||
PLEAF(name,0); /* XXX # of args? */ \
|
||||
WEAK_ALIAS(name, PNAME(name)); \
|
||||
WEAK_ALIAS(__CONCAT(_,name), PNAME(name)); \
|
||||
CALLSYS_ERROR(name)
|
||||
|
||||
#define PRSYSCALL(name) \
|
||||
PLEAF(name,0); /* XXX # of args? */ \
|
||||
WEAK_ALIAS(name, PNAME(name)); \
|
||||
WEAK_ALIAS(__CONCAT(_,name), PNAME(name)); \
|
||||
CALLSYS_ERROR(name) \
|
||||
RET; \
|
||||
PEND(name)
|
||||
|
||||
#define PPSEUDO(label,name) \
|
||||
PLEAF(label,0); /* XXX # of args? */ \
|
||||
WEAK_ALIAS(label, PNAME(label)); \
|
||||
WEAK_ALIAS(__CONCAT(_,label), PNAME(label)); \
|
||||
CALLSYS_ERROR(name); \
|
||||
RET; \
|
||||
PEND(label)
|
||||
|
||||
#else
|
||||
/*
|
||||
* The non-threaded library defaults to traditional syscalls where
|
||||
* the function name matches the syscall name.
|
||||
*/
|
||||
#define PSYSCALL(x) SYSCALL(x)
|
||||
#define PRSYSCALL(x) RSYSCALL(x)
|
||||
#define PPSEUDO(x,y) PSEUDO(x,y)
|
||||
#define PLEAF(x,y) LEAF(x,y)
|
||||
#define PEND(x) END(x)
|
||||
#define PCALL(x) CALL(x)
|
||||
#endif
|
||||
|
@ -87,12 +87,8 @@ LEAF(_setjmp, 1)
|
||||
RET
|
||||
END(_setjmp)
|
||||
|
||||
#ifdef _THREAD_SAFE
|
||||
XLEAF(_longjmp, 2)
|
||||
LEAF(___longjmp, 2)
|
||||
#else
|
||||
XLEAF(___longjmp, 2)
|
||||
LEAF(_longjmp, 2)
|
||||
#endif
|
||||
LDGP(pv)
|
||||
ldq t0, ((31 + 4) * 8)(a0) /* magic in sc_regs[31] */
|
||||
ldiq t1, 0xacedbadd
|
||||
@ -127,8 +123,4 @@ botch:
|
||||
CALL(longjmperror)
|
||||
CALL(abort)
|
||||
RET /* "can't" get here... */
|
||||
#ifdef _THREAD_SAFE
|
||||
END(___longjmp)
|
||||
#else
|
||||
END(_longjmp)
|
||||
#endif
|
||||
|
@ -66,12 +66,12 @@ LEAF(setjmp, 1)
|
||||
lda a2, (71 * 8)(a0) /* oset: sc_reserved */
|
||||
mov zero, a1 /* set: NULL */
|
||||
addq a1, 1, a0 /* how: SIG_BLOCK */
|
||||
PCALL(sigprocmask) /* see what's blocked */
|
||||
CALL(_sigprocmask) /* see what's blocked */
|
||||
|
||||
lda sp, -24(sp) /* sizeof struct sigaltstack */
|
||||
mov zero, a0
|
||||
mov sp, a1
|
||||
PCALL(sigaltstack)
|
||||
CALL(_sigaltstack)
|
||||
ldl t0, 16(sp) /* offset of ss_flags */
|
||||
lda sp, 24(sp) /* sizeof struct sigaltstack */
|
||||
ldq ra, ((26 + 4) * 8)(s0) /* restore return address */
|
||||
@ -115,22 +115,14 @@ LEAF(setjmp, 1)
|
||||
RET
|
||||
END(setjmp)
|
||||
|
||||
#ifdef _THREAD_SAFE
|
||||
XLEAF(longjmp, 2)
|
||||
LEAF(__longjmp, 2)
|
||||
#else
|
||||
XLEAF(__longjmp, 2)
|
||||
LEAF(longjmp, 2)
|
||||
#endif
|
||||
LDGP(pv)
|
||||
stq a1, (( 0 + 4) * 8)(a0) /* save return value */
|
||||
PCALL(sigreturn) /* use sigreturn to return */
|
||||
CALL(_sigreturn) /* use sigreturn to return */
|
||||
|
||||
botch:
|
||||
CALL(longjmperror)
|
||||
CALL(abort)
|
||||
RET /* "can't" get here... */
|
||||
#ifdef _THREAD_SAFE
|
||||
END(__longjmp)
|
||||
#else
|
||||
END(longjmp)
|
||||
#endif
|
||||
|
@ -54,20 +54,12 @@ Lsavesig:
|
||||
jmp zero, setjmp
|
||||
END(sigsetjmp)
|
||||
|
||||
#ifdef _THREAD_SAFE
|
||||
XLEAF(siglongjmp, 2)
|
||||
LEAF(__siglongjmp, 2)
|
||||
#else
|
||||
XLEAF(__siglongjmp, 2)
|
||||
LEAF(siglongjmp, 2)
|
||||
#endif
|
||||
LDGP(pv)
|
||||
ldq t0, (81 * 8)(a0) /* get the mask */
|
||||
bne t0, Lrestoresig /* if !zero, restore signals */
|
||||
jmp zero, _longjmp
|
||||
jmp zero, ___longjmp
|
||||
Lrestoresig:
|
||||
jmp zero, longjmp
|
||||
#ifdef _THREAD_SAFE
|
||||
jmp zero, __longjmp
|
||||
END(__siglongjmp)
|
||||
#else
|
||||
END(siglongjmp)
|
||||
#endif
|
||||
|
@ -25,11 +25,13 @@
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include "SYS.h"
|
||||
|
||||
IMPORT(_logname_valid, 4) /* in getlogin() */
|
||||
IMPORT(_logname_valid, 4) /* in _getlogin() */
|
||||
|
||||
SYSCALL(setlogin)
|
||||
stl zero, _logname_valid /* clear it */
|
||||
|
@ -61,31 +61,28 @@
|
||||
* Design note:
|
||||
*
|
||||
* The macros PSYSCALL() and PRSYSCALL() are intended for use where a
|
||||
* syscall needs to be renamed in the threaded library. When building
|
||||
* a normal library, they default to the traditional SYSCALL() and
|
||||
* RSYSCALL(). This avoids the need to #ifdef _THREAD_SAFE everywhere
|
||||
* that the renamed function needs to be called.
|
||||
* syscall needs to be renamed in the threaded library.
|
||||
*/
|
||||
#ifdef _THREAD_SAFE
|
||||
/*
|
||||
* For the thread_safe versions, we prepend _thread_sys_ to the function
|
||||
* For the thread_safe versions, we prepend __sys_ to the function
|
||||
* name so that the 'C' wrapper can go around the real name.
|
||||
*/
|
||||
#define PSYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \
|
||||
ENTRY(__CONCAT(_thread_sys_,x)); \
|
||||
ENTRY(__CONCAT(__sys_,x)); \
|
||||
.weak CNAME(x); \
|
||||
.set CNAME(x),CNAME(__CONCAT(__sys_,x)); \
|
||||
.weak CNAME(__CONCAT(_,x)); \
|
||||
.set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
|
||||
lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b
|
||||
|
||||
#define PRSYSCALL(x) PSYSCALL(x); ret
|
||||
#define PPSEUDO(x,y) ENTRY(__CONCAT(_thread_sys_,x)); \
|
||||
|
||||
#define PPSEUDO(x,y) ENTRY(__CONCAT(__sys_,x)); \
|
||||
.weak CNAME(x); \
|
||||
.set CNAME(x),CNAME(__CONCAT(__sys_,x)); \
|
||||
.weak CNAME(__CONCAT(_,x)); \
|
||||
.set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
|
||||
lea __CONCAT(SYS_,y), %eax; KERNCALL; ret
|
||||
#else
|
||||
/*
|
||||
* The non-threaded library defaults to traditional syscalls where
|
||||
* the function name matches the syscall name.
|
||||
*/
|
||||
#define PSYSCALL(x) SYSCALL(x)
|
||||
#define PRSYSCALL(x) RSYSCALL(x)
|
||||
#define PPSEUDO(x,y) PSEUDO(x,y)
|
||||
#endif
|
||||
|
||||
#ifdef __ELF__
|
||||
#define KERNCALL int $0x80 /* Faster */
|
||||
|
@ -66,12 +66,9 @@ ENTRY(_setjmp)
|
||||
xorl %eax,%eax
|
||||
ret
|
||||
|
||||
#ifdef _THREAD_SAFE
|
||||
.weak CNAME(_longjmp)
|
||||
.set CNAME(_longjmp),CNAME(___longjmp)
|
||||
ENTRY(___longjmp)
|
||||
#else
|
||||
ALTENTRY(___longjmp)
|
||||
ENTRY(_longjmp)
|
||||
#endif
|
||||
movl 4(%esp),%edx
|
||||
movl 8(%esp),%eax
|
||||
movl 0(%edx),%ecx
|
||||
|
@ -61,11 +61,7 @@ ENTRY(setjmp)
|
||||
pushl %eax /* (sigset_t*)oset */
|
||||
pushl $0 /* (sigset_t*)set */
|
||||
pushl $1 /* SIG_BLOCK */
|
||||
#ifdef _THREAD_SAFE
|
||||
call PIC_PLT(CNAME(_thread_sys_sigprocmask))
|
||||
#else
|
||||
call PIC_PLT(CNAME(sigprocmask))
|
||||
#endif
|
||||
call PIC_PLT(CNAME(_sigprocmask))
|
||||
addl $12,%esp
|
||||
PIC_EPILOGUE
|
||||
movl 4(%esp),%ecx
|
||||
@ -80,10 +76,8 @@ ENTRY(setjmp)
|
||||
xorl %eax,%eax
|
||||
ret
|
||||
|
||||
#ifndef _THREAD_SAFE
|
||||
.weak CNAME(longjmp);
|
||||
.set CNAME(longjmp),CNAME(__longjmp);
|
||||
#endif
|
||||
.weak CNAME(longjmp)
|
||||
.set CNAME(longjmp),CNAME(__longjmp)
|
||||
ENTRY(__longjmp)
|
||||
movl 4(%esp),%edx
|
||||
PIC_PROLOGUE
|
||||
@ -91,11 +85,7 @@ ENTRY(__longjmp)
|
||||
leal 28(%edx), %eax
|
||||
pushl %eax /* (sigset_t*)set */
|
||||
pushl $3 /* SIG_SETMASK */
|
||||
#ifdef _THREAD_SAFE
|
||||
call PIC_PLT(CNAME(_thread_sys_sigprocmask))
|
||||
#else
|
||||
call PIC_PLT(CNAME(sigprocmask))
|
||||
#endif
|
||||
call PIC_PLT(CNAME(_sigprocmask))
|
||||
addl $12,%esp
|
||||
PIC_EPILOGUE
|
||||
movl 4(%esp),%edx
|
||||
|
@ -52,9 +52,6 @@
|
||||
* the renamed functions (introduced in gcc-2.5.3; previous versions
|
||||
* only supported *jmp with 0 or 1 leading underscores).
|
||||
*
|
||||
* Use sigprocmask() instead of sigblock() and sigsetmask(), and
|
||||
* check for and handle errors.
|
||||
*
|
||||
* Restore _all_ the registers and the signal mask atomically. Can
|
||||
* use sigreturn() if sigreturn() works.
|
||||
*/
|
||||
@ -70,11 +67,7 @@ ENTRY(sigsetjmp)
|
||||
pushl %eax /* (sigset_t*)oset */
|
||||
pushl $0 /* (sigset_t*)set */
|
||||
pushl $1 /* SIG_BLOCK */
|
||||
#ifdef _THREAD_SAFE
|
||||
call PIC_PLT(CNAME(_thread_sys_sigprocmask))
|
||||
#else
|
||||
call PIC_PLT(CNAME(sigprocmask))
|
||||
#endif
|
||||
call PIC_PLT(CNAME(_sigprocmask))
|
||||
addl $12,%esp
|
||||
PIC_EPILOGUE
|
||||
movl 4(%esp),%ecx
|
||||
@ -89,10 +82,8 @@ ENTRY(sigsetjmp)
|
||||
xorl %eax,%eax
|
||||
ret
|
||||
|
||||
#ifndef _THREAD_SAFE
|
||||
.weak CNAME(siglongjmp);
|
||||
.set CNAME(siglongjmp),CNAME(__siglongjmp);
|
||||
#endif
|
||||
.weak CNAME(siglongjmp);
|
||||
.set CNAME(siglongjmp),CNAME(__siglongjmp);
|
||||
ENTRY(__siglongjmp);
|
||||
movl 4(%esp),%edx
|
||||
cmpl $0,44(%edx)
|
||||
@ -102,11 +93,7 @@ ENTRY(__siglongjmp);
|
||||
leal 28(%edx), %eax
|
||||
pushl %eax /* (sigset_t*)set */
|
||||
pushl $3 /* SIG_SETMASK */
|
||||
#ifdef _THREAD_SAFE
|
||||
call PIC_PLT(CNAME(_thread_sys_sigprocmask))
|
||||
#else
|
||||
call PIC_PLT(CNAME(sigprocmask))
|
||||
#endif
|
||||
call PIC_PLT(CNAME(_sigprocmask))
|
||||
addl $12,%esp
|
||||
PIC_EPILOGUE
|
||||
movl 4(%esp),%edx
|
||||
|
@ -43,7 +43,7 @@
|
||||
|
||||
#include "SYS.h"
|
||||
|
||||
.globl CNAME(_logname_valid) /* in getlogin() */
|
||||
.globl CNAME(_logname_valid) /* in _getlogin() */
|
||||
|
||||
SYSCALL(setlogin)
|
||||
#ifdef PIC
|
||||
|
@ -51,12 +51,11 @@
|
||||
* %eax == pid of child in parent, %eax == pid of parent in child.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef _THREAD_SAFE
|
||||
ENTRY(_thread_sys_vfork)
|
||||
#else
|
||||
ENTRY(vfork)
|
||||
#endif
|
||||
.weak _vfork
|
||||
.set _vfork,__sys_vfork
|
||||
.weak vfork
|
||||
.set vfork,__sys_vfork
|
||||
ENTRY(__sys_vfork)
|
||||
popl %ecx /* my rta into ecx */
|
||||
lea SYS_vfork,%eax
|
||||
KERNCALL
|
||||
|
@ -37,20 +37,14 @@
|
||||
static char sccsid[] = "@(#)creat.c 8.1 (Berkeley) 6/2/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <fcntl.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
int
|
||||
#if __STDC__
|
||||
__creat(const char *path, mode_t mode)
|
||||
#else
|
||||
__creat(path, mode)
|
||||
char *path;
|
||||
mode_t mode;
|
||||
#endif
|
||||
{
|
||||
return(_open(path, O_WRONLY|O_CREAT|O_TRUNC, mode));
|
||||
}
|
||||
|
||||
#ifndef _THREAD_SAFE
|
||||
__weak_reference(__creat, creat);
|
||||
#endif
|
||||
__weak_reference(__creat, _creat);
|
||||
|
@ -41,8 +41,11 @@ static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <signal.h>
|
||||
#include "un-namespace.h"
|
||||
#include "libc_private.h"
|
||||
|
||||
int
|
||||
sigvec(signo, sv, osv)
|
||||
@ -62,7 +65,7 @@ sigvec(signo, sv, osv)
|
||||
} else
|
||||
sap = NULL;
|
||||
osap = osv != NULL ? &osa : NULL;
|
||||
ret = sigaction(signo, sap, osap);
|
||||
ret = _sigaction(signo, sap, osap);
|
||||
if (ret == 0 && osv != NULL) {
|
||||
osv->sv_handler = osa.sa_handler;
|
||||
osv->sv_flags = osa.sa_flags ^ SV_INTERRUPT;
|
||||
@ -80,7 +83,7 @@ sigsetmask(mask)
|
||||
|
||||
sigemptyset(&set);
|
||||
set.__bits[0] = mask;
|
||||
n = sigprocmask(SIG_SETMASK, &set, &oset);
|
||||
n = _sigprocmask(SIG_SETMASK, &set, &oset);
|
||||
if (n)
|
||||
return (n);
|
||||
return (oset.__bits[0]);
|
||||
@ -95,7 +98,7 @@ sigblock(mask)
|
||||
|
||||
sigemptyset(&set);
|
||||
set.__bits[0] = mask;
|
||||
n = sigprocmask(SIG_BLOCK, &set, &oset);
|
||||
n = _sigprocmask(SIG_BLOCK, &set, &oset);
|
||||
if (n)
|
||||
return (n);
|
||||
return (oset.__bits[0]);
|
||||
|
@ -40,6 +40,7 @@
|
||||
static char sccsid[] = "@(#)bt_close.c 8.7 (Berkeley) 8/17/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <errno.h>
|
||||
@ -47,6 +48,7 @@ static char sccsid[] = "@(#)bt_close.c 8.7 (Berkeley) 8/17/94";
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include <db.h>
|
||||
#include "btree.h"
|
||||
|
@ -48,6 +48,7 @@ static char sccsid[] = "@(#)bt_open.c 8.10 (Berkeley) 8/17/94";
|
||||
* is wholly independent of the Postgres code.
|
||||
*/
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -59,6 +60,7 @@ static char sccsid[] = "@(#)bt_open.c 8.10 (Berkeley) 8/17/94";
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include <db.h>
|
||||
#include "btree.h"
|
||||
@ -217,7 +219,7 @@ __bt_open(fname, flags, mode, openinfo, dflags)
|
||||
if (_fcntl(t->bt_fd, F_SETFD, 1) == -1)
|
||||
goto err;
|
||||
|
||||
if (fstat(t->bt_fd, &sb))
|
||||
if (_fstat(t->bt_fd, &sb))
|
||||
goto err;
|
||||
if (sb.st_size) {
|
||||
if ((nr = _read(t->bt_fd, &m, sizeof(BTMETA))) < 0)
|
||||
@ -399,10 +401,10 @@ tmp()
|
||||
sizeof(path), "%s/bt.XXXXXXXXXX", envtmp ? envtmp : "/tmp");
|
||||
|
||||
(void)sigfillset(&set);
|
||||
(void)sigprocmask(SIG_BLOCK, &set, &oset);
|
||||
(void)_sigprocmask(SIG_BLOCK, &set, &oset);
|
||||
if ((fd = mkstemp(path)) != -1)
|
||||
(void)unlink(path);
|
||||
(void)sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
(void)_sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
return(fd);
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
static char sccsid[] = "@(#)hash.c 8.9 (Berkeley) 6/16/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -52,6 +53,7 @@ static char sccsid[] = "@(#)hash.c 8.9 (Berkeley) 6/16/94";
|
||||
#ifdef DEBUG
|
||||
#include <assert.h>
|
||||
#endif
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include <db.h>
|
||||
#include "hash.h"
|
||||
@ -136,7 +138,7 @@ __hash_open(file, flags, mode, info, dflags)
|
||||
/* if the .db file is empty, and we had permission to create
|
||||
a new .db file, then reinitialize the database */
|
||||
if ((flags & O_CREAT) &&
|
||||
fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0)
|
||||
_fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0)
|
||||
new_table = 1;
|
||||
|
||||
(void)_fcntl(hashp->fp, F_SETFD, 1);
|
||||
@ -562,7 +564,8 @@ hash_put(dbp, key, data, flag)
|
||||
|
||||
hashp = (HTAB *)dbp->internal;
|
||||
if (flag && flag != R_NOOVERWRITE) {
|
||||
hashp->error = errno = EINVAL;
|
||||
hashp->error = EINVAL;
|
||||
errno = EINVAL;
|
||||
return (ERROR);
|
||||
}
|
||||
if ((hashp->flags & O_ACCMODE) == O_RDONLY) {
|
||||
|
@ -32,6 +32,8 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
@ -56,7 +58,6 @@ static char sccsid[] = "@(#)hash_buf.c 8.5 (Berkeley) 7/15/94";
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -56,6 +56,7 @@ static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94";
|
||||
* open_temp
|
||||
*/
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <errno.h>
|
||||
@ -68,6 +69,7 @@ static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94";
|
||||
#ifdef DEBUG
|
||||
#include <assert.h>
|
||||
#endif
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include <db.h>
|
||||
#include "hash.h"
|
||||
@ -866,12 +868,12 @@ open_temp(hashp)
|
||||
|
||||
/* Block signals; make sure file goes away at process exit. */
|
||||
(void)sigfillset(&set);
|
||||
(void)sigprocmask(SIG_BLOCK, &set, &oset);
|
||||
(void)_sigprocmask(SIG_BLOCK, &set, &oset);
|
||||
if ((hashp->fp = mkstemp(namestr)) != -1) {
|
||||
(void)unlink(namestr);
|
||||
(void)_fcntl(hashp->fp, F_SETFD, 1);
|
||||
}
|
||||
(void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL);
|
||||
(void)_sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL);
|
||||
return (hashp->fp != -1 ? 0 : -1);
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
static char sccsid[] = "@(#)mpool.c 8.5 (Berkeley) 7/26/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/stat.h>
|
||||
@ -46,6 +47,7 @@ static char sccsid[] = "@(#)mpool.c 8.5 (Berkeley) 7/26/94";
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include <db.h>
|
||||
|
||||
@ -76,7 +78,7 @@ mpool_open(key, fd, pagesize, maxcache)
|
||||
* XXX
|
||||
* We don't currently handle pipes, although we should.
|
||||
*/
|
||||
if (fstat(fd, &sb))
|
||||
if (_fstat(fd, &sb))
|
||||
return (NULL);
|
||||
if (!S_ISREG(sb.st_mode)) {
|
||||
errno = ESPIPE;
|
||||
|
@ -37,6 +37,7 @@
|
||||
static char sccsid[] = "@(#)rec_close.c 8.6 (Berkeley) 8/18/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/mman.h>
|
||||
@ -45,6 +46,7 @@ static char sccsid[] = "@(#)rec_close.c 8.6 (Berkeley) 8/18/94";
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include <db.h>
|
||||
#include "recno.h"
|
||||
@ -165,7 +167,7 @@ __rec_sync(dbp, flags)
|
||||
while (status == RET_SUCCESS) {
|
||||
iov[0].iov_base = data.data;
|
||||
iov[0].iov_len = data.size;
|
||||
if (writev(t->bt_rfd, iov, 2) != data.size + 1)
|
||||
if (_writev(t->bt_rfd, iov, 2) != data.size + 1)
|
||||
return (RET_ERROR);
|
||||
status = (dbp->seq)(dbp, &key, &data, R_NEXT);
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
static char sccsid[] = "@(#)rec_open.c 8.10 (Berkeley) 9/1/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
@ -50,6 +51,7 @@ static char sccsid[] = "@(#)rec_open.c 8.10 (Berkeley) 9/1/94";
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include <db.h>
|
||||
#include "recno.h"
|
||||
@ -146,7 +148,7 @@ slow: if ((t->bt_rfp = fdopen(rfd, "r")) == NULL)
|
||||
goto einval;
|
||||
}
|
||||
|
||||
if (fstat(rfd, &sb))
|
||||
if (_fstat(rfd, &sb))
|
||||
goto err;
|
||||
/*
|
||||
* Kluge -- we'd like to test to see if the file is too
|
||||
|
@ -4,8 +4,8 @@
|
||||
# machine-independent gen sources
|
||||
.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/gen ${.CURDIR}/../libc/gen
|
||||
|
||||
SRCS+= _rand48.c _spinlock_stub.c alarm.c arc4random.c assert.c \
|
||||
basename.c \
|
||||
SRCS+= _pthread_stubs.c _rand48.c _spinlock_stub.c _thread_init.c \
|
||||
alarm.c arc4random.c assert.c basename.c \
|
||||
clock.c closedir.c confstr.c \
|
||||
crypt.c ctermid.c daemon.c devname.c dirname.c disklabel.c \
|
||||
dlfcn.c drand48.c erand48.c err.c errlst.c \
|
||||
|
131
lib/libc/gen/_pthread_stubs.c
Normal file
131
lib/libc/gen/_pthread_stubs.c
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2001 Daniel Eischen <deischen@FreeBSD.org>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
/*
|
||||
* Weak symbols: All libc internal usage of these functions should
|
||||
* use the weak symbol versions (_pthread_XXX). If libpthread is
|
||||
* linked, it will override these functions with (non-weak) routines.
|
||||
* The _pthread_XXX functions are provided solely for internal libc
|
||||
* usage to avoid unwanted cancellation points and to differentiate
|
||||
* between application locks and libc locks (threads holding the
|
||||
* latter can't be allowed to exit/terminate).
|
||||
*/
|
||||
#pragma weak _pthread_getspecific=_pthread_getspecific_stub
|
||||
#pragma weak _pthread_key_create=_pthread_key_create_stub
|
||||
#pragma weak _pthread_key_delete=_pthread_key_delete_stub
|
||||
#pragma weak _pthread_mutex_destroy=_pthread_mutex_destroy_stub
|
||||
#pragma weak _pthread_mutex_init=_pthread_mutex_init_stub
|
||||
#pragma weak _pthread_mutex_lock=_pthread_mutex_lock_stub
|
||||
#pragma weak _pthread_mutex_trylock=_pthread_mutex_trylock_stub
|
||||
#pragma weak _pthread_mutex_unlock=_pthread_mutex_unlock_stub
|
||||
#pragma weak _pthread_mutexattr_init=_pthread_mutexattr_init_stub
|
||||
#pragma weak _pthread_mutexattr_destroy=_pthread_mutexattr_destroy_stub
|
||||
#pragma weak _pthread_mutexattr_settype=_pthread_mutexattr_settype_stub
|
||||
#pragma weak _pthread_once=_pthread_once_stub
|
||||
#pragma weak _pthread_setspecific=_pthread_setspecific_stub
|
||||
|
||||
|
||||
void *
|
||||
_pthread_getspecific_stub(pthread_key_t key)
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int
|
||||
_pthread_key_create_stub(pthread_key_t *key, void (*destructor) (void *))
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
_pthread_key_delete_stub(pthread_key_t key)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
_pthread_mutex_destroy_stub(pthread_mutex_t *mattr)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
_pthread_mutex_init_stub(pthread_mutex_t *mutex, const pthread_mutexattr_t *mattr)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
_pthread_mutex_lock_stub(pthread_mutex_t *mutex)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
_pthread_mutex_trylock_stub(pthread_mutex_t *mutex)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
_pthread_mutex_unlock_stub(pthread_mutex_t *mutex)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
_pthread_mutexattr_init_stub(pthread_mutexattr_t *mattr)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
_pthread_mutexattr_destroy_stub(pthread_mutexattr_t *mattr)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
_pthread_mutexattr_settype_stub(pthread_mutexattr_t *mattr, int type)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
_pthread_once_stub(pthread_once_t *once_control, void (*init_routine) (void))
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
_pthread_setspecific_stub(pthread_key_t key, const void *value)
|
||||
{
|
||||
return (0);
|
||||
}
|
@ -35,17 +35,26 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Don't build these stubs into libc_r: */
|
||||
#ifndef _THREAD_SAFE
|
||||
#include "spinlock.h"
|
||||
|
||||
/*
|
||||
* Declare weak references in case the application is not linked
|
||||
* Declare weak definitions in case the application is not linked
|
||||
* with libpthread.
|
||||
*/
|
||||
#pragma weak _atomic_lock=_atomic_lock_stub
|
||||
#pragma weak _spinlock=_spinlock_stub
|
||||
#pragma weak _spinlock_debug=_spinlock_debug_stub
|
||||
|
||||
/*
|
||||
* This function is a stub for the _atomic_lock function in libpthread.
|
||||
*/
|
||||
long
|
||||
_atomic_lock_stub(volatile long *lck)
|
||||
{
|
||||
return (0L);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function is a stub for the spinlock function in libpthread.
|
||||
*/
|
||||
@ -61,4 +70,3 @@ void
|
||||
_spinlock_debug_stub(spinlock_t *lck, char *fname, int lineno)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
38
lib/libc/gen/_thread_init.c
Normal file
38
lib/libc/gen/_thread_init.c
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2001 Daniel Eischen <deischen@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS''
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#pragma weak _thread_init=_thread_init_stub
|
||||
#pragma weak _thread_autoinit_dummy_decl=_thread_autoinit_dummy_decl_stub
|
||||
|
||||
int _thread_autoinit_dummy_decl_stub = 0;
|
||||
|
||||
void
|
||||
_thread_init_stub(void)
|
||||
{
|
||||
/* This is just a stub; there is nothing to do. */
|
||||
}
|
@ -25,11 +25,13 @@
|
||||
* RC4 is a registered trademark of RSA Laboratories.
|
||||
*/
|
||||
|
||||
#include "namespace.h"
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
struct arc4_stream {
|
||||
u_int8_t i;
|
||||
|
@ -37,11 +37,15 @@
|
||||
static char sccsid[] = "@(#)closedir.c 8.1 (Berkeley) 6/10/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include "libc_private.h"
|
||||
#include "telldir.h"
|
||||
|
||||
/*
|
||||
@ -53,12 +57,18 @@ closedir(dirp)
|
||||
{
|
||||
int fd;
|
||||
|
||||
seekdir(dirp, dirp->dd_rewind); /* free seekdir storage */
|
||||
if (__isthreaded)
|
||||
_pthread_mutex_lock((pthread_mutex_t *)&dirp->dd_lock);
|
||||
_seekdir(dirp, dirp->dd_rewind); /* free seekdir storage */
|
||||
fd = dirp->dd_fd;
|
||||
dirp->dd_fd = -1;
|
||||
dirp->dd_loc = 0;
|
||||
free((void *)dirp->dd_buf);
|
||||
_reclaim_telldir(dirp);
|
||||
if (__isthreaded) {
|
||||
_pthread_mutex_unlock((pthread_mutex_t *)&dirp->dd_lock);
|
||||
_pthread_mutex_destroy((pthread_mutex_t *)&dirp->dd_lock);
|
||||
}
|
||||
free((void *)dirp);
|
||||
return(_close(fd));
|
||||
}
|
||||
|
@ -37,9 +37,11 @@
|
||||
static char sccsid[] = "@(#)daemon.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <fcntl.h>
|
||||
#include <paths.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
int
|
||||
daemon(nochdir, noclose)
|
||||
@ -63,9 +65,9 @@ daemon(nochdir, noclose)
|
||||
(void)chdir("/");
|
||||
|
||||
if (!noclose && (fd = _open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
|
||||
(void)dup2(fd, STDIN_FILENO);
|
||||
(void)dup2(fd, STDOUT_FILENO);
|
||||
(void)dup2(fd, STDERR_FILENO);
|
||||
(void)_dup2(fd, STDIN_FILENO);
|
||||
(void)_dup2(fd, STDOUT_FILENO);
|
||||
(void)_dup2(fd, STDERR_FILENO);
|
||||
if (fd > 2)
|
||||
(void)_close(fd);
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ static char sccsid[] = "@(#)devname.c 8.2 (Berkeley) 4/29/95";
|
||||
|
||||
#include <db.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <paths.h>
|
||||
#include <stdio.h>
|
||||
|
@ -45,7 +45,6 @@ static const char rcsid[] =
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -41,6 +41,7 @@ static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@ -56,6 +57,7 @@ static const char rcsid[] =
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
#include "un-namespace.h"
|
||||
|
||||
extern char **environ;
|
||||
|
||||
@ -97,7 +99,7 @@ execl(name, arg, va_alist)
|
||||
while ((argv[n] = va_arg(ap, char *)) != NULL)
|
||||
n++;
|
||||
va_end(ap);
|
||||
return (execve(name, argv, environ));
|
||||
return (_execve(name, argv, environ));
|
||||
}
|
||||
|
||||
int
|
||||
@ -139,7 +141,7 @@ execle(name, arg, va_alist)
|
||||
n++;
|
||||
envp = va_arg(ap, char **);
|
||||
va_end(ap);
|
||||
return (execve(name, argv, envp));
|
||||
return (_execve(name, argv, envp));
|
||||
}
|
||||
|
||||
int
|
||||
@ -189,7 +191,7 @@ execv(name, argv)
|
||||
const char *name;
|
||||
char * const *argv;
|
||||
{
|
||||
(void)execve(name, argv, environ);
|
||||
(void)_execve(name, argv, environ);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@ -260,7 +262,7 @@ execvp(name, argv)
|
||||
bcopy(name, buf + lp + 1, ln);
|
||||
buf[lp + ln + 1] = '\0';
|
||||
|
||||
retry: (void)execve(bp, argv, environ);
|
||||
retry: (void)_execve(bp, argv, environ);
|
||||
switch(errno) {
|
||||
case E2BIG:
|
||||
goto done;
|
||||
@ -279,7 +281,7 @@ retry: (void)execve(bp, argv, environ);
|
||||
memp[0] = "sh";
|
||||
memp[1] = bp;
|
||||
bcopy(argv + 1, memp + 2, cnt * sizeof(char *));
|
||||
(void)execve(_PATH_BSHELL, memp, environ);
|
||||
(void)_execve(_PATH_BSHELL, memp, environ);
|
||||
goto done;
|
||||
case ENOMEM:
|
||||
goto done;
|
||||
|
@ -42,6 +42,7 @@ static char rcsid[] =
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
@ -53,6 +54,7 @@ static char rcsid[] =
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
static FILE *_fs_fp;
|
||||
static struct fstab _fs_fstab;
|
||||
|
@ -43,6 +43,7 @@ static char rcsid[] = "$FreeBSD$";
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -53,6 +54,7 @@ static char rcsid[] = "$FreeBSD$";
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
static FTSENT *fts_alloc __P((FTS *, char *, int));
|
||||
static FTSENT *fts_build __P((FTS *, int));
|
||||
@ -1082,7 +1084,7 @@ fts_safe_changedir(sp, p, fd)
|
||||
return (0);
|
||||
if (fd < 0 && (newfd = _open(p->fts_accpath, O_RDONLY, 0)) < 0)
|
||||
return (-1);
|
||||
if (fstat(newfd, &sb)) {
|
||||
if (_fstat(newfd, &sb)) {
|
||||
ret = -1;
|
||||
goto bail;
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ static char rcsid[] = "$FreeBSD$";
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -53,6 +54,7 @@ static char rcsid[] = "$FreeBSD$";
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
static FTSENT *fts_alloc __P((FTS *, char *, int));
|
||||
static FTSENT *fts_build __P((FTS *, int));
|
||||
@ -1082,7 +1084,7 @@ fts_safe_changedir(sp, p, fd)
|
||||
return (0);
|
||||
if (fd < 0 && (newfd = _open(p->fts_accpath, O_RDONLY, 0)) < 0)
|
||||
return (-1);
|
||||
if (fstat(newfd, &sb)) {
|
||||
if (_fstat(newfd, &sb)) {
|
||||
ret = -1;
|
||||
goto bail;
|
||||
}
|
||||
|
@ -40,10 +40,10 @@
|
||||
static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <db.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
@ -51,6 +51,9 @@ static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94";
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include <db.h>
|
||||
|
||||
#define BFRAG 1024
|
||||
#define BSIZE 1024
|
||||
|
@ -37,6 +37,7 @@
|
||||
static char sccsid[] = "@(#)getcwd.c 8.5 (Berkeley) 2/7/95";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@ -47,6 +48,7 @@ static char sccsid[] = "@(#)getcwd.c 8.5 (Berkeley) 2/7/95";
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#define ISDOT(dp) \
|
||||
(dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || \
|
||||
@ -166,7 +168,7 @@ getcwd(pt, size)
|
||||
*bup = '\0';
|
||||
|
||||
/* Open and stat parent directory. */
|
||||
if (!(dir = opendir(up)) || fstat(dirfd(dir), &s))
|
||||
if (!(dir = opendir(up)) || _fstat(dirfd(dir), &s))
|
||||
goto err;
|
||||
|
||||
/* Add trailing slash for next directory. */
|
||||
|
@ -44,22 +44,19 @@ static char sccsid[] = "@(#)getlogin.c 8.1 (Berkeley) 6/4/93";
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "namespace.h"
|
||||
#include <pthread.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include <libc_private.h>
|
||||
|
||||
#ifndef _THREAD_SAFE
|
||||
#define THREAD_LOCK()
|
||||
#define THREAD_UNLOCK()
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#include "pthread_private.h"
|
||||
static struct pthread_mutex logname_lock = PTHREAD_MUTEX_STATIC_INITIALIZER;
|
||||
static pthread_mutex_t logname_mutex = &logname_lock;
|
||||
#define THREAD_LOCK() if (__isthreaded) pthread_mutex_lock(&logname_mutex)
|
||||
#define THREAD_UNLOCK() if (__isthreaded) pthread_mutex_unlock(&logname_mutex)
|
||||
#endif /* _THREAD_SAFE */
|
||||
#define THREAD_LOCK() if (__isthreaded) _pthread_mutex_lock(&logname_mutex)
|
||||
#define THREAD_UNLOCK() if (__isthreaded) _pthread_mutex_unlock(&logname_mutex)
|
||||
|
||||
int _logname_valid; /* known to setlogin() */
|
||||
extern int _getlogin(char *, int);
|
||||
|
||||
int _logname_valid; /* known to setlogin() */
|
||||
static pthread_mutex_t logname_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static char *
|
||||
getlogin_basic(int *status)
|
||||
@ -68,7 +65,7 @@ getlogin_basic(int *status)
|
||||
|
||||
if (_logname_valid == 0) {
|
||||
#ifdef __NETBSD_SYSCALLS
|
||||
if (__getlogin(logname, sizeof(logname) - 1) < 0) {
|
||||
if (_getlogin(logname, sizeof(logname) - 1) < 0) {
|
||||
#else
|
||||
if (_getlogin(logname, sizeof(logname)) < 0) {
|
||||
#endif
|
||||
|
@ -37,6 +37,7 @@
|
||||
static char sccsid[] = "@(#)getpass.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/termios.h>
|
||||
#include <signal.h>
|
||||
|
||||
@ -44,6 +45,7 @@ static char sccsid[] = "@(#)getpass.c 8.1 (Berkeley) 6/4/93";
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
static struct termios oterm, term;
|
||||
static FILE *fp;
|
||||
@ -74,7 +76,7 @@ getpass(prompt)
|
||||
sigemptyset(&nset);
|
||||
sigaddset(&nset, SIGINT);
|
||||
sigaddset(&nset, SIGTSTP);
|
||||
(void)sigprocmask(SIG_BLOCK, &nset, &oset);
|
||||
(void)_sigprocmask(SIG_BLOCK, &nset, &oset);
|
||||
|
||||
(void)tcgetattr(fileno(fp), &oterm);
|
||||
term = oterm;
|
||||
@ -89,7 +91,7 @@ getpass(prompt)
|
||||
(void)_write(fileno(outfp), "\n", 1);
|
||||
(void)tcsetattr(fileno(fp), TCSAFLUSH|TCSASOFT, &oterm);
|
||||
|
||||
(void)sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
(void)_sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
|
||||
if (fp != stdin)
|
||||
(void)fclose(fp);
|
||||
|
@ -40,6 +40,7 @@ static const char *rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "un-namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <fcntl.h>
|
||||
#include <db.h>
|
||||
@ -62,6 +63,7 @@ static const char *rcsid[] =
|
||||
#include <rpcsvc/yp_prot.h>
|
||||
#include <rpcsvc/ypclnt.h>
|
||||
#endif
|
||||
#include "un-namespace.h"
|
||||
|
||||
extern void setnetgrent __P((char *));
|
||||
extern int getnetgrent __P((char **, char **, char **));
|
||||
|
@ -2,6 +2,8 @@
|
||||
* getvfsent.c - get a listing of installed filesystems
|
||||
* Written September 1994 by Garrett A. Wollman
|
||||
* This file is in the public domain.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -14,7 +16,6 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <paths.h>
|
||||
|
||||
/* XXX hide some compatibility problems. */
|
||||
|
@ -29,6 +29,8 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
@ -37,10 +39,6 @@ static char sccsid[] = "@(#)isatty.c 8.1 (Berkeley) 6/4/93";
|
||||
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#ifdef _THREAD_SAFE
|
||||
#include <pthread.h>
|
||||
#include "pthread_private.h"
|
||||
#endif
|
||||
|
||||
int
|
||||
isatty(fd)
|
||||
@ -49,15 +47,6 @@ isatty(fd)
|
||||
int retval;
|
||||
struct termios t;
|
||||
|
||||
#ifdef _THREAD_SAFE
|
||||
if (_FD_LOCK(fd, FD_READ, NULL) == 0) {
|
||||
#endif
|
||||
retval = (tcgetattr(fd, &t) != -1);
|
||||
#ifdef _THREAD_SAFE
|
||||
_FD_UNLOCK(fd, FD_READ);
|
||||
} else {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
retval = (tcgetattr(fd, &t) != -1);
|
||||
return(retval);
|
||||
}
|
||||
|
@ -43,9 +43,11 @@ static const char rcsid[]=
|
||||
"$FreeBSD$";
|
||||
#endif
|
||||
|
||||
#include "namespace.h"
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
int
|
||||
lockf(filedes, function, size)
|
||||
|
@ -37,6 +37,7 @@
|
||||
static char sccsid[] = "@(#)nlist.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
@ -47,6 +48,7 @@ static char sccsid[] = "@(#)nlist.c 8.1 (Berkeley) 6/4/93";
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#define _NLIST_DO_AOUT
|
||||
#define _NLIST_DO_ELF
|
||||
@ -117,7 +119,7 @@ __aout_fdnlist(fd, list)
|
||||
struct stat st;
|
||||
|
||||
/* check that file is at least as large as struct exec! */
|
||||
if ((fstat(fd, &st) < 0) || (st.st_size < sizeof(struct exec)))
|
||||
if ((_fstat(fd, &st) < 0) || (st.st_size < sizeof(struct exec)))
|
||||
return (-1);
|
||||
|
||||
/* Check for files too large to mmap. */
|
||||
@ -257,7 +259,7 @@ __elf_fdnlist(fd, list)
|
||||
if (lseek(fd, (off_t)0, SEEK_SET) == -1 ||
|
||||
_read(fd, &ehdr, sizeof(Elf_Ehdr)) != sizeof(Elf_Ehdr) ||
|
||||
!__elf_is_okay__(&ehdr) ||
|
||||
fstat(fd, &st) < 0)
|
||||
_fstat(fd, &st) < 0)
|
||||
return (-1);
|
||||
|
||||
/* calculate section header table size */
|
||||
|
@ -37,6 +37,7 @@
|
||||
static char sccsid[] = "@(#)opendir.c 8.8 (Berkeley) 5/1/95";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
@ -46,9 +47,9 @@ static char sccsid[] = "@(#)opendir.c 8.8 (Berkeley) 5/1/95";
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include "telldir.h"
|
||||
|
||||
/*
|
||||
* Open a directory.
|
||||
*/
|
||||
@ -56,7 +57,6 @@ DIR *
|
||||
opendir(name)
|
||||
const char *name;
|
||||
{
|
||||
|
||||
return (__opendir2(name, DTF_HIDEW|DTF_NODUP));
|
||||
}
|
||||
|
||||
@ -73,8 +73,8 @@ __opendir2(name, flags)
|
||||
struct stat statb;
|
||||
|
||||
/*
|
||||
* stat() before open() because opening of special files may be
|
||||
* harmful. fstat() after open because the file may have changed.
|
||||
* stat() before _open() because opening of special files may be
|
||||
* harmful. _fstat() after open because the file may have changed.
|
||||
*/
|
||||
if (stat(name, &statb) != 0)
|
||||
return (NULL);
|
||||
@ -85,7 +85,7 @@ __opendir2(name, flags)
|
||||
if ((fd = _open(name, O_RDONLY | O_NONBLOCK)) == -1)
|
||||
return (NULL);
|
||||
dirp = NULL;
|
||||
if (fstat(fd, &statb) != 0)
|
||||
if (_fstat(fd, &statb) != 0)
|
||||
goto fail;
|
||||
if (!S_ISDIR(statb.st_mode)) {
|
||||
errno = ENOTDIR;
|
||||
@ -102,7 +102,7 @@ __opendir2(name, flags)
|
||||
/*
|
||||
* Use the system page size if that is a multiple of DIRBLKSIZ.
|
||||
* Hopefully this can be a big win someday by allowing page
|
||||
* trades to user space to be done by getdirentries().
|
||||
* trades to user space to be done by _getdirentries().
|
||||
*/
|
||||
incr = getpagesize();
|
||||
if ((incr % DIRBLKSIZ) != 0)
|
||||
@ -114,7 +114,7 @@ __opendir2(name, flags)
|
||||
if (flags & DTF_NODUP) {
|
||||
struct statfs sfb;
|
||||
|
||||
if (fstatfs(fd, &sfb) < 0)
|
||||
if (_fstatfs(fd, &sfb) < 0)
|
||||
goto fail;
|
||||
unionstack = !strcmp(sfb.f_fstypename, "union");
|
||||
} else {
|
||||
@ -140,7 +140,7 @@ __opendir2(name, flags)
|
||||
do {
|
||||
/*
|
||||
* Always make at least DIRBLKSIZ bytes
|
||||
* available to getdirentries
|
||||
* available to _getdirentries
|
||||
*/
|
||||
if (space < DIRBLKSIZ) {
|
||||
space += incr;
|
||||
@ -151,7 +151,7 @@ __opendir2(name, flags)
|
||||
ddptr = buf + (len - space);
|
||||
}
|
||||
|
||||
n = getdirentries(fd, ddptr, space, &dirp->dd_seek);
|
||||
n = _getdirentries(fd, ddptr, space, &dirp->dd_seek);
|
||||
if (n > 0) {
|
||||
ddptr += n;
|
||||
space -= n;
|
||||
@ -265,6 +265,7 @@ __opendir2(name, flags)
|
||||
dirp->dd_loc = 0;
|
||||
dirp->dd_fd = fd;
|
||||
dirp->dd_flags = flags;
|
||||
dirp->dd_lock = NULL;
|
||||
|
||||
/*
|
||||
* Set up seek point for rewinddir.
|
||||
|
@ -48,7 +48,5 @@ __pause()
|
||||
{
|
||||
return sigpause(sigblock(0L));
|
||||
}
|
||||
|
||||
#ifndef _THREAD_SAFE
|
||||
__weak_reference(__pause, pause);
|
||||
#endif
|
||||
__weak_reference(__pause, _pause);
|
||||
|
@ -40,6 +40,7 @@
|
||||
static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
@ -50,6 +51,7 @@ static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95";
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <paths.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
extern char **environ;
|
||||
|
||||
@ -70,7 +72,7 @@ popen(command, type)
|
||||
struct pid *p;
|
||||
|
||||
/*
|
||||
* Lite2 introduced two-way popen() pipes using socketpair().
|
||||
* Lite2 introduced two-way popen() pipes using _socketpair().
|
||||
* FreeBSD's pipe() is bidirectional, so we use that.
|
||||
*/
|
||||
if (strchr(type, '+')) {
|
||||
@ -105,7 +107,7 @@ popen(command, type)
|
||||
case 0: /* Child. */
|
||||
if (*type == 'r') {
|
||||
/*
|
||||
* The dup2() to STDIN_FILENO is repeated to avoid
|
||||
* The _dup2() to STDIN_FILENO is repeated to avoid
|
||||
* writing to pdes[1], which might corrupt the
|
||||
* parent's copy. This isn't good enough in
|
||||
* general, since the _exit() is no return, so
|
||||
@ -114,15 +116,15 @@ popen(command, type)
|
||||
*/
|
||||
(void)_close(pdes[0]);
|
||||
if (pdes[1] != STDOUT_FILENO) {
|
||||
(void)dup2(pdes[1], STDOUT_FILENO);
|
||||
(void)_dup2(pdes[1], STDOUT_FILENO);
|
||||
(void)_close(pdes[1]);
|
||||
if (twoway)
|
||||
(void)dup2(STDOUT_FILENO, STDIN_FILENO);
|
||||
(void)_dup2(STDOUT_FILENO, STDIN_FILENO);
|
||||
} else if (twoway && (pdes[1] != STDIN_FILENO))
|
||||
(void)dup2(pdes[1], STDIN_FILENO);
|
||||
(void)_dup2(pdes[1], STDIN_FILENO);
|
||||
} else {
|
||||
if (pdes[0] != STDIN_FILENO) {
|
||||
(void)dup2(pdes[0], STDIN_FILENO);
|
||||
(void)_dup2(pdes[0], STDIN_FILENO);
|
||||
(void)_close(pdes[0]);
|
||||
}
|
||||
(void)_close(pdes[1]);
|
||||
@ -130,7 +132,7 @@ popen(command, type)
|
||||
for (p = pidlist; p; p = p->next) {
|
||||
(void)_close(fileno(p->fp));
|
||||
}
|
||||
execve(_PATH_BSHELL, argv, environ);
|
||||
_execve(_PATH_BSHELL, argv, environ);
|
||||
_exit(127);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
@ -36,6 +37,7 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
int
|
||||
shm_open(const char *path, int flags, mode_t mode)
|
||||
@ -48,7 +50,7 @@ shm_open(const char *path, int flags, mode_t mode)
|
||||
|
||||
fd = _open(path, flags, mode);
|
||||
if (fd != -1) {
|
||||
if (fstat(fd, &stab) != 0 || !S_ISREG(stab.st_mode)) {
|
||||
if (_fstat(fd, &stab) != 0 || !S_ISREG(stab.st_mode)) {
|
||||
_close(fd);
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
|
@ -29,11 +29,13 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/select.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
/*
|
||||
* Emulate the POSIX 1003.1g-2000 `pselect' interface. This is the
|
||||
@ -56,15 +58,15 @@ pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds,
|
||||
tvp = 0;
|
||||
|
||||
if (mask != 0) {
|
||||
rv = sigprocmask(SIG_SETMASK, mask, &omask);
|
||||
rv = _sigprocmask(SIG_SETMASK, mask, &omask);
|
||||
if (rv != 0)
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = select(count, rfds, wfds, efds, tvp);
|
||||
rv = _select(count, rfds, wfds, efds, tvp);
|
||||
if (mask != 0) {
|
||||
sverrno = errno;
|
||||
sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0);
|
||||
_sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0);
|
||||
errno = sverrno;
|
||||
}
|
||||
|
||||
|
@ -41,9 +41,11 @@ static char sccsid[] = "@(#)psignal.c 8.1 (Berkeley) 6/4/93";
|
||||
* Print the name of the signal indicated
|
||||
* along with the supplied message.
|
||||
*/
|
||||
#include "namespace.h"
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
void
|
||||
psignal(sig, s)
|
||||
|
@ -38,20 +38,21 @@
|
||||
static char sccsid[] = "@(#)readdir.c 8.3 (Berkeley) 9/29/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#ifdef _THREAD_SAFE
|
||||
#include <pthread.h>
|
||||
#include "pthread_private.h"
|
||||
#endif /* _THREAD_SAFE */
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include "libc_private.h"
|
||||
|
||||
/*
|
||||
* get next entry in a directory.
|
||||
*/
|
||||
struct dirent *
|
||||
readdir(dirp)
|
||||
_readdir_unlocked(dirp)
|
||||
DIR *dirp;
|
||||
{
|
||||
struct dirent *dp;
|
||||
@ -63,7 +64,7 @@ readdir(dirp)
|
||||
dirp->dd_loc = 0;
|
||||
}
|
||||
if (dirp->dd_loc == 0 && !(dirp->dd_flags & __DTF_READALL)) {
|
||||
dirp->dd_size = getdirentries(dirp->dd_fd,
|
||||
dirp->dd_size = _getdirentries(dirp->dd_fd,
|
||||
dirp->dd_buf, dirp->dd_len, &dirp->dd_seek);
|
||||
if (dirp->dd_size <= 0)
|
||||
return (NULL);
|
||||
@ -83,6 +84,22 @@ readdir(dirp)
|
||||
}
|
||||
}
|
||||
|
||||
struct dirent *
|
||||
readdir(dirp)
|
||||
DIR *dirp;
|
||||
{
|
||||
struct dirent *dp;
|
||||
|
||||
if (__isthreaded) {
|
||||
_pthread_mutex_lock((pthread_mutex_t *)&dirp->dd_lock);
|
||||
dp = _readdir_unlocked(dirp);
|
||||
_pthread_mutex_unlock((pthread_mutex_t *)&dirp->dd_lock);
|
||||
}
|
||||
else
|
||||
dp = _readdir_unlocked(dirp);
|
||||
return (dp);
|
||||
}
|
||||
|
||||
int
|
||||
readdir_r(dirp, entry, result)
|
||||
DIR *dirp;
|
||||
@ -91,32 +108,23 @@ readdir_r(dirp, entry, result)
|
||||
{
|
||||
struct dirent *dp;
|
||||
int saved_errno;
|
||||
#ifdef _THREAD_SAFE
|
||||
int ret;
|
||||
|
||||
if ((ret = _FD_LOCK(dirp->dd_fd, FD_READ, NULL)) != 0)
|
||||
return (ret);
|
||||
#endif
|
||||
|
||||
saved_errno = errno;
|
||||
errno = 0;
|
||||
dp = readdir(dirp);
|
||||
if (errno != 0) {
|
||||
if (dp == NULL) {
|
||||
#ifdef _THREAD_SAFE
|
||||
_FD_UNLOCK(dirp->dd_fd, FD_READ);
|
||||
#endif
|
||||
return (errno);
|
||||
}
|
||||
} else
|
||||
errno = saved_errno;
|
||||
|
||||
if (dp != NULL)
|
||||
if (__isthreaded) {
|
||||
_pthread_mutex_lock((pthread_mutex_t *)&dirp->dd_lock);
|
||||
if ((dp = _readdir_unlocked(dirp)) != NULL)
|
||||
memcpy(entry, dp, sizeof *entry);
|
||||
_pthread_mutex_unlock((pthread_mutex_t *)&dirp->dd_lock);
|
||||
}
|
||||
else if ((dp = _readdir_unlocked(dirp)) != NULL)
|
||||
memcpy(entry, dp, sizeof *entry);
|
||||
|
||||
#ifdef _THREAD_SAFE
|
||||
_FD_UNLOCK(dirp->dd_fd, FD_READ);
|
||||
#endif
|
||||
if (errno != 0) {
|
||||
if (dp == NULL)
|
||||
return (errno);
|
||||
} else
|
||||
errno = saved_errno;
|
||||
|
||||
if (dp != NULL)
|
||||
*result = entry;
|
||||
|
@ -29,6 +29,8 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
@ -42,11 +44,13 @@ static char sccsid[] = "@(#)scandir.c 8.3 (Berkeley) 1/2/94";
|
||||
* struct dirent (through namelist). Returns -1 if there were any errors.
|
||||
*/
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
/*
|
||||
* The DIRSIZ macro is the minimum record length which will hold the directory
|
||||
@ -74,7 +78,7 @@ scandir(dirname, namelist, select, dcomp)
|
||||
|
||||
if ((dirp = opendir(dirname)) == NULL)
|
||||
return(-1);
|
||||
if (fstat(dirp->dd_fd, &stb) < 0)
|
||||
if (_fstat(dirp->dd_fd, &stb) < 0)
|
||||
goto fail;
|
||||
|
||||
/*
|
||||
|
@ -37,9 +37,13 @@
|
||||
static char sccsid[] = "@(#)seekdir.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <dirent.h>
|
||||
#include <pthread.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include "libc_private.h"
|
||||
#include "telldir.h"
|
||||
|
||||
/*
|
||||
@ -51,5 +55,9 @@ seekdir(dirp, loc)
|
||||
DIR *dirp;
|
||||
long loc;
|
||||
{
|
||||
if (__isthreaded)
|
||||
_pthread_mutex_lock((pthread_mutex_t *)&dirp->dd_lock);
|
||||
_seekdir(dirp, loc);
|
||||
if (__isthreaded)
|
||||
_pthread_mutex_unlock((pthread_mutex_t *)&dirp->dd_lock);
|
||||
}
|
||||
|
@ -44,8 +44,10 @@ static char sccsid[] = "@(#)setjmperr.c 8.1 (Berkeley) 6/4/93";
|
||||
* If this routine returns, the program is aborted.
|
||||
*/
|
||||
|
||||
#include "namespace.h"
|
||||
#include <setjmp.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
void
|
||||
longjmperror()
|
||||
|
@ -42,11 +42,11 @@ static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
@ -54,6 +54,7 @@ static const char rcsid[] =
|
||||
#ifdef SETMODE_DEBUG
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#include "un-namespace.h"
|
||||
|
||||
#define SET_LEN 6 /* initial # of bitcmd struct to malloc */
|
||||
#define SET_LEN_INCR 4 /* # of bitcmd structs to add as needed */
|
||||
@ -188,10 +189,10 @@ setmode(p)
|
||||
* as best we can.
|
||||
*/
|
||||
sigfillset(&sigset);
|
||||
(void)sigprocmask(SIG_BLOCK, &sigset, &sigoset);
|
||||
(void)_sigprocmask(SIG_BLOCK, &sigset, &sigoset);
|
||||
(void)umask(mask = umask(0));
|
||||
mask = ~mask;
|
||||
(void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
|
||||
(void)_sigprocmask(SIG_SETMASK, &sigoset, NULL);
|
||||
|
||||
setlen = SET_LEN + 2;
|
||||
|
||||
|
@ -29,13 +29,18 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)siginterrupt.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <signal.h>
|
||||
#include "un-namespace.h"
|
||||
#include "libc_private.h"
|
||||
|
||||
/*
|
||||
* Set signal state to prevent restart of system calls
|
||||
@ -49,7 +54,7 @@ siginterrupt(sig, flag)
|
||||
struct sigaction sa;
|
||||
int ret;
|
||||
|
||||
if ((ret = sigaction(sig, (struct sigaction *)0, &sa)) < 0)
|
||||
if ((ret = _sigaction(sig, (struct sigaction *)0, &sa)) < 0)
|
||||
return (ret);
|
||||
if (flag) {
|
||||
sigaddset(&_sigintr, sig);
|
||||
@ -58,5 +63,5 @@ siginterrupt(sig, flag)
|
||||
sigdelset(&_sigintr, sig);
|
||||
sa.sa_flags |= SA_RESTART;
|
||||
}
|
||||
return (sigaction(sig, &sa, (struct sigaction *)0));
|
||||
return (_sigaction(sig, &sa, (struct sigaction *)0));
|
||||
}
|
||||
|
@ -29,6 +29,8 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
@ -38,7 +40,10 @@ static char sccsid[] = "@(#)signal.c 8.1 (Berkeley) 6/4/93";
|
||||
/*
|
||||
* Almost backwards compatible signal.
|
||||
*/
|
||||
#include "namespace.h"
|
||||
#include <signal.h>
|
||||
#include "un-namespace.h"
|
||||
#include "libc_private.h"
|
||||
|
||||
sigset_t _sigintr; /* shared with siginterrupt */
|
||||
|
||||
@ -54,7 +59,7 @@ signal(s, a)
|
||||
sa.sa_flags = 0;
|
||||
if (!sigismember(&_sigintr, s))
|
||||
sa.sa_flags |= SA_RESTART;
|
||||
if (sigaction(s, &sa, &osa) < 0)
|
||||
if (_sigaction(s, &sa, &osa) < 0)
|
||||
return (SIG_ERR);
|
||||
return (osa.sa_handler);
|
||||
}
|
||||
|
@ -39,10 +39,12 @@ static char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
unsigned int
|
||||
__sleep(seconds)
|
||||
@ -68,6 +70,5 @@ __sleep(seconds)
|
||||
(time_remaining.tv_nsec != 0)); /* round up */
|
||||
}
|
||||
|
||||
#ifndef _THREAD_SAFE
|
||||
__weak_reference(__sleep, sleep);
|
||||
#endif
|
||||
__weak_reference(__sleep, _sleep);
|
||||
|
@ -39,6 +39,7 @@ static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/syslog.h>
|
||||
@ -59,6 +60,7 @@ static const char rcsid[] =
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
#include "un-namespace.h"
|
||||
|
||||
static int LogFile = -1; /* fd for log */
|
||||
static int connected; /* have done connect */
|
||||
@ -235,7 +237,7 @@ vsyslog(pri, fmt, ap)
|
||||
++v;
|
||||
v->iov_base = "\n";
|
||||
v->iov_len = 1;
|
||||
(void)writev(STDERR_FILENO, iov, 2);
|
||||
(void)_writev(STDERR_FILENO, iov, 2);
|
||||
}
|
||||
|
||||
/* Get connected, output the message to the local logger. */
|
||||
@ -270,7 +272,7 @@ vsyslog(pri, fmt, ap)
|
||||
++v;
|
||||
v->iov_base = "\r\n";
|
||||
v->iov_len = 2;
|
||||
(void)writev(fd, iov, 2);
|
||||
(void)_writev(fd, iov, 2);
|
||||
(void)_close(fd);
|
||||
}
|
||||
}
|
||||
@ -295,7 +297,7 @@ connectlog()
|
||||
struct sockaddr_un SyslogAddr; /* AF_UNIX address of local logger */
|
||||
|
||||
if (LogFile == -1) {
|
||||
if ((LogFile = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1)
|
||||
if ((LogFile = _socket(AF_UNIX, SOCK_DGRAM, 0)) == -1)
|
||||
return;
|
||||
(void)_fcntl(LogFile, F_SETFD, 1);
|
||||
}
|
||||
@ -304,7 +306,7 @@ connectlog()
|
||||
SyslogAddr.sun_family = AF_UNIX;
|
||||
(void)strncpy(SyslogAddr.sun_path, _PATH_LOG,
|
||||
sizeof SyslogAddr.sun_path);
|
||||
connected = connect(LogFile, (struct sockaddr *)&SyslogAddr,
|
||||
connected = _connect(LogFile, (struct sockaddr *)&SyslogAddr,
|
||||
sizeof(SyslogAddr)) != -1;
|
||||
|
||||
if (!connected) {
|
||||
@ -314,7 +316,7 @@ connectlog()
|
||||
*/
|
||||
(void)strncpy(SyslogAddr.sun_path, _PATH_OLDLOG,
|
||||
sizeof SyslogAddr.sun_path);
|
||||
connected = connect(LogFile,
|
||||
connected = _connect(LogFile,
|
||||
(struct sockaddr *)&SyslogAddr,
|
||||
sizeof(SyslogAddr)) != -1;
|
||||
}
|
||||
|
@ -37,12 +37,16 @@
|
||||
static char sccsid[] = "@(#)telldir.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
#include <dirent.h>
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include "libc_private.h"
|
||||
#include "telldir.h"
|
||||
|
||||
/*
|
||||
@ -63,10 +67,14 @@ telldir(dirp)
|
||||
|
||||
if ((lp = (struct ddloc *)malloc(sizeof(struct ddloc))) == NULL)
|
||||
return (-1);
|
||||
if (__isthreaded)
|
||||
_pthread_mutex_lock((pthread_mutex_t *)&dirp->dd_lock);
|
||||
lp->loc_index = dirp->dd_td->td_loccnt++;
|
||||
lp->loc_seek = dirp->dd_seek;
|
||||
lp->loc_loc = dirp->dd_loc;
|
||||
LIST_INSERT_HEAD(&dirp->dd_td->td_locq, lp, loc_lqe);
|
||||
if (__isthreaded)
|
||||
_pthread_mutex_unlock((pthread_mutex_t *)&dirp->dd_lock);
|
||||
return (lp->loc_index);
|
||||
}
|
||||
|
||||
@ -94,7 +102,7 @@ _seekdir(dirp, loc)
|
||||
dirp->dd_seek = lp->loc_seek;
|
||||
dirp->dd_loc = 0;
|
||||
while (dirp->dd_loc < lp->loc_loc) {
|
||||
dp = readdir(dirp);
|
||||
dp = _readdir_unlocked(dirp);
|
||||
if (dp == NULL)
|
||||
break;
|
||||
}
|
||||
|
@ -59,7 +59,8 @@ struct _telldir {
|
||||
long td_loccnt; /* index of entry for sequential readdir's */
|
||||
};
|
||||
|
||||
void _reclaim_telldir __P((DIR *));
|
||||
void _seekdir __P((DIR *, long));
|
||||
struct dirent *_readdir_unlocked(DIR *);
|
||||
void _reclaim_telldir(DIR *);
|
||||
void _seekdir(DIR *, long);
|
||||
|
||||
#endif
|
||||
|
@ -37,6 +37,7 @@
|
||||
static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
@ -45,6 +46,7 @@ static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94";
|
||||
#include <errno.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
int
|
||||
tcgetattr(fd, t)
|
||||
@ -52,7 +54,7 @@ tcgetattr(fd, t)
|
||||
struct termios *t;
|
||||
{
|
||||
|
||||
return (ioctl(fd, TIOCGETA, t));
|
||||
return (_ioctl(fd, TIOCGETA, t));
|
||||
}
|
||||
|
||||
int
|
||||
@ -69,11 +71,11 @@ tcsetattr(fd, opt, t)
|
||||
}
|
||||
switch (opt & ~TCSASOFT) {
|
||||
case TCSANOW:
|
||||
return (ioctl(fd, TIOCSETA, t));
|
||||
return (_ioctl(fd, TIOCSETA, t));
|
||||
case TCSADRAIN:
|
||||
return (ioctl(fd, TIOCSETAW, t));
|
||||
return (_ioctl(fd, TIOCSETAW, t));
|
||||
case TCSAFLUSH:
|
||||
return (ioctl(fd, TIOCSETAF, t));
|
||||
return (_ioctl(fd, TIOCSETAF, t));
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
@ -92,7 +94,7 @@ tcsetpgrp(fd, pgrp)
|
||||
int s;
|
||||
|
||||
s = pgrp;
|
||||
return (ioctl(fd, TIOCSPGRP, &s));
|
||||
return (_ioctl(fd, TIOCSPGRP, &s));
|
||||
}
|
||||
|
||||
pid_t
|
||||
@ -101,7 +103,7 @@ tcgetpgrp(fd)
|
||||
{
|
||||
int s;
|
||||
|
||||
if (ioctl(fd, TIOCGPGRP, &s) < 0)
|
||||
if (_ioctl(fd, TIOCGPGRP, &s) < 0)
|
||||
return ((pid_t)-1);
|
||||
|
||||
return ((pid_t)s);
|
||||
@ -180,10 +182,10 @@ tcsendbreak(fd, len)
|
||||
|
||||
sleepytime.tv_sec = 0;
|
||||
sleepytime.tv_usec = 400000;
|
||||
if (ioctl(fd, TIOCSBRK, 0) == -1)
|
||||
if (_ioctl(fd, TIOCSBRK, 0) == -1)
|
||||
return (-1);
|
||||
(void)select(0, 0, 0, 0, &sleepytime);
|
||||
if (ioctl(fd, TIOCCBRK, 0) == -1)
|
||||
(void)_select(0, 0, 0, 0, &sleepytime);
|
||||
if (_ioctl(fd, TIOCCBRK, 0) == -1)
|
||||
return (-1);
|
||||
return (0);
|
||||
}
|
||||
@ -192,12 +194,11 @@ int
|
||||
__tcdrain(fd)
|
||||
int fd;
|
||||
{
|
||||
return (ioctl(fd, TIOCDRAIN, 0));
|
||||
return (_ioctl(fd, TIOCDRAIN, 0));
|
||||
}
|
||||
|
||||
#ifndef _THREAD_SAFE
|
||||
__weak_reference(__tcdrain, tcdrain);
|
||||
#endif
|
||||
__weak_reference(__tcdrain, _tcdrain);
|
||||
|
||||
int
|
||||
tcflush(fd, which)
|
||||
@ -219,7 +220,7 @@ tcflush(fd, which)
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
return (ioctl(fd, TIOCFLUSH, &com));
|
||||
return (_ioctl(fd, TIOCFLUSH, &com));
|
||||
}
|
||||
|
||||
int
|
||||
@ -231,9 +232,9 @@ tcflow(fd, action)
|
||||
|
||||
switch (action) {
|
||||
case TCOOFF:
|
||||
return (ioctl(fd, TIOCSTOP, 0));
|
||||
return (_ioctl(fd, TIOCSTOP, 0));
|
||||
case TCOON:
|
||||
return (ioctl(fd, TIOCSTART, 0));
|
||||
return (_ioctl(fd, TIOCSTART, 0));
|
||||
case TCION:
|
||||
case TCIOFF:
|
||||
if (tcgetattr(fd, &term) == -1)
|
||||
|
@ -29,12 +29,15 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)ttyname.c 8.2 (Berkeley) 1/27/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
@ -42,42 +45,44 @@ static char sccsid[] = "@(#)ttyname.c 8.2 (Berkeley) 1/27/94";
|
||||
#include <stdlib.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <db.h>
|
||||
#include <string.h>
|
||||
#include <paths.h>
|
||||
|
||||
#ifdef _THREAD_SAFE
|
||||
#include <pthread.h>
|
||||
#include "pthread_private.h"
|
||||
static struct pthread_mutex _ttyname_lockd = PTHREAD_MUTEX_STATIC_INITIALIZER;
|
||||
static pthread_mutex_t ttyname_lock = &_ttyname_lockd;
|
||||
static pthread_key_t ttyname_key;
|
||||
static int ttyname_init = 0;
|
||||
#include "un-namespace.h"
|
||||
|
||||
char *
|
||||
#include <db.h>
|
||||
#include "libc_private.h"
|
||||
|
||||
static char buf[sizeof(_PATH_DEV) + MAXNAMLEN] = _PATH_DEV;
|
||||
static char *oldttyname __P((int, struct stat *));
|
||||
static char *ttyname_threaded(int fd);
|
||||
static char *ttyname_unthreaded(int fd);
|
||||
|
||||
static pthread_mutex_t ttyname_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_key_t ttyname_key;
|
||||
static int ttyname_init = 0;
|
||||
|
||||
char *
|
||||
ttyname(int fd)
|
||||
{
|
||||
char *ret;
|
||||
|
||||
if (_FD_LOCK(fd, FD_READ, NULL) == 0) {
|
||||
ret = __ttyname_basic(fd);
|
||||
_FD_UNLOCK(fd, FD_READ);
|
||||
} else {
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
if (__isthreaded == 0)
|
||||
ret = ttyname_unthreaded(fd);
|
||||
else
|
||||
ret = ttyname_threaded(fd);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
char *
|
||||
__ttyname_r_basic(int fd, char *buf, size_t len)
|
||||
char *
|
||||
ttyname_r(int fd, char *buf, size_t len)
|
||||
{
|
||||
register struct dirent *dirp;
|
||||
register DIR *dp;
|
||||
struct stat dsb;
|
||||
struct stat sb;
|
||||
char *rval;
|
||||
int minlen;
|
||||
struct dirent *dirp;
|
||||
DIR *dp;
|
||||
struct stat dsb;
|
||||
struct stat sb;
|
||||
char *rval;
|
||||
int minlen;
|
||||
|
||||
rval = NULL;
|
||||
|
||||
@ -85,7 +90,7 @@ __ttyname_r_basic(int fd, char *buf, size_t len)
|
||||
if (!isatty(fd))
|
||||
return (rval);
|
||||
/* Must be a character device. */
|
||||
if (_thread_sys_fstat(fd, &sb) || !S_ISCHR(sb.st_mode))
|
||||
if (_fstat(fd, &sb) || !S_ISCHR(sb.st_mode))
|
||||
return (rval);
|
||||
/* Must have enough room */
|
||||
if (len <= sizeof(_PATH_DEV))
|
||||
@ -110,25 +115,27 @@ __ttyname_r_basic(int fd, char *buf, size_t len)
|
||||
return (rval);
|
||||
}
|
||||
|
||||
char *
|
||||
__ttyname_basic(int fd)
|
||||
static char *
|
||||
ttyname_threaded(int fd)
|
||||
{
|
||||
char *buf;
|
||||
char *buf;
|
||||
|
||||
pthread_mutex_lock(&ttyname_lock);
|
||||
if (ttyname_init == 0) {
|
||||
if (pthread_key_create(&ttyname_key, free)) {
|
||||
pthread_mutex_unlock(&ttyname_lock);
|
||||
return (NULL);
|
||||
_pthread_mutex_lock(&ttyname_lock);
|
||||
if (ttyname_init == 0) {
|
||||
if (_pthread_key_create(&ttyname_key, free)) {
|
||||
_pthread_mutex_unlock(&ttyname_lock);
|
||||
return (NULL);
|
||||
}
|
||||
ttyname_init = 1;
|
||||
}
|
||||
ttyname_init = 1;
|
||||
_pthread_mutex_unlock(&ttyname_lock);
|
||||
}
|
||||
pthread_mutex_unlock(&ttyname_lock);
|
||||
|
||||
/* Must have thread specific data field to put data */
|
||||
if ((buf = pthread_getspecific(ttyname_key)) == NULL) {
|
||||
if ((buf = _pthread_getspecific(ttyname_key)) == NULL) {
|
||||
if ((buf = malloc(sizeof(_PATH_DEV) + MAXNAMLEN)) != NULL) {
|
||||
if (pthread_setspecific(ttyname_key, buf) != 0) {
|
||||
if (_pthread_setspecific(ttyname_key, buf) != 0) {
|
||||
free(buf);
|
||||
return (NULL);
|
||||
}
|
||||
@ -136,34 +143,16 @@ __ttyname_basic(int fd)
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
return (__ttyname_r_basic(fd, buf, sizeof(_PATH_DEV) + MAXNAMLEN));
|
||||
return (ttyname_r(fd, buf, sizeof(_PATH_DEV) + MAXNAMLEN));
|
||||
}
|
||||
|
||||
char *
|
||||
ttyname_r(int fd, char *buf, size_t len)
|
||||
static char *
|
||||
ttyname_unthreaded(int fd)
|
||||
{
|
||||
char *ret;
|
||||
|
||||
if (_FD_LOCK(fd, FD_READ, NULL) == 0) {
|
||||
ret = __ttyname_r_basic(fd, buf, len);
|
||||
_FD_UNLOCK(fd, FD_READ);
|
||||
} else {
|
||||
ret = NULL;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
#else
|
||||
static char buf[sizeof(_PATH_DEV) + MAXNAMLEN] = _PATH_DEV;
|
||||
static char *oldttyname __P((int, struct stat *));
|
||||
|
||||
char *
|
||||
ttyname(fd)
|
||||
int fd;
|
||||
{
|
||||
struct stat sb;
|
||||
struct termios ttyb;
|
||||
DB *db;
|
||||
DBT data, key;
|
||||
struct stat sb;
|
||||
struct termios ttyb;
|
||||
DB *db;
|
||||
DBT data, key;
|
||||
struct {
|
||||
mode_t type;
|
||||
dev_t dev;
|
||||
@ -173,7 +162,7 @@ ttyname(fd)
|
||||
if (tcgetattr(fd, &ttyb) < 0)
|
||||
return (NULL);
|
||||
/* Must be a character device. */
|
||||
if (fstat(fd, &sb) || !S_ISCHR(sb.st_mode))
|
||||
if (_fstat(fd, &sb) || !S_ISCHR(sb.st_mode))
|
||||
return (NULL);
|
||||
|
||||
if ( (db = dbopen(_PATH_DEVDB, O_RDONLY, 0, DB_HASH, NULL)) ) {
|
||||
@ -194,13 +183,11 @@ ttyname(fd)
|
||||
}
|
||||
|
||||
static char *
|
||||
oldttyname(fd, sb)
|
||||
int fd;
|
||||
struct stat *sb;
|
||||
oldttyname(int fd, struct stat *sb)
|
||||
{
|
||||
register struct dirent *dirp;
|
||||
register DIR *dp;
|
||||
struct stat dsb;
|
||||
struct dirent *dirp;
|
||||
struct stat dsb;
|
||||
DIR *dp;
|
||||
|
||||
if ((dp = opendir(_PATH_DEV)) == NULL)
|
||||
return (NULL);
|
||||
@ -219,4 +206,3 @@ oldttyname(fd, sb)
|
||||
(void)closedir(dp);
|
||||
return (NULL);
|
||||
}
|
||||
#endif
|
||||
|
@ -39,8 +39,10 @@ static char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
int
|
||||
usleep(useconds)
|
||||
|
@ -40,6 +40,7 @@ static char sccsid[] = "@(#)vis.c 8.1 (Berkeley) 7/19/93";
|
||||
#include <sys/types.h>
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <vis.h>
|
||||
|
||||
#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
|
||||
|
@ -37,18 +37,18 @@
|
||||
static char sccsid[] = "@(#)wait.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/resource.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
pid_t
|
||||
__wait(istat)
|
||||
int *istat;
|
||||
__wait(int *istat)
|
||||
{
|
||||
return (wait4(WAIT_ANY, istat, 0, (struct rusage *)0));
|
||||
return (_wait4(WAIT_ANY, istat, 0, (struct rusage *)0));
|
||||
}
|
||||
|
||||
#ifndef _THREAD_SAFE
|
||||
__weak_reference(__wait, wait);
|
||||
#endif
|
||||
__weak_reference(__wait, _wait);
|
||||
|
@ -29,16 +29,20 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)wait3.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/resource.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
pid_t
|
||||
wait3(istat, options, rup)
|
||||
@ -46,5 +50,5 @@ wait3(istat, options, rup)
|
||||
int options;
|
||||
struct rusage *rup;
|
||||
{
|
||||
return (wait4(WAIT_ANY, istat, options, rup));
|
||||
return (_wait4(WAIT_ANY, istat, options, rup));
|
||||
}
|
||||
|
@ -37,24 +37,18 @@
|
||||
static char sccsid[] = "@(#)waitpid.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/resource.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
pid_t
|
||||
#if __STDC__
|
||||
__waitpid(pid_t pid, int *istat, int options)
|
||||
#else
|
||||
__waitpid(pid, istat, options)
|
||||
pid_t pid;
|
||||
int *istat;
|
||||
int options;
|
||||
#endif
|
||||
{
|
||||
return (wait4(pid, istat, options, (struct rusage *)0));
|
||||
return (_wait4(pid, istat, options, (struct rusage *)0));
|
||||
}
|
||||
|
||||
#ifndef _THREAD_SAFE
|
||||
__weak_reference(__waitpid, waitpid);
|
||||
#endif
|
||||
__weak_reference(__waitpid, _waitpid);
|
||||
|
@ -37,6 +37,7 @@
|
||||
static char sccsid[] = "@(#)gmon.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/gmon.h>
|
||||
@ -46,7 +47,9 @@ static char sccsid[] = "@(#)gmon.c 8.1 (Berkeley) 6/4/93";
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#if defined(__ELF__) && defined(i386)
|
||||
extern char *minbrk asm (".minbrk");
|
||||
|
@ -61,31 +61,28 @@
|
||||
* Design note:
|
||||
*
|
||||
* The macros PSYSCALL() and PRSYSCALL() are intended for use where a
|
||||
* syscall needs to be renamed in the threaded library. When building
|
||||
* a normal library, they default to the traditional SYSCALL() and
|
||||
* RSYSCALL(). This avoids the need to #ifdef _THREAD_SAFE everywhere
|
||||
* that the renamed function needs to be called.
|
||||
* syscall needs to be renamed in the threaded library.
|
||||
*/
|
||||
#ifdef _THREAD_SAFE
|
||||
/*
|
||||
* For the thread_safe versions, we prepend _thread_sys_ to the function
|
||||
* For the thread_safe versions, we prepend __sys_ to the function
|
||||
* name so that the 'C' wrapper can go around the real name.
|
||||
*/
|
||||
#define PSYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \
|
||||
ENTRY(__CONCAT(_thread_sys_,x)); \
|
||||
ENTRY(__CONCAT(__sys_,x)); \
|
||||
.weak CNAME(x); \
|
||||
.set CNAME(x),CNAME(__CONCAT(__sys_,x)); \
|
||||
.weak CNAME(__CONCAT(_,x)); \
|
||||
.set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
|
||||
lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b
|
||||
|
||||
#define PRSYSCALL(x) PSYSCALL(x); ret
|
||||
#define PPSEUDO(x,y) ENTRY(__CONCAT(_thread_sys_,x)); \
|
||||
|
||||
#define PPSEUDO(x,y) ENTRY(__CONCAT(__sys_,x)); \
|
||||
.weak CNAME(x); \
|
||||
.set CNAME(x),CNAME(__CONCAT(__sys_,x)); \
|
||||
.weak CNAME(__CONCAT(_,x)); \
|
||||
.set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
|
||||
lea __CONCAT(SYS_,y), %eax; KERNCALL; ret
|
||||
#else
|
||||
/*
|
||||
* The non-threaded library defaults to traditional syscalls where
|
||||
* the function name matches the syscall name.
|
||||
*/
|
||||
#define PSYSCALL(x) SYSCALL(x)
|
||||
#define PRSYSCALL(x) RSYSCALL(x)
|
||||
#define PPSEUDO(x,y) PSEUDO(x,y)
|
||||
#endif
|
||||
|
||||
#ifdef __ELF__
|
||||
#define KERNCALL int $0x80 /* Faster */
|
||||
|
@ -66,12 +66,9 @@ ENTRY(_setjmp)
|
||||
xorl %eax,%eax
|
||||
ret
|
||||
|
||||
#ifdef _THREAD_SAFE
|
||||
.weak CNAME(_longjmp)
|
||||
.set CNAME(_longjmp),CNAME(___longjmp)
|
||||
ENTRY(___longjmp)
|
||||
#else
|
||||
ALTENTRY(___longjmp)
|
||||
ENTRY(_longjmp)
|
||||
#endif
|
||||
movl 4(%esp),%edx
|
||||
movl 8(%esp),%eax
|
||||
movl 0(%edx),%ecx
|
||||
|
@ -61,11 +61,7 @@ ENTRY(setjmp)
|
||||
pushl %eax /* (sigset_t*)oset */
|
||||
pushl $0 /* (sigset_t*)set */
|
||||
pushl $1 /* SIG_BLOCK */
|
||||
#ifdef _THREAD_SAFE
|
||||
call PIC_PLT(CNAME(_thread_sys_sigprocmask))
|
||||
#else
|
||||
call PIC_PLT(CNAME(sigprocmask))
|
||||
#endif
|
||||
call PIC_PLT(CNAME(_sigprocmask))
|
||||
addl $12,%esp
|
||||
PIC_EPILOGUE
|
||||
movl 4(%esp),%ecx
|
||||
@ -80,10 +76,8 @@ ENTRY(setjmp)
|
||||
xorl %eax,%eax
|
||||
ret
|
||||
|
||||
#ifndef _THREAD_SAFE
|
||||
.weak CNAME(longjmp);
|
||||
.set CNAME(longjmp),CNAME(__longjmp);
|
||||
#endif
|
||||
.weak CNAME(longjmp)
|
||||
.set CNAME(longjmp),CNAME(__longjmp)
|
||||
ENTRY(__longjmp)
|
||||
movl 4(%esp),%edx
|
||||
PIC_PROLOGUE
|
||||
@ -91,11 +85,7 @@ ENTRY(__longjmp)
|
||||
leal 28(%edx), %eax
|
||||
pushl %eax /* (sigset_t*)set */
|
||||
pushl $3 /* SIG_SETMASK */
|
||||
#ifdef _THREAD_SAFE
|
||||
call PIC_PLT(CNAME(_thread_sys_sigprocmask))
|
||||
#else
|
||||
call PIC_PLT(CNAME(sigprocmask))
|
||||
#endif
|
||||
call PIC_PLT(CNAME(_sigprocmask))
|
||||
addl $12,%esp
|
||||
PIC_EPILOGUE
|
||||
movl 4(%esp),%edx
|
||||
|
@ -52,9 +52,6 @@
|
||||
* the renamed functions (introduced in gcc-2.5.3; previous versions
|
||||
* only supported *jmp with 0 or 1 leading underscores).
|
||||
*
|
||||
* Use sigprocmask() instead of sigblock() and sigsetmask(), and
|
||||
* check for and handle errors.
|
||||
*
|
||||
* Restore _all_ the registers and the signal mask atomically. Can
|
||||
* use sigreturn() if sigreturn() works.
|
||||
*/
|
||||
@ -70,11 +67,7 @@ ENTRY(sigsetjmp)
|
||||
pushl %eax /* (sigset_t*)oset */
|
||||
pushl $0 /* (sigset_t*)set */
|
||||
pushl $1 /* SIG_BLOCK */
|
||||
#ifdef _THREAD_SAFE
|
||||
call PIC_PLT(CNAME(_thread_sys_sigprocmask))
|
||||
#else
|
||||
call PIC_PLT(CNAME(sigprocmask))
|
||||
#endif
|
||||
call PIC_PLT(CNAME(_sigprocmask))
|
||||
addl $12,%esp
|
||||
PIC_EPILOGUE
|
||||
movl 4(%esp),%ecx
|
||||
@ -89,10 +82,8 @@ ENTRY(sigsetjmp)
|
||||
xorl %eax,%eax
|
||||
ret
|
||||
|
||||
#ifndef _THREAD_SAFE
|
||||
.weak CNAME(siglongjmp);
|
||||
.set CNAME(siglongjmp),CNAME(__siglongjmp);
|
||||
#endif
|
||||
.weak CNAME(siglongjmp);
|
||||
.set CNAME(siglongjmp),CNAME(__siglongjmp);
|
||||
ENTRY(__siglongjmp);
|
||||
movl 4(%esp),%edx
|
||||
cmpl $0,44(%edx)
|
||||
@ -102,11 +93,7 @@ ENTRY(__siglongjmp);
|
||||
leal 28(%edx), %eax
|
||||
pushl %eax /* (sigset_t*)set */
|
||||
pushl $3 /* SIG_SETMASK */
|
||||
#ifdef _THREAD_SAFE
|
||||
call PIC_PLT(CNAME(_thread_sys_sigprocmask))
|
||||
#else
|
||||
call PIC_PLT(CNAME(sigprocmask))
|
||||
#endif
|
||||
call PIC_PLT(CNAME(_sigprocmask))
|
||||
addl $12,%esp
|
||||
PIC_EPILOGUE
|
||||
movl 4(%esp),%edx
|
||||
|
@ -51,12 +51,11 @@
|
||||
* %eax == pid of child in parent, %eax == pid of parent in child.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef _THREAD_SAFE
|
||||
ENTRY(_thread_sys_vfork)
|
||||
#else
|
||||
ENTRY(vfork)
|
||||
#endif
|
||||
.weak _vfork
|
||||
.set _vfork,__sys_vfork
|
||||
.weak vfork
|
||||
.set vfork,__sys_vfork
|
||||
ENTRY(__sys_vfork)
|
||||
popl %ecx /* my rta into ecx */
|
||||
lea SYS_vfork,%eax
|
||||
KERNCALL
|
||||
|
@ -43,7 +43,7 @@
|
||||
|
||||
#include "SYS.h"
|
||||
|
||||
.globl CNAME(_logname_valid) /* in getlogin() */
|
||||
.globl CNAME(_logname_valid) /* in _getlogin() */
|
||||
|
||||
SYSCALL(setlogin)
|
||||
#ifdef PIC
|
||||
|
@ -75,50 +75,35 @@ END(label);
|
||||
* Design note:
|
||||
*
|
||||
* The macros PSYSCALL() and PRSYSCALL() are intended for use where a
|
||||
* syscall needs to be renamed in the threaded library. When building
|
||||
* a normal library, they default to the traditional SYSCALL() and
|
||||
* RSYSCALL(). This avoids the need to #ifdef _THREAD_SAFE everywhere
|
||||
* that the renamed function needs to be called.
|
||||
* syscall needs to be renamed in the threaded library.
|
||||
*/
|
||||
#ifdef _THREAD_SAFE
|
||||
/*
|
||||
* For the thread_safe versions, we prepend _thread_sys_ to the function
|
||||
* For the thread_safe versions, we prepend __sys_ to the function
|
||||
* name so that the 'C' wrapper can go around the real name.
|
||||
*/
|
||||
#define PCALL(name) \
|
||||
CALL(_thread_sys_ ## name)
|
||||
CALL(__sys_ ## name)
|
||||
|
||||
#define PENTRY(name, args) \
|
||||
ENTRY(_thread_sys_ ## name,args)
|
||||
ENTRY(__sys_ ## name,args)
|
||||
|
||||
#define PEND(name) \
|
||||
END(_thread_sys_ ## name)
|
||||
END(__sys_ ## name)
|
||||
|
||||
#define PSYSCALL(name) \
|
||||
PENTRY(name,0); /* XXX # of args? */ \
|
||||
CALLSYS_ERROR(name)
|
||||
|
||||
#define PRSYSCALL(name) \
|
||||
PENTRY(name,0); /* XXX # of args? */ \
|
||||
PENTRY(_sys_ ## name,0); /* XXX # of args? */ \
|
||||
WEAK_ALIAS(name, __sys_ ## name); \
|
||||
WEAK_ALIAS(_ ## name, __sys_ ## name); \
|
||||
CALLSYS_ERROR(name) \
|
||||
br.ret.sptk.few rp; \
|
||||
PEND(name)
|
||||
|
||||
#define PPSEUDO(label,name) \
|
||||
PENTRY(label,0); /* XXX # of args? */ \
|
||||
PENTRY(label,0); /* XXX # of args? */ \
|
||||
CALLSYS_ERROR(name); \
|
||||
br.ret.sptk.few rp; \
|
||||
PEND(label)
|
||||
|
||||
#else
|
||||
/*
|
||||
* The non-threaded library defaults to traditional syscalls where
|
||||
* the function name matches the syscall name.
|
||||
*/
|
||||
#define PSYSCALL(x) SYSCALL(x)
|
||||
#define PRSYSCALL(x) RSYSCALL(x)
|
||||
#define PPSEUDO(x,y) PSEUDO(x,y)
|
||||
#define PENTRY(x,y) ENTRY(x,y)
|
||||
#define PEND(x) END(x)
|
||||
#define PCALL(x) CALL(x)
|
||||
#endif
|
||||
|
@ -90,12 +90,8 @@ ENTRY(_setjmp, 1)
|
||||
#endif
|
||||
END(_setjmp)
|
||||
|
||||
#ifdef _THREAD_SAFE
|
||||
XENTRY(_longjmp)
|
||||
ENTRY(___longjmp, 2)
|
||||
#else
|
||||
XENTRY(___longjmp)
|
||||
ENTRY(_longjmp, 2)
|
||||
#endif
|
||||
#if 0
|
||||
LDGP(pv)
|
||||
ldq t0, ((31 + 4) * 8)(a0) /* magic in sc_regs[31] */
|
||||
@ -132,8 +128,4 @@ botch:
|
||||
CALL(abort)
|
||||
RET /* "can't" get here... */
|
||||
#endif
|
||||
#ifdef _THREAD_SAFE
|
||||
END(___longjmp)
|
||||
#else
|
||||
END(_longjmp)
|
||||
#endif
|
||||
|
@ -30,7 +30,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <machine/ieee.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
|
@ -69,12 +69,12 @@ ENTRY(setjmp, 1)
|
||||
lda a2, (71 * 8)(a0) /* oset: sc_reserved */
|
||||
mov zero, a1 /* set: NULL */
|
||||
addq a1, 1, a0 /* how: SIG_BLOCK */
|
||||
PCALL(sigprocmask) /* see what's blocked */
|
||||
CALL(_sigprocmask) /* see what's blocked */
|
||||
|
||||
lda sp, -24(sp) /* sizeof struct sigaltstack */
|
||||
mov zero, a0
|
||||
mov sp, a1
|
||||
PCALL(sigaltstack)
|
||||
CALL(_sigaltstack)
|
||||
ldl t0, 16(sp) /* offset of ss_flags */
|
||||
lda sp, 24(sp) /* sizeof struct sigaltstack */
|
||||
ldq ra, ((26 + 4) * 8)(s0) /* restore return address */
|
||||
@ -119,24 +119,15 @@ ENTRY(setjmp, 1)
|
||||
#endif
|
||||
END(setjmp)
|
||||
|
||||
#ifdef _THREAD_SAFE
|
||||
XENTRY(longjmp)
|
||||
ENTRY(__longjmp, 2)
|
||||
#else
|
||||
XENTRY(__longjmp)
|
||||
ENTRY(longjmp, 2)
|
||||
#endif
|
||||
#if 0
|
||||
LDGP(pv)
|
||||
stq a1, (( 0 + 4) * 8)(a0) /* save return value */
|
||||
PCALL(sigreturn) /* use sigreturn to return */
|
||||
PCALL(_sigreturn) /* use sigreturn to return */
|
||||
|
||||
botch:
|
||||
CALL(longjmperror)
|
||||
CALL(abort)
|
||||
RET /* "can't" get here... */
|
||||
#endif
|
||||
#ifdef _THREAD_SAFE
|
||||
END(__longjmp)
|
||||
#else
|
||||
END(longjmp)
|
||||
#endif
|
||||
|
@ -55,12 +55,8 @@ Lsavesig:
|
||||
#endif
|
||||
END(sigsetjmp)
|
||||
|
||||
#ifdef _THREAD_SAFE
|
||||
XENTRY(siglongjmp)
|
||||
ENTRY(__siglongjmp, 2)
|
||||
#else
|
||||
XENTRY(__siglongjmp)
|
||||
ENTRY(siglongjmp, 2)
|
||||
#endif
|
||||
#if 0
|
||||
LDGP(pv)
|
||||
ldq t0, (81 * 8)(a0) /* get the mask */
|
||||
@ -69,8 +65,4 @@ ENTRY(siglongjmp, 2)
|
||||
Lrestoresig:
|
||||
jmp zero, longjmp
|
||||
#endif
|
||||
#ifdef _THREAD_SAFE
|
||||
END(__siglongjmp)
|
||||
#else
|
||||
END(siglongjmp)
|
||||
#endif
|
||||
|
@ -53,7 +53,7 @@ extern int __isthreaded;
|
||||
#ifdef _FLOCK_DEBUG
|
||||
#define _FLOCKFILE(x) _flockfile_debug(x, __FILE__, __LINE__)
|
||||
#else
|
||||
#define _FLOCKFILE(x) flockfile(x)
|
||||
#define _FLOCKFILE(x) _flockfile(x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -61,6 +61,6 @@ extern int __isthreaded;
|
||||
* process is threaded to avoid locking when not required.
|
||||
*/
|
||||
#define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp)
|
||||
#define FUNLOCKFILE(fp) if (__isthreaded) funlockfile(fp)
|
||||
#define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp)
|
||||
|
||||
#endif /* _LIBC_PRIVATE_H_ */
|
||||
|
134
lib/libc/include/namespace.h
Normal file
134
lib/libc/include/namespace.h
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 2001 Daniel Eischen <deischen@FreeBSD.org>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _NAMESPACE_H_
|
||||
#define _NAMESPACE_H_
|
||||
|
||||
/*
|
||||
* Prototypes for syscalls/functions that need to be overridden
|
||||
* in libc_r/libpthread.
|
||||
*/
|
||||
#define accept _accept
|
||||
#define bind _bind
|
||||
#define close _close
|
||||
#define connect _connect
|
||||
#define dup _dup
|
||||
#define dup2 _dup2
|
||||
#define execve _execve
|
||||
#define fcntl _fcntl
|
||||
/*#define flock _flock */
|
||||
#define flockfile _flockfile
|
||||
#define fstat _fstat
|
||||
#define fstatfs _fstatfs
|
||||
#define fsync _fsync
|
||||
#define funlockfile _funlockfile
|
||||
#define getdirentries _getdirentries
|
||||
#define getlogin _getlogin
|
||||
#define getpeername _getpeername
|
||||
#define getsockname _getsockname
|
||||
#define getsockopt _getsockopt
|
||||
#define ioctl _ioctl
|
||||
/* #define kevent _kevent */
|
||||
#define listen _listen
|
||||
#define nanosleep _nanosleep
|
||||
#define open _open
|
||||
#define pthread_getspecific _pthread_getspecific
|
||||
#define pthread_key_create _pthread_key_create
|
||||
#define pthread_key_delete _pthread_key_delete
|
||||
#define pthread_mutex_destroy _pthread_mutex_destroy
|
||||
#define pthread_mutex_init _pthread_mutex_init
|
||||
#define pthread_mutex_lock _pthread_mutex_lock
|
||||
#define pthread_mutex_trylock _pthread_mutex_trylock
|
||||
#define pthread_mutex_unlock _pthread_mutex_unlock
|
||||
#define pthread_mutexattr_init _pthread_mutexattr_init
|
||||
#define pthread_mutexattr_destroy _pthread_mutexattr_destroy
|
||||
#define pthread_mutexattr_settype _pthread_mutexattr_settype
|
||||
#define pthread_once _pthread_once
|
||||
#define pthread_setspecific _pthread_setspecific
|
||||
#define read _read
|
||||
#define readv _readv
|
||||
#define recvfrom _recvfrom
|
||||
#define recvmsg _recvmsg
|
||||
#define select _select
|
||||
#define sendmsg _sendmsg
|
||||
#define sendto _sendto
|
||||
#define setsockopt _setsockopt
|
||||
/*#define sigaction _sigaction*/
|
||||
#define sigprocmask _sigprocmask
|
||||
#define sigsuspend _sigsuspend
|
||||
#define socket _socket
|
||||
#define socketpair _socketpair
|
||||
#define wait4 _wait4
|
||||
#define write _write
|
||||
#define writev _writev
|
||||
|
||||
|
||||
/*
|
||||
* Other hidden syscalls/functions that libc_r needs to override
|
||||
* but are not used internally by libc.
|
||||
*
|
||||
* XXX - When modifying libc to use one of the following, remove
|
||||
* the prototype from below and place it in the list above.
|
||||
*/
|
||||
#if 0
|
||||
#define creat _creat
|
||||
#define fchflags _fchflags
|
||||
#define fchmod _fchmod
|
||||
#define fpathconf _fpathconf
|
||||
#define ftrylockfile _ftrylockfile
|
||||
#define msync _msync
|
||||
#define nfssvc _nfssvc
|
||||
#define pause _pause
|
||||
#define poll _poll
|
||||
#define pthread_rwlock_destroy _pthread_rwlock_destroy
|
||||
#define pthread_rwlock_init _pthread_rwlock_init
|
||||
#define pthread_rwlock_rdlock _pthread_rwlock_rdlock
|
||||
#define pthread_rwlock_tryrdlock _pthread_rwlock_tryrdlock
|
||||
#define pthread_rwlock_trywrlock _pthread_rwlock_trywrlock
|
||||
#define pthread_rwlock_unlock _pthread_rwlock_unlock
|
||||
#define pthread_rwlock_wrlock _pthread_rwlock_wrlock
|
||||
#define pthread_rwlockattr_init _pthread_rwlockattr_init
|
||||
#define pthread_rwlockattr_destroy _pthread_rwlockattr_destroy
|
||||
#define pthread_self _pthread_self
|
||||
#define sched_yield _sched_yield
|
||||
#define sendfile _sendfile
|
||||
#define shutdown _shutdown
|
||||
#define sigaltstack _sigaltstack
|
||||
#define signanosleep _signanosleep
|
||||
#define sigpending _sigpending
|
||||
#define sigreturn _sigreturn
|
||||
#define sigsetmask _sigsetmask
|
||||
#define sleep _sleep
|
||||
#define system _system
|
||||
#define tcdrain _tcdrain
|
||||
#define wait _wait
|
||||
#define waitpid _waitpid
|
||||
#endif
|
||||
|
||||
#endif /* _NAMESPACE_H_ */
|
134
lib/libc/include/un-namespace.h
Normal file
134
lib/libc/include/un-namespace.h
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 2001 Daniel Eischen <deischen@FreeBSD.org>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _UN_NAMESPACE_H_
|
||||
#define _UN_NAMESPACE_H_
|
||||
|
||||
#undef accept
|
||||
#undef bind
|
||||
#undef close
|
||||
#undef connect
|
||||
#undef dup
|
||||
#undef dup2
|
||||
#undef execve
|
||||
#undef fcntl
|
||||
#undef flock
|
||||
#undef flockfile
|
||||
#undef fstat
|
||||
#undef fstatfs
|
||||
#undef fsync
|
||||
#undef funlockfile
|
||||
#undef getdirentries
|
||||
#undef getlogin
|
||||
#undef getpeername
|
||||
#undef getsockname
|
||||
#undef getsockopt
|
||||
#undef ioctl
|
||||
#undef kevent
|
||||
#undef listen
|
||||
#undef nanosleep
|
||||
#undef open
|
||||
#undef pthread_getspecific
|
||||
#undef pthread_key_create
|
||||
#undef pthread_key_delete
|
||||
#undef pthread_mutex_destroy
|
||||
#undef pthread_mutex_init
|
||||
#undef pthread_mutex_lock
|
||||
#undef pthread_mutex_trylock
|
||||
#undef pthread_mutex_unlock
|
||||
#undef pthread_mutexattr_init
|
||||
#undef pthread_mutexattr_destroy
|
||||
#undef pthread_mutexattr_settype
|
||||
#undef pthread_once
|
||||
#undef pthread_setspecific
|
||||
#undef read
|
||||
#undef readv
|
||||
#undef recvfrom
|
||||
#undef recvmsg
|
||||
#undef select
|
||||
#undef sendmsg
|
||||
#undef sendto
|
||||
#undef setsockopt
|
||||
#undef sigaction
|
||||
#undef sigprocmask
|
||||
#undef sigsuspend
|
||||
#undef socket
|
||||
#undef socketpair
|
||||
#undef wait4
|
||||
#undef write
|
||||
#undef writev
|
||||
|
||||
#if 0
|
||||
#undef creat
|
||||
#undef fchflags
|
||||
#undef fchmod
|
||||
#undef fpathconf
|
||||
#undef ftrylockfile
|
||||
#undef msync
|
||||
#undef nfssvc
|
||||
#undef pause
|
||||
#undef poll
|
||||
#undef pthread_rwlock_destroy
|
||||
#undef pthread_rwlock_init
|
||||
#undef pthread_rwlock_rdlock
|
||||
#undef pthread_rwlock_tryrdlock
|
||||
#undef pthread_rwlock_trywrlock
|
||||
#undef pthread_rwlock_unlock
|
||||
#undef pthread_rwlock_wrlock
|
||||
#undef pthread_rwlockattr_init
|
||||
#undef pthread_rwlockattr_destroy
|
||||
#undef pthread_self
|
||||
#undef sched_yield
|
||||
#undef sendfile
|
||||
#undef shutdown
|
||||
#undef sigaltstack
|
||||
#undef signanosleep
|
||||
#undef sigpending
|
||||
#undef sigreturn
|
||||
#undef sigsetmask
|
||||
#undef sleep
|
||||
#undef system
|
||||
#undef tcdrain
|
||||
#undef wait
|
||||
#undef waitpid
|
||||
#endif /* 0 */
|
||||
|
||||
#ifdef _SIGNAL_H_
|
||||
int _sigaction(int, const struct sigaction *, struct sigaction *);
|
||||
#endif
|
||||
|
||||
#ifdef _SYS_EVENT_H_
|
||||
int _kevent(int, const struct kevent *, int, struct kevent *,
|
||||
int, const struct timespec *);
|
||||
#endif
|
||||
|
||||
#ifdef _SYS_FCNTL_H_
|
||||
int _flock(int, int);
|
||||
#endif
|
||||
|
||||
#endif /* _UN_NAMESPACE_H_ */
|
@ -40,7 +40,6 @@
|
||||
static char sccsid[] = "@(#)big5.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <errno.h>
|
||||
#include <rune.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
@ -27,6 +27,7 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include "namespace.h"
|
||||
#include <rune.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -34,6 +35,8 @@
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sysexits.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include "collate.h"
|
||||
#include "setlocale.h"
|
||||
|
||||
@ -46,7 +49,7 @@ struct __collate_st_chain_pri __collate_chain_pri_table[TABLE_SIZE];
|
||||
|
||||
#define FREAD(a, b, c, d) \
|
||||
do { \
|
||||
if(fread(a, b, c, d) != c) { \
|
||||
if (fread(a, b, c, d) != c) { \
|
||||
fclose(d); \
|
||||
return -1; \
|
||||
} \
|
||||
|
@ -39,7 +39,6 @@ static char sccsid[] = "@(#)mskanji.c 1.0 (Phase One) 5/5/95";
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <rune.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
@ -32,6 +32,8 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
@ -41,7 +43,6 @@ static char sccsid[] = "@(#)none.c 8.1 (Berkeley) 6/4/93";
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <rune.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
rune_t _none_sgetrune __P((const char *, size_t, char const **));
|
||||
|
@ -32,18 +32,22 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)rune.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <rune.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
_RuneLocale *
|
||||
_Read_RuneMagi(fp)
|
||||
@ -56,7 +60,7 @@ _Read_RuneMagi(fp)
|
||||
struct stat sb;
|
||||
int x;
|
||||
|
||||
if (fstat(fileno(fp), &sb) < 0)
|
||||
if (_fstat(fileno(fp), &sb) < 0)
|
||||
return(0);
|
||||
|
||||
if (sb.st_size < sizeof(_RuneLocale))
|
||||
|
@ -40,7 +40,6 @@
|
||||
static char sccsid[] = "@(#)utf2.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <errno.h>
|
||||
#include <rune.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
@ -86,6 +86,7 @@
|
||||
* - classful IPv4 numeric (127.1) is allowed.
|
||||
*/
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
@ -106,6 +107,7 @@
|
||||
#include <syslog.h>
|
||||
#include <stdarg.h>
|
||||
#include <nsswitch.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#if defined(__KAME__) && defined(INET6)
|
||||
# define FAITH
|
||||
@ -665,7 +667,7 @@ explore_null(pai, servname, res)
|
||||
* filter out AFs that are not supported by the kernel
|
||||
* XXX errno?
|
||||
*/
|
||||
s = socket(pai->ai_family, SOCK_DGRAM, 0);
|
||||
s = _socket(pai->ai_family, SOCK_DGRAM, 0);
|
||||
if (s < 0) {
|
||||
if (errno != EMFILE)
|
||||
return 0;
|
||||
@ -1059,18 +1061,18 @@ addrconfig(pai)
|
||||
*/
|
||||
af = pai->ai_family;
|
||||
if (af == AF_UNSPEC) {
|
||||
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
|
||||
if ((s = _socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
|
||||
af = AF_INET;
|
||||
else {
|
||||
_close(s);
|
||||
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
if ((s = _socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
af = AF_INET6;
|
||||
else
|
||||
_close(s);
|
||||
}
|
||||
}
|
||||
if (af != AF_UNSPEC) {
|
||||
if ((s = socket(af, SOCK_DGRAM, 0)) < 0)
|
||||
if ((s = _socket(af, SOCK_DGRAM, 0)) < 0)
|
||||
return 0;
|
||||
_close(s);
|
||||
}
|
||||
|
@ -63,7 +63,6 @@ static char rcsid[] = "$FreeBSD$";
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <nsswitch.h>
|
||||
|
@ -35,7 +35,6 @@ static char rcsid[] = "$FreeBSD$";
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <nsswitch.h>
|
||||
@ -117,7 +116,6 @@ gethostbyaddr(const char *addr, int len, int type)
|
||||
return hp;
|
||||
}
|
||||
|
||||
#ifdef _THREAD_SAFE
|
||||
struct hostent_data;
|
||||
|
||||
/*
|
||||
@ -136,7 +134,6 @@ int gethostbyaddr_r(const char *addr, int len, int type,
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
sethostent(stayopen)
|
||||
|
@ -28,6 +28,7 @@
|
||||
* NOTE: SIOCGIFCONF case is not LP64 friendly. it also does not perform
|
||||
* try-and-error for region size.
|
||||
*/
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
@ -39,10 +40,10 @@
|
||||
#include <net/if_dl.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#if !defined(AF_LINK)
|
||||
#define SA_LEN(sa) sizeof(struct sockaddr)
|
||||
@ -194,10 +195,10 @@ getifaddrs(struct ifaddrs **pif)
|
||||
ifc.ifc_buf = buf;
|
||||
ifc.ifc_len = sizeof(buf);
|
||||
|
||||
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
if ((sock = _socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
return (-1);
|
||||
i = ioctl(sock, SIOCGIFCONF, (char *)&ifc);
|
||||
close(sock);
|
||||
i = _ioctl(sock, SIOCGIFCONF, (char *)&ifc);
|
||||
_close(sock);
|
||||
if (i < 0)
|
||||
return (-1);
|
||||
|
||||
|
@ -73,7 +73,6 @@ static char rcsid[] = "$FreeBSD$";
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <syslog.h>
|
||||
|
@ -34,7 +34,6 @@ static char rcsid[] = "$FreeBSD$";
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <nsswitch.h>
|
||||
|
@ -53,11 +53,13 @@ static char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93";
|
||||
static char rcsid[] = "$FreeBSD$";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
const char *h_errlist[] = {
|
||||
"Resolver Error 0 (no error)",
|
||||
@ -94,7 +96,7 @@ herror(s)
|
||||
v++;
|
||||
v->iov_base = "\n";
|
||||
v->iov_len = 1;
|
||||
writev(STDERR_FILENO, iov, (v - iov) + 1);
|
||||
_writev(STDERR_FILENO, iov, (v - iov) + 1);
|
||||
}
|
||||
|
||||
const char *
|
||||
|
@ -70,7 +70,6 @@ static char rcsid[] = "$FreeBSD$";
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <syslog.h>
|
||||
|
||||
typedef union {
|
||||
|
@ -94,6 +94,7 @@
|
||||
* rewrite resolvers to be thread safe
|
||||
*/
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
@ -112,6 +113,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <nsswitch.h>
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#ifndef _PATH_HOSTS
|
||||
#define _PATH_HOSTS "/etc/hosts"
|
||||
@ -255,11 +257,11 @@ _ghbyname(const char *name, int af, int flags, int *errp)
|
||||
* because addresses will be dynamically assigned or deleted.
|
||||
*/
|
||||
if (af == AF_UNSPEC) {
|
||||
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
|
||||
if ((s = _socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
|
||||
af = AF_INET;
|
||||
else {
|
||||
_close(s);
|
||||
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
if ((s = _socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
af = AF_INET6;
|
||||
else
|
||||
_close(s);
|
||||
@ -267,7 +269,7 @@ _ghbyname(const char *name, int af, int flags, int *errp)
|
||||
|
||||
}
|
||||
if (af != AF_UNSPEC) {
|
||||
if ((s = socket(af, SOCK_DGRAM, 0)) < 0)
|
||||
if ((s = _socket(af, SOCK_DGRAM, 0)) < 0)
|
||||
return NULL;
|
||||
_close(s);
|
||||
}
|
||||
@ -1699,11 +1701,11 @@ _icmp_fqdn_query(const struct in6_addr *addr, int ifindex)
|
||||
msg.msg_controllen = (char *)cmsg - cbuf;
|
||||
}
|
||||
|
||||
if ((s = socket(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0)
|
||||
if ((s = _socket(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0)
|
||||
return NULL;
|
||||
(void)setsockopt(s, IPPROTO_ICMPV6, ICMP6_FILTER,
|
||||
(void)_setsockopt(s, IPPROTO_ICMPV6, ICMP6_FILTER,
|
||||
(char *)&filter, sizeof(filter));
|
||||
cc = sendmsg(s, &msg, 0);
|
||||
cc = _sendmsg(s, &msg, 0);
|
||||
if (cc < 0) {
|
||||
_close(s);
|
||||
return NULL;
|
||||
@ -1711,12 +1713,12 @@ _icmp_fqdn_query(const struct in6_addr *addr, int ifindex)
|
||||
FD_SET(s, &s_fds);
|
||||
for (;;) {
|
||||
fds = s_fds;
|
||||
if (select(s + 1, &fds, NULL, NULL, &tout) <= 0) {
|
||||
if (_select(s + 1, &fds, NULL, NULL, &tout) <= 0) {
|
||||
_close(s);
|
||||
return NULL;
|
||||
}
|
||||
len = sizeof(sin6);
|
||||
cc = recvfrom(s, buf, sizeof(buf), 0,
|
||||
cc = _recvfrom(s, buf, sizeof(buf), 0,
|
||||
(struct sockaddr *)&sin6, &len);
|
||||
if (cc <= 0) {
|
||||
_close(s);
|
||||
|
@ -37,6 +37,7 @@
|
||||
static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
@ -59,6 +60,7 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
|
||||
#include <rpcsvc/ypclnt.h>
|
||||
#endif
|
||||
#include <arpa/nameser.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
/* wrapper for KAME-special getnameinfo() */
|
||||
#ifndef NI_WITHSCOPEID
|
||||
@ -100,7 +102,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
|
||||
struct addrinfo hints, *res, *ai;
|
||||
struct sockaddr_storage from;
|
||||
fd_set reads;
|
||||
long oldmask;
|
||||
sigset_t oldmask, newmask;
|
||||
pid_t pid;
|
||||
int s, aport, lport, timo, error;
|
||||
char c;
|
||||
@ -136,7 +138,9 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
|
||||
nres++;
|
||||
ai = res;
|
||||
refused = 0;
|
||||
oldmask = sigblock(sigmask(SIGURG));
|
||||
sigemptyset(&newmask);
|
||||
sigaddset(&newmask, SIGURG);
|
||||
_sigprocmask(SIG_BLOCK, (const sigset_t *)&newmask, &oldmask);
|
||||
for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
|
||||
s = rresvport_af(&lport, ai->ai_family);
|
||||
if (s < 0) {
|
||||
@ -151,11 +155,12 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
|
||||
(void)fprintf(stderr, "rcmd: socket: %s\n",
|
||||
strerror(errno));
|
||||
freeaddrinfo(res);
|
||||
sigsetmask(oldmask);
|
||||
_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask,
|
||||
NULL);
|
||||
return (-1);
|
||||
}
|
||||
_fcntl(s, F_SETOWN, pid);
|
||||
if (connect(s, ai->ai_addr, ai->ai_addrlen) >= 0)
|
||||
if (_connect(s, ai->ai_addr, ai->ai_addrlen) >= 0)
|
||||
break;
|
||||
(void)_close(s);
|
||||
if (errno == EADDRINUSE) {
|
||||
@ -168,7 +173,8 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
|
||||
(void)fprintf(stderr, "%s: %s\n",
|
||||
*ahost, strerror(errno));
|
||||
freeaddrinfo(res);
|
||||
sigsetmask(oldmask);
|
||||
_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask,
|
||||
NULL);
|
||||
return (-1);
|
||||
}
|
||||
if (nres > 1) {
|
||||
@ -214,7 +220,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
|
||||
|
||||
if (s2 < 0)
|
||||
goto bad;
|
||||
listen(s2, 1);
|
||||
_listen(s2, 1);
|
||||
(void)snprintf(num, sizeof(num), "%d", lport);
|
||||
if (_write(s, num, strlen(num)+1) != strlen(num)+1) {
|
||||
(void)fprintf(stderr,
|
||||
@ -234,7 +240,7 @@ again:
|
||||
FD_SET(s, &reads);
|
||||
FD_SET(s2, &reads);
|
||||
errno = 0;
|
||||
if (select(nfds, &reads, 0, 0, 0) < 1 || !FD_ISSET(s2, &reads)){
|
||||
if (_select(nfds, &reads, 0, 0, 0) < 1 || !FD_ISSET(s2, &reads)){
|
||||
if (errno != 0)
|
||||
(void)fprintf(stderr,
|
||||
"rcmd: select (setting up stderr): %s\n",
|
||||
@ -245,7 +251,7 @@ again:
|
||||
(void)_close(s2);
|
||||
goto bad;
|
||||
}
|
||||
s3 = accept(s2, (struct sockaddr *)&from, &len);
|
||||
s3 = _accept(s2, (struct sockaddr *)&from, &len);
|
||||
switch (from.ss_family) {
|
||||
case AF_INET:
|
||||
aport = ntohs(((struct sockaddr_in *)&from)->sin_port);
|
||||
@ -297,7 +303,7 @@ again:
|
||||
}
|
||||
goto bad2;
|
||||
}
|
||||
sigsetmask(oldmask);
|
||||
_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL);
|
||||
freeaddrinfo(res);
|
||||
return (s);
|
||||
bad2:
|
||||
@ -305,7 +311,7 @@ bad2:
|
||||
(void)_close(*fd2p);
|
||||
bad:
|
||||
(void)_close(s);
|
||||
sigsetmask(oldmask);
|
||||
_sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL);
|
||||
freeaddrinfo(res);
|
||||
return (-1);
|
||||
}
|
||||
@ -345,12 +351,12 @@ rresvport_af(alport, family)
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = socket(ss.ss_family, SOCK_STREAM, 0);
|
||||
s = _socket(ss.ss_family, SOCK_STREAM, 0);
|
||||
if (s < 0)
|
||||
return (-1);
|
||||
#if 0 /* compat_exact_traditional_rresvport_semantics */
|
||||
sin.sin_port = htons((u_short)*alport);
|
||||
if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
|
||||
if (_bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
|
||||
return (s);
|
||||
if (errno != EADDRINUSE) {
|
||||
(void)_close(s);
|
||||
@ -486,7 +492,7 @@ again:
|
||||
cp = ".rhosts lstat failed";
|
||||
else if (!S_ISREG(sbuf.st_mode))
|
||||
cp = ".rhosts not regular file";
|
||||
else if (fstat(fileno(hostf), &sbuf) < 0)
|
||||
else if (_fstat(fileno(hostf), &sbuf) < 0)
|
||||
cp = ".rhosts fstat failed";
|
||||
else if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid)
|
||||
cp = "bad .rhosts owner";
|
||||
|
@ -29,16 +29,20 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)recv.c 8.2 (Berkeley) 2/21/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
ssize_t
|
||||
recv(s, buf, len, flags)
|
||||
@ -46,5 +50,5 @@ recv(s, buf, len, flags)
|
||||
size_t len;
|
||||
void *buf;
|
||||
{
|
||||
return (recvfrom(s, buf, len, flags, NULL, 0));
|
||||
return (_recvfrom(s, buf, len, flags, NULL, 0));
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user