From 8abe2a2d86ee5f72093b3feeabf05c9f6f963576 Mon Sep 17 00:00:00 2001 From: jasone Date: Thu, 27 Jan 2000 23:07:25 +0000 Subject: Simplify sytem call renaming. Instead of _foo() <-- _libc_foo <-- foo(), just use _foo() <-- foo(). In the case of a libpthread that doesn't do call conversion (such as linuxthreads and our upcoming libpthread), this is adequate. In the case of libc_r, we still need three names, which are now _thread_sys_foo() <-- _foo() <-- foo(). Convert all internal libc usage of: aio_suspend(), close(), fsync(), msync(), nanosleep(), open(), fcntl(), read(), and write() to _foo() instead of foo(). Remove all internal libc usage of: creat(), pause(), sleep(), system(), tcdrain(), wait(), and waitpid(). Make thread cancellation fully POSIX-compliant. Suggested by: deischen --- lib/libc/alpha/SYS.h | 6 ++-- lib/libc/amd64/SYS.h | 13 ++++---- lib/libc/compat-43/creat.c | 5 ++- lib/libc/compat-43/sigcompat.c | 2 +- lib/libc/db/btree/bt_close.c | 2 +- lib/libc/db/btree/bt_open.c | 8 ++--- lib/libc/db/hash/hash.c | 12 +++---- lib/libc/db/hash/hash_page.c | 14 ++++---- lib/libc/db/mpool/mpool.c | 6 ++-- lib/libc/db/recno/rec_close.c | 4 +-- lib/libc/db/recno/rec_open.c | 4 +-- lib/libc/gen/arc4random.c | 6 ++-- lib/libc/gen/closedir.c | 2 +- lib/libc/gen/daemon.c | 4 +-- lib/libc/gen/exec.c | 6 ++-- lib/libc/gen/fstab.c | 12 +++---- lib/libc/gen/fts-compat.c | 23 +++++++------- lib/libc/gen/fts.c | 23 +++++++------- lib/libc/gen/getcap.c | 14 ++++---- lib/libc/gen/getpass.c | 2 +- lib/libc/gen/lockf.c | 4 +-- lib/libc/gen/nlist.c | 8 ++--- lib/libc/gen/opendir.c | 10 +++--- lib/libc/gen/pause.c | 3 +- lib/libc/gen/popen.c | 24 +++++++------- lib/libc/gen/psignal.c | 8 ++--- lib/libc/gen/setjmperr.c | 2 +- lib/libc/gen/sleep.c | 5 ++- lib/libc/gen/syslog.c | 12 +++---- lib/libc/gen/termios.c | 6 ++-- lib/libc/gen/usleep.c | 2 +- lib/libc/gen/wait.c | 3 +- lib/libc/gen/waitpid.c | 3 +- lib/libc/gmon/gmon.c | 18 +++++------ lib/libc/i386/SYS.h | 13 ++++---- lib/libc/locale/collate.c | 12 +++---- lib/libc/net/getaddrinfo.c | 2 +- lib/libc/net/name6.c | 10 +++--- lib/libc/net/rcmd.c | 45 ++++++++++++++------------ lib/libc/net/res_send.c | 10 +++--- lib/libc/nls/msgcat.c | 16 +++++----- lib/libc/rpc/auth_time.c | 6 ++-- lib/libc/rpc/clnt_simple.c | 2 +- lib/libc/rpc/clnt_tcp.c | 10 +++--- lib/libc/rpc/clnt_udp.c | 2 +- lib/libc/rpc/clnt_unix.c | 6 ++-- lib/libc/rpc/get_myaddress.c | 6 ++-- lib/libc/rpc/key_call.c | 2 +- lib/libc/rpc/pmap_clnt.c | 4 +-- lib/libc/rpc/pmap_getmaps.c | 2 +- lib/libc/rpc/pmap_getport.c | 2 +- lib/libc/rpc/pmap_rmt.c | 4 +-- lib/libc/rpc/rtime.c | 4 +-- lib/libc/rpc/svc_tcp.c | 14 ++++---- lib/libc/rpc/svc_udp.c | 4 +-- lib/libc/rpc/svc_unix.c | 4 +-- lib/libc/stdio/fdopen.c | 2 +- lib/libc/stdio/fopen.c | 2 +- lib/libc/stdio/freopen.c | 6 ++-- lib/libc/stdio/gets.c | 2 +- lib/libc/stdio/mktemp.c | 2 +- lib/libc/stdio/stdio.c | 6 ++-- lib/libc/stdio/tmpfile.c | 2 +- lib/libc/stdlib/malloc.c | 18 +++++------ lib/libc/stdlib/random.c | 6 ++-- lib/libc/stdlib/realpath.c | 6 ++-- lib/libc/stdlib/system.c | 5 ++- lib/libc/stdtime/localtime.c | 6 ++-- lib/libc/stdtime/timelocal.c | 8 ++--- lib/libc/yp/yplib.c | 24 ++++++++------ lib/libc_r/Makefile | 2 +- lib/libc_r/uthread/Makefile.inc | 8 +++++ lib/libc_r/uthread/uthread_accept.c | 4 +-- lib/libc_r/uthread/uthread_aio_suspend.c | 51 ++++++++++++++++++++++++++++++ lib/libc_r/uthread/uthread_bind.c | 4 +-- lib/libc_r/uthread/uthread_close.c | 17 +++++++--- lib/libc_r/uthread/uthread_cond.c | 9 ++++++ lib/libc_r/uthread/uthread_connect.c | 4 +-- lib/libc_r/uthread/uthread_creat.c | 48 ++++++++++++++++++++++++++++ lib/libc_r/uthread/uthread_dup.c | 4 +-- lib/libc_r/uthread/uthread_dup2.c | 4 +-- lib/libc_r/uthread/uthread_execve.c | 4 +-- lib/libc_r/uthread/uthread_exit.c | 4 +-- lib/libc_r/uthread/uthread_fchflags.c | 4 +-- lib/libc_r/uthread/uthread_fchmod.c | 4 +-- lib/libc_r/uthread/uthread_fchown.c | 4 +-- lib/libc_r/uthread/uthread_fcntl.c | 35 ++++++++++++++++---- lib/libc_r/uthread/uthread_flock.c | 4 +-- lib/libc_r/uthread/uthread_fork.c | 4 +-- lib/libc_r/uthread/uthread_fstat.c | 4 +-- lib/libc_r/uthread/uthread_fstatfs.c | 4 +-- lib/libc_r/uthread/uthread_fsync.c | 18 ++++++++--- lib/libc_r/uthread/uthread_getdirentries.c | 4 +-- lib/libc_r/uthread/uthread_getpeername.c | 4 +-- lib/libc_r/uthread/uthread_getsockname.c | 4 +-- lib/libc_r/uthread/uthread_getsockopt.c | 4 +-- lib/libc_r/uthread/uthread_ioctl.c | 4 +-- lib/libc_r/uthread/uthread_listen.c | 4 +-- lib/libc_r/uthread/uthread_msync.c | 26 +++++++-------- lib/libc_r/uthread/uthread_nanosleep.c | 17 +++++++--- lib/libc_r/uthread/uthread_open.c | 29 +++++++++++++---- lib/libc_r/uthread/uthread_pause.c | 48 ++++++++++++++++++++++++++++ lib/libc_r/uthread/uthread_pipe.c | 4 +-- lib/libc_r/uthread/uthread_poll.c | 4 +-- lib/libc_r/uthread/uthread_read.c | 19 +++++++---- lib/libc_r/uthread/uthread_readv.c | 4 +-- lib/libc_r/uthread/uthread_recvfrom.c | 4 +-- lib/libc_r/uthread/uthread_recvmsg.c | 4 +-- lib/libc_r/uthread/uthread_select.c | 6 ++-- lib/libc_r/uthread/uthread_sem.c | 3 ++ lib/libc_r/uthread/uthread_sendmsg.c | 4 +-- lib/libc_r/uthread/uthread_sendto.c | 4 +-- lib/libc_r/uthread/uthread_setsockopt.c | 4 +-- lib/libc_r/uthread/uthread_shutdown.c | 4 +-- lib/libc_r/uthread/uthread_sigaction.c | 4 +-- lib/libc_r/uthread/uthread_sigpending.c | 4 +-- lib/libc_r/uthread/uthread_sigprocmask.c | 4 +-- lib/libc_r/uthread/uthread_sigsuspend.c | 14 ++++++-- lib/libc_r/uthread/uthread_sigwait.c | 1 + lib/libc_r/uthread/uthread_sleep.c | 48 ++++++++++++++++++++++++++++ lib/libc_r/uthread/uthread_socket.c | 4 +-- lib/libc_r/uthread/uthread_socketpair.c | 4 +-- lib/libc_r/uthread/uthread_spinlock.c | 2 +- lib/libc_r/uthread/uthread_system.c | 48 ++++++++++++++++++++++++++++ lib/libc_r/uthread/uthread_tcdrain.c | 48 ++++++++++++++++++++++++++++ lib/libc_r/uthread/uthread_wait.c | 47 +++++++++++++++++++++++++++ lib/libc_r/uthread/uthread_wait4.c | 6 ++-- lib/libc_r/uthread/uthread_waitpid.c | 49 ++++++++++++++++++++++++++++ lib/libc_r/uthread/uthread_write.c | 21 +++++++----- lib/libc_r/uthread/uthread_writev.c | 4 +-- lib/libkse/Makefile | 2 +- lib/libkse/thread/Makefile.inc | 8 +++++ lib/libkse/thread/thr_aio_suspend.c | 51 ++++++++++++++++++++++++++++++ lib/libkse/thread/thr_close.c | 17 +++++++--- lib/libkse/thread/thr_cond.c | 9 ++++++ lib/libkse/thread/thr_creat.c | 48 ++++++++++++++++++++++++++++ lib/libkse/thread/thr_exit.c | 4 +-- lib/libkse/thread/thr_fcntl.c | 35 ++++++++++++++++---- lib/libkse/thread/thr_fork.c | 4 +-- lib/libkse/thread/thr_fsync.c | 18 ++++++++--- lib/libkse/thread/thr_msync.c | 26 +++++++-------- lib/libkse/thread/thr_nanosleep.c | 17 +++++++--- lib/libkse/thread/thr_open.c | 29 +++++++++++++---- lib/libkse/thread/thr_pause.c | 48 ++++++++++++++++++++++++++++ lib/libkse/thread/thr_poll.c | 4 +-- lib/libkse/thread/thr_read.c | 19 +++++++---- lib/libkse/thread/thr_readv.c | 4 +-- lib/libkse/thread/thr_select.c | 6 ++-- lib/libkse/thread/thr_sem.c | 3 ++ lib/libkse/thread/thr_sigaction.c | 4 +-- lib/libkse/thread/thr_sigpending.c | 4 +-- lib/libkse/thread/thr_sigprocmask.c | 4 +-- lib/libkse/thread/thr_sigsuspend.c | 14 ++++++-- lib/libkse/thread/thr_sigwait.c | 1 + lib/libkse/thread/thr_sleep.c | 48 ++++++++++++++++++++++++++++ lib/libkse/thread/thr_spinlock.c | 2 +- lib/libkse/thread/thr_system.c | 48 ++++++++++++++++++++++++++++ lib/libkse/thread/thr_tcdrain.c | 48 ++++++++++++++++++++++++++++ lib/libkse/thread/thr_wait.c | 47 +++++++++++++++++++++++++++ lib/libkse/thread/thr_wait4.c | 6 ++-- lib/libkse/thread/thr_waitpid.c | 49 ++++++++++++++++++++++++++++ lib/libkse/thread/thr_write.c | 21 +++++++----- lib/libkse/thread/thr_writev.c | 4 +-- lib/libpthread/Makefile | 2 +- lib/libpthread/thread/Makefile.inc | 8 +++++ lib/libpthread/thread/thr_aio_suspend.c | 51 ++++++++++++++++++++++++++++++ lib/libpthread/thread/thr_close.c | 17 +++++++--- lib/libpthread/thread/thr_cond.c | 9 ++++++ lib/libpthread/thread/thr_creat.c | 48 ++++++++++++++++++++++++++++ lib/libpthread/thread/thr_exit.c | 4 +-- lib/libpthread/thread/thr_fcntl.c | 35 ++++++++++++++++---- lib/libpthread/thread/thr_fork.c | 4 +-- lib/libpthread/thread/thr_fsync.c | 18 ++++++++--- lib/libpthread/thread/thr_msync.c | 26 +++++++-------- lib/libpthread/thread/thr_nanosleep.c | 17 +++++++--- lib/libpthread/thread/thr_open.c | 29 +++++++++++++---- lib/libpthread/thread/thr_pause.c | 48 ++++++++++++++++++++++++++++ lib/libpthread/thread/thr_poll.c | 4 +-- lib/libpthread/thread/thr_read.c | 19 +++++++---- lib/libpthread/thread/thr_readv.c | 4 +-- lib/libpthread/thread/thr_select.c | 6 ++-- lib/libpthread/thread/thr_sem.c | 3 ++ lib/libpthread/thread/thr_sigaction.c | 4 +-- lib/libpthread/thread/thr_sigpending.c | 4 +-- lib/libpthread/thread/thr_sigprocmask.c | 4 +-- lib/libpthread/thread/thr_sigsuspend.c | 14 ++++++-- lib/libpthread/thread/thr_sigwait.c | 1 + lib/libpthread/thread/thr_sleep.c | 48 ++++++++++++++++++++++++++++ lib/libpthread/thread/thr_spinlock.c | 2 +- lib/libpthread/thread/thr_system.c | 48 ++++++++++++++++++++++++++++ lib/libpthread/thread/thr_tcdrain.c | 48 ++++++++++++++++++++++++++++ lib/libpthread/thread/thr_wait.c | 47 +++++++++++++++++++++++++++ lib/libpthread/thread/thr_wait4.c | 6 ++-- lib/libpthread/thread/thr_waitpid.c | 49 ++++++++++++++++++++++++++++ lib/libpthread/thread/thr_write.c | 21 +++++++----- lib/libpthread/thread/thr_writev.c | 4 +-- 196 files changed, 2044 insertions(+), 571 deletions(-) create mode 100644 lib/libc_r/uthread/uthread_aio_suspend.c create mode 100644 lib/libc_r/uthread/uthread_creat.c create mode 100644 lib/libc_r/uthread/uthread_pause.c create mode 100644 lib/libc_r/uthread/uthread_sleep.c create mode 100644 lib/libc_r/uthread/uthread_system.c create mode 100644 lib/libc_r/uthread/uthread_tcdrain.c create mode 100644 lib/libc_r/uthread/uthread_wait.c create mode 100644 lib/libc_r/uthread/uthread_waitpid.c create mode 100644 lib/libkse/thread/thr_aio_suspend.c create mode 100644 lib/libkse/thread/thr_creat.c create mode 100644 lib/libkse/thread/thr_pause.c create mode 100644 lib/libkse/thread/thr_sleep.c create mode 100644 lib/libkse/thread/thr_system.c create mode 100644 lib/libkse/thread/thr_tcdrain.c create mode 100644 lib/libkse/thread/thr_wait.c create mode 100644 lib/libkse/thread/thr_waitpid.c create mode 100644 lib/libpthread/thread/thr_aio_suspend.c create mode 100644 lib/libpthread/thread/thr_creat.c create mode 100644 lib/libpthread/thread/thr_pause.c create mode 100644 lib/libpthread/thread/thr_sleep.c create mode 100644 lib/libpthread/thread/thr_system.c create mode 100644 lib/libpthread/thread/thr_tcdrain.c create mode 100644 lib/libpthread/thread/thr_wait.c create mode 100644 lib/libpthread/thread/thr_waitpid.c diff --git a/lib/libc/alpha/SYS.h b/lib/libc/alpha/SYS.h index 6fddb48..778f73a 100644 --- a/lib/libc/alpha/SYS.h +++ b/lib/libc/alpha/SYS.h @@ -47,7 +47,7 @@ LLABEL(name,1): #define SYSCALL(name) \ LEAF(name,0); /* XXX # of args? */ \ - WEAK_ALIAS(__CONCAT(_libc_,name), name); \ + WEAK_ALIAS(__CONCAT(_,name), name); \ CALLSYS_ERROR(name) #define SYSCALL_NOERROR(name) \ @@ -68,7 +68,7 @@ END(name) #define PSEUDO(label,name) \ LEAF(label,0); /* XXX # of args? */ \ - WEAK_ALIAS(__CONCAT(_libc_,name), name); \ + WEAK_ALIAS(__CONCAT(_,name), name); \ CALLSYS_ERROR(name); \ RET; \ END(label); @@ -104,6 +104,7 @@ END(___CONCAT(_thread_sys_,name)) #define PSYSCALL(name) \ PLEAF(name,0); /* XXX # of args? */ \ + WEAK_ALIAS(__CONCAT(_thread_sys_,name), name); \ CALLSYS_ERROR(name) #define PRSYSCALL(name) \ @@ -114,6 +115,7 @@ PEND(name) #define PPSEUDO(label,name) \ PLEAF(label,0); /* XXX # of args? */ \ + WEAK_ALIAS(__CONCAT(_thread_sys_,name), name); \ CALLSYS_ERROR(name); \ RET; \ PEND(label) diff --git a/lib/libc/amd64/SYS.h b/lib/libc/amd64/SYS.h index 5061052..3494279 100644 --- a/lib/libc/amd64/SYS.h +++ b/lib/libc/amd64/SYS.h @@ -43,18 +43,15 @@ #define SYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ ENTRY(__CONCAT(_,x)); \ - .weak CNAME(__CONCAT(_libc_,x)); \ - .set CNAME(__CONCAT(_libc_,x)),CNAME(__CONCAT(_,x)); \ .weak CNAME(x); \ - .set CNAME(x),CNAME(__CONCAT(_libc_,x)); \ + .set CNAME(x),CNAME(__CONCAT(_,x)); \ lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b + #define RSYSCALL(x) SYSCALL(x); ret #define PSEUDO(x,y) ENTRY(__CONCAT(_,x)); \ - .weak CNAME(__CONCAT(_libc_,x)); \ - .set CNAME(__CONCAT(_libc_,x)),CNAME(__CONCAT(_,x)); \ .weak CNAME(x); \ - .set CNAME(x),CNAME(__CONCAT(_libc_,x)); \ + .set CNAME(x),CNAME(__CONCAT(_,x)); \ lea __CONCAT(SYS_,y), %eax; KERNCALL; ret /* gas messes up offset -- although we don't currently need it, do for BCS */ @@ -76,9 +73,13 @@ */ #define PSYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ ENTRY(__CONCAT(_thread_sys_,x)); \ + .weak CNAME(x); \ + .set CNAME(x),CNAME(__CONCAT(_thread_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)); \ + .weak CNAME(x); \ + .set CNAME(x),CNAME(__CONCAT(_thread_sys_,x)); \ lea __CONCAT(SYS_,y), %eax; KERNCALL; ret #else /* diff --git a/lib/libc/compat-43/creat.c b/lib/libc/compat-43/creat.c index 51f9828..3d17305 100644 --- a/lib/libc/compat-43/creat.c +++ b/lib/libc/compat-43/creat.c @@ -48,8 +48,7 @@ __creat(path, mode) mode_t mode; #endif { - return(_libc_open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)); + return(_open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)); } -__weak_reference(__creat, _libc_creat); -__weak_reference(_libc_creat, creat); +__weak_reference(__creat, creat); diff --git a/lib/libc/compat-43/sigcompat.c b/lib/libc/compat-43/sigcompat.c index b440ee5..9401e73 100644 --- a/lib/libc/compat-43/sigcompat.c +++ b/lib/libc/compat-43/sigcompat.c @@ -109,5 +109,5 @@ sigpause(mask) sigemptyset(&set); set.__bits[0] = mask; - return (_libc_sigsuspend(&set)); + return (_sigsuspend(&set)); } diff --git a/lib/libc/db/btree/bt_close.c b/lib/libc/db/btree/bt_close.c index fbe6a21..c5e0d52 100644 --- a/lib/libc/db/btree/bt_close.c +++ b/lib/libc/db/btree/bt_close.c @@ -105,7 +105,7 @@ __bt_close(dbp) fd = t->bt_fd; free(t); free(dbp); - return (_libc_close(fd) ? RET_ERROR : RET_SUCCESS); + return (_close(fd) ? RET_ERROR : RET_SUCCESS); } /* diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c index d306993..e838f25 100644 --- a/lib/libc/db/btree/bt_open.c +++ b/lib/libc/db/btree/bt_open.c @@ -203,7 +203,7 @@ __bt_open(fname, flags, mode, openinfo, dflags) goto einval; } - if ((t->bt_fd = _libc_open(fname, flags, mode)) < 0) + if ((t->bt_fd = _open(fname, flags, mode)) < 0) goto err; } else { @@ -214,13 +214,13 @@ __bt_open(fname, flags, mode, openinfo, dflags) F_SET(t, B_INMEM); } - if (_libc_fcntl(t->bt_fd, F_SETFD, 1) == -1) + if (_fcntl(t->bt_fd, F_SETFD, 1) == -1) goto err; if (fstat(t->bt_fd, &sb)) goto err; if (sb.st_size) { - if ((nr = _libc_read(t->bt_fd, &m, sizeof(BTMETA))) < 0) + if ((nr = _read(t->bt_fd, &m, sizeof(BTMETA))) < 0) goto err; if (nr != sizeof(BTMETA)) goto eftype; @@ -336,7 +336,7 @@ err: if (t) { if (t->bt_dbp) free(t->bt_dbp); if (t->bt_fd != -1) - (void)_libc_close(t->bt_fd); + (void)_close(t->bt_fd); free(t); } return (NULL); diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index 0a2f3c6..dcef5df 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -130,7 +130,7 @@ __hash_open(file, flags, mode, info, dflags) new_table = 1; } if (file) { - if ((hashp->fp = _libc_open(file, flags, mode)) == -1) + if ((hashp->fp = _open(file, flags, mode)) == -1) RETURN_ERROR(errno, error0); /* if the .db file is empty, and we had permission to create @@ -139,7 +139,7 @@ __hash_open(file, flags, mode, info, dflags) fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0) new_table = 1; - (void)_libc_fcntl(hashp->fp, F_SETFD, 1); + (void)_fcntl(hashp->fp, F_SETFD, 1); } if (new_table) { if (!(hashp = init_hash(hashp, file, (HASHINFO *)info))) @@ -151,7 +151,7 @@ __hash_open(file, flags, mode, info, dflags) else hashp->hash = __default_hash; - hdrsize = _libc_read(hashp->fp, &hashp->hdr, sizeof(HASHHDR)); + hdrsize = _read(hashp->fp, &hashp->hdr, sizeof(HASHHDR)); #if BYTE_ORDER == LITTLE_ENDIAN swap_header(hashp); #endif @@ -242,7 +242,7 @@ __hash_open(file, flags, mode, info, dflags) error1: if (hashp != NULL) - (void)_libc_close(hashp->fp); + (void)_close(hashp->fp); error0: free(hashp); @@ -440,7 +440,7 @@ hdestroy(hashp) free(hashp->mapp[i]); if (hashp->fp != -1) - (void)_libc_close(hashp->fp); + (void)_close(hashp->fp); free(hashp); @@ -509,7 +509,7 @@ flush_meta(hashp) swap_header_copy(&hashp->hdr, whdrp); #endif if ((lseek(fp, (off_t)0, SEEK_SET) == -1) || - ((wsize = _libc_write(fp, whdrp, sizeof(HASHHDR))) == -1)) + ((wsize = _write(fp, whdrp, sizeof(HASHHDR))) == -1)) return (-1); else if (wsize != sizeof(HASHHDR)) { diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c index 7a204ab..30445e4 100644 --- a/lib/libc/db/hash/hash_page.c +++ b/lib/libc/db/hash/hash_page.c @@ -539,7 +539,7 @@ __get_page(hashp, p, bucket, is_bucket, is_disk, is_bitmap) else page = OADDR_TO_PAGE(bucket); if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) || - ((rsize = _libc_read(fd, p, size)) == -1)) + ((rsize = _read(fd, p, size)) == -1)) return (-1); bp = (u_int16_t *)p; if (!rsize) @@ -610,7 +610,7 @@ __put_page(hashp, p, bucket, is_bucket, is_bitmap) else page = OADDR_TO_PAGE(bucket); if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) || - ((wsize = _libc_write(fd, p, size)) == -1)) + ((wsize = _write(fd, p, size)) == -1)) /* Errno is set */ return (-1); if (wsize != size) { @@ -714,8 +714,7 @@ overflow_page(hashp) #define OVMSG "HASH: Out of overflow pages. Increase page size\n" if (offset > SPLITMASK) { if (++splitnum >= NCACHED) { - (void)_libc_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - - 1); + (void)_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); return (0); } hashp->OVFL_POINT = splitnum; @@ -728,8 +727,7 @@ overflow_page(hashp) if (free_bit == (hashp->BSIZE << BYTE_SHIFT) - 1) { free_page++; if (free_page >= NCACHED) { - (void)_libc_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - - 1); + (void)_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); return (0); } /* @@ -753,7 +751,7 @@ overflow_page(hashp) offset++; if (offset > SPLITMASK) { if (++splitnum >= NCACHED) { - (void)_libc_write(STDERR_FILENO, OVMSG, + (void)_write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); return (0); } @@ -871,7 +869,7 @@ open_temp(hashp) (void)sigprocmask(SIG_BLOCK, &set, &oset); if ((hashp->fp = mkstemp(namestr)) != -1) { (void)unlink(namestr); - (void)_libc_fcntl(hashp->fp, F_SETFD, 1); + (void)_fcntl(hashp->fp, F_SETFD, 1); } (void)sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL); return (hashp->fp != -1 ? 0 : -1); diff --git a/lib/libc/db/mpool/mpool.c b/lib/libc/db/mpool/mpool.c index 00d0740..29377d3 100644 --- a/lib/libc/db/mpool/mpool.c +++ b/lib/libc/db/mpool/mpool.c @@ -207,7 +207,7 @@ mpool_get(mp, pgno, flags) off = mp->pagesize * pgno; if (lseek(mp->fd, off, SEEK_SET) != off) return (NULL); - if ((nr = _libc_read(mp->fd, bp->page, mp->pagesize)) != mp->pagesize) { + if ((nr = _read(mp->fd, bp->page, mp->pagesize)) != mp->pagesize) { if (nr >= 0) errno = EFTYPE; return (NULL); @@ -299,7 +299,7 @@ mpool_sync(mp) return (RET_ERROR); /* Sync the file descriptor. */ - return (_libc_fsync(mp->fd) ? RET_ERROR : RET_SUCCESS); + return (_fsync(mp->fd) ? RET_ERROR : RET_SUCCESS); } /* @@ -382,7 +382,7 @@ mpool_write(mp, bp) off = mp->pagesize * bp->pgno; if (lseek(mp->fd, off, SEEK_SET) != off) return (RET_ERROR); - if (_libc_write(mp->fd, bp->page, mp->pagesize) != mp->pagesize) + if (_write(mp->fd, bp->page, mp->pagesize) != mp->pagesize) return (RET_ERROR); bp->flags &= ~MPOOL_DIRTY; diff --git a/lib/libc/db/recno/rec_close.c b/lib/libc/db/recno/rec_close.c index d1f50938..25d01de 100644 --- a/lib/libc/db/recno/rec_close.c +++ b/lib/libc/db/recno/rec_close.c @@ -86,7 +86,7 @@ __rec_close(dbp) if (fclose(t->bt_rfp)) status = RET_ERROR; } else - if (_libc_close(t->bt_rfd)) + if (_close(t->bt_rfd)) status = RET_ERROR; if (__bt_close(dbp) == RET_ERROR) @@ -152,7 +152,7 @@ __rec_sync(dbp, flags) */ status = (dbp->seq)(dbp, &key, &data, R_FIRST); while (status == RET_SUCCESS) { - if (_libc_write(t->bt_rfd, data.data, data.size) != + if (_write(t->bt_rfd, data.data, data.size) != data.size) return (RET_ERROR); status = (dbp->seq)(dbp, &key, &data, R_NEXT); diff --git a/lib/libc/db/recno/rec_open.c b/lib/libc/db/recno/rec_open.c index 55da040..eaeacc5 100644 --- a/lib/libc/db/recno/rec_open.c +++ b/lib/libc/db/recno/rec_open.c @@ -68,7 +68,7 @@ __rec_open(fname, flags, mode, openinfo, dflags) int rfd, sverrno; /* Open the user's file -- if this fails, we're done. */ - if (fname != NULL && (rfd = _libc_open(fname, flags, mode)) < 0) + if (fname != NULL && (rfd = _open(fname, flags, mode)) < 0) return (NULL); /* Create a btree in memory (backed by disk). */ @@ -215,7 +215,7 @@ err: sverrno = errno; if (dbp != NULL) (void)__bt_close(dbp); if (fname != NULL) - (void)_libc_close(rfd); + (void)_close(rfd); errno = sverrno; return (NULL); } diff --git a/lib/libc/gen/arc4random.c b/lib/libc/gen/arc4random.c index 186efa3..c0569e5 100644 --- a/lib/libc/gen/arc4random.c +++ b/lib/libc/gen/arc4random.c @@ -84,10 +84,10 @@ arc4_stir(as) gettimeofday(&rdat.tv, NULL); rdat.pid = getpid(); - fd = _libc_open("/dev/urandom", O_RDONLY, 0); + fd = _open("/dev/urandom", O_RDONLY, 0); if (fd >= 0) { - (void) _libc_read(fd, rdat.rnd, sizeof(rdat.rnd)); - _libc_close(fd); + (void) _read(fd, rdat.rnd, sizeof(rdat.rnd)); + _close(fd); } /* fd < 0? Ah, what the heck. We'll just take whatever was on the * stack... */ diff --git a/lib/libc/gen/closedir.c b/lib/libc/gen/closedir.c index 7f658b8..86de88d 100644 --- a/lib/libc/gen/closedir.c +++ b/lib/libc/gen/closedir.c @@ -60,5 +60,5 @@ closedir(dirp) free((void *)dirp->dd_buf); free((void *)dirp); _reclaim_telldir(dirp); - return(_libc_close(fd)); + return(_close(fd)); } diff --git a/lib/libc/gen/daemon.c b/lib/libc/gen/daemon.c index 0c490e5..4f6c2f3 100644 --- a/lib/libc/gen/daemon.c +++ b/lib/libc/gen/daemon.c @@ -62,12 +62,12 @@ daemon(nochdir, noclose) if (!nochdir) (void)chdir("/"); - if (!noclose && (fd = _libc_open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { + 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); if (fd > 2) - (void)_libc_close(fd); + (void)_close(fd); } return (0); } diff --git a/lib/libc/gen/exec.c b/lib/libc/gen/exec.c index 087a2a9..04bd2d2 100644 --- a/lib/libc/gen/exec.c +++ b/lib/libc/gen/exec.c @@ -249,9 +249,9 @@ execvp(name, argv) * the user may execute the wrong program. */ if (lp + ln + 2 > sizeof(buf)) { - (void)_libc_write(STDERR_FILENO, "execvp: ", 8); - (void)_libc_write(STDERR_FILENO, p, lp); - (void)_libc_write(STDERR_FILENO, ": path too long\n", + (void)_write(STDERR_FILENO, "execvp: ", 8); + (void)_write(STDERR_FILENO, p, lp); + (void)_write(STDERR_FILENO, ": path too long\n", 16); continue; } diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c index 2495c12..ecd79fb 100644 --- a/lib/libc/gen/fstab.c +++ b/lib/libc/gen/fstab.c @@ -253,12 +253,12 @@ error(err) char *p; char num[30]; - (void)_libc_write(STDERR_FILENO, "fstab: ", 7); - (void)_libc_write(STDERR_FILENO, _PATH_FSTAB, sizeof(_PATH_FSTAB) - 1); - (void)_libc_write(STDERR_FILENO, ":", 1); + (void)_write(STDERR_FILENO, "fstab: ", 7); + (void)_write(STDERR_FILENO, _PATH_FSTAB, sizeof(_PATH_FSTAB) - 1); + (void)_write(STDERR_FILENO, ":", 1); sprintf(num, "%d: ", LineNo); - (void)_libc_write(STDERR_FILENO, num, strlen(num)); + (void)_write(STDERR_FILENO, num, strlen(num)); p = strerror(err); - (void)_libc_write(STDERR_FILENO, p, strlen(p)); - (void)_libc_write(STDERR_FILENO, "\n", 1); + (void)_write(STDERR_FILENO, p, strlen(p)); + (void)_write(STDERR_FILENO, "\n", 1); } diff --git a/lib/libc/gen/fts-compat.c b/lib/libc/gen/fts-compat.c index bcab9d7..6b92a12 100644 --- a/lib/libc/gen/fts-compat.c +++ b/lib/libc/gen/fts-compat.c @@ -178,8 +178,7 @@ fts_open(argv, options, compar) * and ".." are all fairly nasty problems. Note, if we can't get the * descriptor we run anyway, just more slowly. */ - if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _libc_open(".", O_RDONLY, 0)) - < 0) + if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _open(".", O_RDONLY, 0)) < 0) SET(FTS_NOCHDIR); return (sp); @@ -248,7 +247,7 @@ fts_close(sp) /* Return to original directory, save errno if necessary. */ if (!ISSET(FTS_NOCHDIR)) { saved_errno = fchdir(sp->fts_rfd) ? errno : 0; - (void)_libc_close(sp->fts_rfd); + (void)_close(sp->fts_rfd); /* Set errno and return. */ if (saved_errno != 0) { @@ -308,7 +307,7 @@ fts_read(sp) (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { p->fts_info = fts_stat(sp, p, 1); if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = _libc_open(".", O_RDONLY, 0)) < 0) { + if ((p->fts_symfd = _open(".", O_RDONLY, 0)) < 0) { p->fts_errno = errno; p->fts_info = FTS_ERR; } else @@ -323,7 +322,7 @@ fts_read(sp) if (instr == FTS_SKIP || (ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) { if (p->fts_flags & FTS_SYMFOLLOW) - (void)_libc_close(p->fts_symfd); + (void)_close(p->fts_symfd); if (sp->fts_child) { fts_lfree(sp->fts_child); sp->fts_child = NULL; @@ -398,7 +397,7 @@ next: tmp = p; p->fts_info = fts_stat(sp, p, 1); if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { if ((p->fts_symfd = - _libc_open(".", O_RDONLY, 0)) < 0) { + _open(".", O_RDONLY, 0)) < 0) { p->fts_errno = errno; p->fts_info = FTS_ERR; } else @@ -443,12 +442,12 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent); } else if (p->fts_flags & FTS_SYMFOLLOW) { if (FCHDIR(sp, p->fts_symfd)) { saved_errno = errno; - (void)_libc_close(p->fts_symfd); + (void)_close(p->fts_symfd); errno = saved_errno; SET(FTS_STOP); return (NULL); } - (void)_libc_close(p->fts_symfd); + (void)_close(p->fts_symfd); } else if (!(p->fts_flags & FTS_DONTCHDIR)) { if (CHDIR(sp, "..")) { SET(FTS_STOP); @@ -540,12 +539,12 @@ fts_children(sp, instr) ISSET(FTS_NOCHDIR)) return (sp->fts_child = fts_build(sp, instr)); - if ((fd = _libc_open(".", O_RDONLY, 0)) < 0) + if ((fd = _open(".", O_RDONLY, 0)) < 0) return (NULL); sp->fts_child = fts_build(sp, instr); if (fchdir(fd)) return (NULL); - (void)_libc_close(fd); + (void)_close(fd); return (sp->fts_child); } @@ -1094,7 +1093,7 @@ fts_safe_changedir(sp, p, fd) newfd = fd; if (ISSET(FTS_NOCHDIR)) return (0); - if (fd < 0 && (newfd = _libc_open(p->fts_accpath, O_RDONLY, 0)) < 0) + if (fd < 0 && (newfd = _open(p->fts_accpath, O_RDONLY, 0)) < 0) return (-1); if (fstat(newfd, &sb)) { ret = -1; @@ -1109,7 +1108,7 @@ fts_safe_changedir(sp, p, fd) bail: oerrno = errno; if (fd < 0) - (void)_libc_close(newfd); + (void)_close(newfd); errno = oerrno; return (ret); } diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index bcab9d7..6b92a12 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -178,8 +178,7 @@ fts_open(argv, options, compar) * and ".." are all fairly nasty problems. Note, if we can't get the * descriptor we run anyway, just more slowly. */ - if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _libc_open(".", O_RDONLY, 0)) - < 0) + if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _open(".", O_RDONLY, 0)) < 0) SET(FTS_NOCHDIR); return (sp); @@ -248,7 +247,7 @@ fts_close(sp) /* Return to original directory, save errno if necessary. */ if (!ISSET(FTS_NOCHDIR)) { saved_errno = fchdir(sp->fts_rfd) ? errno : 0; - (void)_libc_close(sp->fts_rfd); + (void)_close(sp->fts_rfd); /* Set errno and return. */ if (saved_errno != 0) { @@ -308,7 +307,7 @@ fts_read(sp) (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { p->fts_info = fts_stat(sp, p, 1); if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = _libc_open(".", O_RDONLY, 0)) < 0) { + if ((p->fts_symfd = _open(".", O_RDONLY, 0)) < 0) { p->fts_errno = errno; p->fts_info = FTS_ERR; } else @@ -323,7 +322,7 @@ fts_read(sp) if (instr == FTS_SKIP || (ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) { if (p->fts_flags & FTS_SYMFOLLOW) - (void)_libc_close(p->fts_symfd); + (void)_close(p->fts_symfd); if (sp->fts_child) { fts_lfree(sp->fts_child); sp->fts_child = NULL; @@ -398,7 +397,7 @@ next: tmp = p; p->fts_info = fts_stat(sp, p, 1); if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { if ((p->fts_symfd = - _libc_open(".", O_RDONLY, 0)) < 0) { + _open(".", O_RDONLY, 0)) < 0) { p->fts_errno = errno; p->fts_info = FTS_ERR; } else @@ -443,12 +442,12 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent); } else if (p->fts_flags & FTS_SYMFOLLOW) { if (FCHDIR(sp, p->fts_symfd)) { saved_errno = errno; - (void)_libc_close(p->fts_symfd); + (void)_close(p->fts_symfd); errno = saved_errno; SET(FTS_STOP); return (NULL); } - (void)_libc_close(p->fts_symfd); + (void)_close(p->fts_symfd); } else if (!(p->fts_flags & FTS_DONTCHDIR)) { if (CHDIR(sp, "..")) { SET(FTS_STOP); @@ -540,12 +539,12 @@ fts_children(sp, instr) ISSET(FTS_NOCHDIR)) return (sp->fts_child = fts_build(sp, instr)); - if ((fd = _libc_open(".", O_RDONLY, 0)) < 0) + if ((fd = _open(".", O_RDONLY, 0)) < 0) return (NULL); sp->fts_child = fts_build(sp, instr); if (fchdir(fd)) return (NULL); - (void)_libc_close(fd); + (void)_close(fd); return (sp->fts_child); } @@ -1094,7 +1093,7 @@ fts_safe_changedir(sp, p, fd) newfd = fd; if (ISSET(FTS_NOCHDIR)) return (0); - if (fd < 0 && (newfd = _libc_open(p->fts_accpath, O_RDONLY, 0)) < 0) + if (fd < 0 && (newfd = _open(p->fts_accpath, O_RDONLY, 0)) < 0) return (-1); if (fstat(newfd, &sb)) { ret = -1; @@ -1109,7 +1108,7 @@ fts_safe_changedir(sp, p, fd) bail: oerrno = errno; if (fd < 0) - (void)_libc_close(newfd); + (void)_close(newfd); errno = oerrno; return (ret); } diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c index aaa1372..4e41a79 100644 --- a/lib/libc/gen/getcap.c +++ b/lib/libc/gen/getcap.c @@ -268,7 +268,7 @@ getent(cap, len, db_array, fd, name, depth, nfield) *cap = cbuf; return (retval); } else { - fd = _libc_open(*db_p, O_RDONLY, 0); + fd = _open(*db_p, O_RDONLY, 0); if (fd < 0) continue; myfd = 1; @@ -303,10 +303,10 @@ getent(cap, len, db_array, fd, name, depth, nfield) if (bp >= b_end) { int n; - n = _libc_read(fd, buf, sizeof(buf)); + n = _read(fd, buf, sizeof(buf)); if (n <= 0) { if (myfd) - (void)_libc_close(fd); + (void)_close(fd); if (n < 0) { free(record); return (-2); @@ -345,7 +345,7 @@ getent(cap, len, db_array, fd, name, depth, nfield) if (record == NULL) { errno = ENOMEM; if (myfd) - (void)_libc_close(fd); + (void)_close(fd); return (-2); } r_end = record + newsize; @@ -435,7 +435,7 @@ tc_exp: { /* an error */ if (iret < -1) { if (myfd) - (void)_libc_close(fd); + (void)_close(fd); free(record); return (iret); } @@ -485,7 +485,7 @@ tc_exp: { if (record == NULL) { errno = ENOMEM; if (myfd) - (void)_libc_close(fd); + (void)_close(fd); free(icap); return (-2); } @@ -517,7 +517,7 @@ tc_exp: { * return capability, length and success. */ if (myfd) - (void)_libc_close(fd); + (void)_close(fd); *len = rp - record - 1; /* don't count NUL */ if (r_end > rp) if ((record = diff --git a/lib/libc/gen/getpass.c b/lib/libc/gen/getpass.c index 727d58a..60e92b7 100644 --- a/lib/libc/gen/getpass.c +++ b/lib/libc/gen/getpass.c @@ -86,7 +86,7 @@ getpass(prompt) if (p < buf + _PASSWORD_LEN) *p++ = ch; *p = '\0'; - (void)_libc_write(fileno(outfp), "\n", 1); + (void)_write(fileno(outfp), "\n", 1); (void)tcsetattr(fileno(fp), TCSAFLUSH|TCSASOFT, &oterm); (void)sigprocmask(SIG_SETMASK, &oset, NULL); diff --git a/lib/libc/gen/lockf.c b/lib/libc/gen/lockf.c index 4d6874b..15b5b21 100644 --- a/lib/libc/gen/lockf.c +++ b/lib/libc/gen/lockf.c @@ -75,7 +75,7 @@ lockf(filedes, function, size) break; case F_TEST: fl.l_type = F_WRLCK; - if (_libc_fcntl(filedes, F_GETLK, &fl) == -1) + if (_fcntl(filedes, F_GETLK, &fl) == -1) return (-1); if (fl.l_type == F_UNLCK || fl.l_pid == getpid()) return (0); @@ -88,5 +88,5 @@ lockf(filedes, function, size) /* NOTREACHED */ } - return (_libc_fcntl(filedes, cmd, &fl)); + return (_fcntl(filedes, cmd, &fl)); } diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c index 09e93aa..f459067 100644 --- a/lib/libc/gen/nlist.c +++ b/lib/libc/gen/nlist.c @@ -66,11 +66,11 @@ nlist(name, list) { int fd, n; - fd = _libc_open(name, O_RDONLY, 0); + fd = _open(name, O_RDONLY, 0); if (fd < 0) return (-1); n = __fdnlist(fd, list); - (void)_libc_close(fd); + (void)_close(fd); return (n); } @@ -255,7 +255,7 @@ __elf_fdnlist(fd, list) /* Make sure obj is OK */ if (lseek(fd, (off_t)0, SEEK_SET) == -1 || - _libc_read(fd, &ehdr, sizeof(Elf_Ehdr)) != sizeof(Elf_Ehdr) || + _read(fd, &ehdr, sizeof(Elf_Ehdr)) != sizeof(Elf_Ehdr) || !__elf_is_okay__(&ehdr) || fstat(fd, &st) < 0) return (-1); @@ -339,7 +339,7 @@ __elf_fdnlist(fd, list) while (symsize > 0 && nent > 0) { cc = MIN(symsize, sizeof(sbuf)); - if (_libc_read(fd, sbuf, cc) != cc) + if (_read(fd, sbuf, cc) != cc) break; symsize -= cc; for (s = sbuf; cc > 0 && nent > 0; ++s, cc -= sizeof(*s)) { diff --git a/lib/libc/gen/opendir.c b/lib/libc/gen/opendir.c index 077805d..d94b9af 100644 --- a/lib/libc/gen/opendir.c +++ b/lib/libc/gen/opendir.c @@ -80,7 +80,7 @@ __opendir2(name, flags) errno = ENOTDIR; return (NULL); } - if ((fd = _libc_open(name, O_RDONLY | O_NONBLOCK)) == -1) + if ((fd = _open(name, O_RDONLY | O_NONBLOCK)) == -1) return (NULL); dirp = NULL; if (fstat(fd, &statb) != 0) @@ -89,7 +89,7 @@ __opendir2(name, flags) errno = ENOTDIR; goto fail; } - if (_libc_fcntl(fd, F_SETFD, FD_CLOEXEC) == -1 || + if (_fcntl(fd, F_SETFD, FD_CLOEXEC) == -1 || (dirp = malloc(sizeof(DIR))) == NULL) goto fail; @@ -163,8 +163,8 @@ __opendir2(name, flags) * which has also been read -- see fts.c. */ if (flags & DTF_REWIND) { - (void)_libc_close(fd); - if ((fd = _libc_open(name, O_RDONLY)) == -1) { + (void)_close(fd); + if ((fd = _open(name, O_RDONLY)) == -1) { saved_errno = errno; free(buf); free(dirp); @@ -270,7 +270,7 @@ __opendir2(name, flags) fail: saved_errno = errno; free(dirp); - (void)_libc_close(fd); + (void)_close(fd); errno = saved_errno; return (NULL); } diff --git a/lib/libc/gen/pause.c b/lib/libc/gen/pause.c index b1e976e..3327c96 100644 --- a/lib/libc/gen/pause.c +++ b/lib/libc/gen/pause.c @@ -49,5 +49,4 @@ __pause() return sigpause(sigblock(0L)); } -__weak_reference(__pause, _libc_pause); -__weak_reference(_libc_pause, pause); +__weak_reference(__pause, pause); diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c index c744efd..7939b8f 100644 --- a/lib/libc/gen/popen.c +++ b/lib/libc/gen/popen.c @@ -85,8 +85,8 @@ popen(command, type) return (NULL); if ((cur = malloc(sizeof(struct pid))) == NULL) { - (void)_libc_close(pdes[0]); - (void)_libc_close(pdes[1]); + (void)_close(pdes[0]); + (void)_close(pdes[1]); return (NULL); } @@ -97,8 +97,8 @@ popen(command, type) switch (pid = vfork()) { case -1: /* Error. */ - (void)_libc_close(pdes[0]); - (void)_libc_close(pdes[1]); + (void)_close(pdes[0]); + (void)_close(pdes[1]); free(cur); return (NULL); /* NOTREACHED */ @@ -112,10 +112,10 @@ popen(command, type) * the compiler is free to corrupt all the local * variables. */ - (void)_libc_close(pdes[0]); + (void)_close(pdes[0]); if (pdes[1] != STDOUT_FILENO) { (void)dup2(pdes[1], STDOUT_FILENO); - (void)_libc_close(pdes[1]); + (void)_close(pdes[1]); if (twoway) (void)dup2(STDOUT_FILENO, STDIN_FILENO); } else if (twoway && (pdes[1] != STDIN_FILENO)) @@ -123,12 +123,12 @@ popen(command, type) } else { if (pdes[0] != STDIN_FILENO) { (void)dup2(pdes[0], STDIN_FILENO); - (void)_libc_close(pdes[0]); + (void)_close(pdes[0]); } - (void)_libc_close(pdes[1]); + (void)_close(pdes[1]); } for (p = pidlist; p; p = p->next) { - (void)_libc_close(fileno(p->fp)); + (void)_close(fileno(p->fp)); } execve(_PATH_BSHELL, argv, environ); _exit(127); @@ -138,10 +138,10 @@ popen(command, type) /* Parent; assume fdopen can't fail. */ if (*type == 'r') { iop = fdopen(pdes[0], type); - (void)_libc_close(pdes[1]); + (void)_close(pdes[1]); } else { iop = fdopen(pdes[1], type); - (void)_libc_close(pdes[0]); + (void)_close(pdes[0]); } /* Link into list of file descriptors. */ @@ -177,7 +177,7 @@ pclose(iop) (void)fclose(iop); do { - pid = _libc_waitpid(cur->pid, &pstat, 0); + pid = _wait4(cur->pid, &pstat, 0, (struct rusage *)0); } while (pid == -1 && errno == EINTR); /* Remove the entry from the linked list. */ diff --git a/lib/libc/gen/psignal.c b/lib/libc/gen/psignal.c index 704a3ae..7c25476 100644 --- a/lib/libc/gen/psignal.c +++ b/lib/libc/gen/psignal.c @@ -57,9 +57,9 @@ psignal(sig, s) else c = "Unknown signal"; if (s != NULL && *s != '\0') { - (void)_libc_write(STDERR_FILENO, s, strlen(s)); - (void)_libc_write(STDERR_FILENO, ": ", 2); + (void)_write(STDERR_FILENO, s, strlen(s)); + (void)_write(STDERR_FILENO, ": ", 2); } - (void)_libc_write(STDERR_FILENO, c, strlen(c)); - (void)_libc_write(STDERR_FILENO, "\n", 1); + (void)_write(STDERR_FILENO, c, strlen(c)); + (void)_write(STDERR_FILENO, "\n", 1); } diff --git a/lib/libc/gen/setjmperr.c b/lib/libc/gen/setjmperr.c index e1fa498..e9b5d45 100644 --- a/lib/libc/gen/setjmperr.c +++ b/lib/libc/gen/setjmperr.c @@ -51,5 +51,5 @@ void longjmperror() { #define ERRMSG "longjmp botch.\n" - (void)_libc_write(STDERR_FILENO, ERRMSG, sizeof(ERRMSG) - 1); + (void)_write(STDERR_FILENO, ERRMSG, sizeof(ERRMSG) - 1); } diff --git a/lib/libc/gen/sleep.c b/lib/libc/gen/sleep.c index 4a35cf0..2508e9a 100644 --- a/lib/libc/gen/sleep.c +++ b/lib/libc/gen/sleep.c @@ -60,7 +60,7 @@ __sleep(seconds) time_to_sleep.tv_sec = seconds; time_to_sleep.tv_nsec = 0; - if (_libc_nanosleep(&time_to_sleep, &time_remaining) != -1) + if (_nanosleep(&time_to_sleep, &time_remaining) != -1) return (0); if (errno != EINTR) return (seconds); /* best guess */ @@ -68,5 +68,4 @@ __sleep(seconds) (time_remaining.tv_nsec != 0)); /* round up */ } -__weak_reference(__sleep, _libc_sleep); -__weak_reference(_libc_sleep, sleep); +__weak_reference(__sleep, sleep); diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c index 2a53432..18d00d7 100644 --- a/lib/libc/gen/syslog.c +++ b/lib/libc/gen/syslog.c @@ -260,7 +260,7 @@ vsyslog(pri, fmt, ap) * is the one from the syslogd failure. */ if (LogStat & LOG_CONS && - (fd = _libc_open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) { + (fd = _open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) { struct iovec iov[2]; register struct iovec *v = iov; @@ -271,7 +271,7 @@ vsyslog(pri, fmt, ap) v->iov_base = "\r\n"; v->iov_len = 2; (void)writev(fd, iov, 2); - (void)_libc_close(fd); + (void)_close(fd); } } static void @@ -283,7 +283,7 @@ disconnectlog() * system services. */ if (LogFile != -1) { - _libc_close(LogFile); + _close(LogFile); LogFile = -1; } connected = 0; /* retry connect */ @@ -297,7 +297,7 @@ connectlog() if (LogFile == -1) { if ((LogFile = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) return; - (void)_libc_fcntl(LogFile, F_SETFD, 1); + (void)_fcntl(LogFile, F_SETFD, 1); } if (LogFile != -1 && !connected) { SyslogAddr.sun_len = sizeof(SyslogAddr); @@ -320,7 +320,7 @@ connectlog() } if (!connected) { - (void)_libc_close(LogFile); + (void)_close(LogFile); LogFile = -1; } } @@ -346,7 +346,7 @@ openlog(ident, logstat, logfac) void closelog() { - (void)_libc_close(LogFile); + (void)_close(LogFile); LogFile = -1; connected = 0; } diff --git a/lib/libc/gen/termios.c b/lib/libc/gen/termios.c index 70ac8f0..466827e 100644 --- a/lib/libc/gen/termios.c +++ b/lib/libc/gen/termios.c @@ -195,8 +195,7 @@ __tcdrain(fd) return (ioctl(fd, TIOCDRAIN, 0)); } -__weak_reference(__tcdrain, _libc_tcdrain); -__weak_reference(_libc_tcdrain, tcdrain); +__weak_reference(__tcdrain, tcdrain); int tcflush(fd, which) @@ -238,8 +237,7 @@ tcflow(fd, action) if (tcgetattr(fd, &term) == -1) return (-1); c = term.c_cc[action == TCIOFF ? VSTOP : VSTART]; - if (c != _POSIX_VDISABLE && _libc_write(fd, &c, sizeof(c)) == - -1) + if (c != _POSIX_VDISABLE && _write(fd, &c, sizeof(c)) == -1) return (-1); return (0); default: diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c index 05b6927..651edf9 100644 --- a/lib/libc/gen/usleep.c +++ b/lib/libc/gen/usleep.c @@ -50,5 +50,5 @@ usleep(useconds) time_to_sleep.tv_nsec = (useconds % 1000000) * 1000; time_to_sleep.tv_sec = useconds / 1000000; - return (_libc_nanosleep(&time_to_sleep, NULL)); + return (_nanosleep(&time_to_sleep, NULL)); } diff --git a/lib/libc/gen/wait.c b/lib/libc/gen/wait.c index 21f4d11..2f9ca6e 100644 --- a/lib/libc/gen/wait.c +++ b/lib/libc/gen/wait.c @@ -49,5 +49,4 @@ __wait(istat) return (wait4(WAIT_ANY, istat, 0, (struct rusage *)0)); } -__weak_reference(__wait, _libc_wait); -__weak_reference(_libc_wait, wait); +__weak_reference(__wait, wait); diff --git a/lib/libc/gen/waitpid.c b/lib/libc/gen/waitpid.c index 14a5e1a..3f679a7 100644 --- a/lib/libc/gen/waitpid.c +++ b/lib/libc/gen/waitpid.c @@ -55,5 +55,4 @@ __waitpid(pid, istat, options) return (wait4(pid, istat, options, (struct rusage *)0)); } -__weak_reference(__waitpid, _libc_waitpid); -__weak_reference(_libc_waitpid, waitpid); +__weak_reference(__waitpid, waitpid); diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c index 938cd02..6bf3d5b 100644 --- a/lib/libc/gmon/gmon.c +++ b/lib/libc/gmon/gmon.c @@ -62,7 +62,7 @@ static int s_scale; /* see profil(2) where this is describe (incorrectly) */ #define SCALE_1_TO_1 0x10000L -#define ERR(s) _libc_write(2, s, sizeof(s)) +#define ERR(s) _write(2, s, sizeof(s)) void moncontrol __P((int)); static int hertz __P((void)); @@ -172,20 +172,20 @@ _mcleanup() moncontrol(0); snprintf(outname,sizeof(outname),"%s.gmon",__progname); - fd = _libc_open(outname, O_CREAT|O_TRUNC|O_WRONLY, 0666); + fd = _open(outname, O_CREAT|O_TRUNC|O_WRONLY, 0666); if (fd < 0) { warnx("_mcleanup: %s - %s",outname,strerror(errno)); return; } #ifdef DEBUG - log = _libc_open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664); + log = _open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664); if (log < 0) { perror("_mcleanup: gmon.log"); return; } len = sprintf(buf, "[mcleanup1] kcount 0x%x ssiz %d\n", p->kcount, p->kcountsize); - _libc_write(log, buf, len); + _write(log, buf, len); #endif hdr = (struct gmonhdr *)&gmonhdr; hdr->lpc = p->lowpc; @@ -193,8 +193,8 @@ _mcleanup() hdr->ncnt = p->kcountsize + sizeof(gmonhdr); hdr->version = GMONVERSION; hdr->profrate = clockinfo.profhz; - _libc_write(fd, (char *)hdr, sizeof *hdr); - _libc_write(fd, p->kcount, p->kcountsize); + _write(fd, (char *)hdr, sizeof *hdr); + _write(fd, p->kcount, p->kcountsize); endfrom = p->fromssize / sizeof(*p->froms); for (fromindex = 0; fromindex < endfrom; fromindex++) { if (p->froms[fromindex] == 0) @@ -209,15 +209,15 @@ _mcleanup() "[mcleanup2] frompc 0x%x selfpc 0x%x count %d\n" , frompc, p->tos[toindex].selfpc, p->tos[toindex].count); - _libc_write(log, buf, len); + _write(log, buf, len); #endif rawarc.raw_frompc = frompc; rawarc.raw_selfpc = p->tos[toindex].selfpc; rawarc.raw_count = p->tos[toindex].count; - _libc_write(fd, &rawarc, sizeof rawarc); + _write(fd, &rawarc, sizeof rawarc); } } - _libc_close(fd); + _close(fd); } /* diff --git a/lib/libc/i386/SYS.h b/lib/libc/i386/SYS.h index 5061052..3494279 100644 --- a/lib/libc/i386/SYS.h +++ b/lib/libc/i386/SYS.h @@ -43,18 +43,15 @@ #define SYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ ENTRY(__CONCAT(_,x)); \ - .weak CNAME(__CONCAT(_libc_,x)); \ - .set CNAME(__CONCAT(_libc_,x)),CNAME(__CONCAT(_,x)); \ .weak CNAME(x); \ - .set CNAME(x),CNAME(__CONCAT(_libc_,x)); \ + .set CNAME(x),CNAME(__CONCAT(_,x)); \ lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b + #define RSYSCALL(x) SYSCALL(x); ret #define PSEUDO(x,y) ENTRY(__CONCAT(_,x)); \ - .weak CNAME(__CONCAT(_libc_,x)); \ - .set CNAME(__CONCAT(_libc_,x)),CNAME(__CONCAT(_,x)); \ .weak CNAME(x); \ - .set CNAME(x),CNAME(__CONCAT(_libc_,x)); \ + .set CNAME(x),CNAME(__CONCAT(_,x)); \ lea __CONCAT(SYS_,y), %eax; KERNCALL; ret /* gas messes up offset -- although we don't currently need it, do for BCS */ @@ -76,9 +73,13 @@ */ #define PSYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ ENTRY(__CONCAT(_thread_sys_,x)); \ + .weak CNAME(x); \ + .set CNAME(x),CNAME(__CONCAT(_thread_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)); \ + .weak CNAME(x); \ + .set CNAME(x),CNAME(__CONCAT(_thread_sys_,x)); \ lea __CONCAT(SYS_,y), %eax; KERNCALL; ret #else /* diff --git a/lib/libc/locale/collate.c b/lib/libc/locale/collate.c index f726898..373019c 100644 --- a/lib/libc/locale/collate.c +++ b/lib/libc/locale/collate.c @@ -177,14 +177,14 @@ __collate_err(int ex, const char *f) int serrno = errno; s = __progname; - _libc_write(STDERR_FILENO, s, strlen(s)); - _libc_write(STDERR_FILENO, ": ", 2); + _write(STDERR_FILENO, s, strlen(s)); + _write(STDERR_FILENO, ": ", 2); s = f; - _libc_write(STDERR_FILENO, s, strlen(s)); - _libc_write(STDERR_FILENO, ": ", 2); + _write(STDERR_FILENO, s, strlen(s)); + _write(STDERR_FILENO, ": ", 2); s = strerror(serrno); - _libc_write(STDERR_FILENO, s, strlen(s)); - _libc_write(STDERR_FILENO, "\n", 1); + _write(STDERR_FILENO, s, strlen(s)); + _write(STDERR_FILENO, "\n", 1); exit(ex); } diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index 414898e..9f0a47a 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -578,7 +578,7 @@ explore_null(pai, hostname, servname, res) s = socket(pai->ai_family, SOCK_DGRAM, 0); if (s < 0) return 0; - _libc_close(s); + _close(s); afd = find_afd(pai->ai_family); if (afd == NULL) return 0; diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c index e3ddf3e..3f39d03 100644 --- a/lib/libc/net/name6.c +++ b/lib/libc/net/name6.c @@ -257,7 +257,7 @@ _ghbyname(const char *name, int af, int flags, int *errp) * (or apropriate interval), * because addresses will be dynamically assigned or deleted. */ - _libc_close(s); + _close(s); } for (i = 0; i < MAXHOSTCONF; i++) { @@ -1184,21 +1184,21 @@ _icmp_fqdn_query(const struct in6_addr *addr, int ifindex) (char *)&filter, sizeof(filter)); cc = sendmsg(s, &msg, 0); if (cc < 0) { - _libc_close(s); + _close(s); return NULL; } FD_SET(s, &s_fds); for (;;) { fds = s_fds; if (select(s + 1, &fds, NULL, NULL, &tout) <= 0) { - _libc_close(s); + _close(s); return NULL; } len = sizeof(sin6); cc = recvfrom(s, buf, sizeof(buf), 0, (struct sockaddr *)&sin6, &len); if (cc <= 0) { - _libc_close(s); + _close(s); return NULL; } if (cc < sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr)) @@ -1209,7 +1209,7 @@ _icmp_fqdn_query(const struct in6_addr *addr, int ifindex) if (fr->icmp6_fqdn_type == ICMP6_FQDN_REPLY) break; } - _libc_close(s); + _close(s); if (fr->icmp6_fqdn_cookie[1] != 0) { /* rfc1788 type */ name = buf + sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr) + 4; diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index 96d5bab..1448f14 100644 --- a/lib/libc/net/rcmd.c +++ b/lib/libc/net/rcmd.c @@ -136,10 +136,10 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) freeaddrinfo(res); return (-1); } - _libc_fcntl(s, F_SETOWN, pid); + _fcntl(s, F_SETOWN, pid); if (connect(s, ai->ai_addr, ai->ai_addrlen) >= 0) break; - (void)_libc_close(s); + (void)_close(s); if (errno == EADDRINUSE) { lport--; continue; @@ -166,7 +166,12 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) continue; } if (refused && timo <= 16) { - (void)_libc_sleep(timo); + struct timespec time_to_sleep, time_remaining; + + time_to_sleep.tv_sec = timo; + time_to_sleep.tv_nsec = 0; + (void)_nanosleep(&time_to_sleep, &time_remaining); + timo *= 2; ai = res; refused = 0; @@ -179,7 +184,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) } lport--; if (fd2p == 0) { - _libc_write(s, "", 1); + _write(s, "", 1); lport = 0; } else { char num[8]; @@ -191,17 +196,17 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) goto bad; listen(s2, 1); (void)snprintf(num, sizeof(num), "%d", lport); - if (_libc_write(s, num, strlen(num)+1) != strlen(num)+1) { + if (_write(s, num, strlen(num)+1) != strlen(num)+1) { (void)fprintf(stderr, "rcmd: write (setting up stderr): %s\n", strerror(errno)); - (void)_libc_close(s2); + (void)_close(s2); goto bad; } nfds = max(s, s2)+1; if(nfds > FD_SETSIZE) { fprintf(stderr, "rcmd: too many files\n"); - (void)_libc_close(s2); + (void)_close(s2); goto bad; } again: @@ -217,7 +222,7 @@ again: else (void)fprintf(stderr, "select: protocol failure in circuit setup\n"); - (void)_libc_close(s2); + (void)_close(s2); goto bad; } s3 = accept(s2, (struct sockaddr *)&from, &len); @@ -239,10 +244,10 @@ again: * down and check for the real auxiliary channel to connect. */ if (aport == 20) { - _libc_close(s3); + _close(s3); goto again; } - (void)_libc_close(s2); + (void)_close(s2); if (s3 < 0) { (void)fprintf(stderr, "rcmd: accept: %s\n", strerror(errno)); @@ -256,17 +261,17 @@ again: goto bad2; } } - (void)_libc_write(s, locuser, strlen(locuser)+1); - (void)_libc_write(s, remuser, strlen(remuser)+1); - (void)_libc_write(s, cmd, strlen(cmd)+1); - if (_libc_read(s, &c, 1) != 1) { + (void)_write(s, locuser, strlen(locuser)+1); + (void)_write(s, remuser, strlen(remuser)+1); + (void)_write(s, cmd, strlen(cmd)+1); + if (_read(s, &c, 1) != 1) { (void)fprintf(stderr, "rcmd: %s: %s\n", *ahost, strerror(errno)); goto bad2; } if (c != 0) { - while (_libc_read(s, &c, 1) == 1) { - (void)_libc_write(STDERR_FILENO, &c, 1); + while (_read(s, &c, 1) == 1) { + (void)_write(STDERR_FILENO, &c, 1); if (c == '\n') break; } @@ -277,9 +282,9 @@ again: return (s); bad2: if (lport) - (void)_libc_close(*fd2p); + (void)_close(*fd2p); bad: - (void)_libc_close(s); + (void)_close(s); sigsetmask(oldmask); freeaddrinfo(res); return (-1); @@ -328,13 +333,13 @@ rresvport_af(alport, family) if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) return (s); if (errno != EADDRINUSE) { - (void)_libc_close(s); + (void)_close(s); return (-1); } #endif *sport = 0; if (bindresvport_sa(s, (struct sockaddr *)&ss) == -1) { - (void)_libc_close(s); + (void)_close(s); return (-1); } *alport = (int)ntohs(*sport); diff --git a/lib/libc/net/res_send.c b/lib/libc/net/res_send.c index b57b8db..68a7c60 100644 --- a/lib/libc/net/res_send.c +++ b/lib/libc/net/res_send.c @@ -428,7 +428,7 @@ res_send(buf, buflen, ans, anssiz) read_len: cp = ans; len = INT16SZ; - while ((n = _libc_read(s, (char *)cp, (int)len)) > 0) { + while ((n = _read(s, (char *)cp, (int)len)) > 0) { cp += n; if ((len -= n) <= 0) break; @@ -476,7 +476,7 @@ read_len: } cp = ans; while (len != 0 && - (n = _libc_read(s, (char *)cp, (int)len)) > 0) { + (n = _read(s, (char *)cp, (int)len)) > 0) { cp += n; len -= n; } @@ -499,7 +499,7 @@ read_len: n = (len > sizeof(junk) ? sizeof(junk) : len); - if ((n = _libc_read(s, junk, n)) > 0) + if ((n = _read(s, junk, n)) > 0) len -= n; else break; @@ -608,7 +608,7 @@ read_len: if (s1 < 0) goto bad_dg_sock; (void)dup2(s1, s); - (void)_libc_close(s1); + (void)_close(s1); Dprint(_res.options & RES_DEBUG, (stdout, ";; new DG socket\n")) #endif /* CAN_RECONNECT */ @@ -893,7 +893,7 @@ void res_close() { if (s >= 0) { - (void)_libc_close(s); + (void)_close(s); s = -1; connected = 0; vc = 0; diff --git a/lib/libc/nls/msgcat.c b/lib/libc/nls/msgcat.c index bdb089a..f1355df 100644 --- a/lib/libc/nls/msgcat.c +++ b/lib/libc/nls/msgcat.c @@ -285,7 +285,7 @@ nl_catd catd; return -1; } - if (cat->loadType != MCLoadAll) _libc_close(cat->fd); + if (cat->loadType != MCLoadAll) _close(cat->fd); for (i = 0; i < cat->numSets; ++i) { set = cat->sets + i; if (!set->invalid) { @@ -321,14 +321,14 @@ __const char *catpath; if (!cat) return(NLERR); cat->loadType = MCLoadBySet; - if ((cat->fd = _libc_open(catpath, O_RDONLY)) < 0) { + if ((cat->fd = _open(catpath, O_RDONLY)) < 0) { free(cat); return(NLERR); } - (void)_libc_fcntl(cat->fd, F_SETFD, FD_CLOEXEC); + (void)_fcntl(cat->fd, F_SETFD, FD_CLOEXEC); - if (_libc_read(cat->fd, &header, sizeof(header)) != sizeof(header)) + if (_read(cat->fd, &header, sizeof(header)) != sizeof(header)) CORRUPT(); if (strncmp(header.magic, MCMagic, MCMagicLen) != 0) CORRUPT(); @@ -369,7 +369,7 @@ __const char *catpath; /* read in the set header */ set = cat->sets + i; - if (_libc_read(cat->fd, set, sizeof(*set)) != sizeof(*set)) { + if (_read(cat->fd, set, sizeof(*set)) != sizeof(*set)) { for (j = 0; j < i; j++) { set = cat->sets + j; if (!set->invalid) { @@ -408,7 +408,7 @@ __const char *catpath; nextSet = set->nextSet; } if (cat->loadType == MCLoadAll) { - _libc_close(cat->fd); + _close(cat->fd); cat->fd = -1; } return((nl_catd) cat); @@ -424,7 +424,7 @@ MCSetT *set; /* Get the data */ if (lseek(cat->fd, set->data.off, 0) == -1) return(0); if ((set->data.str = malloc(set->dataLen)) == NULL) return(-1); - if (_libc_read(cat->fd, set->data.str, set->dataLen) != set->dataLen) { + if (_read(cat->fd, set->data.str, set->dataLen) != set->dataLen) { free(set->data.str); return(0); } @@ -438,7 +438,7 @@ MCSetT *set; for (i = 0; i < set->numMsgs; ++i) { msg = set->u.msgs + i; - if (_libc_read(cat->fd, msg, sizeof(*msg)) != sizeof(*msg)) { + if (_read(cat->fd, msg, sizeof(*msg)) != sizeof(*msg)) { free(set->u.msgs); free(set->data.str); return(0); } if (msg->invalid) { diff --git a/lib/libc/rpc/auth_time.c b/lib/libc/rpc/auth_time.c index 47f5212..836a69f 100644 --- a/lib/libc/rpc/auth_time.c +++ b/lib/libc/rpc/auth_time.c @@ -437,7 +437,7 @@ __rpc_get_time_offset(td, srv, thost, uaddr, netid) msg("alarm caught it, must be unreachable."); goto error; } - res = _libc_read(s, (char *)&thetime, sizeof(thetime)); + res = _read(s, (char *)&thetime, sizeof(thetime)); if (res != sizeof(thetime)) { if (saw_alarm) msg("timed out TCP call."); @@ -449,7 +449,7 @@ __rpc_get_time_offset(td, srv, thost, uaddr, netid) time_valid = 1; } save = errno; - (void)_libc_close(s); + (void)_close(s); errno = save; s = RPC_ANYSOCK; @@ -468,7 +468,7 @@ error: */ if (s != RPC_ANYSOCK) - (void)_libc_close(s); + (void)_close(s); if (clnt != NULL) clnt_destroy(clnt); diff --git a/lib/libc/rpc/clnt_simple.c b/lib/libc/rpc/clnt_simple.c index d9623a9..897eab5 100644 --- a/lib/libc/rpc/clnt_simple.c +++ b/lib/libc/rpc/clnt_simple.c @@ -86,7 +86,7 @@ callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out) } else { crp->valid = 0; if (crp->socket != -1) - (void)_libc_close(crp->socket); + (void)_close(crp->socket); crp->socket = RPC_ANYSOCK; if (crp->client) { clnt_destroy(crp->client); diff --git a/lib/libc/rpc/clnt_tcp.c b/lib/libc/rpc/clnt_tcp.c index 6cddb7b..1889694 100644 --- a/lib/libc/rpc/clnt_tcp.c +++ b/lib/libc/rpc/clnt_tcp.c @@ -167,7 +167,7 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; if (*sockp != -1) - (void)_libc_close(*sockp); + (void)_close(*sockp); goto fooy; } ct->ct_closeit = TRUE; @@ -200,7 +200,7 @@ clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) XDR_ENCODE); if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) { if (ct->ct_closeit) { - (void)_libc_close(*sockp); + (void)_close(*sockp); } goto fooy; } @@ -474,7 +474,7 @@ clnttcp_destroy(h) (struct ct_data *) h->cl_private; if (ct->ct_closeit) { - (void)_libc_close(ct->ct_sock); + (void)_close(ct->ct_sock); } XDR_DESTROY(&(ct->ct_xdrs)); mem_free((caddr_t)ct, sizeof(struct ct_data)); @@ -544,7 +544,7 @@ readtcp(ct, buf, len) } break; } - switch (len = _libc_read(ct->ct_sock, buf, len)) { + switch (len = _read(ct->ct_sock, buf, len)) { case 0: /* premature eof */ @@ -570,7 +570,7 @@ writetcp(ct, buf, len) register int i, cnt; for (cnt = len; cnt > 0; cnt -= i, buf += i) { - if ((i = _libc_write(ct->ct_sock, buf, cnt)) == -1) { + if ((i = _write(ct->ct_sock, buf, cnt)) == -1) { ct->ct_error.re_errno = errno; ct->ct_error.re_status = RPC_CANTSEND; return (-1); diff --git a/lib/libc/rpc/clnt_udp.c b/lib/libc/rpc/clnt_udp.c index f7f7b50..3dc7710 100644 --- a/lib/libc/rpc/clnt_udp.c +++ b/lib/libc/rpc/clnt_udp.c @@ -559,7 +559,7 @@ clntudp_destroy(cl) register struct cu_data *cu = (struct cu_data *)cl->cl_private; if (cu->cu_closeit) { - (void)_libc_close(cu->cu_sock); + (void)_close(cu->cu_sock); } XDR_DESTROY(&(cu->cu_outxdrs)); mem_free((caddr_t)cu, (sizeof(*cu) + cu->cu_sendsz + cu->cu_recvsz)); diff --git a/lib/libc/rpc/clnt_unix.c b/lib/libc/rpc/clnt_unix.c index 5deb8b0..3b28bf8 100644 --- a/lib/libc/rpc/clnt_unix.c +++ b/lib/libc/rpc/clnt_unix.c @@ -158,7 +158,7 @@ clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz) rpc_createerr.cf_stat = RPC_SYSTEMERROR; rpc_createerr.cf_error.re_errno = errno; if (*sockp != -1) - (void)_libc_close(*sockp); + (void)_close(*sockp); goto fooy; } ct->ct_closeit = TRUE; @@ -191,7 +191,7 @@ clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz) XDR_ENCODE); if (! xdr_callhdr(&(ct->ct_xdrs), &call_msg)) { if (ct->ct_closeit) { - (void)_libc_close(*sockp); + (void)_close(*sockp); } goto fooy; } @@ -465,7 +465,7 @@ clntunix_destroy(h) (struct ct_data *) h->cl_private; if (ct->ct_closeit) { - (void)_libc_close(ct->ct_sock); + (void)_close(ct->ct_sock); } XDR_DESTROY(&(ct->ct_xdrs)); mem_free((caddr_t)ct, sizeof(struct ct_data)); diff --git a/lib/libc/rpc/get_myaddress.c b/lib/libc/rpc/get_myaddress.c index 2c129a4..05fae48 100644 --- a/lib/libc/rpc/get_myaddress.c +++ b/lib/libc/rpc/get_myaddress.c @@ -73,7 +73,7 @@ get_myaddress(addr) ifc.ifc_len = sizeof (buf); ifc.ifc_buf = buf; if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) { - _libc_close(s); + _close(s); return(-1); } again: @@ -83,7 +83,7 @@ again: while (ifr < end) { ifreq = *ifr; if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) { - _libc_close(s); + _close(s); return(-1); } if (((ifreq.ifr_flags & IFF_UP) && @@ -107,6 +107,6 @@ again: loopback = 1; goto again; } - (void)_libc_close(s); + (void)_close(s); return (gotit ? 0 : -1); } diff --git a/lib/libc/rpc/key_call.c b/lib/libc/rpc/key_call.c index bb0d06b..703e038 100644 --- a/lib/libc/rpc/key_call.c +++ b/lib/libc/rpc/key_call.c @@ -369,7 +369,7 @@ int vers; (void) clnt_control(kcp->client, CLSET_RETRY_TIMEOUT, (char *)&wait_time); if (clnt_control(kcp->client, CLGET_FD, (char *)&fd)) - _libc_fcntl(fd, F_SETFD, 1); /* make it "close on exec" */ + _fcntl(fd, F_SETFD, 1); /* make it "close on exec" */ return (kcp->client); } diff --git a/lib/libc/rpc/pmap_clnt.c b/lib/libc/rpc/pmap_clnt.c index f306a78..540187b 100644 --- a/lib/libc/rpc/pmap_clnt.c +++ b/lib/libc/rpc/pmap_clnt.c @@ -102,7 +102,7 @@ pmap_set(program, version, protocol, port) } CLNT_DESTROY(client); if (socket != -1) - (void)_libc_close(socket); + (void)_close(socket); return (rslt); } @@ -144,6 +144,6 @@ pmap_unset(program, version) tottimeout); CLNT_DESTROY(client); if (socket != -1) - (void)_libc_close(socket); + (void)_close(socket); return (rslt); } diff --git a/lib/libc/rpc/pmap_getmaps.c b/lib/libc/rpc/pmap_getmaps.c index 06dabfe..777877b 100644 --- a/lib/libc/rpc/pmap_getmaps.c +++ b/lib/libc/rpc/pmap_getmaps.c @@ -80,7 +80,7 @@ pmap_getmaps(address) CLNT_DESTROY(client); } if (socket != -1) - (void)_libc_close(socket); + (void)_close(socket); address->sin_port = 0; return (head); } diff --git a/lib/libc/rpc/pmap_getport.c b/lib/libc/rpc/pmap_getport.c index 7e4c38b..2d6f5ac 100644 --- a/lib/libc/rpc/pmap_getport.c +++ b/lib/libc/rpc/pmap_getport.c @@ -85,7 +85,7 @@ pmap_getport(address, program, version, protocol) CLNT_DESTROY(client); } if (socket != -1) - (void)_libc_close(socket); + (void)_close(socket); address->sin_port = 0; return (port); } diff --git a/lib/libc/rpc/pmap_rmt.c b/lib/libc/rpc/pmap_rmt.c index da63488..55ddef9 100644 --- a/lib/libc/rpc/pmap_rmt.c +++ b/lib/libc/rpc/pmap_rmt.c @@ -98,7 +98,7 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt stat = RPC_FAILED; } if (socket != -1) - (void)_libc_close(socket); + (void)_close(socket); addr->sin_port = 0; return (stat); } @@ -408,7 +408,7 @@ done_broad: if (fds != &readfds) free(fds); if (sock >= 0) - (void)_libc_close(sock); + (void)_close(sock); AUTH_DESTROY(unix_auth); return (stat); } diff --git a/lib/libc/rpc/rtime.c b/lib/libc/rpc/rtime.c index 25b11ca..0aaf7c0 100644 --- a/lib/libc/rpc/rtime.c +++ b/lib/libc/rpc/rtime.c @@ -129,7 +129,7 @@ rtime(addrp, timep, timeout) do_close(s); return(-1); } - res = _libc_read(s, (char *)&thetime, sizeof(thetime)); + res = _read(s, (char *)&thetime, sizeof(thetime)); do_close(s); if (res < 0) { return(-1); @@ -152,6 +152,6 @@ do_close(s) int save; save = errno; - (void)_libc_close(s); + (void)_close(s); errno = save; } diff --git a/lib/libc/rpc/svc_tcp.c b/lib/libc/rpc/svc_tcp.c index da34518..3e14010 100644 --- a/lib/libc/rpc/svc_tcp.c +++ b/lib/libc/rpc/svc_tcp.c @@ -145,7 +145,7 @@ svctcp_create(sock, sendsize, recvsize) if (ioctl(sock, FIONBIO, &on) < 0) { perror("svc_tcp.c - cannot turn on non-blocking mode"); if (madesock) - (void)_libc_close(sock); + (void)_close(sock); return ((SVCXPRT *)NULL); } memset(&addr, 0, sizeof (addr)); @@ -159,7 +159,7 @@ svctcp_create(sock, sendsize, recvsize) (listen(sock, 2) != 0)) { perror("svctcp_.c - cannot getsockname or listen"); if (madesock) - (void)_libc_close(sock); + (void)_close(sock); return ((SVCXPRT *)NULL); } r = (struct tcp_rendezvous *)mem_alloc(sizeof(*r)); @@ -257,7 +257,7 @@ rendezvous_request(xprt) * Guard against FTP bounce attacks. */ if (addr.sin_port == htons(20)) { - _libc_close(sock); + _close(sock); return (FALSE); } /* @@ -265,7 +265,7 @@ rendezvous_request(xprt) */ off = 0; if (ioctl(sock, FIONBIO, &off) < 0) { - _libc_close(sock); + _close(sock); return (FALSE); } /* @@ -291,7 +291,7 @@ svctcp_destroy(xprt) register struct tcp_conn *cd = (struct tcp_conn *)xprt->xp_p1; xprt_unregister(xprt); - (void)_libc_close(xprt->xp_sock); + (void)_close(xprt->xp_sock); if (xprt->xp_port != 0) { /* a rendezvouser socket */ xprt->xp_port = 0; @@ -376,7 +376,7 @@ readtcp(xprt, buf, len) } } } while (!FD_ISSET(sock, fds)); - if ((len = _libc_read(sock, buf, len)) > 0) { + if ((len = _read(sock, buf, len)) > 0) { if (fds != NULL) free(fds); return (len); @@ -401,7 +401,7 @@ writetcp(xprt, buf, len) register int i, cnt; for (cnt = len; cnt > 0; cnt -= i, buf += i) { - if ((i = _libc_write(xprt->xp_sock, buf, cnt)) < 0) { + if ((i = _write(xprt->xp_sock, buf, cnt)) < 0) { ((struct tcp_conn *)(xprt->xp_p1))->strm_stat = XPRT_DIED; return (-1); diff --git a/lib/libc/rpc/svc_udp.c b/lib/libc/rpc/svc_udp.c index c30d224..9849d53 100644 --- a/lib/libc/rpc/svc_udp.c +++ b/lib/libc/rpc/svc_udp.c @@ -123,7 +123,7 @@ svcudp_bufcreate(sock, sendsz, recvsz) if (getsockname(sock, (struct sockaddr *)&addr, &len) != 0) { perror("svcudp_create - cannot getsockname"); if (madesock) - (void)_libc_close(sock); + (void)_close(sock); return ((SVCXPRT *)NULL); } xprt = (SVCXPRT *)mem_alloc(sizeof(SVCXPRT)); @@ -259,7 +259,7 @@ svcudp_destroy(xprt) register struct svcudp_data *su = su_data(xprt); xprt_unregister(xprt); - (void)_libc_close(xprt->xp_sock); + (void)_close(xprt->xp_sock); XDR_DESTROY(&(su->su_xdrs)); mem_free(rpc_buffer(xprt), su->su_iosz); mem_free((caddr_t)su, sizeof(struct svcudp_data)); diff --git a/lib/libc/rpc/svc_unix.c b/lib/libc/rpc/svc_unix.c index 63a3bad..dc680d0 100644 --- a/lib/libc/rpc/svc_unix.c +++ b/lib/libc/rpc/svc_unix.c @@ -213,7 +213,7 @@ svcunix_create(sock, sendsize, recvsize, path) (listen(sock, 2) != 0)) { perror("svc_unix.c - cannot getsockname or listen"); if (madesock) - (void)_libc_close(sock); + (void)_close(sock); return ((SVCXPRT *)NULL); } r = (struct unix_rendezvous *)mem_alloc(sizeof(*r)); @@ -333,7 +333,7 @@ svcunix_destroy(xprt) register struct unix_conn *cd = (struct unix_conn *)xprt->xp_p1; xprt_unregister(xprt); - (void)_libc_close(xprt->xp_sock); + (void)_close(xprt->xp_sock); if (xprt->xp_port != 0) { /* a rendezvouser socket */ xprt->xp_port = 0; diff --git a/lib/libc/stdio/fdopen.c b/lib/libc/stdio/fdopen.c index 1c56a9d..44341b3 100644 --- a/lib/libc/stdio/fdopen.c +++ b/lib/libc/stdio/fdopen.c @@ -63,7 +63,7 @@ fdopen(fd, mode) return (NULL); /* Make sure the mode the user wants is a subset of the actual mode. */ - if ((fdflags = _libc_fcntl(fd, F_GETFL, 0)) < 0) + if ((fdflags = _fcntl(fd, F_GETFL, 0)) < 0) return (NULL); tmp = fdflags & O_ACCMODE; if (tmp != O_RDWR && (tmp != (oflags & O_ACCMODE))) { diff --git a/lib/libc/stdio/fopen.c b/lib/libc/stdio/fopen.c index d41122c..1ef6bda 100644 --- a/lib/libc/stdio/fopen.c +++ b/lib/libc/stdio/fopen.c @@ -60,7 +60,7 @@ fopen(file, mode) return (NULL); if ((fp = __sfp()) == NULL) return (NULL); - if ((f = _libc_open(file, oflags, DEFFILEMODE)) < 0) { + if ((f = _open(file, oflags, DEFFILEMODE)) < 0) { fp->_flags = 0; /* release */ return (NULL); } diff --git a/lib/libc/stdio/freopen.c b/lib/libc/stdio/freopen.c index 39399f3..f6fa754 100644 --- a/lib/libc/stdio/freopen.c +++ b/lib/libc/stdio/freopen.c @@ -100,13 +100,13 @@ freopen(file, mode, fp) } /* Get a new descriptor to refer to the new file. */ - f = _libc_open(file, oflags, DEFFILEMODE); + f = _open(file, oflags, DEFFILEMODE); if (f < 0 && isopen) { /* If out of fd's close the old one and try again. */ if (errno == ENFILE || errno == EMFILE) { (void) (*fp->_close)(fp->_cookie); isopen = 0; - f = _libc_open(file, oflags, DEFFILEMODE); + f = _open(file, oflags, DEFFILEMODE); } } sverrno = errno; @@ -147,7 +147,7 @@ freopen(file, mode, fp) */ if (wantfd >= 0 && f != wantfd) { if (dup2(f, wantfd) >= 0) { - (void)_libc_close(f); + (void)_close(f); f = wantfd; } } diff --git a/lib/libc/stdio/gets.c b/lib/libc/stdio/gets.c index 42c5da2..1f9be80 100644 --- a/lib/libc/stdio/gets.c +++ b/lib/libc/stdio/gets.c @@ -59,7 +59,7 @@ gets(buf) "warning: this program uses gets(), which is unsafe.\n"; if (!warned) { - (void) _libc_write(STDERR_FILENO, w, sizeof(w) - 1); + (void) _write(STDERR_FILENO, w, sizeof(w) - 1); warned = 1; } for (s = buf; (c = getchar()) != '\n';) diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c index 98f0170..13e15d4 100644 --- a/lib/libc/stdio/mktemp.c +++ b/lib/libc/stdio/mktemp.c @@ -163,7 +163,7 @@ _gettemp(path, doopen, domkdir, slen) for (;;) { if (doopen) { if ((*doopen = - _libc_open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0) + _open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0) return(1); if (errno != EEXIST) return(0); diff --git a/lib/libc/stdio/stdio.c b/lib/libc/stdio/stdio.c index 777f336..b8a3f47 100644 --- a/lib/libc/stdio/stdio.c +++ b/lib/libc/stdio/stdio.c @@ -60,7 +60,7 @@ __sread(cookie, buf, n) register FILE *fp = cookie; register int ret; - ret = _libc_read(fp->_file, buf, (size_t)n); + ret = _read(fp->_file, buf, (size_t)n); /* if the read succeeded, update the current offset */ if (ret >= 0) fp->_offset += ret; @@ -80,7 +80,7 @@ __swrite(cookie, buf, n) if (fp->_flags & __SAPP) (void) lseek(fp->_file, (off_t)0, SEEK_END); fp->_flags &= ~__SOFF; /* in case FAPPEND mode is set */ - return (_libc_write(fp->_file, buf, (size_t)n)); + return (_write(fp->_file, buf, (size_t)n)); } fpos_t @@ -107,5 +107,5 @@ __sclose(cookie) void *cookie; { - return (_libc_close(((FILE *)cookie)->_file)); + return (_close(((FILE *)cookie)->_file)); } diff --git a/lib/libc/stdio/tmpfile.c b/lib/libc/stdio/tmpfile.c index d4beac6..a0162c2 100644 --- a/lib/libc/stdio/tmpfile.c +++ b/lib/libc/stdio/tmpfile.c @@ -74,7 +74,7 @@ tmpfile() if ((fp = fdopen(fd, "w+")) == NULL) { sverrno = errno; - (void)_libc_close(fd); + (void)_close(fd); errno = sverrno; return (NULL); } diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index bf41790..ac0dd48 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -72,7 +72,7 @@ static int fdzero; # define MMAP_FD fdzero # define INIT_MMAP() \ - { if ((fdzero = _libc_open("/dev/zero", O_RDWR, 0000)) == -1) \ + { if ((fdzero = _open("/dev/zero", O_RDWR, 0000)) == -1) \ wrterror("open of /dev/zero"); } # define MADV_FREE MADV_DONTNEED #endif /* __sparc__ */ @@ -275,10 +275,10 @@ static void wrterror(char *p) { char *q = " error: "; - _libc_write(STDERR_FILENO, __progname, strlen(__progname)); - _libc_write(STDERR_FILENO, malloc_func, strlen(malloc_func)); - _libc_write(STDERR_FILENO, q, strlen(q)); - _libc_write(STDERR_FILENO, p, strlen(p)); + _write(STDERR_FILENO, __progname, strlen(__progname)); + _write(STDERR_FILENO, malloc_func, strlen(malloc_func)); + _write(STDERR_FILENO, q, strlen(q)); + _write(STDERR_FILENO, p, strlen(p)); suicide = 1; abort(); } @@ -289,10 +289,10 @@ wrtwarning(char *p) char *q = " warning: "; if (malloc_abort) wrterror(p); - _libc_write(STDERR_FILENO, __progname, strlen(__progname)); - _libc_write(STDERR_FILENO, malloc_func, strlen(malloc_func)); - _libc_write(STDERR_FILENO, q, strlen(q)); - _libc_write(STDERR_FILENO, p, strlen(p)); + _write(STDERR_FILENO, __progname, strlen(__progname)); + _write(STDERR_FILENO, malloc_func, strlen(malloc_func)); + _write(STDERR_FILENO, q, strlen(q)); + _write(STDERR_FILENO, p, strlen(p)); } /* diff --git a/lib/libc/stdlib/random.c b/lib/libc/stdlib/random.c index 1729589..e8e8254 100644 --- a/lib/libc/stdlib/random.c +++ b/lib/libc/stdlib/random.c @@ -298,11 +298,11 @@ srandomdev() len = rand_deg * sizeof state[0]; done = 0; - fd = _libc_open("/dev/urandom", O_RDONLY, 0); + fd = _open("/dev/urandom", O_RDONLY, 0); if (fd >= 0) { - if (_libc_read(fd, (void *) state, len) == (ssize_t) len) + if (_read(fd, (void *) state, len) == (ssize_t) len) done = 1; - _libc_close(fd); + _close(fd); } if (!done) { diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c index b956513..0217dde 100644 --- a/lib/libc/stdlib/realpath.c +++ b/lib/libc/stdlib/realpath.c @@ -67,7 +67,7 @@ realpath(path, resolved) int symlinks = 0; /* Save the starting point. */ - if ((fd = _libc_open(".", O_RDONLY)) < 0) { + if ((fd = _open(".", O_RDONLY)) < 0) { (void)strcpy(resolved, "."); return (NULL); } @@ -154,12 +154,12 @@ loop: } /* It's okay if the close fails, what's an fd more or less? */ - (void)_libc_close(fd); + (void)_close(fd); return (resolved); err1: serrno = errno; (void)fchdir(fd); -err2: (void)_libc_close(fd); +err2: (void)_close(fd); errno = serrno; return (NULL); } diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c index 0039c078..236a8b0 100644 --- a/lib/libc/stdlib/system.c +++ b/lib/libc/stdlib/system.c @@ -84,7 +84,7 @@ __system(command) _exit(127); default: /* parent */ do { - pid = _libc_waitpid(pid, &pstat, 0); + pid = _wait4(pid, &pstat, 0, (struct rusage *)0); } while (pid == -1 && errno == EINTR); break; } @@ -94,5 +94,4 @@ __system(command) return(pid == -1 ? -1 : pstat); } -__weak_reference(__system, _libc_system); -__weak_reference(_libc_system, system); +__weak_reference(__system, system); diff --git a/lib/libc/stdtime/localtime.c b/lib/libc/stdtime/localtime.c index 34c978b..4fa411f 100644 --- a/lib/libc/stdtime/localtime.c +++ b/lib/libc/stdtime/localtime.c @@ -314,7 +314,7 @@ register struct state * const sp; } if (doaccess && access(name, R_OK) != 0) return -1; - if ((fid = _libc_open(name, OPEN_MODE)) == -1) + if ((fid = _open(name, OPEN_MODE)) == -1) return -1; if ((fstat(fid, &stab) < 0) || !S_ISREG(stab.st_mode)) return -1; @@ -325,8 +325,8 @@ register struct state * const sp; int ttisstdcnt; int ttisgmtcnt; - i = _libc_read(fid, buf, sizeof buf); - if (_libc_close(fid) != 0) + i = _read(fid, buf, sizeof buf); + if (_close(fid) != 0) return -1; p = buf; p += (sizeof tzhp->tzh_magic) + (sizeof tzhp->tzh_reserved); diff --git a/lib/libc/stdtime/timelocal.c b/lib/libc/stdtime/timelocal.c index f95dda0..c765cf4 100644 --- a/lib/libc/stdtime/timelocal.c +++ b/lib/libc/stdtime/timelocal.c @@ -157,7 +157,7 @@ __time_load_locale(const char *name) strcat(filename, "/"); strcat(filename, name); strcat(filename, "/LC_TIME"); - fd = _libc_open(filename, O_RDONLY); + fd = _open(filename, O_RDONLY); if (fd < 0) goto no_locale; if (fstat(fd, &st) != 0) @@ -173,9 +173,9 @@ __time_load_locale(const char *name) (void) strcpy(lbuf, name); p = lbuf + namesize; plim = p + st.st_size; - if (_libc_read(fd, p, (size_t) st.st_size) != st.st_size) + if (_read(fd, p, (size_t) st.st_size) != st.st_size) goto bad_lbuf; - if (_libc_close(fd) != 0) + if (_close(fd) != 0) goto bad_lbuf; /* ** Parse the locale file into localebuf. @@ -211,7 +211,7 @@ reset_locale: bad_lbuf: free(lbuf); bad_locale: - (void)_libc_close(fd); + (void)_close(fd); no_locale: _time_using_locale = save_using_locale; return -1; diff --git a/lib/libc/yp/yplib.c b/lib/libc/yp/yplib.c index 8fc1d56..5c72573 100644 --- a/lib/libc/yp/yplib.c +++ b/lib/libc/yp/yplib.c @@ -350,7 +350,7 @@ _yp_dobind(dom, ypdb) ysd->dom_vers = 0; ysd->dom_client = NULL; sock = dup2(save, sock); - _libc_close(save); + _close(save); } } @@ -373,10 +373,10 @@ again: ysd->dom_socket = -1; } snprintf(path, sizeof(path), "%s/%s.%d", BINDINGDIR, dom, 2); - if((fd = _libc_open(path, O_RDONLY)) == -1) { + if((fd = _open(path, O_RDONLY)) == -1) { /* no binding file, YP is dead. */ /* Try to bring it back to life. */ - _libc_close(fd); + _close(fd); goto skipit; } if( flock(fd, LOCK_EX|LOCK_NB) == -1 && errno==EWOULDBLOCK) { @@ -391,7 +391,7 @@ again: r = readv(fd, iov, 2); if(r != iov[0].iov_len + iov[1].iov_len) { - _libc_close(fd); + _close(fd); ysd->dom_vers = -1; goto again; } @@ -405,12 +405,12 @@ again: *(u_short *)&ybr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port; ysd->dom_server_port = ysd->dom_server_addr.sin_port; - _libc_close(fd); + _close(fd); goto gotit; } else { /* no lock on binding file, YP is dead. */ /* Try to bring it back to life. */ - _libc_close(fd); + _close(fd); goto skipit; } } @@ -478,9 +478,15 @@ skipit: goto again; } else { if (ypbr.ypbind_status != YPBIND_SUCC_VAL) { + struct timespec time_to_sleep, time_remaining; + clnt_destroy(client); ysd->dom_vers = -1; - _libc_sleep(_yplib_timeout/2); + + time_to_sleep.tv_sec = _yplib_timeout/2; + time_to_sleep.tv_nsec = 0; + _nanosleep(&time_to_sleep, + &time_remaining); goto again; } } @@ -518,7 +524,7 @@ gotit: ysd->dom_vers = -1; goto again; } - if(_libc_fcntl(ysd->dom_socket, F_SETFD, 1) == -1) + if(_fcntl(ysd->dom_socket, F_SETFD, 1) == -1) perror("fcntl: F_SETFD"); /* * We want a port number associated with this socket @@ -567,7 +573,7 @@ _yp_unbind(ypb) save = dup(ypb->dom_socket); clnt_destroy(ypb->dom_client); sock = dup2(save, sock); - _libc_close(save); + _close(save); } else clnt_destroy(ypb->dom_client); } diff --git a/lib/libc_r/Makefile b/lib/libc_r/Makefile index e79d5c5..1b0afbb 100644 --- a/lib/libc_r/Makefile +++ b/lib/libc_r/Makefile @@ -26,7 +26,7 @@ PRECIOUSLIB= yes # This is a list of syscalls that are renamed as _thread_sys_{syscall} # so that libc_r can provide replacement functions. # -HIDDEN_SYSCALLS= accept.o bind.o close.o connect.o dup.o dup2.o \ +HIDDEN_SYSCALLS= aio_suspend.o accept.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 \ getlogin.o getpeername.o getsockname.o getsockopt.o ioctl.o listen.o \ diff --git a/lib/libc_r/uthread/Makefile.inc b/lib/libc_r/uthread/Makefile.inc index 2a13365..a88f955 100644 --- a/lib/libc_r/uthread/Makefile.inc +++ b/lib/libc_r/uthread/Makefile.inc @@ -5,6 +5,7 @@ SRCS+= \ uthread_accept.c \ + uthread_aio_suspend.c \ uthread_attr_destroy.c \ uthread_attr_init.c \ uthread_attr_getdetachstate.c \ @@ -31,6 +32,7 @@ SRCS+= \ uthread_condattr_destroy.c \ uthread_condattr_init.c \ uthread_connect.c \ + uthread_creat.c \ uthread_create.c \ uthread_detach.c \ uthread_dup.c \ @@ -76,6 +78,7 @@ SRCS+= \ uthread_nanosleep.c \ uthread_once.c \ uthread_open.c \ + uthread_pause.c \ uthread_pipe.c \ uthread_poll.c \ uthread_priority_queue.c \ @@ -106,14 +109,19 @@ SRCS+= \ uthread_sigsuspend.c \ uthread_sigwait.c \ uthread_single_np.c \ + uthread_sleep.c \ uthread_socket.c \ uthread_socketpair.c \ uthread_spec.c \ uthread_spinlock.c \ uthread_suspend_np.c \ uthread_switch_np.c \ + uthread_system.c \ + uthread_tcdrain.c \ uthread_vfork.c \ + uthread_wait.c \ uthread_wait4.c \ + uthread_waitpid.c \ uthread_write.c \ uthread_writev.c \ uthread_yield.c diff --git a/lib/libc_r/uthread/uthread_accept.c b/lib/libc_r/uthread/uthread_accept.c index 9d1bcd8..3fc481c 100644 --- a/lib/libc_r/uthread/uthread_accept.c +++ b/lib/libc_r/uthread/uthread_accept.c @@ -41,7 +41,7 @@ #include "pthread_private.h" int -_libc_accept(int fd, struct sockaddr * name, socklen_t *namelen) +_accept(int fd, struct sockaddr * name, socklen_t *namelen) { int ret; @@ -107,5 +107,5 @@ _libc_accept(int fd, struct sockaddr * name, socklen_t *namelen) return (ret); } -__weak_reference(_libc_accept, accept); +__weak_reference(_accept, accept); #endif diff --git a/lib/libc_r/uthread/uthread_aio_suspend.c b/lib/libc_r/uthread/uthread_aio_suspend.c new file mode 100644 index 0000000..3bc373a --- /dev/null +++ b/lib/libc_r/uthread/uthread_aio_suspend.c @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +int +_aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct + timespec *timeout) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = _aio_suspend(iocbs, niocb, timeout); + _thread_leave_cancellation_point(); + + return ret; +} + +__weak_reference(_aio_suspend, aio_suspend); +#endif diff --git a/lib/libc_r/uthread/uthread_bind.c b/lib/libc_r/uthread/uthread_bind.c index 7cb3028..cf9b074 100644 --- a/lib/libc_r/uthread/uthread_bind.c +++ b/lib/libc_r/uthread/uthread_bind.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_bind(int fd, const struct sockaddr * name, socklen_t namelen) +_bind(int fd, const struct sockaddr * name, socklen_t namelen) { int ret; @@ -49,5 +49,5 @@ _libc_bind(int fd, const struct sockaddr * name, socklen_t namelen) return (ret); } -__weak_reference(_libc_bind, bind); +__weak_reference(_bind, bind); #endif diff --git a/lib/libc_r/uthread/uthread_close.c b/lib/libc_r/uthread/uthread_close.c index fe2d9e2..9dee2bc 100644 --- a/lib/libc_r/uthread/uthread_close.c +++ b/lib/libc_r/uthread/uthread_close.c @@ -41,15 +41,13 @@ #include "pthread_private.h" int -_libc_close(int fd) +_close(int fd) { int flags; int ret; struct stat sb; struct fd_table_entry *entry; - _thread_enter_cancellation_point(); - if ((fd == _thread_kern_pipe[0]) || (fd == _thread_kern_pipe[1])) { /* * Don't allow silly programs to close the kernel pipe. @@ -99,9 +97,18 @@ _libc_close(int fd) /* Close the file descriptor: */ ret = _thread_sys_close(fd); } - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_close, close); +int +close(int fd) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = _close(fd); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libc_r/uthread/uthread_cond.c b/lib/libc_r/uthread/uthread_cond.c index ced48e3..d236607 100644 --- a/lib/libc_r/uthread/uthread_cond.c +++ b/lib/libc_r/uthread/uthread_cond.c @@ -160,6 +160,8 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex) int rval = 0; int interrupted = 0; + _thread_enter_cancellation_point(); + if (cond == NULL) rval = EINVAL; @@ -286,6 +288,8 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex) _thread_leave_cancellation_point(); } + _thread_leave_cancellation_point(); + /* Return the completion status: */ return (rval); } @@ -297,12 +301,15 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, int rval = 0; int interrupted = 0; + _thread_enter_cancellation_point(); + if (cond == NULL || abstime == NULL) rval = EINVAL; if (abstime->tv_sec < 0 || abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) { errno = EINVAL; + _thread_leave_cancellation_point(); return (-1); } @@ -448,6 +455,8 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, _thread_leave_cancellation_point(); } + _thread_leave_cancellation_point(); + /* Return the completion status: */ return (rval); } diff --git a/lib/libc_r/uthread/uthread_connect.c b/lib/libc_r/uthread/uthread_connect.c index 03fea27..4e3ed5c 100644 --- a/lib/libc_r/uthread/uthread_connect.c +++ b/lib/libc_r/uthread/uthread_connect.c @@ -40,7 +40,7 @@ #include "pthread_private.h" int -_libc_connect(int fd, const struct sockaddr * name, socklen_t namelen) +_connect(int fd, const struct sockaddr * name, socklen_t namelen) { struct sockaddr tmpname; int errnolen, ret, tmpnamelen; @@ -76,5 +76,5 @@ _libc_connect(int fd, const struct sockaddr * name, socklen_t namelen) return (ret); } -__weak_reference(_libc_connect, connect); +__weak_reference(_connect, connect); #endif diff --git a/lib/libc_r/uthread/uthread_creat.c b/lib/libc_r/uthread/uthread_creat.c new file mode 100644 index 0000000..bb8e7c2 --- /dev/null +++ b/lib/libc_r/uthread/uthread_creat.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +int +creat(const char *path, mode_t mode) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = __creat(path, mode); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libc_r/uthread/uthread_dup.c b/lib/libc_r/uthread/uthread_dup.c index 63bd9bf..15d8c19 100644 --- a/lib/libc_r/uthread/uthread_dup.c +++ b/lib/libc_r/uthread/uthread_dup.c @@ -37,7 +37,7 @@ #include "pthread_private.h" int -_libc_dup(int fd) +_dup(int fd) { int ret; @@ -68,5 +68,5 @@ _libc_dup(int fd) return (ret); } -__weak_reference(_libc_dup, dup); +__weak_reference(_dup, dup); #endif diff --git a/lib/libc_r/uthread/uthread_dup2.c b/lib/libc_r/uthread/uthread_dup2.c index b8b8a73..ccf0e55 100644 --- a/lib/libc_r/uthread/uthread_dup2.c +++ b/lib/libc_r/uthread/uthread_dup2.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_dup2(int fd, int newfd) +_dup2(int fd, int newfd) { int ret; int newfd_opened; @@ -84,5 +84,5 @@ _libc_dup2(int fd, int newfd) return (ret); } -__weak_reference(_libc_dup2, dup2); +__weak_reference(_dup2, dup2); #endif diff --git a/lib/libc_r/uthread/uthread_execve.c b/lib/libc_r/uthread/uthread_execve.c index af42e39..8aeb24c 100644 --- a/lib/libc_r/uthread/uthread_execve.c +++ b/lib/libc_r/uthread/uthread_execve.c @@ -39,7 +39,7 @@ #include "pthread_private.h" int -_libc_execve(const char *name, char *const * argv, char *const * envp) +_execve(const char *name, char *const * argv, char *const * envp) { int flags; int i; @@ -111,5 +111,5 @@ _libc_execve(const char *name, char *const * argv, char *const * envp) return (ret); } -__weak_reference(_libc_execve, execve); +__weak_reference(_execve, execve); #endif diff --git a/lib/libc_r/uthread/uthread_exit.c b/lib/libc_r/uthread/uthread_exit.c index 57ac114..22e2ce8 100644 --- a/lib/libc_r/uthread/uthread_exit.c +++ b/lib/libc_r/uthread/uthread_exit.c @@ -41,7 +41,7 @@ #include #include "pthread_private.h" -void _libc__exit(int status) +void __exit(int status) { int flags; int i; @@ -77,7 +77,7 @@ void _libc__exit(int status) _thread_sys__exit(status); } -__weak_reference(_libc__exit, _exit); +__weak_reference(__exit, _exit); void _thread_exit(char *fname, int lineno, char *string) diff --git a/lib/libc_r/uthread/uthread_fchflags.c b/lib/libc_r/uthread/uthread_fchflags.c index 3334b56..ef33d86 100644 --- a/lib/libc_r/uthread/uthread_fchflags.c +++ b/lib/libc_r/uthread/uthread_fchflags.c @@ -12,7 +12,7 @@ #include "pthread_private.h" int -_libc_fchflags(int fd, u_long flags) +_fchflags(int fd, u_long flags) { int ret; @@ -23,5 +23,5 @@ _libc_fchflags(int fd, u_long flags) return (ret); } -__weak_reference(_libc_fchflags, fchflags); +__weak_reference(_fchflags, fchflags); #endif diff --git a/lib/libc_r/uthread/uthread_fchmod.c b/lib/libc_r/uthread/uthread_fchmod.c index 1f87637..f57a9ea 100644 --- a/lib/libc_r/uthread/uthread_fchmod.c +++ b/lib/libc_r/uthread/uthread_fchmod.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_fchmod(int fd, mode_t mode) +_fchmod(int fd, mode_t mode) { int ret; @@ -49,5 +49,5 @@ _libc_fchmod(int fd, mode_t mode) return (ret); } -__weak_reference(_libc_fchmod, fchmod); +__weak_reference(_fchmod, fchmod); #endif diff --git a/lib/libc_r/uthread/uthread_fchown.c b/lib/libc_r/uthread/uthread_fchown.c index d49d7d1..98fae73 100644 --- a/lib/libc_r/uthread/uthread_fchown.c +++ b/lib/libc_r/uthread/uthread_fchown.c @@ -39,7 +39,7 @@ #include "pthread_private.h" int -_libc_fchown(int fd, uid_t owner, gid_t group) +_fchown(int fd, uid_t owner, gid_t group) { int ret; @@ -50,5 +50,5 @@ _libc_fchown(int fd, uid_t owner, gid_t group) return (ret); } -__weak_reference(_libc_fchown, fchown); +__weak_reference(_fchown, fchown); #endif diff --git a/lib/libc_r/uthread/uthread_fcntl.c b/lib/libc_r/uthread/uthread_fcntl.c index 6cd2b12..06e2e3b 100644 --- a/lib/libc_r/uthread/uthread_fcntl.c +++ b/lib/libc_r/uthread/uthread_fcntl.c @@ -39,7 +39,7 @@ #include "pthread_private.h" int -_libc_fcntl(int fd, int cmd,...) +_fcntl(int fd, int cmd,...) { int flags = 0; int nonblock; @@ -47,8 +47,6 @@ _libc_fcntl(int fd, int cmd,...) int ret; va_list ap; - _thread_enter_cancellation_point(); - /* Lock the file descriptor: */ if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { /* Initialise the variable argument list: */ @@ -137,11 +135,36 @@ _libc_fcntl(int fd, int cmd,...) /* Unlock the file descriptor: */ _FD_UNLOCK(fd, FD_RDWR); } - _thread_leave_cancellation_point(); - /* Return the completion status: */ return (ret); } -__weak_reference(_libc_fcntl, fcntl); +int +fcntl(int fd, int cmd,...) +{ + int ret; + va_list ap; + + _thread_enter_cancellation_point(); + + va_start(ap, cmd); + switch (cmd) { + case F_DUPFD: + case F_SETFD: + case F_SETFL: + ret = fcntl(fd, cmd, va_arg(ap, int)); + break; + case F_GETFD: + case F_GETFL: + ret = fcntl(fd, cmd); + break; + default: + ret = fcntl(fd, cmd, va_arg(ap, void *)); + } + va_end(ap); + + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libc_r/uthread/uthread_flock.c b/lib/libc_r/uthread/uthread_flock.c index 20de6dc..56d6fbc 100644 --- a/lib/libc_r/uthread/uthread_flock.c +++ b/lib/libc_r/uthread/uthread_flock.c @@ -37,7 +37,7 @@ #include "pthread_private.h" int -_libc_flock(int fd, int operation) +_flock(int fd, int operation) { int ret; @@ -48,5 +48,5 @@ _libc_flock(int fd, int operation) return (ret); } -__weak_reference(_libc_flock, flock); +__weak_reference(_flock, flock); #endif diff --git a/lib/libc_r/uthread/uthread_fork.c b/lib/libc_r/uthread/uthread_fork.c index 8c112e8..88f1c43 100644 --- a/lib/libc_r/uthread/uthread_fork.c +++ b/lib/libc_r/uthread/uthread_fork.c @@ -41,7 +41,7 @@ #include "pthread_private.h" pid_t -_libc_fork(void) +_fork(void) { int i, flags; pid_t ret; @@ -221,5 +221,5 @@ _libc_fork(void) return (ret); } -__weak_reference(_libc_fork, fork); +__weak_reference(_fork, fork); #endif diff --git a/lib/libc_r/uthread/uthread_fstat.c b/lib/libc_r/uthread/uthread_fstat.c index 3f182c3..8df1f1a 100644 --- a/lib/libc_r/uthread/uthread_fstat.c +++ b/lib/libc_r/uthread/uthread_fstat.c @@ -42,7 +42,7 @@ #include "pthread_private.h" int -_libc_fstat(int fd, struct stat * buf) +_fstat(int fd, struct stat * buf) { int ret; @@ -56,5 +56,5 @@ _libc_fstat(int fd, struct stat * buf) return (ret); } -__weak_reference(_libc_fstat, fstat); +__weak_reference(_fstat, fstat); #endif diff --git a/lib/libc_r/uthread/uthread_fstatfs.c b/lib/libc_r/uthread/uthread_fstatfs.c index 84ef0bd..0962cbd 100644 --- a/lib/libc_r/uthread/uthread_fstatfs.c +++ b/lib/libc_r/uthread/uthread_fstatfs.c @@ -42,7 +42,7 @@ #include "pthread_private.h" int -_libc_fstatfs(int fd, struct statfs * buf) +_fstatfs(int fd, struct statfs * buf) { int ret; @@ -56,5 +56,5 @@ _libc_fstatfs(int fd, struct statfs * buf) return (ret); } -__weak_reference(_libc_fstatfs, fstatfs); +__weak_reference(_fstatfs, fstatfs); #endif diff --git a/lib/libc_r/uthread/uthread_fsync.c b/lib/libc_r/uthread/uthread_fsync.c index 048e60b..0d88320 100644 --- a/lib/libc_r/uthread/uthread_fsync.c +++ b/lib/libc_r/uthread/uthread_fsync.c @@ -37,18 +37,26 @@ #include "pthread_private.h" int -_libc_fsync(int fd) +_fsync(int fd) { - int ret; + int ret; - _thread_enter_cancellation_point(); if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { ret = _thread_sys_fsync(fd); _FD_UNLOCK(fd, FD_RDWR); } - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_fsync, fsync); +int +fsync(int fd) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = _fsync(fd); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libc_r/uthread/uthread_getdirentries.c b/lib/libc_r/uthread/uthread_getdirentries.c index 0bd4c85..c1a2edc 100644 --- a/lib/libc_r/uthread/uthread_getdirentries.c +++ b/lib/libc_r/uthread/uthread_getdirentries.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_getdirentries(int fd, char *buf, int nbytes, long *basep) +_getdirentries(int fd, char *buf, int nbytes, long *basep) { int ret; @@ -49,5 +49,5 @@ _libc_getdirentries(int fd, char *buf, int nbytes, long *basep) return (ret); } -__weak_reference(_libc_getdirentries, getdirentries); +__weak_reference(_getdirentries, getdirentries); #endif diff --git a/lib/libc_r/uthread/uthread_getpeername.c b/lib/libc_r/uthread/uthread_getpeername.c index 94c87d6..afc2f3c 100644 --- a/lib/libc_r/uthread/uthread_getpeername.c +++ b/lib/libc_r/uthread/uthread_getpeername.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_getpeername(int fd, struct sockaddr * peer, socklen_t *paddrlen) +_getpeername(int fd, struct sockaddr * peer, socklen_t *paddrlen) { int ret; @@ -49,5 +49,5 @@ _libc_getpeername(int fd, struct sockaddr * peer, socklen_t *paddrlen) return ret; } -__weak_reference(_libc_getpeername, getpeername); +__weak_reference(_getpeername, getpeername); #endif diff --git a/lib/libc_r/uthread/uthread_getsockname.c b/lib/libc_r/uthread/uthread_getsockname.c index 91d11fe..e8816c7 100644 --- a/lib/libc_r/uthread/uthread_getsockname.c +++ b/lib/libc_r/uthread/uthread_getsockname.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_getsockname(int s, struct sockaddr * name, socklen_t *namelen) +_getsockname(int s, struct sockaddr * name, socklen_t *namelen) { int ret; @@ -49,5 +49,5 @@ _libc_getsockname(int s, struct sockaddr * name, socklen_t *namelen) return ret; } -__weak_reference(_libc_getsockname, getsockname); +__weak_reference(_getsockname, getsockname); #endif diff --git a/lib/libc_r/uthread/uthread_getsockopt.c b/lib/libc_r/uthread/uthread_getsockopt.c index a698c2b..45a0834 100644 --- a/lib/libc_r/uthread/uthread_getsockopt.c +++ b/lib/libc_r/uthread/uthread_getsockopt.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_getsockopt(int fd, int level, int optname, void *optval, socklen_t +_getsockopt(int fd, int level, int optname, void *optval, socklen_t *optlen) { int ret; @@ -50,5 +50,5 @@ _libc_getsockopt(int fd, int level, int optname, void *optval, socklen_t return ret; } -__weak_reference(_libc_getsockopt, getsockopt); +__weak_reference(_getsockopt, getsockopt); #endif diff --git a/lib/libc_r/uthread/uthread_ioctl.c b/lib/libc_r/uthread/uthread_ioctl.c index 1857643..0a3d14e 100644 --- a/lib/libc_r/uthread/uthread_ioctl.c +++ b/lib/libc_r/uthread/uthread_ioctl.c @@ -39,7 +39,7 @@ #include "pthread_private.h" int -_libc_ioctl(int fd, unsigned long request,...) +_ioctl(int fd, unsigned long request,...) { int ret; int *op; @@ -77,5 +77,5 @@ _libc_ioctl(int fd, unsigned long request,...) return (ret); } -__weak_reference(_libc_ioctl, ioctl); +__weak_reference(_ioctl, ioctl); #endif diff --git a/lib/libc_r/uthread/uthread_listen.c b/lib/libc_r/uthread/uthread_listen.c index 00ffe5b..1632b60 100644 --- a/lib/libc_r/uthread/uthread_listen.c +++ b/lib/libc_r/uthread/uthread_listen.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_listen(int fd, int backlog) +_listen(int fd, int backlog) { int ret; @@ -49,5 +49,5 @@ _libc_listen(int fd, int backlog) return (ret); } -__weak_reference(_libc_listen, listen); +__weak_reference(_listen, listen); #endif diff --git a/lib/libc_r/uthread/uthread_msync.c b/lib/libc_r/uthread/uthread_msync.c index 9559ec4..2ae6ac7 100644 --- a/lib/libc_r/uthread/uthread_msync.c +++ b/lib/libc_r/uthread/uthread_msync.c @@ -13,30 +13,30 @@ #include "pthread_private.h" int -_libc_msync(addr, len, flags) - void *addr; - size_t len; - int flags; +_msync(void *addr, size_t len, int flags) { int ret; + ret = _thread_sys_msync(addr, len, flags); + + return (ret); +} + +int +msync(void *addr, size_t len, int flags) +{ + int ret; + /* * XXX This is quite pointless unless we know how to get the * file descriptor associated with the memory, and lock it for * write. The only real use of this wrapper is to guarantee * a cancellation point, as per the standard. sigh. */ - - /* This is a cancellation point: */ _thread_enter_cancellation_point(); - - ret = _thread_sys_msync(addr, len, flags); - - /* No longer in a cancellation point: */ + ret = _msync(addr, len, flags); _thread_leave_cancellation_point(); - return (ret); + return ret; } - -__weak_reference(_libc_msync, msync); #endif diff --git a/lib/libc_r/uthread/uthread_nanosleep.c b/lib/libc_r/uthread/uthread_nanosleep.c index e9052f9..3bbc9a6 100644 --- a/lib/libc_r/uthread/uthread_nanosleep.c +++ b/lib/libc_r/uthread/uthread_nanosleep.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_nanosleep(const struct timespec * time_to_sleep, +_nanosleep(const struct timespec * time_to_sleep, struct timespec * time_remaining) { int ret = 0; @@ -47,7 +47,6 @@ _libc_nanosleep(const struct timespec * time_to_sleep, struct timespec remaining_time; struct timeval tv; - _thread_enter_cancellation_point(); /* Check if the time to sleep is legal: */ if (time_to_sleep == NULL || time_to_sleep->tv_sec < 0 || time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec >= 1000000000) { @@ -117,9 +116,19 @@ _libc_nanosleep(const struct timespec * time_to_sleep, ret = -1; } } - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_nanosleep, nanosleep); +int +nanosleep(const struct timespec * time_to_sleep, struct timespec * + time_remaining) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = _nanosleep(time_to_sleep, time_remaining); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libc_r/uthread/uthread_open.c b/lib/libc_r/uthread/uthread_open.c index 4bc2f1a..e7fef91 100644 --- a/lib/libc_r/uthread/uthread_open.c +++ b/lib/libc_r/uthread/uthread_open.c @@ -42,14 +42,12 @@ #include "pthread_private.h" int -_libc_open(const char *path, int flags,...) +_open(const char *path, int flags,...) { int fd; int mode = 0; va_list ap; - _thread_enter_cancellation_point(); - /* Check if the file is being created: */ if (flags & O_CREAT) { /* Get the creation mode: */ @@ -69,11 +67,30 @@ _libc_open(const char *path, int flags,...) fd = -1; } - _thread_leave_cancellation_point(); - /* Return the file descriptor or -1 on error: */ return (fd); } -__weak_reference(_libc_open, open); +int +open(const char *path, int flags,...) +{ + int ret; + int mode = 0; + va_list ap; + + _thread_enter_cancellation_point(); + + /* Check if the file is being created: */ + if (flags & O_CREAT) { + /* Get the creation mode: */ + va_start(ap, flags); + mode = va_arg(ap, int); + va_end(ap); + } + + ret = _open(path, flags, mode); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libc_r/uthread/uthread_pause.c b/lib/libc_r/uthread/uthread_pause.c new file mode 100644 index 0000000..a841556 --- /dev/null +++ b/lib/libc_r/uthread/uthread_pause.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +int +pause(void) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = __pause(); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libc_r/uthread/uthread_pipe.c b/lib/libc_r/uthread/uthread_pipe.c index b815e1a..770384c 100644 --- a/lib/libc_r/uthread/uthread_pipe.c +++ b/lib/libc_r/uthread/uthread_pipe.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_pipe(int fds[2]) +_pipe(int fds[2]) { int ret; if ((ret = _thread_sys_pipe(fds)) >= 0) { @@ -52,5 +52,5 @@ _libc_pipe(int fds[2]) return (ret); } -__weak_reference(_libc_pipe, pipe); +__weak_reference(_pipe, pipe); #endif diff --git a/lib/libc_r/uthread/uthread_poll.c b/lib/libc_r/uthread/uthread_poll.c index fb6a266..d395250 100644 --- a/lib/libc_r/uthread/uthread_poll.c +++ b/lib/libc_r/uthread/uthread_poll.c @@ -44,7 +44,7 @@ int -_libc_poll(struct pollfd *fds, unsigned int nfds, int timeout) +_poll(struct pollfd *fds, unsigned int nfds, int timeout) { struct timespec ts; int numfds = nfds; @@ -97,5 +97,5 @@ _libc_poll(struct pollfd *fds, unsigned int nfds, int timeout) return (ret); } -__weak_reference(_libc_poll, poll); +__weak_reference(_poll, poll); #endif diff --git a/lib/libc_r/uthread/uthread_read.c b/lib/libc_r/uthread/uthread_read.c index ad66df3..b4d9694 100644 --- a/lib/libc_r/uthread/uthread_read.c +++ b/lib/libc_r/uthread/uthread_read.c @@ -42,16 +42,13 @@ #include "pthread_private.h" ssize_t -_libc_read(int fd, void *buf, size_t nbytes) +_read(int fd, void *buf, size_t nbytes) { int ret; int type; - _thread_enter_cancellation_point(); - /* POSIX says to do just this: */ if (nbytes == 0) { - _thread_leave_cancellation_point(); return (0); } @@ -65,7 +62,6 @@ _libc_read(int fd, void *buf, size_t nbytes) /* File is not open for read: */ errno = EBADF; _FD_UNLOCK(fd, FD_READ); - _thread_leave_cancellation_point(); return (-1); } @@ -97,9 +93,18 @@ _libc_read(int fd, void *buf, size_t nbytes) } _FD_UNLOCK(fd, FD_READ); } - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_read, read); +ssize_t +read(int fd, void *buf, size_t nbytes) +{ + ssize_t ret; + + _thread_enter_cancellation_point(); + ret = _read(fd, buf, nbytes); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libc_r/uthread/uthread_readv.c b/lib/libc_r/uthread/uthread_readv.c index c1965d8..2c66a98 100644 --- a/lib/libc_r/uthread/uthread_readv.c +++ b/lib/libc_r/uthread/uthread_readv.c @@ -42,7 +42,7 @@ #include "pthread_private.h" ssize_t -_libc_readv(int fd, const struct iovec * iov, int iovcnt) +_readv(int fd, const struct iovec * iov, int iovcnt) { int ret; int type; @@ -91,5 +91,5 @@ _libc_readv(int fd, const struct iovec * iov, int iovcnt) return (ret); } -__weak_reference(_libc_readv, readv); +__weak_reference(_readv, readv); #endif diff --git a/lib/libc_r/uthread/uthread_recvfrom.c b/lib/libc_r/uthread/uthread_recvfrom.c index 897e218..ed761ca 100644 --- a/lib/libc_r/uthread/uthread_recvfrom.c +++ b/lib/libc_r/uthread/uthread_recvfrom.c @@ -40,7 +40,7 @@ #include "pthread_private.h" ssize_t -_libc_recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr * from, +_recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr * from, socklen_t *from_len) { int ret; @@ -72,5 +72,5 @@ _libc_recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr * from, return (ret); } -__weak_reference(_libc_recvfrom, recvfrom); +__weak_reference(_recvfrom, recvfrom); #endif diff --git a/lib/libc_r/uthread/uthread_recvmsg.c b/lib/libc_r/uthread/uthread_recvmsg.c index d89c963..cbad5f5 100644 --- a/lib/libc_r/uthread/uthread_recvmsg.c +++ b/lib/libc_r/uthread/uthread_recvmsg.c @@ -40,7 +40,7 @@ #include "pthread_private.h" ssize_t -_libc_recvmsg(int fd, struct msghdr *msg, int flags) +_recvmsg(int fd, struct msghdr *msg, int flags) { int ret; @@ -71,5 +71,5 @@ _libc_recvmsg(int fd, struct msghdr *msg, int flags) return (ret); } -__weak_reference(_libc_recvmsg, recvmsg); +__weak_reference(_recvmsg, recvmsg); #endif diff --git a/lib/libc_r/uthread/uthread_select.c b/lib/libc_r/uthread/uthread_select.c index a7ceecc..d0e61e2 100644 --- a/lib/libc_r/uthread/uthread_select.c +++ b/lib/libc_r/uthread/uthread_select.c @@ -45,8 +45,8 @@ #include "pthread_private.h" int -_libc_select(int numfds, fd_set * readfds, fd_set * writefds, fd_set * - exceptfds, struct timeval * timeout) +_select(int numfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds, + struct timeval * timeout) { struct timespec ts; int i, ret = 0, f_wait = 1; @@ -204,5 +204,5 @@ _libc_select(int numfds, fd_set * readfds, fd_set * writefds, fd_set * return (ret); } -__weak_reference(_libc_select, select); +__weak_reference(_select, select); #endif diff --git a/lib/libc_r/uthread/uthread_sem.c b/lib/libc_r/uthread/uthread_sem.c index 8adb0d4..d35f9bc 100644 --- a/lib/libc_r/uthread/uthread_sem.c +++ b/lib/libc_r/uthread/uthread_sem.c @@ -147,6 +147,8 @@ sem_wait(sem_t *sem) { int retval; + _thread_enter_cancellation_point(); + _SEM_CHECK_VALIDITY(sem); pthread_mutex_lock(&(*sem)->lock); @@ -162,6 +164,7 @@ sem_wait(sem_t *sem) retval = 0; RETURN: + _thread_leave_cancellation_point(); return retval; } diff --git a/lib/libc_r/uthread/uthread_sendmsg.c b/lib/libc_r/uthread/uthread_sendmsg.c index d280519..c515269 100644 --- a/lib/libc_r/uthread/uthread_sendmsg.c +++ b/lib/libc_r/uthread/uthread_sendmsg.c @@ -40,7 +40,7 @@ #include "pthread_private.h" ssize_t -_libc_sendmsg(int fd, const struct msghdr *msg, int flags) +_sendmsg(int fd, const struct msghdr *msg, int flags) { int ret; @@ -70,5 +70,5 @@ _libc_sendmsg(int fd, const struct msghdr *msg, int flags) return (ret); } -__weak_reference(_libc_sendmsg, sendmsg); +__weak_reference(_sendmsg, sendmsg); #endif diff --git a/lib/libc_r/uthread/uthread_sendto.c b/lib/libc_r/uthread/uthread_sendto.c index dc134bc..6c1df48 100644 --- a/lib/libc_r/uthread/uthread_sendto.c +++ b/lib/libc_r/uthread/uthread_sendto.c @@ -40,7 +40,7 @@ #include "pthread_private.h" ssize_t -_libc_sendto(int fd, const void *msg, size_t len, int flags, const struct +_sendto(int fd, const void *msg, size_t len, int flags, const struct sockaddr * to, socklen_t to_len) { int ret; @@ -71,5 +71,5 @@ _libc_sendto(int fd, const void *msg, size_t len, int flags, const struct return (ret); } -__weak_reference(_libc_sendto, sendto); +__weak_reference(_sendto, sendto); #endif diff --git a/lib/libc_r/uthread/uthread_setsockopt.c b/lib/libc_r/uthread/uthread_setsockopt.c index eb917f5..fe0a55e 100644 --- a/lib/libc_r/uthread/uthread_setsockopt.c +++ b/lib/libc_r/uthread/uthread_setsockopt.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_setsockopt(int fd, int level, int optname, const void *optval, socklen_t +_setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen) { int ret; @@ -50,5 +50,5 @@ _libc_setsockopt(int fd, int level, int optname, const void *optval, socklen_t return ret; } -__weak_reference(_libc_setsockopt, setsockopt); +__weak_reference(_setsockopt, setsockopt); #endif diff --git a/lib/libc_r/uthread/uthread_shutdown.c b/lib/libc_r/uthread/uthread_shutdown.c index cffe4b6..8ce4d6d 100644 --- a/lib/libc_r/uthread/uthread_shutdown.c +++ b/lib/libc_r/uthread/uthread_shutdown.c @@ -39,7 +39,7 @@ #include "pthread_private.h" int -_libc_shutdown(int fd, int how) +_shutdown(int fd, int how) { int ret; @@ -70,5 +70,5 @@ _libc_shutdown(int fd, int how) return (ret); } -__weak_reference(_libc_shutdown, shutdown); +__weak_reference(_shutdown, shutdown); #endif diff --git a/lib/libc_r/uthread/uthread_sigaction.c b/lib/libc_r/uthread/uthread_sigaction.c index f2f7286..e0aa523 100644 --- a/lib/libc_r/uthread/uthread_sigaction.c +++ b/lib/libc_r/uthread/uthread_sigaction.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_sigaction(int sig, const struct sigaction * act, struct sigaction * oact) +_sigaction(int sig, const struct sigaction * act, struct sigaction * oact) { int ret = 0; struct sigaction gact; @@ -106,5 +106,5 @@ _libc_sigaction(int sig, const struct sigaction * act, struct sigaction * oact) return (ret); } -__weak_reference(_libc_sigaction, sigaction); +__weak_reference(_sigaction, sigaction); #endif diff --git a/lib/libc_r/uthread/uthread_sigpending.c b/lib/libc_r/uthread/uthread_sigpending.c index feb4300..a630f0c 100644 --- a/lib/libc_r/uthread/uthread_sigpending.c +++ b/lib/libc_r/uthread/uthread_sigpending.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_sigpending(sigset_t * set) +_sigpending(sigset_t * set) { int ret = 0; @@ -54,5 +54,5 @@ _libc_sigpending(sigset_t * set) return (ret); } -__weak_reference(_libc_sigpending, sigpending); +__weak_reference(_sigpending, sigpending); #endif diff --git a/lib/libc_r/uthread/uthread_sigprocmask.c b/lib/libc_r/uthread/uthread_sigprocmask.c index 28ab4fa..b10089c 100644 --- a/lib/libc_r/uthread/uthread_sigprocmask.c +++ b/lib/libc_r/uthread/uthread_sigprocmask.c @@ -41,7 +41,7 @@ #include "pthread_private.h" int -_libc_sigprocmask(int how, const sigset_t * set, sigset_t * oset) +_sigprocmask(int how, const sigset_t * set, sigset_t * oset) { int ret = 0; @@ -90,5 +90,5 @@ _libc_sigprocmask(int how, const sigset_t * set, sigset_t * oset) return (ret); } -__weak_reference(_libc_sigprocmask, sigprocmask); +__weak_reference(_sigprocmask, sigprocmask); #endif diff --git a/lib/libc_r/uthread/uthread_sigsuspend.c b/lib/libc_r/uthread/uthread_sigsuspend.c index b64897a..28959c8 100644 --- a/lib/libc_r/uthread/uthread_sigsuspend.c +++ b/lib/libc_r/uthread/uthread_sigsuspend.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_sigsuspend(const sigset_t * set) +_sigsuspend(const sigset_t * set) { int ret = -1; sigset_t oset; @@ -68,5 +68,15 @@ _libc_sigsuspend(const sigset_t * set) return (ret); } -__weak_reference(_libc_sigsuspend, sigsuspend); +int +sigsuspend(const sigset_t * set) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = _sigsuspend(set); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libc_r/uthread/uthread_sigwait.c b/lib/libc_r/uthread/uthread_sigwait.c index faa227e..a509687 100644 --- a/lib/libc_r/uthread/uthread_sigwait.c +++ b/lib/libc_r/uthread/uthread_sigwait.c @@ -143,6 +143,7 @@ sigwait(const sigset_t * set, int *sig) } _thread_leave_cancellation_point(); + /* Return the completion status: */ return (ret); } diff --git a/lib/libc_r/uthread/uthread_sleep.c b/lib/libc_r/uthread/uthread_sleep.c new file mode 100644 index 0000000..34a5925 --- /dev/null +++ b/lib/libc_r/uthread/uthread_sleep.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +unsigned int +sleep(unsigned int seconds) +{ + unsigned int ret; + + _thread_enter_cancellation_point(); + ret = __sleep(seconds); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libc_r/uthread/uthread_socket.c b/lib/libc_r/uthread/uthread_socket.c index bab70df..d1fe141 100644 --- a/lib/libc_r/uthread/uthread_socket.c +++ b/lib/libc_r/uthread/uthread_socket.c @@ -40,7 +40,7 @@ #include "pthread_private.h" int -_libc_socket(int af, int type, int protocol) +_socket(int af, int type, int protocol) { int fd; @@ -56,5 +56,5 @@ _libc_socket(int af, int type, int protocol) return (fd); } -__weak_reference(_libc_socket, socket); +__weak_reference(_socket, socket); #endif diff --git a/lib/libc_r/uthread/uthread_socketpair.c b/lib/libc_r/uthread/uthread_socketpair.c index f35ab94..023bfa9 100644 --- a/lib/libc_r/uthread/uthread_socketpair.c +++ b/lib/libc_r/uthread/uthread_socketpair.c @@ -41,7 +41,7 @@ #include "pthread_private.h" int -_libc_socketpair(int af, int type, int protocol, int pair[2]) +_socketpair(int af, int type, int protocol, int pair[2]) { int ret; if (!((ret = _thread_sys_socketpair(af, type, protocol, pair)) < 0)) @@ -54,5 +54,5 @@ _libc_socketpair(int af, int type, int protocol, int pair[2]) return (ret); } -__weak_reference(_libc_socketpair, socketpair); +__weak_reference(_socketpair, socketpair); #endif diff --git a/lib/libc_r/uthread/uthread_spinlock.c b/lib/libc_r/uthread/uthread_spinlock.c index 4e94ffc..e797f90 100644 --- a/lib/libc_r/uthread/uthread_spinlock.c +++ b/lib/libc_r/uthread/uthread_spinlock.c @@ -90,7 +90,7 @@ _spinlock_debug(spinlock_t *lck, char *fname, int lineno) char str[256]; snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) was left locked from %s (%d)\n", __progname, _thread_run, lck, fname, lineno, lck->fname, lck->lineno); _thread_sys_write(2,str,strlen(str)); - sleep(1); + __sleep(1); cnt = 0; } diff --git a/lib/libc_r/uthread/uthread_system.c b/lib/libc_r/uthread/uthread_system.c new file mode 100644 index 0000000..9265975 --- /dev/null +++ b/lib/libc_r/uthread/uthread_system.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +int +system(const char *string) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = __system(string); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libc_r/uthread/uthread_tcdrain.c b/lib/libc_r/uthread/uthread_tcdrain.c new file mode 100644 index 0000000..d040599 --- /dev/null +++ b/lib/libc_r/uthread/uthread_tcdrain.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +int +tcdrain(int fd) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = __tcdrain(fd); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libc_r/uthread/uthread_wait.c b/lib/libc_r/uthread/uthread_wait.c new file mode 100644 index 0000000..abc19cc --- /dev/null +++ b/lib/libc_r/uthread/uthread_wait.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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$ + */ + +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +pid_t +wait(int *istat) +{ + pid_t ret; + + _thread_enter_cancellation_point(); + ret = __wait(istat); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libc_r/uthread/uthread_wait4.c b/lib/libc_r/uthread/uthread_wait4.c index 4c3f1de..90eb0ab 100644 --- a/lib/libc_r/uthread/uthread_wait4.c +++ b/lib/libc_r/uthread/uthread_wait4.c @@ -38,11 +38,10 @@ #include "pthread_private.h" pid_t -_libc_wait4(pid_t pid, int *istat, int options, struct rusage * rusage) +_wait4(pid_t pid, int *istat, int options, struct rusage * rusage) { pid_t ret; - _thread_enter_cancellation_point(); _thread_kern_sig_defer(); /* Perform a non-blocking wait4 syscall: */ @@ -62,10 +61,9 @@ _libc_wait4(pid_t pid, int *istat, int options, struct rusage * rusage) } _thread_kern_sig_undefer(); - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_wait4, wait4); +__weak_reference(_wait4, wait4); #endif diff --git a/lib/libc_r/uthread/uthread_waitpid.c b/lib/libc_r/uthread/uthread_waitpid.c new file mode 100644 index 0000000..a847295 --- /dev/null +++ b/lib/libc_r/uthread/uthread_waitpid.c @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#include +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +pid_t +waitpid(pid_t wpid, int *status, int options) +{ + pid_t ret; + + _thread_enter_cancellation_point(); + ret = __waitpid(wpid, status, options); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libc_r/uthread/uthread_write.c b/lib/libc_r/uthread/uthread_write.c index f25c606..6408a64 100644 --- a/lib/libc_r/uthread/uthread_write.c +++ b/lib/libc_r/uthread/uthread_write.c @@ -42,7 +42,7 @@ #include "pthread_private.h" ssize_t -_libc_write(int fd, const void *buf, size_t nbytes) +_write(int fd, const void *buf, size_t nbytes) { int blocking; int type; @@ -50,12 +50,9 @@ _libc_write(int fd, const void *buf, size_t nbytes) ssize_t num = 0; ssize_t ret; - _thread_enter_cancellation_point(); /* POSIX says to do just this: */ - if (nbytes == 0) { - _thread_leave_cancellation_point(); + if (nbytes == 0) return (0); - } /* Lock the file descriptor for write: */ if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { @@ -67,7 +64,6 @@ _libc_write(int fd, const void *buf, size_t nbytes) /* File is not open for write: */ errno = EBADF; _FD_UNLOCK(fd, FD_WRITE); - _thread_leave_cancellation_point(); return (-1); } @@ -133,9 +129,18 @@ _libc_write(int fd, const void *buf, size_t nbytes) } _FD_UNLOCK(fd, FD_RDWR); } - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_write, write); +ssize_t +write(int fd, const void *buf, size_t nbytes) +{ + ssize_t ret; + + _thread_enter_cancellation_point(); + ret = _write(fd, buf, nbytes); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libc_r/uthread/uthread_writev.c b/lib/libc_r/uthread/uthread_writev.c index 74da521..7c5fffe 100644 --- a/lib/libc_r/uthread/uthread_writev.c +++ b/lib/libc_r/uthread/uthread_writev.c @@ -44,7 +44,7 @@ #include "pthread_private.h" ssize_t -_libc_writev(int fd, const struct iovec * iov, int iovcnt) +_writev(int fd, const struct iovec * iov, int iovcnt) { int blocking; int idx = 0; @@ -201,5 +201,5 @@ _libc_writev(int fd, const struct iovec * iov, int iovcnt) return (ret); } -__weak_reference(_libc_writev, writev); +__weak_reference(_writev, writev); #endif diff --git a/lib/libkse/Makefile b/lib/libkse/Makefile index e79d5c5..1b0afbb 100644 --- a/lib/libkse/Makefile +++ b/lib/libkse/Makefile @@ -26,7 +26,7 @@ PRECIOUSLIB= yes # This is a list of syscalls that are renamed as _thread_sys_{syscall} # so that libc_r can provide replacement functions. # -HIDDEN_SYSCALLS= accept.o bind.o close.o connect.o dup.o dup2.o \ +HIDDEN_SYSCALLS= aio_suspend.o accept.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 \ getlogin.o getpeername.o getsockname.o getsockopt.o ioctl.o listen.o \ diff --git a/lib/libkse/thread/Makefile.inc b/lib/libkse/thread/Makefile.inc index 2a13365..a88f955 100644 --- a/lib/libkse/thread/Makefile.inc +++ b/lib/libkse/thread/Makefile.inc @@ -5,6 +5,7 @@ SRCS+= \ uthread_accept.c \ + uthread_aio_suspend.c \ uthread_attr_destroy.c \ uthread_attr_init.c \ uthread_attr_getdetachstate.c \ @@ -31,6 +32,7 @@ SRCS+= \ uthread_condattr_destroy.c \ uthread_condattr_init.c \ uthread_connect.c \ + uthread_creat.c \ uthread_create.c \ uthread_detach.c \ uthread_dup.c \ @@ -76,6 +78,7 @@ SRCS+= \ uthread_nanosleep.c \ uthread_once.c \ uthread_open.c \ + uthread_pause.c \ uthread_pipe.c \ uthread_poll.c \ uthread_priority_queue.c \ @@ -106,14 +109,19 @@ SRCS+= \ uthread_sigsuspend.c \ uthread_sigwait.c \ uthread_single_np.c \ + uthread_sleep.c \ uthread_socket.c \ uthread_socketpair.c \ uthread_spec.c \ uthread_spinlock.c \ uthread_suspend_np.c \ uthread_switch_np.c \ + uthread_system.c \ + uthread_tcdrain.c \ uthread_vfork.c \ + uthread_wait.c \ uthread_wait4.c \ + uthread_waitpid.c \ uthread_write.c \ uthread_writev.c \ uthread_yield.c diff --git a/lib/libkse/thread/thr_aio_suspend.c b/lib/libkse/thread/thr_aio_suspend.c new file mode 100644 index 0000000..3bc373a --- /dev/null +++ b/lib/libkse/thread/thr_aio_suspend.c @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +int +_aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct + timespec *timeout) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = _aio_suspend(iocbs, niocb, timeout); + _thread_leave_cancellation_point(); + + return ret; +} + +__weak_reference(_aio_suspend, aio_suspend); +#endif diff --git a/lib/libkse/thread/thr_close.c b/lib/libkse/thread/thr_close.c index fe2d9e2..9dee2bc 100644 --- a/lib/libkse/thread/thr_close.c +++ b/lib/libkse/thread/thr_close.c @@ -41,15 +41,13 @@ #include "pthread_private.h" int -_libc_close(int fd) +_close(int fd) { int flags; int ret; struct stat sb; struct fd_table_entry *entry; - _thread_enter_cancellation_point(); - if ((fd == _thread_kern_pipe[0]) || (fd == _thread_kern_pipe[1])) { /* * Don't allow silly programs to close the kernel pipe. @@ -99,9 +97,18 @@ _libc_close(int fd) /* Close the file descriptor: */ ret = _thread_sys_close(fd); } - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_close, close); +int +close(int fd) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = _close(fd); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libkse/thread/thr_cond.c b/lib/libkse/thread/thr_cond.c index ced48e3..d236607 100644 --- a/lib/libkse/thread/thr_cond.c +++ b/lib/libkse/thread/thr_cond.c @@ -160,6 +160,8 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex) int rval = 0; int interrupted = 0; + _thread_enter_cancellation_point(); + if (cond == NULL) rval = EINVAL; @@ -286,6 +288,8 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex) _thread_leave_cancellation_point(); } + _thread_leave_cancellation_point(); + /* Return the completion status: */ return (rval); } @@ -297,12 +301,15 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, int rval = 0; int interrupted = 0; + _thread_enter_cancellation_point(); + if (cond == NULL || abstime == NULL) rval = EINVAL; if (abstime->tv_sec < 0 || abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) { errno = EINVAL; + _thread_leave_cancellation_point(); return (-1); } @@ -448,6 +455,8 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, _thread_leave_cancellation_point(); } + _thread_leave_cancellation_point(); + /* Return the completion status: */ return (rval); } diff --git a/lib/libkse/thread/thr_creat.c b/lib/libkse/thread/thr_creat.c new file mode 100644 index 0000000..bb8e7c2 --- /dev/null +++ b/lib/libkse/thread/thr_creat.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +int +creat(const char *path, mode_t mode) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = __creat(path, mode); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libkse/thread/thr_exit.c b/lib/libkse/thread/thr_exit.c index 57ac114..22e2ce8 100644 --- a/lib/libkse/thread/thr_exit.c +++ b/lib/libkse/thread/thr_exit.c @@ -41,7 +41,7 @@ #include #include "pthread_private.h" -void _libc__exit(int status) +void __exit(int status) { int flags; int i; @@ -77,7 +77,7 @@ void _libc__exit(int status) _thread_sys__exit(status); } -__weak_reference(_libc__exit, _exit); +__weak_reference(__exit, _exit); void _thread_exit(char *fname, int lineno, char *string) diff --git a/lib/libkse/thread/thr_fcntl.c b/lib/libkse/thread/thr_fcntl.c index 6cd2b12..06e2e3b 100644 --- a/lib/libkse/thread/thr_fcntl.c +++ b/lib/libkse/thread/thr_fcntl.c @@ -39,7 +39,7 @@ #include "pthread_private.h" int -_libc_fcntl(int fd, int cmd,...) +_fcntl(int fd, int cmd,...) { int flags = 0; int nonblock; @@ -47,8 +47,6 @@ _libc_fcntl(int fd, int cmd,...) int ret; va_list ap; - _thread_enter_cancellation_point(); - /* Lock the file descriptor: */ if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { /* Initialise the variable argument list: */ @@ -137,11 +135,36 @@ _libc_fcntl(int fd, int cmd,...) /* Unlock the file descriptor: */ _FD_UNLOCK(fd, FD_RDWR); } - _thread_leave_cancellation_point(); - /* Return the completion status: */ return (ret); } -__weak_reference(_libc_fcntl, fcntl); +int +fcntl(int fd, int cmd,...) +{ + int ret; + va_list ap; + + _thread_enter_cancellation_point(); + + va_start(ap, cmd); + switch (cmd) { + case F_DUPFD: + case F_SETFD: + case F_SETFL: + ret = fcntl(fd, cmd, va_arg(ap, int)); + break; + case F_GETFD: + case F_GETFL: + ret = fcntl(fd, cmd); + break; + default: + ret = fcntl(fd, cmd, va_arg(ap, void *)); + } + va_end(ap); + + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libkse/thread/thr_fork.c b/lib/libkse/thread/thr_fork.c index 8c112e8..88f1c43 100644 --- a/lib/libkse/thread/thr_fork.c +++ b/lib/libkse/thread/thr_fork.c @@ -41,7 +41,7 @@ #include "pthread_private.h" pid_t -_libc_fork(void) +_fork(void) { int i, flags; pid_t ret; @@ -221,5 +221,5 @@ _libc_fork(void) return (ret); } -__weak_reference(_libc_fork, fork); +__weak_reference(_fork, fork); #endif diff --git a/lib/libkse/thread/thr_fsync.c b/lib/libkse/thread/thr_fsync.c index 048e60b..0d88320 100644 --- a/lib/libkse/thread/thr_fsync.c +++ b/lib/libkse/thread/thr_fsync.c @@ -37,18 +37,26 @@ #include "pthread_private.h" int -_libc_fsync(int fd) +_fsync(int fd) { - int ret; + int ret; - _thread_enter_cancellation_point(); if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { ret = _thread_sys_fsync(fd); _FD_UNLOCK(fd, FD_RDWR); } - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_fsync, fsync); +int +fsync(int fd) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = _fsync(fd); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libkse/thread/thr_msync.c b/lib/libkse/thread/thr_msync.c index 9559ec4..2ae6ac7 100644 --- a/lib/libkse/thread/thr_msync.c +++ b/lib/libkse/thread/thr_msync.c @@ -13,30 +13,30 @@ #include "pthread_private.h" int -_libc_msync(addr, len, flags) - void *addr; - size_t len; - int flags; +_msync(void *addr, size_t len, int flags) { int ret; + ret = _thread_sys_msync(addr, len, flags); + + return (ret); +} + +int +msync(void *addr, size_t len, int flags) +{ + int ret; + /* * XXX This is quite pointless unless we know how to get the * file descriptor associated with the memory, and lock it for * write. The only real use of this wrapper is to guarantee * a cancellation point, as per the standard. sigh. */ - - /* This is a cancellation point: */ _thread_enter_cancellation_point(); - - ret = _thread_sys_msync(addr, len, flags); - - /* No longer in a cancellation point: */ + ret = _msync(addr, len, flags); _thread_leave_cancellation_point(); - return (ret); + return ret; } - -__weak_reference(_libc_msync, msync); #endif diff --git a/lib/libkse/thread/thr_nanosleep.c b/lib/libkse/thread/thr_nanosleep.c index e9052f9..3bbc9a6 100644 --- a/lib/libkse/thread/thr_nanosleep.c +++ b/lib/libkse/thread/thr_nanosleep.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_nanosleep(const struct timespec * time_to_sleep, +_nanosleep(const struct timespec * time_to_sleep, struct timespec * time_remaining) { int ret = 0; @@ -47,7 +47,6 @@ _libc_nanosleep(const struct timespec * time_to_sleep, struct timespec remaining_time; struct timeval tv; - _thread_enter_cancellation_point(); /* Check if the time to sleep is legal: */ if (time_to_sleep == NULL || time_to_sleep->tv_sec < 0 || time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec >= 1000000000) { @@ -117,9 +116,19 @@ _libc_nanosleep(const struct timespec * time_to_sleep, ret = -1; } } - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_nanosleep, nanosleep); +int +nanosleep(const struct timespec * time_to_sleep, struct timespec * + time_remaining) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = _nanosleep(time_to_sleep, time_remaining); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libkse/thread/thr_open.c b/lib/libkse/thread/thr_open.c index 4bc2f1a..e7fef91 100644 --- a/lib/libkse/thread/thr_open.c +++ b/lib/libkse/thread/thr_open.c @@ -42,14 +42,12 @@ #include "pthread_private.h" int -_libc_open(const char *path, int flags,...) +_open(const char *path, int flags,...) { int fd; int mode = 0; va_list ap; - _thread_enter_cancellation_point(); - /* Check if the file is being created: */ if (flags & O_CREAT) { /* Get the creation mode: */ @@ -69,11 +67,30 @@ _libc_open(const char *path, int flags,...) fd = -1; } - _thread_leave_cancellation_point(); - /* Return the file descriptor or -1 on error: */ return (fd); } -__weak_reference(_libc_open, open); +int +open(const char *path, int flags,...) +{ + int ret; + int mode = 0; + va_list ap; + + _thread_enter_cancellation_point(); + + /* Check if the file is being created: */ + if (flags & O_CREAT) { + /* Get the creation mode: */ + va_start(ap, flags); + mode = va_arg(ap, int); + va_end(ap); + } + + ret = _open(path, flags, mode); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libkse/thread/thr_pause.c b/lib/libkse/thread/thr_pause.c new file mode 100644 index 0000000..a841556 --- /dev/null +++ b/lib/libkse/thread/thr_pause.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +int +pause(void) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = __pause(); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libkse/thread/thr_poll.c b/lib/libkse/thread/thr_poll.c index fb6a266..d395250 100644 --- a/lib/libkse/thread/thr_poll.c +++ b/lib/libkse/thread/thr_poll.c @@ -44,7 +44,7 @@ int -_libc_poll(struct pollfd *fds, unsigned int nfds, int timeout) +_poll(struct pollfd *fds, unsigned int nfds, int timeout) { struct timespec ts; int numfds = nfds; @@ -97,5 +97,5 @@ _libc_poll(struct pollfd *fds, unsigned int nfds, int timeout) return (ret); } -__weak_reference(_libc_poll, poll); +__weak_reference(_poll, poll); #endif diff --git a/lib/libkse/thread/thr_read.c b/lib/libkse/thread/thr_read.c index ad66df3..b4d9694 100644 --- a/lib/libkse/thread/thr_read.c +++ b/lib/libkse/thread/thr_read.c @@ -42,16 +42,13 @@ #include "pthread_private.h" ssize_t -_libc_read(int fd, void *buf, size_t nbytes) +_read(int fd, void *buf, size_t nbytes) { int ret; int type; - _thread_enter_cancellation_point(); - /* POSIX says to do just this: */ if (nbytes == 0) { - _thread_leave_cancellation_point(); return (0); } @@ -65,7 +62,6 @@ _libc_read(int fd, void *buf, size_t nbytes) /* File is not open for read: */ errno = EBADF; _FD_UNLOCK(fd, FD_READ); - _thread_leave_cancellation_point(); return (-1); } @@ -97,9 +93,18 @@ _libc_read(int fd, void *buf, size_t nbytes) } _FD_UNLOCK(fd, FD_READ); } - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_read, read); +ssize_t +read(int fd, void *buf, size_t nbytes) +{ + ssize_t ret; + + _thread_enter_cancellation_point(); + ret = _read(fd, buf, nbytes); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libkse/thread/thr_readv.c b/lib/libkse/thread/thr_readv.c index c1965d8..2c66a98 100644 --- a/lib/libkse/thread/thr_readv.c +++ b/lib/libkse/thread/thr_readv.c @@ -42,7 +42,7 @@ #include "pthread_private.h" ssize_t -_libc_readv(int fd, const struct iovec * iov, int iovcnt) +_readv(int fd, const struct iovec * iov, int iovcnt) { int ret; int type; @@ -91,5 +91,5 @@ _libc_readv(int fd, const struct iovec * iov, int iovcnt) return (ret); } -__weak_reference(_libc_readv, readv); +__weak_reference(_readv, readv); #endif diff --git a/lib/libkse/thread/thr_select.c b/lib/libkse/thread/thr_select.c index a7ceecc..d0e61e2 100644 --- a/lib/libkse/thread/thr_select.c +++ b/lib/libkse/thread/thr_select.c @@ -45,8 +45,8 @@ #include "pthread_private.h" int -_libc_select(int numfds, fd_set * readfds, fd_set * writefds, fd_set * - exceptfds, struct timeval * timeout) +_select(int numfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds, + struct timeval * timeout) { struct timespec ts; int i, ret = 0, f_wait = 1; @@ -204,5 +204,5 @@ _libc_select(int numfds, fd_set * readfds, fd_set * writefds, fd_set * return (ret); } -__weak_reference(_libc_select, select); +__weak_reference(_select, select); #endif diff --git a/lib/libkse/thread/thr_sem.c b/lib/libkse/thread/thr_sem.c index 8adb0d4..d35f9bc 100644 --- a/lib/libkse/thread/thr_sem.c +++ b/lib/libkse/thread/thr_sem.c @@ -147,6 +147,8 @@ sem_wait(sem_t *sem) { int retval; + _thread_enter_cancellation_point(); + _SEM_CHECK_VALIDITY(sem); pthread_mutex_lock(&(*sem)->lock); @@ -162,6 +164,7 @@ sem_wait(sem_t *sem) retval = 0; RETURN: + _thread_leave_cancellation_point(); return retval; } diff --git a/lib/libkse/thread/thr_sigaction.c b/lib/libkse/thread/thr_sigaction.c index f2f7286..e0aa523 100644 --- a/lib/libkse/thread/thr_sigaction.c +++ b/lib/libkse/thread/thr_sigaction.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_sigaction(int sig, const struct sigaction * act, struct sigaction * oact) +_sigaction(int sig, const struct sigaction * act, struct sigaction * oact) { int ret = 0; struct sigaction gact; @@ -106,5 +106,5 @@ _libc_sigaction(int sig, const struct sigaction * act, struct sigaction * oact) return (ret); } -__weak_reference(_libc_sigaction, sigaction); +__weak_reference(_sigaction, sigaction); #endif diff --git a/lib/libkse/thread/thr_sigpending.c b/lib/libkse/thread/thr_sigpending.c index feb4300..a630f0c 100644 --- a/lib/libkse/thread/thr_sigpending.c +++ b/lib/libkse/thread/thr_sigpending.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_sigpending(sigset_t * set) +_sigpending(sigset_t * set) { int ret = 0; @@ -54,5 +54,5 @@ _libc_sigpending(sigset_t * set) return (ret); } -__weak_reference(_libc_sigpending, sigpending); +__weak_reference(_sigpending, sigpending); #endif diff --git a/lib/libkse/thread/thr_sigprocmask.c b/lib/libkse/thread/thr_sigprocmask.c index 28ab4fa..b10089c 100644 --- a/lib/libkse/thread/thr_sigprocmask.c +++ b/lib/libkse/thread/thr_sigprocmask.c @@ -41,7 +41,7 @@ #include "pthread_private.h" int -_libc_sigprocmask(int how, const sigset_t * set, sigset_t * oset) +_sigprocmask(int how, const sigset_t * set, sigset_t * oset) { int ret = 0; @@ -90,5 +90,5 @@ _libc_sigprocmask(int how, const sigset_t * set, sigset_t * oset) return (ret); } -__weak_reference(_libc_sigprocmask, sigprocmask); +__weak_reference(_sigprocmask, sigprocmask); #endif diff --git a/lib/libkse/thread/thr_sigsuspend.c b/lib/libkse/thread/thr_sigsuspend.c index b64897a..28959c8 100644 --- a/lib/libkse/thread/thr_sigsuspend.c +++ b/lib/libkse/thread/thr_sigsuspend.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_sigsuspend(const sigset_t * set) +_sigsuspend(const sigset_t * set) { int ret = -1; sigset_t oset; @@ -68,5 +68,15 @@ _libc_sigsuspend(const sigset_t * set) return (ret); } -__weak_reference(_libc_sigsuspend, sigsuspend); +int +sigsuspend(const sigset_t * set) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = _sigsuspend(set); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libkse/thread/thr_sigwait.c b/lib/libkse/thread/thr_sigwait.c index faa227e..a509687 100644 --- a/lib/libkse/thread/thr_sigwait.c +++ b/lib/libkse/thread/thr_sigwait.c @@ -143,6 +143,7 @@ sigwait(const sigset_t * set, int *sig) } _thread_leave_cancellation_point(); + /* Return the completion status: */ return (ret); } diff --git a/lib/libkse/thread/thr_sleep.c b/lib/libkse/thread/thr_sleep.c new file mode 100644 index 0000000..34a5925 --- /dev/null +++ b/lib/libkse/thread/thr_sleep.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +unsigned int +sleep(unsigned int seconds) +{ + unsigned int ret; + + _thread_enter_cancellation_point(); + ret = __sleep(seconds); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libkse/thread/thr_spinlock.c b/lib/libkse/thread/thr_spinlock.c index 4e94ffc..e797f90 100644 --- a/lib/libkse/thread/thr_spinlock.c +++ b/lib/libkse/thread/thr_spinlock.c @@ -90,7 +90,7 @@ _spinlock_debug(spinlock_t *lck, char *fname, int lineno) char str[256]; snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) was left locked from %s (%d)\n", __progname, _thread_run, lck, fname, lineno, lck->fname, lck->lineno); _thread_sys_write(2,str,strlen(str)); - sleep(1); + __sleep(1); cnt = 0; } diff --git a/lib/libkse/thread/thr_system.c b/lib/libkse/thread/thr_system.c new file mode 100644 index 0000000..9265975 --- /dev/null +++ b/lib/libkse/thread/thr_system.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +int +system(const char *string) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = __system(string); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libkse/thread/thr_tcdrain.c b/lib/libkse/thread/thr_tcdrain.c new file mode 100644 index 0000000..d040599 --- /dev/null +++ b/lib/libkse/thread/thr_tcdrain.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +int +tcdrain(int fd) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = __tcdrain(fd); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libkse/thread/thr_wait.c b/lib/libkse/thread/thr_wait.c new file mode 100644 index 0000000..abc19cc --- /dev/null +++ b/lib/libkse/thread/thr_wait.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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$ + */ + +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +pid_t +wait(int *istat) +{ + pid_t ret; + + _thread_enter_cancellation_point(); + ret = __wait(istat); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libkse/thread/thr_wait4.c b/lib/libkse/thread/thr_wait4.c index 4c3f1de..90eb0ab 100644 --- a/lib/libkse/thread/thr_wait4.c +++ b/lib/libkse/thread/thr_wait4.c @@ -38,11 +38,10 @@ #include "pthread_private.h" pid_t -_libc_wait4(pid_t pid, int *istat, int options, struct rusage * rusage) +_wait4(pid_t pid, int *istat, int options, struct rusage * rusage) { pid_t ret; - _thread_enter_cancellation_point(); _thread_kern_sig_defer(); /* Perform a non-blocking wait4 syscall: */ @@ -62,10 +61,9 @@ _libc_wait4(pid_t pid, int *istat, int options, struct rusage * rusage) } _thread_kern_sig_undefer(); - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_wait4, wait4); +__weak_reference(_wait4, wait4); #endif diff --git a/lib/libkse/thread/thr_waitpid.c b/lib/libkse/thread/thr_waitpid.c new file mode 100644 index 0000000..a847295 --- /dev/null +++ b/lib/libkse/thread/thr_waitpid.c @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#include +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +pid_t +waitpid(pid_t wpid, int *status, int options) +{ + pid_t ret; + + _thread_enter_cancellation_point(); + ret = __waitpid(wpid, status, options); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libkse/thread/thr_write.c b/lib/libkse/thread/thr_write.c index f25c606..6408a64 100644 --- a/lib/libkse/thread/thr_write.c +++ b/lib/libkse/thread/thr_write.c @@ -42,7 +42,7 @@ #include "pthread_private.h" ssize_t -_libc_write(int fd, const void *buf, size_t nbytes) +_write(int fd, const void *buf, size_t nbytes) { int blocking; int type; @@ -50,12 +50,9 @@ _libc_write(int fd, const void *buf, size_t nbytes) ssize_t num = 0; ssize_t ret; - _thread_enter_cancellation_point(); /* POSIX says to do just this: */ - if (nbytes == 0) { - _thread_leave_cancellation_point(); + if (nbytes == 0) return (0); - } /* Lock the file descriptor for write: */ if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { @@ -67,7 +64,6 @@ _libc_write(int fd, const void *buf, size_t nbytes) /* File is not open for write: */ errno = EBADF; _FD_UNLOCK(fd, FD_WRITE); - _thread_leave_cancellation_point(); return (-1); } @@ -133,9 +129,18 @@ _libc_write(int fd, const void *buf, size_t nbytes) } _FD_UNLOCK(fd, FD_RDWR); } - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_write, write); +ssize_t +write(int fd, const void *buf, size_t nbytes) +{ + ssize_t ret; + + _thread_enter_cancellation_point(); + ret = _write(fd, buf, nbytes); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libkse/thread/thr_writev.c b/lib/libkse/thread/thr_writev.c index 74da521..7c5fffe 100644 --- a/lib/libkse/thread/thr_writev.c +++ b/lib/libkse/thread/thr_writev.c @@ -44,7 +44,7 @@ #include "pthread_private.h" ssize_t -_libc_writev(int fd, const struct iovec * iov, int iovcnt) +_writev(int fd, const struct iovec * iov, int iovcnt) { int blocking; int idx = 0; @@ -201,5 +201,5 @@ _libc_writev(int fd, const struct iovec * iov, int iovcnt) return (ret); } -__weak_reference(_libc_writev, writev); +__weak_reference(_writev, writev); #endif diff --git a/lib/libpthread/Makefile b/lib/libpthread/Makefile index e79d5c5..1b0afbb 100644 --- a/lib/libpthread/Makefile +++ b/lib/libpthread/Makefile @@ -26,7 +26,7 @@ PRECIOUSLIB= yes # This is a list of syscalls that are renamed as _thread_sys_{syscall} # so that libc_r can provide replacement functions. # -HIDDEN_SYSCALLS= accept.o bind.o close.o connect.o dup.o dup2.o \ +HIDDEN_SYSCALLS= aio_suspend.o accept.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 \ getlogin.o getpeername.o getsockname.o getsockopt.o ioctl.o listen.o \ diff --git a/lib/libpthread/thread/Makefile.inc b/lib/libpthread/thread/Makefile.inc index 2a13365..a88f955 100644 --- a/lib/libpthread/thread/Makefile.inc +++ b/lib/libpthread/thread/Makefile.inc @@ -5,6 +5,7 @@ SRCS+= \ uthread_accept.c \ + uthread_aio_suspend.c \ uthread_attr_destroy.c \ uthread_attr_init.c \ uthread_attr_getdetachstate.c \ @@ -31,6 +32,7 @@ SRCS+= \ uthread_condattr_destroy.c \ uthread_condattr_init.c \ uthread_connect.c \ + uthread_creat.c \ uthread_create.c \ uthread_detach.c \ uthread_dup.c \ @@ -76,6 +78,7 @@ SRCS+= \ uthread_nanosleep.c \ uthread_once.c \ uthread_open.c \ + uthread_pause.c \ uthread_pipe.c \ uthread_poll.c \ uthread_priority_queue.c \ @@ -106,14 +109,19 @@ SRCS+= \ uthread_sigsuspend.c \ uthread_sigwait.c \ uthread_single_np.c \ + uthread_sleep.c \ uthread_socket.c \ uthread_socketpair.c \ uthread_spec.c \ uthread_spinlock.c \ uthread_suspend_np.c \ uthread_switch_np.c \ + uthread_system.c \ + uthread_tcdrain.c \ uthread_vfork.c \ + uthread_wait.c \ uthread_wait4.c \ + uthread_waitpid.c \ uthread_write.c \ uthread_writev.c \ uthread_yield.c diff --git a/lib/libpthread/thread/thr_aio_suspend.c b/lib/libpthread/thread/thr_aio_suspend.c new file mode 100644 index 0000000..3bc373a --- /dev/null +++ b/lib/libpthread/thread/thr_aio_suspend.c @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +int +_aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct + timespec *timeout) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = _aio_suspend(iocbs, niocb, timeout); + _thread_leave_cancellation_point(); + + return ret; +} + +__weak_reference(_aio_suspend, aio_suspend); +#endif diff --git a/lib/libpthread/thread/thr_close.c b/lib/libpthread/thread/thr_close.c index fe2d9e2..9dee2bc 100644 --- a/lib/libpthread/thread/thr_close.c +++ b/lib/libpthread/thread/thr_close.c @@ -41,15 +41,13 @@ #include "pthread_private.h" int -_libc_close(int fd) +_close(int fd) { int flags; int ret; struct stat sb; struct fd_table_entry *entry; - _thread_enter_cancellation_point(); - if ((fd == _thread_kern_pipe[0]) || (fd == _thread_kern_pipe[1])) { /* * Don't allow silly programs to close the kernel pipe. @@ -99,9 +97,18 @@ _libc_close(int fd) /* Close the file descriptor: */ ret = _thread_sys_close(fd); } - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_close, close); +int +close(int fd) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = _close(fd); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libpthread/thread/thr_cond.c b/lib/libpthread/thread/thr_cond.c index ced48e3..d236607 100644 --- a/lib/libpthread/thread/thr_cond.c +++ b/lib/libpthread/thread/thr_cond.c @@ -160,6 +160,8 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex) int rval = 0; int interrupted = 0; + _thread_enter_cancellation_point(); + if (cond == NULL) rval = EINVAL; @@ -286,6 +288,8 @@ pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex) _thread_leave_cancellation_point(); } + _thread_leave_cancellation_point(); + /* Return the completion status: */ return (rval); } @@ -297,12 +301,15 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, int rval = 0; int interrupted = 0; + _thread_enter_cancellation_point(); + if (cond == NULL || abstime == NULL) rval = EINVAL; if (abstime->tv_sec < 0 || abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) { errno = EINVAL; + _thread_leave_cancellation_point(); return (-1); } @@ -448,6 +455,8 @@ pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, _thread_leave_cancellation_point(); } + _thread_leave_cancellation_point(); + /* Return the completion status: */ return (rval); } diff --git a/lib/libpthread/thread/thr_creat.c b/lib/libpthread/thread/thr_creat.c new file mode 100644 index 0000000..bb8e7c2 --- /dev/null +++ b/lib/libpthread/thread/thr_creat.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +int +creat(const char *path, mode_t mode) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = __creat(path, mode); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libpthread/thread/thr_exit.c b/lib/libpthread/thread/thr_exit.c index 57ac114..22e2ce8 100644 --- a/lib/libpthread/thread/thr_exit.c +++ b/lib/libpthread/thread/thr_exit.c @@ -41,7 +41,7 @@ #include #include "pthread_private.h" -void _libc__exit(int status) +void __exit(int status) { int flags; int i; @@ -77,7 +77,7 @@ void _libc__exit(int status) _thread_sys__exit(status); } -__weak_reference(_libc__exit, _exit); +__weak_reference(__exit, _exit); void _thread_exit(char *fname, int lineno, char *string) diff --git a/lib/libpthread/thread/thr_fcntl.c b/lib/libpthread/thread/thr_fcntl.c index 6cd2b12..06e2e3b 100644 --- a/lib/libpthread/thread/thr_fcntl.c +++ b/lib/libpthread/thread/thr_fcntl.c @@ -39,7 +39,7 @@ #include "pthread_private.h" int -_libc_fcntl(int fd, int cmd,...) +_fcntl(int fd, int cmd,...) { int flags = 0; int nonblock; @@ -47,8 +47,6 @@ _libc_fcntl(int fd, int cmd,...) int ret; va_list ap; - _thread_enter_cancellation_point(); - /* Lock the file descriptor: */ if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { /* Initialise the variable argument list: */ @@ -137,11 +135,36 @@ _libc_fcntl(int fd, int cmd,...) /* Unlock the file descriptor: */ _FD_UNLOCK(fd, FD_RDWR); } - _thread_leave_cancellation_point(); - /* Return the completion status: */ return (ret); } -__weak_reference(_libc_fcntl, fcntl); +int +fcntl(int fd, int cmd,...) +{ + int ret; + va_list ap; + + _thread_enter_cancellation_point(); + + va_start(ap, cmd); + switch (cmd) { + case F_DUPFD: + case F_SETFD: + case F_SETFL: + ret = fcntl(fd, cmd, va_arg(ap, int)); + break; + case F_GETFD: + case F_GETFL: + ret = fcntl(fd, cmd); + break; + default: + ret = fcntl(fd, cmd, va_arg(ap, void *)); + } + va_end(ap); + + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libpthread/thread/thr_fork.c b/lib/libpthread/thread/thr_fork.c index 8c112e8..88f1c43 100644 --- a/lib/libpthread/thread/thr_fork.c +++ b/lib/libpthread/thread/thr_fork.c @@ -41,7 +41,7 @@ #include "pthread_private.h" pid_t -_libc_fork(void) +_fork(void) { int i, flags; pid_t ret; @@ -221,5 +221,5 @@ _libc_fork(void) return (ret); } -__weak_reference(_libc_fork, fork); +__weak_reference(_fork, fork); #endif diff --git a/lib/libpthread/thread/thr_fsync.c b/lib/libpthread/thread/thr_fsync.c index 048e60b..0d88320 100644 --- a/lib/libpthread/thread/thr_fsync.c +++ b/lib/libpthread/thread/thr_fsync.c @@ -37,18 +37,26 @@ #include "pthread_private.h" int -_libc_fsync(int fd) +_fsync(int fd) { - int ret; + int ret; - _thread_enter_cancellation_point(); if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) { ret = _thread_sys_fsync(fd); _FD_UNLOCK(fd, FD_RDWR); } - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_fsync, fsync); +int +fsync(int fd) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = _fsync(fd); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libpthread/thread/thr_msync.c b/lib/libpthread/thread/thr_msync.c index 9559ec4..2ae6ac7 100644 --- a/lib/libpthread/thread/thr_msync.c +++ b/lib/libpthread/thread/thr_msync.c @@ -13,30 +13,30 @@ #include "pthread_private.h" int -_libc_msync(addr, len, flags) - void *addr; - size_t len; - int flags; +_msync(void *addr, size_t len, int flags) { int ret; + ret = _thread_sys_msync(addr, len, flags); + + return (ret); +} + +int +msync(void *addr, size_t len, int flags) +{ + int ret; + /* * XXX This is quite pointless unless we know how to get the * file descriptor associated with the memory, and lock it for * write. The only real use of this wrapper is to guarantee * a cancellation point, as per the standard. sigh. */ - - /* This is a cancellation point: */ _thread_enter_cancellation_point(); - - ret = _thread_sys_msync(addr, len, flags); - - /* No longer in a cancellation point: */ + ret = _msync(addr, len, flags); _thread_leave_cancellation_point(); - return (ret); + return ret; } - -__weak_reference(_libc_msync, msync); #endif diff --git a/lib/libpthread/thread/thr_nanosleep.c b/lib/libpthread/thread/thr_nanosleep.c index e9052f9..3bbc9a6 100644 --- a/lib/libpthread/thread/thr_nanosleep.c +++ b/lib/libpthread/thread/thr_nanosleep.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_nanosleep(const struct timespec * time_to_sleep, +_nanosleep(const struct timespec * time_to_sleep, struct timespec * time_remaining) { int ret = 0; @@ -47,7 +47,6 @@ _libc_nanosleep(const struct timespec * time_to_sleep, struct timespec remaining_time; struct timeval tv; - _thread_enter_cancellation_point(); /* Check if the time to sleep is legal: */ if (time_to_sleep == NULL || time_to_sleep->tv_sec < 0 || time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec >= 1000000000) { @@ -117,9 +116,19 @@ _libc_nanosleep(const struct timespec * time_to_sleep, ret = -1; } } - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_nanosleep, nanosleep); +int +nanosleep(const struct timespec * time_to_sleep, struct timespec * + time_remaining) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = _nanosleep(time_to_sleep, time_remaining); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libpthread/thread/thr_open.c b/lib/libpthread/thread/thr_open.c index 4bc2f1a..e7fef91 100644 --- a/lib/libpthread/thread/thr_open.c +++ b/lib/libpthread/thread/thr_open.c @@ -42,14 +42,12 @@ #include "pthread_private.h" int -_libc_open(const char *path, int flags,...) +_open(const char *path, int flags,...) { int fd; int mode = 0; va_list ap; - _thread_enter_cancellation_point(); - /* Check if the file is being created: */ if (flags & O_CREAT) { /* Get the creation mode: */ @@ -69,11 +67,30 @@ _libc_open(const char *path, int flags,...) fd = -1; } - _thread_leave_cancellation_point(); - /* Return the file descriptor or -1 on error: */ return (fd); } -__weak_reference(_libc_open, open); +int +open(const char *path, int flags,...) +{ + int ret; + int mode = 0; + va_list ap; + + _thread_enter_cancellation_point(); + + /* Check if the file is being created: */ + if (flags & O_CREAT) { + /* Get the creation mode: */ + va_start(ap, flags); + mode = va_arg(ap, int); + va_end(ap); + } + + ret = _open(path, flags, mode); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libpthread/thread/thr_pause.c b/lib/libpthread/thread/thr_pause.c new file mode 100644 index 0000000..a841556 --- /dev/null +++ b/lib/libpthread/thread/thr_pause.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +int +pause(void) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = __pause(); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libpthread/thread/thr_poll.c b/lib/libpthread/thread/thr_poll.c index fb6a266..d395250 100644 --- a/lib/libpthread/thread/thr_poll.c +++ b/lib/libpthread/thread/thr_poll.c @@ -44,7 +44,7 @@ int -_libc_poll(struct pollfd *fds, unsigned int nfds, int timeout) +_poll(struct pollfd *fds, unsigned int nfds, int timeout) { struct timespec ts; int numfds = nfds; @@ -97,5 +97,5 @@ _libc_poll(struct pollfd *fds, unsigned int nfds, int timeout) return (ret); } -__weak_reference(_libc_poll, poll); +__weak_reference(_poll, poll); #endif diff --git a/lib/libpthread/thread/thr_read.c b/lib/libpthread/thread/thr_read.c index ad66df3..b4d9694 100644 --- a/lib/libpthread/thread/thr_read.c +++ b/lib/libpthread/thread/thr_read.c @@ -42,16 +42,13 @@ #include "pthread_private.h" ssize_t -_libc_read(int fd, void *buf, size_t nbytes) +_read(int fd, void *buf, size_t nbytes) { int ret; int type; - _thread_enter_cancellation_point(); - /* POSIX says to do just this: */ if (nbytes == 0) { - _thread_leave_cancellation_point(); return (0); } @@ -65,7 +62,6 @@ _libc_read(int fd, void *buf, size_t nbytes) /* File is not open for read: */ errno = EBADF; _FD_UNLOCK(fd, FD_READ); - _thread_leave_cancellation_point(); return (-1); } @@ -97,9 +93,18 @@ _libc_read(int fd, void *buf, size_t nbytes) } _FD_UNLOCK(fd, FD_READ); } - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_read, read); +ssize_t +read(int fd, void *buf, size_t nbytes) +{ + ssize_t ret; + + _thread_enter_cancellation_point(); + ret = _read(fd, buf, nbytes); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libpthread/thread/thr_readv.c b/lib/libpthread/thread/thr_readv.c index c1965d8..2c66a98 100644 --- a/lib/libpthread/thread/thr_readv.c +++ b/lib/libpthread/thread/thr_readv.c @@ -42,7 +42,7 @@ #include "pthread_private.h" ssize_t -_libc_readv(int fd, const struct iovec * iov, int iovcnt) +_readv(int fd, const struct iovec * iov, int iovcnt) { int ret; int type; @@ -91,5 +91,5 @@ _libc_readv(int fd, const struct iovec * iov, int iovcnt) return (ret); } -__weak_reference(_libc_readv, readv); +__weak_reference(_readv, readv); #endif diff --git a/lib/libpthread/thread/thr_select.c b/lib/libpthread/thread/thr_select.c index a7ceecc..d0e61e2 100644 --- a/lib/libpthread/thread/thr_select.c +++ b/lib/libpthread/thread/thr_select.c @@ -45,8 +45,8 @@ #include "pthread_private.h" int -_libc_select(int numfds, fd_set * readfds, fd_set * writefds, fd_set * - exceptfds, struct timeval * timeout) +_select(int numfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds, + struct timeval * timeout) { struct timespec ts; int i, ret = 0, f_wait = 1; @@ -204,5 +204,5 @@ _libc_select(int numfds, fd_set * readfds, fd_set * writefds, fd_set * return (ret); } -__weak_reference(_libc_select, select); +__weak_reference(_select, select); #endif diff --git a/lib/libpthread/thread/thr_sem.c b/lib/libpthread/thread/thr_sem.c index 8adb0d4..d35f9bc 100644 --- a/lib/libpthread/thread/thr_sem.c +++ b/lib/libpthread/thread/thr_sem.c @@ -147,6 +147,8 @@ sem_wait(sem_t *sem) { int retval; + _thread_enter_cancellation_point(); + _SEM_CHECK_VALIDITY(sem); pthread_mutex_lock(&(*sem)->lock); @@ -162,6 +164,7 @@ sem_wait(sem_t *sem) retval = 0; RETURN: + _thread_leave_cancellation_point(); return retval; } diff --git a/lib/libpthread/thread/thr_sigaction.c b/lib/libpthread/thread/thr_sigaction.c index f2f7286..e0aa523 100644 --- a/lib/libpthread/thread/thr_sigaction.c +++ b/lib/libpthread/thread/thr_sigaction.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_sigaction(int sig, const struct sigaction * act, struct sigaction * oact) +_sigaction(int sig, const struct sigaction * act, struct sigaction * oact) { int ret = 0; struct sigaction gact; @@ -106,5 +106,5 @@ _libc_sigaction(int sig, const struct sigaction * act, struct sigaction * oact) return (ret); } -__weak_reference(_libc_sigaction, sigaction); +__weak_reference(_sigaction, sigaction); #endif diff --git a/lib/libpthread/thread/thr_sigpending.c b/lib/libpthread/thread/thr_sigpending.c index feb4300..a630f0c 100644 --- a/lib/libpthread/thread/thr_sigpending.c +++ b/lib/libpthread/thread/thr_sigpending.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_sigpending(sigset_t * set) +_sigpending(sigset_t * set) { int ret = 0; @@ -54,5 +54,5 @@ _libc_sigpending(sigset_t * set) return (ret); } -__weak_reference(_libc_sigpending, sigpending); +__weak_reference(_sigpending, sigpending); #endif diff --git a/lib/libpthread/thread/thr_sigprocmask.c b/lib/libpthread/thread/thr_sigprocmask.c index 28ab4fa..b10089c 100644 --- a/lib/libpthread/thread/thr_sigprocmask.c +++ b/lib/libpthread/thread/thr_sigprocmask.c @@ -41,7 +41,7 @@ #include "pthread_private.h" int -_libc_sigprocmask(int how, const sigset_t * set, sigset_t * oset) +_sigprocmask(int how, const sigset_t * set, sigset_t * oset) { int ret = 0; @@ -90,5 +90,5 @@ _libc_sigprocmask(int how, const sigset_t * set, sigset_t * oset) return (ret); } -__weak_reference(_libc_sigprocmask, sigprocmask); +__weak_reference(_sigprocmask, sigprocmask); #endif diff --git a/lib/libpthread/thread/thr_sigsuspend.c b/lib/libpthread/thread/thr_sigsuspend.c index b64897a..28959c8 100644 --- a/lib/libpthread/thread/thr_sigsuspend.c +++ b/lib/libpthread/thread/thr_sigsuspend.c @@ -38,7 +38,7 @@ #include "pthread_private.h" int -_libc_sigsuspend(const sigset_t * set) +_sigsuspend(const sigset_t * set) { int ret = -1; sigset_t oset; @@ -68,5 +68,15 @@ _libc_sigsuspend(const sigset_t * set) return (ret); } -__weak_reference(_libc_sigsuspend, sigsuspend); +int +sigsuspend(const sigset_t * set) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = _sigsuspend(set); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libpthread/thread/thr_sigwait.c b/lib/libpthread/thread/thr_sigwait.c index faa227e..a509687 100644 --- a/lib/libpthread/thread/thr_sigwait.c +++ b/lib/libpthread/thread/thr_sigwait.c @@ -143,6 +143,7 @@ sigwait(const sigset_t * set, int *sig) } _thread_leave_cancellation_point(); + /* Return the completion status: */ return (ret); } diff --git a/lib/libpthread/thread/thr_sleep.c b/lib/libpthread/thread/thr_sleep.c new file mode 100644 index 0000000..34a5925 --- /dev/null +++ b/lib/libpthread/thread/thr_sleep.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +unsigned int +sleep(unsigned int seconds) +{ + unsigned int ret; + + _thread_enter_cancellation_point(); + ret = __sleep(seconds); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libpthread/thread/thr_spinlock.c b/lib/libpthread/thread/thr_spinlock.c index 4e94ffc..e797f90 100644 --- a/lib/libpthread/thread/thr_spinlock.c +++ b/lib/libpthread/thread/thr_spinlock.c @@ -90,7 +90,7 @@ _spinlock_debug(spinlock_t *lck, char *fname, int lineno) char str[256]; snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) was left locked from %s (%d)\n", __progname, _thread_run, lck, fname, lineno, lck->fname, lck->lineno); _thread_sys_write(2,str,strlen(str)); - sleep(1); + __sleep(1); cnt = 0; } diff --git a/lib/libpthread/thread/thr_system.c b/lib/libpthread/thread/thr_system.c new file mode 100644 index 0000000..9265975 --- /dev/null +++ b/lib/libpthread/thread/thr_system.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +int +system(const char *string) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = __system(string); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libpthread/thread/thr_tcdrain.c b/lib/libpthread/thread/thr_tcdrain.c new file mode 100644 index 0000000..d040599 --- /dev/null +++ b/lib/libpthread/thread/thr_tcdrain.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +int +tcdrain(int fd) +{ + int ret; + + _thread_enter_cancellation_point(); + ret = __tcdrain(fd); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libpthread/thread/thr_wait.c b/lib/libpthread/thread/thr_wait.c new file mode 100644 index 0000000..abc19cc --- /dev/null +++ b/lib/libpthread/thread/thr_wait.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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$ + */ + +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +pid_t +wait(int *istat) +{ + pid_t ret; + + _thread_enter_cancellation_point(); + ret = __wait(istat); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libpthread/thread/thr_wait4.c b/lib/libpthread/thread/thr_wait4.c index 4c3f1de..90eb0ab 100644 --- a/lib/libpthread/thread/thr_wait4.c +++ b/lib/libpthread/thread/thr_wait4.c @@ -38,11 +38,10 @@ #include "pthread_private.h" pid_t -_libc_wait4(pid_t pid, int *istat, int options, struct rusage * rusage) +_wait4(pid_t pid, int *istat, int options, struct rusage * rusage) { pid_t ret; - _thread_enter_cancellation_point(); _thread_kern_sig_defer(); /* Perform a non-blocking wait4 syscall: */ @@ -62,10 +61,9 @@ _libc_wait4(pid_t pid, int *istat, int options, struct rusage * rusage) } _thread_kern_sig_undefer(); - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_wait4, wait4); +__weak_reference(_wait4, wait4); #endif diff --git a/lib/libpthread/thread/thr_waitpid.c b/lib/libpthread/thread/thr_waitpid.c new file mode 100644 index 0000000..a847295 --- /dev/null +++ b/lib/libpthread/thread/thr_waitpid.c @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2000 Jason Evans . + * 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(s), this list of conditions and the following disclaimer as + * the first lines of this file unmodified other than the possible + * addition of one or more copyright notices. + * 2. Redistributions in binary form must reproduce the above copyright + * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 +#include +#ifdef _THREAD_SAFE +#include +#include "pthread_private.h" + +pid_t +waitpid(pid_t wpid, int *status, int options) +{ + pid_t ret; + + _thread_enter_cancellation_point(); + ret = __waitpid(wpid, status, options); + _thread_leave_cancellation_point(); + + return ret; +} +#endif diff --git a/lib/libpthread/thread/thr_write.c b/lib/libpthread/thread/thr_write.c index f25c606..6408a64 100644 --- a/lib/libpthread/thread/thr_write.c +++ b/lib/libpthread/thread/thr_write.c @@ -42,7 +42,7 @@ #include "pthread_private.h" ssize_t -_libc_write(int fd, const void *buf, size_t nbytes) +_write(int fd, const void *buf, size_t nbytes) { int blocking; int type; @@ -50,12 +50,9 @@ _libc_write(int fd, const void *buf, size_t nbytes) ssize_t num = 0; ssize_t ret; - _thread_enter_cancellation_point(); /* POSIX says to do just this: */ - if (nbytes == 0) { - _thread_leave_cancellation_point(); + if (nbytes == 0) return (0); - } /* Lock the file descriptor for write: */ if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) { @@ -67,7 +64,6 @@ _libc_write(int fd, const void *buf, size_t nbytes) /* File is not open for write: */ errno = EBADF; _FD_UNLOCK(fd, FD_WRITE); - _thread_leave_cancellation_point(); return (-1); } @@ -133,9 +129,18 @@ _libc_write(int fd, const void *buf, size_t nbytes) } _FD_UNLOCK(fd, FD_RDWR); } - _thread_leave_cancellation_point(); return (ret); } -__weak_reference(_libc_write, write); +ssize_t +write(int fd, const void *buf, size_t nbytes) +{ + ssize_t ret; + + _thread_enter_cancellation_point(); + ret = _write(fd, buf, nbytes); + _thread_leave_cancellation_point(); + + return ret; +} #endif diff --git a/lib/libpthread/thread/thr_writev.c b/lib/libpthread/thread/thr_writev.c index 74da521..7c5fffe 100644 --- a/lib/libpthread/thread/thr_writev.c +++ b/lib/libpthread/thread/thr_writev.c @@ -44,7 +44,7 @@ #include "pthread_private.h" ssize_t -_libc_writev(int fd, const struct iovec * iov, int iovcnt) +_writev(int fd, const struct iovec * iov, int iovcnt) { int blocking; int idx = 0; @@ -201,5 +201,5 @@ _libc_writev(int fd, const struct iovec * iov, int iovcnt) return (ret); } -__weak_reference(_libc_writev, writev); +__weak_reference(_writev, writev); #endif -- cgit v1.1